From 9045b75b51cf245fcfc1b28066e62cb55ad517d2 Mon Sep 17 00:00:00 2001 From: "deepin-community-bot[bot]" <156989552+deepin-community-bot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 04:51:09 +0000 Subject: [PATCH 1/2] feat: update qtwebengine-opensource-src to 5.15.17+dfsg-3 --- .gitignore | 1 - .qmake.conf | 2 +- .tag | 2 +- CHROMIUM_VERSION | 2 +- config_help.txt | 1 + configure.pri | 35 +- debian/changelog | 123 +- debian/clean | 1 + debian/control | 65 +- debian/copyright | 106 +- debian/libqt5pdf5.symbols | 4 +- debian/libqt5webengine5.symbols | 2 +- debian/libqt5webenginecore5.symbols | 244 +- debian/libqt5webenginewidgets5.symbols | 2 +- debian/patches/Port-for-loongarch64.patch | 42362 --------------- debian/patches/add-riscv64-support.patch | 44231 ---------------- debian/patches/breakpad-getcontext.patch | 2 +- debian/patches/build-with-c++17.patch | 89 + debian/patches/chromium-python3.patch | 1687 - debian/patches/ffmpeg-x86-optimization.patch | 64 - debian/patches/fix-example-pro-files.patch | 2 +- debian/patches/icu74.patch | 17 - debian/patches/mips64el-no-dav1d.patch | 2 +- debian/patches/mips64el-ptrace-include.patch | 2 +- debian/patches/mips64el-v8-regexp.patch | 140 + debian/patches/ninja-1.12.patch | 47 + debian/patches/python3.11.patch | 46 - debian/patches/python3.12-imp.patch | 24 + debian/patches/python3.12-six.patch | 56 + debian/patches/python3.patch | 159 - debian/patches/sandbox-time64-syscalls.patch | 2 +- debian/patches/series | 11 +- debian/patches/system-openjpeg2.patch | 10 +- debian/patches/verbose-gn-bootstrap.patch | 2 +- debian/rules | 32 +- debian/source/lintian-overrides | 86 +- src/3rdparty/chromium/AUTHORS | 1 + .../address_space_randomization.h | 15 + .../page_allocator_constants.h | 62 +- .../partition_address_space.cc | 6 + .../partition_allocator/partition_alloc.cc | 2 +- .../partition_alloc_constants.h | 5 +- .../build/android/gyp/java_cpp_enum.py | 5 +- .../chromium/build/print_python_deps.py | 4 +- .../chromium/build/util/python2_action.py | 14 +- .../components/crx_file/crx_verifier.cc | 16 + .../protobufs/binary_proto_generator.py | 27 +- .../update_client/protocol_parser_json.cc | 2 +- .../components/variations/seed_response.h | 1 + .../service/generate_ui_string_overrider.py | 2 +- .../compositor_frame_sink_support.cc | 5 +- .../loader/navigation_url_loader_impl.cc | 4 +- .../web_contents_video_capture_device.cc | 19 +- .../renderer_host/render_frame_host_impl.cc | 35 +- .../tracing/generate_trace_viewer_grd.py | 2 +- .../browser/web_contents/web_contents_impl.cc | 5 + .../content/gpu/in_process_gpu_thread.cc | 8 + .../api/web_request/form_data_parser.cc | 4 +- .../gpu/config/gpu_control_list_format.txt | 7 +- .../gpu/config/gpu_driver_bug_workarounds.h | 1 + src/3rdparty/chromium/gpu/config/gpu_info.h | 9 +- src/3rdparty/chromium/gpu/config/gpu_util.cc | 22 + .../chromium/gpu/config/process_json.py | 9 +- .../chromium/ipc/ipc_mojo_bootstrap.cc | 43 +- .../formats/mp2t/ts_section_cets_pssh.cc | 5 + .../chromium/mojo/core/channel_posix.cc | 27 +- .../mojo/public/cpp/bindings/lib/message.cc | 2 +- .../mojo/public/tools/bindings/BUILD.gn | 2 + ...concatenate_and_replace_closure_exports.py | 2 +- .../tools/bindings/gen_data_files_list.py | 8 +- .../generators/mojom_java_generator.py | 4 + .../tools/mojom/mojom/generate/generator.py | 14 +- .../tools/mojom/mojom/generate/module.py | 3 +- .../mojom/mojom/generate/template_expander.py | 12 +- .../net/quic/quic_chromium_client_stream.cc | 4 + .../quiche/src/quic/core/quic_stream.h | 1 + .../sandbox/policy/mac/package_sb_file.py | 11 +- .../services/device/usb/mojo/device_impl.cc | 32 + .../services/network/network_context.cc | 11 + .../services/network/network_context.h | 13 +- .../public/cpp/source_stream_to_data_pipe.cc | 6 +- .../gpu/context_provider_command_buffer.cc | 24 +- .../cpp/gpu/context_provider_command_buffer.h | 34 +- .../libANGLE/renderer/vulkan/TextureVk.cpp | 23 +- .../scripts/bind_gen/blink_v8_bridge.py | 6 +- .../scripts/bind_gen/callback_interface.py | 2 +- .../bindings/scripts/bind_gen/code_node.py | 10 +- .../bindings/scripts/bind_gen/codegen_expr.py | 15 +- .../scripts/bind_gen/codegen_format.py | 2 +- .../scripts/bind_gen/codegen_utils.py | 2 +- .../bindings/scripts/bind_gen/dictionary.py | 2 +- .../bindings/scripts/bind_gen/interface.py | 82 +- .../scripts/bind_gen/mako_renderer.py | 2 +- .../bindings/scripts/bind_gen/style_format.py | 9 +- .../bindings/scripts/bind_gen/task_queue.py | 5 +- .../bindings/scripts/code_generator.py | 10 + .../scripts/generate_origin_trial_features.py | 4 +- .../bindings/scripts/idl_definitions.py | 8 +- .../renderer/bindings/scripts/idl_reader.py | 4 +- .../renderer/bindings/scripts/idl_types.py | 2 +- .../renderer/bindings/scripts/utilities.py | 28 +- .../renderer/bindings/scripts/v8_interface.py | 9 +- .../renderer/bindings/scripts/v8_methods.py | 4 + .../renderer/bindings/scripts/v8_utilities.py | 2 +- .../scripts/web_idl/callback_interface.py | 12 +- .../bindings/scripts/web_idl/database.py | 2 +- .../bindings/scripts/web_idl/exposure.py | 5 +- .../bindings/scripts/web_idl/function_like.py | 28 +- .../bindings/scripts/web_idl/idl_compiler.py | 21 +- .../bindings/scripts/web_idl/interface.py | 45 +- .../bindings/scripts/web_idl/ir_builder.py | 29 +- .../bindings/scripts/web_idl/make_copy.py | 7 + .../bindings/scripts/web_idl/namespace.py | 12 +- .../bindings/templates/dictionary_v8.cc.tmpl | 8 +- .../scripts/core/css/make_style_shorthands.py | 23 +- .../properties/make_css_property_instances.py | 4 +- .../blink/renderer/build/scripts/gperf.py | 2 +- .../blink/renderer/build/scripts/in_file.py | 2 +- .../renderer/build/scripts/in_generator.py | 5 + .../build/scripts/make_runtime_features.py | 2 +- .../scripts/templates/element_factory.cc.tmpl | 4 +- .../templates/element_type_helpers.cc.tmpl | 4 +- .../templates/element_type_helpers.h.tmpl | 2 +- .../build/scripts/templates/macros.tmpl | 4 +- .../templates/make_qualified_names.h.tmpl | 4 +- .../blink/renderer/core/fetch/body.cc | 7 +- .../blink/renderer/core/paint/BUILD.gn | 2 + .../blink/renderer/core/paint/DEPS | 2 + .../core/paint/image_element_timing.cc | 8 +- .../core/paint/image_element_timing.h | 6 +- .../core/paint/image_paint_timing_detector.cc | 44 +- .../core/paint/image_paint_timing_detector.h | 45 +- .../renderer/core/paint/media_record_id.cc | 27 + .../renderer/core/paint/media_record_id.h | 37 + .../blink/renderer/core/xml/xslt_processor.h | 5 + .../core/xml/xslt_processor_libxslt.cc | 4 + .../canvas2d/canvas_rendering_context_2d.cc | 50 +- .../canvas2d/canvas_rendering_context_2d.h | 2 - .../rtc_peer_connection_handler.cc | 17 +- .../modules/webaudio/analyser_node.cc | 11 +- .../modules/webaudio/audio_worklet_node.cc | 13 +- .../webaudio/audio_worklet_processor.cc | 6 + .../modules/webaudio/deferred_task_handler.cc | 10 + .../realtime_audio_destination_node.cc | 20 +- .../renderer/modules/webusb/usb_device.cc | 42 + .../platform/audio/audio_delay_dsp_kernel.cc | 2 +- .../cpu/arm/audio_delay_dsp_kernel_neon.cc | 7 +- .../cpu/x86/audio_delay_dsp_kernel_sse2.cc | 10 +- .../image-decoders/bmp/bmp_image_reader.cc | 43 +- .../peerconnection/webrtc_audio_sink.cc | 2 +- .../worker/non_main_thread_task_queue.cc | 4 + .../platform/text/text_break_iterator.cc | 4 +- .../presubmit/audit_non_blink_usage.py | 1 + .../sanitized/module_snapshot_sanitized.cc | 8 +- .../dawn/generator/generator_lib.py | 4 + .../devtools-frontend/src/BUILD.gn | 2 + .../src/front_end/dagre_layout/LICENSE | 21 - .../src/front_end/dagre_layout/README.md | 16 - .../src/front_end/dagre_layout/dagre.js | 11500 ---- .../scripts/build/build_inspector_overlay.py | 25 +- .../build/build_release_applications.py | 21 +- .../scripts/build/generate_devtools_grd.py | 4 +- .../src/scripts/build/modular_build.py | 6 +- .../ffmpeg/libavcodec/x86/mathops.h | 26 +- .../chromium/third_party/jinja2/tests.py | 6 +- .../source/libvpx/vp8/encoder/onyx_if.c | 5 + .../third_party/libwebp/src/dec/vp8l_dec.c | 46 +- .../third_party/libwebp/src/dec/vp8li_dec.h | 2 +- .../libwebp/src/utils/huffman_utils.c | 97 +- .../libwebp/src/utils/huffman_utils.h | 27 +- .../pdfium/fpdfsdk/pwl/cpwl_combo_box.h | 2 +- .../address_space_randomization.h | 15 + .../partition_allocator/page_allocator.cc | 8 + .../page_allocator_constants.h | 61 +- .../partition_allocator/partition_alloc.cc | 2 +- .../partition_alloc_constants.h | 5 +- .../perfetto/ext/base/circular_queue.h | 9 +- .../src/trace_processor/storage/metadata.h | 2 + .../src/trace_processor/storage/stats.h | 2 + .../trace_processor/tables/macros_internal.h | 2 + .../third_party/skia/src/core/SkPath.cpp | 79 +- .../skia/src/gpu/ops/GrDrawVerticesOp.cpp | 6 +- .../sqlite/src/amalgamation/sqlite3.c | 24 +- .../sqlite/src/amalgamation_dev/sqlite3.c | 6 +- .../third_party/sqlite/src/src/resolve.c | 7 +- .../third_party/sqlite/src/src/sqliteInt.h | 1 + .../webrtc/modules/pacing/packet_router.cc | 5 +- .../modules/rtp_rtcp/source/rtp_format_vp9.cc | 26 +- .../webrtc/rtc_base/system/file_wrapper.h | 1 + .../zlib/contrib/minizip/README.chromium | 3 + .../third_party/zlib/contrib/minizip/zip.c | 11 + .../tools/generate_stubs/generate_stubs.py | 10 +- src/3rdparty/chromium/tools/grit/grit/util.py | 2 +- .../tools/metrics/histograms/enums.xml | 4 + .../tools/metrics/structured/model.py | 2 +- .../tools/metrics/ukm/gen_builders.py | 5 +- .../chromium/tools/metrics/ukm/ukm_model.py | 4 +- .../chromium/ui/base/resource/data_pack.cc | 19 +- .../ui/base/resource/data_pack_literal.cc | 12 + .../ui/base/resource/data_pack_literal.h | 2 + .../ui/ozone/generate_constructor_list.py | 13 +- .../ui/ozone/generate_ozone_platform_list.py | 26 +- src/3rdparty/chromium/v8/include/v8-version.h | 2 +- .../chromium/v8/src/builtins/promise-any.tq | 12 +- .../v8/src/codegen/arm/register-arm.h | 6 + .../v8/src/codegen/arm64/register-arm64.h | 6 + .../chromium/v8/src/codegen/compiler.cc | 4 +- .../v8/src/codegen/mips64/register-mips64.h | 6 + .../v8/src/codegen/ppc/register-ppc.h | 6 + .../v8/src/codegen/s390/register-s390.h | 6 + .../js-native-context-specialization.cc | 12 +- .../chromium/v8/src/execution/isolate.cc | 16 +- .../regexp/arm/regexp-macro-assembler-arm.cc | 22 +- .../regexp/arm/regexp-macro-assembler-arm.h | 5 +- .../arm64/regexp-macro-assembler-arm64.cc | 14 +- .../arm64/regexp-macro-assembler-arm64.h | 6 +- .../ia32/regexp-macro-assembler-ia32.cc | 19 +- .../regexp/ia32/regexp-macro-assembler-ia32.h | 5 +- .../v8/src/regexp/regexp-macro-assembler.cc | 5 +- .../v8/src/regexp/regexp-macro-assembler.h | 2 +- .../regexp/x64/regexp-macro-assembler-x64.cc | 35 +- .../regexp/x64/regexp-macro-assembler-x64.h | 4 +- .../chromium/v8/src/runtime/runtime-object.cc | 160 - src/buildtools/config/support.pri | 10 +- src/buildtools/configure.json | 41 +- src/core/content_browser_client_qt.cpp | 9 + .../doc/src/qtwebengine-platform-notes.qdoc | 4 + 227 files changed, 2486 insertions(+), 101223 deletions(-) delete mode 100644 .gitignore delete mode 100644 debian/patches/Port-for-loongarch64.patch delete mode 100644 debian/patches/add-riscv64-support.patch create mode 100644 debian/patches/build-with-c++17.patch delete mode 100644 debian/patches/chromium-python3.patch delete mode 100644 debian/patches/ffmpeg-x86-optimization.patch delete mode 100644 debian/patches/icu74.patch create mode 100644 debian/patches/mips64el-v8-regexp.patch create mode 100644 debian/patches/ninja-1.12.patch delete mode 100644 debian/patches/python3.11.patch create mode 100644 debian/patches/python3.12-imp.patch create mode 100644 debian/patches/python3.12-six.patch delete mode 100644 debian/patches/python3.patch create mode 100644 src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.cc create mode 100644 src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.h delete mode 100644 src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/LICENSE delete mode 100644 src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/README.md delete mode 100644 src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/dagre.js diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 224e7f052e..0000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pc/ diff --git a/.qmake.conf b/.qmake.conf index a56fde9965..04aa122a8e 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -5,4 +5,4 @@ QTWEBENGINE_OUT_ROOT = $$shadowed($$PWD) load(qt_build_config) CONFIG += warning_clean -MODULE_VERSION = 5.15.15 +MODULE_VERSION = 5.15.17 diff --git a/.tag b/.tag index a76851c082..149fe6b312 100644 --- a/.tag +++ b/.tag @@ -1 +1 @@ -21ddfe15f638a36160cb11d00639c3126c1aed7c +17fd3176988586168bee8654008a097a5f23ec1d diff --git a/CHROMIUM_VERSION b/CHROMIUM_VERSION index d293d46b43..cfc4c49b38 100644 --- a/CHROMIUM_VERSION +++ b/CHROMIUM_VERSION @@ -1,2 +1,2 @@ Based on Chromium version: 87.0.4280.144 -Patched with security patches up to Chromium version: 108.0.5359.124 +Patched with security patches up to Chromium version: 123.0.6312.58 diff --git a/config_help.txt b/config_help.txt index 48236c18ab..d50892121c 100644 --- a/config_help.txt +++ b/config_help.txt @@ -15,6 +15,7 @@ WebEngine options: (Linux only) -webengine-pepper-plugins ...... Enable use of Pepper Flash and Widevine plugins [auto] + -webengine-python-version ...... Use specific python version for building [python2/python3] -webengine-printing-and-pdf .... Enable use of printing and output to PDF [auto] -webengine-proprietary-codecs .. Enable support for proprietary codecs [no] diff --git a/configure.pri b/configure.pri index 3a33bdc820..cb53c93b0a 100644 --- a/configure.pri +++ b/configure.pri @@ -12,12 +12,9 @@ defineTest(isPythonVersionSupported) { python_version ~= s/[()]//g python_version = $$split(python_version, ',') python_major_version = $$first(python_version) - greaterThan(python_major_version, 2) { - qtLog("Python version 3 is not supported by Chromium.") - return(false) - } python_minor_version = $$member(python_version, 1) python_patch_version = $$member(python_version, 2) + greaterThan(python_major_version, 2): greaterThan(python_minor_version, 7): return(true) greaterThan(python_major_version, 1): greaterThan(python_minor_version, 6): greaterThan(python_patch_version, 4): return(true) qtLog("Unsupported python version: $${python_major_version}.$${python_minor_version}.$${python_patch_version}.") return(false) @@ -53,21 +50,37 @@ defineTest(qtConfReport_jumboBuild) { } defineTest(qtConfTest_detectPython2) { - python = $$qtConfFindInPath("python2$$EXE_SUFFIX") - isEmpty(python) { - qtLog("'python2$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.") - python = $$qtConfFindInPath("python$$EXE_SUFFIX") + pythonOverride = $$eval(config.input.python_override) + !isEmpty(pythonOverride) { + python = $$qtConfFindInPath("$$pythonOverride$$EXE_SUFFIX") + isEmpty(python) { + qtLog("User selected '$$pythonOverride$$EXE_SUFFIX' was not found in PATH. Giving up.") + return(false) + } } + + win32 { + # the default name of the python 2 executable on windows is just + # python, so try that first + isEmpty(python):python = $$qtConfFindInPath("python$$EXE_SUFFIX") + isEmpty(python):python = $$qtConfFindInPath("python2$$EXE_SUFFIX") + isEmpty(python):python = $$qtConfFindInPath("python3$$EXE_SUFFIX") + } else { + isEmpty(python):python = $$qtConfFindInPath("python2$$EXE_SUFFIX") + isEmpty(python):python = $$qtConfFindInPath("python3$$EXE_SUFFIX") + isEmpty(python):python = $$qtConfFindInPath("python$$EXE_SUFFIX") + } + isEmpty(python) { - qtLog("'python$$EXE_SUFFIX' not found in PATH. Giving up.") + qtLog("Python not found in PATH. Giving up.") return(false) } !isPythonVersionSupported($$python) { - qtLog("A suitable Python 2 executable could not be located.") + qtLog("A suitable Python executable could not be located.") return(false) } - # Make tests.python2.location available in configure.json. + # Make tests.python.location available in configure.json. $${1}.location = $$clean_path($$python) export($${1}.location) $${1}.cache += location diff --git a/debian/changelog b/debian/changelog index 225e9528b4..4aa25e4db2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,21 +1,126 @@ -qtwebengine-opensource-src (5.15.15+dfsg-3deepin3) unstable; urgency=medium +qtwebengine-opensource-src (5.15.17+dfsg-3) unstable; urgency=medium - * add LoongArch support + * Upload to unstable. + + -- Dmitry Shachnev Tue, 09 Jul 2024 14:43:34 +0300 + +qtwebengine-opensource-src (5.15.17+dfsg-2) experimental; urgency=medium + + * Backport v8 patch to port the latest RegExpMacroAssembler changes to + mips64el. + * Update debian/libqt5webenginecore5.symbols from buildds’ logs. + + -- Dmitry Shachnev Sun, 07 Jul 2024 11:44:46 +0300 - -- Shi Pujin Fri, 05 Jul 2024 14:19:06 +0800 +qtwebengine-opensource-src (5.15.17+dfsg-1) experimental; urgency=medium + + * New upstream release. + - Fixes build with libxml2 2.12 (closes: #1074671). + * Update SUBMODULE_COMMIT for the new release. + * Drop patches, included in the new release: + - python3.patch + - chromium-python3.patch + - python3.11.patch + - ffmpeg-x86-optimization.patch + - icu74.patch + * Also drop part of python3.12-imp.patch which was applied upstream. + * Refresh debian/patches/system-openjpeg2.patch. + * Update debian/libqt5webenginecore5.symbols from buildds’ logs. + * Bump ABI version to qtwebengine-abi-5-15-17. + * Pass QMAKE_PYTHON2=python3 to qmake, to get the docs built. + + -- Dmitry Shachnev Tue, 02 Jul 2024 22:53:32 +0300 + +qtwebengine-opensource-src (5.15.16+dfsg-5) unstable; urgency=medium + + * Add a patch from Arch Linux to build using C++17, which is required by ICU + 75. + * Cherry-pick upstream patches to build with Ninja 1.12. + * Mark applicable patches as "Forwarded: not-needed" to fix lintian errors. + * Update symbols files from local build log. + + -- Soren Stoutner Wed, 22 May 2024 12:37:00 -0700 + +qtwebengine-opensource-src (5.15.16+dfsg-4) unstable; urgency=medium + + * Upload to unstable. + + [ Soren Stoutner ] + * Merge 5.15.15+dfsg2-1 upload from unstable. + * Update symbols files from buildds’ logs. -qtwebengine-opensource-src (5.15.15+dfsg-3deepin2) unstable; urgency=medium + -- Dmitry Shachnev Tue, 21 May 2024 23:07:25 +0300 + +qtwebengine-opensource-src (5.15.16+dfsg-3) experimental; urgency=medium + + * Merge 5.15.15+dfsg-3 upload from unstable. + * Add upstream patches to stop using imp Python module (LP: #2058066). + Thanks Zixing Liu! + * Update bundled six module for Python 3.12 compatibility (LP: #2058117). + + -- Dmitry Shachnev Fri, 29 Mar 2024 16:12:37 +0300 + +qtwebengine-opensource-src (5.15.16+dfsg-2) experimental; urgency=medium + + * Replace pkg-config build-dependency with pkgconf. + * Build against Qt 5.15.13. + + -- Dmitry Shachnev Tue, 12 Mar 2024 18:00:47 +0300 + +qtwebengine-opensource-src (5.15.16+dfsg-1) experimental; urgency=medium + + [ Soren Stoutner ] + * New upstream release. + * Bump ABI version to qtwebengine-abi-5-15-16. + * Refresh python3.patch and system-openjpeg2.patch. + * Update symbols files. [ Dmitry Shachnev ] + * Build against Qt 5.15.12. * Add a patch from Gentoo to fix build with ICU 74. - -- Tianyu Chen Thu, 07 Mar 2024 14:40:40 +0800 + -- Dmitry Shachnev Mon, 25 Dec 2023 00:14:27 +0300 -qtwebengine-opensource-src (5.15.15+dfsg-3deepin1) unstable; urgency=medium +qtwebengine-opensource-src (5.15.15+dfsg2-1) unstable; urgency=medium - * Fix riscv64 build (closes: #1030916) + [ Soren Stoutner ] + * Drop the build depend on libre2-dev, which forces building with the bundled + RE2 (closes: #1053409). + * Bump standards version to 4.7.0 (no changes needed). + * Fix debian/rules to handle dfsg repack counts. + * Change my email address from soren@stoutner.com to soren@debian.org in the + following locations: + - debian/changelog + - debian/control + - debian/copyright + - debian/patches/fix-example-pro-files.patch + - debian/patches/system-openjpeg2.patch + * Add 2024 to debian/copyright entries. + * Update debian/libqt5webenginecore5.symbols from local build log. + + [ Dmitry Shachnev ] + * Add a patch from Gentoo to fix build with ICU 74. + * Replace pkg-config build-dependency with pkgconf. + * Add upstream patches to stop using imp Python module (LP: #2058066). + Thanks Zixing Liu! + * Update bundled six module for Python 3.12 compatibility (LP: #2058117). + + -- Soren Stoutner Thu, 09 May 2024 10:01:42 -0700 + +qtwebengine-opensource-src (5.15.15+dfsg-3) unstable; urgency=medium + + [ Soren Stoutner ] + * Remove unused build-depends on rollup (Closes: #1023334). + * Add Lintian overrides for source-is-missing false positives. + * Add Lintian override for missing-notice-file-for-apache-license false + positive. + * Correct BSD license text in debian/copyright. + * Build with the system version of dagre-layout. + + [ Dmitry Shachnev ] + * Update debian/libqt5webenginecore5.symbols for armhf (closes: #1067906). - -- Chang Yang Wed, 15 Nov 2023 21:11:30 +0800 + -- Dmitry Shachnev Fri, 29 Mar 2024 15:08:36 +0300 qtwebengine-opensource-src (5.15.15+dfsg-2) unstable; urgency=medium @@ -162,7 +267,7 @@ qtwebengine-opensource-src (5.15.12+dfsg-3) unstable; urgency=medium * Bump Standards-Version to 4.6.2, no changes needed. * Add myself to uploaders. - -- Soren Stoutner Wed, 01 Feb 2023 06:57:05 -0700 + -- Soren Stoutner Wed, 01 Feb 2023 06:57:05 -0700 qtwebengine-opensource-src (5.15.12+dfsg-2) unstable; urgency=medium diff --git a/debian/clean b/debian/clean index 2468547fe0..d8f3b1c7c1 100644 --- a/debian/clean +++ b/debian/clean @@ -38,6 +38,7 @@ src/*/*/*/Makefile src/*/*/Makefile src/*/Makefile src/*/Makefile.* +src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/ src/3rdparty/chromium/third_party/jstemplate/jstemplate_compiled.js src/3rdparty/gn/out/ src/Makefile diff --git a/debian/control b/debian/control index 997b82eab1..af2afb65f1 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Uploaders: Scarlett Moore , Sandro Knauß , Dmitry Shachnev , Simon Quigley , - Soren Stoutner + Soren Stoutner Section: libs Priority: optional Build-Depends: binutils (>= 2.32-8~), @@ -43,10 +43,9 @@ Build-Depends: binutils (>= 2.32-8~), libpng-dev, libprotobuf-dev, libpulse-dev, - libqt5opengl5-dev (>= 5.15.8), - libqt5svg5-dev (>= 5.15.7), - libqt5webchannel5-dev (>= 5.15.7), - libre2-dev, + libqt5opengl5-dev (>= 5.15.13+dfsg~), + libqt5svg5-dev (>= 5.15.13~), + libqt5webchannel5-dev (>= 5.15.13~), libsnappy-dev, libsqlite3-dev, libusb-1.0-0-dev, @@ -67,36 +66,36 @@ Build-Depends: binutils (>= 2.32-8~), libxtst-dev, mesa-common-dev, ninja-build, + node-dagre-layout, node-rollup-plugin-terser, node-yargs, nodejs (>= 16.14), - pkg-config, pkg-kde-tools, + pkgconf, protobuf-compiler, python3, - qtbase5-dev (>= 5.15.8), - qtbase5-private-dev (>= 5.15.8), - qtdeclarative5-private-dev (>= 5.15.8), - qtpositioning5-dev (>= 5.15.7), - qtquickcontrols2-5-dev (>= 5.15.7), - qttools5-dev (>= 5.15.8), + qtbase5-dev (>= 5.15.13+dfsg~), + qtbase5-private-dev (>= 5.15.13+dfsg~), + qtdeclarative5-private-dev (>= 5.15.13+dfsg~), + qtpositioning5-dev (>= 5.15.13+dfsg~), + qtquickcontrols2-5-dev (>= 5.15.13+dfsg~), + qttools5-dev (>= 5.15.13~), re2c, - rollup, ruby, xauth, xvfb, yui-compressor -Build-Depends-Indep: qdoc-qt5 (>= 5.15.7~) , - qhelpgenerator-qt5 (>= 5.15.7~) , - qtattributionsscanner-qt5 (>= 5.15.7~) , - qtbase5-doc-html (>= 5.15.7) -Standards-Version: 4.6.2 +Build-Depends-Indep: qdoc-qt5 (>= 5.15.13~) , + qhelpgenerator-qt5 (>= 5.15.13~) , + qtattributionsscanner-qt5 (>= 5.15.13~) , + qtbase5-doc-html (>= 5.15.13+dfsg~) +Standards-Version: 4.7.0 Vcs-Browser: https://salsa.debian.org/qt-kde-team/qt/qtwebengine Vcs-Git: https://salsa.debian.org/qt-kde-team/qt/qtwebengine.git Homepage: https://doc.qt.io/qt-5/qtwebengine-index.html Package: qtwebengine5-dev -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Section: libdevel Depends: libqt5webchannel5-dev, @@ -117,7 +116,7 @@ Description: Web content engine library for Qt - development files using QtWebEngine library. Package: qtwebengine5-private-dev -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Section: libdevel Depends: qtwebengine5-dev (= ${binary:Version}), ${misc:Depends} @@ -129,7 +128,7 @@ Description: Web content engine library for Qt - private development files Qt 5 applications using QtWebEngine library. Package: qtpdf5-dev -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Section: libdevel Depends: libqt5pdf5 (= ${binary:Version}), @@ -144,7 +143,7 @@ Description: Qt 5 PDF library - development files using Qt PDF library. Package: libqt5webengine5 -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: libqt5webengine-data (= ${source:Version}), ${misc:Depends}, @@ -157,9 +156,9 @@ Description: Web content engine library for Qt This package contains the QtWebEngine library. Package: libqt5webenginecore5 -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same -Provides: qtwebengine-abi-5-15-15 +Provides: qtwebengine-abi-5-15-17 Depends: libqt5webengine-data (= ${source:Version}), sse2-support [i386], ${misc:Depends}, @@ -174,7 +173,7 @@ Description: Web content engine library for Qt - Core This package contains the core QtWebEngine library. Package: libqt5webenginewidgets5 -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: libqt5webengine-data (= ${source:Version}), ${misc:Depends}, @@ -187,7 +186,7 @@ Description: Web content engine library for Qt - Widget This package contains the widget QtWebEngine library. Package: libqt5pdf5 -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF library @@ -196,7 +195,7 @@ Description: Qt 5 PDF library This package contains the Qt PDF library. Package: libqt5pdfwidgets5 -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF Widgets library @@ -216,7 +215,7 @@ Description: Web content engine library for Qt - Data This package contains the arch independent parts of QtWebEngine libraries. Package: qt5-image-formats-plugin-pdf -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF image format plugin @@ -226,7 +225,7 @@ Description: Qt 5 PDF image format plugin to view PDF files (the first page of PDF will be shown). Package: qml-module-qtwebengine -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: qml-module-qtquick2, ${misc:Depends}, ${shlibs:Depends} Pre-Depends: ${misc:Pre-Depends} @@ -237,7 +236,7 @@ Description: Qt WebEngine QML module This package contains the WebEngine QML module for QtDeclarative. Package: qml-module-qtquick-pdf -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: qml-module-qtgraphicaleffects (>= 5.12), qml-module-qtquick-controls2 (>= 5.14), @@ -254,7 +253,7 @@ Description: Qt Quick PDF QML module This package contains the Qt Quick PDF QML module. Package: qtwebengine5-dev-tools -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: foreign Section: devel Depends: qtchooser, ${misc:Depends}, ${shlibs:Depends} @@ -267,7 +266,7 @@ Description: Qt WebEngine tools in Qt WebEngine. Package: qtwebengine5-examples -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: libjs-jquery, libjs-marked, @@ -292,7 +291,7 @@ Description: Qt WebEngine - Examples This package contains the WebEngine examples. Package: qtpdf5-examples -Architecture: amd64 arm64 armhf i386 loong64 mips64el riscv64 +Architecture: amd64 arm64 armhf i386 mips64el Multi-Arch: same Depends: qml-module-qtquick-pdf (= ${binary:Version}), ${misc:Depends}, diff --git a/debian/copyright b/debian/copyright index f8e99e9449..77bfacb8c8 100644 --- a/debian/copyright +++ b/debian/copyright @@ -32,6 +32,7 @@ Files-Excluded: src/3rdparty/chromium/build/android/CheckInstallApk-debug.apk src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/elf/elf_image_reader_fuzzer_corpus src/3rdparty/chromium/third_party/crashpad/crashpad/third_party/apple_cf/* src/3rdparty/chromium/third_party/crashpad/crashpad/util/misc/capture_context_win_arm64.obj + src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/diff/diff_match_patch.js src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/acorn/package/dist/acorn.js src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/lighthouse-dt-bundle.js @@ -85,8 +86,8 @@ License: LGPL-3 or GPL-2 Files: debian/* Copyright: 2016-2019 Scarlett Moore 2016-2017 Sandro Knauß - 2017-2023 Dmitry Shachnev - 2023 Soren Stoutner + 2017-2024 Dmitry Shachnev + 2023-2024 Soren Stoutner License: LGPL-3 Files: config.tests/* @@ -112,6 +113,21 @@ Files: src/3rdparty/chromium/* Copyright: 2015-2021 The Chromium Authors License: BSD-3-clause +Files: src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/intl-messageformat/* +Copyright: 2013-2014 Yahoo! Inc. + 2012 Andreas Lind Petersen + 2019 Oath Inc. +License: BSD-3-clause + +Files: src/3rdparty/chromium/third_party/ukey2/* +Copyright: 2018-2020 Google LLC +License: Apache-2.0 + +Files: src/3rdparty/chromium/third_party/ukey2/BUILD.gn + src/3rdparty/chromium/third_party/ukey2/fuzzers/BUILD.gn +Copyright: 2020 The Chromium Authors +License: BSD-3-clause + Files: src/3rdparty/gn/* Copyright: 2015-2020 The Chromium Authors License: BSD-3-clause @@ -536,10 +552,6 @@ Files: src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_p Copyright: i18n developers License: Apache-2.0 -Files: src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/intl-messageformat/* -Copyright: intl-messageformat developers -License: BSD-3-clause - Files: src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/* Copyright: lighthouse developers License: Apache-2.0 @@ -1277,10 +1289,6 @@ Files: src/3rdparty/chromium/third_party/ub-uiautomator/* Copyright: uiautomator (unbundled) developers License: Apache-2.0 -Files: src/3rdparty/chromium/third_party/ukey2/* -Copyright: Ukey2 developers -License: Apache-2.0 - Files: src/3rdparty/chromium/third_party/usb_ids/* Copyright: usb-ids developers License: BSD-3-clause @@ -1865,48 +1873,48 @@ License: bitstream-vera License: BSD-2-clause Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - . - THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, INC. OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: BSD-3-clause Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - . - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Neither the name of the authors nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the authors nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: BSL-1.0 Permission is hereby granted, free of charge, to any person or organization diff --git a/debian/libqt5pdf5.symbols b/debian/libqt5pdf5.symbols index e79bfe6ba6..a2fc676f07 100644 --- a/debian/libqt5pdf5.symbols +++ b/debian/libqt5pdf5.symbols @@ -1,4 +1,4 @@ -# SymbolsHelper-Confirmed: 5.15.15 amd64 arm64 armhf i386 mips64el +# SymbolsHelper-Confirmed: 5.15.16 amd64 libQt5Pdf.so.5 libqt5pdf5 #MINVER# * Build-Depends-Package: qtpdf5-dev Qt_5.0@Qt_5.0 5.15.1 @@ -178,9 +178,7 @@ libQt5Pdf.so.5 libqt5pdf5 #MINVER# (optional=templinst|subst)_ZNSt11_Deque_baseIjSaIjEE17_M_initialize_mapE{size_t}@Qt_5 5.15.1 (optional=templinst)_ZNSt11_Deque_baseIjSaIjEED1Ev@Qt_5 5.15.1 (optional=templinst)_ZNSt11_Deque_baseIjSaIjEED2Ev@Qt_5 5.15.1 - (optional=templinst)_ZNSt5dequeIN11CFX_XMLNode4TypeESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt5dequeIjSaIjEE17_M_reallocate_mapE{size_t}b@Qt_5 5.15.1 - (optional=templinst)_ZNSt5dequeIwSaIwEE12emplace_backIJwEEEvDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt6vectorI18UnsupportedFeatureSaIS0_EE17_M_realloc_insertIJS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt6vectorIN10CPDF_Annot7SubtypeESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.1 diff --git a/debian/libqt5webengine5.symbols b/debian/libqt5webengine5.symbols index ba3ec78432..376ff0be4f 100644 --- a/debian/libqt5webengine5.symbols +++ b/debian/libqt5webengine5.symbols @@ -1,6 +1,6 @@ # SymbolsHelper-Confirmed: 5.15.5 amd64 libQt5WebEngine.so.5 libqt5webengine5 #MINVER# -| libqt5webengine5 #MINVER#, qtwebengine-abi-5-15-15 +| libqt5webengine5 #MINVER#, qtwebengine-abi-5-15-17 * Build-Depends-Package: qtwebengine5-dev Qt_5.0@Qt_5.0 5.7.1 Qt_5.10@Qt_5.10 5.10.1 diff --git a/debian/libqt5webenginecore5.symbols b/debian/libqt5webenginecore5.symbols index ad3cefe579..17f1ec3ce9 100644 --- a/debian/libqt5webenginecore5.symbols +++ b/debian/libqt5webenginecore5.symbols @@ -1,6 +1,6 @@ -# SymbolsHelper-Confirmed: 5.15.15 amd64 arm64 armhf i386 mips64el +# SymbolsHelper-Confirmed: 5.15.17 armhf i386 libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# -| libqt5webenginecore5 #MINVER#, qtwebengine-abi-5-15-15 +| libqt5webenginecore5 #MINVER#, qtwebengine-abi-5-15-17 * Build-Depends-Package: qtwebengine5-dev (optional=gold)Qt_5.0@Qt_5.0 5.7.1 (optional=gold)Qt_5.10@Qt_5.10 5.10.1 @@ -100,7 +100,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# _ZN15QtWebEngineCore14ProfileAdapter19visitedLinksManagerEv@Qt_5 5.12.2 _ZN15QtWebEngineCore14ProfileAdapter20setSpellCheckEnabledEb@Qt_5 5.12.2 _ZN15QtWebEngineCore14ProfileAdapter21defaultProfileAdapterEv@Qt_5 5.12.2 - _ZN15QtWebEngineCore14ProfileAdapter21determineDownloadPathERK7QStringS3_RKl@Qt_5 5.14.1 + (subst)_ZN15QtWebEngineCore14ProfileAdapter21determineDownloadPathERK7QStringS3_RK{time_t}@Qt_5 5.14.1 _ZN15QtWebEngineCore14ProfileAdapter21setHttpAcceptLanguageERK7QString@Qt_5 5.12.2 _ZN15QtWebEngineCore14ProfileAdapter21setRequestInterceptorEP31QWebEngineUrlRequestInterceptor@Qt_5 5.12.2 _ZN15QtWebEngineCore14ProfileAdapter21setVisitedLinksPolicyENS0_18VisitedLinksPolicyE@Qt_5 5.12.2 @@ -572,11 +572,20 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# _ZN40QWebEngineRegisterProtocolHandlerRequestC2E14QSharedPointerIN15QtWebEngineCore40RegisterProtocolHandlerRequestControllerEE@Qt_5 5.11.1 (optional=templinst)_ZN5blink8SetPixelIL13J_COLOR_SPACE2EEEvPjPPhi@Qt_5 5.10.1 (optional=templinst)_ZN5blink8SetPixelIL13J_COLOR_SPACE4EEEvPjPPhi@Qt_5 5.10.1 + (optional=templinst)_ZN6webrtc19ParseTypedParameterINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESt8optionalIT_ES6_@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterISt8optionalIbEEES1_IT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterISt8optionalIdEEES1_IT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterISt8optionalIiEEES1_IT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterISt8optionalIjEEES1_IT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterIbEESt8optionalIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterIdEESt8optionalIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterIiEESt8optionalIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 + (optional=templinst)_ZN6webrtc19ParseTypedParameterIjEESt8optionalIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Qt_5 5.15.16 (optional=templinst|subst)_ZN6webrtc24DownmixInterleavedToMonoIsEEvPKT_{size_t}iPS1_@Qt_5 5.14.1 - _ZN7sandbox18localtime_overrideEPKl@Qt_5 5.12.2 - _ZN7sandbox20localtime64_overrideEPKl@Qt_5 5.12.2 - _ZN7sandbox20localtime_r_overrideEPKlP2tm@Qt_5 5.12.2 - _ZN7sandbox22localtime64_r_overrideEPKlP2tm@Qt_5 5.12.2 + (subst)_ZN7sandbox18localtime_overrideEPK{time_t}@Qt_5 5.12.2 + (subst)_ZN7sandbox20localtime64_overrideEPK{time_t}@Qt_5 5.12.2 + (subst)_ZN7sandbox20localtime_r_overrideEPK{time_t}P2tm@Qt_5 5.12.2 + (subst)_ZN7sandbox22localtime64_r_overrideEPK{time_t}P2tm@Qt_5 5.12.2 (optional=templinst|subst)_ZN8perfetto6legacy15ConvertThreadIdINS0_29PerfettoLegacyCurrentThreadIdEEEbRKT_P{uint64_t}PiS7_@Qt_5 5.15.2 _ZNK15QtWebEngineCore10UserScript10sourceCodeEv@Qt_5 5.7.1 _ZNK15QtWebEngineCore10UserScript14injectionPointEv@Qt_5 5.7.1 @@ -732,11 +741,22 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# _ZNK32QWebEngineClientCertificateStore12certificatesEv@Qt_5 5.14.1 _ZNK40QWebEngineRegisterProtocolHandlerRequest6originEv@Qt_5 5.11.1 _ZNK40QWebEngineRegisterProtocolHandlerRequest6schemeEv@Qt_5 5.11.1 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_SaIS5_ENSt8__detail9_IdentityESt8equal_toIS5_ESt4hashIS5_ENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb1ELb1ELb1EEEE19_M_find_before_nodeE{size_t}RKS5_{size_t}@Qt_5 5.15.16 (optional=templinst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_SaIS5_ENSt8__detail9_IdentityESt8equal_toIS5_ESt4hashIS5_ENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb1ELb1ELb1EEEE4findERKS5_@Qt_5 5.15.10 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3gpu5gles212ProgramCache19LinkedProgramStatusEESaISC_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSE_18_Mod_range_hashingENSE_20_Default_ranged_hashENSE_20_Prime_rehash_policyENSE_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media8EmeCodecEESaISA_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSC_18_Mod_range_hashingENSC_20_Default_ranged_hashENSC_20_Prime_rehash_policyENSC_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N6device5mojom10SensorTypeEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 (optional=templinst|arch=!i386 !mipsel)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N6device5mojom10SensorTypeEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_PKvESaISA_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSC_18_Mod_range_hashingENSC_20_Default_ranged_hashENSC_20_Prime_rehash_policyENSC_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 (optional=templinst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIS5_SaIS5_EEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 (optional=templinst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIS5_SaIS5_EEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIiSaIiEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_bESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 (optional=templinst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 + (optional=templinst|subst)_ZNKSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_jESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE19_M_find_before_nodeE{size_t}RS7_{size_t}@Qt_5 5.15.16 (optional=templinst|arch=i386)_ZNKSt10_HashtableIxxSaIxENSt8__detail9_IdentityESt8equal_toIxESt4hashIxENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE4findERKx@Qt_5 5.15.15 (optional=templinst|arch=armhf i386)_ZNKSt6bitsetILj64EE17_M_copy_to_stringIcSt11char_traitsIcESaIcEEEvRNSt7__cxx1112basic_stringIT_T0_T1_EES7_S7_@Qt_5 5.15.14 (optional=templinst)_ZNKSt7__cxx1112regex_traitsIcE16lookup_classnameIPKcEENS1_10_RegexMaskET_S6_b@Qt_5 5.14.1 @@ -757,12 +777,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt10_HashtableIN2ax5mojom15StringAttributeESt4pairIKS2_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE5clearEv@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt10_HashtableIN2ax5mojom16IntListAttributeESt4pairIKS2_St6vectorIiSaIiEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNSA_10_Hash_nodeIS8_Lb1EEE{size_t}@Qt_5 5.15.6 (optional=templinst)_ZNSt10_HashtableIN2ax5mojom16IntListAttributeESt4pairIKS2_St6vectorIiSaIiEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE5clearEv@Qt_5 5.14.1 - (optional=templinst)_ZNSt10_HashtableIN2ax5mojom16IntListAttributeESt4pairIKS2_St6vectorIiSaIiEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEED1Ev@Qt_5 5.15.15 - (optional=templinst)_ZNSt10_HashtableIN2ax5mojom16IntListAttributeESt4pairIKS2_St6vectorIiSaIiEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEED2Ev@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableIN2ax5mojom19StringListAttributeESt4pairIKS2_St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EEESaISE_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSG_18_Mod_range_hashingENSG_20_Default_ranged_hashENSG_20_Prime_rehash_policyENSG_17_Hashtable_traitsILb1ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNSG_10_Hash_nodeISE_Lb1EEE{size_t}@Qt_5 5.15.6 (optional=templinst)_ZNSt10_HashtableIN2ax5mojom19StringListAttributeESt4pairIKS2_St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EEESaISE_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSG_18_Mod_range_hashingENSG_20_Default_ranged_hashENSG_20_Prime_rehash_policyENSG_17_Hashtable_traitsILb1ELb0ELb1EEEE5clearEv@Qt_5 5.14.1 - (optional=templinst)_ZNSt10_HashtableIN2ax5mojom19StringListAttributeESt4pairIKS2_St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EEESaISE_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSG_18_Mod_range_hashingENSG_20_Default_ranged_hashENSG_20_Prime_rehash_policyENSG_17_Hashtable_traitsILb1ELb0ELb1EEEED1Ev@Qt_5 5.15.15 - (optional=templinst)_ZNSt10_HashtableIN2ax5mojom19StringListAttributeESt4pairIKS2_St6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISB_EEESaISE_ENSt8__detail10_Select1stESt8equal_toIS2_ESt4hashIS2_ENSG_18_Mod_range_hashingENSG_20_Default_ranged_hashENSG_20_Prime_rehash_policyENSG_17_Hashtable_traitsILb1ELb0ELb1EEEED2Ev@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableIN4quic13QuicErrorCodeESt4pairIKS1_{size_t}ESaIS4_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS6_10_Hash_nodeIS4_Lb0EEE{size_t}@Qt_5 5.15.6 (optional=templinst|subst)_ZNSt10_HashtableIN4quic13QuicErrorCodeESt4pairIKS1_{size_t}ESaIS4_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableIN4quic13QuicErrorCodeESt4pairIKS1_{size_t}ESaIS4_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev@Qt_5 5.15.15 @@ -784,8 +800,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|subst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIS5_SaIS5_EEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNSD_10_Hash_nodeISB_Lb1EEE{size_t}@Qt_5 5.15.6 (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIS5_SaIS5_EEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE5clearEv@Qt_5 5.10.1 (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIiSaIiEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE5clearEv@Qt_5 5.14.1 - (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_dESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE18_M_assign_elementsIRKSL_EEvOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_dESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 + (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_dESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE9_M_assignIRKSL_NSA_17_ReuseOrAllocNodeISaINSA_10_Hash_nodeIS8_Lb1EEEEEEEEvOT_RKT0_@Qt_5 5.15.16 (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_dESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEED1Ev@Qt_5 5.15.15 (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_dESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEED2Ev@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNSA_10_Hash_nodeIS8_Lb1EEE{size_t}@Qt_5 5.15.6 @@ -796,11 +812,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEED2Ev@Qt_5 5.15.15 (optional=templinst|arch=!i386 !mipsel)_ZNSt10_HashtableINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_jESaIS8_ENSt8__detail10_Select1stESt8equal_toIS5_ESt4hashIS5_ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb1ELb0ELb1EEEE4findERS7_@Qt_5 5.15.10 (optional=templinst|subst)_ZNSt10_HashtableIPvS0_SaIS0_ENSt8__detail9_IdentityESt8equal_toIS0_ESt4hashIS0_ENS2_18_Mod_range_hashingENS2_20_Default_ranged_hashENS2_20_Prime_rehash_policyENS2_17_Hashtable_traitsILb0ELb1ELb1EEEE8_M_eraseE{size_t}PNS2_15_Hash_node_baseEPNS2_10_Hash_nodeIS0_Lb0EEE@Qt_5 5.14.1 - (optional=templinst|subst|arch=!i386 !mipsel)_ZNSt10_HashtableIPvSt4pairIKS0_{size_t}ESaIS3_ENSt8__detail10_Select1stESt8equal_toIS0_ESt4hashIS0_ENS5_18_Mod_range_hashingENS5_20_Default_ranged_hashENS5_20_Prime_rehash_policyENS5_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS5_10_Hash_nodeIS3_Lb0EEE{size_t}@Qt_5 5.15.6 (optional=templinst)_ZNSt10_HashtableIiSt4pairIKiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev@Qt_5 5.15.15 (optional=templinst)_ZNSt10_HashtableIiSt4pairIKiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaIS8_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev@Qt_5 5.15.15 - (optional=templinst|subst)_ZNSt10_HashtableIiSt4pairIKiSt6vectorIiSaIiEEESaIS5_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS7_10_Hash_nodeIS5_Lb0EEE{size_t}@Qt_5 5.15.6 - (optional=templinst|subst)_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS4_10_Hash_nodeIS2_Lb0EEE{size_t}@Qt_5 5.15.6 (optional=templinst)_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED1Ev@Qt_5 5.15.15 (optional=templinst)_ZNSt10_HashtableIiSt4pairIKiiESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEED2Ev@Qt_5 5.15.15 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt10_HashtableIiSt4pairIKijESaIS2_ENSt8__detail10_Select1stESt8equal_toIiESt4hashIiENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeEjjPNS4_10_Hash_nodeIS2_Lb0EEEj@Qt_5 5.15.7 @@ -831,12 +844,11 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|subst)_ZNSt10_HashtableIjjSaIjENSt8__detail9_IdentityESt8equal_toIjESt4hashIjENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE8_M_eraseE{size_t}PNS1_15_Hash_node_baseEPNS1_10_Hash_nodeIjLb0EEE@Qt_5 5.14.1 (optional=templinst|subst|arch=armhf)_ZNSt10_HashtableIjjSaIjENSt8__detail9_IdentityESt8equal_toIjESt4hashIjENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEEC1IPKjEET_SG_{size_t}RKS6_RKS7_RKS8_RKS4_RKS2_RKS0_@Qt_5 5.14.1 (optional=templinst|subst|arch=armhf)_ZNSt10_HashtableIjjSaIjENSt8__detail9_IdentityESt8equal_toIjESt4hashIjENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEEC2IPKjEET_SG_{size_t}RKS6_RKS7_RKS8_RKS4_RKS2_RKS0_@Qt_5 5.14.1 - (optional=templinst|arch=!armhf !i386 !mipsel)_ZNSt10_HashtableImSt4pairIKmmESaIS2_ENSt8__detail10_Select1stESt8equal_toImESt4hashImENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeEmmPNS4_10_Hash_nodeIS2_Lb0EEEm@Qt_5 5.15.6 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt10_HashtableImmSaImENSt8__detail9_IdentityESt8equal_toImESt4hashImENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE8_M_eraseEmPNS1_15_Hash_node_baseEPNS1_10_Hash_nodeImLb0EEE@Qt_5 5.14.1 (optional=templinst)_ZNSt10_HashtableItSt4pairIKtSt6vectorIhSaIhEEESaIS5_ENSt8__detail10_Select1stESt8equal_toItESt4hashItENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb0ELb0ELb1EEEE5clearEv@Qt_5 5.9.0 - (optional=templinst|arch=!amd64 !arm64 !i386|subst)_ZNSt10_HashtableI{int64_t}{int64_t}SaI{int64_t}ENSt8__detail9_IdentityESt8equal_toI{int64_t}ESt4hashI{int64_t}ENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS1_10_Hash_nodeI{int64_t}Lb0EEE{size_t}@Qt_5 5.15.10 + (optional=templinst|arch=i386)_ZNSt10_HashtableIySt4pairIKyiESaIS2_ENSt8__detail10_Select1stESt8equal_toIyESt4hashIyENS4_18_Mod_range_hashingENS4_20_Default_ranged_hashENS4_20_Prime_rehash_policyENS4_17_Hashtable_traitsILb0ELb0ELb1EEEE4findERS1_@Qt_5 5.15.16 + (optional=templinst|arch=!i386|subst)_ZNSt10_HashtableI{int64_t}{int64_t}SaI{int64_t}ENSt8__detail9_IdentityESt8equal_toI{int64_t}ESt4hashI{int64_t}ENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS1_10_Hash_nodeI{int64_t}Lb0EEE{size_t}@Qt_5 5.15.10 (subst)_ZNSt10_HashtableI{size_t}St4pairIK{size_t}St10unique_ptrIA_cSt14default_deleteIS3_EEESaIS7_ENSt8__detail10_Select1stESt8equal_toI{size_t}ESt4hashI{size_t}ENS9_18_Mod_range_hashingENS9_20_Default_ranged_hashENS9_20_Prime_rehash_policyENS9_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS9_10_Hash_nodeIS7_Lb0EEE{size_t}@Qt_5 5.15.7 - (optional=templinst|subst)_ZNSt10_HashtableI{size_t}St4pairIK{size_t}St6vectorI{size_t}SaI{size_t}EEESaIS5_ENSt8__detail10_Select1stESt8equal_toI{size_t}ESt4hashI{size_t}ENS7_18_Mod_range_hashingENS7_20_Default_ranged_hashENS7_20_Prime_rehash_policyENS7_17_Hashtable_traitsILb0ELb0ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS7_10_Hash_nodeIS5_Lb0EEE{size_t}@Qt_5 5.15.6 (optional=templinst|subst)_ZNSt10_HashtableI{uint64_t}St4pairIK{uint64_t}NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaIS8_ENSt8__detail10_Select1stESt8equal_toI{uint64_t}ESt4hashI{uint64_t}ENSA_18_Mod_range_hashingENSA_20_Default_ranged_hashENSA_20_Prime_rehash_policyENSA_17_Hashtable_traitsILb0ELb0ELb1EEEE5clearEv@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableI{uint64_t}{uint64_t}SaI{uint64_t}ENSt8__detail9_IdentityESt8equal_toI{uint64_t}ESt4hashI{uint64_t}ENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEE21_M_insert_unique_nodeE{size_t}{size_t}PNS1_10_Hash_nodeI{uint64_t}Lb0EEE{size_t}@Qt_5 5.15.15 (optional=templinst|subst)_ZNSt10_HashtableI{uint64_t}{uint64_t}SaI{uint64_t}ENSt8__detail9_IdentityESt8equal_toI{uint64_t}ESt4hashI{uint64_t}ENS1_18_Mod_range_hashingENS1_20_Default_ranged_hashENS1_20_Prime_rehash_policyENS1_17_Hashtable_traitsILb0ELb1ELb1EEEEC1IN9__gnu_cxx17__normal_iteratorIP{uint64_t}St6vectorI{uint64_t}S0_EEEEET_SK_{size_t}RKS6_RKS4_RKS0_St17integral_constantIbLb1EE@Qt_5 5.15.15 @@ -859,7 +871,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt11_Deque_baseIjSaIjEE17_M_initialize_mapEm@Qt_5 5.7.1 (optional=templinst)_ZNSt11_Deque_baseIjSaIjEED1Ev@Qt_5 5.7.1 (optional=templinst)_ZNSt11_Deque_baseIjSaIjEED2Ev@Qt_5 5.7.1 - (optional=templinst|subst|arch=i386 mips64el mipsel)_ZNSt11_Deque_baseIlSaIlEE17_M_initialize_mapE{size_t}@Qt_5 5.14.1 + (optional=templinst|subst|arch=i386 mipsel)_ZNSt11_Deque_baseIlSaIlEE17_M_initialize_mapE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt11_Deque_baseIlSaIlEED1Ev@Qt_5 5.14.1 (optional=templinst)_ZNSt11_Deque_baseIlSaIlEED2Ev@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt11_Deque_baseImSaImEED1Ev@Qt_5 5.11.1 @@ -916,46 +928,30 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=i386)_ZNSt23mersenne_twister_engineIyLj64ELj312ELj156ELj31ELy13043109905998158313ELj29ELy6148914691236517205ELj17ELy8202884508482404352ELj37ELy18444473444759240704ELj43ELy6364136223846793005EE11_M_gen_randEv@Qt_5 5.15.10 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt23mersenne_twister_engineIyLj64ELj312ELj156ELj31ELy13043109905998158313ELj29ELy6148914691236517205ELj17ELy8202884508482404352ELj37ELy18444473444759240704ELj43ELy6364136223846793005EEclEv@Qt_5 5.15.7 (optional=templinst|subst)_ZNSt23mersenne_twister_engineI{size_t}L{size_t}32EL{size_t}624EL{size_t}397EL{size_t}31EL{size_t}2567483615EL{size_t}11EL{size_t}4294967295EL{size_t}7EL{size_t}2636928640EL{size_t}15EL{size_t}4022730752EL{size_t}18EL{size_t}1812433253EE11_M_gen_randEv@Qt_5 5.14.2 - (optional=templinst)_ZNSt5dequeIN11CFX_XMLNode4TypeESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.14.1 - (optional=templinst)_ZNSt5dequeIN3net19HostResolverManager8TaskTypeESaIS2_EE12emplace_backIJS2_EEEvDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt5dequeIN3net19HostResolverManager8TaskTypeESaIS2_EE17_M_push_front_auxIJS2_EEEvDpOT_@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt5dequeIN3net19HostResolverManager8TaskTypeESaIS2_EE17_M_reallocate_mapE{size_t}b@Qt_5 5.14.1 (optional=templinst)_ZNSt5dequeIN3net19HostResolverManager8TaskTypeESaIS2_EE8_M_eraseESt15_Deque_iteratorIS2_RS2_PS2_E@Qt_5 5.14.1 (optional=templinst|arch=armhf)_ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE16_M_push_back_auxIJS5_EEEvDpOT_@Qt_5 5.15.1 - (optional=templinst)_ZNSt5dequeINSt8__detail9_StateSeqINSt7__cxx1112regex_traitsIcEEEESaIS5_EE12emplace_backIJS5_EEEvDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt5dequeINSt8__detail9_StateSeqINSt7__cxx1112regex_traitsIcEEEESaIS5_EE16_M_push_back_auxIJRKS5_EEEvDpOT_@Qt_5 5.14.1 (optional=templinst|arch=armhf mips64el mipsel)_ZNSt5dequeINSt8__detail9_StateSeqINSt7__cxx1112regex_traitsIcEEEESaIS5_EE16_M_push_back_auxIJS5_EEEvDpOT_@Qt_5 5.14.2 (optional=templinst|subst)_ZNSt5dequeINSt8__detail9_StateSeqINSt7__cxx1112regex_traitsIcEEEESaIS5_EE17_M_reallocate_mapE{size_t}b@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt5dequeISt4pairI{int64_t}iESaIS1_EE8_M_eraseESt15_Deque_iteratorIS1_RS1_PS1_ES7_@Qt_5 5.14.1 - (optional=templinst|subst)_ZNSt5dequeISt4pairI{size_t}{size_t}ESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.15.3 - (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt5dequeIdSaIdEE12emplace_backIJEEEvDpOT_@Qt_5 5.15.7 - (optional=templinst)_ZNSt5dequeIdSaIdEE12emplace_backIJdEEEvDpOT_@Qt_5 5.12.2 (optional=templinst|arch=i386)_ZNSt5dequeIdSaIdEE13_M_insert_auxIJRKdEEESt15_Deque_iteratorIdRdPdES8_DpOT_@Qt_5 5.15.2 (optional=templinst|subst)_ZNSt5dequeIdSaIdEE17_M_reallocate_mapE{size_t}b@Qt_5 5.15.2 (optional=templinst|subst)_ZNSt5dequeIfSaIfEE17_M_reallocate_mapE{size_t}b@Qt_5 5.14.1 - (optional=templinst)_ZNSt5dequeIiSaIiEE12emplace_backIJiEEEvDpOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt5dequeIiSaIiEE16_M_push_back_auxIJRKiEEEvDpOT_@Qt_5 5.7.1 - (optional=templinst)_ZNSt5dequeIiSaIiEE16_M_push_back_auxIJRiEEEvDpOT_@Qt_5 5.15.1 (optional=templinst|arch=armhf i386 mipsel)_ZNSt5dequeIiSaIiEE17_M_reallocate_mapEjb@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt5dequeIiSaIiEE17_M_reallocate_mapEmb@Qt_5 5.7.1 - (optional=templinst)_ZNSt5dequeIjSaIjEE12emplace_backIJRjEEEvDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt5dequeIjSaIjEE16_M_push_back_auxIJEEEvDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt5dequeIjSaIjEE16_M_push_back_auxIJRKjEEEvDpOT_@Qt_5 5.7.1 - (optional=templinst)_ZNSt5dequeIjSaIjEE16_M_push_back_auxIJRjEEEvDpOT_@Qt_5 5.15.1 (optional=templinst|arch=armhf i386 mipsel)_ZNSt5dequeIjSaIjEE17_M_reallocate_mapEjb@Qt_5 5.11.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt5dequeIjSaIjEE17_M_reallocate_mapEmb@Qt_5 5.11.1 (optional=templinst)_ZNSt5dequeIlSaIlEE16_M_push_back_auxIJRKlEEEvDpOT_@Qt_5 5.14.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt5dequeIlSaIlEE16_M_push_back_auxIJlEEEvDpOT_@Qt_5 5.15.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt5dequeImSaImEE16_M_push_back_auxIJRKmEEEvDpOT_@Qt_5 5.15.3 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt5dequeImSaImEE17_M_reallocate_mapEmb@Qt_5 5.14.2 - (optional=templinst)_ZNSt5dequeIwSaIwEE12emplace_backIJwEEEvDpOT_@Qt_5 5.12.2 - (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt5dequeIxSaIxEE12emplace_backIJEEEvDpOT_@Qt_5 5.15.7 - (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt5dequeIxSaIxEE12emplace_backIJxEEEvDpOT_@Qt_5 5.15.1 (optional=templinst|arch=i386)_ZNSt5dequeIxSaIxEE13_M_insert_auxIJRKxEEESt15_Deque_iteratorIxRxPxES8_DpOT_@Qt_5 5.15.1 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt5dequeIxSaIxEE16_M_push_back_auxIJRKxEEEvDpOT_@Qt_5 5.15.1 (optional=templinst|arch=armhf mipsel)_ZNSt5dequeIxSaIxEE16_M_push_back_auxIJRxEEEvDpOT_@Qt_5 5.15.2 - (optional=templinst|arch=i386)_ZNSt5dequeIxSaIxEE16_M_push_back_auxIJxEEEvDpOT_@Qt_5 5.15.10 - (optional=templinst|subst)_ZNSt5dequeI{int64_t}SaI{int64_t}EE12emplace_backIJR{int64_t}EEEvDpOT_@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt5dequeI{int64_t}SaI{int64_t}EE16_M_push_back_auxIJEEEvDpOT_@Qt_5 5.15.6 (optional=templinst|subst)_ZNSt5dequeI{int64_t}SaI{int64_t}EE17_M_reallocate_mapE{size_t}b@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt6vectorI11PP_FileTypeSaIS0_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 @@ -1062,10 +1058,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorIN8perfetto15trace_processor18ThreadNamePriorityESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorIN8perfetto6protos3gen21ObservableEvents_TypeESaIS3_EE17_M_realloc_insertIJEEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorIN8perfetto6protos3gen21ObservableEvents_TypeESaIS3_EE17_M_realloc_insertIJRS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.2 - (optional=templinst)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJPcEEEvDpOT_@Qt_5 5.15.3 - (optional=templinst)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJRA_KcEEEvDpOT_@Qt_5 5.15.3 - (optional=templinst|arch=!armhf)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJRKS5_EEEvDpOT_@Qt_5 5.15.3 - (optional=templinst)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJRN4base16BasicStringPieceIS5_EEEEEvDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJS5_EEEvDpOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE13_M_insert_auxIS5_EEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEOT_@Qt_5 5.11.1 (optional=templinst|arch=armhf)_ZNSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE14_M_emplace_auxIJRKS5_EEEN9__gnu_cxx17__normal_iteratorIPS5_S7_EENSC_IPS9_S7_EEDpOT_@Qt_5 5.14.1 @@ -1090,9 +1082,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorINSt8__detail6_StateIcEESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIPFPKciESaIS3_EE17_M_realloc_insertIJRKS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.12.2 (optional=templinst)_ZNSt6vectorIPKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE17_M_realloc_insertIJS7_EEEvN9__gnu_cxx17__normal_iteratorIPS7_S9_EEDpOT_@Qt_5 5.12.2 - (optional=templinst)_ZNSt6vectorIPKcSaIS1_EE12emplace_backIJRA18_S0_EEEvDpOT_@Qt_5 5.14.1 - (optional=templinst)_ZNSt6vectorIPKcSaIS1_EE12emplace_backIJRA20_S0_EEEvDpOT_@Qt_5 5.14.1 - (optional=templinst)_ZNSt6vectorIPKcSaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.10.1 (optional=templinst|subst)_ZNSt6vectorIPKcSaIS1_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIPKcSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIPKcSaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 @@ -1110,14 +1099,12 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorIPhSaIS0_EE17_M_realloc_insertIJS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_@Qt_5 5.9.1 (optional=templinst|subst)_ZNSt6vectorIPhSaIS0_EE7reserveE{size_t}@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt6vectorIPsSaIS0_EE17_M_default_appendE{size_t}@Qt_5 5.15.2 - (optional=templinst)_ZNSt6vectorIPvSaIS0_EE12emplace_backIJS0_EEEvDpOT_@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt6vectorIPvSaIS0_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIPvSaIS0_EE17_M_realloc_insertIJRKS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIPvSaIS0_EE17_M_realloc_insertIJS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_@Qt_5 5.11.1 (optional=templinst|subst)_ZNSt6vectorIPvSaIS0_EE7reserveE{size_t}@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt6vectorIP{size_t}SaIS0_EE17_M_realloc_insertIJRKS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIS_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EESaIS7_EE17_M_realloc_insertIJRKS7_EEEvN9__gnu_cxx17__normal_iteratorIPS7_S9_EEDpOT_@Qt_5 5.9.1 - (optional=templinst)_ZNSt6vectorIS_IcSaIcEESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.15.6 (optional=templinst|subst)_ZNSt6vectorIS_IcSaIcEESaIS1_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIS_IcSaIcEESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIS_IfSaIfEESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.15 @@ -1129,6 +1116,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorIS_IhSaIhEESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|subst)_ZNSt6vectorIS_IhSaIhEESaIS1_EE17_M_realloc_insertIJ{size_t}EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.3 (optional=templinst|subst)_ZNSt6vectorIS_IiSaIiEESaIS1_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 + (optional=templinst)_ZNSt6vectorIS_IiSaIiEESaIS1_EE17_M_realloc_insertIJEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt6vectorIS_IjSaIjEESaIS1_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIS_IjSaIjEESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIS_ItSaItEESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.10 @@ -1136,12 +1124,13 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorISt10unique_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt14default_deleteIS6_EESaIS9_EE17_M_realloc_insertIJPS6_EEEvN9__gnu_cxx17__normal_iteratorIPS9_SB_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorISt10unique_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt14default_deleteIS6_EESaIS9_EE17_M_realloc_insertIJS9_EEEvN9__gnu_cxx17__normal_iteratorIPS9_SB_EEDpOT_@Qt_5 5.15.6 (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IcSaIcEESt14default_deleteIS2_EESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.6 - (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IdSaIdEESt14default_deleteIS2_EESaIS5_EE12emplace_backIJS5_EEEvDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IdSaIdEESt14default_deleteIS2_EESaIS5_EE17_M_realloc_insertIJEEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IdSaIdEESt14default_deleteIS2_EESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IiSaIiEESt14default_deleteIS2_EESaIS5_EE17_M_realloc_insertIJEEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorISt10unique_ptrIS_IiSaIiEESt14default_deleteIS2_EESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt6vectorISt10unique_ptrISt5arrayIhL{size_t}65536EESt14default_deleteIS2_EESaIS5_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 + (optional=templinst|arch=armhf mips64el|subst)_ZNSt6vectorISt17basic_string_viewIcSt11char_traitsIcEESaIS3_EE17_M_realloc_insertIJPKcRK{size_t}EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt6vectorISt17basic_string_viewIcSt11char_traitsIcEESaIS3_EE17_M_realloc_insertIJRKS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt6vectorISt4pairIN10variations5mojom19GoogleWebVisibilityENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Qt_5 5.15.3 (optional=templinst|subst)_ZNSt6vectorISt4pairIN2ax5mojom12IntAttributeEiESaIS4_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorISt4pairIN2ax5mojom12IntAttributeEiESaIS4_EE17_M_realloc_insertIJS4_EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.12.2 @@ -1176,8 +1165,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorISt4pairIN5blink5mojom21DocumentPolicyFeatureENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorISt4pairIN5blink5mojom23EffectiveConnectionTypeEiESaIS4_EE17_M_realloc_insertIJS4_EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.15.3 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIN5blink9scheduler26WebSchedulerTrackedFeatureEiESaIS4_EE17_M_realloc_insertIJRKS3_iEEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.15.7 - (optional=templinst|arch=i386)_ZNSt6vectorISt4pairIN6webrtc14Vp8FrameConfig18Vp8BufferReferenceEjESaIS4_EE12emplace_backIJS3_RjEEEvDpOT_@Qt_5 5.15.10 - (optional=templinst|arch=amd64 arm64)_ZNSt6vectorISt4pairIN6webrtc14Vp8FrameConfig18Vp8BufferReferenceEmESaIS4_EE12emplace_backIJS3_RmEEEvDpOT_@Qt_5 5.15.6 (optional=templinst|subst|arch=armhf mips64el mipsel)_ZNSt6vectorISt4pairIN6webrtc14Vp8FrameConfig18Vp8BufferReferenceE{size_t}ESaIS4_EE17_M_realloc_insertIJS3_R{size_t}EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorISt4pairIN7content14PermissionTypeEN5blink5mojom16PermissionStatusEESaIS6_EE13_M_insert_auxIS6_EEvN9__gnu_cxx17__normal_iteratorIPS6_S8_EEOT_@Qt_5 5.15.1 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIN7content14PermissionTypeEN5blink5mojom16PermissionStatusEESaIS6_EE17_M_realloc_insertIJRKS2_S5_EEEvN9__gnu_cxx17__normal_iteratorIPS6_S8_EEDpOT_@Qt_5 5.15.7 @@ -1186,8 +1173,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorISt4pairIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESB_ESaISC_EE17_M_realloc_insertIJSC_EEEvNS2_IPSC_SE_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN5blink5mojom21DocumentPolicyFeatureEESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN7network5mojom18WebClientHintsTypeEESaISA_EE17_M_realloc_insertIJSA_EEEvN9__gnu_cxx17__normal_iteratorIPSA_SC_EEDpOT_@Qt_5 5.15.3 - (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE12emplace_backIJS6_S6_EEEvDpOT_@Qt_5 5.11.1 - (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE12emplace_backIJS7_EEEvDpOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE14_M_emplace_auxIJRKS6_S6_EEEN9__gnu_cxx17__normal_iteratorIPS7_S9_EENSE_IPKS7_S9_EEDpOT_@Qt_5 5.14.2 (optional=templinst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE14_M_insert_rvalEN9__gnu_cxx17__normal_iteratorIPKS7_S9_EEOS7_@Qt_5 5.11.1 (optional=templinst|subst)_ZNSt6vectorISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_ESaIS7_EE17_M_default_appendE{size_t}@Qt_5 5.14.1 @@ -1223,6 +1208,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorISt4pairIPvS1_ESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorISt4pairIS0_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_EbESaIS8_EE17_M_realloc_insertIJS7_bEEEvN9__gnu_cxx17__normal_iteratorIPS8_SA_EEDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt6vectorISt4pairIS_IhSaIhEEtESaIS3_EE17_M_realloc_insertIJRKS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.9.1 + (optional=templinst)_ZNSt6vectorISt4pairISt17basic_string_viewIcSt11char_traitsIcEES4_ESaIS5_EE17_M_realloc_insertIJRKS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt6vectorISt4pairISt17basic_string_viewIcSt11char_traitsIcEES4_ESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt6vectorISt4pairISt5arrayIhL{size_t}32EES_IhSaIhEEESaIS5_EE17_M_realloc_insertIJS5_EEEvN9__gnu_cxx17__normal_iteratorIPS5_S7_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorISt4pairIccESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.14.1 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIcjESaIS1_EE17_M_realloc_insertIJRKcjEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 @@ -1246,6 +1233,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIibESaIS1_EE17_M_realloc_insertIJRiRbEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJRKiRiEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJRiRKiEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 + (optional=templinst|arch=armhf)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJRiS5_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorISt4pairIiiESaIS1_EE17_M_realloc_insertIJiiEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIijESaIS1_EE17_M_realloc_insertIJRKijEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.7 @@ -1256,10 +1244,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=armhf i386 mipsel)_ZNSt6vectorISt4pairIjN3gfx4Font6WeightEESaIS4_EE8_M_eraseEN9__gnu_cxx17__normal_iteratorIPS4_S6_EESA_@Qt_5 5.9.0 (optional=templinst)_ZNSt6vectorISt4pairIjN3net13AddressFamilyEESaIS3_EE17_M_realloc_insertIJS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.12.2 (optional=templinst|arch=armhf i386 mipsel)_ZNSt6vectorISt4pairIjbESaIS1_EE8_M_eraseEN9__gnu_cxx17__normal_iteratorIPS1_S3_EES7_@Qt_5 5.9.0 - (optional=templinst|arch=!mips64el !mipsel)_ZNSt6vectorISt4pairIjhESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt6vectorISt4pairIjhESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIjiESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 - (optional=templinst|arch=!armhf !mipsel)_ZNSt6vectorISt4pairIjjESaIS1_EE12emplace_backIJRjS5_EEEvDpOT_@Qt_5 5.15.6 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIjjESaIS1_EE14_M_insert_rvalEN9__gnu_cxx17__normal_iteratorIPKS1_S3_EEOS1_@Qt_5 5.9.1 (optional=templinst|arch=armhf mipsel)_ZNSt6vectorISt4pairIjjESaIS1_EE17_M_realloc_insertIJRjS5_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.1 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIjjESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 @@ -1272,10 +1258,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIjyESaIS1_EE17_M_realloc_insertIJRKjyEEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.14.2 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIjyESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.12.2 (optional=templinst|arch=mips64el)_ZNSt6vectorISt4pairIlN7content13LevelDBScopes18StartupCleanupTypeEESaIS4_EE17_M_realloc_insertIJRlS3_EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.15.6 - (optional=templinst|arch=!i386)_ZNSt6vectorISt4pairIlS_INSt7__cxx119sub_matchIN9__gnu_cxx17__normal_iteratorIPKcNS1_12basic_stringIcSt11char_traitsIcESaIcEEEEEEESaISD_EEESaISG_EE12emplace_backIJRlRKSF_EEEvDpOT_@Qt_5 5.14.2 (optional=templinst)_ZNSt6vectorISt4pairIlS_INSt7__cxx119sub_matchIN9__gnu_cxx17__normal_iteratorIPKcNS1_12basic_stringIcSt11char_traitsIcESaIcEEEEEEESaISD_EEESaISG_EE17_M_realloc_insertIJRlRKSF_EEEvNS4_IPSG_SI_EEDpOT_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorISt4pairIlS_IhSaIhEEESaIS3_EE17_M_realloc_insertIJRlS2_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.3 - (optional=templinst|arch=amd64 arm64)_ZNSt6vectorISt4pairIllESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.15.6 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorISt4pairIllESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorISt4pairIllESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorISt4pairImN3gfx13BaselineStyleEESaIS3_EE8_M_eraseEN9__gnu_cxx17__normal_iteratorIPS3_S5_EES9_@Qt_5 5.7.1 @@ -1299,7 +1283,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorISt4pairIttESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIxN7content13LevelDBScopes18StartupCleanupTypeEESaIS4_EE17_M_realloc_insertIJRxS3_EEEvN9__gnu_cxx17__normal_iteratorIPS4_S6_EEDpOT_@Qt_5 5.15.1 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIxS_IhSaIhEEESaIS3_EE17_M_realloc_insertIJRxS2_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.15.3 - (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIxxESaIS1_EE12emplace_backIJS1_EEEvDpOT_@Qt_5 5.14.2 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIxxESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorISt4pairIxxESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=!amd64 !arm64 !i386 !mips64el)_ZNSt6vectorISt4pairIxxESaIS1_EE6insertEN9__gnu_cxx17__normal_iteratorIPKS1_S3_EERS6_@Qt_5 5.14.2 @@ -1324,16 +1307,14 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|subst)_ZNSt6vectorISt5arrayIhL{size_t}16EESaIS1_EE17_M_realloc_insertIJS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_@Qt_5 5.15.1 (optional=templinst|subst)_ZNSt6vectorISt5arrayIsL{size_t}160EESaIS1_EE17_M_default_appendE{size_t}@Qt_5 5.15.1 (optional=templinst)_ZNSt6vectorISt5tupleIJttN6device10XInputTypeEEESaIS3_EE17_M_realloc_insertIJS3_EEEvN9__gnu_cxx17__normal_iteratorIPS3_S5_EEDpOT_@Qt_5 5.14.1 - (optional=templinst|arch=amd64 arm64 i386)_ZNSt6vectorISt8functionIFvN2v88internal4wasm16CompilationEventEEESaIS6_EE12emplace_backIJS6_EEEvDpOT_@Qt_5 5.15.6 (optional=templinst|arch=!amd64 !arm64 !i386)_ZNSt6vectorISt8functionIFvN2v88internal4wasm16CompilationEventEEESaIS6_EE17_M_realloc_insertIJS6_EEEvN9__gnu_cxx17__normal_iteratorIPS6_S8_EEDpOT_@Qt_5 5.15.8 (optional=templinst)_ZNSt6vectorISt8functionIFvvEESaIS2_EE17_M_realloc_insertIJRKS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Qt_5 5.15.2 (optional=templinst)_ZNSt6vectorISt8functionIFvvEESaIS2_EE17_M_realloc_insertIJS2_EEEvN9__gnu_cxx17__normal_iteratorIPS2_S4_EEDpOT_@Qt_5 5.15.3 (optional=templinst|subst)_ZNSt6vectorIaSaIaEE17_M_default_appendE{size_t}@Qt_5 5.14.1 - (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorIbSaIbEE13_M_insert_auxESt13_Bit_iteratorb@Qt_5 5.14.2 + (optional=templinst)_ZNSt6vectorIbSaIbEE13_M_insert_auxESt13_Bit_iteratorb@Qt_5 5.14.2 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt6vectorIbSaIbEE13_M_reallocateEj@Qt_5 5.11.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIbSaIbEE13_M_reallocateEm@Qt_5 5.14.2 + (optional=templinst|arch=amd64 arm64)_ZNSt6vectorIbSaIbEE13_M_reallocateEm@Qt_5 5.14.2 (optional=templinst|subst)_ZNSt6vectorIbSaIbEE14_M_fill_insertESt13_Bit_iterator{size_t}b@Qt_5 5.14.1 - (optional=templinst)_ZNSt6vectorIcSaIcEE12emplace_backIJcEEEvDpOT_@Qt_5 5.7.1 (optional=templinst|subst)_ZNSt6vectorIcSaIcEE17_M_default_appendE{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIcSaIcEE17_M_realloc_insertIJRKcEEEvN9__gnu_cxx17__normal_iteratorIPcS1_EEDpOT_@Qt_5 5.14.2 (optional=templinst)_ZNSt6vectorIcSaIcEE17_M_realloc_insertIJcEEEvN9__gnu_cxx17__normal_iteratorIPcS1_EEDpOT_@Qt_5 5.12.5 @@ -1351,7 +1332,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIfSaIfEE17_M_default_appendEm@Qt_5 5.7.1 (optional=templinst)_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJRKfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIfSaIfEE17_M_realloc_insertIJfEEEvN9__gnu_cxx17__normal_iteratorIPfS1_EEDpOT_@Qt_5 5.9.1 - (optional=templinst)_ZNSt6vectorIhSaIhEE12emplace_backIJhEEEvDpOT_@Qt_5 5.7.1 (optional=templinst|subst)_ZNSt6vectorIhSaIhEE14_M_fill_assignE{size_t}RKh@Qt_5 5.14.2 (optional=templinst|subst)_ZNSt6vectorIhSaIhEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPhS1_EE{size_t}RKh@Qt_5 5.14.1 (optional=templinst|arch=!i386 !mipsel)_ZNSt6vectorIhSaIhEE14_M_insert_rvalEN9__gnu_cxx17__normal_iteratorIPKhS1_EEOh@Qt_5 5.15.1 @@ -1359,9 +1339,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt6vectorIhSaIhEE17_M_realloc_insertIJRKhEEEvN9__gnu_cxx17__normal_iteratorIPhS1_EEDpOT_@Qt_5 5.9.1 (optional=templinst)_ZNSt6vectorIhSaIhEE17_M_realloc_insertIJhEEEvN9__gnu_cxx17__normal_iteratorIPhS1_EEDpOT_@Qt_5 5.9.1 (optional=templinst|subst)_ZNSt6vectorIhSaIhEE7reserveE{size_t}@Qt_5 5.14.1 - (optional=templinst)_ZNSt6vectorIiSaIiEE12emplace_backIJRKjEEEvDpOT_@Qt_5 5.14.1 - (optional=templinst)_ZNSt6vectorIiSaIiEE12emplace_backIJRiEEEvDpOT_@Qt_5 5.11.1 - (optional=templinst)_ZNSt6vectorIiSaIiEE12emplace_backIJiEEEvDpOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt6vectorIiSaIiEE14_M_emplace_auxIJRKiEEEN9__gnu_cxx17__normal_iteratorIPiS1_EENS6_IPS3_S1_EEDpOT_@Qt_5 5.11.1 (optional=templinst|subst)_ZNSt6vectorIiSaIiEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPiS1_EE{size_t}RKi@Qt_5 5.14.1 (optional=templinst)_ZNSt6vectorIiSaIiEE14_M_insert_rvalEN9__gnu_cxx17__normal_iteratorIPKiS1_EEOi@Qt_5 5.14.2 @@ -1369,6 +1346,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIiSaIiEE17_M_default_appendEm@Qt_5 5.11.1 (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.9.1 + (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKjEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.11.1 (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRjEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.15.3 (optional=templinst)_ZNSt6vectorIiSaIiEE17_M_realloc_insertIJiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Qt_5 5.9.1 @@ -1376,8 +1354,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=!i386 !mipsel)_ZNSt6vectorIiSaIiEE6insertEN9__gnu_cxx17__normal_iteratorIPKiS1_EERS4_@Qt_5 5.15.2 (optional=templinst|arch=armhf i386 mipsel)_ZNSt6vectorIiSaIiEE7reserveEj@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIiSaIiEE7reserveEm@Qt_5 5.7.1 - (optional=templinst)_ZNSt6vectorIjSaIjEE12emplace_backIJRjEEEvDpOT_@Qt_5 5.15.2 - (optional=templinst)_ZNSt6vectorIjSaIjEE12emplace_backIJjEEEvDpOT_@Qt_5 5.7.1 (optional=templinst|subst)_ZNSt6vectorIjSaIjEE14_M_fill_assignE{size_t}RKj@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt6vectorIjSaIjEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPjS1_EE{size_t}RKj@Qt_5 5.14.1 (optional=templinst|arch=armhf i386 mipsel)_ZNSt6vectorIjSaIjEE17_M_default_appendEj@Qt_5 5.7.1 @@ -1392,7 +1368,6 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIlSaIlEE17_M_default_appendEm@Qt_5 5.11.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIlSaIlEE17_M_realloc_insertIJRKlEEEvN9__gnu_cxx17__normal_iteratorIPlS1_EEDpOT_@Qt_5 5.9.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorIlSaIlEE17_M_realloc_insertIJlEEEvN9__gnu_cxx17__normal_iteratorIPlS1_EEDpOT_@Qt_5 5.9.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorImSaImEE12emplace_backIJmEEEvDpOT_@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorImSaImEE14_M_fill_insertEN9__gnu_cxx17__normal_iteratorIPmS1_EEmRKm@Qt_5 5.9.0 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorImSaImEE17_M_default_appendEm@Qt_5 5.11.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt6vectorImSaImEE17_M_realloc_insertIJRKmEEEvN9__gnu_cxx17__normal_iteratorIPmS1_EEDpOT_@Qt_5 5.9.1 @@ -1422,12 +1397,16 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|subst)_ZNSt7__cxx1112basic_stringItSt11char_traitsItESaItEE9_M_mutateE{size_t}{size_t}PKt{size_t}@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIS6_S5_ESt10_Select1stIS8_ESt4lessIS6_ESaIS8_EE24_M_get_insert_unique_posERS6_@Qt_5 5.9.0 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIS6_S5_ESt10_Select1stIS8_ESt4lessIS6_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS6_@Qt_5 5.9.0 + (optional=templinst)_ZNSt8_Rb_treeIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIS6_S6_ESt10_Select1stIS8_ESt4lessIS6_ESaIS8_EE22_M_emplace_hint_uniqueIJS7_IS5_S5_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIS6_S6_ESt10_Select1stIS8_ESt4lessIS6_ESaIS8_EE24_M_get_insert_unique_posERS6_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIS6_S6_ESt10_Select1stIS8_ESt4lessIS6_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS6_@Qt_5 5.15.16 (optional=templinst|arch=!armhf !i386 !mipsel)_ZNSt8_Rb_treeIN10extensions12PreloadCheck5ErrorES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE16_M_insert_uniqueIS2_EESt4pairISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIN10extensions3api10automation9EventTypeES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE16_M_insert_uniqueIRKS3_EESt4pairISt17_Rb_tree_iteratorIS3_EbEOT_@Qt_5 5.15.3 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIN16device_event_log7LogTypeES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE16_M_insert_uniqueIRKS1_EESt4pairISt17_Rb_tree_iteratorIS1_EbEOT_@Qt_5 5.10.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIN2ui12KeyboardCodeES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE16_M_insert_uniqueIRKS1_EESt4pairISt17_Rb_tree_iteratorIS1_EbEOT_@Qt_5 5.7.1 + (optional=templinst)_ZNSt8_Rb_treeIN3net23EffectiveConnectionTypeESt4pairIKS1_iESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE22_M_emplace_hint_uniqueIJS2_IS1_iEEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=!armhf !i386 !mips64el !mipsel)_ZNSt8_Rb_treeIN3net8HttpAuth6SchemeES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE16_M_insert_uniqueIRKS2_EESt4pairISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.14.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIN3rtc6Socket6OptionESt4pairIKS2_iESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE17_M_emplace_uniqueIJS3_IS2_iEEEES3_ISt17_Rb_tree_iteratorIS5_EbEDpOT_@Qt_5 5.11.2 + (optional=templinst)_ZNSt8_Rb_treeIN3rtc6Socket6OptionESt4pairIKS2_iESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE22_M_emplace_hint_uniqueIJS3_IS2_iEEEESt17_Rb_tree_iteratorIS5_ESt23_Rb_tree_const_iteratorIS5_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIN4base11UkmSourceId4TypeESt4pairIKS2_iESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE24_M_get_insert_unique_posERS4_@Qt_5 5.15.15 (optional=templinst|arch=amd64 arm64)_ZNSt8_Rb_treeIN4base11trace_event23MemoryDumpLevelOfDetailES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE16_M_insert_uniqueIS2_EESt4pairISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.9.0 (optional=templinst)_ZNSt8_Rb_treeIN5blink5mojom10WebFeatureES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE16_M_insert_uniqueIRKS2_EESt4pairISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.11.1 @@ -1443,9 +1422,9 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St9_IdentityIS5_ESt4lessIS5_ESaIS5_EE4findERKS5_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St9_IdentityIS5_ESt4lessIS5_ESaIS5_EE4swapERSB_@Qt_5 5.9.0 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St9_IdentityIS5_ESt4lessIS5_ESaIS5_EE5eraseERKS5_@Qt_5 5.7.1 - (optional=templinst|arch=amd64 arm64 armhf i386 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions13RulesRegistry24ProcessChangedRulesStateEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE17_M_emplace_uniqueIJS6_IS5_SA_EEEES6_ISt17_Rb_tree_iteratorISB_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions13RulesRegistry24ProcessChangedRulesStateEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE22_M_emplace_hint_uniqueIJS6_IS5_SA_EEEESt17_Rb_tree_iteratorISB_ESt23_Rb_tree_const_iteratorISB_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions13RulesRegistry24ProcessChangedRulesStateEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions13RulesRegistry24ProcessChangedRulesStateEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISB_ERS7_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions13RulesRegistry24ProcessChangedRulesStateEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISB_ERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions3api5power5LevelEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE11equal_rangeERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions3api5power5LevelEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N10extensions3api5power5LevelEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISC_ERS7_@Qt_5 5.14.1 @@ -1472,17 +1451,21 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3gpu11DomainGuiltEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE11equal_rangeERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3gpu11DomainGuiltEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3gpu11DomainGuiltEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3x114AtomEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE22_M_emplace_hint_uniqueIJRS7_RS9_EEESt17_Rb_tree_iteratorISA_ESt23_Rb_tree_const_iteratorISA_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3x114AtomEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.3 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3x114AtomEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.15.3 - (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media14CdmSessionTypeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE17_M_emplace_uniqueIJRS7_RS9_EEES6_ISt17_Rb_tree_iteratorISA_EbEDpOT_@Qt_5 5.10.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N3x114AtomEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.15.3 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media14CdmSessionTypeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE22_M_emplace_hint_uniqueIJRS7_RS9_EEESt17_Rb_tree_iteratorISA_ESt23_Rb_tree_const_iteratorISA_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media14CdmSessionTypeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media14CdmSessionTypeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N5media14CdmSessionTypeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE4findERS7_@Qt_5 5.10.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N6webrtc18InterLayerPredModeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N6webrtc18InterLayerPredModeEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.14.1 (optional=templinst|arch=!mipsel)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content23BackForwardCacheMetrics17NotRestoredReasonEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE11equal_rangeERS7_@Qt_5 5.15.2 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content23BackForwardCacheMetrics17NotRestoredReasonEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.2 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content23BackForwardCacheMetrics17NotRestoredReasonEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISB_ERS7_@Qt_5 5.15.2 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content30ChildProcessSecurityPolicyImpl13SecurityState19CommitRequestPolicyEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE22_M_emplace_hint_uniqueIJRS7_SB_EEESt17_Rb_tree_iteratorISC_ESt23_Rb_tree_const_iteratorISC_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content30ChildProcessSecurityPolicyImpl13SecurityState19CommitRequestPolicyEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE24_M_get_insert_unique_posERS7_@Qt_5 5.12.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content30ChildProcessSecurityPolicyImpl13SecurityState19CommitRequestPolicyEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISC_ERS7_@Qt_5 5.12.2 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content30ChildProcessSecurityPolicyImpl13SecurityState19CommitRequestPolicyEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISC_ERS7_@Qt_5 5.12.2 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N7content30ChildProcessSecurityPolicyImpl13SecurityState19CommitRequestPolicyEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE4findERS7_@Qt_5 5.12.2 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N8download15DownloadContentEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE24_M_get_insert_unique_posERS7_@Qt_5 5.12.2 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_N8download15DownloadContentEESt10_Select1stISA_ESt4lessIS5_ESaISA_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISA_ERS7_@Qt_5 5.12.2 @@ -1498,8 +1481,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE16_M_assign_uniqueIPKS8_EEvT_SI_@Qt_5 5.14.1 (optional=templinst|arch=!i386 !mipsel)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE16_M_emplace_equalIJS6_IS5_S5_EEEESt17_Rb_tree_iteratorIS8_EDpOT_@Qt_5 5.11.2 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJRS7_SG_EEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.15.10 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJS5_S5_EEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.12.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJS6_IS5_S5_EEEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.11.2 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJS5_S5_EEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJS6_IS5_S5_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE4findERS7_@Qt_5 5.7.1 @@ -1512,13 +1495,14 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_IiiEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE4findERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_IjjEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE24_M_get_insert_unique_posERS7_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_IjjEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS9_ERS7_@Qt_5 5.7.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_ImmEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE17_M_emplace_uniqueIJS6_IS5_S8_EEEES6_ISt17_Rb_tree_iteratorIS9_EbEDpOT_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_ImmEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS9_ERS7_@Qt_5 5.15.3 - (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_IyyEESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE17_M_emplace_uniqueIJS6_IS5_S8_EEEES6_ISt17_Rb_tree_iteratorIS9_EbEDpOT_@Qt_5 5.14.2 + (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_I{uint64_t}{uint64_t}EESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE22_M_emplace_hint_uniqueIJS6_IS5_S8_EEEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S6_I{uint64_t}{uint64_t}EESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.3 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE11equal_rangeERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE12_M_erase_auxESt23_Rb_tree_const_iteratorISF_ESN_@Qt_5 5.14.2 - (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE17_M_emplace_uniqueIJS6_IS5_SE_EEEES6_ISt17_Rb_tree_iteratorISF_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE22_M_emplace_hint_uniqueIJS6_IS5_SE_EEEESt17_Rb_tree_iteratorISF_ESt23_Rb_tree_const_iteratorISF_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISF_ERS7_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE4findERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St13unordered_setIiSt4hashIiESt8equal_toIiESaIiEEESt10_Select1stISF_ESt4lessIS5_ESaISF_EE4swapERSL_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St3mapIS5_S5_St4lessIS5_ESaIS6_IS7_S5_EEEESt10_Select1stISE_ESA_SaISE_EE11equal_rangeERS7_@Qt_5 5.14.1 @@ -1541,9 +1525,11 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIS6_IS5_S5_ESaIS9_EEESt10_Select1stISC_ESt4lessIS5_ESaISC_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISC_ERS7_@Qt_5 5.14.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIhSaIhEEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE24_M_get_insert_unique_posERS7_@Qt_5 5.9.0 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St6vectorIhSaIhEEESt10_Select1stISB_ESt4lessIS5_ESaISB_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorISB_ERS7_@Qt_5 5.9.0 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_bESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJRS7_bEEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_bESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJRS7_bEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_bESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_bESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE11equal_rangeERS7_@Qt_5 5.7.1 - (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJS6_IS5_iEEEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJS6_IS5_iEEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 i386 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_iESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE4findERS7_@Qt_5 5.7.1 @@ -1557,16 +1543,23 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_tESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_tESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS7_@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_{int64_t}ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE24_M_get_insert_unique_posERS7_@Qt_5 5.14.1 - (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_{size_t}ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE17_M_emplace_uniqueIJS6_IS5_{size_t}EEEES6_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_{size_t}ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE22_M_emplace_hint_uniqueIJS6_IS5_{size_t}EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_{size_t}ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE4findERS7_@Qt_5 5.14.1 - (optional=templinst|subst)_ZNSt8_Rb_treeIPKcSt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE17_M_emplace_uniqueIJS2_IS1_{size_t}EEEES2_ISt17_Rb_tree_iteratorIS4_EbEDpOT_@Qt_5 5.15.2 - (optional=templinst|subst)_ZNSt8_Rb_treeIPKcSt4pairIKS1_{uint64_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE17_M_emplace_uniqueIJRS1_iEEES2_ISt17_Rb_tree_iteratorIS4_EbEDpOT_@Qt_5 5.15.2 + (optional=templinst|arch=armhf)_ZNSt8_Rb_treeIPKcSt4pairIKS1_yESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE22_M_emplace_hint_uniqueIJRS1_iEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeIPKcSt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE22_M_emplace_hint_uniqueIJS2_IS1_{size_t}EEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64)_ZNSt8_Rb_treeIPKhS1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE16_M_insert_uniqueIRKS1_EESt4pairISt17_Rb_tree_iteratorIS1_EbEOT_@Qt_5 5.11.1 - (optional=templinst)_ZNSt8_Rb_treeIPvSt4pairIKS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS9_ESt4lessIS0_ESaIS9_EE17_M_emplace_uniqueIJRS0_S8_EEES1_ISt17_Rb_tree_iteratorIS9_EbEDpOT_@Qt_5 5.15.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_iESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE17_M_emplace_uniqueIJS1_IPhiEEEES1_ISt17_Rb_tree_iteratorIS3_EbEDpOT_@Qt_5 5.11.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_jESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE17_M_emplace_uniqueIJS1_IS0_jEEEES1_ISt17_Rb_tree_iteratorIS3_EbEDpOT_@Qt_5 5.14.2 - (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_jEEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE11equal_rangeERS4_@Qt_5 5.14.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_mEEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE11equal_rangeERS4_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeIPvSt4pairIKS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS9_ESt4lessIS0_ESaIS9_EE22_M_emplace_hint_uniqueIJRS0_S8_EEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS9_ESt4lessIS0_ESaIS9_EE24_M_get_insert_unique_posERS2_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS9_ESt4lessIS0_ESaIS9_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS9_ERS2_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIPvSt4pairIKS0_iESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE22_M_emplace_hint_uniqueIJS1_IPhiEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_iESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE24_M_get_insert_unique_posERS2_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_iESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS2_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIPvSt4pairIKS0_jESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE22_M_emplace_hint_uniqueIJS1_IS0_jEEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_jESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE24_M_get_insert_unique_posERS2_@Qt_5 5.15.16 + (optional=templinst|arch=mips64el)_ZNSt8_Rb_treeIPvSt4pairIKS0_jESt10_Select1stIS3_ESt4lessIS0_ESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS2_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_mEEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE11equal_rangeERS4_@Qt_5 5.14.1 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_mEEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS8_ERS4_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_{size_t}EEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE22_M_emplace_hint_uniqueIJRS4_S7_EEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeISt4pairIN2cc18PaintCacheDataTypeEjES0_IKS3_St14_List_iteratorIS0_IS3_{size_t}EEESt10_Select1stIS8_ESt4lessIS3_ESaIS8_EE4findERS4_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIN2cc22TransferCacheEntryTypeEjES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE16_M_insert_uniqueIRKS3_EES0_ISt17_Rb_tree_iteratorIS3_EbEOT_@Qt_5 5.12.2 (optional=templinst)_ZNSt8_Rb_treeISt4pairINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN5blink5mojom11StorageTypeEESA_St9_IdentityISA_ESt4lessISA_ESaISA_EE11equal_rangeERKSA_@Qt_5 5.11.1 @@ -1587,12 +1580,13 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIiiES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE17_M_emplace_uniqueIJRtS9_EEES0_ISt17_Rb_tree_iteratorIS1_EbEDpOT_@Qt_5 5.15.1 (optional=templinst|subst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIi{uint64_t}ES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE16_M_insert_uniqueIS1_EES0_ISt17_Rb_tree_iteratorIS1_EbEOT_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIjjES0_IKS1_St6vectorIjSaIjEEESt10_Select1stIS6_ESt4lessIS1_ESaIS6_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS6_ERS2_@Qt_5 5.14.1 - (optional=templinst)_ZNSt8_Rb_treeISt4pairIjjES0_IKS1_jESt10_Select1stIS3_ESt4lessIS1_ESaIS3_EE17_M_emplace_uniqueIJS1_RjEEES0_ISt17_Rb_tree_iteratorIS3_EbEDpOT_@Qt_5 5.15.2 + (optional=templinst)_ZNSt8_Rb_treeISt4pairIjjES0_IKS1_jESt10_Select1stIS3_ESt4lessIS1_ESaIS3_EE22_M_emplace_hint_uniqueIJS1_RjEEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIjjES0_IKS1_jESt10_Select1stIS3_ESt4lessIS1_ESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS2_@Qt_5 5.9.0 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt8_Rb_treeISt4pairIjjES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE16_M_insert_uniqueIS1_EES0_ISt17_Rb_tree_iteratorIS1_EbEOT_@Qt_5 5.14.2 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt4pairIttES0_IKS1_jESt10_Select1stIS3_ESt4lessIS1_ESaIS3_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS3_ERS2_@Qt_5 5.14.1 - (optional=templinst|subst)_ZNSt8_Rb_treeISt5tupleIJtj{size_t}{size_t}EESt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE17_M_emplace_uniqueIJS2_IS1_{size_t}EEEES2_ISt17_Rb_tree_iteratorIS4_EbEDpOT_@Qt_5 5.14.1 - (optional=templinst|subst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt5tupleIJtj{size_t}{size_t}EESt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE24_M_get_insert_unique_posERS3_@Qt_5 5.14.2 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt5tupleIJtjmmEESt4pairIKS1_mESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS3_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeISt5tupleIJtj{size_t}{size_t}EESt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE22_M_emplace_hint_uniqueIJS2_IS1_{size_t}EEEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeISt5tupleIJtj{size_t}{size_t}EESt4pairIKS1_{size_t}ESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE24_M_get_insert_unique_posERS3_@Qt_5 5.14.2 (optional=templinst|subst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt5tupleIJ{uint64_t}{uint64_t}jEES1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE17_M_emplace_uniqueIJRK{uint64_t}SA_RKjEEESt4pairISt17_Rb_tree_iteratorIS1_EbEDpOT_@Qt_5 5.15.1 (optional=templinst)_ZNSt8_Rb_treeISt6vectorIhSaIhEES2_St9_IdentityIS2_ESt4lessIS2_ESaIS2_EE24_M_get_insert_unique_posERKS2_@Qt_5 5.11.1 (optional=templinst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stISB_ESt4lessIS2_ESaISB_EE24_M_get_insert_unique_posERS4_@Qt_5 5.15.1 @@ -1601,65 +1595,84 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_S2_ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE24_M_get_insert_unique_posERS4_@Qt_5 5.9.0 (optional=templinst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_S2_ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS5_ERS4_@Qt_5 5.9.0 (optional=templinst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_S2_ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE4findERS4_@Qt_5 5.9.0 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_mESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE17_M_emplace_uniqueIJS3_IS2_mEEEES3_ISt17_Rb_tree_iteratorIS5_EbEDpOT_@Qt_5 5.14.2 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_jESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS5_ERS4_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_mESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS5_ERS4_@Qt_5 5.11.1 + (optional=templinst|subst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_{size_t}ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE22_M_emplace_hint_uniqueIJS3_IS2_{size_t}EEEESt17_Rb_tree_iteratorIS5_ESt23_Rb_tree_const_iteratorIS5_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_{size_t}ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE24_M_get_insert_unique_posERS4_@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt8_Rb_treeISt6vectorIhSaIhEESt4pairIKS2_{size_t}ESt10_Select1stIS5_ESt4lessIS2_ESaIS5_EE4findERS4_@Qt_5 5.14.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIffSt9_IdentityIfESt4lessIfESaIfEE16_M_insert_uniqueIfEESt4pairISt17_Rb_tree_iteratorIfEbEOT_@Qt_5 5.14.1 + (optional=templinst)_ZNSt8_Rb_treeIhSt4pairIKhSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_St4lessIS8_ESaIS0_IKS8_S8_EEEESt10_Select1stISF_ES9_IhESaISF_EE22_M_emplace_hint_uniqueIJRhRKSE_EEESt17_Rb_tree_iteratorISF_ESt23_Rb_tree_const_iteratorISF_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIhhSt9_IdentityIhESt4lessIhESaIhEE16_M_insert_uniqueIhEESt4pairISt17_Rb_tree_iteratorIhEbEOT_@Qt_5 5.14.2 - (optional=templinst|arch=!armhf)_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE17_M_emplace_uniqueIJRS2_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.10 - (optional=templinst|arch=amd64 arm64)_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE17_M_emplace_uniqueIJS0_IiiEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.6 + (optional=templinst)_ZNSt8_Rb_treeIiSt4pairIKiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIiESaIS8_EE22_M_emplace_hint_uniqueIJS0_IiS7_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIiSt4pairIKiS0_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiEESt10_Select1stIS9_ESt4lessIiESaIS9_EE22_M_emplace_hint_uniqueIJS0_IiS8_EEEESt17_Rb_tree_iteratorIS9_ESt23_Rb_tree_const_iteratorIS9_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=armhf mips64el)_ZNSt8_Rb_treeIiSt4pairIKiSt6vectorIS0_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_ESaIS9_EEESt10_Select1stISC_ESt4lessIiESaISC_EE22_M_emplace_hint_uniqueIJRiRSB_EEESt17_Rb_tree_iteratorISC_ESt23_Rb_tree_const_iteratorISC_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE22_M_emplace_hint_uniqueIJRS2_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIiSt4pairIKiiESt10_Select1stIS2_ESt4lessIiESaIS2_EE22_M_emplace_hint_uniqueIJS0_IiiEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeIiSt4pairIKijESt10_Select1stIS2_ESt4lessIiESaIS2_EE16_M_insert_uniqueIS2_EES0_ISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.15.3 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIiSt4pairIKimESt10_Select1stIS2_ESt4lessIiESaIS2_EE16_M_insert_uniqueIS2_EES0_ISt17_Rb_tree_iteratorIS2_EbEOT_@Qt_5 5.15.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIiSt4pairIKimESt10_Select1stIS2_ESt4lessIiESaIS2_EE17_M_emplace_uniqueIJiRKmEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.3 + (optional=templinst|subst)_ZNSt8_Rb_treeIiSt4pairIKi{uint64_t}ESt10_Select1stIS2_ESt4lessIiESaIS2_EE22_M_emplace_hint_uniqueIJRiRK{uint64_t}EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeIiSt4pairIKi{uint64_t}ESt10_Select1stIS2_ESt4lessIiESaIS2_EE22_M_emplace_hint_uniqueIJiRK{uint64_t}EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=!i386 !mipsel)_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE15_M_insert_equalIRKiEESt17_Rb_tree_iteratorIiEOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIRKiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE16_M_insert_uniqueIiEESt4pairISt17_Rb_tree_iteratorIiEbEOT_@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 armhf mips64el)_ZNSt8_Rb_treeIiiSt9_IdentityIiESt4lessIiESaIiEE17_M_emplace_uniqueIJRKiEEESt4pairISt17_Rb_tree_iteratorIiEbEDpOT_@Qt_5 5.14.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIjSt4pairIKjN7content22PepperVideoDecoderHost18PictureBufferStateEESt10_Select1stIS5_ESt4lessIjESaIS5_EE17_M_emplace_uniqueIJS0_IjS4_EEEES0_ISt17_Rb_tree_iteratorIS5_EbEDpOT_@Qt_5 5.11.2 + (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjN7content22PepperVideoDecoderHost18PictureBufferStateEESt10_Select1stIS5_ESt4lessIjESaIS5_EE22_M_emplace_hint_uniqueIJS0_IjS4_EEEESt17_Rb_tree_iteratorIS5_ESt23_Rb_tree_const_iteratorIS5_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjN7content22PepperVideoDecoderHost18PictureBufferStateEESt10_Select1stIS5_ESt4lessIjESaIS5_EE4swapERSB_@Qt_5 5.10.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIjSt4pairIKjNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIjESaIS8_EE17_M_emplace_uniqueIJS0_IjS7_EEEES0_ISt17_Rb_tree_iteratorIS8_EbEDpOT_@Qt_5 5.14.1 - (optional=templinst|arch=amd64 arm64)_ZNSt8_Rb_treeIjSt4pairIKjS0_IjjEESt10_Select1stIS3_ESt4lessIjESaIS3_EE17_M_emplace_uniqueIJRjS2_EEES0_ISt17_Rb_tree_iteratorIS3_EbEDpOT_@Qt_5 5.15.10 - (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjjESt10_Select1stIS2_ESt4lessIjESaIS2_EE17_M_emplace_uniqueIJRjSA_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIjSt4pairIKjjESt10_Select1stIS2_ESt4lessIjESaIS2_EE17_M_emplace_uniqueIJS0_IjjEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.11.2 - (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjtESt10_Select1stIS2_ESt4lessIjESaIS2_EE17_M_emplace_uniqueIJS0_IjtEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.1 - (optional=templinst|subst)_ZNSt8_Rb_treeIjSt4pairIKj{uint64_t}ESt10_Select1stIS2_ESt4lessIjESaIS2_EE17_M_emplace_uniqueIJS0_Ij{uint64_t}EEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.2 + (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIjESaIS8_EE22_M_emplace_hint_uniqueIJS0_IjS7_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=armhf)_ZNSt8_Rb_treeIjSt4pairIKjS0_IjjEESt10_Select1stIS3_ESt4lessIjESaIS3_EE22_M_emplace_hint_uniqueIJRjS2_EEESt17_Rb_tree_iteratorIS3_ESt23_Rb_tree_const_iteratorIS3_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 armhf mips64el)_ZNSt8_Rb_treeIjSt4pairIKjSt6vectorIjSaIjEEESt10_Select1stIS5_ESt4lessIjESaIS5_EE22_M_emplace_hint_uniqueIJiS4_EEESt17_Rb_tree_iteratorIS5_ESt23_Rb_tree_const_iteratorIS5_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 armhf mips64el)_ZNSt8_Rb_treeIjSt4pairIKjiESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJS0_IjiEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjjESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJRjSA_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjjESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJS0_IjjEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIjSt4pairIKjmESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJS0_IjmEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeIjSt4pairIKjtESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJS0_IjtEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIjSt4pairIKjyESt10_Select1stIS2_ESt4lessIjESaIS2_EE22_M_emplace_hint_uniqueIJS0_IjyEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE16_M_insert_uniqueIRKjEESt4pairISt17_Rb_tree_iteratorIjEbEOT_@Qt_5 5.7.1 (optional=templinst)_ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE16_M_insert_uniqueIjEESt4pairISt17_Rb_tree_iteratorIjEbEOT_@Qt_5 5.10.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKlSt5arrayIlLm5EEESt10_Select1stIS4_ESt4lessIlESaIS4_EE17_M_emplace_uniqueIJRlRS3_EEES0_ISt17_Rb_tree_iteratorIS4_EbEDpOT_@Qt_5 5.15.3 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKliESt10_Select1stIS2_ESt4lessIlESaIS2_EE17_M_emplace_uniqueIJRS2_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.10 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKllESt10_Select1stIS2_ESt4lessIlESaIS2_EE17_M_emplace_uniqueIJS0_IllEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.10 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKlNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIlESaIS8_EE22_M_emplace_hint_uniqueIJS0_IlS7_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKliESt10_Select1stIS2_ESt4lessIlESaIS2_EE22_M_emplace_hint_uniqueIJRS2_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKliESt10_Select1stIS2_ESt4lessIlESaIS2_EE22_M_emplace_hint_uniqueIJS0_IliEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIlSt4pairIKllESt10_Select1stIS2_ESt4lessIlESaIS2_EE22_M_emplace_hint_uniqueIJS0_IllEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIllSt9_IdentityIlESt4lessIlESaIlEE16_M_insert_uniqueIlEESt4pairISt17_Rb_tree_iteratorIlEbEOT_@Qt_5 5.11.1 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeImSt4pairIKmSt6vectorIiSaIiEEESt10_Select1stIS5_ESt4lessImESaIS5_EE17_M_emplace_uniqueIJRmS4_EEES0_ISt17_Rb_tree_iteratorIS5_EbEDpOT_@Qt_5 5.15.10 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeImmSt9_IdentityImESt4lessImESaImEE16_M_insert_uniqueIRKmEESt4pairISt17_Rb_tree_iteratorImEbEOT_@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeImmSt9_IdentityImESt4lessImESaImEE16_M_insert_uniqueImEESt4pairISt17_Rb_tree_iteratorImEbEOT_@Qt_5 5.11.1 - (optional=templinst)_ZNSt8_Rb_treeItSt4pairIKthESt10_Select1stIS2_ESt4lessItESaIS2_EE17_M_emplace_uniqueIJS0_IthEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.11.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeItSt4pairIKtjESt10_Select1stIS2_ESt4lessItESaIS2_EE17_M_emplace_uniqueIJRS2_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.12.2 - (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeItSt4pairIKtjESt10_Select1stIS2_ESt4lessItESaIS2_EE17_M_emplace_uniqueIJS0_ItjEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.6 - (optional=templinst|arch=!armhf !i386 !mipsel)_ZNSt8_Rb_treeItSt4pairIKttESt10_Select1stIS2_ESt4lessItESaIS2_EE17_M_emplace_uniqueIJRS1_RtEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.1 + (optional=templinst)_ZNSt8_Rb_treeItSt4pairIKthESt10_Select1stIS2_ESt4lessItESaIS2_EE22_M_emplace_hint_uniqueIJS0_IthEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeItSt4pairIKtjESt10_Select1stIS2_ESt4lessItESaIS2_EE22_M_emplace_hint_uniqueIJRS2_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeItSt4pairIKtjESt10_Select1stIS2_ESt4lessItESaIS2_EE22_M_emplace_hint_uniqueIJS0_ItjEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst)_ZNSt8_Rb_treeItSt4pairIKttESt10_Select1stIS2_ESt4lessItESaIS2_EE22_M_emplace_hint_uniqueIJRS1_RtEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIttSt9_IdentityItESt4lessItESaItEE16_M_insert_uniqueIRKtEESt4pairISt17_Rb_tree_iteratorItEbEOT_@Qt_5 5.7.1 (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8_Rb_treeIttSt9_IdentityItESt4lessItESaItEE16_M_insert_uniqueItEESt4pairISt17_Rb_tree_iteratorItEbEOT_@Qt_5 5.14.1 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxN7content27IndexedDBActiveBlobRegistry9BlobStateEESt10_Select1stIS5_ESt4lessIxESaIS5_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIxSt4pairIKxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIxESaIS8_EE22_M_emplace_hint_uniqueIJS0_IxS7_EEEESt17_Rb_tree_iteratorIS8_ESt23_Rb_tree_const_iteratorIS8_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIxESaIS8_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.16 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxSt3mapIxN7content27IndexedDBActiveBlobRegistry9BlobStateESt4lessIxESaIS0_IS1_S5_EEEESt10_Select1stISB_ES7_SaISB_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 - (optional=templinst|arch=i386 mipsel)_ZNSt8_Rb_treeIxSt4pairIKxSt5arrayIxLj5EEESt10_Select1stIS4_ESt4lessIxESaIS4_EE17_M_emplace_uniqueIJRxRS3_EEES0_ISt17_Rb_tree_iteratorIS4_EbEDpOT_@Qt_5 5.15.10 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxSt5arrayIxLj5EEESt10_Select1stIS4_ESt4lessIxESaIS4_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 - (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIxSt4pairIKxiESt10_Select1stIS2_ESt4lessIxESaIS2_EE17_M_emplace_uniqueIJRS2_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.15.10 + (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxSt5arrayIxLj5EEESt10_Select1stIS4_ESt4lessIxESaIS4_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_@Qt_5 5.15.16 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIxSt4pairIKxiESt10_Select1stIS2_ESt4lessIxESaIS2_EE22_M_emplace_hint_uniqueIJRS2_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIxSt4pairIKxiESt10_Select1stIS2_ESt4lessIxESaIS2_EE22_M_emplace_hint_uniqueIJS0_IxiEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=i386 mipsel)_ZNSt8_Rb_treeIxSt4pairIKxiESt10_Select1stIS2_ESt4lessIxESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.7.1 + (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxiESt10_Select1stIS2_ESt4lessIxESaIS2_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS2_ERS1_@Qt_5 5.15.16 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxjESt10_Select1stIS2_ESt4lessIxESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxtESt10_Select1stIS2_ESt4lessIxESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 + (optional=templinst|arch=armhf i386)_ZNSt8_Rb_treeIxSt4pairIKxxESt10_Select1stIS2_ESt4lessIxESaIS2_EE22_M_emplace_hint_uniqueIJS0_IxxEEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|arch=i386 mipsel)_ZNSt8_Rb_treeIxSt4pairIKxxESt10_Select1stIS2_ESt4lessIxESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.7.1 + (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxSt4pairIKxxESt10_Select1stIS2_ESt4lessIxESaIS2_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS2_ERS1_@Qt_5 5.15.16 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIxxSt9_IdentityIxESt4lessIxESaIxEE24_M_get_insert_unique_posERKx@Qt_5 5.15.15 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIySt4pairIKyNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEESt10_Select1stIS8_ESt4lessIyESaIS8_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIySt4pairIKyPKcESt10_Select1stIS4_ESt4lessIyESaIS4_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIySt4pairIKySt6vectorIiSaIiEEESt10_Select1stIS5_ESt4lessIyESaIS5_EE24_M_get_insert_unique_posERS1_@Qt_5 5.15.15 + (optional=templinst|arch=i386)_ZNSt8_Rb_treeIySt4pairIKySt6vectorIiSaIiEEESt10_Select1stIS5_ESt4lessIyESaIS5_EE29_M_get_insert_hint_unique_posESt23_Rb_tree_const_iteratorIS5_ERS1_@Qt_5 5.15.16 (optional=templinst|arch=i386 mipsel)_ZNSt8_Rb_treeIySt4pairIKyiESt10_Select1stIS2_ESt4lessIyESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.11.1 (optional=templinst|arch=i386 mipsel)_ZNSt8_Rb_treeIySt4pairIKyyESt10_Select1stIS2_ESt4lessIyESaIS2_EE24_M_get_insert_unique_posERS1_@Qt_5 5.9.0 (optional=templinst|arch=i386)_ZNSt8_Rb_treeIyySt9_IdentityIyESt4lessIyESaIyEE24_M_get_insert_unique_posERKy@Qt_5 5.15.15 - (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}iESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE17_M_emplace_uniqueIJR{int64_t}SA_EEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.14.1 - (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}iESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE17_M_emplace_uniqueIJS0_I{int64_t}iEEEES0_ISt17_Rb_tree_iteratorIS2_EbEDpOT_@Qt_5 5.14.1 + (optional=templinst|arch=amd64 arm64 armhf mips64el|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}St5arrayI{int64_t}L{size_t}5EEESt10_Select1stIS4_ESt4lessI{int64_t}ESaIS4_EE22_M_emplace_hint_uniqueIJR{int64_t}RS3_EEESt17_Rb_tree_iteratorIS4_ESt23_Rb_tree_const_iteratorIS4_EDpOT_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}iESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE22_M_emplace_hint_uniqueIJR{int64_t}SA_EEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}{int64_t}ESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE12_M_erase_auxESt23_Rb_tree_const_iteratorIS2_ESA_@Qt_5 5.14.1 + (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}{size_t}ESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE22_M_emplace_hint_uniqueIJRS0_I{int64_t}{size_t}EEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 + (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}St4pairIK{int64_t}{size_t}ESt10_Select1stIS2_ESt4lessI{int64_t}ESaIS2_EE22_M_emplace_hint_uniqueIJS0_I{int64_t}{size_t}EEEESt17_Rb_tree_iteratorIS2_ESt23_Rb_tree_const_iteratorIS2_EDpOT_@Qt_5 5.15.16 (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}{int64_t}St9_IdentityI{int64_t}ESt4lessI{int64_t}ESaI{int64_t}EE12_M_erase_auxESt23_Rb_tree_const_iteratorI{int64_t}ES7_@Qt_5 5.14.1 (optional=templinst|subst)_ZNSt8_Rb_treeI{int64_t}{int64_t}St9_IdentityI{int64_t}ESt4lessI{int64_t}ESaI{int64_t}EE16_M_insert_uniqueIRK{int64_t}EESt4pairISt17_Rb_tree_iteratorI{int64_t}EbEOT_@Qt_5 5.14.1 + (optional=templinst|subst)_ZNSt8_Rb_treeI{uint64_t}St4pairIK{uint64_t}St6vectorIiSaIiEEESt10_Select1stIS5_ESt4lessI{uint64_t}ESaIS5_EE22_M_emplace_hint_uniqueIJR{uint64_t}S4_EEESt17_Rb_tree_iteratorIS5_ESt23_Rb_tree_const_iteratorIS5_EDpOT_@Qt_5 5.15.16 (optional=templinst)_ZNSt8__detail17__regex_algo_implIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEESaINS5_9sub_matchISB_EEEcNS5_12regex_traitsIcEEEEbT_SH_RNS5_13match_resultsISH_T0_EERKNS5_11basic_regexIT1_T2_EENSt15regex_constants15match_flag_typeENS_20_RegexExecutorPolicyEb@Qt_5 5.15.10 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_@Qt_5 5.14.2 (optional=templinst)_ZNSt8__detail8_ScannerIcE12_M_eat_classEc@Qt_5 5.14.1 @@ -1669,8 +1682,8 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8__detail8_ScannerIcE18_M_eat_escape_ecmaEv@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail8_ScannerIcE18_M_scan_in_bracketEv@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail8_ScannerIcE19_M_eat_escape_posixEv@Qt_5 5.14.1 - (optional=templinst|arch=!arm64 !mips64el !mipsel)_ZNSt8__detail8_ScannerIcEC1EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale@Qt_5 5.14.1 - (optional=templinst|arch=!arm64 !mips64el !mipsel)_ZNSt8__detail8_ScannerIcEC2EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale@Qt_5 5.14.1 + (optional=templinst)_ZNSt8__detail8_ScannerIcEC1EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale@Qt_5 5.14.1 + (optional=templinst)_ZNSt8__detail8_ScannerIcEC2EPKcS3_NSt15regex_constants18syntax_option_typeESt6locale@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail9_CompilerINSt7__cxx1112regex_traitsIcEEE11_M_try_charEv@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail9_CompilerINSt7__cxx1112regex_traitsIcEEE12_M_assertionEv@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail9_CompilerINSt7__cxx1112regex_traitsIcEEE13_M_quantifierEv@Qt_5 5.14.1 @@ -1709,6 +1722,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_N5media8EmeCodecEESaISB_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixERS8_@Qt_5 5.14.1 (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_N6device5mojom10SensorTypeEESaISC_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixERS8_@Qt_5 5.10.1 (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_S6_ESaIS9_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixEOS6_@Qt_5 5.15.3 + (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_S6_ESaIS9_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixERS8_@Qt_5 5.15.16 (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_St6vectorIS6_SaIS6_EEESaISC_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixEOS6_@Qt_5 5.15.15 (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_St6vectorIS6_SaIS6_EEESaISC_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixERS8_@Qt_5 5.11.1 (optional=templinst)_ZNSt8__detail9_Map_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS6_iESaIS9_ENS_10_Select1stESt8equal_toIS6_ESt4hashIS6_ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb1ELb0ELb1EEELb1EEixEOS6_@Qt_5 5.10.1 @@ -1730,6 +1744,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=amd64 arm64 mips64el)_ZNSt8__detail9_Map_baseImSt4pairIKmiESaIS3_ENS_10_Select1stESt8equal_toImESt4hashImENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixEOm@Qt_5 5.15.2 (optional=templinst|arch=!amd64 !arm64 !mips64el)_ZNSt8__detail9_Map_baseIxSt4pairIKxjESaIS3_ENS_10_Select1stESt8equal_toIxESt4hashIxENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_@Qt_5 5.11.1 (subst)_ZNSt8__detail9_Map_baseI{size_t}St4pairIK{size_t}St10unique_ptrIA_cSt14default_deleteIS4_EEESaIS8_ENS_10_Select1stESt8equal_toI{size_t}ESt4hashI{size_t}ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_@Qt_5 5.14.1 + (optional=templinst|subst)_ZNSt8__detail9_Map_baseI{uint64_t}St4pairIK{uint64_t}iESaIS3_ENS_10_Select1stESt8equal_toI{uint64_t}ESt4hashI{uint64_t}ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_@Qt_5 5.15.16 (optional=templinst|subst|arch=amd64 arm64 mips64el)_ZNSt8__detail9_Map_baseI{uint64_t}St4pairIK{uint64_t}{uint64_t}ESaIS3_ENS_10_Select1stESt8equal_toI{uint64_t}ESt4hashI{uint64_t}ENS_18_Mod_range_hashingENS_20_Default_ranged_hashENS_20_Prime_rehash_policyENS_17_Hashtable_traitsILb0ELb0ELb1EEELb1EEixERS2_@Qt_5 5.15.1 (optional=templinst)_ZNSt8__detail9_StateSeqINSt7__cxx1112regex_traitsIcEEE8_M_cloneEv@Qt_5 5.14.1 (optional=templinst)_ZSt13binary_searchIN9__gnu_cxx17__normal_iteratorIPKcSt6vectorIcSaIcEEEEcEbT_S8_RKT0_@Qt_5 5.14.1 @@ -1757,6 +1772,7 @@ libQt5WebEngineCore.so.5 libqt5webenginecore5 #MINVER# (optional=templinst|arch=i386)_ZSt17__rotate_adaptiveIN9__gnu_cxx17__normal_iteratorIPSt4pairIyxESt6vectorIS3_SaIS3_EEEES4_iET_S9_S9_S9_T1_SA_T0_SA_@Qt_5 5.15.10 (optional=templinst|arch=armhf i386 mipsel)_ZSt17__rotate_adaptiveIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEES2_iET_S7_S7_S7_T1_S8_T0_S8_@Qt_5 5.14.2 (optional=templinst|arch=amd64 arm64 mips64el)_ZSt17__rotate_adaptiveIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEES2_lET_S7_S7_S7_T1_S8_T0_S8_@Qt_5 5.14.2 + _ZSt19piecewise_construct@Qt_5 5.15.16 (optional=templinst)_ZSt23__copy_move_backward_a1ILb1EPN3net19HostResolverManager8TaskTypeES2_EN9__gnu_cxx11__enable_ifIXsrSt23__is_random_access_iterIT0_NSt15iterator_traitsIS7_E17iterator_categoryEE7__valueESt15_Deque_iteratorIT1_RSD_PSD_EE6__typeES7_S7_SG_@Qt_5 5.14.2 (optional=templinst|subst)_ZSt23__copy_move_backward_a1ILb1EPSt4pairI{int64_t}iES1_EN9__gnu_cxx11__enable_ifIXsrSt23__is_random_access_iterIT0_NSt15iterator_traitsIS6_E17iterator_categoryEE7__valueESt15_Deque_iteratorIT1_RSC_PSC_EE6__typeES6_S6_SF_@Qt_5 5.14.2 (optional=templinst)_ZSt23__copy_move_backward_a1ILb1EPddEN9__gnu_cxx11__enable_ifIXsrSt23__is_random_access_iterIT0_NSt15iterator_traitsIS4_E17iterator_categoryEE7__valueESt15_Deque_iteratorIT1_RSA_PSA_EE6__typeES4_S4_SD_@Qt_5 5.15.2 diff --git a/debian/libqt5webenginewidgets5.symbols b/debian/libqt5webenginewidgets5.symbols index 7e80fbd6c4..7f6e010284 100644 --- a/debian/libqt5webenginewidgets5.symbols +++ b/debian/libqt5webenginewidgets5.symbols @@ -1,6 +1,6 @@ # SymbolsHelper-Confirmed: 5.15.3 amd64 mips64el libQt5WebEngineWidgets.so.5 libqt5webenginewidgets5 #MINVER# -| libqt5webenginewidgets5 #MINVER#, qtwebengine-abi-5-15-15 +| libqt5webenginewidgets5 #MINVER#, qtwebengine-abi-5-15-17 * Build-Depends-Package: qtwebengine5-dev Qt_5.0@Qt_5.0 5.7.1 Qt_5.10@Qt_5.10 5.10.1 diff --git a/debian/patches/Port-for-loongarch64.patch b/debian/patches/Port-for-loongarch64.patch deleted file mode 100644 index 2f3215abc8..0000000000 --- a/debian/patches/Port-for-loongarch64.patch +++ /dev/null @@ -1,42362 +0,0 @@ -From da5633efd7cc01759b9d77efb6c12100dbf12944 Mon Sep 17 00:00:00 2001 -From: Mu Tao -Date: Wed, 26 Jun 2024 14:17:54 +0800 -Subject: [PATCH] Port for loongarch64 - -01. port qt building procedure -02. port gn -03. port 'chromium/build' -04. port 'chromium/base' -05. port 'chromium/v8' -06. port 'chromium/third_party/webrtc' -07. port 'chromium/third_party/swiftshader' -08. port 'chromium/third_party/dav1d' -09. port 'chromium/third_party/ffmpeg' -10. port 'chromium/third_party/abseil-cpp' -11. port 'chromium/third_party/angle' -12. port 'chromium/third_party/blink' -13. port 'chromium/third_party/boringssl' -14. port 'chromium/sandbox' -15. port 'chromium/skia' -16. port 'chromium/third_party/lss' -17. port 'chromium/third_party/breakpad' -18. port 'chromium/third_party/crashpad' -19. port 'chromium/third_party/pdfium' ---- - configure.pri | 1 + - mkspecs/features/functions.prf | 1 + - .../page_allocator_constants.h | 2 +- - .../partition_alloc_constants.h | 2 +- - .../partition_allocator/yield_processor.h | 2 + - .../chromium/base/process/launch_posix.cc | 2 +- - .../double-conversion/utils.h | 3 +- - src/3rdparty/chromium/build/build_config.h | 12 +- - .../chromium/build/toolchain/linux/BUILD.gn | 24 + - src/3rdparty/chromium/sandbox/features.gni | 3 +- - .../linux/bpf_dsl/linux_syscall_ranges.h | 7 + - .../sandbox/linux/bpf_dsl/seccomp_macros.h | 46 + - .../seccomp-bpf-helpers/baseline_policy.cc | 8 +- - .../seccomp-bpf-helpers/sigsys_handlers.cc | 2 + - .../syscall_parameters_restrictions.cc | 3 +- - .../linux/seccomp-bpf-helpers/syscall_sets.cc | 66 +- - .../linux/seccomp-bpf-helpers/syscall_sets.h | 11 +- - .../sandbox/linux/seccomp-bpf/syscall.cc | 33 +- - .../sandbox/linux/services/credentials.cc | 2 +- - .../linux/services/syscall_wrappers.cc | 67 +- - .../linux/syscall_broker/broker_process.cc | 18 +- - .../linux/system_headers/linux_seccomp.h | 8 + - .../linux/system_headers/linux_signal.h | 11 +- - .../sandbox/linux/system_headers/linux_stat.h | 65 + - .../linux/system_headers/linux_syscalls.h | 4 + - .../loongarch64_linux_syscalls.h | 851 +++ - .../linux/bpf_cros_amd_gpu_policy_linux.cc | 2 +- - .../policy/linux/bpf_gpu_policy_linux.cc | 2 +- - src/3rdparty/chromium/skia/BUILD.gn | 2 + - .../absl/debugging/internal/examine_stack.cc | 2 + - .../chromium/third_party/angle/gni/angle.gni | 2 +- - .../blink/renderer/platform/heap/asm/BUILD.gn | 2 + - .../heap/asm/SaveRegisters_loongarch64.S | 41 + - .../boringssl/src/include/openssl/base.h | 3 + - .../dump_writer_common/raw_context_cpu.h | 2 + - .../linux/dump_writer_common/thread_info.cc | 10 + - .../linux/dump_writer_common/thread_info.h | 11 + - .../client/linux/handler/exception_handler.cc | 11 +- - .../client/linux/handler/exception_handler.h | 2 +- - .../microdump_writer/microdump_writer.cc | 8 +- - .../minidump_writer/linux_core_dumper.cc | 14 +- - .../linux/minidump_writer/linux_dumper.h | 1 + - .../minidump_writer/linux_ptrace_dumper.cc | 21 + - .../linux/minidump_writer/minidump_writer.cc | 68 +- - .../linux/minidump_writer/minidump_writer.h | 2 +- - .../src/common/linux/memory_mapped_file.cc | 1 + - .../common/minidump_cpu_loong64.h | 60 + - .../google_breakpad/common/minidump_format.h | 2 + - .../crashpad/crashpad/util/linux/ptracer.cc | 41 + - .../crashpad/util/linux/thread_info.h | 24 +- - .../chromium/third_party/dav1d/BUILD.gn | 8 +- - .../config/linux-noasm/loongarch64/config.h | 38 + - .../config/Chrome/linux/loongarch64/config.h | 2626 ++++++++ - .../linux/loongarch64/libavcodec/bsf_list.c | 3 + - .../linux/loongarch64/libavcodec/codec_list.c | 20 + - .../loongarch64/libavcodec/parser_list.c | 11 + - .../loongarch64/libavformat/demuxer_list.c | 9 + - .../loongarch64/libavformat/muxer_list.c | 2 + - .../loongarch64/libavformat/protocol_list.c | 2 + - .../linux/loongarch64/libavutil/avconfig.h | 6 + - .../linux/loongarch64/libavutil/ffversion.h | 5 + - .../ffmpeg/chromium/scripts/build_ffmpeg.py | 26 +- - .../ffmpeg/chromium/scripts/copy_config.sh | 2 +- - .../ffmpeg/chromium/scripts/generate_gn.py | 2 +- - .../chromium/third_party/ffmpeg/configure | 17 +- - .../third_party/lss/linux_syscall_support.h | 332 +- - .../page_allocator_constants.h | 2 +- - .../partition_alloc_constants.h | 2 +- - .../third_party/llvm-10.0/BUILD.gn | 2 + - .../modules/desktop_capture/differ_block.cc | 3 +- - .../third_party/webrtc/rtc_base/system/arch.h | 4 + - src/3rdparty/chromium/v8/BUILD.gn | 44 + - .../chromium/v8/gni/snapshot_toolchain.gni | 3 +- - .../chromium/v8/src/base/build_config.h | 19 +- - .../v8/src/base/platform/platform-posix.cc | 8 + - .../chromium/v8/src/builtins/builtins.cc | 2 +- - .../loongarch64/builtins-loongarch64.cc | 3549 +++++++++++ - .../chromium/v8/src/codegen/assembler-arch.h | 2 + - .../chromium/v8/src/codegen/assembler-inl.h | 2 + - .../chromium/v8/src/codegen/assembler.h | 3 +- - .../chromium/v8/src/codegen/constants-arch.h | 2 + - .../chromium/v8/src/codegen/cpu-features.h | 3 + - .../v8/src/codegen/external-reference.cc | 2 + - .../v8/src/codegen/interface-descriptors.cc | 6 +- - .../loongarch64/assembler-loongarch64-inl.h | 267 + - .../loongarch64/assembler-loongarch64.cc | 2689 ++++++++ - .../loongarch64/assembler-loongarch64.h | 1138 ++++ - .../loongarch64/constants-loongarch64.cc | 100 + - .../loongarch64/constants-loongarch64.h | 1340 ++++ - .../codegen/loongarch64/cpu-loongarch64.cc | 38 + - .../interface-descriptors-loongarch64.cc | 357 ++ - .../macro-assembler-loongarch64.cc | 4021 ++++++++++++ - .../loongarch64/macro-assembler-loongarch64.h | 1110 ++++ - .../loongarch64/register-loongarch64.h | 330 + - .../chromium/v8/src/codegen/macro-assembler.h | 3 + - .../chromium/v8/src/codegen/register-arch.h | 2 + - .../v8/src/codegen/register-configuration.cc | 2 + - .../chromium/v8/src/codegen/reloc-info.cc | 3 +- - src/3rdparty/chromium/v8/src/common/globals.h | 3 + - .../src/compiler/backend/instruction-codes.h | 2 + - .../compiler/backend/instruction-selector.cc | 9 +- - .../loongarch64/code-generator-loongarch64.cc | 2846 +++++++++ - .../instruction-codes-loongarch64.h | 432 ++ - .../instruction-scheduler-loongarch64.cc | 1554 +++++ - .../instruction-selector-loongarch64.cc | 3170 ++++++++++ - .../chromium/v8/src/compiler/c-linkage.cc | 12 + - .../chromium/v8/src/debug/debug-evaluate.cc | 2 +- - .../debug/loongarch64/debug-loongarch64.cc | 55 + - .../loongarch64/deoptimizer-loongarch64.cc | 241 + - .../chromium/v8/src/diagnostics/gdb-jit.cc | 2 + - .../loongarch64/disasm-loongarch64.cc | 1694 +++++ - .../chromium/v8/src/diagnostics/perf-jit.h | 3 + - .../v8/src/execution/frame-constants.h | 2 + - .../frame-constants-loongarch64.cc | 32 + - .../loongarch64/frame-constants-loongarch64.h | 77 + - .../loongarch64/simulator-loongarch64.cc | 5564 +++++++++++++++++ - .../loongarch64/simulator-loongarch64.h | 646 ++ - .../v8/src/execution/simulator-base.h | 2 +- - .../chromium/v8/src/execution/simulator.h | 2 + - .../chromium/v8/src/flags/flag-definitions.h | 2 +- - .../asm/loongarch64/push_registers_asm.cc | 48 + - .../src/interpreter/interpreter-assembler.cc | 2 +- - .../chromium/v8/src/libsampler/sampler.cc | 4 + - src/3rdparty/chromium/v8/src/logging/log.cc | 2 + - .../chromium/v8/src/objects/backing-store.cc | 2 +- - src/3rdparty/chromium/v8/src/objects/code.cc | 2 +- - src/3rdparty/chromium/v8/src/objects/code.h | 2 + - .../chromium/v8/src/profiler/tick-sample.cc | 2 +- - .../regexp-macro-assembler-loongarch64.cc | 1270 ++++ - .../regexp-macro-assembler-loongarch64.h | 211 + - .../src/regexp/regexp-macro-assembler-arch.h | 2 + - .../regexp/regexp-macro-assembler-tracer.cc | 2 +- - .../v8/src/regexp/regexp-macro-assembler.h | 1 + - src/3rdparty/chromium/v8/src/regexp/regexp.cc | 3 + - .../v8/src/runtime/runtime-atomics.cc | 3 +- - .../chromium/v8/src/snapshot/deserializer.h | 1 + - .../platform-embedded-file-writer-generic.cc | 3 +- - .../wasm/baseline/liftoff-assembler-defs.h | 10 +- - .../v8/src/wasm/baseline/liftoff-assembler.h | 2 + - .../liftoff-assembler-loongarch64.h | 2080 ++++++ - .../v8/src/wasm/jump-table-assembler.cc | 31 + - .../v8/src/wasm/jump-table-assembler.h | 6 + - .../chromium/v8/src/wasm/wasm-linkage.h | 9 + - src/3rdparty/gn/tools/gn/args.cc | 3 + - src/3rdparty/gn/util/build_config.h | 9 + - src/buildtools/config/support.pri | 2 +- - 146 files changed, 39663 insertions(+), 156 deletions(-) - create mode 100644 src/3rdparty/chromium/sandbox/linux/system_headers/loongarch64_linux_syscalls.h - create mode 100644 src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_loongarch64.S - create mode 100644 src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_loong64.h - create mode 100644 src/3rdparty/chromium/third_party/dav1d/config/linux-noasm/loongarch64/config.h - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/config.h - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/bsf_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/codec_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/parser_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/demuxer_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/muxer_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/protocol_list.c - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/avconfig.h - create mode 100644 src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/ffversion.h - create mode 100644 src/3rdparty/chromium/v8/src/builtins/loongarch64/builtins-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64-inl.h - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/cpu-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/interface-descriptors-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/codegen/loongarch64/register-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/code-generator-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-codes-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/debug/loongarch64/debug-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/diagnostics/loongarch64/disasm-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/heap/base/asm/loongarch64/push_registers_asm.cc - create mode 100644 src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc - create mode 100644 src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h - create mode 100644 src/3rdparty/chromium/v8/src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h - -diff --git a/configure.pri b/configure.pri -index 080f582b7..cb01399b4 100644 ---- a/configure.pri -+++ b/configure.pri -@@ -123,6 +123,7 @@ defineTest(qtConfTest_detectArch) { - contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) - contains(QT_ARCH, "mips"): return(true) - contains(QT_ARCH, "mips64"): return(true) -+ contains(QT_ARCH, "loongarch64"): return(true) - qtLog("Architecture not supported.") - return(false) - } -diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf -index 951f4d277..3514a299e 100644 ---- a/mkspecs/features/functions.prf -+++ b/mkspecs/features/functions.prf -@@ -112,6 +112,7 @@ defineReplace(gnArch) { - contains(qtArch, "mips"): return(mipsel) - contains(qtArch, "mips64"): return(mips64el) - contains(qtArch, "mips64el"): return(mips64el) -+ contains(qtArch, "loongarch64"): return(loongarch64) - return(unknown) - } - -diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h -index c42fe2835..a7aee4943 100644 ---- a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h -+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h -@@ -47,7 +47,7 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { - // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice - // here. - return 16; // 64kB --#elif defined(_MIPS_ARCH_LOONGSON) -+#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) - return 14; // 16kB - #else - return 12; // 4kB -diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h -index c8268ec30..fd00eb375 100644 ---- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h -+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h -@@ -47,7 +47,7 @@ static_assert(sizeof(void*) != 8, ""); - // other constant values, we pack _all_ `PartitionRoot::Alloc` sizes perfectly - // up against the end of a system page. - --#if defined(_MIPS_ARCH_LOONGSON) -+#if defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) - PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int - PartitionPageShift() { - return 16; // 64 KiB -diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h b/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h -index dd9fbfccb..31560faba 100644 ---- a/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h -+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h -@@ -29,6 +29,8 @@ - // Don't bother doing using .word here since r2 is the lowest supported mips64 - // that Chromium supports. - #define YIELD_PROCESSOR __asm__ __volatile__("pause") -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+#define YIELD_PROCESSOR __asm__ __volatile__("nop") - #elif defined(ARCH_CPU_PPC64_FAMILY) - #define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31") - #elif defined(ARCH_CPU_S390_FAMILY) -diff --git a/src/3rdparty/chromium/base/process/launch_posix.cc b/src/3rdparty/chromium/base/process/launch_posix.cc -index a8b1f0bdf..19da244e4 100644 ---- a/src/3rdparty/chromium/base/process/launch_posix.cc -+++ b/src/3rdparty/chromium/base/process/launch_posix.cc -@@ -704,7 +704,7 @@ NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, - alignas(16) char stack_buf[PTHREAD_STACK_MIN]; - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ - defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \ -- defined(ARCH_CPU_PPC64_FAMILY) -+ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) - // The stack grows downward. - void* stack = stack_buf + sizeof(stack_buf); - #else -diff --git a/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h b/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h -index 471c3da84..3122c600c 100644 ---- a/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h -+++ b/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h -@@ -110,7 +110,8 @@ int main(int argc, char** argv) { - defined(__riscv) || defined(__e2k__) || \ - defined(__or1k__) || defined(__arc__) || \ - defined(__microblaze__) || defined(__XTENSA__) || \ -- defined(__EMSCRIPTEN__) || defined(__wasm32__) -+ defined(__EMSCRIPTEN__) || defined(__wasm32__) || \ -+ defined(__loongarch__) - #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 - #elif defined(__mc68000__) || \ - defined(__pnacl__) || defined(__native_client__) -diff --git a/src/3rdparty/chromium/build/build_config.h b/src/3rdparty/chromium/build/build_config.h -index 2c3e81ee1..2886e294f 100644 ---- a/src/3rdparty/chromium/build/build_config.h -+++ b/src/3rdparty/chromium/build/build_config.h -@@ -22,13 +22,14 @@ - // Processor: - // ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 / - // ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 / --// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 -+// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_LOONGARCH64 - // Processor family: - // ARCH_CPU_ARM_FAMILY: ARMEL or ARM64 - // ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS - // ARCH_CPU_PPC64_FAMILY: PPC64 - // ARCH_CPU_S390_FAMILY: S390 or S390X - // ARCH_CPU_X86_FAMILY: X86 or X86_64 -+// ARCH_CPU_LOONGARCH_FAMILY: LOONGARCH64 - // Processor features: - // ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS - // ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN -@@ -193,6 +194,15 @@ - #define ARCH_CPU_32_BITS 1 - #define ARCH_CPU_BIG_ENDIAN 1 - #endif -+#elif defined(__loongarch__) -+#if defined(__loongarch_lp64) -+#define ARCH_CPU_LOONGARCH_FAMILY 1 -+#define ARCH_CPU_LOONGARCH64 1 -+#define ARCH_CPU_64_BITS 1 -+#define ARCH_CPU_LITTLE_ENDIAN 1 -+#else -+#error Only lp64 been supported on loongarch architecture! -+#endif - #else - #error Please add support for your architecture in build/build_config.h - #endif -diff --git a/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn b/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn -index fa8b17e9d..bd757b4e9 100644 ---- a/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn -+++ b/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn -@@ -298,3 +298,27 @@ gcc_toolchain("mips64") { - is_clang = false - } - } -+ -+clang_toolchain("clang_loongarch64") { -+ toolchain_args = { -+ current_cpu = "loongarch64" -+ current_os = "linux" -+ is_clang = true -+ } -+} -+ -+gcc_toolchain("loongarch64") { -+ cc = "gcc" -+ cxx = "g++" -+ -+ readelf = "readelf" -+ nm = "nm" -+ ar = "ar" -+ ld = cxx -+ -+ toolchain_args = { -+ current_cpu = "loongarch64" -+ current_os = "linux" -+ is_clang = false -+ } -+} -diff --git a/src/3rdparty/chromium/sandbox/features.gni b/src/3rdparty/chromium/sandbox/features.gni -index db30ae6d6..5f1e32f0b 100644 ---- a/src/3rdparty/chromium/sandbox/features.gni -+++ b/src/3rdparty/chromium/sandbox/features.gni -@@ -11,7 +11,8 @@ import("//build/config/nacl/config.gni") - use_seccomp_bpf = (is_linux || is_chromeos || is_android) && - (current_cpu == "x86" || current_cpu == "x64" || - current_cpu == "arm" || current_cpu == "arm64" || -- current_cpu == "mipsel" || current_cpu == "mips64el") -+ current_cpu == "mipsel" || current_cpu == "mips64el" || -+ current_cpu == "loongarch64") - - use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi - -diff --git a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -index 642ceddae..62f64a93b 100644 ---- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -@@ -49,6 +49,13 @@ - #define MAX_PUBLIC_SYSCALL __NR_syscalls - #define MAX_SYSCALL MAX_PUBLIC_SYSCALL - -+#elif defined(__loongarch64) -+ -+#include -+#define MIN_SYSCALL 0u -+#define MAX_PUBLIC_SYSCALL __NR_syscalls -+#define MAX_SYSCALL MAX_PUBLIC_SYSCALL -+ - #else - #error "Unsupported architecture" - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -index 1a407b952..10780b4be 100644 ---- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -@@ -346,6 +346,52 @@ struct regs_struct { - #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] - #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] - #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] -+ -+#elif defined(__loongarch64) -+struct regs_struct // TODO:MT -+{ -+ uint64_t regs[32]; -+ uint64_t orig_a0; -+ uint64_t csr_era; -+ uint64_t csr_badv; -+ uint64_t reserved[10]; -+}; -+ -+#define SECCOMP_ARCH AUDIT_ARCH_LOONGARCH64 -+ -+#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) -+ -+#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 4) -+#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 11) -+#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__pc -+#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 4) -+#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 5) -+#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 6) -+#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 7) -+#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 8) -+#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 9) -+ -+#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) -+#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) -+#define SECCOMP_IP_MSB_IDX \ -+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) -+#define SECCOMP_IP_LSB_IDX \ -+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) -+#define SECCOMP_ARG_MSB_IDX(nr) \ -+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) -+#define SECCOMP_ARG_LSB_IDX(nr) \ -+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) -+ -+#define SECCOMP_PT_RESULT(_regs) (_regs).regs[4] -+#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[11] -+#define SECCOMP_PT_IP(_regs) (_regs).csr_era -+#define SECCOMP_PT_PARM1(_regs) (_regs).regs[4] -+#define SECCOMP_PT_PARM2(_regs) (_regs).regs[5] -+#define SECCOMP_PT_PARM3(_regs) (_regs).regs[6] -+#define SECCOMP_PT_PARM4(_regs) (_regs).regs[7] -+#define SECCOMP_PT_PARM5(_regs) (_regs).regs[8] -+#define SECCOMP_PT_PARM6(_regs) (_regs).regs[9] -+ - #else - #error Unsupported target platform - -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -index a340f579e..cfde6ebda 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -@@ -181,7 +181,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, - return RestrictFcntlCommands(); - #endif - --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - // fork() is never used as a system call (clone() is used instead), but we - // have seen it in fallback code on Android. - if (sysno == __NR_fork) { -@@ -231,7 +231,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, - } - - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - if (sysno == __NR_mmap) - return RestrictMmapFlags(); - #endif -@@ -249,7 +249,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, - return RestrictPrctl(); - - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - if (sysno == __NR_socketpair) { - // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. - static_assert(AF_UNIX == PF_UNIX, -@@ -269,12 +269,14 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, - return RestrictKillTarget(current_pid, sysno); - } - -+#if !defined(__loongarch64) - // The fstatat syscalls are file system syscalls, which will be denied below - // with fs_denied_errno. However some allowed fstat syscalls are rewritten by - // libc implementations to fstatat syscalls, and we need to rewrite them back. - if (sysno == __NR_fstatat_default) { - return RewriteFstatatSIGSYS(fs_denied_errno); - } -+#endif - - // The statx syscall is a filesystem syscall, which will be denied below with - // fs_denied_errno. However, on some platforms, glibc will default to statx -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc -index 13e71801f..a03107de6 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc -@@ -359,6 +359,7 @@ intptr_t SIGSYSSchedHandler(const struct arch_seccomp_data& args, - - intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, - void* fs_denied_errno) { -+#if !defined(__loongarch64) - if (args.nr == __NR_fstatat_default) { - if (*reinterpret_cast(args.args[1]) == '\0' && - args.args[3] == static_cast(AT_EMPTY_PATH)) { -@@ -367,6 +368,7 @@ intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, - } - return -reinterpret_cast(fs_denied_errno); - } -+#endif - - CrashSIGSYS_Handler(args, fs_denied_errno); - -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -index da22c8f1a..121505922 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -@@ -37,7 +37,8 @@ - #include - #include - #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(__arm__) && \ -- !defined(__aarch64__) && !defined(PTRACE_GET_THREAD_AREA) -+ !defined(__aarch64__) && !defined(__loongarch__) && \ -+ !defined(PTRACE_GET_THREAD_AREA) - // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance - // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. - // asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -index d1ea8e99a..73dd369c5 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -@@ -86,7 +86,7 @@ bool SyscallSets::IsUmask(int sysno) { - // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. - bool SyscallSets::IsFileSystem(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_access: // EPERM not a valid errno. - case __NR_chmod: - case __NR_chown: -@@ -174,10 +174,15 @@ bool SyscallSets::IsFileSystem(int sysno) { - - bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { - switch (sysno) { -+#if !defined(__loongarch64) - case __NR_fstat: -+#endif - #if defined(__i386__) || defined(__arm__) || \ - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR_fstat64: -+#endif -+#if defined(__loongarch64) -+ case __NR_statx: - #endif - return true; - // TODO(jln): these should be denied gracefully as well (moved below). -@@ -202,7 +207,7 @@ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { - case __NR_oldfstat: - #endif - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_sync_file_range: // EPERM not a valid errno. - #elif defined(__arm__) - case __NR_arm_sync_file_range: // EPERM not a valid errno. -@@ -226,7 +231,7 @@ bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR_ftruncate64: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_getdents: // EPERM not a valid errno. - #endif - case __NR_getdents64: // EPERM not a valid errno. -@@ -305,7 +310,7 @@ bool SyscallSets::IsProcessPrivilegeChange(int sysno) { - bool SyscallSets::IsProcessGroupOrSession(int sysno) { - switch (sysno) { - case __NR_setpgid: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_getpgrp: - #endif - case __NR_setsid: -@@ -334,7 +339,7 @@ bool SyscallSets::IsAllowedSignalHandling(int sysno) { - case __NR_rt_sigsuspend: - case __NR_rt_tgsigqueueinfo: - case __NR_sigaltstack: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_signalfd: - #endif - case __NR_signalfd4: -@@ -358,12 +363,12 @@ bool SyscallSets::IsAllowedOperationOnFd(int sysno) { - switch (sysno) { - case __NR_close: - case __NR_dup: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_dup2: - #endif - case __NR_dup3: - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_shutdown: - #endif - return true; -@@ -402,7 +407,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { - return true; - case __NR_clone: // Should be parameter-restricted. - case __NR_setns: // Privileged. --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_fork: - #endif - #if defined(__i386__) || defined(__x86_64__) -@@ -413,7 +418,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { - #endif - case __NR_set_tid_address: - case __NR_unshare: --#if !defined(__mips__) && !defined(__aarch64__) -+#if !defined(__mips__) && !defined(__aarch64__) && !defined(__loongarch__) - case __NR_vfork: - #endif - default: -@@ -434,7 +439,7 @@ bool SyscallSets::IsAllowedFutex(int sysno) { - - bool SyscallSets::IsAllowedEpoll(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_epoll_create: - case __NR_epoll_wait: - #endif -@@ -455,7 +460,7 @@ bool SyscallSets::IsAllowedEpoll(int sysno) { - - bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_pipe: - #endif - case __NR_pipe2: -@@ -472,7 +477,7 @@ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { - bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { - switch (sysno) { - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_accept: - case __NR_accept4: - case __NR_bind: -@@ -501,7 +506,8 @@ bool SyscallSets::IsSocketCall(int sysno) { - } - #endif - --#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) -+#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -+ defined(__loongarch__) - bool SyscallSets::IsNetworkSocketInformation(int sysno) { - switch (sysno) { - case __NR_getpeername: -@@ -526,7 +532,7 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { - case __NR_mincore: - case __NR_mlockall: - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_mmap: - #endif - #if defined(__i386__) || defined(__arm__) || \ -@@ -559,7 +565,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR__llseek: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_poll: - #endif - case __NR_ppoll: -@@ -572,7 +578,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { - case __NR_recv: - #endif - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_recvfrom: // Could specify source. - case __NR_recvmsg: // Could specify source. - #endif -@@ -587,7 +593,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { - case __NR_send: - #endif - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_sendmsg: // Could specify destination. - case __NR_sendto: // Could specify destination. - #endif -@@ -637,7 +643,7 @@ bool SyscallSets::IsSeccomp(int sysno) { - bool SyscallSets::IsAllowedBasicScheduler(int sysno) { - switch (sysno) { - case __NR_sched_yield: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_pause: - #endif - case __NR_nanosleep: -@@ -721,7 +727,7 @@ bool SyscallSets::IsNuma(int sysno) { - case __NR_getcpu: - case __NR_mbind: - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_migrate_pages: - #endif - case __NR_move_pages: -@@ -750,7 +756,7 @@ bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { - switch (sysno) { - case __NR_acct: // Privileged. - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - case __NR_getrlimit: - #endif - #if defined(__i386__) || defined(__arm__) -@@ -785,7 +791,7 @@ bool SyscallSets::IsDebug(int sysno) { - - bool SyscallSets::IsGlobalSystemStatus(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR__sysctl: - case __NR_sysfs: - #endif -@@ -803,7 +809,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) { - - bool SyscallSets::IsEventFd(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_eventfd: - #endif - case __NR_eventfd2: -@@ -839,7 +845,8 @@ bool SyscallSets::IsKeyManagement(int sysno) { - } - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - bool SyscallSets::IsSystemVSemaphores(int sysno) { - switch (sysno) { - case __NR_semctl: -@@ -855,7 +862,8 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) { - - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - // These give a lot of ambient authority and bypass the setuid sandbox. - bool SyscallSets::IsSystemVSharedMemory(int sysno) { - switch (sysno) { -@@ -871,7 +879,8 @@ bool SyscallSets::IsSystemVSharedMemory(int sysno) { - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - bool SyscallSets::IsSystemVMessageQueue(int sysno) { - switch (sysno) { - case __NR_msgctl: -@@ -902,7 +911,8 @@ bool SyscallSets::IsSystemVIpc(int sysno) { - - bool SyscallSets::IsAnySystemV(int sysno) { - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || - IsSystemVSharedMemory(sysno); - #elif defined(__i386__) || \ -@@ -935,7 +945,7 @@ bool SyscallSets::IsAdvancedScheduler(int sysno) { - bool SyscallSets::IsInotify(int sysno) { - switch (sysno) { - case __NR_inotify_add_watch: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_inotify_init: - #endif - case __NR_inotify_init1: -@@ -1066,7 +1076,7 @@ bool SyscallSets::IsMisc(int sysno) { - #if defined(__x86_64__) - case __NR_tuxcall: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_vserver: - #endif - return true; -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -index 0fc7b2b9c..9bebc2b34 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -@@ -49,7 +49,7 @@ class SANDBOX_EXPORT SyscallSets { - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch__) - static bool IsNetworkSocketInformation(int sysno); - #endif - -@@ -72,18 +72,21 @@ class SANDBOX_EXPORT SyscallSets { - static bool IsAsyncIo(int sysno); - static bool IsKeyManagement(int sysno); - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - static bool IsSystemVSemaphores(int sysno); - #endif - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - // These give a lot of ambient authority and bypass the setuid sandbox. - static bool IsSystemVSharedMemory(int sysno); - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__loongarch64) - static bool IsSystemVMessageQueue(int sysno); - #endif - -diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc -index e47e98bf5..609ea6588 100644 ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc -@@ -18,7 +18,7 @@ namespace sandbox { - namespace { - - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ -- defined(ARCH_CPU_MIPS_FAMILY) -+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) - // Number that's not currently used by any Linux kernel ABIs. - const int kInvalidSyscallNumber = 0x351d3; - #else -@@ -312,6 +312,25 @@ asm(// We need to be able to tell the kernel exactly where we made a - "2:ret\n" - ".cfi_endproc\n" - ".size SyscallAsm, .-SyscallAsm\n" -+#elif defined(__loongarch64) -+ ".text\n" -+ ".global SyscallAsm\n" -+ ".type SyscallAsm, %function\n" -+ "SyscallAsm:\n" -+ "bge $a0, $zero, 1f\n" -+ "la.pcrel $a0, 2f\n" -+ "b 2f\n" -+ "1:ld.d $a5, $a6, 40\n" -+ "ld.d $a4, $a6, 32\n" -+ "ld.d $a3, $a6, 24\n" -+ "ld.d $a2, $a6, 16\n" -+ "ld.d $a1, $a6, 8\n" -+ "move $a7, $a0\n" -+ "ld.d $a0, $a6, 0\n" -+ // Enter the kernel -+ "syscall 0\n" -+ "2:jirl $zero, $ra, 0\n" -+ ".size SyscallAsm, .-SyscallAsm\n" - #endif - ); // asm - -@@ -429,6 +448,18 @@ intptr_t Syscall::Call(int nr, - ret = inout; - } - -+#elif defined(__loongarch64) -+ intptr_t ret; -+ { -+ register intptr_t inout __asm__("$r4") = nr; -+ register const intptr_t* data __asm__("$r10") = args; -+ asm volatile("bl SyscallAsm\n" -+ : "=r"(inout) -+ : "0"(inout), "r"(data) -+ : "memory", "$r5", "$r6", "$r7", "$r8", "$r9", "$r11", "$r1"); -+ ret = inout; -+ } -+ - #else - #error "Unimplemented architecture" - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc -index 8be3652fb..38eeeeed2 100644 ---- a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc -+++ b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc -@@ -81,7 +81,7 @@ bool ChrootToSafeEmptyDir() { - pid_t pid = -1; - alignas(16) char stack_buf[PTHREAD_STACK_MIN]; - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ -- defined(ARCH_CPU_MIPS_FAMILY) -+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) - // The stack grows downward. - void* stack = stack_buf + sizeof(stack_buf); - #else -diff --git a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc -index 3bec18a14..179e13902 100644 ---- a/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc -+++ b/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc -@@ -61,7 +61,7 @@ long sys_clone(unsigned long flags, - #if defined(ARCH_CPU_X86_64) - return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls); - #elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \ -- defined(ARCH_CPU_MIPS_FAMILY) -+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) - // CONFIG_CLONE_BACKWARDS defined. - return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid); - #endif -@@ -264,11 +264,61 @@ int sys_sigaction(int signum, - - #endif // !defined(OS_NACL_NONSFI) - -+ -+#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+void statx_to_stat(struct kernel_stat* to, struct kernel_statx* from) { -+ memset(to, 0, sizeof(struct kernel_stat)); -+ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) | -+ ((from->stx_dev_minor & ~0xff) << 12)); -+ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) | -+ ((from->stx_rdev_minor & ~0xff) << 12)); -+ to->st_ino = from->stx_ino; -+ to->st_mode = from->stx_mode; -+ to->st_nlink = from->stx_nlink; -+ to->st_uid = from->stx_uid; -+ to->st_gid = from->stx_gid; -+ to->st_atime_ = from->stx_atime.tv_sec; -+ to->st_atime_nsec_ = from->stx_atime.tv_nsec; -+ to->st_mtime_ = from->stx_mtime.tv_sec; -+ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; -+ to->st_ctime_ = from->stx_ctime.tv_sec; -+ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; -+ to->st_size = from->stx_size; -+ to->st_blocks = from->stx_blocks; -+ to->st_blksize = from->stx_blksize; -+} -+ -+int sys_statx(int fd, -+ const char* path, -+ int flags, -+ unsigned int mask, -+ struct kernel_statx* statx_buf) { -+#if defined(__NR_statx) -+ int res; -+ res = syscall(__NR_statx, fd, path, flags, mask, statx_buf); -+ if (res == 0) -+ MSAN_UNPOISON(stat_buf, sizeof(*stat_buf)); -+ return res; -+#else // defined(__NR_statx) -+ RAW_CHECK(false); -+ return (int)-ENOSYS; -+#endif -+} -+#endif // defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+ - int sys_stat(const char* path, struct kernel_stat* stat_buf) { - int res; - #if !defined(__NR_stat) -+#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+ kernel_statx statx_buf; -+ res = sys_statx(AT_FDCWD, path, AT_STATX_SYNC_AS_STAT, STATX_BASIC_STATS, -+ &statx_buf); -+ if (res == 0) -+ statx_to_stat(stat_buf, &statx_buf); -+#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) - res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, 0); --#else -+#endif -+#else // !defined(__NR_stat) - res = syscall(__NR_stat, path, stat_buf); - #endif - if (res == 0) -@@ -279,8 +329,17 @@ int sys_stat(const char* path, struct kernel_stat* stat_buf) { - int sys_lstat(const char* path, struct kernel_stat* stat_buf) { - int res; - #if !defined(__NR_lstat) -- res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); --#else -+#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+ kernel_statx statx_buf; -+ int flag = 0; -+ flag = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW; -+ res = sys_statx(AT_FDCWD, path, flag, STATX_BASIC_STATS, &statx_buf); -+ if (res == 0) -+ statx_to_stat(stat_buf, &statx_buf); -+#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+ res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); -+#endif -+#else // !defined(__NR_lstat) - res = syscall(__NR_lstat, path, stat_buf); - #endif - if (res == 0) -diff --git a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc -index 36df5e4b1..4534ca336 100644 ---- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc -+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc -@@ -128,43 +128,45 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { - // and are default disabled in Android. So, we should refuse to broker them - // to be consistent with the platform's restrictions. - switch (sysno) { --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_access: - #endif - case __NR_faccessat: - return !fast_check || allowed_command_set_.test(COMMAND_ACCESS); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_mkdir: - #endif - case __NR_mkdirat: - return !fast_check || allowed_command_set_.test(COMMAND_MKDIR); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_open: - #endif - case __NR_openat: - return !fast_check || allowed_command_set_.test(COMMAND_OPEN); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_readlink: - #endif - case __NR_readlinkat: - return !fast_check || allowed_command_set_.test(COMMAND_READLINK); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_rename: - #endif -+#if !defined(__loongarch64) - case __NR_renameat: -+#endif - case __NR_renameat2: - return !fast_check || allowed_command_set_.test(COMMAND_RENAME); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_rmdir: - return !fast_check || allowed_command_set_.test(COMMAND_RMDIR); - #endif - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_stat: - case __NR_lstat: - #endif -@@ -189,7 +191,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { - return !fast_check || allowed_command_set_.test(COMMAND_STAT); - #endif - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) - case __NR_unlink: - return !fast_check || allowed_command_set_.test(COMMAND_UNLINK); - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h -index 1fa47ed09..b3686e378 100644 ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h -@@ -42,6 +42,10 @@ - #define EM_AARCH64 183 - #endif - -+#ifndef EM_LOONGARCH -+#define EM_LOONGARCH 258 -+#endif -+ - #ifndef __AUDIT_ARCH_64BIT - #define __AUDIT_ARCH_64BIT 0x80000000 - #endif -@@ -74,6 +78,10 @@ - #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) - #endif - -+#ifndef AUDIT_ARCH_LOONGARCH64 -+#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) -+#endif -+ - // For prctl.h - #ifndef PR_SET_SECCOMP - #define PR_SET_SECCOMP 22 -diff --git a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h -index f5a736761..9c3b1a62f 100644 ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h -@@ -13,7 +13,7 @@ - // (not undefined, but defined different values and in different memory - // layouts). So, fill the gap here. - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__loongarch64) - - #define LINUX_SIGHUP 1 - #define LINUX_SIGINT 2 -@@ -127,6 +127,13 @@ struct LinuxSigSet { - struct LinuxSigSet { - unsigned long sig[_NSIG_WORDS]; - }; -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+#if !defined(_NSIG_WORDS) -+#define _NSIG_WORDS 1 -+#endif -+struct LinuxSigSet { -+ unsigned long sig[_NSIG_WORDS]; -+}; - #else - typedef uint64_t LinuxSigSet; - #endif -@@ -142,7 +149,9 @@ struct LinuxSigAction { - struct LinuxSigAction { - void (*kernel_handler)(int); - uint32_t sa_flags; -+#if !defined(ARCH_CPU_LOONGARCH_FAMILY) || defined(SA_RESTORER) - void (*sa_restorer)(void); -+#endif - LinuxSigSet sa_mask; - }; - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h -index 5f49a9584..65a9606fd 100644 ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h -@@ -173,6 +173,57 @@ struct kernel_stat { - unsigned int __unused4; - unsigned int __unused5; - }; -+#elif defined(__loongarch64) -+struct kernel_stat { -+ unsigned long st_dev; -+ unsigned long st_ino; -+ unsigned int st_mode; -+ unsigned int st_nlink; -+ unsigned int st_uid; -+ unsigned int st_gid; -+ unsigned long st_rdev; -+ unsigned long __pad1; -+ long st_size; -+ int st_blksize; -+ int __pad2; -+ long st_blocks; -+ long st_atime_; -+ unsigned long st_atime_nsec_; -+ long st_mtime_; -+ unsigned long st_mtime_nsec_; -+ long st_ctime_; -+ unsigned long st_ctime_nsec_; -+ unsigned int __unused4; -+ unsigned int __unused5; -+}; -+struct kernel_statx_timestamp { -+ long tv_sec; -+ unsigned int tv_nsec; -+ int __reserved; -+}; -+struct kernel_statx { -+ unsigned int stx_mask; -+ unsigned int stx_blksize; -+ unsigned long stx_attributes; -+ unsigned int stx_nlink; -+ unsigned int stx_uid; -+ unsigned int stx_gid; -+ unsigned short stx_mode; -+ unsigned short __spare0[1]; -+ unsigned long stx_ino; -+ unsigned long stx_size; -+ unsigned long stx_blocks; -+ unsigned long stx_attributes_mask; -+ struct kernel_statx_timestamp stx_atime; -+ struct kernel_statx_timestamp stx_btime; -+ struct kernel_statx_timestamp stx_ctime; -+ struct kernel_statx_timestamp stx_mtime; -+ unsigned int stx_rdev_major; -+ unsigned int stx_rdev_minor; -+ unsigned int stx_dev_major; -+ unsigned int stx_dev_minor; -+ unsigned long __spare2[14]; -+}; - #endif - - #if !defined(AT_EMPTY_PATH) -@@ -207,6 +258,20 @@ using default_stat_struct = struct kernel_stat; - #define __NR_fstatat_default __NR_newfstatat - #define __NR_fstat_default __NR_fstat - -+#elif defined(__NR_statx) // loongarch64 -+ -+namespace sandbox { -+using default_stat_struct = struct kernel_statx; -+} // namespace sandbox -+ -+#define AT_STATX_SYNC_TYPE 0x6000 -+#define AT_STATX_SYNC_AS_STAT 0x0000 -+#define AT_STATX_FORCE_SYNC 0x2000 -+#define AT_STATX_DONT_SYNC 0x4000 -+#define STATX_ALL 0x00000fffU -+ -+#define __NR_statx_default __NR_statx -+ - #else - #error "one of fstatat64 and newfstatat must be defined" - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h -index 2b78a0cc3..e9efd8ecb 100644 ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h -@@ -31,6 +31,10 @@ - #include "sandbox/linux/system_headers/mips64_linux_syscalls.h" - #endif - -+#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) -+#include "sandbox/linux/system_headers/loongarch64_linux_syscalls.h" -+#endif -+ - #if defined(__aarch64__) - #include "sandbox/linux/system_headers/arm64_linux_syscalls.h" - #endif -diff --git a/src/3rdparty/chromium/sandbox/linux/system_headers/loongarch64_linux_syscalls.h b/src/3rdparty/chromium/sandbox/linux/system_headers/loongarch64_linux_syscalls.h -new file mode 100644 -index 000000000..65bd0ac8e ---- /dev/null -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/loongarch64_linux_syscalls.h -@@ -0,0 +1,851 @@ -+// Copyright 2021 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ -+#define SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ -+ -+#if !defined(__loongarch__) -+#error "Including header on wrong architecture" -+#endif -+#include -+#if !defined(__NR_io_setup) -+#define __NR_io_setup 0 -+#endif -+#if !defined(__NR_io_destroy) -+#define __NR_io_destroy 1 -+#endif -+#if !defined(__NR_io_submit) -+#define __NR_io_submit 2 -+#endif -+#if !defined(__NR_io_cancel) -+#define __NR_io_cancel 3 -+#endif -+#if !defined(__NR_io_getevents) -+#define __NR_io_getevents 4 -+#endif -+#if !defined(__NR_setxattr) -+#define __NR_setxattr 5 -+#endif -+#if !defined(__NR_lsetxattr) -+#define __NR_lsetxattr 6 -+#endif -+#if !defined(__NR_fsetxattr) -+#define __NR_fsetxattr 7 -+#endif -+#if !defined(__NR_getxattr) -+#define __NR_getxattr 8 -+#endif -+#if !defined(__NR_lgetxattr) -+#define __NR_lgetxattr 9 -+#endif -+#if !defined(__NR_fgetxattr) -+#define __NR_fgetxattr 10 -+#endif -+#if !defined(__NR_listxattr) -+#define __NR_listxattr 11 -+#endif -+#if !defined(__NR_llistxattr) -+#define __NR_llistxattr 12 -+#endif -+#if !defined(__NR_flistxattr) -+#define __NR_flistxattr 13 -+#endif -+#if !defined(__NR_removexattr) -+#define __NR_removexattr 14 -+#endif -+#if !defined(__NR_lremovexattr) -+#define __NR_lremovexattr 15 -+#endif -+#if !defined(__NR_fremovexattr) -+#define __NR_fremovexattr 16 -+#endif -+#if !defined(__NR_getcwd) -+#define __NR_getcwd 17 -+#endif -+#if !defined(__NR_lookup_dcookie) -+#define __NR_lookup_dcookie 18 -+#endif -+#if !defined(__NR_eventfd2) -+#define __NR_eventfd2 19 -+#endif -+#if !defined(__NR_epoll_create1) -+#define __NR_epoll_create1 20 -+#endif -+#if !defined(__NR_epoll_ctl) -+#define __NR_epoll_ctl 21 -+#endif -+#if !defined(__NR_epoll_pwait) -+#define __NR_epoll_pwait 22 -+#endif -+#if !defined(__NR_dup) -+#define __NR_dup 23 -+#endif -+#if !defined(__NR_dup3) -+#define __NR_dup3 24 -+#endif -+#if !defined(__NR_fcntl) -+#define __NR_fcntl 25 -+#endif -+#if !defined(__NR_inotify_init1) -+#define __NR_inotify_init1 26 -+#endif -+#if !defined(__NR_inotify_add_watch) -+#define __NR_inotify_add_watch 27 -+#endif -+#if !defined(__NR_inotify_rm_watch) -+#define __NR_inotify_rm_watch 28 -+#endif -+#if !defined(__NR_ioctl) -+#define __NR_ioctl 29 -+#endif -+#if !defined(__NR_ioprio_set) -+#define __NR_ioprio_set 30 -+#endif -+#if !defined(__NR_ioprio_get) -+#define __NR_ioprio_get 31 -+#endif -+#if !defined(__NR_flock) -+#define __NR_flock 32 -+#endif -+#if !defined(__NR_mknodat) -+#define __NR_mknodat 33 -+#endif -+#if !defined(__NR_mkdirat) -+#define __NR_mkdirat 34 -+#endif -+#if !defined(__NR_unlinkat) -+#define __NR_unlinkat 35 -+#endif -+#if !defined(__NR_symlinkat) -+#define __NR_symlinkat 36 -+#endif -+#if !defined(__NR_linkat) -+#define __NR_linkat 37 -+#endif -+#if !defined(__NR_renameat) -+#define __NR_renameat 38 -+#endif -+#if !defined(__NR_umount2) -+#define __NR_umount2 39 -+#endif -+#if !defined(__NR_mount) -+#define __NR_mount 40 -+#endif -+#if !defined(__NR_pivot_root) -+#define __NR_pivot_root 41 -+#endif -+#if !defined(__NR_nfsservctl) -+#define __NR_nfsservctl 42 -+#endif -+#if !defined(__NR_statfs) -+#define __NR_statfs 43 -+#endif -+#if !defined(__NR_fstatfs) -+#define __NR_fstatfs 44 -+#endif -+#if !defined(__NR_truncate) -+#define __NR_truncate 45 -+#endif -+#if !defined(__NR_ftruncate) -+#define __NR_ftruncate 46 -+#endif -+#if !defined(__NR_fallocate) -+#define __NR_fallocate 47 -+#endif -+#if !defined(__NR_faccessat) -+#define __NR_faccessat 48 -+#endif -+#if !defined(__NR_chdir) -+#define __NR_chdir 49 -+#endif -+#if !defined(__NR_fchdir) -+#define __NR_fchdir 50 -+#endif -+#if !defined(__NR_chroot) -+#define __NR_chroot 51 -+#endif -+#if !defined(__NR_fchmod) -+#define __NR_fchmod 52 -+#endif -+#if !defined(__NR_fchmodat) -+#define __NR_fchmodat 53 -+#endif -+#if !defined(__NR_fchownat) -+#define __NR_fchownat 54 -+#endif -+#if !defined(__NR_fchown) -+#define __NR_fchown 55 -+#endif -+#if !defined(__NR_openat) -+#define __NR_openat 56 -+#endif -+#if !defined(__NR_close) -+#define __NR_close 57 -+#endif -+#if !defined(__NR_vhangup) -+#define __NR_vhangup 58 -+#endif -+#if !defined(__NR_pipe2) -+#define __NR_pipe2 59 -+#endif -+#if !defined(__NR_quotactl) -+#define __NR_quotactl 60 -+#endif -+#if !defined(__NR_getdents64) -+#define __NR_getdents64 61 -+#endif -+#if !defined(__NR_lseek) -+#define __NR_lseek 62 -+#endif -+#if !defined(__NR_read) -+#define __NR_read 63 -+#endif -+#if !defined(__NR_write) -+#define __NR_write 64 -+#endif -+#if !defined(__NR_readv) -+#define __NR_readv 65 -+#endif -+#if !defined(__NR_writev) -+#define __NR_writev 66 -+#endif -+#if !defined(__NR_pread64) -+#define __NR_pread64 67 -+#endif -+#if !defined(__NR_pwrite64) -+#define __NR_pwrite64 68 -+#endif -+#if !defined(__NR_preadv) -+#define __NR_preadv 69 -+#endif -+#if !defined(__NR_pwritev) -+#define __NR_pwritev 70 -+#endif -+#if !defined(__NR_sendfile) -+#define __NR_sendfile 71 -+#endif -+#if !defined(__NR_pselect6) -+#define __NR_pselect6 72 -+#endif -+#if !defined(__NR_ppoll) -+#define __NR_ppoll 73 -+#endif -+#if !defined(__NR_signalfd4) -+#define __NR_signalfd4 74 -+#endif -+#if !defined(__NR_vmsplice) -+#define __NR_vmsplice 75 -+#endif -+#if !defined(__NR_splice) -+#define __NR_splice 76 -+#endif -+#if !defined(__NR_tee) -+#define __NR_tee 77 -+#endif -+#if !defined(__NR_readlinkat) -+#define __NR_readlinkat 78 -+#endif -+#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) -+#if !defined(__NR_newfstatat) -+#define __NR_newfstatat 79 -+#endif -+#if !defined(__NR_fstat) -+#define __NR_fstat 80 -+#endif -+#endif -+#if !defined(__NR_sync) -+#define __NR_sync 81 -+#endif -+#if !defined(__NR_fsync) -+#define __NR_fsync 82 -+#endif -+#if !defined(__NR_fdatasync) -+#define __NR_fdatasync 83 -+#endif -+#if !defined(__NR_sync_file_range) -+#define __NR_sync_file_range 84 -+#endif -+#if !defined(__NR_timerfd_create) -+#define __NR_timerfd_create 85 -+#endif -+#if !defined(__NR_timerfd_settime) -+#define __NR_timerfd_settime 86 -+#endif -+#if !defined(__NR_timerfd_gettime) -+#define __NR_timerfd_gettime 87 -+#endif -+#if !defined(__NR_utimensat) -+#define __NR_utimensat 88 -+#endif -+#if !defined(__NR_acct) -+#define __NR_acct 89 -+#endif -+#if !defined(__NR_capget) -+#define __NR_capget 90 -+#endif -+#if !defined(__NR_capset) -+#define __NR_capset 91 -+#endif -+#if !defined(__NR_personality) -+#define __NR_personality 92 -+#endif -+#if !defined(__NR_exit) -+#define __NR_exit 93 -+#endif -+#if !defined(__NR_exit_group) -+#define __NR_exit_group 94 -+#endif -+#if !defined(__NR_waitid) -+#define __NR_waitid 95 -+#endif -+#if !defined(__NR_set_tid_address) -+#define __NR_set_tid_address 96 -+#endif -+#if !defined(__NR_unshare) -+#define __NR_unshare 97 -+#endif -+#if !defined(__NR_futex) -+#define __NR_futex 98 -+#endif -+#if !defined(__NR_set_robust_list) -+#define __NR_set_robust_list 99 -+#endif -+#if !defined(__NR_get_robust_list) -+#define __NR_get_robust_list 100 -+#endif -+#if !defined(__NR_nanosleep) -+#define __NR_nanosleep 101 -+#endif -+#if !defined(__NR_getitimer) -+#define __NR_getitimer 102 -+#endif -+#if !defined(__NR_setitimer) -+#define __NR_setitimer 103 -+#endif -+#if !defined(__NR_kexec_load) -+#define __NR_kexec_load 104 -+#endif -+#if !defined(__NR_init_module) -+#define __NR_init_module 105 -+#endif -+#if !defined(__NR_delete_module) -+#define __NR_delete_module 106 -+#endif -+#if !defined(__NR_timer_create) -+#define __NR_timer_create 107 -+#endif -+#if !defined(__NR_timer_gettime) -+#define __NR_timer_gettime 108 -+#endif -+#if !defined(__NR_timer_getoverrun) -+#define __NR_timer_getoverrun 109 -+#endif -+#if !defined(__NR_timer_settime) -+#define __NR_timer_settime 110 -+#endif -+#if !defined(__NR_timer_delete) -+#define __NR_timer_delete 111 -+#endif -+#if !defined(__NR_clock_settime) -+#define __NR_clock_settime 112 -+#endif -+#if !defined(__NR_clock_gettime) -+#define __NR_clock_gettime 113 -+#endif -+#if !defined(__NR_clock_getres) -+#define __NR_clock_getres 114 -+#endif -+#if !defined(__NR_clock_nanosleep) -+#define __NR_clock_nanosleep 115 -+#endif -+#if !defined(__NR_syslog) -+#define __NR_syslog 116 -+#endif -+#if !defined(__NR_ptrace) -+#define __NR_ptrace 117 -+#endif -+#if !defined(__NR_sched_setparam) -+#define __NR_sched_setparam 118 -+#endif -+#if !defined(__NR_sched_setscheduler) -+#define __NR_sched_setscheduler 119 -+#endif -+#if !defined(__NR_sched_getscheduler) -+#define __NR_sched_getscheduler 120 -+#endif -+#if !defined(__NR_sched_getparam) -+#define __NR_sched_getparam 121 -+#endif -+#if !defined(__NR_sched_setaffinity) -+#define __NR_sched_setaffinity 122 -+#endif -+#if !defined(__NR_sched_getaffinity) -+#define __NR_sched_getaffinity 123 -+#endif -+#if !defined(__NR_sched_yield) -+#define __NR_sched_yield 124 -+#endif -+#if !defined(__NR_sched_get_priority_max) -+#define __NR_sched_get_priority_max 125 -+#endif -+#if !defined(__NR_sched_get_priority_min) -+#define __NR_sched_get_priority_min 126 -+#endif -+#if !defined(__NR_sched_rr_get_interval) -+#define __NR_sched_rr_get_interval 127 -+#endif -+#if !defined(__NR_restart_syscall) -+#define __NR_restart_syscall 128 -+#endif -+#if !defined(__NR_kill) -+#define __NR_kill 129 -+#endif -+#if !defined(__NR_tkill) -+#define __NR_tkill 130 -+#endif -+#if !defined(__NR_tgkill) -+#define __NR_tgkill 131 -+#endif -+#if !defined(__NR_sigaltstack) -+#define __NR_sigaltstack 132 -+#endif -+#if !defined(__NR_rt_sigsuspend) -+#define __NR_rt_sigsuspend 133 -+#endif -+#if !defined(__NR_rt_sigaction) -+#define __NR_rt_sigaction 134 -+#endif -+#if !defined(__NR_rt_sigprocmask) -+#define __NR_rt_sigprocmask 135 -+#endif -+#if !defined(__NR_rt_sigpending) -+#define __NR_rt_sigpending 136 -+#endif -+#if !defined(__NR_rt_sigtimedwait) -+#define __NR_rt_sigtimedwait 137 -+#endif -+#if !defined(__NR_rt_sigqueueinfo) -+#define __NR_rt_sigqueueinfo 138 -+#endif -+#if !defined(__NR_rt_sigreturn) -+#define __NR_rt_sigreturn 139 -+#endif -+#if !defined(__NR_setpriority) -+#define __NR_setpriority 140 -+#endif -+#if !defined(__NR_getpriority) -+#define __NR_getpriority 141 -+#endif -+#if !defined(__NR_reboot) -+#define __NR_reboot 142 -+#endif -+#if !defined(__NR_setregid) -+#define __NR_setregid 143 -+#endif -+#if !defined(__NR_setgid) -+#define __NR_setgid 144 -+#endif -+#if !defined(__NR_setreuid) -+#define __NR_setreuid 145 -+#endif -+#if !defined(__NR_setuid) -+#define __NR_setuid 146 -+#endif -+#if !defined(__NR_setresuid) -+#define __NR_setresuid 147 -+#endif -+#if !defined(__NR_getresuid) -+#define __NR_getresuid 148 -+#endif -+#if !defined(__NR_setresgid) -+#define __NR_setresgid 149 -+#endif -+#if !defined(__NR_getresgid) -+#define __NR_getresgid 150 -+#endif -+#if !defined(__NR_setfsuid) -+#define __NR_setfsuid 151 -+#endif -+#if !defined(__NR_setfsgid) -+#define __NR_setfsgid 152 -+#endif -+#if !defined(__NR_times) -+#define __NR_times 153 -+#endif -+#if !defined(__NR_setpgid) -+#define __NR_setpgid 154 -+#endif -+#if !defined(__NR_getpgid) -+#define __NR_getpgid 155 -+#endif -+#if !defined(__NR_getsid) -+#define __NR_getsid 156 -+#endif -+#if !defined(__NR_setsid) -+#define __NR_setsid 157 -+#endif -+#if !defined(__NR_getgroups) -+#define __NR_getgroups 158 -+#endif -+#if !defined(__NR_setgroups) -+#define __NR_setgroups 159 -+#endif -+#if !defined(__NR_uname) -+#define __NR_uname 160 -+#endif -+#if !defined(__NR_sethostname) -+#define __NR_sethostname 161 -+#endif -+#if !defined(__NR_setdomainname) -+#define __NR_setdomainname 162 -+#endif -+#if !defined(__NR_getrlimit) -+#define __NR_getrlimit 163 -+#endif -+#if !defined(__NR_setrlimit) -+#define __NR_setrlimit 164 -+#endif -+#if !defined(__NR_getrusage) -+#define __NR_getrusage 165 -+#endif -+#if !defined(__NR_umask) -+#define __NR_umask 166 -+#endif -+#if !defined(__NR_prctl) -+#define __NR_prctl 167 -+#endif -+#if !defined(__NR_getcpu) -+#define __NR_getcpu 168 -+#endif -+#if !defined(__NR_gettimeofday) -+#define __NR_gettimeofday 169 -+#endif -+#if !defined(__NR_settimeofday) -+#define __NR_settimeofday 170 -+#endif -+#if !defined(__NR_adjtimex) -+#define __NR_adjtimex 171 -+#endif -+#if !defined(__NR_getpid) -+#define __NR_getpid 172 -+#endif -+#if !defined(__NR_getppid) -+#define __NR_getppid 173 -+#endif -+#if !defined(__NR_getuid) -+#define __NR_getuid 174 -+#endif -+#if !defined(__NR_geteuid) -+#define __NR_geteuid 175 -+#endif -+#if !defined(__NR_getgid) -+#define __NR_getgid 176 -+#endif -+#if !defined(__NR_getegid) -+#define __NR_getegid 177 -+#endif -+#if !defined(__NR_gettid) -+#define __NR_gettid 178 -+#endif -+#if !defined(__NR_sysinfo) -+#define __NR_sysinfo 179 -+#endif -+#if !defined(__NR_mq_open) -+#define __NR_mq_open 180 -+#endif -+#if !defined(__NR_mq_unlink) -+#define __NR_mq_unlink 181 -+#endif -+#if !defined(__NR_mq_timedsend) -+#define __NR_mq_timedsend 182 -+#endif -+#if !defined(__NR_mq_timedreceive) -+#define __NR_mq_timedreceive 183 -+#endif -+#if !defined(__NR_mq_notify) -+#define __NR_mq_notify 184 -+#endif -+#if !defined(__NR_mq_getsetattr) -+#define __NR_mq_getsetattr 185 -+#endif -+#if !defined(__NR_msgget) -+#define __NR_msgget 186 -+#endif -+#if !defined(__NR_msgctl) -+#define __NR_msgctl 187 -+#endif -+#if !defined(__NR_msgrcv) -+#define __NR_msgrcv 188 -+#endif -+#if !defined(__NR_msgsnd) -+#define __NR_msgsnd 189 -+#endif -+#if !defined(__NR_semget) -+#define __NR_semget 190 -+#endif -+#if !defined(__NR_semctl) -+#define __NR_semctl 191 -+#endif -+#if !defined(__NR_semtimedop) -+#define __NR_semtimedop 192 -+#endif -+#if !defined(__NR_semop) -+#define __NR_semop 193 -+#endif -+#if !defined(__NR_shmget) -+#define __NR_shmget 194 -+#endif -+#if !defined(__NR_shmctl) -+#define __NR_shmctl 195 -+#endif -+#if !defined(__NR_shmat) -+#define __NR_shmat 196 -+#endif -+#if !defined(__NR_shmdt) -+#define __NR_shmdt 197 -+#endif -+#if !defined(__NR_socket) -+#define __NR_socket 198 -+#endif -+#if !defined(__NR_socketpair) -+#define __NR_socketpair 199 -+#endif -+#if !defined(__NR_bind) -+#define __NR_bind 200 -+#endif -+#if !defined(__NR_listen) -+#define __NR_listen 201 -+#endif -+#if !defined(__NR_accept) -+#define __NR_accept 202 -+#endif -+#if !defined(__NR_connect) -+#define __NR_connect 203 -+#endif -+#if !defined(__NR_getsockname) -+#define __NR_getsockname 204 -+#endif -+#if !defined(__NR_getpeername) -+#define __NR_getpeername 205 -+#endif -+#if !defined(__NR_sendto) -+#define __NR_sendto 206 -+#endif -+#if !defined(__NR_recvfrom) -+#define __NR_recvfrom 207 -+#endif -+#if !defined(__NR_setsockopt) -+#define __NR_setsockopt 208 -+#endif -+#if !defined(__NR_getsockopt) -+#define __NR_getsockopt 209 -+#endif -+#if !defined(__NR_shutdown) -+#define __NR_shutdown 210 -+#endif -+#if !defined(__NR_sendmsg) -+#define __NR_sendmsg 211 -+#endif -+#if !defined(__NR_recvmsg) -+#define __NR_recvmsg 212 -+#endif -+#if !defined(__NR_readahead) -+#define __NR_readahead 213 -+#endif -+#if !defined(__NR_brk) -+#define __NR_brk 214 -+#endif -+#if !defined(__NR_munmap) -+#define __NR_munmap 215 -+#endif -+#if !defined(__NR_mremap) -+#define __NR_mremap 216 -+#endif -+#if !defined(__NR_add_key) -+#define __NR_add_key 217 -+#endif -+#if !defined(__NR_request_key) -+#define __NR_request_key 218 -+#endif -+#if !defined(__NR_keyctl) -+#define __NR_keyctl 219 -+#endif -+#if !defined(__NR_clone) -+#define __NR_clone 220 -+#endif -+#if !defined(__NR_execve) -+#define __NR_execve 221 -+#endif -+#if !defined(__NR_mmap) -+#define __NR_mmap 222 -+#endif -+#if !defined(__NR_fadvise64) -+#define __NR_fadvise64 223 -+#endif -+#if !defined(__NR_swapon) -+#define __NR_swapon 224 -+#endif -+#if !defined(__NR_swapoff) -+#define __NR_swapoff 225 -+#endif -+#if !defined(__NR_mprotect) -+#define __NR_mprotect 226 -+#endif -+#if !defined(__NR_msync) -+#define __NR_msync 227 -+#endif -+#if !defined(__NR_mlock) -+#define __NR_mlock 228 -+#endif -+#if !defined(__NR_munlock) -+#define __NR_munlock 229 -+#endif -+#if !defined(__NR_mlockall) -+#define __NR_mlockall 230 -+#endif -+#if !defined(__NR_munlockall) -+#define __NR_munlockall 231 -+#endif -+#if !defined(__NR_mincore) -+#define __NR_mincore 232 -+#endif -+#if !defined(__NR_madvise) -+#define __NR_madvise 233 -+#endif -+#if !defined(__NR_remap_file_pages) -+#define __NR_remap_file_pages 234 -+#endif -+#if !defined(__NR_mbind) -+#define __NR_mbind 235 -+#endif -+#if !defined(__NR_get_mempolicy) -+#define __NR_get_mempolicy 236 -+#endif -+#if !defined(__NR_set_mempolicy) -+#define __NR_set_mempolicy 237 -+#endif -+#if !defined(__NR_migrate_pages) -+#define __NR_migrate_pages 238 -+#endif -+#if !defined(__NR_move_pages) -+#define __NR_move_pages 239 -+#endif -+#if !defined(__NR_rt_tgsigqueueinfo) -+#define __NR_rt_tgsigqueueinfo 240 -+#endif -+#if !defined(__NR_perf_event_open) -+#define __NR_perf_event_open 241 -+#endif -+#if !defined(__NR_accept4) -+#define __NR_accept4 242 -+#endif -+#if !defined(__NR_recvmmsg) -+#define __NR_recvmmsg 243 -+#endif -+#if !defined(__NR_wait4) -+#define __NR_wait4 260 -+#endif -+#if !defined(__NR_prlimit64) -+#define __NR_prlimit64 261 -+#endif -+#if !defined(__NR_fanotify_init) -+#define __NR_fanotify_init 262 -+#endif -+#if !defined(__NR_fanotify_mark) -+#define __NR_fanotify_mark 263 -+#endif -+#if !defined(__NR_name_to_handle_at) -+#define __NR_name_to_handle_at 264 -+#endif -+#if !defined(__NR_open_by_handle_at) -+#define __NR_open_by_handle_at 265 -+#endif -+#if !defined(__NR_clock_adjtime) -+#define __NR_clock_adjtime 266 -+#endif -+#if !defined(__NR_syncfs) -+#define __NR_syncfs 267 -+#endif -+#if !defined(__NR_setns) -+#define __NR_setns 268 -+#endif -+#if !defined(__NR_sendmmsg) -+#define __NR_sendmmsg 269 -+#endif -+#if !defined(__NR_process_vm_readv) -+#define __NR_process_vm_readv 270 -+#endif -+#if !defined(__NR_process_vm_writev) -+#define __NR_process_vm_writev 271 -+#endif -+#if !defined(__NR_kcmp) -+#define __NR_kcmp 272 -+#endif -+#if !defined(__NR_finit_module) -+#define __NR_finit_module 273 -+#endif -+#if !defined(__NR_sched_setattr) -+#define __NR_sched_setattr 274 -+#endif -+#if !defined(__NR_sched_getattr) -+#define __NR_sched_getattr 275 -+#endif -+#if !defined(__NR_renameat2) -+#define __NR_renameat2 276 -+#endif -+#if !defined(__NR_seccomp) -+#define __NR_seccomp 277 -+#endif -+#if !defined(__NR_getrandom) -+#define __NR_getrandom 278 -+#endif -+#if !defined(__NR_memfd_create) -+#define __NR_memfd_create 279 -+#endif -+#if !defined(__NR_bpf) -+#define __NR_bfp 280 -+#endif -+#if !defined(__NR_execveat) -+#define __NR_execveat 281 -+#endif -+#if !defined(__NR_userfaultfd) -+#define __NR_userfaultfd 282 -+#endif -+#if !defined(__NR_membarrier) -+#define __NR_membarrier 283 -+#endif -+#if !defined(__NR_mlock2) -+#define __NR_mlock2 284 -+#endif -+#if !defined(__NR_copy_file_range) -+#define __NR_copy_file_range 285 -+#endif -+#if !defined(__NR_preadv2) -+#define __NR_preadv2 286 -+#endif -+#if !defined(__NR_pwritev2) -+#define __NR_pwritev2 287 -+#endif -+#if !defined(__NR_pkey_mprotect) -+#define __NR_pkey_mprotect 288 -+#endif -+#if !defined(__NR_pkey_alloc) -+#define __NR_pkey_alloc 289 -+#endif -+#if !defined(__NR_pkey_free) -+#define __NR_pkey_free 290 -+#endif -+#if !defined(__NR_statx) -+#define __NR_statx 291 -+#endif -+#if !defined(__NR_io_pgetevents) -+#define __NR_io_pgetevents 292 -+#endif -+#if !defined(__NR_rseq) -+#define __NR_rseq 293 -+#endif -+#if !defined(__NR_clone3) -+#define __NR_clone3 435 -+#endif -+#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ -diff --git a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -index 0f86af559..bf436c59d 100644 ---- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const { - case __NR_sched_setscheduler: - case __NR_sysinfo: - case __NR_uname: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_readlink: - case __NR_stat: - #endif -diff --git a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -index 0b672bb88..729cf9af4 100644 ---- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -@@ -70,7 +70,7 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR_ftruncate64: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__loongarch64) - case __NR_getdents: - #endif - case __NR_getdents64: -diff --git a/src/3rdparty/chromium/skia/BUILD.gn b/src/3rdparty/chromium/skia/BUILD.gn -index 6a107a51a..a198a362b 100644 ---- a/src/3rdparty/chromium/skia/BUILD.gn -+++ b/src/3rdparty/chromium/skia/BUILD.gn -@@ -821,6 +821,8 @@ skia_source_set("skia_opts") { - sources = skia_opts.none_sources - } else if (current_cpu == "s390x") { - sources = skia_opts.none_sources -+ } else if (current_cpu == "loongarch64") { -+ sources = skia_opts.none_sources - } else { - assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp") - } -diff --git a/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc b/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc -index 6e5ff1fbd..e6a621ade 100644 ---- a/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc -+++ b/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc -@@ -66,6 +66,8 @@ void* GetProgramCounter(void* vuc) { - #elif defined(__x86_64__) - if (16 < ABSL_ARRAYSIZE(context->uc_mcontext.gregs)) - return reinterpret_cast(context->uc_mcontext.gregs[16]); -+#elif defined(__loongarch__) -+ return reinterpret_cast(context->uc_mcontext.__pc); - #else - #error "Undefined Architecture." - #endif -diff --git a/src/3rdparty/chromium/third_party/angle/gni/angle.gni b/src/3rdparty/chromium/third_party/angle/gni/angle.gni -index c4fe8c83b..bfb63142b 100644 ---- a/src/3rdparty/chromium/third_party/angle/gni/angle.gni -+++ b/src/3rdparty/chromium/third_party/angle/gni/angle.gni -@@ -54,7 +54,7 @@ angle_data_dir = "angledata" - declare_args() { - if (current_cpu == "arm64" || current_cpu == "x64" || - current_cpu == "mips64el" || current_cpu == "s390x" || -- current_cpu == "ppc64") { -+ current_cpu == "ppc64" || current_cpu == "loongarch64") { - angle_64bit_current_cpu = true - } else if (current_cpu == "arm" || current_cpu == "x86" || - current_cpu == "mipsel" || current_cpu == "s390" || -diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn -index fe44daf27..b5baa8c17 100644 ---- a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn -@@ -36,6 +36,8 @@ if (current_cpu == "x86" || current_cpu == "x64") { - sources = [ "SaveRegisters_mips.S" ] - } else if (current_cpu == "mips64el") { - sources = [ "SaveRegisters_mips64.S" ] -+ } else if (current_cpu == "loongarch64") { -+ sources = [ "SaveRegisters_loongarch64.S" ] - } else if (current_cpu == "ppc64") { - sources = [ "SaveRegisters_ppc64.S" ] - } -diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_loongarch64.S b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_loongarch64.S -new file mode 100644 -index 000000000..f95546f0d ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_loongarch64.S -@@ -0,0 +1,41 @@ -+// Copyright 2014 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+/* -+ * typedef void (*PushAllRegistersCallback)(ThreadState*, intptr_t*); -+ * extern "C" void PushAllRegisters(ThreadState*, PushAllRegistersCallback) -+ */ -+ -+.type PushAllRegisters, %function -+.global PushAllRegisters -+.hidden PushAllRegisters -+PushAllRegisters: -+ // Push all callee-saves registers to get them -+ // on the stack for conservative stack scanning. -+ // Reserve space for callee-saved registers and return address. -+ addi.d $sp,$sp,-80 -+ // Save the callee-saved registers and the return address. -+ st.d $s0, $sp, 0 -+ st.d $s1, $sp, 8 -+ st.d $s2, $sp, 16 -+ st.d $s3, $sp, 24 -+ st.d $s4, $sp, 32 -+ st.d $s5, $sp, 40 -+ st.d $s6, $sp, 48 -+ st.d $s7, $sp, 56 -+ st.d $ra, $sp, 64 -+ // Note: the callee-saved floating point registers do not need to be -+ // copied to the stack, because fp registers never hold heap pointers -+ // and so do not need to be kept visible to the garbage collector. -+ // Pass the first argument untouched in a0 and the -+ // stack pointer to the callback. -+ ori $t7, $a1, 0 -+ ori $a1, $sp, 0 -+ jirl $ra, $t7, 0 -+ // Restore return address, adjust stack and return. -+ // Note: the copied registers do not need to be reloaded here, -+ // because they were preserved by the called routine. -+ ld.d $ra, $sp, 64 -+ addi.d $sp, $sp, 80 -+ jirl $r0, $ra, 0 -diff --git a/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h b/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h -index d681bdf81..9087b4c1d 100644 ---- a/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h -+++ b/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h -@@ -114,6 +114,9 @@ extern "C" { - #define OPENSSL_32_BIT - #elif defined(__myriad2__) - #define OPENSSL_32_BIT -+#elif defined(__loongarch__) && defined(__loongarch_lp64) -+#define OPENSSL_64_BIT -+#define OPENSSL_LOONGARCH64 - #else - // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, - // little-endian architectures. Functions will not produce the correct answer -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h -index 07d9171a0..cbbccdeaf 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h -@@ -44,6 +44,8 @@ typedef MDRawContextARM RawContextCPU; - typedef MDRawContextARM64_Old RawContextCPU; - #elif defined(__mips__) - typedef MDRawContextMIPS RawContextCPU; -+#elif defined(__loongarch64) -+typedef MDRawContextLOONG64 RawContextCPU; - #else - #error "This code has not been ported to your platform yet." - #endif -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc -index aae1dc13b..545f4df5f 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc -@@ -279,6 +279,11 @@ void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) { - *gp_regs = mcontext.gregs; - if (size) - *size = sizeof(mcontext.gregs); -+#elif defined(__loongarch64) -+ if (gp_regs) -+ *gp_regs = &_gpregs; -+ if (size) -+ *size = sizeof(_gpregs); - #else - if (gp_regs) - *gp_regs = ®s; -@@ -294,6 +299,11 @@ void ThreadInfo::GetFloatingPointRegisters(void** fp_regs, size_t* size) { - *fp_regs = &mcontext.fpregs; - if (size) - *size = sizeof(mcontext.fpregs); -+#elif defined(__loongarch64) -+ if (fp_regs) -+ *fp_regs = &_fpregs; -+ if (size) -+ *size = sizeof(_fpregs); - #else - if (fp_regs) - *fp_regs = &fpregs; -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h -index fb216fa6d..9658fda17 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h -@@ -32,6 +32,9 @@ - - #include - #include -+#if defined(__loongarch64) -+#include -+#endif - - #include "client/linux/dump_writer_common/raw_context_cpu.h" - #include "common/memory_allocator.h" -@@ -71,6 +74,14 @@ struct ThreadInfo { - #elif defined(__mips__) - // Use the structure defined in . - mcontext_t mcontext; -+#elif defined(__loongarch64) -+ // Use the structure defined in . -+ struct user_pt_regs _gpregs; -+ int32_t uc_mctxflags; -+ int32_t fp_lp64_width; // 0: unknown, 1: fp, 2: lsx, 4: lasx -+ struct user_lasx_state _fpregs; -+ uint64_t fcc; -+ uint32_t fcsr; - #endif - - // Returns the instruction pointer (platform-dependent impl.). -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc -index 5cdabcf64..f08a3b52c 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc -@@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { - memcpy(&g_crash_context_.float_state, fp_ptr, - sizeof(g_crash_context_.float_state)); - } --#elif !defined(__ARM_EABI__) && !defined(__mips__) -+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - // FP state is not part of user ABI on ARM Linux. - // In case of MIPS Linux FP state is already part of ucontext_t - // and 'float_state' is not a member of CrashContext. -@@ -471,6 +471,8 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { - sizeof(g_crash_context_.float_state)); - } - #endif -+// TODO:MT loongarch64 floating-point registers -+ - g_crash_context_.tid = syscall(__NR_gettid); - if (crash_handler_ != NULL) { - if (crash_handler_(&g_crash_context_, sizeof(g_crash_context_), -@@ -701,11 +703,13 @@ bool ExceptionHandler::WriteMinidump() { - } - #endif - --#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && \ -+ !defined(__loongarch64) - // FPU state is not part of ARM EABI ucontext_t. - memcpy(&context.float_state, context.context.uc_mcontext.fpregs, - sizeof(context.float_state)); - #endif -+// TODO:MT loongarch64 floating-point registers - context.tid = sys_gettid(); - - // Add an exception stream to the minidump for better reporting. -@@ -726,6 +730,9 @@ bool ExceptionHandler::WriteMinidump() { - #elif defined(__mips__) - context.siginfo.si_addr = - reinterpret_cast(context.context.uc_mcontext.pc); -+#elif defined(__loongarch64) -+ context.siginfo.si_addr = -+ reinterpret_cast(context.context.uc_mcontext.__pc); - #else - #error "This code has not been ported to your platform yet." - #endif -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h -index f80843ea7..7e2e0f217 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h -@@ -192,7 +192,7 @@ class ExceptionHandler { - siginfo_t siginfo; - pid_t tid; // the crashing thread. - ucontext_t context; --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - // #ifdef this out because FP state is not part of user ABI for Linux ARM. - // In case of MIPS Linux FP state is already part of ucontext_t so - // 'float_state' is not required. -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc -index fa3c1713a..7a66cb454 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc -@@ -138,7 +138,7 @@ class MicrodumpWriter { - const MicrodumpExtraInfo& microdump_extra_info, - LinuxDumper* dumper) - : ucontext_(context ? &context->context : NULL), --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - float_state_(context ? &context->float_state : NULL), - #endif - dumper_(dumper), -@@ -337,6 +337,8 @@ class MicrodumpWriter { - # else - # error "This mips ABI is currently not supported (n32)" - #endif -+#elif defined(__loongarch64) -+ const char kArch[] = "loongarch64"; - #else - #error "This code has not been ported to your platform yet" - #endif -@@ -409,7 +411,7 @@ class MicrodumpWriter { - void DumpCPUState() { - RawContextCPU cpu; - my_memset(&cpu, 0, sizeof(RawContextCPU)); --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); - #else - UContextReader::FillCPUContext(&cpu, ucontext_); -@@ -605,7 +607,7 @@ class MicrodumpWriter { - void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } - - const ucontext_t* const ucontext_; --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - const google_breakpad::fpstate_t* const float_state_; - #endif - LinuxDumper* dumper_; -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc -index 415068983..6c999ffcd 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc -@@ -38,7 +38,7 @@ - #include - #include - #include --#if defined(__mips__) && defined(__ANDROID__) -+#if defined(__mips__) && defined(__ANDROID__) || defined(__loongarch64) - // To get register definitions. - #include - #endif -@@ -112,6 +112,9 @@ bool LinuxCoreDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { - #elif defined(__mips__) - stack_pointer = - reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); -+#elif defined(__loongarch64) -+ stack_pointer = -+ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); - #else - #error "This code hasn't been ported to your platform yet." - #endif -@@ -208,7 +211,13 @@ bool LinuxCoreDumper::EnumerateThreads() { - info.mcontext.mdlo = status->pr_reg[EF_LO]; - info.mcontext.mdhi = status->pr_reg[EF_HI]; - info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; --#else // __mips__ -+#elif defined(__loongarch64) -+ // TODO:MT -+ for (int i = LOONGARCH_EF_R0; i <= LOONGARCH_EF_R31; ++i) -+ info._gpregs.regs[i-LOONGARCH_EF_R0] = status->pr_reg[i]; -+ info._gpregs.csr_era = status->pr_reg[LOONGARCH_EF_CSR_ERA]; -+ info._gpregs.csr_badv = status->pr_reg[LOONGARCH_EF_CSR_BADV]; -+#else - memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); - #endif // __mips__ - if (first_thread) { -@@ -263,6 +272,7 @@ bool LinuxCoreDumper::EnumerateThreads() { - break; - } - #if defined(__i386) || defined(__x86_64) -+ // TODO:MT FPU - case NT_FPREGSET: { - if (thread_infos_.empty()) - return false; -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h -index 7bee160f1..fa54118af 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h -@@ -63,6 +63,7 @@ namespace google_breakpad { - (defined(__mips__) && _MIPS_SIM == _ABIO32) - typedef Elf32_auxv_t elf_aux_entry; - #elif defined(__x86_64) || defined(__aarch64__) || \ -+ defined(__loongarch64) || \ - (defined(__mips__) && _MIPS_SIM != _ABIO32) - typedef Elf64_auxv_t elf_aux_entry; - #endif -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc -index e3ddb81a6..1a0e6651f 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc -@@ -162,6 +162,24 @@ bool LinuxPtraceDumper::ReadRegisterSet(ThreadInfo* info, pid_t tid) - if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { - return false; - } -+ -+// TODO:MT -+#if defined(__loongarch64) -+ info->fp_lp64_width = 1; -+// user_fp_state *_fp_state = (struct user_fp_state*)io.iov_base; -+// info->fcc = _fp_state->fcc; -+// info->fcsr = _fp_state->fcsr; -+// -+// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LASX, (void*)&io) == -1) { -+// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LSX, (void*)&io) == -1) { -+// } else { -+// info->fp_lp64_width = 2; -+// } -+// } else { -+// info->fp_lp64_width = 4; -+// } -+#endif // defined(__loongarch64) -+ - return true; - #else - return false; -@@ -298,6 +316,9 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { - #elif defined(__mips__) - stack_pointer = - reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); -+#elif defined(__loongarch64) -+ stack_pointer = -+ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); - #else - #error "This code hasn't been ported to your platform yet." - #endif -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc -index 32634ef00..2949c354d 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc -@@ -136,7 +136,7 @@ class MinidumpWriter { - : fd_(minidump_fd), - path_(minidump_path), - ucontext_(context ? &context->context : NULL), --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - float_state_(context ? &context->float_state : NULL), - #endif - dumper_(dumper), -@@ -468,7 +468,7 @@ class MinidumpWriter { - if (!cpu.Allocate()) - return false; - my_memset(cpu.get(), 0, sizeof(RawContextCPU)); --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); - #else - UContextReader::FillCPUContext(cpu.get(), ucontext_); -@@ -1205,6 +1205,68 @@ class MinidumpWriter { - - return true; - } -+#elif defined(__loongarch64) -+ bool WriteCPUInformation(MDRawSystemInfo* sys_info) { -+ // TODO:MT -+ struct CpuInfoEntry { -+ const char* info_name; -+ int value; -+ bool found; -+ } cpu_info_table[] = { -+ { "processor", -1, false }, -+ }; -+ -+ // processor_architecture should always be set, do this first -+ sys_info->processor_architecture = MD_CPU_ARCHITECTURE_LOONG64; -+ -+ const int fd = sys_open("/proc/cpuinfo", O_RDONLY, 0); -+ if (fd < 0) -+ return false; -+ -+ { -+ PageAllocator allocator; -+ ProcCpuInfoReader* const reader = new(allocator) ProcCpuInfoReader(fd); -+ const char* field; -+ while (reader->GetNextField(&field)) { -+ bool is_first_entry = true; -+ for (CpuInfoEntry& entry : cpu_info_table) { -+ if (!is_first_entry && entry.found) { -+ // except for the 'processor' field, ignore repeated values. -+ continue; -+ } -+ is_first_entry = false; -+ if (!my_strcmp(field, entry.info_name)) { -+ size_t value_len; -+ const char* value = reader->GetValueAndLen(&value_len); -+ if (value_len == 0) -+ continue; -+ -+ uintptr_t val; -+ if (my_read_decimal_ptr(&val, value) == value) -+ continue; -+ -+ entry.value = static_cast(val); -+ entry.found = true; -+ } -+ } -+ } -+ sys_close(fd); -+ } -+ // make sure we got everything we wanted -+ for (const CpuInfoEntry& entry : cpu_info_table) { -+ if (!entry.found) { -+ return false; -+ } -+ } -+ // cpu_info_table[0] holds the last cpu id listed in /proc/cpuinfo, -+ // assuming this is the highest id, change it to the number of CPUs -+ // by adding one. -+ cpu_info_table[0].value++; -+ -+ sys_info->number_of_processors = cpu_info_table[0].value; -+ -+ return true; -+ } - #else - # error "Unsupported CPU" - #endif -@@ -1333,7 +1395,7 @@ class MinidumpWriter { - const char* path_; // Path to the file where the minidum should be written. - - const ucontext_t* const ucontext_; // also from the signal handler --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - const google_breakpad::fpstate_t* const float_state_; // ditto - #endif - LinuxDumper* dumper_; -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h -index e3b0b16da..f99555ed0 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h -@@ -48,7 +48,7 @@ class ExceptionHandler; - - #if defined(__aarch64__) - typedef struct fpsimd_context fpstate_t; --#elif !defined(__ARM_EABI__) && !defined(__mips__) -+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) - typedef std::remove_pointer::type fpstate_t; - #endif - -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc -index 99362945c..a2e0bda48 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc -@@ -65,6 +65,7 @@ bool MemoryMappedFile::Map(const char* path, size_t offset) { - } - - #if defined(__x86_64__) || defined(__aarch64__) || \ -+ defined(__loongarch64) || \ - (defined(__mips__) && _MIPS_SIM == _ABI64) - - struct kernel_stat st; -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_loong64.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_loong64.h -new file mode 100644 -index 000000000..3267db963 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_loong64.h -@@ -0,0 +1,60 @@ -+#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ -+#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ -+ -+#define MD_CONTEXT_LOONG64_GPR_COUNT 32 -+#define MD_CONTEXT_LOONG64_FPRVR_COUNT 32 -+ -+#define FPR_LP64_WIDTH 1 -+#define LSX_LP64_WIDTH 2 -+#define LASX_LP64_WIDTH 4 -+ -+union user_fpr_vr_regs_union { -+ uint64_t fpregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * FPR_LP64_WIDTH]; -+ uint64_t lsxregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * LSX_LP64_WIDTH]; -+ uint64_t lasxregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * LASX_LP64_WIDTH]; -+}; -+typedef union user_fpr_vr_regs_union MDFPRVRSaveAreaLOONG64; -+ -+typedef struct { -+ uint32_t context_flags; -+ -+ uint32_t flags; -+ uint64_t gregs[MD_CONTEXT_LOONG64_GPR_COUNT]; -+ uint64_t pc; // exception return address(ERA) -+ uint64_t badvaddr; // bad virtual address(BADV) -+ uint64_t reserved[11]; -+ -+ MDFPRVRSaveAreaLOONG64 fprvr_save; -+ uint64_t fcc; // condition flag register -+ uint32_t fcsr; // floating-point control and status register -+ -+ // TODO:MT add lbt registers -+} MDRawContextLOONG64; -+ -+/* Indices into __gregs for registers with a dedicated or conventional -+ * purpose. -+ * -+ * 32 64-bit integer registers, r0..r31. -+ * Note the following fixed uses: -+ * r1 is the return address. -+ * r3 is the stack pointer. -+ * r22 is the frame pointer. -+ */ -+enum MDLOONG64RegisterNumbers { -+ MD_CONTEXT_LOONG64_REG_RA = 1, -+ MD_CONTEXT_LOONG64_REG_SP = 3, -+ MD_CONTEXT_LOONG64_REG_FP = 22 -+}; -+ -+ -+ /* For (MDRawContextLOONG64).context_flags. These values indicate the type of -+ * context stored in the structure. MD_CONTEXT_LOONG64 is Breakpad-defined. Its -+ * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other -+ * CPUs. */ -+#define MD_CONTEXT_LOONG64 0x08000000 -+#define MD_CONTEXT_LOONG64_GPR (MD_CONTEXT_LOONG64 | 0x00000001) -+#define MD_CONTEXT_LOONG64_FPR (MD_CONTEXT_LOONG64 | 0x00000002) -+#define MD_CONTEXT_LOONG64_LSX (MD_CONTEXT_LOONG64 | 0x00000004) -+#define MD_CONTEXT_LOONG64_LASX (MD_CONTEXT_LOONG64 | 0x00000008) -+ -+#endif // GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ -diff --git a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h -index 7b36d1127..52eb2ac91 100644 ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h -@@ -115,6 +115,7 @@ typedef struct { - #include "minidump_cpu_amd64.h" - #include "minidump_cpu_arm.h" - #include "minidump_cpu_arm64.h" -+#include "minidump_cpu_loong64.h" - #include "minidump_cpu_mips.h" - #include "minidump_cpu_ppc.h" - #include "minidump_cpu_ppc64.h" -@@ -660,6 +661,7 @@ typedef enum { - MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */ - MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */ - MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */ -+ MD_CPU_ARCHITECTURE_LOONG64 = 0x8007, /* Breakpad-defined value for LOONG64 */ - MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */ - } MDCPUArchitecture; - -diff --git a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc -index 557e0d363..c75fb0061 100644 ---- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc -+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc -@@ -398,6 +398,47 @@ bool GetThreadArea64(pid_t tid, - return true; - } - -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+bool GetFloatingPointRegisters32(pid_t tid, -+ FloatContext* context, -+ bool can_log) { -+ return false; -+} -+ -+bool GetFloatingPointRegisters64(pid_t tid, -+ FloatContext* context, -+ bool can_log) { -+ iovec iov; -+ iov.iov_base = context; -+ iov.iov_len = sizeof(*context); -+ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { -+ PLOG_IF(ERROR, can_log) << "ptrace"; -+ return false; -+ } -+ if (iov.iov_len != sizeof(context->f64)) { -+ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len -+ << " != " << sizeof(context->f64); -+ return false; -+ } -+ -+ return true; -+} -+ -+bool GetThreadArea32(pid_t tid, -+ const ThreadContext& context, -+ LinuxVMAddress* address, -+ bool can_log) { -+ return false; -+} -+ -+bool GetThreadArea64(pid_t tid, -+ const ThreadContext& context, -+ LinuxVMAddress* address, -+ bool can_log) { -+ *address = context.t64.regs[2]; -+ return true; -+} -+ - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -diff --git a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h -index 5b55c24a7..8beb982e9 100644 ---- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h -+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h -@@ -79,6 +79,8 @@ union ThreadContext { - uint32_t cp0_status; - uint32_t cp0_cause; - uint32_t padding1_; -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+ // nothing - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -132,12 +134,20 @@ union ThreadContext { - uint64_t cp0_badvaddr; - uint64_t cp0_status; - uint64_t cp0_cause; -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+ // Reflects user_regs_struct in sys/user.h -+ uint64_t regs[32]; -+ uint64_t orig_a0; -+ uint64_t csr_era; -+ uint64_t csr_badv; -+ uint64_t reserved[10]; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY - } t64; - --#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) -+#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) || \ -+ defined(ARCH_CPU_LOONGARCH_FAMILY) - using NativeThreadContext = user_regs_struct; - #elif defined(ARCH_CPU_ARMEL) - using NativeThreadContext = user_regs; -@@ -145,7 +155,7 @@ union ThreadContext { - // No appropriate NativeThreadsContext type available for MIPS - #else - #error Port. --#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 -+#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 || ARCH_CPU_LOONGARCH_FAMILY - - #if !defined(ARCH_CPU_MIPS_FAMILY) - #if defined(ARCH_CPU_32_BITS) -@@ -218,6 +228,8 @@ union FloatContext { - } fpregs[32]; - uint32_t fpcsr; - uint32_t fpu_id; -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+ // nothing - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -252,6 +264,10 @@ union FloatContext { - double fpregs[32]; - uint32_t fpcsr; - uint32_t fpu_id; -+#elif defined(ARCH_CPU_LOONGARCH_FAMILY) -+ uint64_t fvregs[32*4]; -+ uint64_t fcc; -+ uint32_t fcsr; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -278,8 +294,8 @@ union FloatContext { - #endif - #elif defined(ARCH_CPU_ARM64) - static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch"); --#elif defined(ARCH_CPU_MIPS_FAMILY) --// No appropriate floating point context native type for available MIPS. -+#elif defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) -+// No appropriate floating point context native type for available MIPS and LOONGARCH. - #else - #error Port. - #endif // ARCH_CPU_X86 -diff --git a/src/3rdparty/chromium/third_party/dav1d/BUILD.gn b/src/3rdparty/chromium/third_party/dav1d/BUILD.gn -index 7616b7f3f..fddb4fb9f 100644 ---- a/src/3rdparty/chromium/third_party/dav1d/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/dav1d/BUILD.gn -@@ -18,8 +18,12 @@ if (is_win) { - "Only Linux X64 MSAN is supported") - platform_config_root = "config/linux-noasm/$current_cpu" - } else { -- # Linux configuration files seem to work on Mac, so just reuse them. -- platform_config_root = "config/linux/$current_cpu" -+ if (current_cpu == "loongarch64") { -+ platform_config_root = "config/linux-noasm/$current_cpu" -+ } else { -+ # Linux configuration files seem to work on Mac, so just reuse them. -+ platform_config_root = "config/linux/$current_cpu" -+ } - } - - # Clang LTO doesn't respect stack alignment and clang-cl doesn't support setting -diff --git a/src/3rdparty/chromium/third_party/dav1d/config/linux-noasm/loongarch64/config.h b/src/3rdparty/chromium/third_party/dav1d/config/linux-noasm/loongarch64/config.h -new file mode 100644 -index 000000000..0bf4191db ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/dav1d/config/linux-noasm/loongarch64/config.h -@@ -0,0 +1,38 @@ -+/* -+ * Autogenerated by the Meson build system. -+ * Do not edit, your changes will be lost. -+ */ -+ -+#pragma once -+ -+#define ARCH_LOONGARCH 1 -+ -+#define ARCH_AARCH64 0 -+ -+#define ARCH_ARM 0 -+ -+#define ARCH_PPC64LE 0 -+ -+#define ARCH_X86 0 -+ -+#define ARCH_X86_32 0 -+ -+#define ARCH_X86_64 0 -+ -+#define CONFIG_16BPC 1 -+ -+#define CONFIG_8BPC 1 -+ -+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium -+ -+#define ENDIANNESS_BIG 0 -+ -+#define HAVE_ASM 0 -+ -+#define HAVE_CLOCK_GETTIME 1 -+ -+#define HAVE_DLSYM 1 -+ -+#define HAVE_POSIX_MEMALIGN 1 -+ -+#define HAVE_UNISTD_H 1 -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/config.h b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/config.h -new file mode 100644 -index 000000000..ae8c2ba9b ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/config.h -@@ -0,0 +1,2626 @@ -+/* Automatically generated by configure - do not modify! */ -+#ifndef FFMPEG_CONFIG_H -+#define FFMPEG_CONFIG_H -+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/home/loongson/mt/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.15+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=loongarch64 --enable-pic --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */ -+#define FFMPEG_LICENSE "LGPL version 2.1 or later" -+#define CONFIG_THIS_YEAR 2020 -+#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" -+#define AVCONV_DATADIR "/usr/local/share/ffmpeg" -+#define CC_IDENT "gcc 13 (Debian 13.2.0-9)" -+#define av_restrict restrict -+#define EXTERN_PREFIX "" -+#define EXTERN_ASM -+#define BUILDSUF "" -+#define SLIBSUF ".so" -+#define HAVE_MMX2 HAVE_MMXEXT -+#define SWS_MAX_FILTER_SIZE 256 -+#define ARCH_AARCH64 0 -+#define ARCH_ALPHA 0 -+#define ARCH_ARM 0 -+#define ARCH_AVR32 0 -+#define ARCH_AVR32_AP 0 -+#define ARCH_AVR32_UC 0 -+#define ARCH_BFIN 0 -+#define ARCH_IA64 0 -+#define ARCH_LOONGARCH64 1 -+#define ARCH_M68K 0 -+#define ARCH_MIPS 0 -+#define ARCH_MIPS64 0 -+#define ARCH_PARISC 0 -+#define ARCH_PPC 0 -+#define ARCH_PPC64 0 -+#define ARCH_S390 0 -+#define ARCH_SH4 0 -+#define ARCH_SPARC 0 -+#define ARCH_SPARC64 0 -+#define ARCH_TILEGX 0 -+#define ARCH_TILEPRO 0 -+#define ARCH_TOMI 0 -+#define ARCH_X86 0 -+#define ARCH_X86_32 0 -+#define ARCH_X86_64 0 -+#define HAVE_ARMV5TE 0 -+#define HAVE_ARMV6 0 -+#define HAVE_ARMV6T2 0 -+#define HAVE_ARMV8 0 -+#define HAVE_NEON 0 -+#define HAVE_VFP 0 -+#define HAVE_VFPV3 0 -+#define HAVE_SETEND 0 -+#define HAVE_ALTIVEC 0 -+#define HAVE_DCBZL 0 -+#define HAVE_LDBRX 0 -+#define HAVE_POWER8 0 -+#define HAVE_PPC4XX 0 -+#define HAVE_VSX 0 -+#define HAVE_AESNI 0 -+#define HAVE_AMD3DNOW 0 -+#define HAVE_AMD3DNOWEXT 0 -+#define HAVE_AVX 0 -+#define HAVE_AVX2 0 -+#define HAVE_AVX512 0 -+#define HAVE_FMA3 0 -+#define HAVE_FMA4 0 -+#define HAVE_MMX 0 -+#define HAVE_MMXEXT 0 -+#define HAVE_SSE 0 -+#define HAVE_SSE2 0 -+#define HAVE_SSE3 0 -+#define HAVE_SSE4 0 -+#define HAVE_SSE42 0 -+#define HAVE_SSSE3 0 -+#define HAVE_XOP 0 -+#define HAVE_CPUNOP 0 -+#define HAVE_I686 0 -+#define HAVE_MIPSFPU 0 -+#define HAVE_MIPS32R2 0 -+#define HAVE_MIPS32R5 0 -+#define HAVE_MIPS64R2 0 -+#define HAVE_MIPS32R6 0 -+#define HAVE_MIPS64R6 0 -+#define HAVE_MIPSDSP 0 -+#define HAVE_MIPSDSPR2 0 -+#define HAVE_MSA 0 -+#define HAVE_MSA2 0 -+#define HAVE_LOONGSON2 0 -+#define HAVE_LOONGSON3 0 -+#define HAVE_MMI 0 -+#define HAVE_ARMV5TE_EXTERNAL 0 -+#define HAVE_ARMV6_EXTERNAL 0 -+#define HAVE_ARMV6T2_EXTERNAL 0 -+#define HAVE_ARMV8_EXTERNAL 0 -+#define HAVE_NEON_EXTERNAL 0 -+#define HAVE_VFP_EXTERNAL 0 -+#define HAVE_VFPV3_EXTERNAL 0 -+#define HAVE_SETEND_EXTERNAL 0 -+#define HAVE_ALTIVEC_EXTERNAL 0 -+#define HAVE_DCBZL_EXTERNAL 0 -+#define HAVE_LDBRX_EXTERNAL 0 -+#define HAVE_POWER8_EXTERNAL 0 -+#define HAVE_PPC4XX_EXTERNAL 0 -+#define HAVE_VSX_EXTERNAL 0 -+#define HAVE_AESNI_EXTERNAL 0 -+#define HAVE_AMD3DNOW_EXTERNAL 0 -+#define HAVE_AMD3DNOWEXT_EXTERNAL 0 -+#define HAVE_AVX_EXTERNAL 0 -+#define HAVE_AVX2_EXTERNAL 0 -+#define HAVE_AVX512_EXTERNAL 0 -+#define HAVE_FMA3_EXTERNAL 0 -+#define HAVE_FMA4_EXTERNAL 0 -+#define HAVE_MMX_EXTERNAL 0 -+#define HAVE_MMXEXT_EXTERNAL 0 -+#define HAVE_SSE_EXTERNAL 0 -+#define HAVE_SSE2_EXTERNAL 0 -+#define HAVE_SSE3_EXTERNAL 0 -+#define HAVE_SSE4_EXTERNAL 0 -+#define HAVE_SSE42_EXTERNAL 0 -+#define HAVE_SSSE3_EXTERNAL 0 -+#define HAVE_XOP_EXTERNAL 0 -+#define HAVE_CPUNOP_EXTERNAL 0 -+#define HAVE_I686_EXTERNAL 0 -+#define HAVE_MIPSFPU_EXTERNAL 0 -+#define HAVE_MIPS32R2_EXTERNAL 0 -+#define HAVE_MIPS32R5_EXTERNAL 0 -+#define HAVE_MIPS64R2_EXTERNAL 0 -+#define HAVE_MIPS32R6_EXTERNAL 0 -+#define HAVE_MIPS64R6_EXTERNAL 0 -+#define HAVE_MIPSDSP_EXTERNAL 0 -+#define HAVE_MIPSDSPR2_EXTERNAL 0 -+#define HAVE_MSA_EXTERNAL 0 -+#define HAVE_MSA2_EXTERNAL 0 -+#define HAVE_LOONGSON2_EXTERNAL 0 -+#define HAVE_LOONGSON3_EXTERNAL 0 -+#define HAVE_MMI_EXTERNAL 0 -+#define HAVE_ARMV5TE_INLINE 0 -+#define HAVE_ARMV6_INLINE 0 -+#define HAVE_ARMV6T2_INLINE 0 -+#define HAVE_ARMV8_INLINE 0 -+#define HAVE_NEON_INLINE 0 -+#define HAVE_VFP_INLINE 0 -+#define HAVE_VFPV3_INLINE 0 -+#define HAVE_SETEND_INLINE 0 -+#define HAVE_ALTIVEC_INLINE 0 -+#define HAVE_DCBZL_INLINE 0 -+#define HAVE_LDBRX_INLINE 0 -+#define HAVE_POWER8_INLINE 0 -+#define HAVE_PPC4XX_INLINE 0 -+#define HAVE_VSX_INLINE 0 -+#define HAVE_AESNI_INLINE 0 -+#define HAVE_AMD3DNOW_INLINE 0 -+#define HAVE_AMD3DNOWEXT_INLINE 0 -+#define HAVE_AVX_INLINE 0 -+#define HAVE_AVX2_INLINE 0 -+#define HAVE_AVX512_INLINE 0 -+#define HAVE_FMA3_INLINE 0 -+#define HAVE_FMA4_INLINE 0 -+#define HAVE_MMX_INLINE 0 -+#define HAVE_MMXEXT_INLINE 0 -+#define HAVE_SSE_INLINE 0 -+#define HAVE_SSE2_INLINE 0 -+#define HAVE_SSE3_INLINE 0 -+#define HAVE_SSE4_INLINE 0 -+#define HAVE_SSE42_INLINE 0 -+#define HAVE_SSSE3_INLINE 0 -+#define HAVE_XOP_INLINE 0 -+#define HAVE_CPUNOP_INLINE 0 -+#define HAVE_I686_INLINE 0 -+#define HAVE_MIPSFPU_INLINE 0 -+#define HAVE_MIPS32R2_INLINE 0 -+#define HAVE_MIPS32R5_INLINE 0 -+#define HAVE_MIPS64R2_INLINE 0 -+#define HAVE_MIPS32R6_INLINE 0 -+#define HAVE_MIPS64R6_INLINE 0 -+#define HAVE_MIPSDSP_INLINE 0 -+#define HAVE_MIPSDSPR2_INLINE 0 -+#define HAVE_MSA_INLINE 0 -+#define HAVE_MSA2_INLINE 0 -+#define HAVE_LOONGSON2_INLINE 0 -+#define HAVE_LOONGSON3_INLINE 0 -+#define HAVE_MMI_INLINE 0 -+#define HAVE_ALIGNED_STACK 1 -+#define HAVE_FAST_64BIT 1 -+#define HAVE_FAST_CLZ 1 -+#define HAVE_FAST_CMOV 0 -+#define HAVE_LOCAL_ALIGNED 0 -+#define HAVE_SIMD_ALIGN_16 0 -+#define HAVE_SIMD_ALIGN_32 0 -+#define HAVE_SIMD_ALIGN_64 0 -+#define HAVE_ATOMIC_CAS_PTR 0 -+#define HAVE_MACHINE_RW_BARRIER 0 -+#define HAVE_MEMORYBARRIER 0 -+#define HAVE_MM_EMPTY 0 -+#define HAVE_RDTSC 0 -+#define HAVE_SEM_TIMEDWAIT 1 -+#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 -+#define HAVE_CABS 0 -+#define HAVE_CEXP 0 -+#define HAVE_INLINE_ASM 1 -+#define HAVE_SYMVER 0 -+#define HAVE_X86ASM 0 -+#define HAVE_BIGENDIAN 0 -+#define HAVE_FAST_UNALIGNED 1 -+#define HAVE_ARPA_INET_H 0 -+#define HAVE_ASM_TYPES_H 1 -+#define HAVE_CDIO_PARANOIA_H 0 -+#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 -+#define HAVE_CUDA_H 0 -+#define HAVE_DISPATCH_DISPATCH_H 0 -+#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 -+#define HAVE_DEV_IC_BT8XX_H 0 -+#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 -+#define HAVE_DIRECT_H 0 -+#define HAVE_DIRENT_H 1 -+#define HAVE_DXGIDEBUG_H 0 -+#define HAVE_DXVA_H 0 -+#define HAVE_ES2_GL_H 0 -+#define HAVE_GSM_H 0 -+#define HAVE_IO_H 0 -+#define HAVE_LINUX_PERF_EVENT_H 1 -+#define HAVE_MACHINE_IOCTL_BT848_H 0 -+#define HAVE_MACHINE_IOCTL_METEOR_H 0 -+#define HAVE_MALLOC_H 1 -+#define HAVE_OPENCV2_CORE_CORE_C_H 0 -+#define HAVE_OPENGL_GL3_H 0 -+#define HAVE_POLL_H 1 -+#define HAVE_SYS_PARAM_H 1 -+#define HAVE_SYS_RESOURCE_H 1 -+#define HAVE_SYS_SELECT_H 1 -+#define HAVE_SYS_SOUNDCARD_H 1 -+#define HAVE_SYS_TIME_H 1 -+#define HAVE_SYS_UN_H 1 -+#define HAVE_SYS_VIDEOIO_H 0 -+#define HAVE_TERMIOS_H 1 -+#define HAVE_UDPLITE_H 0 -+#define HAVE_UNISTD_H 1 -+#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ -+#define HAVE_WINDOWS_H 0 -+#define HAVE_WINSOCK2_H 0 -+#define HAVE_INTRINSICS_NEON 0 -+#define HAVE_ATANF 1 -+#define HAVE_ATAN2F 1 -+#define HAVE_CBRT 1 -+#define HAVE_CBRTF 1 -+#define HAVE_COPYSIGN 1 -+#define HAVE_COSF 1 -+#define HAVE_ERF 1 -+#define HAVE_EXP2 1 -+#define HAVE_EXP2F 1 -+#define HAVE_EXPF 1 -+#define HAVE_HYPOT 1 -+#define HAVE_ISFINITE 1 -+#define HAVE_ISINF 1 -+#define HAVE_ISNAN 1 -+#define HAVE_LDEXPF 1 -+#define HAVE_LLRINT 1 -+#define HAVE_LLRINTF 1 -+#define HAVE_LOG2 1 -+#define HAVE_LOG2F 1 -+#define HAVE_LOG10F 1 -+#define HAVE_LRINT 1 -+#define HAVE_LRINTF 1 -+#define HAVE_POWF 1 -+#define HAVE_RINT 1 -+#define HAVE_ROUND 1 -+#define HAVE_ROUNDF 1 -+#define HAVE_SINF 1 -+#define HAVE_TRUNC 1 -+#define HAVE_TRUNCF 1 -+#define HAVE_DOS_PATHS 0 -+#define HAVE_LIBC_MSVCRT 0 -+#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 -+#define HAVE_SECTION_DATA_REL_RO 1 -+#define HAVE_THREADS 1 -+#define HAVE_UWP 0 -+#define HAVE_WINRT 0 -+#define HAVE_ACCESS 1 -+#define HAVE_ALIGNED_MALLOC 0 -+#define HAVE_ARC4RANDOM 0 -+#define HAVE_CLOCK_GETTIME 1 -+#define HAVE_CLOSESOCKET 0 -+#define HAVE_COMMANDLINETOARGVW 0 -+#define HAVE_FCNTL 1 -+#define HAVE_GETADDRINFO 0 -+#define HAVE_GETHRTIME 0 -+#define HAVE_GETOPT 1 -+#define HAVE_GETMODULEHANDLE 0 -+#define HAVE_GETPROCESSAFFINITYMASK 0 -+#define HAVE_GETPROCESSMEMORYINFO 0 -+#define HAVE_GETPROCESSTIMES 0 -+#define HAVE_GETRUSAGE 1 -+#define HAVE_GETSTDHANDLE 0 -+#define HAVE_GETSYSTEMTIMEASFILETIME 0 -+#define HAVE_GETTIMEOFDAY 1 -+#define HAVE_GLOB 1 -+#define HAVE_GLXGETPROCADDRESS 0 -+#define HAVE_GMTIME_R 1 -+#define HAVE_INET_ATON 0 -+#define HAVE_ISATTY 1 -+#define HAVE_KBHIT 0 -+#define HAVE_LOCALTIME_R 1 -+#define HAVE_LSTAT 1 -+#define HAVE_LZO1X_999_COMPRESS 0 -+#define HAVE_MACH_ABSOLUTE_TIME 0 -+#define HAVE_MAPVIEWOFFILE 0 -+#define HAVE_MEMALIGN 1 -+#define HAVE_MKSTEMP 1 -+#define HAVE_MMAP 1 -+#define HAVE_MPROTECT 1 -+#define HAVE_NANOSLEEP 1 -+#define HAVE_PEEKNAMEDPIPE 0 -+#define HAVE_POSIX_MEMALIGN 1 -+#define HAVE_PTHREAD_CANCEL 1 -+#define HAVE_SCHED_GETAFFINITY 1 -+#define HAVE_SECITEMIMPORT 0 -+#define HAVE_SETCONSOLETEXTATTRIBUTE 0 -+#define HAVE_SETCONSOLECTRLHANDLER 0 -+#define HAVE_SETDLLDIRECTORY 0 -+#define HAVE_SETMODE 0 -+#define HAVE_SETRLIMIT 1 -+#define HAVE_SLEEP 0 -+#define HAVE_STRERROR_R 1 -+#define HAVE_SYSCONF 1 -+#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ -+#define HAVE_USLEEP 1 -+#define HAVE_UTGETOSTYPEFROMSTRING 0 -+#define HAVE_VIRTUALALLOC 0 -+#define HAVE_WGLGETPROCADDRESS 0 -+#define HAVE_BCRYPT 0 -+#define HAVE_VAAPI_DRM 0 -+#define HAVE_VAAPI_X11 0 -+#define HAVE_VDPAU_X11 0 -+#define HAVE_PTHREADS 1 -+#define HAVE_OS2THREADS 0 -+#define HAVE_W32THREADS 0 -+#define HAVE_AS_ARCH_DIRECTIVE 0 -+#define HAVE_AS_DN_DIRECTIVE 0 -+#define HAVE_AS_FPU_DIRECTIVE 0 -+#define HAVE_AS_FUNC 0 -+#define HAVE_AS_OBJECT_ARCH 0 -+#define HAVE_ASM_MOD_Q 0 -+#define HAVE_BLOCKS_EXTENSION 0 -+#define HAVE_EBP_AVAILABLE 0 -+#define HAVE_EBX_AVAILABLE 0 -+#define HAVE_GNU_AS 0 -+#define HAVE_GNU_WINDRES 0 -+#define HAVE_IBM_ASM 0 -+#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 -+#define HAVE_INLINE_ASM_LABELS 1 -+#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 -+#define HAVE_PRAGMA_DEPRECATED 1 -+#define HAVE_RSYNC_CONTIMEOUT 1 -+#define HAVE_SYMVER_ASM_LABEL 0 -+#define HAVE_SYMVER_GNU_ASM 1 -+#define HAVE_VFP_ARGS 0 -+#define HAVE_XFORM_ASM 0 -+#define HAVE_XMM_CLOBBERS 0 -+#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 -+#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 -+#define HAVE_SOCKLEN_T 0 -+#define HAVE_STRUCT_ADDRINFO 0 -+#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 -+#define HAVE_STRUCT_IP_MREQ_SOURCE 0 -+#define HAVE_STRUCT_IPV6_MREQ 0 -+#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 -+#define HAVE_STRUCT_POLLFD 0 -+#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 -+#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 -+#define HAVE_STRUCT_SOCKADDR_IN6 0 -+#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 -+#define HAVE_STRUCT_SOCKADDR_STORAGE 0 -+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 -+#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 -+#define HAVE_LIBDRM_GETFB2 0 -+#define HAVE_MAKEINFO 0 -+#define HAVE_MAKEINFO_HTML 0 -+#define HAVE_OPENCL_D3D11 0 -+#define HAVE_OPENCL_DRM_ARM 0 -+#define HAVE_OPENCL_DRM_BEIGNET 0 -+#define HAVE_OPENCL_DXVA2 0 -+#define HAVE_OPENCL_VAAPI_BEIGNET 0 -+#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 -+#define HAVE_PERL 1 -+#define HAVE_POD2MAN 1 -+#define HAVE_TEXI2HTML 0 -+#define CONFIG_DOC 0 -+#define CONFIG_HTMLPAGES 0 -+#define CONFIG_MANPAGES 0 -+#define CONFIG_PODPAGES 0 -+#define CONFIG_TXTPAGES 0 -+#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 -+#define CONFIG_AVIO_READING_EXAMPLE 1 -+#define CONFIG_DECODE_AUDIO_EXAMPLE 1 -+#define CONFIG_DECODE_VIDEO_EXAMPLE 1 -+#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 -+#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 -+#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 -+#define CONFIG_EXTRACT_MVS_EXAMPLE 1 -+#define CONFIG_FILTER_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 -+#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 -+#define CONFIG_HW_DECODE_EXAMPLE 1 -+#define CONFIG_METADATA_EXAMPLE 1 -+#define CONFIG_MUXING_EXAMPLE 0 -+#define CONFIG_QSVDEC_EXAMPLE 0 -+#define CONFIG_REMUXING_EXAMPLE 1 -+#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 -+#define CONFIG_SCALING_VIDEO_EXAMPLE 0 -+#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 -+#define CONFIG_TRANSCODING_EXAMPLE 0 -+#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 -+#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 -+#define CONFIG_AVISYNTH 0 -+#define CONFIG_FREI0R 0 -+#define CONFIG_LIBCDIO 0 -+#define CONFIG_LIBDAVS2 0 -+#define CONFIG_LIBRUBBERBAND 0 -+#define CONFIG_LIBVIDSTAB 0 -+#define CONFIG_LIBX264 0 -+#define CONFIG_LIBX265 0 -+#define CONFIG_LIBXAVS 0 -+#define CONFIG_LIBXAVS2 0 -+#define CONFIG_LIBXVID 0 -+#define CONFIG_DECKLINK 0 -+#define CONFIG_LIBFDK_AAC 0 -+#define CONFIG_OPENSSL 0 -+#define CONFIG_LIBTLS 0 -+#define CONFIG_GMP 0 -+#define CONFIG_LIBARIBB24 0 -+#define CONFIG_LIBLENSFUN 0 -+#define CONFIG_LIBOPENCORE_AMRNB 0 -+#define CONFIG_LIBOPENCORE_AMRWB 0 -+#define CONFIG_LIBVO_AMRWBENC 0 -+#define CONFIG_MBEDTLS 0 -+#define CONFIG_RKMPP 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_CHROMAPRINT 0 -+#define CONFIG_GCRYPT 0 -+#define CONFIG_GNUTLS 0 -+#define CONFIG_JNI 0 -+#define CONFIG_LADSPA 0 -+#define CONFIG_LIBAOM 0 -+#define CONFIG_LIBASS 0 -+#define CONFIG_LIBBLURAY 0 -+#define CONFIG_LIBBS2B 0 -+#define CONFIG_LIBCACA 0 -+#define CONFIG_LIBCELT 0 -+#define CONFIG_LIBCODEC2 0 -+#define CONFIG_LIBDAV1D 0 -+#define CONFIG_LIBDC1394 0 -+#define CONFIG_LIBDRM 0 -+#define CONFIG_LIBFLITE 0 -+#define CONFIG_LIBFONTCONFIG 0 -+#define CONFIG_LIBFREETYPE 0 -+#define CONFIG_LIBFRIBIDI 0 -+#define CONFIG_LIBGLSLANG 0 -+#define CONFIG_LIBGME 0 -+#define CONFIG_LIBGSM 0 -+#define CONFIG_LIBIEC61883 0 -+#define CONFIG_LIBILBC 0 -+#define CONFIG_LIBJACK 0 -+#define CONFIG_LIBKLVANC 0 -+#define CONFIG_LIBKVAZAAR 0 -+#define CONFIG_LIBMODPLUG 0 -+#define CONFIG_LIBMP3LAME 0 -+#define CONFIG_LIBMYSOFA 0 -+#define CONFIG_LIBOPENCV 0 -+#define CONFIG_LIBOPENH264 0 -+#define CONFIG_LIBOPENJPEG 0 -+#define CONFIG_LIBOPENMPT 0 -+#define CONFIG_LIBOPENVINO 0 -+#define CONFIG_LIBOPUS 1 -+#define CONFIG_LIBPULSE 0 -+#define CONFIG_LIBRABBITMQ 0 -+#define CONFIG_LIBRAV1E 0 -+#define CONFIG_LIBRSVG 0 -+#define CONFIG_LIBRTMP 0 -+#define CONFIG_LIBSHINE 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_LIBSNAPPY 0 -+#define CONFIG_LIBSOXR 0 -+#define CONFIG_LIBSPEEX 0 -+#define CONFIG_LIBSRT 0 -+#define CONFIG_LIBSSH 0 -+#define CONFIG_LIBSVTAV1 0 -+#define CONFIG_LIBTENSORFLOW 0 -+#define CONFIG_LIBTESSERACT 0 -+#define CONFIG_LIBTHEORA 0 -+#define CONFIG_LIBTWOLAME 0 -+#define CONFIG_LIBV4L2 0 -+#define CONFIG_LIBVMAF 0 -+#define CONFIG_LIBVORBIS 0 -+#define CONFIG_LIBVPX 0 -+#define CONFIG_LIBWAVPACK 0 -+#define CONFIG_LIBWEBP 0 -+#define CONFIG_LIBXML2 0 -+#define CONFIG_LIBZIMG 0 -+#define CONFIG_LIBZMQ 0 -+#define CONFIG_LIBZVBI 0 -+#define CONFIG_LV2 0 -+#define CONFIG_MEDIACODEC 0 -+#define CONFIG_OPENAL 0 -+#define CONFIG_OPENGL 0 -+#define CONFIG_POCKETSPHINX 0 -+#define CONFIG_VAPOURSYNTH 0 -+#define CONFIG_ALSA 0 -+#define CONFIG_APPKIT 0 -+#define CONFIG_AVFOUNDATION 0 -+#define CONFIG_BZLIB 0 -+#define CONFIG_COREIMAGE 0 -+#define CONFIG_ICONV 0 -+#define CONFIG_LIBXCB 0 -+#define CONFIG_LIBXCB_SHM 0 -+#define CONFIG_LIBXCB_SHAPE 0 -+#define CONFIG_LIBXCB_XFIXES 0 -+#define CONFIG_LZMA 0 -+#define CONFIG_MEDIAFOUNDATION 0 -+#define CONFIG_SCHANNEL 0 -+#define CONFIG_SDL2 0 -+#define CONFIG_SECURETRANSPORT 0 -+#define CONFIG_SNDIO 0 -+#define CONFIG_XLIB 0 -+#define CONFIG_ZLIB 0 -+#define CONFIG_CUDA_NVCC 0 -+#define CONFIG_CUDA_SDK 0 -+#define CONFIG_LIBNPP 0 -+#define CONFIG_LIBMFX 0 -+#define CONFIG_MMAL 0 -+#define CONFIG_OMX 0 -+#define CONFIG_OPENCL 0 -+#define CONFIG_VULKAN 0 -+#define CONFIG_AMF 0 -+#define CONFIG_AUDIOTOOLBOX 0 -+#define CONFIG_CRYSTALHD 0 -+#define CONFIG_CUDA 0 -+#define CONFIG_CUDA_LLVM 0 -+#define CONFIG_CUVID 0 -+#define CONFIG_D3D11VA 0 -+#define CONFIG_DXVA2 0 -+#define CONFIG_FFNVCODEC 0 -+#define CONFIG_NVDEC 0 -+#define CONFIG_NVENC 0 -+#define CONFIG_VAAPI 0 -+#define CONFIG_VDPAU 0 -+#define CONFIG_VIDEOTOOLBOX 0 -+#define CONFIG_V4L2_M2M 0 -+#define CONFIG_XVMC 0 -+#define CONFIG_FTRAPV 0 -+#define CONFIG_GRAY 0 -+#define CONFIG_HARDCODED_TABLES 0 -+#define CONFIG_OMX_RPI 0 -+#define CONFIG_RUNTIME_CPUDETECT 1 -+#define CONFIG_SAFE_BITSTREAM_READER 1 -+#define CONFIG_SHARED 0 -+#define CONFIG_SMALL 0 -+#define CONFIG_STATIC 1 -+#define CONFIG_SWSCALE_ALPHA 1 -+#define CONFIG_GPL 0 -+#define CONFIG_NONFREE 0 -+#define CONFIG_VERSION3 0 -+#define CONFIG_AVDEVICE 0 -+#define CONFIG_AVFILTER 0 -+#define CONFIG_SWSCALE 0 -+#define CONFIG_POSTPROC 0 -+#define CONFIG_AVFORMAT 1 -+#define CONFIG_AVCODEC 1 -+#define CONFIG_SWRESAMPLE 0 -+#define CONFIG_AVRESAMPLE 0 -+#define CONFIG_AVUTIL 1 -+#define CONFIG_FFPLAY 0 -+#define CONFIG_FFPROBE 0 -+#define CONFIG_FFMPEG 0 -+#define CONFIG_DCT 1 -+#define CONFIG_DWT 0 -+#define CONFIG_ERROR_RESILIENCE 0 -+#define CONFIG_FAAN 0 -+#define CONFIG_FAST_UNALIGNED 1 -+#define CONFIG_FFT 1 -+#define CONFIG_LSP 0 -+#define CONFIG_LZO 0 -+#define CONFIG_MDCT 1 -+#define CONFIG_PIXELUTILS 0 -+#define CONFIG_NETWORK 0 -+#define CONFIG_RDFT 1 -+#define CONFIG_AUTODETECT 0 -+#define CONFIG_FONTCONFIG 0 -+#define CONFIG_LARGE_TESTS 1 -+#define CONFIG_LINUX_PERF 0 -+#define CONFIG_MEMORY_POISONING 0 -+#define CONFIG_NEON_CLOBBER_TEST 0 -+#define CONFIG_OSSFUZZ 0 -+#define CONFIG_PIC 1 -+#define CONFIG_THUMB 0 -+#define CONFIG_VALGRIND_BACKTRACE 0 -+#define CONFIG_XMM_CLOBBER_TEST 0 -+#define CONFIG_BSFS 1 -+#define CONFIG_DECODERS 1 -+#define CONFIG_ENCODERS 0 -+#define CONFIG_HWACCELS 0 -+#define CONFIG_PARSERS 1 -+#define CONFIG_INDEVS 0 -+#define CONFIG_OUTDEVS 0 -+#define CONFIG_FILTERS 0 -+#define CONFIG_DEMUXERS 1 -+#define CONFIG_MUXERS 0 -+#define CONFIG_PROTOCOLS 0 -+#define CONFIG_AANDCTTABLES 0 -+#define CONFIG_AC3DSP 0 -+#define CONFIG_ADTS_HEADER 1 -+#define CONFIG_ATSC_A53 1 -+#define CONFIG_AUDIO_FRAME_QUEUE 0 -+#define CONFIG_AUDIODSP 0 -+#define CONFIG_BLOCKDSP 0 -+#define CONFIG_BSWAPDSP 0 -+#define CONFIG_CABAC 1 -+#define CONFIG_CBS 0 -+#define CONFIG_CBS_AV1 0 -+#define CONFIG_CBS_H264 0 -+#define CONFIG_CBS_H265 0 -+#define CONFIG_CBS_JPEG 0 -+#define CONFIG_CBS_MPEG2 0 -+#define CONFIG_CBS_VP9 0 -+#define CONFIG_DIRAC_PARSE 1 -+#define CONFIG_DNN 0 -+#define CONFIG_DVPROFILE 0 -+#define CONFIG_EXIF 0 -+#define CONFIG_FAANDCT 0 -+#define CONFIG_FAANIDCT 0 -+#define CONFIG_FDCTDSP 0 -+#define CONFIG_FLACDSP 1 -+#define CONFIG_FMTCONVERT 0 -+#define CONFIG_FRAME_THREAD_ENCODER 0 -+#define CONFIG_G722DSP 0 -+#define CONFIG_GOLOMB 1 -+#define CONFIG_GPLV3 0 -+#define CONFIG_H263DSP 0 -+#define CONFIG_H264CHROMA 1 -+#define CONFIG_H264DSP 1 -+#define CONFIG_H264PARSE 1 -+#define CONFIG_H264PRED 1 -+#define CONFIG_H264QPEL 1 -+#define CONFIG_HEVCPARSE 0 -+#define CONFIG_HPELDSP 1 -+#define CONFIG_HUFFMAN 0 -+#define CONFIG_HUFFYUVDSP 0 -+#define CONFIG_HUFFYUVENCDSP 0 -+#define CONFIG_IDCTDSP 0 -+#define CONFIG_IIRFILTER 0 -+#define CONFIG_MDCT15 1 -+#define CONFIG_INTRAX8 0 -+#define CONFIG_ISO_MEDIA 1 -+#define CONFIG_IVIDSP 0 -+#define CONFIG_JPEGTABLES 0 -+#define CONFIG_LGPLV3 0 -+#define CONFIG_LIBX262 0 -+#define CONFIG_LLAUDDSP 0 -+#define CONFIG_LLVIDDSP 0 -+#define CONFIG_LLVIDENCDSP 0 -+#define CONFIG_LPC 0 -+#define CONFIG_LZF 0 -+#define CONFIG_ME_CMP 0 -+#define CONFIG_MPEG_ER 0 -+#define CONFIG_MPEGAUDIO 1 -+#define CONFIG_MPEGAUDIODSP 1 -+#define CONFIG_MPEGAUDIOHEADER 1 -+#define CONFIG_MPEGVIDEO 0 -+#define CONFIG_MPEGVIDEOENC 0 -+#define CONFIG_MSS34DSP 0 -+#define CONFIG_PIXBLOCKDSP 0 -+#define CONFIG_QPELDSP 0 -+#define CONFIG_QSV 0 -+#define CONFIG_QSVDEC 0 -+#define CONFIG_QSVENC 0 -+#define CONFIG_QSVVPP 0 -+#define CONFIG_RANGECODER 0 -+#define CONFIG_RIFFDEC 1 -+#define CONFIG_RIFFENC 0 -+#define CONFIG_RTPDEC 0 -+#define CONFIG_RTPENC_CHAIN 0 -+#define CONFIG_RV34DSP 0 -+#define CONFIG_SCENE_SAD 0 -+#define CONFIG_SINEWIN 1 -+#define CONFIG_SNAPPY 0 -+#define CONFIG_SRTP 0 -+#define CONFIG_STARTCODE 1 -+#define CONFIG_TEXTUREDSP 0 -+#define CONFIG_TEXTUREDSPENC 0 -+#define CONFIG_TPELDSP 0 -+#define CONFIG_VAAPI_1 0 -+#define CONFIG_VAAPI_ENCODE 0 -+#define CONFIG_VC1DSP 0 -+#define CONFIG_VIDEODSP 1 -+#define CONFIG_VP3DSP 1 -+#define CONFIG_VP56DSP 0 -+#define CONFIG_VP8DSP 1 -+#define CONFIG_WMA_FREQS 0 -+#define CONFIG_WMV2DSP 0 -+#define CONFIG_AAC_ADTSTOASC_BSF 0 -+#define CONFIG_AV1_FRAME_MERGE_BSF 0 -+#define CONFIG_AV1_FRAME_SPLIT_BSF 0 -+#define CONFIG_AV1_METADATA_BSF 0 -+#define CONFIG_CHOMP_BSF 0 -+#define CONFIG_DUMP_EXTRADATA_BSF 0 -+#define CONFIG_DCA_CORE_BSF 0 -+#define CONFIG_EAC3_CORE_BSF 0 -+#define CONFIG_EXTRACT_EXTRADATA_BSF 0 -+#define CONFIG_FILTER_UNITS_BSF 0 -+#define CONFIG_H264_METADATA_BSF 0 -+#define CONFIG_H264_MP4TOANNEXB_BSF 0 -+#define CONFIG_H264_REDUNDANT_PPS_BSF 0 -+#define CONFIG_HAPQA_EXTRACT_BSF 0 -+#define CONFIG_HEVC_METADATA_BSF 0 -+#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 -+#define CONFIG_IMX_DUMP_HEADER_BSF 0 -+#define CONFIG_MJPEG2JPEG_BSF 0 -+#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 -+#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 -+#define CONFIG_MPEG2_METADATA_BSF 0 -+#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 -+#define CONFIG_MOV2TEXTSUB_BSF 0 -+#define CONFIG_NOISE_BSF 0 -+#define CONFIG_NULL_BSF 1 -+#define CONFIG_OPUS_METADATA_BSF 0 -+#define CONFIG_PCM_RECHUNK_BSF 0 -+#define CONFIG_PRORES_METADATA_BSF 0 -+#define CONFIG_REMOVE_EXTRADATA_BSF 0 -+#define CONFIG_TEXT2MOVSUB_BSF 0 -+#define CONFIG_TRACE_HEADERS_BSF 0 -+#define CONFIG_TRUEHD_CORE_BSF 0 -+#define CONFIG_VP9_METADATA_BSF 0 -+#define CONFIG_VP9_RAW_REORDER_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 -+#define CONFIG_AASC_DECODER 0 -+#define CONFIG_AIC_DECODER 0 -+#define CONFIG_ALIAS_PIX_DECODER 0 -+#define CONFIG_AGM_DECODER 0 -+#define CONFIG_AMV_DECODER 0 -+#define CONFIG_ANM_DECODER 0 -+#define CONFIG_ANSI_DECODER 0 -+#define CONFIG_APNG_DECODER 0 -+#define CONFIG_ARBC_DECODER 0 -+#define CONFIG_ASV1_DECODER 0 -+#define CONFIG_ASV2_DECODER 0 -+#define CONFIG_AURA_DECODER 0 -+#define CONFIG_AURA2_DECODER 0 -+#define CONFIG_AVRP_DECODER 0 -+#define CONFIG_AVRN_DECODER 0 -+#define CONFIG_AVS_DECODER 0 -+#define CONFIG_AVUI_DECODER 0 -+#define CONFIG_AYUV_DECODER 0 -+#define CONFIG_BETHSOFTVID_DECODER 0 -+#define CONFIG_BFI_DECODER 0 -+#define CONFIG_BINK_DECODER 0 -+#define CONFIG_BITPACKED_DECODER 0 -+#define CONFIG_BMP_DECODER 0 -+#define CONFIG_BMV_VIDEO_DECODER 0 -+#define CONFIG_BRENDER_PIX_DECODER 0 -+#define CONFIG_C93_DECODER 0 -+#define CONFIG_CAVS_DECODER 0 -+#define CONFIG_CDGRAPHICS_DECODER 0 -+#define CONFIG_CDTOONS_DECODER 0 -+#define CONFIG_CDXL_DECODER 0 -+#define CONFIG_CFHD_DECODER 0 -+#define CONFIG_CINEPAK_DECODER 0 -+#define CONFIG_CLEARVIDEO_DECODER 0 -+#define CONFIG_CLJR_DECODER 0 -+#define CONFIG_CLLC_DECODER 0 -+#define CONFIG_COMFORTNOISE_DECODER 0 -+#define CONFIG_CPIA_DECODER 0 -+#define CONFIG_CSCD_DECODER 0 -+#define CONFIG_CYUV_DECODER 0 -+#define CONFIG_DDS_DECODER 0 -+#define CONFIG_DFA_DECODER 0 -+#define CONFIG_DIRAC_DECODER 0 -+#define CONFIG_DNXHD_DECODER 0 -+#define CONFIG_DPX_DECODER 0 -+#define CONFIG_DSICINVIDEO_DECODER 0 -+#define CONFIG_DVAUDIO_DECODER 0 -+#define CONFIG_DVVIDEO_DECODER 0 -+#define CONFIG_DXA_DECODER 0 -+#define CONFIG_DXTORY_DECODER 0 -+#define CONFIG_DXV_DECODER 0 -+#define CONFIG_EACMV_DECODER 0 -+#define CONFIG_EAMAD_DECODER 0 -+#define CONFIG_EATGQ_DECODER 0 -+#define CONFIG_EATGV_DECODER 0 -+#define CONFIG_EATQI_DECODER 0 -+#define CONFIG_EIGHTBPS_DECODER 0 -+#define CONFIG_EIGHTSVX_EXP_DECODER 0 -+#define CONFIG_EIGHTSVX_FIB_DECODER 0 -+#define CONFIG_ESCAPE124_DECODER 0 -+#define CONFIG_ESCAPE130_DECODER 0 -+#define CONFIG_EXR_DECODER 0 -+#define CONFIG_FFV1_DECODER 0 -+#define CONFIG_FFVHUFF_DECODER 0 -+#define CONFIG_FIC_DECODER 0 -+#define CONFIG_FITS_DECODER 0 -+#define CONFIG_FLASHSV_DECODER 0 -+#define CONFIG_FLASHSV2_DECODER 0 -+#define CONFIG_FLIC_DECODER 0 -+#define CONFIG_FLV_DECODER 0 -+#define CONFIG_FMVC_DECODER 0 -+#define CONFIG_FOURXM_DECODER 0 -+#define CONFIG_FRAPS_DECODER 0 -+#define CONFIG_FRWU_DECODER 0 -+#define CONFIG_G2M_DECODER 0 -+#define CONFIG_GDV_DECODER 0 -+#define CONFIG_GIF_DECODER 0 -+#define CONFIG_H261_DECODER 0 -+#define CONFIG_H263_DECODER 0 -+#define CONFIG_H263I_DECODER 0 -+#define CONFIG_H263P_DECODER 0 -+#define CONFIG_H263_V4L2M2M_DECODER 0 -+#define CONFIG_H264_DECODER 1 -+#define CONFIG_H264_CRYSTALHD_DECODER 0 -+#define CONFIG_H264_V4L2M2M_DECODER 0 -+#define CONFIG_H264_MEDIACODEC_DECODER 0 -+#define CONFIG_H264_MMAL_DECODER 0 -+#define CONFIG_H264_QSV_DECODER 0 -+#define CONFIG_H264_RKMPP_DECODER 0 -+#define CONFIG_HAP_DECODER 0 -+#define CONFIG_HEVC_DECODER 0 -+#define CONFIG_HEVC_QSV_DECODER 0 -+#define CONFIG_HEVC_RKMPP_DECODER 0 -+#define CONFIG_HEVC_V4L2M2M_DECODER 0 -+#define CONFIG_HNM4_VIDEO_DECODER 0 -+#define CONFIG_HQ_HQA_DECODER 0 -+#define CONFIG_HQX_DECODER 0 -+#define CONFIG_HUFFYUV_DECODER 0 -+#define CONFIG_HYMT_DECODER 0 -+#define CONFIG_IDCIN_DECODER 0 -+#define CONFIG_IFF_ILBM_DECODER 0 -+#define CONFIG_IMM4_DECODER 0 -+#define CONFIG_IMM5_DECODER 0 -+#define CONFIG_INDEO2_DECODER 0 -+#define CONFIG_INDEO3_DECODER 0 -+#define CONFIG_INDEO4_DECODER 0 -+#define CONFIG_INDEO5_DECODER 0 -+#define CONFIG_INTERPLAY_VIDEO_DECODER 0 -+#define CONFIG_JPEG2000_DECODER 0 -+#define CONFIG_JPEGLS_DECODER 0 -+#define CONFIG_JV_DECODER 0 -+#define CONFIG_KGV1_DECODER 0 -+#define CONFIG_KMVC_DECODER 0 -+#define CONFIG_LAGARITH_DECODER 0 -+#define CONFIG_LOCO_DECODER 0 -+#define CONFIG_LSCR_DECODER 0 -+#define CONFIG_M101_DECODER 0 -+#define CONFIG_MAGICYUV_DECODER 0 -+#define CONFIG_MDEC_DECODER 0 -+#define CONFIG_MIMIC_DECODER 0 -+#define CONFIG_MJPEG_DECODER 0 -+#define CONFIG_MJPEGB_DECODER 0 -+#define CONFIG_MMVIDEO_DECODER 0 -+#define CONFIG_MOTIONPIXELS_DECODER 0 -+#define CONFIG_MPEG1VIDEO_DECODER 0 -+#define CONFIG_MPEG2VIDEO_DECODER 0 -+#define CONFIG_MPEG4_DECODER 0 -+#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG4_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG4_MMAL_DECODER 0 -+#define CONFIG_MPEGVIDEO_DECODER 0 -+#define CONFIG_MPEG1_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_MMAL_DECODER 0 -+#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG2_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_QSV_DECODER 0 -+#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 -+#define CONFIG_MSA1_DECODER 0 -+#define CONFIG_MSCC_DECODER 0 -+#define CONFIG_MSMPEG4V1_DECODER 0 -+#define CONFIG_MSMPEG4V2_DECODER 0 -+#define CONFIG_MSMPEG4V3_DECODER 0 -+#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MSRLE_DECODER 0 -+#define CONFIG_MSS1_DECODER 0 -+#define CONFIG_MSS2_DECODER 0 -+#define CONFIG_MSVIDEO1_DECODER 0 -+#define CONFIG_MSZH_DECODER 0 -+#define CONFIG_MTS2_DECODER 0 -+#define CONFIG_MV30_DECODER 0 -+#define CONFIG_MVC1_DECODER 0 -+#define CONFIG_MVC2_DECODER 0 -+#define CONFIG_MVDV_DECODER 0 -+#define CONFIG_MVHA_DECODER 0 -+#define CONFIG_MWSC_DECODER 0 -+#define CONFIG_MXPEG_DECODER 0 -+#define CONFIG_NOTCHLC_DECODER 0 -+#define CONFIG_NUV_DECODER 0 -+#define CONFIG_PAF_VIDEO_DECODER 0 -+#define CONFIG_PAM_DECODER 0 -+#define CONFIG_PBM_DECODER 0 -+#define CONFIG_PCX_DECODER 0 -+#define CONFIG_PFM_DECODER 0 -+#define CONFIG_PGM_DECODER 0 -+#define CONFIG_PGMYUV_DECODER 0 -+#define CONFIG_PGX_DECODER 0 -+#define CONFIG_PICTOR_DECODER 0 -+#define CONFIG_PIXLET_DECODER 0 -+#define CONFIG_PNG_DECODER 0 -+#define CONFIG_PPM_DECODER 0 -+#define CONFIG_PRORES_DECODER 0 -+#define CONFIG_PROSUMER_DECODER 0 -+#define CONFIG_PSD_DECODER 0 -+#define CONFIG_PTX_DECODER 0 -+#define CONFIG_QDRAW_DECODER 0 -+#define CONFIG_QPEG_DECODER 0 -+#define CONFIG_QTRLE_DECODER 0 -+#define CONFIG_R10K_DECODER 0 -+#define CONFIG_R210_DECODER 0 -+#define CONFIG_RASC_DECODER 0 -+#define CONFIG_RAWVIDEO_DECODER 0 -+#define CONFIG_RL2_DECODER 0 -+#define CONFIG_ROQ_DECODER 0 -+#define CONFIG_RPZA_DECODER 0 -+#define CONFIG_RSCC_DECODER 0 -+#define CONFIG_RV10_DECODER 0 -+#define CONFIG_RV20_DECODER 0 -+#define CONFIG_RV30_DECODER 0 -+#define CONFIG_RV40_DECODER 0 -+#define CONFIG_S302M_DECODER 0 -+#define CONFIG_SANM_DECODER 0 -+#define CONFIG_SCPR_DECODER 0 -+#define CONFIG_SCREENPRESSO_DECODER 0 -+#define CONFIG_SGI_DECODER 0 -+#define CONFIG_SGIRLE_DECODER 0 -+#define CONFIG_SHEERVIDEO_DECODER 0 -+#define CONFIG_SMACKER_DECODER 0 -+#define CONFIG_SMC_DECODER 0 -+#define CONFIG_SMVJPEG_DECODER 0 -+#define CONFIG_SNOW_DECODER 0 -+#define CONFIG_SP5X_DECODER 0 -+#define CONFIG_SPEEDHQ_DECODER 0 -+#define CONFIG_SRGC_DECODER 0 -+#define CONFIG_SUNRAST_DECODER 0 -+#define CONFIG_SVQ1_DECODER 0 -+#define CONFIG_SVQ3_DECODER 0 -+#define CONFIG_TARGA_DECODER 0 -+#define CONFIG_TARGA_Y216_DECODER 0 -+#define CONFIG_TDSC_DECODER 0 -+#define CONFIG_THEORA_DECODER 1 -+#define CONFIG_THP_DECODER 0 -+#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 -+#define CONFIG_TIFF_DECODER 0 -+#define CONFIG_TMV_DECODER 0 -+#define CONFIG_TRUEMOTION1_DECODER 0 -+#define CONFIG_TRUEMOTION2_DECODER 0 -+#define CONFIG_TRUEMOTION2RT_DECODER 0 -+#define CONFIG_TSCC_DECODER 0 -+#define CONFIG_TSCC2_DECODER 0 -+#define CONFIG_TXD_DECODER 0 -+#define CONFIG_ULTI_DECODER 0 -+#define CONFIG_UTVIDEO_DECODER 0 -+#define CONFIG_V210_DECODER 0 -+#define CONFIG_V210X_DECODER 0 -+#define CONFIG_V308_DECODER 0 -+#define CONFIG_V408_DECODER 0 -+#define CONFIG_V410_DECODER 0 -+#define CONFIG_VB_DECODER 0 -+#define CONFIG_VBLE_DECODER 0 -+#define CONFIG_VC1_DECODER 0 -+#define CONFIG_VC1_CRYSTALHD_DECODER 0 -+#define CONFIG_VC1IMAGE_DECODER 0 -+#define CONFIG_VC1_MMAL_DECODER 0 -+#define CONFIG_VC1_QSV_DECODER 0 -+#define CONFIG_VC1_V4L2M2M_DECODER 0 -+#define CONFIG_VCR1_DECODER 0 -+#define CONFIG_VMDVIDEO_DECODER 0 -+#define CONFIG_VMNC_DECODER 0 -+#define CONFIG_VP3_DECODER 1 -+#define CONFIG_VP4_DECODER 0 -+#define CONFIG_VP5_DECODER 0 -+#define CONFIG_VP6_DECODER 0 -+#define CONFIG_VP6A_DECODER 0 -+#define CONFIG_VP6F_DECODER 0 -+#define CONFIG_VP7_DECODER 0 -+#define CONFIG_VP8_DECODER 1 -+#define CONFIG_VP8_RKMPP_DECODER 0 -+#define CONFIG_VP8_V4L2M2M_DECODER 0 -+#define CONFIG_VP9_DECODER 0 -+#define CONFIG_VP9_RKMPP_DECODER 0 -+#define CONFIG_VP9_V4L2M2M_DECODER 0 -+#define CONFIG_VQA_DECODER 0 -+#define CONFIG_WEBP_DECODER 0 -+#define CONFIG_WCMV_DECODER 0 -+#define CONFIG_WRAPPED_AVFRAME_DECODER 0 -+#define CONFIG_WMV1_DECODER 0 -+#define CONFIG_WMV2_DECODER 0 -+#define CONFIG_WMV3_DECODER 0 -+#define CONFIG_WMV3_CRYSTALHD_DECODER 0 -+#define CONFIG_WMV3IMAGE_DECODER 0 -+#define CONFIG_WNV1_DECODER 0 -+#define CONFIG_XAN_WC3_DECODER 0 -+#define CONFIG_XAN_WC4_DECODER 0 -+#define CONFIG_XBM_DECODER 0 -+#define CONFIG_XFACE_DECODER 0 -+#define CONFIG_XL_DECODER 0 -+#define CONFIG_XPM_DECODER 0 -+#define CONFIG_XWD_DECODER 0 -+#define CONFIG_Y41P_DECODER 0 -+#define CONFIG_YLC_DECODER 0 -+#define CONFIG_YOP_DECODER 0 -+#define CONFIG_YUV4_DECODER 0 -+#define CONFIG_ZERO12V_DECODER 0 -+#define CONFIG_ZEROCODEC_DECODER 0 -+#define CONFIG_ZLIB_DECODER 0 -+#define CONFIG_ZMBV_DECODER 0 -+#define CONFIG_AAC_DECODER 1 -+#define CONFIG_AAC_FIXED_DECODER 0 -+#define CONFIG_AAC_LATM_DECODER 0 -+#define CONFIG_AC3_DECODER 0 -+#define CONFIG_AC3_FIXED_DECODER 0 -+#define CONFIG_ACELP_KELVIN_DECODER 0 -+#define CONFIG_ALAC_DECODER 0 -+#define CONFIG_ALS_DECODER 0 -+#define CONFIG_AMRNB_DECODER 0 -+#define CONFIG_AMRWB_DECODER 0 -+#define CONFIG_APE_DECODER 0 -+#define CONFIG_APTX_DECODER 0 -+#define CONFIG_APTX_HD_DECODER 0 -+#define CONFIG_ATRAC1_DECODER 0 -+#define CONFIG_ATRAC3_DECODER 0 -+#define CONFIG_ATRAC3AL_DECODER 0 -+#define CONFIG_ATRAC3P_DECODER 0 -+#define CONFIG_ATRAC3PAL_DECODER 0 -+#define CONFIG_ATRAC9_DECODER 0 -+#define CONFIG_BINKAUDIO_DCT_DECODER 0 -+#define CONFIG_BINKAUDIO_RDFT_DECODER 0 -+#define CONFIG_BMV_AUDIO_DECODER 0 -+#define CONFIG_COOK_DECODER 0 -+#define CONFIG_DCA_DECODER 0 -+#define CONFIG_DOLBY_E_DECODER 0 -+#define CONFIG_DSD_LSBF_DECODER 0 -+#define CONFIG_DSD_MSBF_DECODER 0 -+#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 -+#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 -+#define CONFIG_DSICINAUDIO_DECODER 0 -+#define CONFIG_DSS_SP_DECODER 0 -+#define CONFIG_DST_DECODER 0 -+#define CONFIG_EAC3_DECODER 0 -+#define CONFIG_EVRC_DECODER 0 -+#define CONFIG_FFWAVESYNTH_DECODER 0 -+#define CONFIG_FLAC_DECODER 1 -+#define CONFIG_G723_1_DECODER 0 -+#define CONFIG_G729_DECODER 0 -+#define CONFIG_GSM_DECODER 0 -+#define CONFIG_GSM_MS_DECODER 0 -+#define CONFIG_HCA_DECODER 0 -+#define CONFIG_HCOM_DECODER 0 -+#define CONFIG_IAC_DECODER 0 -+#define CONFIG_ILBC_DECODER 0 -+#define CONFIG_IMC_DECODER 0 -+#define CONFIG_INTERPLAY_ACM_DECODER 0 -+#define CONFIG_MACE3_DECODER 0 -+#define CONFIG_MACE6_DECODER 0 -+#define CONFIG_METASOUND_DECODER 0 -+#define CONFIG_MLP_DECODER 0 -+#define CONFIG_MP1_DECODER 0 -+#define CONFIG_MP1FLOAT_DECODER 0 -+#define CONFIG_MP2_DECODER 0 -+#define CONFIG_MP2FLOAT_DECODER 0 -+#define CONFIG_MP3FLOAT_DECODER 0 -+#define CONFIG_MP3_DECODER 1 -+#define CONFIG_MP3ADUFLOAT_DECODER 0 -+#define CONFIG_MP3ADU_DECODER 0 -+#define CONFIG_MP3ON4FLOAT_DECODER 0 -+#define CONFIG_MP3ON4_DECODER 0 -+#define CONFIG_MPC7_DECODER 0 -+#define CONFIG_MPC8_DECODER 0 -+#define CONFIG_NELLYMOSER_DECODER 0 -+#define CONFIG_ON2AVC_DECODER 0 -+#define CONFIG_OPUS_DECODER 0 -+#define CONFIG_PAF_AUDIO_DECODER 0 -+#define CONFIG_QCELP_DECODER 0 -+#define CONFIG_QDM2_DECODER 0 -+#define CONFIG_QDMC_DECODER 0 -+#define CONFIG_RA_144_DECODER 0 -+#define CONFIG_RA_288_DECODER 0 -+#define CONFIG_RALF_DECODER 0 -+#define CONFIG_SBC_DECODER 0 -+#define CONFIG_SHORTEN_DECODER 0 -+#define CONFIG_SIPR_DECODER 0 -+#define CONFIG_SIREN_DECODER 0 -+#define CONFIG_SMACKAUD_DECODER 0 -+#define CONFIG_SONIC_DECODER 0 -+#define CONFIG_TAK_DECODER 0 -+#define CONFIG_TRUEHD_DECODER 0 -+#define CONFIG_TRUESPEECH_DECODER 0 -+#define CONFIG_TTA_DECODER 0 -+#define CONFIG_TWINVQ_DECODER 0 -+#define CONFIG_VMDAUDIO_DECODER 0 -+#define CONFIG_VORBIS_DECODER 1 -+#define CONFIG_WAVPACK_DECODER 0 -+#define CONFIG_WMALOSSLESS_DECODER 0 -+#define CONFIG_WMAPRO_DECODER 0 -+#define CONFIG_WMAV1_DECODER 0 -+#define CONFIG_WMAV2_DECODER 0 -+#define CONFIG_WMAVOICE_DECODER 0 -+#define CONFIG_WS_SND1_DECODER 0 -+#define CONFIG_XMA1_DECODER 0 -+#define CONFIG_XMA2_DECODER 0 -+#define CONFIG_PCM_ALAW_DECODER 1 -+#define CONFIG_PCM_BLURAY_DECODER 0 -+#define CONFIG_PCM_DVD_DECODER 0 -+#define CONFIG_PCM_F16LE_DECODER 0 -+#define CONFIG_PCM_F24LE_DECODER 0 -+#define CONFIG_PCM_F32BE_DECODER 0 -+#define CONFIG_PCM_F32LE_DECODER 1 -+#define CONFIG_PCM_F64BE_DECODER 0 -+#define CONFIG_PCM_F64LE_DECODER 0 -+#define CONFIG_PCM_LXF_DECODER 0 -+#define CONFIG_PCM_MULAW_DECODER 1 -+#define CONFIG_PCM_S8_DECODER 0 -+#define CONFIG_PCM_S8_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16BE_DECODER 1 -+#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16LE_DECODER 1 -+#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S24BE_DECODER 1 -+#define CONFIG_PCM_S24DAUD_DECODER 0 -+#define CONFIG_PCM_S24LE_DECODER 1 -+#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S32BE_DECODER 0 -+#define CONFIG_PCM_S32LE_DECODER 1 -+#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S64BE_DECODER 0 -+#define CONFIG_PCM_S64LE_DECODER 0 -+#define CONFIG_PCM_U8_DECODER 1 -+#define CONFIG_PCM_U16BE_DECODER 0 -+#define CONFIG_PCM_U16LE_DECODER 0 -+#define CONFIG_PCM_U24BE_DECODER 0 -+#define CONFIG_PCM_U24LE_DECODER 0 -+#define CONFIG_PCM_U32BE_DECODER 0 -+#define CONFIG_PCM_U32LE_DECODER 0 -+#define CONFIG_PCM_VIDC_DECODER 0 -+#define CONFIG_DERF_DPCM_DECODER 0 -+#define CONFIG_GREMLIN_DPCM_DECODER 0 -+#define CONFIG_INTERPLAY_DPCM_DECODER 0 -+#define CONFIG_ROQ_DPCM_DECODER 0 -+#define CONFIG_SDX2_DPCM_DECODER 0 -+#define CONFIG_SOL_DPCM_DECODER 0 -+#define CONFIG_XAN_DPCM_DECODER 0 -+#define CONFIG_ADPCM_4XM_DECODER 0 -+#define CONFIG_ADPCM_ADX_DECODER 0 -+#define CONFIG_ADPCM_AFC_DECODER 0 -+#define CONFIG_ADPCM_AGM_DECODER 0 -+#define CONFIG_ADPCM_AICA_DECODER 0 -+#define CONFIG_ADPCM_ARGO_DECODER 0 -+#define CONFIG_ADPCM_CT_DECODER 0 -+#define CONFIG_ADPCM_DTK_DECODER 0 -+#define CONFIG_ADPCM_EA_DECODER 0 -+#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 -+#define CONFIG_ADPCM_EA_R1_DECODER 0 -+#define CONFIG_ADPCM_EA_R2_DECODER 0 -+#define CONFIG_ADPCM_EA_R3_DECODER 0 -+#define CONFIG_ADPCM_EA_XAS_DECODER 0 -+#define CONFIG_ADPCM_G722_DECODER 0 -+#define CONFIG_ADPCM_G726_DECODER 0 -+#define CONFIG_ADPCM_G726LE_DECODER 0 -+#define CONFIG_ADPCM_IMA_AMV_DECODER 0 -+#define CONFIG_ADPCM_IMA_ALP_DECODER 0 -+#define CONFIG_ADPCM_IMA_APC_DECODER 0 -+#define CONFIG_ADPCM_IMA_APM_DECODER 0 -+#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 -+#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK3_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK4_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_ISS_DECODER 0 -+#define CONFIG_ADPCM_IMA_MTF_DECODER 0 -+#define CONFIG_ADPCM_IMA_OKI_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_DECODER 0 -+#define CONFIG_ADPCM_IMA_RAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_SSI_DECODER 0 -+#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 -+#define CONFIG_ADPCM_IMA_WAV_DECODER 0 -+#define CONFIG_ADPCM_IMA_WS_DECODER 0 -+#define CONFIG_ADPCM_MS_DECODER 0 -+#define CONFIG_ADPCM_MTAF_DECODER 0 -+#define CONFIG_ADPCM_PSX_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_2_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_3_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_4_DECODER 0 -+#define CONFIG_ADPCM_SWF_DECODER 0 -+#define CONFIG_ADPCM_THP_DECODER 0 -+#define CONFIG_ADPCM_THP_LE_DECODER 0 -+#define CONFIG_ADPCM_VIMA_DECODER 0 -+#define CONFIG_ADPCM_XA_DECODER 0 -+#define CONFIG_ADPCM_YAMAHA_DECODER 0 -+#define CONFIG_ADPCM_ZORK_DECODER 0 -+#define CONFIG_SSA_DECODER 0 -+#define CONFIG_ASS_DECODER 0 -+#define CONFIG_CCAPTION_DECODER 0 -+#define CONFIG_DVBSUB_DECODER 0 -+#define CONFIG_DVDSUB_DECODER 0 -+#define CONFIG_JACOSUB_DECODER 0 -+#define CONFIG_MICRODVD_DECODER 0 -+#define CONFIG_MOVTEXT_DECODER 0 -+#define CONFIG_MPL2_DECODER 0 -+#define CONFIG_PGSSUB_DECODER 0 -+#define CONFIG_PJS_DECODER 0 -+#define CONFIG_REALTEXT_DECODER 0 -+#define CONFIG_SAMI_DECODER 0 -+#define CONFIG_SRT_DECODER 0 -+#define CONFIG_STL_DECODER 0 -+#define CONFIG_SUBRIP_DECODER 0 -+#define CONFIG_SUBVIEWER_DECODER 0 -+#define CONFIG_SUBVIEWER1_DECODER 0 -+#define CONFIG_TEXT_DECODER 0 -+#define CONFIG_VPLAYER_DECODER 0 -+#define CONFIG_WEBVTT_DECODER 0 -+#define CONFIG_XSUB_DECODER 0 -+#define CONFIG_AAC_AT_DECODER 0 -+#define CONFIG_AC3_AT_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 -+#define CONFIG_ALAC_AT_DECODER 0 -+#define CONFIG_AMR_NB_AT_DECODER 0 -+#define CONFIG_EAC3_AT_DECODER 0 -+#define CONFIG_GSM_MS_AT_DECODER 0 -+#define CONFIG_ILBC_AT_DECODER 0 -+#define CONFIG_MP1_AT_DECODER 0 -+#define CONFIG_MP2_AT_DECODER 0 -+#define CONFIG_MP3_AT_DECODER 0 -+#define CONFIG_PCM_ALAW_AT_DECODER 0 -+#define CONFIG_PCM_MULAW_AT_DECODER 0 -+#define CONFIG_QDMC_AT_DECODER 0 -+#define CONFIG_QDM2_AT_DECODER 0 -+#define CONFIG_LIBARIBB24_DECODER 0 -+#define CONFIG_LIBCELT_DECODER 0 -+#define CONFIG_LIBCODEC2_DECODER 0 -+#define CONFIG_LIBDAV1D_DECODER 0 -+#define CONFIG_LIBDAVS2_DECODER 0 -+#define CONFIG_LIBFDK_AAC_DECODER 0 -+#define CONFIG_LIBGSM_DECODER 0 -+#define CONFIG_LIBGSM_MS_DECODER 0 -+#define CONFIG_LIBILBC_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 -+#define CONFIG_LIBOPENJPEG_DECODER 0 -+#define CONFIG_LIBOPUS_DECODER 1 -+#define CONFIG_LIBRSVG_DECODER 0 -+#define CONFIG_LIBSPEEX_DECODER 0 -+#define CONFIG_LIBVORBIS_DECODER 0 -+#define CONFIG_LIBVPX_VP8_DECODER 0 -+#define CONFIG_LIBVPX_VP9_DECODER 0 -+#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 -+#define CONFIG_BINTEXT_DECODER 0 -+#define CONFIG_XBIN_DECODER 0 -+#define CONFIG_IDF_DECODER 0 -+#define CONFIG_LIBAOM_AV1_DECODER 0 -+#define CONFIG_LIBOPENH264_DECODER 0 -+#define CONFIG_H264_CUVID_DECODER 0 -+#define CONFIG_HEVC_CUVID_DECODER 0 -+#define CONFIG_HEVC_MEDIACODEC_DECODER 0 -+#define CONFIG_MJPEG_CUVID_DECODER 0 -+#define CONFIG_MJPEG_QSV_DECODER 0 -+#define CONFIG_MPEG1_CUVID_DECODER 0 -+#define CONFIG_MPEG2_CUVID_DECODER 0 -+#define CONFIG_MPEG4_CUVID_DECODER 0 -+#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 -+#define CONFIG_VC1_CUVID_DECODER 0 -+#define CONFIG_VP8_CUVID_DECODER 0 -+#define CONFIG_VP8_MEDIACODEC_DECODER 0 -+#define CONFIG_VP8_QSV_DECODER 0 -+#define CONFIG_VP9_CUVID_DECODER 0 -+#define CONFIG_VP9_MEDIACODEC_DECODER 0 -+#define CONFIG_VP9_QSV_DECODER 0 -+#define CONFIG_A64MULTI_ENCODER 0 -+#define CONFIG_A64MULTI5_ENCODER 0 -+#define CONFIG_ALIAS_PIX_ENCODER 0 -+#define CONFIG_AMV_ENCODER 0 -+#define CONFIG_APNG_ENCODER 0 -+#define CONFIG_ASV1_ENCODER 0 -+#define CONFIG_ASV2_ENCODER 0 -+#define CONFIG_AVRP_ENCODER 0 -+#define CONFIG_AVUI_ENCODER 0 -+#define CONFIG_AYUV_ENCODER 0 -+#define CONFIG_BMP_ENCODER 0 -+#define CONFIG_CFHD_ENCODER 0 -+#define CONFIG_CINEPAK_ENCODER 0 -+#define CONFIG_CLJR_ENCODER 0 -+#define CONFIG_COMFORTNOISE_ENCODER 0 -+#define CONFIG_DNXHD_ENCODER 0 -+#define CONFIG_DPX_ENCODER 0 -+#define CONFIG_DVVIDEO_ENCODER 0 -+#define CONFIG_FFV1_ENCODER 0 -+#define CONFIG_FFVHUFF_ENCODER 0 -+#define CONFIG_FITS_ENCODER 0 -+#define CONFIG_FLASHSV_ENCODER 0 -+#define CONFIG_FLASHSV2_ENCODER 0 -+#define CONFIG_FLV_ENCODER 0 -+#define CONFIG_GIF_ENCODER 0 -+#define CONFIG_H261_ENCODER 0 -+#define CONFIG_H263_ENCODER 0 -+#define CONFIG_H263P_ENCODER 0 -+#define CONFIG_HAP_ENCODER 0 -+#define CONFIG_HUFFYUV_ENCODER 0 -+#define CONFIG_JPEG2000_ENCODER 0 -+#define CONFIG_JPEGLS_ENCODER 0 -+#define CONFIG_LJPEG_ENCODER 0 -+#define CONFIG_MAGICYUV_ENCODER 0 -+#define CONFIG_MJPEG_ENCODER 0 -+#define CONFIG_MPEG1VIDEO_ENCODER 0 -+#define CONFIG_MPEG2VIDEO_ENCODER 0 -+#define CONFIG_MPEG4_ENCODER 0 -+#define CONFIG_MSMPEG4V2_ENCODER 0 -+#define CONFIG_MSMPEG4V3_ENCODER 0 -+#define CONFIG_MSVIDEO1_ENCODER 0 -+#define CONFIG_PAM_ENCODER 0 -+#define CONFIG_PBM_ENCODER 0 -+#define CONFIG_PCX_ENCODER 0 -+#define CONFIG_PGM_ENCODER 0 -+#define CONFIG_PGMYUV_ENCODER 0 -+#define CONFIG_PNG_ENCODER 0 -+#define CONFIG_PPM_ENCODER 0 -+#define CONFIG_PRORES_ENCODER 0 -+#define CONFIG_PRORES_AW_ENCODER 0 -+#define CONFIG_PRORES_KS_ENCODER 0 -+#define CONFIG_QTRLE_ENCODER 0 -+#define CONFIG_R10K_ENCODER 0 -+#define CONFIG_R210_ENCODER 0 -+#define CONFIG_RAWVIDEO_ENCODER 0 -+#define CONFIG_ROQ_ENCODER 0 -+#define CONFIG_RPZA_ENCODER 0 -+#define CONFIG_RV10_ENCODER 0 -+#define CONFIG_RV20_ENCODER 0 -+#define CONFIG_S302M_ENCODER 0 -+#define CONFIG_SGI_ENCODER 0 -+#define CONFIG_SNOW_ENCODER 0 -+#define CONFIG_SUNRAST_ENCODER 0 -+#define CONFIG_SVQ1_ENCODER 0 -+#define CONFIG_TARGA_ENCODER 0 -+#define CONFIG_TIFF_ENCODER 0 -+#define CONFIG_UTVIDEO_ENCODER 0 -+#define CONFIG_V210_ENCODER 0 -+#define CONFIG_V308_ENCODER 0 -+#define CONFIG_V408_ENCODER 0 -+#define CONFIG_V410_ENCODER 0 -+#define CONFIG_VC2_ENCODER 0 -+#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 -+#define CONFIG_WMV1_ENCODER 0 -+#define CONFIG_WMV2_ENCODER 0 -+#define CONFIG_XBM_ENCODER 0 -+#define CONFIG_XFACE_ENCODER 0 -+#define CONFIG_XWD_ENCODER 0 -+#define CONFIG_Y41P_ENCODER 0 -+#define CONFIG_YUV4_ENCODER 0 -+#define CONFIG_ZLIB_ENCODER 0 -+#define CONFIG_ZMBV_ENCODER 0 -+#define CONFIG_AAC_ENCODER 0 -+#define CONFIG_AC3_ENCODER 0 -+#define CONFIG_AC3_FIXED_ENCODER 0 -+#define CONFIG_ALAC_ENCODER 0 -+#define CONFIG_APTX_ENCODER 0 -+#define CONFIG_APTX_HD_ENCODER 0 -+#define CONFIG_DCA_ENCODER 0 -+#define CONFIG_EAC3_ENCODER 0 -+#define CONFIG_FLAC_ENCODER 0 -+#define CONFIG_G723_1_ENCODER 0 -+#define CONFIG_MLP_ENCODER 0 -+#define CONFIG_MP2_ENCODER 0 -+#define CONFIG_MP2FIXED_ENCODER 0 -+#define CONFIG_NELLYMOSER_ENCODER 0 -+#define CONFIG_OPUS_ENCODER 0 -+#define CONFIG_RA_144_ENCODER 0 -+#define CONFIG_SBC_ENCODER 0 -+#define CONFIG_SONIC_ENCODER 0 -+#define CONFIG_SONIC_LS_ENCODER 0 -+#define CONFIG_TRUEHD_ENCODER 0 -+#define CONFIG_TTA_ENCODER 0 -+#define CONFIG_VORBIS_ENCODER 0 -+#define CONFIG_WAVPACK_ENCODER 0 -+#define CONFIG_WMAV1_ENCODER 0 -+#define CONFIG_WMAV2_ENCODER 0 -+#define CONFIG_PCM_ALAW_ENCODER 0 -+#define CONFIG_PCM_DVD_ENCODER 0 -+#define CONFIG_PCM_F32BE_ENCODER 0 -+#define CONFIG_PCM_F32LE_ENCODER 0 -+#define CONFIG_PCM_F64BE_ENCODER 0 -+#define CONFIG_PCM_F64LE_ENCODER 0 -+#define CONFIG_PCM_MULAW_ENCODER 0 -+#define CONFIG_PCM_S8_ENCODER 0 -+#define CONFIG_PCM_S8_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16BE_ENCODER 0 -+#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16LE_ENCODER 0 -+#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S24BE_ENCODER 0 -+#define CONFIG_PCM_S24DAUD_ENCODER 0 -+#define CONFIG_PCM_S24LE_ENCODER 0 -+#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S32BE_ENCODER 0 -+#define CONFIG_PCM_S32LE_ENCODER 0 -+#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S64BE_ENCODER 0 -+#define CONFIG_PCM_S64LE_ENCODER 0 -+#define CONFIG_PCM_U8_ENCODER 0 -+#define CONFIG_PCM_U16BE_ENCODER 0 -+#define CONFIG_PCM_U16LE_ENCODER 0 -+#define CONFIG_PCM_U24BE_ENCODER 0 -+#define CONFIG_PCM_U24LE_ENCODER 0 -+#define CONFIG_PCM_U32BE_ENCODER 0 -+#define CONFIG_PCM_U32LE_ENCODER 0 -+#define CONFIG_PCM_VIDC_ENCODER 0 -+#define CONFIG_ROQ_DPCM_ENCODER 0 -+#define CONFIG_ADPCM_ADX_ENCODER 0 -+#define CONFIG_ADPCM_ARGO_ENCODER 0 -+#define CONFIG_ADPCM_G722_ENCODER 0 -+#define CONFIG_ADPCM_G726_ENCODER 0 -+#define CONFIG_ADPCM_G726LE_ENCODER 0 -+#define CONFIG_ADPCM_IMA_APM_ENCODER 0 -+#define CONFIG_ADPCM_IMA_QT_ENCODER 0 -+#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 -+#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 -+#define CONFIG_ADPCM_MS_ENCODER 0 -+#define CONFIG_ADPCM_SWF_ENCODER 0 -+#define CONFIG_ADPCM_YAMAHA_ENCODER 0 -+#define CONFIG_SSA_ENCODER 0 -+#define CONFIG_ASS_ENCODER 0 -+#define CONFIG_DVBSUB_ENCODER 0 -+#define CONFIG_DVDSUB_ENCODER 0 -+#define CONFIG_MOVTEXT_ENCODER 0 -+#define CONFIG_SRT_ENCODER 0 -+#define CONFIG_SUBRIP_ENCODER 0 -+#define CONFIG_TEXT_ENCODER 0 -+#define CONFIG_WEBVTT_ENCODER 0 -+#define CONFIG_XSUB_ENCODER 0 -+#define CONFIG_AAC_AT_ENCODER 0 -+#define CONFIG_ALAC_AT_ENCODER 0 -+#define CONFIG_ILBC_AT_ENCODER 0 -+#define CONFIG_PCM_ALAW_AT_ENCODER 0 -+#define CONFIG_PCM_MULAW_AT_ENCODER 0 -+#define CONFIG_LIBAOM_AV1_ENCODER 0 -+#define CONFIG_LIBCODEC2_ENCODER 0 -+#define CONFIG_LIBFDK_AAC_ENCODER 0 -+#define CONFIG_LIBGSM_ENCODER 0 -+#define CONFIG_LIBGSM_MS_ENCODER 0 -+#define CONFIG_LIBILBC_ENCODER 0 -+#define CONFIG_LIBMP3LAME_ENCODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 -+#define CONFIG_LIBOPENJPEG_ENCODER 0 -+#define CONFIG_LIBOPUS_ENCODER 0 -+#define CONFIG_LIBRAV1E_ENCODER 0 -+#define CONFIG_LIBSHINE_ENCODER 0 -+#define CONFIG_LIBSPEEX_ENCODER 0 -+#define CONFIG_LIBSVTAV1_ENCODER 0 -+#define CONFIG_LIBTHEORA_ENCODER 0 -+#define CONFIG_LIBTWOLAME_ENCODER 0 -+#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 -+#define CONFIG_LIBVORBIS_ENCODER 0 -+#define CONFIG_LIBVPX_VP8_ENCODER 0 -+#define CONFIG_LIBVPX_VP9_ENCODER 0 -+#define CONFIG_LIBWAVPACK_ENCODER 0 -+#define CONFIG_LIBWEBP_ANIM_ENCODER 0 -+#define CONFIG_LIBWEBP_ENCODER 0 -+#define CONFIG_LIBX262_ENCODER 0 -+#define CONFIG_LIBX264_ENCODER 0 -+#define CONFIG_LIBX264RGB_ENCODER 0 -+#define CONFIG_LIBX265_ENCODER 0 -+#define CONFIG_LIBXAVS_ENCODER 0 -+#define CONFIG_LIBXAVS2_ENCODER 0 -+#define CONFIG_LIBXVID_ENCODER 0 -+#define CONFIG_AAC_MF_ENCODER 0 -+#define CONFIG_AC3_MF_ENCODER 0 -+#define CONFIG_H263_V4L2M2M_ENCODER 0 -+#define CONFIG_LIBOPENH264_ENCODER 0 -+#define CONFIG_H264_AMF_ENCODER 0 -+#define CONFIG_H264_MF_ENCODER 0 -+#define CONFIG_H264_NVENC_ENCODER 0 -+#define CONFIG_H264_OMX_ENCODER 0 -+#define CONFIG_H264_QSV_ENCODER 0 -+#define CONFIG_H264_V4L2M2M_ENCODER 0 -+#define CONFIG_H264_VAAPI_ENCODER 0 -+#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_NVENC_ENCODER 0 -+#define CONFIG_NVENC_H264_ENCODER 0 -+#define CONFIG_NVENC_HEVC_ENCODER 0 -+#define CONFIG_HEVC_AMF_ENCODER 0 -+#define CONFIG_HEVC_MF_ENCODER 0 -+#define CONFIG_HEVC_NVENC_ENCODER 0 -+#define CONFIG_HEVC_QSV_ENCODER 0 -+#define CONFIG_HEVC_V4L2M2M_ENCODER 0 -+#define CONFIG_HEVC_VAAPI_ENCODER 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_LIBKVAZAAR_ENCODER 0 -+#define CONFIG_MJPEG_QSV_ENCODER 0 -+#define CONFIG_MJPEG_VAAPI_ENCODER 0 -+#define CONFIG_MP3_MF_ENCODER 0 -+#define CONFIG_MPEG2_QSV_ENCODER 0 -+#define CONFIG_MPEG2_VAAPI_ENCODER 0 -+#define CONFIG_MPEG4_OMX_ENCODER 0 -+#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_VAAPI_ENCODER 0 -+#define CONFIG_VP9_VAAPI_ENCODER 0 -+#define CONFIG_VP9_QSV_ENCODER 0 -+#define CONFIG_H263_VAAPI_HWACCEL 0 -+#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_H264_D3D11VA_HWACCEL 0 -+#define CONFIG_H264_D3D11VA2_HWACCEL 0 -+#define CONFIG_H264_DXVA2_HWACCEL 0 -+#define CONFIG_H264_NVDEC_HWACCEL 0 -+#define CONFIG_H264_VAAPI_HWACCEL 0 -+#define CONFIG_H264_VDPAU_HWACCEL 0 -+#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 -+#define CONFIG_HEVC_DXVA2_HWACCEL 0 -+#define CONFIG_HEVC_NVDEC_HWACCEL 0 -+#define CONFIG_HEVC_VAAPI_HWACCEL 0 -+#define CONFIG_HEVC_VDPAU_HWACCEL 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MJPEG_NVDEC_HWACCEL 0 -+#define CONFIG_MJPEG_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG1_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG1_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG1_XVMC_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 -+#define CONFIG_MPEG2_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG2_DXVA2_HWACCEL 0 -+#define CONFIG_MPEG2_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG2_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG2_XVMC_HWACCEL 0 -+#define CONFIG_MPEG4_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG4_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG4_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA2_HWACCEL 0 -+#define CONFIG_VC1_DXVA2_HWACCEL 0 -+#define CONFIG_VC1_NVDEC_HWACCEL 0 -+#define CONFIG_VC1_VAAPI_HWACCEL 0 -+#define CONFIG_VC1_VDPAU_HWACCEL 0 -+#define CONFIG_VP8_NVDEC_HWACCEL 0 -+#define CONFIG_VP8_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA2_HWACCEL 0 -+#define CONFIG_VP9_DXVA2_HWACCEL 0 -+#define CONFIG_VP9_NVDEC_HWACCEL 0 -+#define CONFIG_VP9_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_VDPAU_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 -+#define CONFIG_WMV3_DXVA2_HWACCEL 0 -+#define CONFIG_WMV3_NVDEC_HWACCEL 0 -+#define CONFIG_WMV3_VAAPI_HWACCEL 0 -+#define CONFIG_WMV3_VDPAU_HWACCEL 0 -+#define CONFIG_AAC_PARSER 1 -+#define CONFIG_AAC_LATM_PARSER 0 -+#define CONFIG_AC3_PARSER 0 -+#define CONFIG_ADX_PARSER 0 -+#define CONFIG_AV1_PARSER 0 -+#define CONFIG_AVS2_PARSER 0 -+#define CONFIG_BMP_PARSER 0 -+#define CONFIG_CAVSVIDEO_PARSER 0 -+#define CONFIG_COOK_PARSER 0 -+#define CONFIG_DCA_PARSER 0 -+#define CONFIG_DIRAC_PARSER 0 -+#define CONFIG_DNXHD_PARSER 0 -+#define CONFIG_DPX_PARSER 0 -+#define CONFIG_DVAUDIO_PARSER 0 -+#define CONFIG_DVBSUB_PARSER 0 -+#define CONFIG_DVDSUB_PARSER 0 -+#define CONFIG_DVD_NAV_PARSER 0 -+#define CONFIG_FLAC_PARSER 1 -+#define CONFIG_G723_1_PARSER 0 -+#define CONFIG_G729_PARSER 0 -+#define CONFIG_GIF_PARSER 0 -+#define CONFIG_GSM_PARSER 0 -+#define CONFIG_H261_PARSER 0 -+#define CONFIG_H263_PARSER 0 -+#define CONFIG_H264_PARSER 1 -+#define CONFIG_HEVC_PARSER 0 -+#define CONFIG_JPEG2000_PARSER 0 -+#define CONFIG_MJPEG_PARSER 0 -+#define CONFIG_MLP_PARSER 0 -+#define CONFIG_MPEG4VIDEO_PARSER 0 -+#define CONFIG_MPEGAUDIO_PARSER 1 -+#define CONFIG_MPEGVIDEO_PARSER 0 -+#define CONFIG_OPUS_PARSER 1 -+#define CONFIG_PNG_PARSER 0 -+#define CONFIG_PNM_PARSER 0 -+#define CONFIG_RV30_PARSER 0 -+#define CONFIG_RV40_PARSER 0 -+#define CONFIG_SBC_PARSER 0 -+#define CONFIG_SIPR_PARSER 0 -+#define CONFIG_TAK_PARSER 0 -+#define CONFIG_VC1_PARSER 0 -+#define CONFIG_VORBIS_PARSER 1 -+#define CONFIG_VP3_PARSER 1 -+#define CONFIG_VP8_PARSER 1 -+#define CONFIG_VP9_PARSER 1 -+#define CONFIG_WEBP_PARSER 0 -+#define CONFIG_XMA_PARSER 0 -+#define CONFIG_ALSA_INDEV 0 -+#define CONFIG_ANDROID_CAMERA_INDEV 0 -+#define CONFIG_AVFOUNDATION_INDEV 0 -+#define CONFIG_BKTR_INDEV 0 -+#define CONFIG_DECKLINK_INDEV 0 -+#define CONFIG_DSHOW_INDEV 0 -+#define CONFIG_FBDEV_INDEV 0 -+#define CONFIG_GDIGRAB_INDEV 0 -+#define CONFIG_IEC61883_INDEV 0 -+#define CONFIG_JACK_INDEV 0 -+#define CONFIG_KMSGRAB_INDEV 0 -+#define CONFIG_LAVFI_INDEV 0 -+#define CONFIG_OPENAL_INDEV 0 -+#define CONFIG_OSS_INDEV 0 -+#define CONFIG_PULSE_INDEV 0 -+#define CONFIG_SNDIO_INDEV 0 -+#define CONFIG_V4L2_INDEV 0 -+#define CONFIG_VFWCAP_INDEV 0 -+#define CONFIG_XCBGRAB_INDEV 0 -+#define CONFIG_LIBCDIO_INDEV 0 -+#define CONFIG_LIBDC1394_INDEV 0 -+#define CONFIG_ALSA_OUTDEV 0 -+#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 -+#define CONFIG_CACA_OUTDEV 0 -+#define CONFIG_DECKLINK_OUTDEV 0 -+#define CONFIG_FBDEV_OUTDEV 0 -+#define CONFIG_OPENGL_OUTDEV 0 -+#define CONFIG_OSS_OUTDEV 0 -+#define CONFIG_PULSE_OUTDEV 0 -+#define CONFIG_SDL2_OUTDEV 0 -+#define CONFIG_SNDIO_OUTDEV 0 -+#define CONFIG_V4L2_OUTDEV 0 -+#define CONFIG_XV_OUTDEV 0 -+#define CONFIG_ABENCH_FILTER 0 -+#define CONFIG_ACOMPRESSOR_FILTER 0 -+#define CONFIG_ACONTRAST_FILTER 0 -+#define CONFIG_ACOPY_FILTER 0 -+#define CONFIG_ACUE_FILTER 0 -+#define CONFIG_ACROSSFADE_FILTER 0 -+#define CONFIG_ACROSSOVER_FILTER 0 -+#define CONFIG_ACRUSHER_FILTER 0 -+#define CONFIG_ADECLICK_FILTER 0 -+#define CONFIG_ADECLIP_FILTER 0 -+#define CONFIG_ADELAY_FILTER 0 -+#define CONFIG_ADERIVATIVE_FILTER 0 -+#define CONFIG_AECHO_FILTER 0 -+#define CONFIG_AEMPHASIS_FILTER 0 -+#define CONFIG_AEVAL_FILTER 0 -+#define CONFIG_AFADE_FILTER 0 -+#define CONFIG_AFFTDN_FILTER 0 -+#define CONFIG_AFFTFILT_FILTER 0 -+#define CONFIG_AFIR_FILTER 0 -+#define CONFIG_AFORMAT_FILTER 0 -+#define CONFIG_AGATE_FILTER 0 -+#define CONFIG_AIIR_FILTER 0 -+#define CONFIG_AINTEGRAL_FILTER 0 -+#define CONFIG_AINTERLEAVE_FILTER 0 -+#define CONFIG_ALIMITER_FILTER 0 -+#define CONFIG_ALLPASS_FILTER 0 -+#define CONFIG_ALOOP_FILTER 0 -+#define CONFIG_AMERGE_FILTER 0 -+#define CONFIG_AMETADATA_FILTER 0 -+#define CONFIG_AMIX_FILTER 0 -+#define CONFIG_AMULTIPLY_FILTER 0 -+#define CONFIG_ANEQUALIZER_FILTER 0 -+#define CONFIG_ANLMDN_FILTER 0 -+#define CONFIG_ANLMS_FILTER 0 -+#define CONFIG_ANULL_FILTER 0 -+#define CONFIG_APAD_FILTER 0 -+#define CONFIG_APERMS_FILTER 0 -+#define CONFIG_APHASER_FILTER 0 -+#define CONFIG_APULSATOR_FILTER 0 -+#define CONFIG_AREALTIME_FILTER 0 -+#define CONFIG_ARESAMPLE_FILTER 0 -+#define CONFIG_AREVERSE_FILTER 0 -+#define CONFIG_ARNNDN_FILTER 0 -+#define CONFIG_ASELECT_FILTER 0 -+#define CONFIG_ASENDCMD_FILTER 0 -+#define CONFIG_ASETNSAMPLES_FILTER 0 -+#define CONFIG_ASETPTS_FILTER 0 -+#define CONFIG_ASETRATE_FILTER 0 -+#define CONFIG_ASETTB_FILTER 0 -+#define CONFIG_ASHOWINFO_FILTER 0 -+#define CONFIG_ASIDEDATA_FILTER 0 -+#define CONFIG_ASOFTCLIP_FILTER 0 -+#define CONFIG_ASPLIT_FILTER 0 -+#define CONFIG_ASR_FILTER 0 -+#define CONFIG_ASTATS_FILTER 0 -+#define CONFIG_ASTREAMSELECT_FILTER 0 -+#define CONFIG_ASUBBOOST_FILTER 0 -+#define CONFIG_ATEMPO_FILTER 0 -+#define CONFIG_ATRIM_FILTER 0 -+#define CONFIG_AXCORRELATE_FILTER 0 -+#define CONFIG_AZMQ_FILTER 0 -+#define CONFIG_BANDPASS_FILTER 0 -+#define CONFIG_BANDREJECT_FILTER 0 -+#define CONFIG_BASS_FILTER 0 -+#define CONFIG_BIQUAD_FILTER 0 -+#define CONFIG_BS2B_FILTER 0 -+#define CONFIG_CHROMABER_VULKAN_FILTER 0 -+#define CONFIG_CHANNELMAP_FILTER 0 -+#define CONFIG_CHANNELSPLIT_FILTER 0 -+#define CONFIG_CHORUS_FILTER 0 -+#define CONFIG_COMPAND_FILTER 0 -+#define CONFIG_COMPENSATIONDELAY_FILTER 0 -+#define CONFIG_CROSSFEED_FILTER 0 -+#define CONFIG_CRYSTALIZER_FILTER 0 -+#define CONFIG_DCSHIFT_FILTER 0 -+#define CONFIG_DEESSER_FILTER 0 -+#define CONFIG_DRMETER_FILTER 0 -+#define CONFIG_DYNAUDNORM_FILTER 0 -+#define CONFIG_EARWAX_FILTER 0 -+#define CONFIG_EBUR128_FILTER 0 -+#define CONFIG_EQUALIZER_FILTER 0 -+#define CONFIG_EXTRASTEREO_FILTER 0 -+#define CONFIG_FIREQUALIZER_FILTER 0 -+#define CONFIG_FLANGER_FILTER 0 -+#define CONFIG_HAAS_FILTER 0 -+#define CONFIG_HDCD_FILTER 0 -+#define CONFIG_HEADPHONE_FILTER 0 -+#define CONFIG_HIGHPASS_FILTER 0 -+#define CONFIG_HIGHSHELF_FILTER 0 -+#define CONFIG_JOIN_FILTER 0 -+#define CONFIG_LADSPA_FILTER 0 -+#define CONFIG_LOUDNORM_FILTER 0 -+#define CONFIG_LOWPASS_FILTER 0 -+#define CONFIG_LOWSHELF_FILTER 0 -+#define CONFIG_LV2_FILTER 0 -+#define CONFIG_MCOMPAND_FILTER 0 -+#define CONFIG_PAN_FILTER 0 -+#define CONFIG_REPLAYGAIN_FILTER 0 -+#define CONFIG_RESAMPLE_FILTER 0 -+#define CONFIG_RUBBERBAND_FILTER 0 -+#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 -+#define CONFIG_SIDECHAINGATE_FILTER 0 -+#define CONFIG_SILENCEDETECT_FILTER 0 -+#define CONFIG_SILENCEREMOVE_FILTER 0 -+#define CONFIG_SOFALIZER_FILTER 0 -+#define CONFIG_STEREOTOOLS_FILTER 0 -+#define CONFIG_STEREOWIDEN_FILTER 0 -+#define CONFIG_SUPEREQUALIZER_FILTER 0 -+#define CONFIG_SURROUND_FILTER 0 -+#define CONFIG_TREBLE_FILTER 0 -+#define CONFIG_TREMOLO_FILTER 0 -+#define CONFIG_VIBRATO_FILTER 0 -+#define CONFIG_VOLUME_FILTER 0 -+#define CONFIG_VOLUMEDETECT_FILTER 0 -+#define CONFIG_AEVALSRC_FILTER 0 -+#define CONFIG_AFIRSRC_FILTER 0 -+#define CONFIG_ANOISESRC_FILTER 0 -+#define CONFIG_ANULLSRC_FILTER 0 -+#define CONFIG_FLITE_FILTER 0 -+#define CONFIG_HILBERT_FILTER 0 -+#define CONFIG_SINC_FILTER 0 -+#define CONFIG_SINE_FILTER 0 -+#define CONFIG_ANULLSINK_FILTER 0 -+#define CONFIG_ADDROI_FILTER 0 -+#define CONFIG_ALPHAEXTRACT_FILTER 0 -+#define CONFIG_ALPHAMERGE_FILTER 0 -+#define CONFIG_AMPLIFY_FILTER 0 -+#define CONFIG_ASS_FILTER 0 -+#define CONFIG_ATADENOISE_FILTER 0 -+#define CONFIG_AVGBLUR_FILTER 0 -+#define CONFIG_AVGBLUR_OPENCL_FILTER 0 -+#define CONFIG_AVGBLUR_VULKAN_FILTER 0 -+#define CONFIG_BBOX_FILTER 0 -+#define CONFIG_BENCH_FILTER 0 -+#define CONFIG_BILATERAL_FILTER 0 -+#define CONFIG_BITPLANENOISE_FILTER 0 -+#define CONFIG_BLACKDETECT_FILTER 0 -+#define CONFIG_BLACKFRAME_FILTER 0 -+#define CONFIG_BLEND_FILTER 0 -+#define CONFIG_BM3D_FILTER 0 -+#define CONFIG_BOXBLUR_FILTER 0 -+#define CONFIG_BOXBLUR_OPENCL_FILTER 0 -+#define CONFIG_BWDIF_FILTER 0 -+#define CONFIG_CAS_FILTER 0 -+#define CONFIG_CHROMAHOLD_FILTER 0 -+#define CONFIG_CHROMAKEY_FILTER 0 -+#define CONFIG_CHROMANR_FILTER 0 -+#define CONFIG_CHROMASHIFT_FILTER 0 -+#define CONFIG_CIESCOPE_FILTER 0 -+#define CONFIG_CODECVIEW_FILTER 0 -+#define CONFIG_COLORBALANCE_FILTER 0 -+#define CONFIG_COLORCHANNELMIXER_FILTER 0 -+#define CONFIG_COLORKEY_FILTER 0 -+#define CONFIG_COLORKEY_OPENCL_FILTER 0 -+#define CONFIG_COLORHOLD_FILTER 0 -+#define CONFIG_COLORLEVELS_FILTER 0 -+#define CONFIG_COLORMATRIX_FILTER 0 -+#define CONFIG_COLORSPACE_FILTER 0 -+#define CONFIG_CONVOLUTION_FILTER 0 -+#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 -+#define CONFIG_CONVOLVE_FILTER 0 -+#define CONFIG_COPY_FILTER 0 -+#define CONFIG_COREIMAGE_FILTER 0 -+#define CONFIG_COVER_RECT_FILTER 0 -+#define CONFIG_CROP_FILTER 0 -+#define CONFIG_CROPDETECT_FILTER 0 -+#define CONFIG_CUE_FILTER 0 -+#define CONFIG_CURVES_FILTER 0 -+#define CONFIG_DATASCOPE_FILTER 0 -+#define CONFIG_DBLUR_FILTER 0 -+#define CONFIG_DCTDNOIZ_FILTER 0 -+#define CONFIG_DEBAND_FILTER 0 -+#define CONFIG_DEBLOCK_FILTER 0 -+#define CONFIG_DECIMATE_FILTER 0 -+#define CONFIG_DECONVOLVE_FILTER 0 -+#define CONFIG_DEDOT_FILTER 0 -+#define CONFIG_DEFLATE_FILTER 0 -+#define CONFIG_DEFLICKER_FILTER 0 -+#define CONFIG_DEINTERLACE_QSV_FILTER 0 -+#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 -+#define CONFIG_DEJUDDER_FILTER 0 -+#define CONFIG_DELOGO_FILTER 0 -+#define CONFIG_DENOISE_VAAPI_FILTER 0 -+#define CONFIG_DERAIN_FILTER 0 -+#define CONFIG_DESHAKE_FILTER 0 -+#define CONFIG_DESHAKE_OPENCL_FILTER 0 -+#define CONFIG_DESPILL_FILTER 0 -+#define CONFIG_DETELECINE_FILTER 0 -+#define CONFIG_DILATION_FILTER 0 -+#define CONFIG_DILATION_OPENCL_FILTER 0 -+#define CONFIG_DISPLACE_FILTER 0 -+#define CONFIG_DNN_PROCESSING_FILTER 0 -+#define CONFIG_DOUBLEWEAVE_FILTER 0 -+#define CONFIG_DRAWBOX_FILTER 0 -+#define CONFIG_DRAWGRAPH_FILTER 0 -+#define CONFIG_DRAWGRID_FILTER 0 -+#define CONFIG_DRAWTEXT_FILTER 0 -+#define CONFIG_EDGEDETECT_FILTER 0 -+#define CONFIG_ELBG_FILTER 0 -+#define CONFIG_ENTROPY_FILTER 0 -+#define CONFIG_EQ_FILTER 0 -+#define CONFIG_EROSION_FILTER 0 -+#define CONFIG_EROSION_OPENCL_FILTER 0 -+#define CONFIG_EXTRACTPLANES_FILTER 0 -+#define CONFIG_FADE_FILTER 0 -+#define CONFIG_FFTDNOIZ_FILTER 0 -+#define CONFIG_FFTFILT_FILTER 0 -+#define CONFIG_FIELD_FILTER 0 -+#define CONFIG_FIELDHINT_FILTER 0 -+#define CONFIG_FIELDMATCH_FILTER 0 -+#define CONFIG_FIELDORDER_FILTER 0 -+#define CONFIG_FILLBORDERS_FILTER 0 -+#define CONFIG_FIND_RECT_FILTER 0 -+#define CONFIG_FLOODFILL_FILTER 0 -+#define CONFIG_FORMAT_FILTER 0 -+#define CONFIG_FPS_FILTER 0 -+#define CONFIG_FRAMEPACK_FILTER 0 -+#define CONFIG_FRAMERATE_FILTER 0 -+#define CONFIG_FRAMESTEP_FILTER 0 -+#define CONFIG_FREEZEDETECT_FILTER 0 -+#define CONFIG_FREEZEFRAMES_FILTER 0 -+#define CONFIG_FREI0R_FILTER 0 -+#define CONFIG_FSPP_FILTER 0 -+#define CONFIG_GBLUR_FILTER 0 -+#define CONFIG_GEQ_FILTER 0 -+#define CONFIG_GRADFUN_FILTER 0 -+#define CONFIG_GRAPHMONITOR_FILTER 0 -+#define CONFIG_GREYEDGE_FILTER 0 -+#define CONFIG_HALDCLUT_FILTER 0 -+#define CONFIG_HFLIP_FILTER 0 -+#define CONFIG_HISTEQ_FILTER 0 -+#define CONFIG_HISTOGRAM_FILTER 0 -+#define CONFIG_HQDN3D_FILTER 0 -+#define CONFIG_HQX_FILTER 0 -+#define CONFIG_HSTACK_FILTER 0 -+#define CONFIG_HUE_FILTER 0 -+#define CONFIG_HWDOWNLOAD_FILTER 0 -+#define CONFIG_HWMAP_FILTER 0 -+#define CONFIG_HWUPLOAD_FILTER 0 -+#define CONFIG_HWUPLOAD_CUDA_FILTER 0 -+#define CONFIG_HYSTERESIS_FILTER 0 -+#define CONFIG_IDET_FILTER 0 -+#define CONFIG_IL_FILTER 0 -+#define CONFIG_INFLATE_FILTER 0 -+#define CONFIG_INTERLACE_FILTER 0 -+#define CONFIG_INTERLEAVE_FILTER 0 -+#define CONFIG_KERNDEINT_FILTER 0 -+#define CONFIG_LAGFUN_FILTER 0 -+#define CONFIG_LENSCORRECTION_FILTER 0 -+#define CONFIG_LENSFUN_FILTER 0 -+#define CONFIG_LIBVMAF_FILTER 0 -+#define CONFIG_LIMITER_FILTER 0 -+#define CONFIG_LOOP_FILTER 0 -+#define CONFIG_LUMAKEY_FILTER 0 -+#define CONFIG_LUT_FILTER 0 -+#define CONFIG_LUT1D_FILTER 0 -+#define CONFIG_LUT2_FILTER 0 -+#define CONFIG_LUT3D_FILTER 0 -+#define CONFIG_LUTRGB_FILTER 0 -+#define CONFIG_LUTYUV_FILTER 0 -+#define CONFIG_MASKEDCLAMP_FILTER 0 -+#define CONFIG_MASKEDMAX_FILTER 0 -+#define CONFIG_MASKEDMERGE_FILTER 0 -+#define CONFIG_MASKEDMIN_FILTER 0 -+#define CONFIG_MASKEDTHRESHOLD_FILTER 0 -+#define CONFIG_MASKFUN_FILTER 0 -+#define CONFIG_MCDEINT_FILTER 0 -+#define CONFIG_MEDIAN_FILTER 0 -+#define CONFIG_MERGEPLANES_FILTER 0 -+#define CONFIG_MESTIMATE_FILTER 0 -+#define CONFIG_METADATA_FILTER 0 -+#define CONFIG_MIDEQUALIZER_FILTER 0 -+#define CONFIG_MINTERPOLATE_FILTER 0 -+#define CONFIG_MIX_FILTER 0 -+#define CONFIG_MPDECIMATE_FILTER 0 -+#define CONFIG_NEGATE_FILTER 0 -+#define CONFIG_NLMEANS_FILTER 0 -+#define CONFIG_NLMEANS_OPENCL_FILTER 0 -+#define CONFIG_NNEDI_FILTER 0 -+#define CONFIG_NOFORMAT_FILTER 0 -+#define CONFIG_NOISE_FILTER 0 -+#define CONFIG_NORMALIZE_FILTER 0 -+#define CONFIG_NULL_FILTER 0 -+#define CONFIG_OCR_FILTER 0 -+#define CONFIG_OCV_FILTER 0 -+#define CONFIG_OSCILLOSCOPE_FILTER 0 -+#define CONFIG_OVERLAY_FILTER 0 -+#define CONFIG_OVERLAY_OPENCL_FILTER 0 -+#define CONFIG_OVERLAY_QSV_FILTER 0 -+#define CONFIG_OVERLAY_VULKAN_FILTER 0 -+#define CONFIG_OVERLAY_CUDA_FILTER 0 -+#define CONFIG_OWDENOISE_FILTER 0 -+#define CONFIG_PAD_FILTER 0 -+#define CONFIG_PAD_OPENCL_FILTER 0 -+#define CONFIG_PALETTEGEN_FILTER 0 -+#define CONFIG_PALETTEUSE_FILTER 0 -+#define CONFIG_PERMS_FILTER 0 -+#define CONFIG_PERSPECTIVE_FILTER 0 -+#define CONFIG_PHASE_FILTER 0 -+#define CONFIG_PHOTOSENSITIVITY_FILTER 0 -+#define CONFIG_PIXDESCTEST_FILTER 0 -+#define CONFIG_PIXSCOPE_FILTER 0 -+#define CONFIG_PP_FILTER 0 -+#define CONFIG_PP7_FILTER 0 -+#define CONFIG_PREMULTIPLY_FILTER 0 -+#define CONFIG_PREWITT_FILTER 0 -+#define CONFIG_PREWITT_OPENCL_FILTER 0 -+#define CONFIG_PROCAMP_VAAPI_FILTER 0 -+#define CONFIG_PROGRAM_OPENCL_FILTER 0 -+#define CONFIG_PSEUDOCOLOR_FILTER 0 -+#define CONFIG_PSNR_FILTER 0 -+#define CONFIG_PULLUP_FILTER 0 -+#define CONFIG_QP_FILTER 0 -+#define CONFIG_RANDOM_FILTER 0 -+#define CONFIG_READEIA608_FILTER 0 -+#define CONFIG_READVITC_FILTER 0 -+#define CONFIG_REALTIME_FILTER 0 -+#define CONFIG_REMAP_FILTER 0 -+#define CONFIG_REMOVEGRAIN_FILTER 0 -+#define CONFIG_REMOVELOGO_FILTER 0 -+#define CONFIG_REPEATFIELDS_FILTER 0 -+#define CONFIG_REVERSE_FILTER 0 -+#define CONFIG_RGBASHIFT_FILTER 0 -+#define CONFIG_ROBERTS_FILTER 0 -+#define CONFIG_ROBERTS_OPENCL_FILTER 0 -+#define CONFIG_ROTATE_FILTER 0 -+#define CONFIG_SAB_FILTER 0 -+#define CONFIG_SCALE_FILTER 0 -+#define CONFIG_SCALE_CUDA_FILTER 0 -+#define CONFIG_SCALE_NPP_FILTER 0 -+#define CONFIG_SCALE_QSV_FILTER 0 -+#define CONFIG_SCALE_VAAPI_FILTER 0 -+#define CONFIG_SCALE_VULKAN_FILTER 0 -+#define CONFIG_SCALE2REF_FILTER 0 -+#define CONFIG_SCDET_FILTER 0 -+#define CONFIG_SCROLL_FILTER 0 -+#define CONFIG_SELECT_FILTER 0 -+#define CONFIG_SELECTIVECOLOR_FILTER 0 -+#define CONFIG_SENDCMD_FILTER 0 -+#define CONFIG_SEPARATEFIELDS_FILTER 0 -+#define CONFIG_SETDAR_FILTER 0 -+#define CONFIG_SETFIELD_FILTER 0 -+#define CONFIG_SETPARAMS_FILTER 0 -+#define CONFIG_SETPTS_FILTER 0 -+#define CONFIG_SETRANGE_FILTER 0 -+#define CONFIG_SETSAR_FILTER 0 -+#define CONFIG_SETTB_FILTER 0 -+#define CONFIG_SHARPNESS_VAAPI_FILTER 0 -+#define CONFIG_SHOWINFO_FILTER 0 -+#define CONFIG_SHOWPALETTE_FILTER 0 -+#define CONFIG_SHUFFLEFRAMES_FILTER 0 -+#define CONFIG_SHUFFLEPLANES_FILTER 0 -+#define CONFIG_SIDEDATA_FILTER 0 -+#define CONFIG_SIGNALSTATS_FILTER 0 -+#define CONFIG_SIGNATURE_FILTER 0 -+#define CONFIG_SMARTBLUR_FILTER 0 -+#define CONFIG_SOBEL_FILTER 0 -+#define CONFIG_SOBEL_OPENCL_FILTER 0 -+#define CONFIG_SPLIT_FILTER 0 -+#define CONFIG_SPP_FILTER 0 -+#define CONFIG_SR_FILTER 0 -+#define CONFIG_SSIM_FILTER 0 -+#define CONFIG_STEREO3D_FILTER 0 -+#define CONFIG_STREAMSELECT_FILTER 0 -+#define CONFIG_SUBTITLES_FILTER 0 -+#define CONFIG_SUPER2XSAI_FILTER 0 -+#define CONFIG_SWAPRECT_FILTER 0 -+#define CONFIG_SWAPUV_FILTER 0 -+#define CONFIG_TBLEND_FILTER 0 -+#define CONFIG_TELECINE_FILTER 0 -+#define CONFIG_THISTOGRAM_FILTER 0 -+#define CONFIG_THRESHOLD_FILTER 0 -+#define CONFIG_THUMBNAIL_FILTER 0 -+#define CONFIG_THUMBNAIL_CUDA_FILTER 0 -+#define CONFIG_TILE_FILTER 0 -+#define CONFIG_TINTERLACE_FILTER 0 -+#define CONFIG_TLUT2_FILTER 0 -+#define CONFIG_TMEDIAN_FILTER 0 -+#define CONFIG_TMIX_FILTER 0 -+#define CONFIG_TONEMAP_FILTER 0 -+#define CONFIG_TONEMAP_OPENCL_FILTER 0 -+#define CONFIG_TONEMAP_VAAPI_FILTER 0 -+#define CONFIG_TPAD_FILTER 0 -+#define CONFIG_TRANSPOSE_FILTER 0 -+#define CONFIG_TRANSPOSE_NPP_FILTER 0 -+#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 -+#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 -+#define CONFIG_TRIM_FILTER 0 -+#define CONFIG_UNPREMULTIPLY_FILTER 0 -+#define CONFIG_UNSHARP_FILTER 0 -+#define CONFIG_UNSHARP_OPENCL_FILTER 0 -+#define CONFIG_UNTILE_FILTER 0 -+#define CONFIG_USPP_FILTER 0 -+#define CONFIG_V360_FILTER 0 -+#define CONFIG_VAGUEDENOISER_FILTER 0 -+#define CONFIG_VECTORSCOPE_FILTER 0 -+#define CONFIG_VFLIP_FILTER 0 -+#define CONFIG_VFRDET_FILTER 0 -+#define CONFIG_VIBRANCE_FILTER 0 -+#define CONFIG_VIDSTABDETECT_FILTER 0 -+#define CONFIG_VIDSTABTRANSFORM_FILTER 0 -+#define CONFIG_VIGNETTE_FILTER 0 -+#define CONFIG_VMAFMOTION_FILTER 0 -+#define CONFIG_VPP_QSV_FILTER 0 -+#define CONFIG_VSTACK_FILTER 0 -+#define CONFIG_W3FDIF_FILTER 0 -+#define CONFIG_WAVEFORM_FILTER 0 -+#define CONFIG_WEAVE_FILTER 0 -+#define CONFIG_XBR_FILTER 0 -+#define CONFIG_XFADE_FILTER 0 -+#define CONFIG_XFADE_OPENCL_FILTER 0 -+#define CONFIG_XMEDIAN_FILTER 0 -+#define CONFIG_XSTACK_FILTER 0 -+#define CONFIG_YADIF_FILTER 0 -+#define CONFIG_YADIF_CUDA_FILTER 0 -+#define CONFIG_YAEPBLUR_FILTER 0 -+#define CONFIG_ZMQ_FILTER 0 -+#define CONFIG_ZOOMPAN_FILTER 0 -+#define CONFIG_ZSCALE_FILTER 0 -+#define CONFIG_ALLRGB_FILTER 0 -+#define CONFIG_ALLYUV_FILTER 0 -+#define CONFIG_CELLAUTO_FILTER 0 -+#define CONFIG_COLOR_FILTER 0 -+#define CONFIG_COREIMAGESRC_FILTER 0 -+#define CONFIG_FREI0R_SRC_FILTER 0 -+#define CONFIG_GRADIENTS_FILTER 0 -+#define CONFIG_HALDCLUTSRC_FILTER 0 -+#define CONFIG_LIFE_FILTER 0 -+#define CONFIG_MANDELBROT_FILTER 0 -+#define CONFIG_MPTESTSRC_FILTER 0 -+#define CONFIG_NULLSRC_FILTER 0 -+#define CONFIG_OPENCLSRC_FILTER 0 -+#define CONFIG_PAL75BARS_FILTER 0 -+#define CONFIG_PAL100BARS_FILTER 0 -+#define CONFIG_RGBTESTSRC_FILTER 0 -+#define CONFIG_SIERPINSKI_FILTER 0 -+#define CONFIG_SMPTEBARS_FILTER 0 -+#define CONFIG_SMPTEHDBARS_FILTER 0 -+#define CONFIG_TESTSRC_FILTER 0 -+#define CONFIG_TESTSRC2_FILTER 0 -+#define CONFIG_YUVTESTSRC_FILTER 0 -+#define CONFIG_NULLSINK_FILTER 0 -+#define CONFIG_ABITSCOPE_FILTER 0 -+#define CONFIG_ADRAWGRAPH_FILTER 0 -+#define CONFIG_AGRAPHMONITOR_FILTER 0 -+#define CONFIG_AHISTOGRAM_FILTER 0 -+#define CONFIG_APHASEMETER_FILTER 0 -+#define CONFIG_AVECTORSCOPE_FILTER 0 -+#define CONFIG_CONCAT_FILTER 0 -+#define CONFIG_SHOWCQT_FILTER 0 -+#define CONFIG_SHOWFREQS_FILTER 0 -+#define CONFIG_SHOWSPATIAL_FILTER 0 -+#define CONFIG_SHOWSPECTRUM_FILTER 0 -+#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 -+#define CONFIG_SHOWVOLUME_FILTER 0 -+#define CONFIG_SHOWWAVES_FILTER 0 -+#define CONFIG_SHOWWAVESPIC_FILTER 0 -+#define CONFIG_SPECTRUMSYNTH_FILTER 0 -+#define CONFIG_AMOVIE_FILTER 0 -+#define CONFIG_MOVIE_FILTER 0 -+#define CONFIG_AFIFO_FILTER 0 -+#define CONFIG_FIFO_FILTER 0 -+#define CONFIG_AA_DEMUXER 0 -+#define CONFIG_AAC_DEMUXER 1 -+#define CONFIG_AC3_DEMUXER 0 -+#define CONFIG_ACM_DEMUXER 0 -+#define CONFIG_ACT_DEMUXER 0 -+#define CONFIG_ADF_DEMUXER 0 -+#define CONFIG_ADP_DEMUXER 0 -+#define CONFIG_ADS_DEMUXER 0 -+#define CONFIG_ADX_DEMUXER 0 -+#define CONFIG_AEA_DEMUXER 0 -+#define CONFIG_AFC_DEMUXER 0 -+#define CONFIG_AIFF_DEMUXER 0 -+#define CONFIG_AIX_DEMUXER 0 -+#define CONFIG_ALP_DEMUXER 0 -+#define CONFIG_AMR_DEMUXER 0 -+#define CONFIG_AMRNB_DEMUXER 0 -+#define CONFIG_AMRWB_DEMUXER 0 -+#define CONFIG_ANM_DEMUXER 0 -+#define CONFIG_APC_DEMUXER 0 -+#define CONFIG_APE_DEMUXER 0 -+#define CONFIG_APM_DEMUXER 0 -+#define CONFIG_APNG_DEMUXER 0 -+#define CONFIG_APTX_DEMUXER 0 -+#define CONFIG_APTX_HD_DEMUXER 0 -+#define CONFIG_AQTITLE_DEMUXER 0 -+#define CONFIG_ARGO_ASF_DEMUXER 0 -+#define CONFIG_ASF_DEMUXER 0 -+#define CONFIG_ASF_O_DEMUXER 0 -+#define CONFIG_ASS_DEMUXER 0 -+#define CONFIG_AST_DEMUXER 0 -+#define CONFIG_AU_DEMUXER 0 -+#define CONFIG_AV1_DEMUXER 0 -+#define CONFIG_AVI_DEMUXER 0 -+#define CONFIG_AVISYNTH_DEMUXER 0 -+#define CONFIG_AVR_DEMUXER 0 -+#define CONFIG_AVS_DEMUXER 0 -+#define CONFIG_AVS2_DEMUXER 0 -+#define CONFIG_BETHSOFTVID_DEMUXER 0 -+#define CONFIG_BFI_DEMUXER 0 -+#define CONFIG_BINTEXT_DEMUXER 0 -+#define CONFIG_BINK_DEMUXER 0 -+#define CONFIG_BIT_DEMUXER 0 -+#define CONFIG_BMV_DEMUXER 0 -+#define CONFIG_BFSTM_DEMUXER 0 -+#define CONFIG_BRSTM_DEMUXER 0 -+#define CONFIG_BOA_DEMUXER 0 -+#define CONFIG_C93_DEMUXER 0 -+#define CONFIG_CAF_DEMUXER 0 -+#define CONFIG_CAVSVIDEO_DEMUXER 0 -+#define CONFIG_CDG_DEMUXER 0 -+#define CONFIG_CDXL_DEMUXER 0 -+#define CONFIG_CINE_DEMUXER 0 -+#define CONFIG_CODEC2_DEMUXER 0 -+#define CONFIG_CODEC2RAW_DEMUXER 0 -+#define CONFIG_CONCAT_DEMUXER 0 -+#define CONFIG_DASH_DEMUXER 0 -+#define CONFIG_DATA_DEMUXER 0 -+#define CONFIG_DAUD_DEMUXER 0 -+#define CONFIG_DCSTR_DEMUXER 0 -+#define CONFIG_DERF_DEMUXER 0 -+#define CONFIG_DFA_DEMUXER 0 -+#define CONFIG_DHAV_DEMUXER 0 -+#define CONFIG_DIRAC_DEMUXER 0 -+#define CONFIG_DNXHD_DEMUXER 0 -+#define CONFIG_DSF_DEMUXER 0 -+#define CONFIG_DSICIN_DEMUXER 0 -+#define CONFIG_DSS_DEMUXER 0 -+#define CONFIG_DTS_DEMUXER 0 -+#define CONFIG_DTSHD_DEMUXER 0 -+#define CONFIG_DV_DEMUXER 0 -+#define CONFIG_DVBSUB_DEMUXER 0 -+#define CONFIG_DVBTXT_DEMUXER 0 -+#define CONFIG_DXA_DEMUXER 0 -+#define CONFIG_EA_DEMUXER 0 -+#define CONFIG_EA_CDATA_DEMUXER 0 -+#define CONFIG_EAC3_DEMUXER 0 -+#define CONFIG_EPAF_DEMUXER 0 -+#define CONFIG_FFMETADATA_DEMUXER 0 -+#define CONFIG_FILMSTRIP_DEMUXER 0 -+#define CONFIG_FITS_DEMUXER 0 -+#define CONFIG_FLAC_DEMUXER 1 -+#define CONFIG_FLIC_DEMUXER 0 -+#define CONFIG_FLV_DEMUXER 0 -+#define CONFIG_LIVE_FLV_DEMUXER 0 -+#define CONFIG_FOURXM_DEMUXER 0 -+#define CONFIG_FRM_DEMUXER 0 -+#define CONFIG_FSB_DEMUXER 0 -+#define CONFIG_FWSE_DEMUXER 0 -+#define CONFIG_G722_DEMUXER 0 -+#define CONFIG_G723_1_DEMUXER 0 -+#define CONFIG_G726_DEMUXER 0 -+#define CONFIG_G726LE_DEMUXER 0 -+#define CONFIG_G729_DEMUXER 0 -+#define CONFIG_GDV_DEMUXER 0 -+#define CONFIG_GENH_DEMUXER 0 -+#define CONFIG_GIF_DEMUXER 0 -+#define CONFIG_GSM_DEMUXER 0 -+#define CONFIG_GXF_DEMUXER 0 -+#define CONFIG_H261_DEMUXER 0 -+#define CONFIG_H263_DEMUXER 0 -+#define CONFIG_H264_DEMUXER 0 -+#define CONFIG_HCA_DEMUXER 0 -+#define CONFIG_HCOM_DEMUXER 0 -+#define CONFIG_HEVC_DEMUXER 0 -+#define CONFIG_HLS_DEMUXER 0 -+#define CONFIG_HNM_DEMUXER 0 -+#define CONFIG_ICO_DEMUXER 0 -+#define CONFIG_IDCIN_DEMUXER 0 -+#define CONFIG_IDF_DEMUXER 0 -+#define CONFIG_IFF_DEMUXER 0 -+#define CONFIG_IFV_DEMUXER 0 -+#define CONFIG_ILBC_DEMUXER 0 -+#define CONFIG_IMAGE2_DEMUXER 0 -+#define CONFIG_IMAGE2PIPE_DEMUXER 0 -+#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 -+#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 -+#define CONFIG_INGENIENT_DEMUXER 0 -+#define CONFIG_IPMOVIE_DEMUXER 0 -+#define CONFIG_IRCAM_DEMUXER 0 -+#define CONFIG_ISS_DEMUXER 0 -+#define CONFIG_IV8_DEMUXER 0 -+#define CONFIG_IVF_DEMUXER 0 -+#define CONFIG_IVR_DEMUXER 0 -+#define CONFIG_JACOSUB_DEMUXER 0 -+#define CONFIG_JV_DEMUXER 0 -+#define CONFIG_KUX_DEMUXER 0 -+#define CONFIG_KVAG_DEMUXER 0 -+#define CONFIG_LMLM4_DEMUXER 0 -+#define CONFIG_LOAS_DEMUXER 0 -+#define CONFIG_LRC_DEMUXER 0 -+#define CONFIG_LVF_DEMUXER 0 -+#define CONFIG_LXF_DEMUXER 0 -+#define CONFIG_M4V_DEMUXER 0 -+#define CONFIG_MCC_DEMUXER 0 -+#define CONFIG_MATROSKA_DEMUXER 1 -+#define CONFIG_MGSTS_DEMUXER 0 -+#define CONFIG_MICRODVD_DEMUXER 0 -+#define CONFIG_MJPEG_DEMUXER 0 -+#define CONFIG_MJPEG_2000_DEMUXER 0 -+#define CONFIG_MLP_DEMUXER 0 -+#define CONFIG_MLV_DEMUXER 0 -+#define CONFIG_MM_DEMUXER 0 -+#define CONFIG_MMF_DEMUXER 0 -+#define CONFIG_MOV_DEMUXER 1 -+#define CONFIG_MP3_DEMUXER 1 -+#define CONFIG_MPC_DEMUXER 0 -+#define CONFIG_MPC8_DEMUXER 0 -+#define CONFIG_MPEGPS_DEMUXER 0 -+#define CONFIG_MPEGTS_DEMUXER 0 -+#define CONFIG_MPEGTSRAW_DEMUXER 0 -+#define CONFIG_MPEGVIDEO_DEMUXER 0 -+#define CONFIG_MPJPEG_DEMUXER 0 -+#define CONFIG_MPL2_DEMUXER 0 -+#define CONFIG_MPSUB_DEMUXER 0 -+#define CONFIG_MSF_DEMUXER 0 -+#define CONFIG_MSNWC_TCP_DEMUXER 0 -+#define CONFIG_MTAF_DEMUXER 0 -+#define CONFIG_MTV_DEMUXER 0 -+#define CONFIG_MUSX_DEMUXER 0 -+#define CONFIG_MV_DEMUXER 0 -+#define CONFIG_MVI_DEMUXER 0 -+#define CONFIG_MXF_DEMUXER 0 -+#define CONFIG_MXG_DEMUXER 0 -+#define CONFIG_NC_DEMUXER 0 -+#define CONFIG_NISTSPHERE_DEMUXER 0 -+#define CONFIG_NSP_DEMUXER 0 -+#define CONFIG_NSV_DEMUXER 0 -+#define CONFIG_NUT_DEMUXER 0 -+#define CONFIG_NUV_DEMUXER 0 -+#define CONFIG_OBU_DEMUXER 0 -+#define CONFIG_OGG_DEMUXER 1 -+#define CONFIG_OMA_DEMUXER 0 -+#define CONFIG_PAF_DEMUXER 0 -+#define CONFIG_PCM_ALAW_DEMUXER 0 -+#define CONFIG_PCM_MULAW_DEMUXER 0 -+#define CONFIG_PCM_VIDC_DEMUXER 0 -+#define CONFIG_PCM_F64BE_DEMUXER 0 -+#define CONFIG_PCM_F64LE_DEMUXER 0 -+#define CONFIG_PCM_F32BE_DEMUXER 0 -+#define CONFIG_PCM_F32LE_DEMUXER 0 -+#define CONFIG_PCM_S32BE_DEMUXER 0 -+#define CONFIG_PCM_S32LE_DEMUXER 0 -+#define CONFIG_PCM_S24BE_DEMUXER 0 -+#define CONFIG_PCM_S24LE_DEMUXER 0 -+#define CONFIG_PCM_S16BE_DEMUXER 0 -+#define CONFIG_PCM_S16LE_DEMUXER 0 -+#define CONFIG_PCM_S8_DEMUXER 0 -+#define CONFIG_PCM_U32BE_DEMUXER 0 -+#define CONFIG_PCM_U32LE_DEMUXER 0 -+#define CONFIG_PCM_U24BE_DEMUXER 0 -+#define CONFIG_PCM_U24LE_DEMUXER 0 -+#define CONFIG_PCM_U16BE_DEMUXER 0 -+#define CONFIG_PCM_U16LE_DEMUXER 0 -+#define CONFIG_PCM_U8_DEMUXER 0 -+#define CONFIG_PJS_DEMUXER 0 -+#define CONFIG_PMP_DEMUXER 0 -+#define CONFIG_PP_BNK_DEMUXER 0 -+#define CONFIG_PVA_DEMUXER 0 -+#define CONFIG_PVF_DEMUXER 0 -+#define CONFIG_QCP_DEMUXER 0 -+#define CONFIG_R3D_DEMUXER 0 -+#define CONFIG_RAWVIDEO_DEMUXER 0 -+#define CONFIG_REALTEXT_DEMUXER 0 -+#define CONFIG_REDSPARK_DEMUXER 0 -+#define CONFIG_RL2_DEMUXER 0 -+#define CONFIG_RM_DEMUXER 0 -+#define CONFIG_ROQ_DEMUXER 0 -+#define CONFIG_RPL_DEMUXER 0 -+#define CONFIG_RSD_DEMUXER 0 -+#define CONFIG_RSO_DEMUXER 0 -+#define CONFIG_RTP_DEMUXER 0 -+#define CONFIG_RTSP_DEMUXER 0 -+#define CONFIG_S337M_DEMUXER 0 -+#define CONFIG_SAMI_DEMUXER 0 -+#define CONFIG_SAP_DEMUXER 0 -+#define CONFIG_SBC_DEMUXER 0 -+#define CONFIG_SBG_DEMUXER 0 -+#define CONFIG_SCC_DEMUXER 0 -+#define CONFIG_SDP_DEMUXER 0 -+#define CONFIG_SDR2_DEMUXER 0 -+#define CONFIG_SDS_DEMUXER 0 -+#define CONFIG_SDX_DEMUXER 0 -+#define CONFIG_SEGAFILM_DEMUXER 0 -+#define CONFIG_SER_DEMUXER 0 -+#define CONFIG_SHORTEN_DEMUXER 0 -+#define CONFIG_SIFF_DEMUXER 0 -+#define CONFIG_SLN_DEMUXER 0 -+#define CONFIG_SMACKER_DEMUXER 0 -+#define CONFIG_SMJPEG_DEMUXER 0 -+#define CONFIG_SMUSH_DEMUXER 0 -+#define CONFIG_SOL_DEMUXER 0 -+#define CONFIG_SOX_DEMUXER 0 -+#define CONFIG_SPDIF_DEMUXER 0 -+#define CONFIG_SRT_DEMUXER 0 -+#define CONFIG_STR_DEMUXER 0 -+#define CONFIG_STL_DEMUXER 0 -+#define CONFIG_SUBVIEWER1_DEMUXER 0 -+#define CONFIG_SUBVIEWER_DEMUXER 0 -+#define CONFIG_SUP_DEMUXER 0 -+#define CONFIG_SVAG_DEMUXER 0 -+#define CONFIG_SWF_DEMUXER 0 -+#define CONFIG_TAK_DEMUXER 0 -+#define CONFIG_TEDCAPTIONS_DEMUXER 0 -+#define CONFIG_THP_DEMUXER 0 -+#define CONFIG_THREEDOSTR_DEMUXER 0 -+#define CONFIG_TIERTEXSEQ_DEMUXER 0 -+#define CONFIG_TMV_DEMUXER 0 -+#define CONFIG_TRUEHD_DEMUXER 0 -+#define CONFIG_TTA_DEMUXER 0 -+#define CONFIG_TXD_DEMUXER 0 -+#define CONFIG_TTY_DEMUXER 0 -+#define CONFIG_TY_DEMUXER 0 -+#define CONFIG_V210_DEMUXER 0 -+#define CONFIG_V210X_DEMUXER 0 -+#define CONFIG_VAG_DEMUXER 0 -+#define CONFIG_VC1_DEMUXER 0 -+#define CONFIG_VC1T_DEMUXER 0 -+#define CONFIG_VIVIDAS_DEMUXER 0 -+#define CONFIG_VIVO_DEMUXER 0 -+#define CONFIG_VMD_DEMUXER 0 -+#define CONFIG_VOBSUB_DEMUXER 0 -+#define CONFIG_VOC_DEMUXER 0 -+#define CONFIG_VPK_DEMUXER 0 -+#define CONFIG_VPLAYER_DEMUXER 0 -+#define CONFIG_VQF_DEMUXER 0 -+#define CONFIG_W64_DEMUXER 0 -+#define CONFIG_WAV_DEMUXER 1 -+#define CONFIG_WC3_DEMUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 -+#define CONFIG_WEBVTT_DEMUXER 0 -+#define CONFIG_WSAUD_DEMUXER 0 -+#define CONFIG_WSD_DEMUXER 0 -+#define CONFIG_WSVQA_DEMUXER 0 -+#define CONFIG_WTV_DEMUXER 0 -+#define CONFIG_WVE_DEMUXER 0 -+#define CONFIG_WV_DEMUXER 0 -+#define CONFIG_XA_DEMUXER 0 -+#define CONFIG_XBIN_DEMUXER 0 -+#define CONFIG_XMV_DEMUXER 0 -+#define CONFIG_XVAG_DEMUXER 0 -+#define CONFIG_XWMA_DEMUXER 0 -+#define CONFIG_YOP_DEMUXER 0 -+#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 -+#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 -+#define CONFIG_LIBGME_DEMUXER 0 -+#define CONFIG_LIBMODPLUG_DEMUXER 0 -+#define CONFIG_LIBOPENMPT_DEMUXER 0 -+#define CONFIG_VAPOURSYNTH_DEMUXER 0 -+#define CONFIG_A64_MUXER 0 -+#define CONFIG_AC3_MUXER 0 -+#define CONFIG_ADTS_MUXER 0 -+#define CONFIG_ADX_MUXER 0 -+#define CONFIG_AIFF_MUXER 0 -+#define CONFIG_AMR_MUXER 0 -+#define CONFIG_APM_MUXER 0 -+#define CONFIG_APNG_MUXER 0 -+#define CONFIG_APTX_MUXER 0 -+#define CONFIG_APTX_HD_MUXER 0 -+#define CONFIG_ARGO_ASF_MUXER 0 -+#define CONFIG_ASF_MUXER 0 -+#define CONFIG_ASS_MUXER 0 -+#define CONFIG_AST_MUXER 0 -+#define CONFIG_ASF_STREAM_MUXER 0 -+#define CONFIG_AU_MUXER 0 -+#define CONFIG_AVI_MUXER 0 -+#define CONFIG_AVM2_MUXER 0 -+#define CONFIG_AVS2_MUXER 0 -+#define CONFIG_BIT_MUXER 0 -+#define CONFIG_CAF_MUXER 0 -+#define CONFIG_CAVSVIDEO_MUXER 0 -+#define CONFIG_CODEC2_MUXER 0 -+#define CONFIG_CODEC2RAW_MUXER 0 -+#define CONFIG_CRC_MUXER 0 -+#define CONFIG_DASH_MUXER 0 -+#define CONFIG_DATA_MUXER 0 -+#define CONFIG_DAUD_MUXER 0 -+#define CONFIG_DIRAC_MUXER 0 -+#define CONFIG_DNXHD_MUXER 0 -+#define CONFIG_DTS_MUXER 0 -+#define CONFIG_DV_MUXER 0 -+#define CONFIG_EAC3_MUXER 0 -+#define CONFIG_F4V_MUXER 0 -+#define CONFIG_FFMETADATA_MUXER 0 -+#define CONFIG_FIFO_MUXER 0 -+#define CONFIG_FIFO_TEST_MUXER 0 -+#define CONFIG_FILMSTRIP_MUXER 0 -+#define CONFIG_FITS_MUXER 0 -+#define CONFIG_FLAC_MUXER 0 -+#define CONFIG_FLV_MUXER 0 -+#define CONFIG_FRAMECRC_MUXER 0 -+#define CONFIG_FRAMEHASH_MUXER 0 -+#define CONFIG_FRAMEMD5_MUXER 0 -+#define CONFIG_G722_MUXER 0 -+#define CONFIG_G723_1_MUXER 0 -+#define CONFIG_G726_MUXER 0 -+#define CONFIG_G726LE_MUXER 0 -+#define CONFIG_GIF_MUXER 0 -+#define CONFIG_GSM_MUXER 0 -+#define CONFIG_GXF_MUXER 0 -+#define CONFIG_H261_MUXER 0 -+#define CONFIG_H263_MUXER 0 -+#define CONFIG_H264_MUXER 0 -+#define CONFIG_HASH_MUXER 0 -+#define CONFIG_HDS_MUXER 0 -+#define CONFIG_HEVC_MUXER 0 -+#define CONFIG_HLS_MUXER 0 -+#define CONFIG_ICO_MUXER 0 -+#define CONFIG_ILBC_MUXER 0 -+#define CONFIG_IMAGE2_MUXER 0 -+#define CONFIG_IMAGE2PIPE_MUXER 0 -+#define CONFIG_IPOD_MUXER 0 -+#define CONFIG_IRCAM_MUXER 0 -+#define CONFIG_ISMV_MUXER 0 -+#define CONFIG_IVF_MUXER 0 -+#define CONFIG_JACOSUB_MUXER 0 -+#define CONFIG_KVAG_MUXER 0 -+#define CONFIG_LATM_MUXER 0 -+#define CONFIG_LRC_MUXER 0 -+#define CONFIG_M4V_MUXER 0 -+#define CONFIG_MD5_MUXER 0 -+#define CONFIG_MATROSKA_MUXER 0 -+#define CONFIG_MATROSKA_AUDIO_MUXER 0 -+#define CONFIG_MICRODVD_MUXER 0 -+#define CONFIG_MJPEG_MUXER 0 -+#define CONFIG_MLP_MUXER 0 -+#define CONFIG_MMF_MUXER 0 -+#define CONFIG_MOV_MUXER 0 -+#define CONFIG_MP2_MUXER 0 -+#define CONFIG_MP3_MUXER 0 -+#define CONFIG_MP4_MUXER 0 -+#define CONFIG_MPEG1SYSTEM_MUXER 0 -+#define CONFIG_MPEG1VCD_MUXER 0 -+#define CONFIG_MPEG1VIDEO_MUXER 0 -+#define CONFIG_MPEG2DVD_MUXER 0 -+#define CONFIG_MPEG2SVCD_MUXER 0 -+#define CONFIG_MPEG2VIDEO_MUXER 0 -+#define CONFIG_MPEG2VOB_MUXER 0 -+#define CONFIG_MPEGTS_MUXER 0 -+#define CONFIG_MPJPEG_MUXER 0 -+#define CONFIG_MXF_MUXER 0 -+#define CONFIG_MXF_D10_MUXER 0 -+#define CONFIG_MXF_OPATOM_MUXER 0 -+#define CONFIG_NULL_MUXER 0 -+#define CONFIG_NUT_MUXER 0 -+#define CONFIG_OGA_MUXER 0 -+#define CONFIG_OGG_MUXER 0 -+#define CONFIG_OGV_MUXER 0 -+#define CONFIG_OMA_MUXER 0 -+#define CONFIG_OPUS_MUXER 0 -+#define CONFIG_PCM_ALAW_MUXER 0 -+#define CONFIG_PCM_MULAW_MUXER 0 -+#define CONFIG_PCM_VIDC_MUXER 0 -+#define CONFIG_PCM_F64BE_MUXER 0 -+#define CONFIG_PCM_F64LE_MUXER 0 -+#define CONFIG_PCM_F32BE_MUXER 0 -+#define CONFIG_PCM_F32LE_MUXER 0 -+#define CONFIG_PCM_S32BE_MUXER 0 -+#define CONFIG_PCM_S32LE_MUXER 0 -+#define CONFIG_PCM_S24BE_MUXER 0 -+#define CONFIG_PCM_S24LE_MUXER 0 -+#define CONFIG_PCM_S16BE_MUXER 0 -+#define CONFIG_PCM_S16LE_MUXER 0 -+#define CONFIG_PCM_S8_MUXER 0 -+#define CONFIG_PCM_U32BE_MUXER 0 -+#define CONFIG_PCM_U32LE_MUXER 0 -+#define CONFIG_PCM_U24BE_MUXER 0 -+#define CONFIG_PCM_U24LE_MUXER 0 -+#define CONFIG_PCM_U16BE_MUXER 0 -+#define CONFIG_PCM_U16LE_MUXER 0 -+#define CONFIG_PCM_U8_MUXER 0 -+#define CONFIG_PSP_MUXER 0 -+#define CONFIG_RAWVIDEO_MUXER 0 -+#define CONFIG_RM_MUXER 0 -+#define CONFIG_ROQ_MUXER 0 -+#define CONFIG_RSO_MUXER 0 -+#define CONFIG_RTP_MUXER 0 -+#define CONFIG_RTP_MPEGTS_MUXER 0 -+#define CONFIG_RTSP_MUXER 0 -+#define CONFIG_SAP_MUXER 0 -+#define CONFIG_SBC_MUXER 0 -+#define CONFIG_SCC_MUXER 0 -+#define CONFIG_SEGAFILM_MUXER 0 -+#define CONFIG_SEGMENT_MUXER 0 -+#define CONFIG_STREAM_SEGMENT_MUXER 0 -+#define CONFIG_SINGLEJPEG_MUXER 0 -+#define CONFIG_SMJPEG_MUXER 0 -+#define CONFIG_SMOOTHSTREAMING_MUXER 0 -+#define CONFIG_SOX_MUXER 0 -+#define CONFIG_SPX_MUXER 0 -+#define CONFIG_SPDIF_MUXER 0 -+#define CONFIG_SRT_MUXER 0 -+#define CONFIG_STREAMHASH_MUXER 0 -+#define CONFIG_SUP_MUXER 0 -+#define CONFIG_SWF_MUXER 0 -+#define CONFIG_TEE_MUXER 0 -+#define CONFIG_TG2_MUXER 0 -+#define CONFIG_TGP_MUXER 0 -+#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 -+#define CONFIG_TRUEHD_MUXER 0 -+#define CONFIG_TTA_MUXER 0 -+#define CONFIG_UNCODEDFRAMECRC_MUXER 0 -+#define CONFIG_VC1_MUXER 0 -+#define CONFIG_VC1T_MUXER 0 -+#define CONFIG_VOC_MUXER 0 -+#define CONFIG_W64_MUXER 0 -+#define CONFIG_WAV_MUXER 0 -+#define CONFIG_WEBM_MUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 -+#define CONFIG_WEBM_CHUNK_MUXER 0 -+#define CONFIG_WEBP_MUXER 0 -+#define CONFIG_WEBVTT_MUXER 0 -+#define CONFIG_WTV_MUXER 0 -+#define CONFIG_WV_MUXER 0 -+#define CONFIG_YUV4MPEGPIPE_MUXER 0 -+#define CONFIG_CHROMAPRINT_MUXER 0 -+#define CONFIG_ASYNC_PROTOCOL 0 -+#define CONFIG_BLURAY_PROTOCOL 0 -+#define CONFIG_CACHE_PROTOCOL 0 -+#define CONFIG_CONCAT_PROTOCOL 0 -+#define CONFIG_CRYPTO_PROTOCOL 0 -+#define CONFIG_DATA_PROTOCOL 0 -+#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 -+#define CONFIG_FFRTMPHTTP_PROTOCOL 0 -+#define CONFIG_FILE_PROTOCOL 0 -+#define CONFIG_FTP_PROTOCOL 0 -+#define CONFIG_GOPHER_PROTOCOL 0 -+#define CONFIG_HLS_PROTOCOL 0 -+#define CONFIG_HTTP_PROTOCOL 0 -+#define CONFIG_HTTPPROXY_PROTOCOL 0 -+#define CONFIG_HTTPS_PROTOCOL 0 -+#define CONFIG_ICECAST_PROTOCOL 0 -+#define CONFIG_MMSH_PROTOCOL 0 -+#define CONFIG_MMST_PROTOCOL 0 -+#define CONFIG_MD5_PROTOCOL 0 -+#define CONFIG_PIPE_PROTOCOL 0 -+#define CONFIG_PROMPEG_PROTOCOL 0 -+#define CONFIG_RTMP_PROTOCOL 0 -+#define CONFIG_RTMPE_PROTOCOL 0 -+#define CONFIG_RTMPS_PROTOCOL 0 -+#define CONFIG_RTMPT_PROTOCOL 0 -+#define CONFIG_RTMPTE_PROTOCOL 0 -+#define CONFIG_RTMPTS_PROTOCOL 0 -+#define CONFIG_RTP_PROTOCOL 0 -+#define CONFIG_SCTP_PROTOCOL 0 -+#define CONFIG_SRTP_PROTOCOL 0 -+#define CONFIG_SUBFILE_PROTOCOL 0 -+#define CONFIG_TEE_PROTOCOL 0 -+#define CONFIG_TCP_PROTOCOL 0 -+#define CONFIG_TLS_PROTOCOL 0 -+#define CONFIG_UDP_PROTOCOL 0 -+#define CONFIG_UDPLITE_PROTOCOL 0 -+#define CONFIG_UNIX_PROTOCOL 0 -+#define CONFIG_LIBAMQP_PROTOCOL 0 -+#define CONFIG_LIBRTMP_PROTOCOL 0 -+#define CONFIG_LIBRTMPE_PROTOCOL 0 -+#define CONFIG_LIBRTMPS_PROTOCOL 0 -+#define CONFIG_LIBRTMPT_PROTOCOL 0 -+#define CONFIG_LIBRTMPTE_PROTOCOL 0 -+#define CONFIG_LIBSRT_PROTOCOL 0 -+#define CONFIG_LIBSSH_PROTOCOL 0 -+#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 -+#define CONFIG_LIBZMQ_PROTOCOL 0 -+#endif /* FFMPEG_CONFIG_H */ -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/bsf_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/bsf_list.c -new file mode 100644 -index 000000000..d31ece942 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/bsf_list.c -@@ -0,0 +1,3 @@ -+static const AVBitStreamFilter * const bitstream_filters[] = { -+ &ff_null_bsf, -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/codec_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/codec_list.c -new file mode 100644 -index 000000000..49f757b2d ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/codec_list.c -@@ -0,0 +1,20 @@ -+static const AVCodec * const codec_list[] = { -+ &ff_h264_decoder, -+ &ff_theora_decoder, -+ &ff_vp3_decoder, -+ &ff_vp8_decoder, -+ &ff_aac_decoder, -+ &ff_flac_decoder, -+ &ff_mp3_decoder, -+ &ff_vorbis_decoder, -+ &ff_pcm_alaw_decoder, -+ &ff_pcm_f32le_decoder, -+ &ff_pcm_mulaw_decoder, -+ &ff_pcm_s16be_decoder, -+ &ff_pcm_s16le_decoder, -+ &ff_pcm_s24be_decoder, -+ &ff_pcm_s24le_decoder, -+ &ff_pcm_s32le_decoder, -+ &ff_pcm_u8_decoder, -+ &ff_libopus_decoder, -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/parser_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/parser_list.c -new file mode 100644 -index 000000000..50acddb28 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/parser_list.c -@@ -0,0 +1,11 @@ -+static const AVCodecParser * const parser_list[] = { -+ &ff_aac_parser, -+ &ff_flac_parser, -+ &ff_h264_parser, -+ &ff_mpegaudio_parser, -+ &ff_opus_parser, -+ &ff_vorbis_parser, -+ &ff_vp3_parser, -+ &ff_vp8_parser, -+ &ff_vp9_parser, -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/demuxer_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/demuxer_list.c -new file mode 100644 -index 000000000..920b22bfa ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/demuxer_list.c -@@ -0,0 +1,9 @@ -+static const AVInputFormat * const demuxer_list[] = { -+ &ff_aac_demuxer, -+ &ff_flac_demuxer, -+ &ff_matroska_demuxer, -+ &ff_mov_demuxer, -+ &ff_mp3_demuxer, -+ &ff_ogg_demuxer, -+ &ff_wav_demuxer, -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/muxer_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/muxer_list.c -new file mode 100644 -index 000000000..f36d9499c ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/muxer_list.c -@@ -0,0 +1,2 @@ -+static const AVOutputFormat * const muxer_list[] = { -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/protocol_list.c b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/protocol_list.c -new file mode 100644 -index 000000000..247e1e4c3 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/protocol_list.c -@@ -0,0 +1,2 @@ -+static const URLProtocol * const url_protocols[] = { -+ NULL }; -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/avconfig.h b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/avconfig.h -new file mode 100644 -index 000000000..c289fbb55 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/avconfig.h -@@ -0,0 +1,6 @@ -+/* Generated by ffmpeg configure */ -+#ifndef AVUTIL_AVCONFIG_H -+#define AVUTIL_AVCONFIG_H -+#define AV_HAVE_BIGENDIAN 0 -+#define AV_HAVE_FAST_UNALIGNED 1 -+#endif /* AVUTIL_AVCONFIG_H */ -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/ffversion.h b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/ffversion.h -new file mode 100644 -index 000000000..86446e843 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/ffversion.h -@@ -0,0 +1,5 @@ -+/* Automatically generated by version.sh, do not manually edit! */ -+#ifndef AVUTIL_FFVERSION_H -+#define AVUTIL_FFVERSION_H -+#define FFMPEG_VERSION "git-2024-04-23-445820325" -+#endif /* AVUTIL_FFVERSION_H */ -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py -index 75333a2c9..5db77aab9 100755 ---- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py -@@ -36,7 +36,7 @@ BRANDINGS = [ - ARCH_MAP = { - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ -- 'ia32', 'x64', 'mipsel', 'mips64el', 'noasm-x64', 'arm', 'arm-neon', -+ 'ia32', 'x64', 'mipsel', 'mips64el', 'loongarch64', 'noasm-x64', 'arm', 'arm-neon', - 'arm64' - ], - 'mac': ['x64', 'arm64'], -@@ -133,6 +133,8 @@ def DetermineHostOsAndArch(): - host_arch = 'x64' - elif platform.machine() == 'aarch64': - host_arch = 'arm64' -+ elif platform.machine() == 'loongarch64': -+ host_arch = 'loongarch64' - elif platform.machine() == 'mips32': - host_arch = 'mipsel' - elif platform.machine() == 'mips64': -@@ -820,6 +822,11 @@ def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) -+ elif target_arch == 'loongarch64': -+ if target_os == 'linux': -+ configure_flags['Common'].extend([ -+ '--arch=loongarch64', -+ ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, -@@ -834,18 +841,21 @@ def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, - ]) - - if 'win' not in target_os: -- configure_flags['Common'].extend([ -- '--enable-pic', -- '--cc=clang', -- '--cxx=clang++', -- '--ld=clang', -- ]) -+ if target_arch != 'loongarch64': -+ configure_flags['Common'].extend([ -+ '--enable-pic', -+ '--cc=clang', -+ '--cxx=clang++', -+ '--ld=clang', -+ ]) -+ else: -+ configure_flags['Common'].extend(['--enable-pic']) - - # Clang Linux will use the first 'ld' it finds on the path, which will - # typically be the system one, so explicitly configure use of Clang's - # ld.lld, to ensure that things like cross-compilation and LTO work. - # This does not work for ia32 and is always used on mac. -- if target_arch != 'ia32' and target_os != 'mac': -+ if target_arch != 'ia32' and target_os != 'mac' and target_arch != 'loongarch64': - configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') - - # Should be run on Mac, unless we're cross-compiling on Linux. -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh -index 0e5159d6f..ee640403d 100755 ---- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh -@@ -10,7 +10,7 @@ for os in android linux linux-noasm mac win; do - # Copy config files for various architectures: - # - ia32/x64 have config.asm, config.h - # - arm/arm-neon have config.h -- for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do -+ for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el loongarch64; do - # Don't waste time on non-existent configs, if no config.h then skip. - [ ! -e "build.$arch.$os/$target/config.h" ] && continue - for f in config.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py -index 0f606dfae..ca6b9ae84 100755 ---- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py -@@ -77,7 +77,7 @@ GN_SOURCE_END = """] - Attr = enum('ARCHITECTURE', 'TARGET', 'PLATFORM') - SUPPORT_MATRIX = { - Attr.ARCHITECTURE: -- set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el']), -+ set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el', 'loongarch64']), - Attr.TARGET: - set(['Chromium', 'Chrome', 'ChromeOS']), - Attr.PLATFORM: -diff --git a/src/3rdparty/chromium/third_party/ffmpeg/configure b/src/3rdparty/chromium/third_party/ffmpeg/configure -index f09efe19a..53e24f34c 100755 ---- a/src/3rdparty/chromium/third_party/ffmpeg/configure -+++ b/src/3rdparty/chromium/third_party/ffmpeg/configure -@@ -1984,6 +1984,7 @@ ARCH_LIST=" - avr32_uc - bfin - ia64 -+ loongarch64 - m68k - mips - mips64 -@@ -2596,10 +2597,10 @@ for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do - eval ${ext}_suggest='"${ext}_external ${ext}_inline"' - done - --aligned_stack_if_any="aarch64 ppc x86" --fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64" --fast_clz_if_any="aarch64 alpha avr32 mips ppc x86" --fast_unaligned_if_any="aarch64 ppc x86" -+aligned_stack_if_any="aarch64 ppc x86 loongarch64" -+fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64 loongarch64" -+fast_clz_if_any="aarch64 alpha avr32 mips ppc x86 loongarch64" -+fast_unaligned_if_any="aarch64 ppc x86 loongarch64" - simd_align_16_if_any="altivec neon sse" - simd_align_32_if_any="avx" - simd_align_64_if_any="avx512" -@@ -4871,6 +4872,9 @@ case "$arch" in - arm*|iPad*|iPhone*) - arch="arm" - ;; -+ loongarch64) -+ arch="loongarch64" -+ ;; - mips*|IP*) - case "$arch" in - *el) -@@ -5278,6 +5282,11 @@ case "$arch" in - aarch64|alpha|ia64) - enabled shared && enable_weak pic - ;; -+ loongarch64) -+ enable loongarch64 -+ enabled loongarch64 -+ enabled shared && enabled_weak pic -+ ;; - mips) - check_64bit mips mips64 '_MIPS_SIM > 1' - enabled shared && enable_weak pic -diff --git a/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h b/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h -index e67df4123..2cef1c3e6 100644 ---- a/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h -+++ b/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h -@@ -88,7 +88,7 @@ - */ - #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ - defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ -- defined(__aarch64__) || defined(__s390__)) \ -+ defined(__aarch64__) || defined(__s390__) || defined(__loongarch64)) \ - && (defined(__linux) || defined(__ANDROID__)) - - #ifndef SYS_CPLUSPLUS -@@ -266,6 +266,12 @@ struct kernel_timeval { - long tv_usec; - }; - -+/* include/linux/time.h */ -+struct kernel_itimerval { -+ struct kernel_timeval it_interval; -+ struct kernel_timeval it_value; -+}; -+ - /* include/linux/resource.h */ - struct kernel_rusage { - struct kernel_timeval ru_utime; -@@ -301,8 +307,8 @@ struct kernel_old_sigaction { - } __attribute__((packed,aligned(4))); - #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) - #define kernel_old_sigaction kernel_sigaction --#elif defined(__aarch64__) -- // No kernel_old_sigaction defined for arm64. -+#elif defined(__aarch64__) || defined(__loongarch64) -+ // No kernel_old_sigaction defined for arm64 and loongarch64. - #endif - - /* Some kernel functions (e.g. sigaction() in 2.6.23) require that the -@@ -341,7 +347,9 @@ struct kernel_sigaction { - void (*sa_sigaction_)(int, siginfo_t *, void *); - }; - unsigned long sa_flags; -+ #if !defined(__loongarch64) - void (*sa_restorer)(void); -+ #endif - struct kernel_sigset_t sa_mask; - #endif - }; -@@ -519,7 +527,7 @@ struct kernel_stat { - int st_blocks; - int st_pad4[14]; - }; --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__loongarch64) - struct kernel_stat { - unsigned long st_dev; - unsigned long st_ino; -@@ -701,6 +709,37 @@ struct kernel_statfs { - }; - #endif - -+struct kernel_statx_timestamp { -+ int64_t tv_sec; -+ uint32_t tv_nsec; -+ int32_t __reserved; -+}; -+ -+struct kernel_statx { -+ uint32_t stx_mask; -+ uint32_t stx_blksize; -+ uint64_t stx_attributes; -+ uint32_t stx_nlink; -+ uint32_t stx_uid; -+ uint32_t stx_gid; -+ uint16_t stx_mode; -+ uint16_t __spare0[1]; -+ uint64_t stx_ino; -+ uint64_t stx_size; -+ uint64_t stx_blocks; -+ uint64_t stx_attributes_mask; -+ struct kernel_statx_timestamp stx_atime; -+ struct kernel_statx_timestamp stx_btime; -+ struct kernel_statx_timestamp stx_ctime; -+ struct kernel_statx_timestamp stx_mtime; -+ uint32_t stx_rdev_major; -+ uint32_t stx_rdev_minor; -+ uint32_t stx_dev_major; -+ uint32_t stx_dev_minor; -+ uint64_t stx_mnt_id; -+ uint64_t __spare2; -+ uint64_t __spare3[12]; -+}; - - /* Definitions missing from the standard header files */ - #ifndef O_DIRECTORY -@@ -737,6 +776,18 @@ struct kernel_statfs { - #ifndef AT_REMOVEDIR - #define AT_REMOVEDIR 0x200 - #endif -+#ifndef AT_NO_AUTOMOUNT -+#define AT_NO_AUTOMOUNT 0x800 -+#endif -+#ifndef AT_EMPTY_PATH -+#define AT_EMPTY_PATH 0x1000 -+#endif -+#ifndef STATX_BASIC_STATS -+#define STATX_BASIC_STATS 0x000007ffU -+#endif -+#ifndef AT_STATX_SYNC_AS_STAT -+#define AT_STATX_SYNC_AS_STAT 0x0000 -+#endif - #ifndef MREMAP_FIXED - #define MREMAP_FIXED 2 - #endif -@@ -1065,7 +1116,7 @@ struct kernel_statfs { - #define __NR_getrandom (__NR_SYSCALL_BASE + 384) - #endif - /* End of ARM 3/EABI definitions */ --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__loongarch64) - #ifndef __NR_setxattr - #define __NR_setxattr 5 - #endif -@@ -1121,9 +1172,11 @@ struct kernel_statfs { - #ifndef __NR_readlinkat - #define __NR_readlinkat 78 - #endif -+#if !defined(__loongarch64) - #ifndef __NR_newfstatat - #define __NR_newfstatat 79 - #endif -+#endif // __loongarch64 - #ifndef __NR_set_tid_address - #define __NR_set_tid_address 96 - #endif -@@ -1164,7 +1217,10 @@ struct kernel_statfs { - #ifndef __NR_getrandom - #define __NR_getrandom 278 - #endif --/* End of aarch64 definitions */ -+#ifndef __NR_statx -+#define __NR_statx 291 -+#endif -+/* End of aarch64 || __loongarch64 definitions */ - #elif defined(__x86_64__) - #ifndef __NR_pread64 - #define __NR_pread64 17 -@@ -1880,14 +1936,15 @@ struct kernel_statfs { - - #undef LSS_RETURN - #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ -- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) -+ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) \ -+ || defined(__loongarch64)) - /* Failing system calls return a negative result in the range of - * -1..-4095. These are "errno" values with the sign inverted. - */ - #define LSS_RETURN(type, res) \ - do { \ - if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ -- LSS_ERRNO = -(res); \ -+ LSS_ERRNO = (int)(-(res)); \ - res = -1; \ - } \ - return (type) (res); \ -@@ -1980,7 +2037,7 @@ struct kernel_statfs { - LSS_ENTRYPOINT \ - "pop %%ebx" \ - args \ -- : "memory"); \ -+ : "memory"); \ - LSS_RETURN(type,__res) - #undef _syscall0 - #define _syscall0(type,name) \ -@@ -2037,7 +2094,7 @@ struct kernel_statfs { - : "i" (__NR_##name), "ri" ((long)(arg1)), \ - "c" ((long)(arg2)), "d" ((long)(arg3)), \ - "S" ((long)(arg4)), "D" ((long)(arg5)) \ -- : "memory"); \ -+ : "memory"); \ - LSS_RETURN(type,__res); \ - } - #undef _syscall6 -@@ -2059,7 +2116,7 @@ struct kernel_statfs { - : "i" (__NR_##name), "0" ((long)(&__s)), \ - "c" ((long)(arg2)), "d" ((long)(arg3)), \ - "S" ((long)(arg4)), "D" ((long)(arg5)) \ -- : "memory"); \ -+ : "memory"); \ - LSS_RETURN(type,__res); \ - } - LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, -@@ -2241,7 +2298,7 @@ struct kernel_statfs { - #define _LSS_RETURN(type, res, cast) \ - do { \ - if ((uint64_t)(res) >= (uint64_t)(-4095)) { \ -- LSS_ERRNO = -(res); \ -+ LSS_ERRNO = (int)(-(res)); \ - res = -1; \ - } \ - return (type)(cast)(res); \ -@@ -3373,6 +3430,134 @@ struct kernel_statfs { - } - LSS_RETURN(int, __ret); - } -+ #elif defined(__loongarch64) -+ /* Most definitions of _syscallX() neglect to mark "memory" as being -+ * clobbered. This causes problems with compilers, that do a better job -+ * at optimizing across __asm__ calls. -+ * So, we just have to redefine all of the _syscallX() macros. -+ */ -+ #undef LSS_REG -+ #define LSS_REG(ar,a) register int64_t __r##ar __asm__("a"#ar) = (int64_t)a -+ /* syscall is like subroutine calls, all caller-saved registers may be -+ * clobbered, we should add them to the |Clobbers| list. -+ * a0 is not included because it's in the output list. -+ */ -+ #define LSS_SYSCALL_CLOBBERS "t0", "t1", "t2", "t3", "t4", "t5", "t6", \ -+ "t7", "t8", "memory" -+ #undef LSS_BODY -+ #define LSS_BODY(type,name,args...) \ -+ register int64_t __res_a0 __asm__("a0"); \ -+ register int64_t __a7 __asm__("a7") = __NR_##name; \ -+ int64_t __res; \ -+ __asm__ __volatile__ ("syscall 0x0\n" \ -+ : "=r"(__res_a0) \ -+ : "r"(__a7), ## args \ -+ : LSS_SYSCALL_CLOBBERS); \ -+ __res = __res_a0; \ -+ LSS_RETURN(type, __res) -+ #undef _syscall0 -+ #define _syscall0(type, name) \ -+ type LSS_NAME(name)(void) { \ -+ LSS_BODY(type, name); \ -+ } -+ #undef _syscall1 -+ #define _syscall1(type, name, type1, arg1) \ -+ type LSS_NAME(name)(type1 arg1) { \ -+ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ -+ } -+ #undef _syscall2 -+ #define _syscall2(type, name, type1, arg1, type2, arg2) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ -+ } -+ #undef _syscall3 -+ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ -+ } -+ #undef _syscall4 -+ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ -+ } -+ #undef _syscall5 -+ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ -+ type5,arg5) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ -+ type5 arg5) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); LSS_REG(4, arg5); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ -+ "r"(__r4)); \ -+ } -+ #undef _syscall6 -+ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ -+ type5,arg5,type6,arg6) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ -+ type5 arg5, type6 arg6) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ -+ "r"(__r4), "r"(__r5)); \ -+ } -+ -+ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, -+ int flags, void *arg, int *parent_tidptr, -+ void *newtls, int *child_tidptr) { -+ int64_t __res; -+ { -+ register int64_t __res_a0 __asm__("a0"); -+ register uint64_t __flags __asm__("a0") = flags; -+ register void *__stack __asm__("a1") = child_stack; -+ register void *__ptid __asm__("a2") = parent_tidptr; -+ register void *__tls __asm__("a3") = newtls; -+ register int *__ctid __asm__("a4") = child_tidptr; -+ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be -+ * used by the child. -+ */ -+ "addi.d %2, %2, -16\n" -+ "st.d %1, %2, 8\n" -+ "st.d %4, %2, 0\n" -+ -+ /* %a0 = syscall(%a0 = flags, -+ * %a1 = child_stack, -+ * %a2 = parent_tidptr, -+ * %a3 = newtls, -+ * %a4 = child_tidptr) -+ */ -+ "li.d $a7, %8\n" -+ "syscall 0x0\n" -+ -+ /* if (%a0 != 0) -+ * return %a0; -+ */ -+ "bnez $a0, 1f\n" -+ -+ /* In the child, now. Call "fn(arg)". -+ */ -+ "ld.d $a0, $sp, 0\n" -+ "ld.d $a1, $sp, 8\n" -+ "addi.d $sp, $sp, 16\n" -+ "jirl $ra, $a1, 0\n" -+ -+ /* Call _exit(%a0). -+ */ -+ "li.d $a7, %9\n" -+ "syscall 0x0\n" -+ "1:\n" -+ : "=r" (__res_a0) -+ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), -+ "r"(__ptid), "r"(__tls), "r"(__ctid), -+ "i"(__NR_clone), "i"(__NR_exit) -+ : "a7", LSS_SYSCALL_CLOBBERS); -+ __res = __res_a0; -+ } -+ LSS_RETURN(int, __res); -+ } - #endif - #define __NR__exit __NR_exit - #define __NR__gettid __NR_gettid -@@ -3403,8 +3588,10 @@ struct kernel_statfs { - // fork is polyfilled below when not available. - LSS_INLINE _syscall0(pid_t, fork) - #endif -+ #if defined(__NR_fstat) - LSS_INLINE _syscall2(int, fstat, int, f, - struct kernel_stat*, b) -+ #endif - LSS_INLINE _syscall2(int, fstatfs, int, f, - struct kernel_statfs*, b) - #if defined(__x86_64__) -@@ -3426,6 +3613,8 @@ struct kernel_statfs { - struct kernel_dirent64*, d, int, c) - LSS_INLINE _syscall0(gid_t, getegid) - LSS_INLINE _syscall0(uid_t, geteuid) -+ LSS_INLINE _syscall2(int, getitimer, int, w, -+ struct kernel_itimerval*, c) - #if defined(__NR_getpgrp) - LSS_INLINE _syscall0(pid_t, getpgrp) - #endif -@@ -3437,10 +3626,10 @@ struct kernel_statfs { - gid_t *, e, gid_t *, s) - LSS_INLINE _syscall3(int, getresuid, uid_t *, r, - uid_t *, e, uid_t *, s) --#if !defined(__ARM_EABI__) -+ #if defined(__NR_getrlimit) - LSS_INLINE _syscall2(int, getrlimit, int, r, - struct kernel_rlimit*, l) --#endif -+ #endif - LSS_INLINE _syscall1(pid_t, getsid, pid_t, p) - LSS_INLINE _syscall0(pid_t, _gettid) - LSS_INLINE _syscall2(pid_t, gettimeofday, struct kernel_timeval*, t, -@@ -3547,6 +3736,9 @@ struct kernel_statfs { - LSS_INLINE _syscall1(int, setfsuid, uid_t, u) - LSS_INLINE _syscall1(int, setuid, uid_t, u) - LSS_INLINE _syscall1(int, setgid, gid_t, g) -+ LSS_INLINE _syscall3(int, setitimer, int, w, -+ const struct kernel_itimerval*, n, -+ struct kernel_itimerval*, o) - LSS_INLINE _syscall2(int, setpgid, pid_t, p, - pid_t, g) - LSS_INLINE _syscall3(int, setpriority, int, a, -@@ -3555,8 +3747,10 @@ struct kernel_statfs { - gid_t, e, gid_t, s) - LSS_INLINE _syscall3(int, setresuid, uid_t, r, - uid_t, e, uid_t, s) -+ #if defined(__NR_setrlimit) - LSS_INLINE _syscall2(int, setrlimit, int, r, - const struct kernel_rlimit*, l) -+ #endif - LSS_INLINE _syscall0(pid_t, setsid) - LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, - const stack_t*, o) -@@ -3586,23 +3780,6 @@ struct kernel_statfs { - LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, - unsigned *, node, void *, unused) - #endif -- #if defined(__x86_64__) || \ -- (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) -- LSS_INLINE _syscall3(int, recvmsg, int, s, -- struct kernel_msghdr*, m, int, f) -- LSS_INLINE _syscall3(int, sendmsg, int, s, -- const struct kernel_msghdr*, m, int, f) -- LSS_INLINE _syscall6(int, sendto, int, s, -- const void*, m, size_t, l, -- int, f, -- const struct kernel_sockaddr*, a, int, t) -- LSS_INLINE _syscall2(int, shutdown, int, s, -- int, h) -- LSS_INLINE _syscall3(int, socket, int, d, -- int, t, int, p) -- LSS_INLINE _syscall4(int, socketpair, int, d, -- int, t, int, p, int*, s) -- #endif - #if defined(__NR_fadvise64) - #if defined(__x86_64__) - /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ -@@ -3685,6 +3862,12 @@ struct kernel_statfs { - const char *, p, - struct kernel_stat*, b, int, f) - #endif -+ #if defined(__NR_statx) -+ LSS_INLINE _syscall5(int, statx, int, d, -+ const char *, p, -+ int, f, int, m, -+ struct kernel_statx*, b) -+ #endif - #if defined(__x86_64__) || defined(__s390x__) - LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, - gid_t *egid, -@@ -4181,23 +4364,30 @@ struct kernel_statfs { - LSS_SC_BODY(4, int, 8, d, type, protocol, sv); - } - #endif -- #if defined(__ARM_EABI__) || defined (__aarch64__) -+ #if defined(__NR_recvmsg) - LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, - int, flags) -+ #endif -+ #if defined(__NR_sendmsg) - LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, - msg, int, flags) -+ #endif -+ #if defined(__NR_sendto) - LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, - int, flags, const struct kernel_sockaddr*, to, - unsigned int, tolen) -+ #endif -+ #if defined(__NR_shutdown) - LSS_INLINE _syscall2(int, shutdown, int, s, int, how) -+ #endif -+ #if defined(__NR_socket) - LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) -+ #endif -+ #if defined(__NR_socketpair) - LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, - int*, sv) - #endif -- #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ -- (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ -- defined(__s390__) -- #define __NR__socketcall __NR_socketcall -+ #if defined(__NR_socketcall) - LSS_INLINE _syscall2(int, _socketcall, int, c, - va_list, a) - LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { -@@ -4209,37 +4399,49 @@ struct kernel_statfs { - return rc; - } - -+ #if !defined(__NR_recvmsg) - LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, - int flags){ - return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); - } -+ #endif - -+ #if !defined(__NR_sendmsg) - LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, - const struct kernel_msghdr *msg, - int flags) { - return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); - } -+ #endif - -+ #if !defined(__NR_sendto) - LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, - int flags, - const struct kernel_sockaddr *to, - unsigned int tolen) { - return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); - } -+ #endif - -+ #if !defined(__NR_shutdown) - LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { - return LSS_NAME(socketcall)(13, s, how); - } -+ #endif - -+ #if !defined(__NR_socket) - LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { - return LSS_NAME(socketcall)(1, domain, type, protocol); - } -+ #endif - -+ #if !defined(__NR_socketpair) - LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, - int sv[2]) { - return LSS_NAME(socketcall)(8, d, type, protocol, sv); - } -- #endif -+ #endif -+ #endif // defined(__NR_socketcall) - #if defined(__NR_fstatat64) - LSS_INLINE _syscall4(int, fstatat64, int, d, - const char *, p, -@@ -4486,10 +4688,64 @@ struct kernel_statfs { - } - #endif - -+#if defined(__NR_statx) -+ /* copy the contents of kernel_statx to the kernel_stat structure. */ -+ LSS_INLINE void LSS_NAME(cp_stat_statx)(struct kernel_stat *to, -+ struct kernel_statx *from) { -+ memset(to, 0, sizeof(struct kernel_stat)); -+ to->st_dev = (unsigned long)((from->stx_dev_minor & 0xff) | -+ ((from->stx_dev_major & 0xfff) << 8) | -+ ((from->stx_dev_minor & ~0xffu) << 12)); -+ to->st_rdev = (unsigned long)((from->stx_rdev_minor & 0xff) | -+ ((from->stx_rdev_major & 0xfff) << 8) | -+ ((from->stx_rdev_minor & ~0xffu) << 12)); -+ to->st_ino = (unsigned long)from->stx_ino; -+ to->st_mode = (unsigned int)from->stx_mode; -+ to->st_nlink = (unsigned int)from->stx_nlink; -+ to->st_uid = (unsigned int)from->stx_uid; -+ to->st_gid = (unsigned int)from->stx_gid; -+ to->st_atime_ = (long)(from->stx_atime.tv_sec); -+ to->st_atime_nsec_ = from->stx_atime.tv_nsec; -+ to->st_mtime_ = (long)(from->stx_mtime.tv_sec); -+ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; -+ to->st_ctime_ = (long)(from->stx_ctime.tv_sec); -+ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; -+ to->st_size = (long)(from->stx_size); -+ to->st_blocks = (int)(from->stx_blocks); -+ to->st_blksize = (int)from->stx_blksize; -+ } -+#endif -+ -+#if !defined(__NR_fstat) -+ LSS_INLINE int LSS_NAME(fstat)(int fd, -+ struct kernel_stat *buf) { -+ #if defined(__NR_newfstatat) -+ return LSS_NAME(newfstatat)(fd, "", buf, AT_EMPTY_PATH); -+ #elif defined(__NR_statx) -+ struct kernel_statx stx; -+ int flags = AT_NO_AUTOMOUNT | AT_EMPTY_PATH; -+ int mask = STATX_BASIC_STATS; -+ int res = LSS_NAME(statx)(fd, "", flags, mask, &stx); -+ LSS_NAME(cp_stat_statx)(buf, &stx); -+ return res; -+ #endif -+ } -+#endif -+ -+ - #if !defined(__NR_stat) - LSS_INLINE int LSS_NAME(stat)(const char *pathname, - struct kernel_stat *buf) { -+ #if defined(__NR_newfstatat) - return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, 0); -+ #elif defined(__NR_statx) -+ struct kernel_statx stx; -+ int flags = AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT; -+ int mask = STATX_BASIC_STATS; -+ int res = LSS_NAME(statx)(AT_FDCWD, pathname, flags, mask, &stx); -+ LSS_NAME(cp_stat_statx)(buf, &stx); -+ return res; -+ #endif - } - #endif - -@@ -4503,7 +4759,7 @@ struct kernel_statfs { - // TODO: define this in an arch-independant way instead of inlining the clone - // syscall body. - --# if defined(__aarch64__) -+# if defined(__aarch64__) || defined(__loongarch64) - LSS_INLINE pid_t LSS_NAME(fork)(void) { - // No fork syscall on aarch64 - implement by means of the clone syscall. - // Note that this does not reset glibc's cached view of the PID/TID, so -diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h -index fdc65ac47..7e274a3bc 100644 ---- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h -+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h -@@ -48,7 +48,7 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { - // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice - // here. - return 16; // 64kB --#elif defined(_MIPS_ARCH_LOONGSON) -+#elif defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) - return 14; // 16kB - #else - return 12; // 4kB -diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h -index 71d63ba41..e4342dcbb 100644 ---- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h -+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h -@@ -40,7 +40,7 @@ static const size_t kBucketShift = (kAllocationGranularity == 8) ? 3 : 2; - // other constant values, we pack _all_ `PartitionRootGeneric::Alloc` sizes - // perfectly up against the end of a system page. - --#if defined(_MIPS_ARCH_LOONGSON) -+#if defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) - PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int - PartitionPageShift() { - return 16; // 64 KiB -diff --git a/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn b/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn -index 70e14c06f..8f0cb668e 100644 ---- a/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn -@@ -149,6 +149,8 @@ swiftshader_llvm_source_set("swiftshader_llvm") { - deps += [ ":swiftshader_llvm_ppc" ] - } else if (current_cpu == "x86" || current_cpu == "x64") { - deps += [ ":swiftshader_llvm_x86" ] -+ } else if (current_cpu == "loongarch64") { -+ # Do Nothing - } else { - assert(false, "Unsupported current_cpu") - } -diff --git a/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc b/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc -index 4f0c5430c..db0bdbba1 100644 ---- a/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc -+++ b/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc -@@ -30,7 +30,8 @@ bool VectorDifference(const uint8_t* image1, const uint8_t* image2) { - static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr; - - if (!diff_proc) { --#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) -+#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || \ -+ defined(WEBRTC_ARCH_LOONGARCH_FAMILY) - // For ARM and MIPS processors, always use C version. - // TODO(hclam): Implement a NEON version. - diff_proc = &VectorDifference_C; -diff --git a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h -index ed216e660..0352b4888 100644 ---- a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h -+++ b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h -@@ -50,6 +50,10 @@ - #elif defined(__EMSCRIPTEN__) - #define WEBRTC_ARCH_32_BITS - #define WEBRTC_ARCH_LITTLE_ENDIAN -+#elif defined(__loongarch64) -+#define WEBRTC_ARCH_LOONGARCH_FAMILY -+#define WEBRTC_ARCH_64_BITS -+#define WEBRTC_ARCH_LITTLE_ENDIAN - #else - #error Please add support for your architecture in rtc_base/system/arch.h - #endif -diff --git a/src/3rdparty/chromium/v8/BUILD.gn b/src/3rdparty/chromium/v8/BUILD.gn -index ba99c7514..06f596ecf 100644 ---- a/src/3rdparty/chromium/v8/BUILD.gn -+++ b/src/3rdparty/chromium/v8/BUILD.gn -@@ -794,6 +794,16 @@ config("toolchain") { - cflags += [ "-march=z196" ] - } - } -+ -+ # loongarch64 simulators. -+ if (target_is_simulator && v8_current_cpu == "loongarch64") { -+ defines += [ "_LOONGARCH64_TARGET_SIMULATOR" ] -+ } -+ -+ if (v8_current_cpu == "loongarch64") { -+ defines += [ "V8_TARGET_ARCH_LOONGARCH64" ] -+ } -+ - if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { - if (v8_current_cpu == "ppc") { - defines += [ "V8_TARGET_ARCH_PPC" ] -@@ -1873,6 +1883,11 @@ v8_source_set("v8_initializers") { - ### gcmole(arch:mips64el) ### - "src/builtins/mips64/builtins-mips64.cc", - ] -+ } else if (v8_current_cpu == "loongarch64") { -+ sources += [ -+ ### gcmole(arch:loongarch64) ### -+ "src/builtins/loongarch64/builtins-loongarch64.cc", -+ ] - } else if (v8_current_cpu == "ppc") { - sources += [ - ### gcmole(arch:ppc) ### -@@ -3672,6 +3687,33 @@ v8_source_set("v8_base_without_compiler") { - "src/regexp/mips64/regexp-macro-assembler-mips64.h", - "src/wasm/baseline/mips64/liftoff-assembler-mips64.h", - ] -+ } else if (v8_current_cpu == "loongarch64") { -+ sources += [ ### gcmole(arch:loongarch64) ### -+ "src/codegen/loongarch64/assembler-loongarch64-inl.h", -+ "src/codegen/loongarch64/assembler-loongarch64.cc", -+ "src/codegen/loongarch64/assembler-loongarch64.h", -+ "src/codegen/loongarch64/constants-loongarch64.cc", -+ "src/codegen/loongarch64/constants-loongarch64.h", -+ "src/codegen/loongarch64/cpu-loongarch64.cc", -+ "src/codegen/loongarch64/interface-descriptors-loongarch64.cc", -+ "src/codegen/loongarch64/macro-assembler-loongarch64.cc", -+ "src/codegen/loongarch64/macro-assembler-loongarch64.h", -+ "src/codegen/loongarch64/register-loongarch64.h", -+ "src/compiler/backend/loongarch64/code-generator-loongarch64.cc", -+ "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h", -+ "src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc", -+ "src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc", -+ "src/debug/loongarch64/debug-loongarch64.cc", -+ "src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc", -+ "src/diagnostics/loongarch64/disasm-loongarch64.cc", -+ "src/execution/loongarch64/frame-constants-loongarch64.cc", -+ "src/execution/loongarch64/frame-constants-loongarch64.h", -+ "src/execution/loongarch64/simulator-loongarch64.cc", -+ "src/execution/loongarch64/simulator-loongarch64.h", -+ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc", -+ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h", -+ "src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h", -+ ] - } else if (v8_current_cpu == "ppc") { - sources += [ ### gcmole(arch:ppc) ### - "src/codegen/ppc/assembler-ppc-inl.h", -@@ -4328,6 +4370,8 @@ v8_source_set("v8_cppgc_shared") { - sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ] - } else if (current_cpu == "mips64el") { - sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ] -+ } else if (current_cpu == "loongarch64") { -+ sources += [ "src/heap/base/asm/loongarch64/push_registers_asm.cc" ] - } - } else if (is_win) { - if (current_cpu == "x64") { -diff --git a/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni b/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni -index 5e444efcf..5e51df482 100644 ---- a/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni -+++ b/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni -@@ -79,7 +79,8 @@ if (v8_snapshot_toolchain == "") { - - if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { - _cpus = v8_current_cpu -- } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { -+ } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || -+ v8_current_cpu == "loongarch64") { - if (is_win && v8_current_cpu == "arm64") { - # set _cpus to blank for Windows ARM64 so host_toolchain could be - # selected as snapshot toolchain later. -diff --git a/src/3rdparty/chromium/v8/src/base/build_config.h b/src/3rdparty/chromium/v8/src/base/build_config.h -index c3a3849f7..b34e69e9b 100644 ---- a/src/3rdparty/chromium/v8/src/base/build_config.h -+++ b/src/3rdparty/chromium/v8/src/base/build_config.h -@@ -46,6 +46,13 @@ - #else - #define V8_HOST_ARCH_32_BIT 1 - #endif -+#elif defined(__loongarch__) -+#if defined(__loongarch_lp64) -+#define V8_HOST_ARCH_LOONGARCH64 1 -+#define V8_HOST_ARCH_64_BIT 1 -+#else -+#error "Only lp64 been supported by v8" -+#endif - #else - #error "Host architecture was not detected as supported by v8" - #endif -@@ -77,7 +84,8 @@ - // environment as presented by the compiler. - #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ - !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ -- !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 -+ !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ -+ !V8_TARGET_ARCH_LOONGARCH64 - #if defined(_M_X64) || defined(__x86_64__) - #define V8_TARGET_ARCH_X64 1 - #elif defined(_M_IX86) || defined(__i386__) -@@ -94,6 +102,8 @@ - #define V8_TARGET_ARCH_PPC64 1 - #elif defined(_ARCH_PPC) - #define V8_TARGET_ARCH_PPC 1 -+#elif defined(__loongarch_lp64) -+#define V8_TARGET_ARCH_LOONGARCH64 1 - #else - #error Target architecture was not detected as supported by v8 - #endif -@@ -128,6 +138,8 @@ - #else - #define V8_TARGET_ARCH_32_BIT 1 - #endif -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#define V8_TARGET_ARCH_64_BIT 1 - #else - #error Unknown target architecture pointer size - #endif -@@ -156,6 +168,9 @@ - #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) - #error Target architecture mips64 is only supported on mips64 and x64 host - #endif -+#if (V8_TARGET_ARCH_LOONGARCH64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_LOONGARCH64)) -+#error Target architecture loongarch64 is only supported on loongarch64 and x64 host -+#endif - - // Determine architecture endianness. - #if V8_TARGET_ARCH_IA32 -@@ -190,6 +205,8 @@ - #else - #define V8_TARGET_BIG_ENDIAN 1 - #endif -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#define V8_TARGET_LITTLE_ENDIAN 1 - #else - #error Unknown target architecture endianness - #endif -diff --git a/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc b/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc -index 89173b593..13ec3a436 100644 ---- a/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc -+++ b/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc -@@ -324,6 +324,10 @@ void* OS::GetRandomMmapAddr() { - // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance - // to fulfill request. - raw_addr &= uint64_t{0xFFFFFF0000}; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance -+ // to fulfill request. -+ raw_addr &= uint64_t{0xFFFFFF0000}; - #else - raw_addr &= 0x3FFFF000; - -@@ -503,6 +507,8 @@ void OS::DebugBreak() { - asm("break"); - #elif V8_HOST_ARCH_MIPS64 - asm("break"); -+#elif V8_HOST_ARCH_LOONGARCH64 -+ asm("break 0"); - #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 - asm("twge 2,2"); - #elif V8_HOST_ARCH_IA32 -@@ -512,6 +518,8 @@ void OS::DebugBreak() { - #elif V8_HOST_ARCH_S390 - // Software breakpoint instruction is 0x0001 - asm volatile(".word 0x0001"); -+#elif V8_HOST_ARCH_LOONGARCH64 -+ asm("break 0"); - #else - #error Unsupported host architecture. - #endif -diff --git a/src/3rdparty/chromium/v8/src/builtins/builtins.cc b/src/3rdparty/chromium/v8/src/builtins/builtins.cc -index 31682f397..3bceeae45 100644 ---- a/src/3rdparty/chromium/v8/src/builtins/builtins.cc -+++ b/src/3rdparty/chromium/v8/src/builtins/builtins.cc -@@ -490,7 +490,7 @@ bool Builtins::CodeObjectIsExecutable(int builtin_index) { - case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit: - return true; - default: --#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - // TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE - // caused MIPS platform to crash, and we need some time to handle it. Now - // disable this change temporarily on MIPS platform. -diff --git a/src/3rdparty/chromium/v8/src/builtins/loongarch64/builtins-loongarch64.cc b/src/3rdparty/chromium/v8/src/builtins/loongarch64/builtins-loongarch64.cc -new file mode 100644 -index 000000000..9c4708b8b ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/builtins/loongarch64/builtins-loongarch64.cc -@@ -0,0 +1,3549 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/api/api-arguments.h" -+#include "src/codegen/code-factory.h" -+#include "src/debug/debug.h" -+#include "src/deoptimizer/deoptimizer.h" -+#include "src/execution/frame-constants.h" -+#include "src/execution/frames.h" -+#include "src/logging/counters.h" -+// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/macro-assembler-inl.h" -+#include "src/codegen/register-configuration.h" -+#include "src/heap/heap-inl.h" -+#include "src/objects/cell.h" -+#include "src/objects/foreign.h" -+#include "src/objects/heap-number.h" -+#include "src/objects/js-generator.h" -+#include "src/objects/objects-inl.h" -+#include "src/objects/smi.h" -+#include "src/runtime/runtime.h" -+#include "src/wasm/wasm-linkage.h" -+#include "src/wasm/wasm-objects.h" -+ -+namespace v8 { -+namespace internal { -+ -+#define __ ACCESS_MASM(masm) -+ -+void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { -+ __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), -+ RelocInfo::CODE_TARGET); -+} -+ -+static void GenerateTailCallToReturnedCode(MacroAssembler* masm, -+ Runtime::FunctionId function_id) { -+ // ----------- S t a t e ------------- -+ // -- a0 : actual argument count -+ // -- a1 : target function (preserved for callee) -+ // -- a3 : new target (preserved for callee) -+ // ----------------------------------- -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ // Push a copy of the target function, the new target and the actual -+ // argument count. -+ // Push function as parameter to the runtime call. -+ __ SmiTag(kJavaScriptCallArgCountRegister); -+ __ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister, -+ kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister); -+ -+ __ CallRuntime(function_id, 1); -+ __ Add_d(a2, a0, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ // Restore target function, new target and actual argument count. -+ __ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister, -+ kJavaScriptCallArgCountRegister); -+ __ SmiUntag(kJavaScriptCallArgCountRegister); -+ } -+ -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Jump(a2); -+} -+ -+namespace { -+ -+enum StackLimitKind { kInterruptStackLimit, kRealStackLimit }; -+ -+void LoadStackLimit(MacroAssembler* masm, Register destination, -+ StackLimitKind kind) { -+ DCHECK(masm->root_array_available()); -+ Isolate* isolate = masm->isolate(); -+ ExternalReference limit = -+ kind == StackLimitKind::kRealStackLimit -+ ? ExternalReference::address_of_real_jslimit(isolate) -+ : ExternalReference::address_of_jslimit(isolate); -+ DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); -+ -+ intptr_t offset = -+ TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); -+ CHECK(is_int32(offset)); -+ __ Ld_d(destination, MemOperand(kRootRegister, static_cast(offset))); -+} -+ -+void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : number of arguments -+ // -- a1 : constructor function -+ // -- a3 : new target -+ // -- cp : context -+ // -- ra : return address -+ // -- sp[...]: constructor arguments -+ // ----------------------------------- -+ -+ // Enter a construct frame. -+ { -+ FrameScope scope(masm, StackFrame::CONSTRUCT); -+ -+ // Preserve the incoming parameters on the stack. -+ __ SmiTag(a0); -+ __ Push(cp, a0); -+ __ SmiUntag(a0); -+ -+#ifdef V8_REVERSE_JSARGS -+ // Set up pointer to last argument (skip receiver). -+ __ Add_d( -+ t2, fp, -+ Operand(StandardFrameConstants::kCallerSPOffset + kSystemPointerSize)); -+ // Copy arguments and receiver to the expression stack. -+ __ PushArray(t2, a0, t3, t0); -+ // The receiver for the builtin/api call. -+ __ PushRoot(RootIndex::kTheHoleValue); -+#else -+ // The receiver for the builtin/api call. -+ __ PushRoot(RootIndex::kTheHoleValue); -+ // Set up pointer to last argument. -+ __ Add_d(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); -+ -+ // Copy arguments and receiver to the expression stack. -+ __ PushArray(t2, a0, t3, t0); -+#endif -+ -+ // Call the function. -+ // a0: number of arguments (untagged) -+ // a1: constructor function -+ // a3: new target -+ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); -+ -+ // Restore context from the frame. -+ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ // Restore smi-tagged arguments count from the frame. -+ __ Ld_d(t3, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ // Leave construct frame. -+ } -+ -+ // Remove caller arguments from the stack and return. -+ __ SmiScale(t3, t3, kPointerSizeLog2); -+ __ Add_d(sp, sp, t3); -+ __ Add_d(sp, sp, kPointerSize); -+ __ Ret(); -+} -+ -+static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, -+ Register scratch1, Register scratch2, -+ Label* stack_overflow) { -+ // Check the stack for overflow. We are not trying to catch -+ // interruptions (e.g. debug break and preemption) here, so the "real stack -+ // limit" is checked. -+ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); -+ // Make scratch1 the space we have left. The stack might already be overflowed -+ // here which will cause scratch1 to become negative. -+ __ sub_d(scratch1, sp, scratch1); -+ // Check if the arguments will overflow the stack. -+ __ slli_d(scratch2, num_args, kPointerSizeLog2); -+ // Signed comparison. -+ __ Branch(stack_overflow, le, scratch1, Operand(scratch2)); -+} -+ -+} // namespace -+ -+// The construct stub for ES5 constructor functions and ES6 class constructors. -+void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0: number of arguments (untagged) -+ // -- a1: constructor function -+ // -- a3: new target -+ // -- cp: context -+ // -- ra: return address -+ // -- sp[...]: constructor arguments -+ // ----------------------------------- -+ -+ // Enter a construct frame. -+ { -+ FrameScope scope(masm, StackFrame::CONSTRUCT); -+ Label post_instantiation_deopt_entry, not_create_implicit_receiver; -+ -+ // Preserve the incoming parameters on the stack. -+ __ SmiTag(a0); -+ __ Push(cp, a0, a1); -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ Push(a3); -+ -+ // ----------- S t a t e ------------- -+ // -- sp[0*kPointerSize]: new target -+ // -- sp[1*kPointerSize]: padding -+ // -- a1 and sp[2*kPointerSize]: constructor function -+ // -- sp[3*kPointerSize]: number of arguments (tagged) -+ // -- sp[4*kPointerSize]: context -+ // ----------------------------------- -+ -+ __ Ld_d(t2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_wu(t2, FieldMemOperand(t2, SharedFunctionInfo::kFlagsOffset)); -+ __ DecodeField(t2); -+ __ JumpIfIsInRange(t2, kDefaultDerivedConstructor, kDerivedConstructor, -+ ¬_create_implicit_receiver); -+ -+ // If not derived class constructor: Allocate the new receiver object. -+ __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1, -+ t2, t3); -+ __ Call(BUILTIN_CODE(masm->isolate(), FastNewObject), -+ RelocInfo::CODE_TARGET); -+ __ Branch(&post_instantiation_deopt_entry); -+ -+ // Else: use TheHoleValue as receiver for constructor call -+ __ bind(¬_create_implicit_receiver); -+ __ LoadRoot(a0, RootIndex::kTheHoleValue); -+ -+ // ----------- S t a t e ------------- -+ // -- a0: receiver -+ // -- Slot 4 / sp[0*kPointerSize]: new target -+ // -- Slot 3 / sp[1*kPointerSize]: padding -+ // -- Slot 2 / sp[2*kPointerSize]: constructor function -+ // -- Slot 1 / sp[3*kPointerSize]: number of arguments (tagged) -+ // -- Slot 0 / sp[4*kPointerSize]: context -+ // ----------------------------------- -+ // Deoptimizer enters here. -+ masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( -+ masm->pc_offset()); -+ __ bind(&post_instantiation_deopt_entry); -+ -+ // Restore new target. -+ __ Pop(a3); -+ -+#ifdef V8_REVERSE_JSARGS -+ // Push the allocated receiver to the stack. -+ __ Push(a0); -+ -+ // We need two copies because we may have to return the original one -+ // and the calling conventions dictate that the called function pops the -+ // receiver. The second copy is pushed after the arguments, we saved in a6 -+ // since a0 will store the return value of callRuntime. -+ __ mov(a6, a0); -+ -+ // Set up pointer to last argument. -+ __ Add_d( -+ t2, fp, -+ Operand(StandardFrameConstants::kCallerSPOffset + kSystemPointerSize)); -+#else -+ // Push the allocated receiver to the stack. We need two copies -+ // because we may have to return the original one and the calling -+ // conventions dictate that the called function pops the receiver. -+ __ Push(a0, a0); -+ -+ // Set up pointer to last argument. -+ __ Add_d(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); -+#endif -+ -+ // ----------- S t a t e ------------- -+ // -- r3: new target -+ // -- sp[0*kPointerSize]: implicit receiver -+ // -- sp[1*kPointerSize]: implicit receiver -+ // -- sp[2*kPointerSize]: padding -+ // -- sp[3*kPointerSize]: constructor function -+ // -- sp[4*kPointerSize]: number of arguments (tagged) -+ // -- sp[5*kPointerSize]: context -+ // ----------------------------------- -+ -+ // Restore constructor function and argument count. -+ __ Ld_d(a1, MemOperand(fp, ConstructFrameConstants::kConstructorOffset)); -+ __ Ld_d(a0, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ __ SmiUntag(a0); -+ -+ Label enough_stack_space, stack_overflow; -+ Generate_StackOverflowCheck(masm, a0, t0, t1, &stack_overflow); -+ __ Branch(&enough_stack_space); -+ -+ __ bind(&stack_overflow); -+ // Restore the context from the frame. -+ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ -+ __ bind(&enough_stack_space); -+ -+ // Copy arguments and receiver to the expression stack. -+ __ PushArray(t2, a0, t0, t1); -+#ifdef V8_REVERSE_JSARGS -+ // We need two copies because we may have to return the original one -+ // and the calling conventions dictate that the called function pops the -+ // receiver. The second copy is pushed after the arguments, -+ __ Push(a6); -+#endif -+ -+ // Call the function. -+ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); -+ -+ // ----------- S t a t e ------------- -+ // -- a0: constructor result -+ // -- sp[0*kPointerSize]: implicit receiver -+ // -- sp[1*kPointerSize]: padding -+ // -- sp[2*kPointerSize]: constructor function -+ // -- sp[3*kPointerSize]: number of arguments -+ // -- sp[4*kPointerSize]: context -+ // ----------------------------------- -+ -+ // Store offset of return address for deoptimizer. -+ masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( -+ masm->pc_offset()); -+ -+ // Restore the context from the frame. -+ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ -+ // If the result is an object (in the ECMA sense), we should get rid -+ // of the receiver and use the result; see ECMA-262 section 13.2.2-7 -+ // on page 74. -+ Label use_receiver, do_throw, leave_frame; -+ -+ // If the result is undefined, we jump out to using the implicit receiver. -+ __ JumpIfRoot(a0, RootIndex::kUndefinedValue, &use_receiver); -+ -+ // Otherwise we do a smi check and fall through to check if the return value -+ // is a valid receiver. -+ -+ // If the result is a smi, it is *not* an object in the ECMA sense. -+ __ JumpIfSmi(a0, &use_receiver); -+ -+ // If the type of the result (stored in its map) is less than -+ // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. -+ __ GetObjectType(a0, t2, t2); -+ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); -+ __ Branch(&leave_frame, greater_equal, t2, Operand(FIRST_JS_RECEIVER_TYPE)); -+ __ Branch(&use_receiver); -+ -+ __ bind(&do_throw); -+ __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); -+ -+ // Throw away the result of the constructor invocation and use the -+ // on-stack receiver as the result. -+ __ bind(&use_receiver); -+ __ Ld_d(a0, MemOperand(sp, 0 * kPointerSize)); -+ __ JumpIfRoot(a0, RootIndex::kTheHoleValue, &do_throw); -+ -+ __ bind(&leave_frame); -+ // Restore smi-tagged arguments count from the frame. -+ __ Ld_d(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ // Leave construct frame. -+ } -+ // Remove caller arguments from the stack and return. -+ __ SmiScale(a4, a1, kPointerSizeLog2); -+ __ Add_d(sp, sp, a4); -+ __ Add_d(sp, sp, kPointerSize); -+ __ Ret(); -+} -+ -+void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { -+ Generate_JSBuiltinsConstructStubHelper(masm); -+} -+ -+static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, -+ Register sfi_data, -+ Register scratch1) { -+ Label done; -+ -+ __ GetObjectType(sfi_data, scratch1, scratch1); -+ __ Branch(&done, ne, scratch1, Operand(INTERPRETER_DATA_TYPE)); -+ __ Ld_d(sfi_data, -+ FieldMemOperand(sfi_data, InterpreterData::kBytecodeArrayOffset)); -+ -+ __ bind(&done); -+} -+ -+// static -+void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the value to pass to the generator -+ // -- a1 : the JSGeneratorObject to resume -+ // -- ra : return address -+ // ----------------------------------- -+ __ AssertGeneratorObject(a1); -+ -+ // Store input value into generator object. -+ __ St_d(a0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); -+ __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, a0, a3, -+ kRAHasNotBeenSaved, kDontSaveFPRegs); -+ -+ // Load suspended function and context. -+ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Ld_d(cp, FieldMemOperand(a4, JSFunction::kContextOffset)); -+ -+ // Flood function if we are stepping. -+ Label prepare_step_in_if_stepping, prepare_step_in_suspended_generator; -+ Label stepping_prepared; -+ ExternalReference debug_hook = -+ ExternalReference::debug_hook_on_function_call_address(masm->isolate()); -+ __ li(a5, debug_hook); -+ __ Ld_b(a5, MemOperand(a5, 0)); -+ __ Branch(&prepare_step_in_if_stepping, ne, a5, Operand(zero_reg)); -+ -+ // Flood function if we need to continue stepping in the suspended generator. -+ ExternalReference debug_suspended_generator = -+ ExternalReference::debug_suspended_generator_address(masm->isolate()); -+ __ li(a5, debug_suspended_generator); -+ __ Ld_d(a5, MemOperand(a5, 0)); -+ __ Branch(&prepare_step_in_suspended_generator, eq, a1, Operand(a5)); -+ __ bind(&stepping_prepared); -+ -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ Label stack_overflow; -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&stack_overflow, lo, sp, Operand(kScratchReg)); -+ -+#ifndef V8_REVERSE_JSARGS -+ // Push receiver. -+ __ Ld_d(a5, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); -+ __ Push(a5); -+#endif -+ -+ // ----------- S t a t e ------------- -+ // -- a1 : the JSGeneratorObject to resume -+ // -- a4 : generator function -+ // -- cp : generator context -+ // -- ra : return address -+ // -- sp[0] : generator receiver -+ // ----------------------------------- -+ -+ // Push holes for arguments to generator function. Since the parser forced -+ // context allocation for any variables in generators, the actual argument -+ // values have already been copied into the context and these dummy values -+ // will never be used. -+ __ Ld_d(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_hu( -+ a3, FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ Ld_d(t1, FieldMemOperand( -+ a1, JSGeneratorObject::kParametersAndRegistersOffset)); -+ { -+#ifdef V8_REVERSE_JSARGS -+ Label done_loop, loop; -+ __ bind(&loop); -+ __ Sub_d(a3, a3, Operand(1)); -+ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); -+ __ Alsl_d(kScratchReg, a3, t1, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); -+ __ Push(kScratchReg); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ // Push receiver. -+ __ Ld_d(kScratchReg, -+ FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); -+ __ Push(kScratchReg); -+#else -+ Label done_loop, loop; -+ __ Move(t2, zero_reg); -+ __ bind(&loop); -+ __ Sub_d(a3, a3, Operand(1)); -+ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); -+ __ Alsl_d(kScratchReg, t2, t1, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); -+ __ Push(kScratchReg); -+ __ Add_d(t2, t2, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+#endif -+ } -+ -+ // Underlying function needs to have bytecode available. -+ if (FLAG_debug_code) { -+ __ Ld_d(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_d(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); -+ GetSharedFunctionInfoBytecode(masm, a3, t5); -+ __ GetObjectType(a3, a3, a3); -+ __ Assert(eq, AbortReason::kMissingBytecodeArray, a3, -+ Operand(BYTECODE_ARRAY_TYPE)); -+ } -+ -+ // Resume (Ignition/TurboFan) generator object. -+ { -+ __ Ld_d(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_hu(a0, FieldMemOperand( -+ a0, SharedFunctionInfo::kFormalParameterCountOffset)); -+ // We abuse new.target both to indicate that this is a resume call and to -+ // pass in the generator object. In ordinary calls, new.target is always -+ // undefined because generator functions are non-constructable. -+ __ Move(a3, a1); -+ __ Move(a1, a4); -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ } -+ -+ __ bind(&prepare_step_in_if_stepping); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1, a4); -+ // Push hole as receiver since we do not use it for stepping. -+ __ PushRoot(RootIndex::kTheHoleValue); -+ __ CallRuntime(Runtime::kDebugOnFunctionCall); -+ __ Pop(a1); -+ } -+ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Branch(&stepping_prepared); -+ -+ __ bind(&prepare_step_in_suspended_generator); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kDebugPrepareStepInSuspendedGenerator); -+ __ Pop(a1); -+ } -+ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Branch(&stepping_prepared); -+ -+ __ bind(&stack_overflow); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ __ break_(0xCC); // This should be unreachable. -+ } -+} -+ -+void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowConstructedNonConstructable); -+} -+ -+// Clobbers scratch1 and scratch2; preserves all other registers. -+static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, -+ Register scratch1, Register scratch2) { -+ // Check the stack for overflow. We are not trying to catch -+ // interruptions (e.g. debug break and preemption) here, so the "real stack -+ // limit" is checked. -+ Label okay; -+ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); -+ // Make a2 the space we have left. The stack might already be overflowed -+ // here which will cause r2 to become negative. -+ __ sub_d(scratch1, sp, scratch1); -+ // Check if the arguments will overflow the stack. -+ __ slli_d(scratch2, argc, kPointerSizeLog2); -+ __ Branch(&okay, gt, scratch1, Operand(scratch2)); // Signed comparison. -+ -+ // Out of stack space. -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ -+ __ bind(&okay); -+} -+ -+namespace { -+ -+// Called with the native C calling convention. The corresponding function -+// signature is either: -+// -+// using JSEntryFunction = GeneratedCode; -+// or -+// using JSEntryFunction = GeneratedCode; -+void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, -+ Builtins::Name entry_trampoline) { -+ Label invoke, handler_entry, exit; -+ -+ { -+ NoRootArrayScope no_root_array(masm); -+ -+ // TODO(plind): unify the ABI description here. -+ // Registers: -+ // either -+ // a0: root register value -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a0: root register value -+ // a1: microtask_queue -+ // -+ // Stack: -+ // 0 arg slots on mips64 (4 args slots on mips) -+ -+ // Save callee saved registers on the stack. -+ __ MultiPush(kCalleeSaved | ra.bit()); -+ -+ // Save callee-saved FPU registers. -+ __ MultiPushFPU(kCalleeSavedFPU); -+ // Set up the reserved register for 0.0. -+ __ Move(kDoubleRegZero, 0.0); -+ -+ // Initialize the root register. -+ // C calling convention. The first argument is passed in a0. -+ __ mov(kRootRegister, a0); -+ } -+ -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ -+ // We build an EntryFrame. -+ __ li(s1, Operand(-1)); // Push a bad frame pointer to fail if it is used. -+ __ li(s2, Operand(StackFrame::TypeToMarker(type))); -+ __ li(s3, Operand(StackFrame::TypeToMarker(type))); -+ ExternalReference c_entry_fp = ExternalReference::Create( -+ IsolateAddressId::kCEntryFPAddress, masm->isolate()); -+ __ li(s4, c_entry_fp); -+ __ Ld_d(s4, MemOperand(s4, 0)); -+ __ Push(s1, s2, s3, s4); -+ // Set up frame pointer for the frame to be pushed. -+ __ addi_d(fp, sp, -EntryFrameConstants::kCallerFPOffset); -+ -+ // Registers: -+ // either -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a1: microtask_queue -+ // -+ // Stack: -+ // caller fp | -+ // function slot | entry frame -+ // context slot | -+ // bad fp (0xFF...F) | -+ // callee saved registers + ra -+ // [ O32: 4 args slots] -+ // args -+ -+ // If this is the outermost JS call, set js_entry_sp value. -+ Label non_outermost_js; -+ ExternalReference js_entry_sp = ExternalReference::Create( -+ IsolateAddressId::kJSEntrySPAddress, masm->isolate()); -+ __ li(s1, js_entry_sp); -+ __ Ld_d(s2, MemOperand(s1, 0)); -+ __ Branch(&non_outermost_js, ne, s2, Operand(zero_reg)); -+ __ St_d(fp, MemOperand(s1, 0)); -+ __ li(s3, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); -+ Label cont; -+ __ b(&cont); -+ __ nop(); // Branch delay slot nop. -+ __ bind(&non_outermost_js); -+ __ li(s3, Operand(StackFrame::INNER_JSENTRY_FRAME)); -+ __ bind(&cont); -+ __ push(s3); -+ -+ // Jump to a faked try block that does the invoke, with a faked catch -+ // block that sets the pending exception. -+ __ jmp(&invoke); -+ __ bind(&handler_entry); -+ -+ // Store the current pc as the handler offset. It's used later to create the -+ // handler table. -+ masm->isolate()->builtins()->SetJSEntryHandlerOffset(handler_entry.pos()); -+ -+ // Caught exception: Store result (exception) in the pending exception -+ // field in the JSEnv and return a failure sentinel. Coming in here the -+ // fp will be invalid because the PushStackHandler below sets it to 0 to -+ // signal the existence of the JSEntry frame. -+ __ li(s1, ExternalReference::Create( -+ IsolateAddressId::kPendingExceptionAddress, masm->isolate())); -+ __ St_d(a0, -+ MemOperand(s1, 0)); // We come back from 'invoke'. result is in a0. -+ __ LoadRoot(a0, RootIndex::kException); -+ __ b(&exit); // b exposes branch delay slot. -+ __ nop(); // Branch delay slot nop. -+ -+ // Invoke: Link this frame into the handler chain. -+ __ bind(&invoke); -+ __ PushStackHandler(); -+ // If an exception not caught by another handler occurs, this handler -+ // returns control to the code after the bal(&invoke) above, which -+ // restores all kCalleeSaved registers (including cp and fp) to their -+ // saved values before returning a failure to C. -+ // -+ // Registers: -+ // either -+ // a0: root register value -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a0: root register value -+ // a1: microtask_queue -+ // -+ // Stack: -+ // handler frame -+ // entry frame -+ // callee saved registers + ra -+ // [ O32: 4 args slots] -+ // args -+ // -+ // Invoke the function by calling through JS entry trampoline builtin and -+ // pop the faked function when we return. -+ -+ Handle trampoline_code = -+ masm->isolate()->builtins()->builtin_handle(entry_trampoline); -+ __ Call(trampoline_code, RelocInfo::CODE_TARGET); -+ -+ // Unlink this frame from the handler chain. -+ __ PopStackHandler(); -+ -+ __ bind(&exit); // a0 holds result -+ // Check if the current stack frame is marked as the outermost JS frame. -+ Label non_outermost_js_2; -+ __ pop(a5); -+ __ Branch(&non_outermost_js_2, ne, a5, -+ Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); -+ __ li(a5, js_entry_sp); -+ __ St_d(zero_reg, MemOperand(a5, 0)); -+ __ bind(&non_outermost_js_2); -+ -+ // Restore the top frame descriptors from the stack. -+ __ pop(a5); -+ __ li(a4, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, -+ masm->isolate())); -+ __ St_d(a5, MemOperand(a4, 0)); -+ -+ // Reset the stack to the callee saved registers. -+ __ addi_d(sp, sp, -EntryFrameConstants::kCallerFPOffset); -+ -+ // Restore callee-saved fpu registers. -+ __ MultiPopFPU(kCalleeSavedFPU); -+ -+ // Restore callee saved registers from the stack. -+ __ MultiPop(kCalleeSaved | ra.bit()); -+ // Return. -+ __ Jump(ra); -+} -+ -+} // namespace -+ -+void Builtins::Generate_JSEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::ENTRY, -+ Builtins::kJSEntryTrampoline); -+} -+ -+void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::CONSTRUCT_ENTRY, -+ Builtins::kJSConstructEntryTrampoline); -+} -+ -+void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::ENTRY, -+ Builtins::kRunMicrotasksTrampoline); -+} -+ -+static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, -+ bool is_construct) { -+ // ----------- S t a t e ------------- -+ // -- a1: new.target -+ // -- a2: function -+ // -- a3: receiver_pointer -+ // -- a4: argc -+ // -- a5: argv -+ // ----------------------------------- -+ -+ // Enter an internal frame. -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ -+ // Setup the context (we need to use the caller context from the isolate). -+ ExternalReference context_address = ExternalReference::Create( -+ IsolateAddressId::kContextAddress, masm->isolate()); -+ __ li(cp, context_address); -+ __ Ld_d(cp, MemOperand(cp, 0)); -+ -+ // Push the function and the receiver onto the stack. -+ __ Push(a2); -+ -+ // Check if we have enough stack space to push all arguments. -+ __ addi_d(a6, a4, 1); -+ Generate_CheckStackOverflow(masm, a6, a0, s2); -+ -+ // Copy arguments to the stack in a loop. -+ // a4: argc -+ // a5: argv, i.e. points to first arg -+#ifdef V8_REVERSE_JSARGS -+ Label loop, entry; -+ __ Alsl_d(s1, a4, a5, kPointerSizeLog2, t7); -+ __ b(&entry); -+ // s1 points past last arg. -+ __ bind(&loop); -+ __ addi_d(s1, s1, -kPointerSize); -+ __ Ld_d(s2, MemOperand(s1, 0)); // Read next parameter. -+ __ Ld_d(s2, MemOperand(s2, 0)); // Dereference handle. -+ __ push(s2); // Push parameter. -+ __ bind(&entry); -+ __ Branch(&loop, ne, a5, Operand(s1)); -+ -+ // Push the receive. -+ __ Push(a3); -+#else -+ // Push the receive. -+ __ Push(a3); -+ -+ Label loop, entry; -+ __ Alsl_d(s1, a4, a5, kPointerSizeLog2, t7); -+ __ b(&entry); -+ // s1 points past last arg. -+ __ bind(&loop); -+ __ Ld_d(s2, MemOperand(a5, 0)); // Read next parameter. -+ __ addi_d(a5, a5, kPointerSize); -+ __ Ld_d(s2, MemOperand(s2, 0)); // Dereference handle. -+ __ push(s2); // Push parameter. -+ __ bind(&entry); -+ __ Branch(&loop, ne, a5, Operand(s1)); -+ -+#endif -+ -+ // a0: argc -+ // a1: function -+ // a3: new.target -+ __ mov(a3, a1); -+ __ mov(a1, a2); -+ __ mov(a0, a4); -+ -+ // Initialize all JavaScript callee-saved registers, since they will be seen -+ // by the garbage collector as part of handlers. -+ __ LoadRoot(a4, RootIndex::kUndefinedValue); -+ __ mov(a5, a4); -+ __ mov(s1, a4); -+ __ mov(s2, a4); -+ __ mov(s3, a4); -+ __ mov(s4, a4); -+ __ mov(s5, a4); -+ // s6 holds the root address. Do not clobber. -+ // s7 is cp. Do not init. -+ -+ // Invoke the code. -+ Handle builtin = is_construct -+ ? BUILTIN_CODE(masm->isolate(), Construct) -+ : masm->isolate()->builtins()->Call(); -+ __ Call(builtin, RelocInfo::CODE_TARGET); -+ -+ // Leave internal frame. -+ } -+ __ Jump(ra); -+} -+ -+void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { -+ Generate_JSEntryTrampolineHelper(masm, false); -+} -+ -+void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { -+ Generate_JSEntryTrampolineHelper(masm, true); -+} -+ -+void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) { -+ // a1: microtask_queue -+ __ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1); -+ __ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET); -+} -+ -+static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm, -+ Register optimized_code, -+ Register closure, -+ Register scratch1, -+ Register scratch2) { -+ // Store code entry in the closure. -+ __ St_d(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset)); -+ __ mov(scratch1, optimized_code); // Write barrier clobbers scratch1 below. -+ __ RecordWriteField(closure, JSFunction::kCodeOffset, scratch1, scratch2, -+ kRAHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, -+ OMIT_SMI_CHECK); -+} -+ -+static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { -+ Register args_count = scratch; -+ -+ // Get the arguments + receiver count. -+ __ Ld_d(args_count, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Ld_w(t0, FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); -+ -+ // Leave the frame (also dropping the register file). -+ __ LeaveFrame(StackFrame::INTERPRETED); -+ -+ // Drop receiver + arguments. -+ __ Add_d(sp, sp, args_count); -+} -+ -+// Tail-call |function_id| if |smi_entry| == |marker| -+static void TailCallRuntimeIfMarkerEquals(MacroAssembler* masm, -+ Register smi_entry, -+ OptimizationMarker marker, -+ Runtime::FunctionId function_id) { -+ Label no_match; -+ __ Branch(&no_match, ne, smi_entry, Operand(Smi::FromEnum(marker))); -+ GenerateTailCallToReturnedCode(masm, function_id); -+ __ bind(&no_match); -+} -+ -+static void TailCallOptimizedCodeSlot(MacroAssembler* masm, -+ Register optimized_code_entry, -+ Register scratch1, Register scratch2) { -+ // ----------- S t a t e ------------- -+ // -- a0 : actual argument count -+ // -- a3 : new target (preserved for callee if needed, and caller) -+ // -- a1 : target function (preserved for callee if needed, and caller) -+ // ----------------------------------- -+ DCHECK(!AreAliased(optimized_code_entry, a1, a3, scratch1, scratch2)); -+ -+ Register closure = a1; -+ -+ // Check if the optimized code is marked for deopt. If it is, call the -+ // runtime to clear it. -+ Label found_deoptimized_code; -+ __ Ld_d(a5, FieldMemOperand(optimized_code_entry, -+ Code::kCodeDataContainerOffset)); -+ __ Ld_w(a5, FieldMemOperand(a5, CodeDataContainer::kKindSpecificFlagsOffset)); -+ __ And(a5, a5, Operand(1 << Code::kMarkedForDeoptimizationBit)); -+ __ Branch(&found_deoptimized_code, ne, a5, Operand(zero_reg)); -+ -+ // Optimized code is good, get it into the closure and link the closure into -+ // the optimized functions list, then tail call the optimized code. -+ // The feedback vector is no longer used, so re-use it as a scratch -+ // register. -+ ReplaceClosureCodeWithOptimizedCode(masm, optimized_code_entry, closure, -+ scratch1, scratch2); -+ -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Add_d(a2, optimized_code_entry, -+ Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ -+ // Optimized code slot contains deoptimized code, evict it and re-enter the -+ // closure's code. -+ __ bind(&found_deoptimized_code); -+ GenerateTailCallToReturnedCode(masm, Runtime::kEvictOptimizedCodeSlot); -+} -+ -+static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, -+ Register optimization_marker) { -+ // ----------- S t a t e ------------- -+ // -- a0 : actual argument count -+ // -- a3 : new target (preserved for callee if needed, and caller) -+ // -- a1 : target function (preserved for callee if needed, and caller) -+ // -- feedback vector (preserved for caller if needed) -+ // -- optimization_marker : a Smi containing a non-zero optimization marker. -+ // ----------------------------------- -+ DCHECK(!AreAliased(feedback_vector, a1, a3, optimization_marker)); -+ -+ // TODO(v8:8394): The logging of first execution will break if -+ // feedback vectors are not allocated. We need to find a different way of -+ // logging these events if required. -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kLogFirstExecution, -+ Runtime::kFunctionFirstExecution); -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kCompileOptimized, -+ Runtime::kCompileOptimized_NotConcurrent); -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kCompileOptimizedConcurrent, -+ Runtime::kCompileOptimized_Concurrent); -+ -+ // Otherwise, the marker is InOptimizationQueue, so fall through hoping -+ // that an interrupt will eventually update the slot with optimized code. -+ if (FLAG_debug_code) { -+ __ Assert(eq, AbortReason::kExpectedOptimizationSentinel, -+ optimization_marker, -+ Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); -+ } -+} -+ -+// Advance the current bytecode offset. This simulates what all bytecode -+// handlers do upon completion of the underlying operation. Will bail out to a -+// label if the bytecode (without prefix) is a return bytecode. Will not advance -+// the bytecode offset if the current bytecode is a JumpLoop, instead just -+// re-executing the JumpLoop to jump to the correct bytecode. -+static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, -+ Register bytecode_array, -+ Register bytecode_offset, -+ Register bytecode, Register scratch1, -+ Register scratch2, Register scratch3, -+ Label* if_return) { -+ Register bytecode_size_table = scratch1; -+ -+ // The bytecode offset value will be increased by one in wide and extra wide -+ // cases. In the case of having a wide or extra wide JumpLoop bytecode, we -+ // will restore the original bytecode. In order to simplify the code, we have -+ // a backup of it. -+ Register original_bytecode_offset = scratch3; -+ DCHECK(!AreAliased(bytecode_array, bytecode_offset, bytecode, -+ bytecode_size_table, original_bytecode_offset)); -+ __ Move(original_bytecode_offset, bytecode_offset); -+ __ li(bytecode_size_table, ExternalReference::bytecode_size_table_address()); -+ -+ // Check if the bytecode is a Wide or ExtraWide prefix bytecode. -+ Label process_bytecode, extra_wide; -+ STATIC_ASSERT(0 == static_cast(interpreter::Bytecode::kWide)); -+ STATIC_ASSERT(1 == static_cast(interpreter::Bytecode::kExtraWide)); -+ STATIC_ASSERT(2 == static_cast(interpreter::Bytecode::kDebugBreakWide)); -+ STATIC_ASSERT(3 == -+ static_cast(interpreter::Bytecode::kDebugBreakExtraWide)); -+ __ Branch(&process_bytecode, hi, bytecode, Operand(3)); -+ __ And(scratch2, bytecode, Operand(1)); -+ __ Branch(&extra_wide, ne, scratch2, Operand(zero_reg)); -+ -+ // Load the next bytecode and update table to the wide scaled table. -+ __ Add_d(bytecode_offset, bytecode_offset, Operand(1)); -+ __ Add_d(scratch2, bytecode_array, bytecode_offset); -+ __ Ld_bu(bytecode, MemOperand(scratch2, 0)); -+ __ Add_d(bytecode_size_table, bytecode_size_table, -+ Operand(kIntSize * interpreter::Bytecodes::kBytecodeCount)); -+ __ jmp(&process_bytecode); -+ -+ __ bind(&extra_wide); -+ // Load the next bytecode and update table to the extra wide scaled table. -+ __ Add_d(bytecode_offset, bytecode_offset, Operand(1)); -+ __ Add_d(scratch2, bytecode_array, bytecode_offset); -+ __ Ld_bu(bytecode, MemOperand(scratch2, 0)); -+ __ Add_d(bytecode_size_table, bytecode_size_table, -+ Operand(2 * kIntSize * interpreter::Bytecodes::kBytecodeCount)); -+ -+ __ bind(&process_bytecode); -+ -+// Bailout to the return label if this is a return bytecode. -+#define JUMP_IF_EQUAL(NAME) \ -+ __ Branch(if_return, eq, bytecode, \ -+ Operand(static_cast(interpreter::Bytecode::k##NAME))); -+ RETURN_BYTECODE_LIST(JUMP_IF_EQUAL) -+#undef JUMP_IF_EQUAL -+ -+ // If this is a JumpLoop, re-execute it to perform the jump to the beginning -+ // of the loop. -+ Label end, not_jump_loop; -+ __ Branch(¬_jump_loop, ne, bytecode, -+ Operand(static_cast(interpreter::Bytecode::kJumpLoop))); -+ // We need to restore the original bytecode_offset since we might have -+ // increased it to skip the wide / extra-wide prefix bytecode. -+ __ Move(bytecode_offset, original_bytecode_offset); -+ __ jmp(&end); -+ -+ __ bind(¬_jump_loop); -+ // Otherwise, load the size of the current bytecode and advance the offset. -+ __ Alsl_d(scratch2, bytecode, bytecode_size_table, 2, t7); -+ __ Ld_w(scratch2, MemOperand(scratch2, 0)); -+ __ Add_d(bytecode_offset, bytecode_offset, scratch2); -+ -+ __ bind(&end); -+} -+ -+// Generate code for entering a JS function with the interpreter. -+// On entry to the function the receiver and arguments have been pushed on the -+// stack left to right. -+// -+// The live registers are: -+// o a0 : actual argument count (not including the receiver) -+// o a1: the JS function object being called. -+// o a3: the incoming new target or generator object -+// o cp: our context -+// o fp: the caller's frame pointer -+// o sp: stack pointer -+// o ra: return address -+// -+// The function builds an interpreter frame. See InterpreterFrameConstants in -+// frames.h for its layout. -+void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { -+ Register closure = a1; -+ Register feedback_vector = a2; -+ -+ // Get the bytecode array from the function object and load it into -+ // kInterpreterBytecodeArrayRegister. -+ __ Ld_d(kScratchReg, -+ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_d( -+ kInterpreterBytecodeArrayRegister, -+ FieldMemOperand(kScratchReg, SharedFunctionInfo::kFunctionDataOffset)); -+ GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, -+ kScratchReg); -+ -+ // The bytecode array could have been flushed from the shared function info, -+ // if so, call into CompileLazy. -+ Label compile_lazy; -+ __ GetObjectType(kInterpreterBytecodeArrayRegister, kScratchReg, kScratchReg); -+ __ Branch(&compile_lazy, ne, kScratchReg, Operand(BYTECODE_ARRAY_TYPE)); -+ -+ // Load the feedback vector from the closure. -+ __ Ld_d(feedback_vector, -+ FieldMemOperand(closure, JSFunction::kFeedbackCellOffset)); -+ __ Ld_d(feedback_vector, -+ FieldMemOperand(feedback_vector, Cell::kValueOffset)); -+ -+ Label push_stack_frame; -+ // Check if feedback vector is valid. If valid, check for optimized code -+ // and update invocation count. Otherwise, setup the stack frame. -+ __ Ld_d(a4, FieldMemOperand(feedback_vector, HeapObject::kMapOffset)); -+ __ Ld_hu(a4, FieldMemOperand(a4, Map::kInstanceTypeOffset)); -+ __ Branch(&push_stack_frame, ne, a4, Operand(FEEDBACK_VECTOR_TYPE)); -+ -+ // Read off the optimized code slot in the feedback vector, and if there -+ // is optimized code or an optimization marker, call that instead. -+ Register optimized_code_entry = a4; -+ __ Ld_d(optimized_code_entry, -+ FieldMemOperand(feedback_vector, -+ FeedbackVector::kOptimizedCodeWeakOrSmiOffset)); -+ -+ // Check if the optimized code slot is not empty. -+ Label optimized_code_slot_not_empty; -+ -+ __ Branch(&optimized_code_slot_not_empty, ne, optimized_code_entry, -+ Operand(Smi::FromEnum(OptimizationMarker::kNone))); -+ -+ Label not_optimized; -+ __ bind(¬_optimized); -+ -+ // Increment invocation count for the function. -+ __ Ld_w(a4, FieldMemOperand(feedback_vector, -+ FeedbackVector::kInvocationCountOffset)); -+ __ Add_w(a4, a4, Operand(1)); -+ __ St_w(a4, FieldMemOperand(feedback_vector, -+ FeedbackVector::kInvocationCountOffset)); -+ -+ // Open a frame scope to indicate that there is a frame on the stack. The -+ // MANUAL indicates that the scope shouldn't actually generate code to set up -+ // the frame (that is done below). -+ __ bind(&push_stack_frame); -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ PushStandardFrame(closure); -+ -+ // Reset code age and the OSR arming. The OSR field and BytecodeAgeOffset are -+ // 8-bit fields next to each other, so we could just optimize by writing a -+ // 16-bit. These static asserts guard our assumption is valid. -+ STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset == -+ BytecodeArray::kOsrNestingLevelOffset + kCharSize); -+ STATIC_ASSERT(BytecodeArray::kNoAgeBytecodeAge == 0); -+ __ St_h(zero_reg, FieldMemOperand(kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kOsrNestingLevelOffset)); -+ -+ // Load initial bytecode offset. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ -+ // Push bytecode array and Smi tagged bytecode array offset. -+ __ SmiTag(a4, kInterpreterBytecodeOffsetRegister); -+ __ Push(kInterpreterBytecodeArrayRegister, a4); -+ -+ // Allocate the local and temporary register file on the stack. -+ Label stack_overflow; -+ { -+ // Load frame size (word) from the BytecodeArray object. -+ __ Ld_w(a4, FieldMemOperand(kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kFrameSizeOffset)); -+ -+ // Do a stack check to ensure we don't go over the limit. -+ __ Sub_d(a5, sp, Operand(a4)); -+ LoadStackLimit(masm, a2, StackLimitKind::kRealStackLimit); -+ __ Branch(&stack_overflow, lo, a5, Operand(a2)); -+ -+ // If ok, push undefined as the initial value for all register file entries. -+ Label loop_header; -+ Label loop_check; -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ Branch(&loop_check); -+ __ bind(&loop_header); -+ // TODO(rmcilroy): Consider doing more than one push per loop iteration. -+ __ push(a5); -+ // Continue loop if not done. -+ __ bind(&loop_check); -+ __ Sub_d(a4, a4, Operand(kPointerSize)); -+ __ Branch(&loop_header, ge, a4, Operand(zero_reg)); -+ } -+ -+ // If the bytecode array has a valid incoming new target or generator object -+ // register, initialize it with incoming value which was passed in r3. -+ Label no_incoming_new_target_or_generator_register; -+ __ Ld_w(a5, FieldMemOperand( -+ kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kIncomingNewTargetOrGeneratorRegisterOffset)); -+ __ Branch(&no_incoming_new_target_or_generator_register, eq, a5, -+ Operand(zero_reg)); -+ __ Alsl_d(a5, a5, fp, kPointerSizeLog2, t7); -+ __ St_d(a3, MemOperand(a5, 0)); -+ __ bind(&no_incoming_new_target_or_generator_register); -+ -+ // Perform interrupt stack check. -+ // TODO(solanes): Merge with the real stack limit check above. -+ Label stack_check_interrupt, after_stack_check_interrupt; -+ LoadStackLimit(masm, a5, StackLimitKind::kInterruptStackLimit); -+ __ Branch(&stack_check_interrupt, lo, sp, Operand(a5)); -+ __ bind(&after_stack_check_interrupt); -+ -+ // Load accumulator as undefined. -+ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); -+ -+ // Load the dispatch table into a register and dispatch to the bytecode -+ // handler at the current bytecode offset. -+ Label do_dispatch; -+ __ bind(&do_dispatch); -+ __ li(kInterpreterDispatchTableRegister, -+ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); -+ __ Add_d(t5, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Ld_bu(a7, MemOperand(t5, 0)); -+ __ Alsl_d(kScratchReg, a7, kInterpreterDispatchTableRegister, -+ kPointerSizeLog2, t7); -+ __ Ld_d(kJavaScriptCallCodeStartRegister, MemOperand(kScratchReg, 0)); -+ __ Call(kJavaScriptCallCodeStartRegister); -+ masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); -+ -+ // Any returns to the entry trampoline are either due to the return bytecode -+ // or the interpreter tail calling a builtin and then a dispatch. -+ -+ // Get bytecode array and bytecode offset from the stack frame. -+ __ Ld_d(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Ld_d(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister); -+ -+ // Either return, or advance to the next bytecode and dispatch. -+ Label do_return; -+ __ Add_d(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Ld_bu(a1, MemOperand(a1, 0)); -+ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister, a1, a2, a3, -+ a4, &do_return); -+ __ jmp(&do_dispatch); -+ -+ __ bind(&do_return); -+ // The return value is in a0. -+ LeaveInterpreterFrame(masm, t0); -+ __ Jump(ra); -+ -+ __ bind(&stack_check_interrupt); -+ // Modify the bytecode offset in the stack to be kFunctionEntryBytecodeOffset -+ // for the call to the StackGuard. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(Smi::FromInt(BytecodeArray::kHeaderSize - kHeapObjectTag + -+ kFunctionEntryBytecodeOffset))); -+ __ St_d(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ CallRuntime(Runtime::kStackGuard); -+ -+ // After the call, restore the bytecode array, bytecode offset and accumulator -+ // registers again. Also, restore the bytecode offset in the stack to its -+ // previous value. -+ __ Ld_d(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); -+ -+ __ SmiTag(a5, kInterpreterBytecodeOffsetRegister); -+ __ St_d(a5, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ __ jmp(&after_stack_check_interrupt); -+ -+ __ bind(&optimized_code_slot_not_empty); -+ Label maybe_has_optimized_code; -+ // Check if optimized code marker is actually a weak reference to the -+ // optimized code as opposed to an optimization marker. -+ __ JumpIfNotSmi(optimized_code_entry, &maybe_has_optimized_code, t7); -+ MaybeOptimizeCode(masm, feedback_vector, optimized_code_entry); -+ // Fall through if there's no runnable optimized code. -+ __ jmp(¬_optimized); -+ -+ __ bind(&maybe_has_optimized_code); -+ // Load code entry from the weak reference, if it was cleared, resume -+ // execution of unoptimized code. -+ __ LoadWeakValue(optimized_code_entry, optimized_code_entry, ¬_optimized); -+ TailCallOptimizedCodeSlot(masm, optimized_code_entry, t3, a5); -+ -+ __ bind(&compile_lazy); -+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); -+ // Unreachable code. -+ __ break_(0xCC); -+ -+ __ bind(&stack_overflow); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+} -+ -+static void Generate_InterpreterPushArgs(MacroAssembler* masm, -+ Register num_args, -+ Register start_address, -+ Register scratch, Register scratch2) { -+ // Find the address of the last argument. -+ __ Sub_d(scratch, num_args, Operand(1)); -+ __ slli_d(scratch, scratch, kPointerSizeLog2); -+ __ Sub_d(start_address, start_address, scratch); -+ -+ // Push the arguments. -+#ifdef V8_REVERSE_JSARGS -+ __ PushArray(start_address, num_args, scratch, scratch2, -+ TurboAssembler::PushArrayOrder::kReverse); -+#else -+ __ PushArray(start_address, num_args, scratch, scratch2); -+#endif -+} -+ -+// static -+void Builtins::Generate_InterpreterPushArgsThenCallImpl( -+ MacroAssembler* masm, ConvertReceiverMode receiver_mode, -+ InterpreterPushArgsMode mode) { -+ DCHECK(mode != InterpreterPushArgsMode::kArrayFunction); -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a2 : the address of the first argument to be pushed. Subsequent -+ // arguments should be consecutive above this, in the same order as -+ // they are to be pushed onto the stack. -+ // -- a1 : the target to call (can be any Object). -+ // ----------------------------------- -+ Label stack_overflow; -+ -+#ifdef V8_REVERSE_JSARGS -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // The spread argument should not be pushed. -+ __ Sub_d(a0, a0, Operand(1)); -+ } -+#endif -+ -+ __ Add_d(a3, a0, Operand(1)); // Add one for receiver. -+ -+ Generate_StackOverflowCheck(masm, a3, a4, t0, &stack_overflow); -+ -+#ifdef V8_REVERSE_JSARGS -+ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { -+ // Don't copy receiver. -+ __ mov(a3, a0); -+ } -+ -+ // This function modifies a2, t0 and a4. -+ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); -+ -+ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { -+ __ PushRoot(RootIndex::kUndefinedValue); -+ } -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // Pass the spread in the register a2. -+ // a2 already points to the penultime argument, the spread -+ // is below that. -+ __ Ld_d(a2, MemOperand(a2, -kSystemPointerSize)); -+ } -+#else -+ // Push "undefined" as the receiver arg if we need to. -+ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ mov(a3, a0); -+ } -+ -+ // This function modifies a2, t0 and a4. -+ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Pop(a2); // Pass the spread in a register -+ __ Sub_d(a0, a0, Operand(1)); // Subtract one for spread -+ } -+#endif -+ -+ // Call the target. -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithSpread), -+ RelocInfo::CODE_TARGET); -+ } else { -+ __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny), -+ RelocInfo::CODE_TARGET); -+ } -+ -+ __ bind(&stack_overflow); -+ { -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ } -+} -+ -+// static -+void Builtins::Generate_InterpreterPushArgsThenConstructImpl( -+ MacroAssembler* masm, InterpreterPushArgsMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argument count (not including receiver) -+ // -- a3 : new target -+ // -- a1 : constructor to call -+ // -- a2 : allocation site feedback if available, undefined otherwise. -+ // -- a4 : address of the first argument -+ // ----------------------------------- -+ Label stack_overflow; -+ __ addi_d(a6, a0, 1); -+ Generate_StackOverflowCheck(masm, a6, a5, t0, &stack_overflow); -+ -+#ifdef V8_REVERSE_JSARGS -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // The spread argument should not be pushed. -+ __ Sub_d(a0, a0, Operand(1)); -+ } -+ -+ // Push the arguments, This function modifies t0, a4 and a5. -+ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); -+ -+ // Push a slot for the receiver. -+ __ push(zero_reg); -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // Pass the spread in the register a2. -+ // a4 already points to the penultimate argument, the spread -+ // lies in the next interpreter register. -+ __ Ld_d(a2, MemOperand(a4, -kSystemPointerSize)); -+ } else { -+ __ AssertUndefinedOrAllocationSite(a2, t0); -+ } -+#else -+ // Push a slot for the receiver. -+ __ push(zero_reg); -+ -+ // This function modifies t0, a4 and a5. -+ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Pop(a2); // Pass the spread in a register -+ __ Sub_d(a0, a0, Operand(1)); // Subtract one for spread -+ } else { -+ __ AssertUndefinedOrAllocationSite(a2, t0); -+ } -+#endif -+ -+ if (mode == InterpreterPushArgsMode::kArrayFunction) { -+ __ AssertFunction(a1); -+ -+ // Tail call to the function-specific construct stub (still in the caller -+ // context at this point). -+ __ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl), -+ RelocInfo::CODE_TARGET); -+ } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // Call the constructor with a0, a1, and a3 unmodified. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithSpread), -+ RelocInfo::CODE_TARGET); -+ } else { -+ DCHECK_EQ(InterpreterPushArgsMode::kOther, mode); -+ // Call the constructor with a0, a1, and a3 unmodified. -+ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); -+ } -+ -+ __ bind(&stack_overflow); -+ { -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ } -+} -+ -+static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { -+ // Set the return address to the correct point in the interpreter entry -+ // trampoline. -+ Label builtin_trampoline, trampoline_loaded; -+ Smi interpreter_entry_return_pc_offset( -+ masm->isolate()->heap()->interpreter_entry_return_pc_offset()); -+ DCHECK_NE(interpreter_entry_return_pc_offset, Smi::zero()); -+ -+ // If the SFI function_data is an InterpreterData, the function will have a -+ // custom copy of the interpreter entry trampoline for profiling. If so, -+ // get the custom trampoline, otherwise grab the entry address of the global -+ // trampoline. -+ __ Ld_d(t0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ Ld_d(t0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_d(t0, FieldMemOperand(t0, SharedFunctionInfo::kFunctionDataOffset)); -+ __ GetObjectType(t0, kInterpreterDispatchTableRegister, -+ kInterpreterDispatchTableRegister); -+ __ Branch(&builtin_trampoline, ne, kInterpreterDispatchTableRegister, -+ Operand(INTERPRETER_DATA_TYPE)); -+ -+ __ Ld_d(t0, -+ FieldMemOperand(t0, InterpreterData::kInterpreterTrampolineOffset)); -+ __ Add_d(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Branch(&trampoline_loaded); -+ -+ __ bind(&builtin_trampoline); -+ __ li(t0, ExternalReference:: -+ address_of_interpreter_entry_trampoline_instruction_start( -+ masm->isolate())); -+ __ Ld_d(t0, MemOperand(t0, 0)); -+ -+ __ bind(&trampoline_loaded); -+ __ Add_d(ra, t0, Operand(interpreter_entry_return_pc_offset.value())); -+ -+ // Initialize the dispatch table register. -+ __ li(kInterpreterDispatchTableRegister, -+ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); -+ -+ // Get the bytecode array pointer from the frame. -+ __ Ld_d(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ -+ if (FLAG_debug_code) { -+ // Check function data field is actually a BytecodeArray object. -+ __ SmiTst(kInterpreterBytecodeArrayRegister, kScratchReg); -+ __ Assert(ne, -+ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, -+ kScratchReg, Operand(zero_reg)); -+ __ GetObjectType(kInterpreterBytecodeArrayRegister, a1, a1); -+ __ Assert(eq, -+ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, -+ a1, Operand(BYTECODE_ARRAY_TYPE)); -+ } -+ -+ // Get the target bytecode offset from the frame. -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ if (FLAG_debug_code) { -+ Label okay; -+ __ Branch(&okay, ge, kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ // Unreachable code. -+ __ break_(0xCC); -+ __ bind(&okay); -+ } -+ -+ // Dispatch to the target bytecode. -+ __ Add_d(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Ld_bu(a7, MemOperand(a1, 0)); -+ __ Alsl_d(a1, a7, kInterpreterDispatchTableRegister, kPointerSizeLog2, t7); -+ __ Ld_d(kJavaScriptCallCodeStartRegister, MemOperand(a1, 0)); -+ __ Jump(kJavaScriptCallCodeStartRegister); -+} -+ -+void Builtins::Generate_InterpreterEnterBytecodeAdvance(MacroAssembler* masm) { -+ // Advance the current bytecode offset stored within the given interpreter -+ // stack frame. This simulates what all bytecode handlers do upon completion -+ // of the underlying operation. -+ __ Ld_d(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Ld_d(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister); -+ -+ Label enter_bytecode, function_entry_bytecode; -+ __ Branch(&function_entry_bytecode, eq, kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag + -+ kFunctionEntryBytecodeOffset)); -+ -+ // Load the current bytecode. -+ __ Add_d(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Ld_bu(a1, MemOperand(a1, 0)); -+ -+ // Advance to the next bytecode. -+ Label if_return; -+ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister, a1, a2, a3, -+ a4, &if_return); -+ -+ __ bind(&enter_bytecode); -+ // Convert new bytecode offset to a Smi and save in the stackframe. -+ __ SmiTag(a2, kInterpreterBytecodeOffsetRegister); -+ __ St_d(a2, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ Generate_InterpreterEnterBytecode(masm); -+ -+ __ bind(&function_entry_bytecode); -+ // If the code deoptimizes during the implicit function entry stack interrupt -+ // check, it will have a bailout ID of kFunctionEntryBytecodeOffset, which is -+ // not a valid bytecode offset. Detect this case and advance to the first -+ // actual bytecode. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ __ Branch(&enter_bytecode); -+ -+ // We should never take the if_return path. -+ __ bind(&if_return); -+ __ Abort(AbortReason::kInvalidBytecodeAdvance); -+} -+ -+void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { -+ Generate_InterpreterEnterBytecode(masm); -+} -+ -+namespace { -+void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, -+ bool java_script_builtin, -+ bool with_result) { -+ const RegisterConfiguration* config(RegisterConfiguration::Default()); -+ int allocatable_register_count = config->num_allocatable_general_registers(); -+ Register scratch = t8; -+ if (with_result) { -+#ifdef V8_REVERSE_JSARGS -+ if (java_script_builtin) { -+ __ mov(scratch, a0); -+ } else { -+ // Overwrite the hole inserted by the deoptimizer with the return value -+ // from the LAZY deopt point. -+ __ St_d( -+ a0, -+ MemOperand( -+ sp, config->num_allocatable_general_registers() * kPointerSize + -+ BuiltinContinuationFrameConstants::kFixedFrameSize)); -+ } -+#else -+ // Overwrite the hole inserted by the deoptimizer with the return value from -+ // the LAZY deopt point. -+ __ St_d(a0, -+ MemOperand( -+ sp, config->num_allocatable_general_registers() * kPointerSize + -+ BuiltinContinuationFrameConstants::kFixedFrameSize)); -+ USE(scratch); -+#endif -+ } -+ for (int i = allocatable_register_count - 1; i >= 0; --i) { -+ int code = config->GetAllocatableGeneralCode(i); -+ __ Pop(Register::from_code(code)); -+ if (java_script_builtin && code == kJavaScriptCallArgCountRegister.code()) { -+ __ SmiUntag(Register::from_code(code)); -+ } -+ } -+ -+#ifdef V8_REVERSE_JSARGS -+ if (with_result && java_script_builtin) { -+ // Overwrite the hole inserted by the deoptimizer with the return value from -+ // the LAZY deopt point. t0 contains the arguments count, the return value -+ // from LAZY is always the last argument. -+ __ Add_d(a0, a0, -+ Operand(BuiltinContinuationFrameConstants::kFixedSlotCount)); -+ __ Alsl_d(t0, a0, sp, kSystemPointerSizeLog2, t7); -+ __ St_d(scratch, MemOperand(t0, 0)); -+ // Recover arguments count. -+ __ Sub_d(a0, a0, -+ Operand(BuiltinContinuationFrameConstants::kFixedSlotCount)); -+ } -+#endif -+ -+ __ Ld_d( -+ fp, -+ MemOperand(sp, BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); -+ // Load builtin index (stored as a Smi) and use it to get the builtin start -+ // address from the builtins table. -+ __ Pop(t0); -+ __ Add_d(sp, sp, -+ Operand(BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); -+ __ Pop(ra); -+ __ LoadEntryFromBuiltinIndex(t0); -+ __ Jump(t0); -+} -+} // namespace -+ -+void Builtins::Generate_ContinueToCodeStubBuiltin(MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, false, false); -+} -+ -+void Builtins::Generate_ContinueToCodeStubBuiltinWithResult( -+ MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, false, true); -+} -+ -+void Builtins::Generate_ContinueToJavaScriptBuiltin(MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, true, false); -+} -+ -+void Builtins::Generate_ContinueToJavaScriptBuiltinWithResult( -+ MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, true, true); -+} -+ -+void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kNotifyDeoptimized); -+ } -+ -+ DCHECK_EQ(kInterpreterAccumulatorRegister.code(), a0.code()); -+ __ Ld_d(a0, MemOperand(sp, 0 * kPointerSize)); -+ __ Add_d(sp, sp, Operand(1 * kPointerSize)); // Remove state. -+ __ Ret(); -+} -+ -+void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kCompileForOnStackReplacement); -+ } -+ -+ // If the code object is null, just return to the caller. -+ __ Ret(eq, a0, Operand(Smi::zero())); -+ -+ // Drop the handler frame that is be sitting on top of the actual -+ // JavaScript frame. This is the case then OSR is triggered from bytecode. -+ __ LeaveFrame(StackFrame::STUB); -+ -+ // Load deoptimization data from the code object. -+ // = [#deoptimization_data_offset] -+ __ Ld_d(a1, MemOperand(a0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); -+ -+ // Load the OSR entrypoint offset from the deoptimization data. -+ // = [#header_size + #osr_pc_offset] -+ __ SmiUntag(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( -+ DeoptimizationData::kOsrPcOffsetIndex) - -+ kHeapObjectTag)); -+ -+ // Compute the target address = code_obj + header_size + osr_offset -+ // = + #header_size + -+ __ Add_d(a0, a0, a1); -+ __ addi_d(ra, a0, Code::kHeaderSize - kHeapObjectTag); -+ -+ // And "return" to the OSR entry point of the function. -+ __ Ret(); -+} -+ -+// static -+void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : argArray -+ // -- sp[4] : thisArg -+ // -- sp[8] : receiver -+ // ----------------------------------- -+ -+ Register argc = a0; -+ Register arg_array = a2; -+ Register receiver = a1; -+ Register this_arg = a5; -+ Register undefined_value = a3; -+ Register scratch = a4; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load receiver into a1, argArray into a2 (if present), remove all -+ // arguments from the stack (including the receiver), and push thisArg (if -+ // present) instead. -+ { -+ // Claim (2 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ -+#ifdef V8_REVERSE_JSARGS -+ __ mov(scratch, argc); -+ __ Ld_d(this_arg, MemOperand(sp, kPointerSize)); -+ __ Ld_d(arg_array, MemOperand(sp, 2 * kPointerSize)); -+ __ Movz(arg_array, undefined_value, scratch); // if argc == 0 -+ __ Movz(this_arg, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arg_array, undefined_value, scratch); // if argc == 1 -+ __ Ld_d(receiver, MemOperand(sp, 0)); -+ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); -+ __ St_d(this_arg, MemOperand(sp, 0)); -+#else -+ __ Sub_d(sp, sp, Operand(2 * kPointerSize)); -+ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); -+ __ mov(scratch, argc); -+ __ Pop(this_arg, arg_array); // Overwrite argc -+ __ Movz(arg_array, undefined_value, scratch); // if argc == 0 -+ __ Movz(this_arg, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arg_array, undefined_value, scratch); // if argc == 1 -+ __ Ld_d(receiver, MemOperand(sp, 0)); -+ __ St_d(this_arg, MemOperand(sp, 0)); -+#endif -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argArray -+ // -- a1 : receiver -+ // -- a3 : undefined root value -+ // -- sp[0] : thisArg -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for callable receiver here, -+ // since that's the first thing the Call/CallWithArrayLike builtins -+ // will do. -+ -+ // 3. Tail call with no arguments if argArray is null or undefined. -+ Label no_arguments; -+ __ JumpIfRoot(arg_array, RootIndex::kNullValue, &no_arguments); -+ __ Branch(&no_arguments, eq, arg_array, Operand(undefined_value)); -+ -+ // 4a. Apply the receiver to the given argArray. -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), -+ RelocInfo::CODE_TARGET); -+ -+ // 4b. The argArray is either null or undefined, so we tail call without any -+ // arguments to the receiver. -+ __ bind(&no_arguments); -+ { -+ __ mov(a0, zero_reg); -+ DCHECK(receiver == a1); -+ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); -+ } -+} -+ -+// static -+void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { -+#ifdef V8_REVERSE_JSARGS -+ // 1. Get the callable to call (passed as receiver) from the stack. -+ { __ Pop(a1); } -+ -+ // 2. Make sure we have at least one argument. -+ // a0: actual number of arguments -+ { -+ Label done; -+ __ Branch(&done, ne, a0, Operand(zero_reg)); -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ Add_d(a0, a0, Operand(1)); -+ __ bind(&done); -+ } -+ -+ // 3. Adjust the actual number of arguments. -+ __ addi_d(a0, a0, -1); -+#else -+ // 1. Make sure we have at least one argument. -+ // a0: actual number of arguments -+ { -+ Label done; -+ __ Branch(&done, ne, a0, Operand(zero_reg)); -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ Add_d(a0, a0, Operand(1)); -+ __ bind(&done); -+ } -+ -+ // 2. Get the function to call (passed as receiver) from the stack. -+ // a0: actual number of arguments -+ __ LoadReceiver(a1, a0); -+ -+ // 3. Shift arguments and return address one slot down on the stack -+ // (overwriting the original receiver). Adjust argument count to make -+ // the original first argument the new receiver. -+ // a0: actual number of arguments -+ // a1: function -+ { -+ Label loop; -+ // Calculate the copy start address (destination). Copy end address is sp. -+ __ Alsl_d(a2, a0, sp, kPointerSizeLog2, t7); -+ -+ __ bind(&loop); -+ __ Ld_d(kScratchReg, MemOperand(a2, -kPointerSize)); -+ __ St_d(kScratchReg, MemOperand(a2, 0)); -+ __ Sub_d(a2, a2, Operand(kPointerSize)); -+ __ Branch(&loop, ne, a2, Operand(sp)); -+ // Adjust the actual number of arguments and remove the top element -+ // (which is a copy of the last argument). -+ __ Sub_d(a0, a0, Operand(1)); -+ __ Pop(); -+ } -+#endif -+ -+ // 4. Call the callable. -+ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ReflectApply(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : argumentsList (if argc ==3) -+ // -- sp[4] : thisArgument (if argc >=2) -+ // -- sp[8] : target (if argc >=1) -+ // -- sp[12] : receiver -+ // ----------------------------------- -+ -+ Register argc = a0; -+ Register arguments_list = a2; -+ Register target = a1; -+ Register this_argument = a5; -+ Register undefined_value = a3; -+ Register scratch = a4; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load target into a1 (if present), argumentsList into a2 (if present), -+ // remove all arguments from the stack (including the receiver), and push -+ // thisArgument (if present) instead. -+ { -+ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ -+#ifdef V8_REVERSE_JSARGS -+ __ mov(scratch, argc); -+ __ Ld_d(target, MemOperand(sp, kPointerSize)); -+ __ Ld_d(this_argument, MemOperand(sp, 2 * kPointerSize)); -+ __ Ld_d(arguments_list, MemOperand(sp, 3 * kPointerSize)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 -+ __ Movz(this_argument, undefined_value, scratch); // if argc == 0 -+ __ Movz(target, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 -+ __ Movz(this_argument, undefined_value, scratch); // if argc == 1 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 2 -+ -+ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); -+ __ St_d(this_argument, MemOperand(sp, 0)); // Overwrite receiver -+#else -+ __ Sub_d(sp, sp, Operand(3 * kPointerSize)); -+ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); -+ __ mov(scratch, argc); -+ __ Pop(target, this_argument, arguments_list); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 -+ __ Movz(this_argument, undefined_value, scratch); // if argc == 0 -+ __ Movz(target, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 -+ __ Movz(this_argument, undefined_value, scratch); // if argc == 1 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 2 -+ -+ __ St_d(this_argument, MemOperand(sp, 0)); // Overwrite receiver -+#endif -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argumentsList -+ // -- a1 : target -+ // -- a3 : undefined root value -+ // -- sp[0] : thisArgument -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for callable target here, -+ // since that's the first thing the Call/CallWithArrayLike builtins -+ // will do. -+ -+ // 3. Apply the target to the given argumentsList. -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), -+ RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : new.target (optional) (dummy value if argc <= 2) -+ // -- sp[4] : argumentsList (dummy value if argc <= 1) -+ // -- sp[8] : target (dummy value if argc == 0) -+ // -- sp[12] : receiver -+ // ----------------------------------- -+ // NOTE: The order of args in the stack are reversed if V8_REVERSE_JSARGS -+ -+ Register argc = a0; -+ Register arguments_list = a2; -+ Register target = a1; -+ Register new_target = a3; -+ Register undefined_value = a4; -+ Register scratch = a5; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load target into a1 (if present), argumentsList into a2 (if present), -+ // new.target into a3 (if present, otherwise use target), remove all -+ // arguments from the stack (including the receiver), and push thisArgument -+ // (if present) instead. -+ { -+ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ -+#ifdef V8_REVERSE_JSARGS -+ __ mov(scratch, argc); -+ __ Ld_d(target, MemOperand(sp, kPointerSize)); -+ __ Ld_d(arguments_list, MemOperand(sp, 2 * kPointerSize)); -+ __ Ld_d(new_target, MemOperand(sp, 3 * kPointerSize)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 -+ __ Movz(new_target, undefined_value, scratch); // if argc == 0 -+ __ Movz(target, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 -+ __ Movz(new_target, target, scratch); // if argc == 1 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(new_target, target, scratch); // if argc == 2 -+ -+ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); -+ __ St_d(undefined_value, MemOperand(sp, 0)); // Overwrite receiver -+#else -+ __ Sub_d(sp, sp, Operand(3 * kPointerSize)); -+ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); -+ __ mov(scratch, argc); -+ __ Pop(target, arguments_list, new_target); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 -+ __ Movz(new_target, undefined_value, scratch); // if argc == 0 -+ __ Movz(target, undefined_value, scratch); // if argc == 0 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 -+ __ Movz(new_target, target, scratch); // if argc == 1 -+ __ Sub_d(scratch, scratch, Operand(1)); -+ __ Movz(new_target, target, scratch); // if argc == 2 -+ -+ __ St_d(undefined_value, MemOperand(sp, 0)); // Overwrite receiver -+#endif -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argumentsList -+ // -- a1 : target -+ // -- a3 : new.target -+ // -- sp[0] : receiver (undefined) -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for constructor target here, -+ // since that's the first thing the Construct/ConstructWithArrayLike -+ // builtins will do. -+ -+ // 3. We don't need to check explicitly for constructor new.target here, -+ // since that's the second thing the Construct/ConstructWithArrayLike -+ // builtins will do. -+ -+ // 4. Construct the target with the given new.target and argumentsList. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithArrayLike), -+ RelocInfo::CODE_TARGET); -+} -+ -+static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { -+ __ SmiTag(a0); -+ __ li(a4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ __ Push(ra, fp, a4, a1, a0); -+ __ Push(Smi::zero()); // Padding. -+ __ Add_d(fp, sp, -+ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp)); -+} -+ -+static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : result being passed through -+ // ----------------------------------- -+ // Get the number of arguments passed (as a smi), tear down the frame and -+ // then tear down the parameters. -+ __ Ld_d(a1, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ __ mov(sp, fp); -+ __ Pop(ra, fp); -+ __ SmiScale(a4, a1, kPointerSizeLog2); -+ __ Add_d(sp, sp, a4); -+ // Adjust for the receiver. -+ __ Add_d(sp, sp, Operand(kPointerSize)); -+} -+ -+// static -+void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, -+ Handle code) { -+ // ----------- S t a t e ------------- -+ // -- a1 : target -+ // -- a0 : number of parameters on the stack (not including the receiver) -+ // -- a2 : arguments list (a FixedArray) -+ // -- a4 : len (number of elements to push from args) -+ // -- a3 : new.target (for [[Construct]]) -+ // ----------------------------------- -+ if (masm->emit_debug_code()) { -+ // Allow a2 to be a FixedArray, or a FixedDoubleArray if a4 == 0. -+ Label ok, fail; -+ __ AssertNotSmi(a2); -+ __ GetObjectType(a2, t8, t8); -+ __ Branch(&ok, eq, t8, Operand(FIXED_ARRAY_TYPE)); -+ __ Branch(&fail, ne, t8, Operand(FIXED_DOUBLE_ARRAY_TYPE)); -+ __ Branch(&ok, eq, a4, Operand(zero_reg)); -+ // Fall through. -+ __ bind(&fail); -+ __ Abort(AbortReason::kOperandIsNotAFixedArray); -+ -+ __ bind(&ok); -+ } -+ -+ Register args = a2; -+ Register len = a4; -+ -+ // Check for stack overflow. -+ Label stack_overflow; -+ Generate_StackOverflowCheck(masm, len, kScratchReg, a5, &stack_overflow); -+ -+#ifdef V8_REVERSE_JSARGS -+ // Move the arguments already in the stack, -+ // including the receiver and the return address. -+ { -+ Label copy; -+ Register src = a6, dest = a7; -+ __ mov(src, sp); -+ __ slli_d(t0, a4, kSystemPointerSizeLog2); -+ __ Sub_d(sp, sp, Operand(t0)); -+ // Update stack pointer. -+ __ mov(dest, sp); -+ __ Add_d(t0, a0, Operand(zero_reg)); -+ -+ __ bind(©); -+ __ Ld_d(t1, MemOperand(src, 0)); -+ __ St_d(t1, MemOperand(dest, 0)); -+ __ Sub_d(t0, t0, Operand(1)); -+ __ Add_d(src, src, Operand(kSystemPointerSize)); -+ __ Add_d(dest, dest, Operand(kSystemPointerSize)); -+ __ Branch(©, ge, t0, Operand(zero_reg)); -+ } -+#endif -+ -+ // Push arguments onto the stack (thisArgument is already on the stack). -+ { -+ Label done, push, loop; -+ Register src = a6; -+ Register scratch = len; -+ -+ __ addi_d(src, args, FixedArray::kHeaderSize - kHeapObjectTag); -+ __ Add_d(a0, a0, len); // The 'len' argument for Call() or Construct(). -+ __ Branch(&done, eq, len, Operand(zero_reg)); -+ __ slli_d(scratch, len, kPointerSizeLog2); -+ __ Sub_d(scratch, sp, Operand(scratch)); -+ __ LoadRoot(t1, RootIndex::kTheHoleValue); -+ __ bind(&loop); -+ __ Ld_d(a5, MemOperand(src, 0)); -+ __ addi_d(src, src, kPointerSize); -+ __ Branch(&push, ne, a5, Operand(t1)); -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ bind(&push); -+#ifdef V8_REVERSE_JSARGS -+ __ St_d(a5, MemOperand(a7, 0)); -+ __ Add_d(a7, a7, Operand(kSystemPointerSize)); -+ __ Add_d(scratch, scratch, Operand(kSystemPointerSize)); -+#else -+ __ Push(a5); -+#endif -+ __ Branch(&loop, ne, scratch, Operand(sp)); -+ __ bind(&done); -+ } -+ -+ // Tail-call to the actual Call or Construct builtin. -+ __ Jump(code, RelocInfo::CODE_TARGET); -+ -+ __ bind(&stack_overflow); -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+} -+ -+// static -+void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, -+ CallOrConstructMode mode, -+ Handle code) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a3 : the new.target (for [[Construct]] calls) -+ // -- a1 : the target to call (can be any Object) -+ // -- a2 : start index (to support rest parameters) -+ // ----------------------------------- -+ -+ // Check if new.target has a [[Construct]] internal method. -+ if (mode == CallOrConstructMode::kConstruct) { -+ Label new_target_constructor, new_target_not_constructor; -+ __ JumpIfSmi(a3, &new_target_not_constructor); -+ __ Ld_d(t1, FieldMemOperand(a3, HeapObject::kMapOffset)); -+ __ Ld_bu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t1, t1, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ __ Branch(&new_target_constructor, ne, t1, Operand(zero_reg)); -+ __ bind(&new_target_not_constructor); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ Push(a3); -+ __ CallRuntime(Runtime::kThrowNotConstructor); -+ } -+ __ bind(&new_target_constructor); -+ } -+ -+ // Check if we have an arguments adaptor frame below the function frame. -+ Label arguments_adaptor, arguments_done; -+ __ Ld_d(a6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ __ Ld_d(a7, MemOperand(a6, CommonFrameConstants::kContextOrFrameTypeOffset)); -+ __ Branch(&arguments_adaptor, eq, a7, -+ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ { -+ __ Ld_d(a7, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ Ld_d(a7, FieldMemOperand(a7, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_hu(a7, FieldMemOperand( -+ a7, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ mov(a6, fp); -+ } -+ __ Branch(&arguments_done); -+ __ bind(&arguments_adaptor); -+ { -+ // Just get the length from the ArgumentsAdaptorFrame. -+ __ SmiUntag(a7, -+ MemOperand(a6, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ } -+ __ bind(&arguments_done); -+ -+ Label stack_done, stack_overflow; -+ __ Sub_w(a7, a7, a2); -+ __ Branch(&stack_done, le, a7, Operand(zero_reg)); -+ { -+ // Check for stack overflow. -+ Generate_StackOverflowCheck(masm, a7, a4, a5, &stack_overflow); -+ -+ // Forward the arguments from the caller frame. -+ -+#ifdef V8_REVERSE_JSARGS -+ // Point to the first argument to copy (skipping the receiver). -+ __ Add_d(a6, a6, -+ Operand(CommonFrameConstants::kFixedFrameSizeAboveFp + -+ kSystemPointerSize)); -+ __ Alsl_d(a6, a2, a6, kSystemPointerSizeLog2, t7); -+ -+ // Move the arguments already in the stack, -+ // including the receiver and the return address. -+ { -+ Label copy; -+ Register src = t0, dest = a2; -+ __ mov(src, sp); -+ // Update stack pointer. -+ __ slli_d(t1, a7, kSystemPointerSizeLog2); -+ __ Sub_d(sp, sp, Operand(t1)); -+ __ mov(dest, sp); -+ __ Add_d(t2, a0, Operand(zero_reg)); -+ -+ __ bind(©); -+ __ Ld_d(t1, MemOperand(src, 0)); -+ __ St_d(t1, MemOperand(dest, 0)); -+ __ Sub_d(t2, t2, Operand(1)); -+ __ Add_d(src, src, Operand(kSystemPointerSize)); -+ __ Add_d(dest, dest, Operand(kSystemPointerSize)); -+ __ Branch(©, ge, t2, Operand(zero_reg)); -+ } -+#endif -+ -+ // Copy arguments from the caller frame. -+ // TODO(victorgomes): Consider using forward order as potentially more cache -+ // friendly. -+ { -+ Label loop; -+#ifndef V8_REVERSE_JSARGS -+ __ Add_d(a6, a6, Operand(CommonFrameConstants::kFixedFrameSizeAboveFp)); -+#endif -+ __ Add_d(a0, a0, a7); -+ __ bind(&loop); -+ { -+ __ Sub_w(a7, a7, Operand(1)); -+ __ Alsl_d(t0, a7, a6, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(t0, 0)); -+#ifdef V8_REVERSE_JSARGS -+ __ Alsl_d(t0, a7, a2, kPointerSizeLog2, t7); -+ __ St_d(kScratchReg, MemOperand(t0, 0)); -+#else -+ __ push(kScratchReg); -+#endif -+ __ Branch(&loop, ne, a7, Operand(zero_reg)); -+ } -+ } -+ } -+ __ Branch(&stack_done); -+ __ bind(&stack_overflow); -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ __ bind(&stack_done); -+ -+ // Tail-call to the {code} handler. -+ __ Jump(code, RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_CallFunction(MacroAssembler* masm, -+ ConvertReceiverMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // ----------------------------------- -+ __ AssertFunction(a1); -+ -+ // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) -+ // Check that function is not a "classConstructor". -+ Label class_constructor; -+ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_wu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); -+ __ And(kScratchReg, a3, -+ Operand(SharedFunctionInfo::IsClassConstructorBit::kMask)); -+ __ Branch(&class_constructor, ne, kScratchReg, Operand(zero_reg)); -+ -+ // Enter the context of the function; ToObject has to run in the function -+ // context, and we also need to take the global proxy from the function -+ // context in case of conversion. -+ __ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ // We need to convert the receiver for non-native sloppy mode functions. -+ Label done_convert; -+ __ Ld_wu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); -+ __ And(kScratchReg, a3, -+ Operand(SharedFunctionInfo::IsNativeBit::kMask | -+ SharedFunctionInfo::IsStrictBit::kMask)); -+ __ Branch(&done_convert, ne, kScratchReg, Operand(zero_reg)); -+ { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // -- a2 : the shared function info. -+ // -- cp : the function context. -+ // ----------------------------------- -+ -+ if (mode == ConvertReceiverMode::kNullOrUndefined) { -+ // Patch receiver to global proxy. -+ __ LoadGlobalProxy(a3); -+ } else { -+ Label convert_to_object, convert_receiver; -+ __ LoadReceiver(a3, a0); -+ __ JumpIfSmi(a3, &convert_to_object); -+ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); -+ __ GetObjectType(a3, a4, a4); -+ __ Branch(&done_convert, hs, a4, Operand(FIRST_JS_RECEIVER_TYPE)); -+ if (mode != ConvertReceiverMode::kNotNullOrUndefined) { -+ Label convert_global_proxy; -+ __ JumpIfRoot(a3, RootIndex::kUndefinedValue, &convert_global_proxy); -+ __ JumpIfNotRoot(a3, RootIndex::kNullValue, &convert_to_object); -+ __ bind(&convert_global_proxy); -+ { -+ // Patch receiver to global proxy. -+ __ LoadGlobalProxy(a3); -+ } -+ __ Branch(&convert_receiver); -+ } -+ __ bind(&convert_to_object); -+ { -+ // Convert receiver using ToObject. -+ // TODO(bmeurer): Inline the allocation here to avoid building the frame -+ // in the fast case? (fall back to AllocateInNewSpace?) -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ SmiTag(a0); -+ __ Push(a0, a1); -+ __ mov(a0, a3); -+ __ Push(cp); -+ __ Call(BUILTIN_CODE(masm->isolate(), ToObject), -+ RelocInfo::CODE_TARGET); -+ __ Pop(cp); -+ __ mov(a3, a0); -+ __ Pop(a0, a1); -+ __ SmiUntag(a0); -+ } -+ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ bind(&convert_receiver); -+ } -+ __ StoreReceiver(a3, a0, kScratchReg); -+ } -+ __ bind(&done_convert); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // -- a2 : the shared function info. -+ // -- cp : the function context. -+ // ----------------------------------- -+ -+ __ Ld_hu( -+ a2, FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ InvokeFunctionCode(a1, no_reg, a2, a0, JUMP_FUNCTION); -+ -+ // The function is a "classConstructor", need to raise an exception. -+ __ bind(&class_constructor); -+ { -+ FrameScope frame(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowConstructorNonCallableError); -+ } -+} -+ -+// static -+void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // ----------------------------------- -+ __ AssertBoundFunction(a1); -+ -+ // Patch the receiver to [[BoundThis]]. -+ { -+ __ Ld_d(t0, FieldMemOperand(a1, JSBoundFunction::kBoundThisOffset)); -+ __ StoreReceiver(t0, a0, kScratchReg); -+ } -+ -+ // Load [[BoundArguments]] into a2 and length of that into a4. -+ __ Ld_d(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) -+ // -- a4 : the number of [[BoundArguments]] -+ // ----------------------------------- -+ -+ // Reserve stack space for the [[BoundArguments]]. -+ { -+ Label done; -+ __ slli_d(a5, a4, kPointerSizeLog2); -+ __ Sub_d(t0, sp, Operand(a5)); -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&done, hs, t0, Operand(kScratchReg)); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ } -+ __ bind(&done); -+ } -+ -+#ifdef V8_REVERSE_JSARGS -+ // Pop receiver. -+ __ Pop(t0); -+ -+ // Push [[BoundArguments]]. -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add_d(a0, a0, Operand(a4)); -+ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub_d(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a5, 0)); -+ __ Push(kScratchReg); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Push receiver. -+ __ Push(t0); -+#else -+ __ mov(sp, t0); -+ // Relocate arguments down the stack. -+ { -+ Label loop, done_loop; -+ __ mov(a5, zero_reg); -+ __ bind(&loop); -+ __ Branch(&done_loop, gt, a5, Operand(a0)); -+ __ Alsl_d(a6, a4, sp, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a6, 0)); -+ __ Alsl_d(a6, a5, sp, kPointerSizeLog2, t7); -+ __ St_d(kScratchReg, MemOperand(a6, 0)); -+ __ Add_d(a4, a4, Operand(1)); -+ __ Add_d(a5, a5, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Copy [[BoundArguments]] to the stack (below the arguments). -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub_d(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a5, 0)); -+ __ Alsl_d(a5, a0, sp, kPointerSizeLog2, t7); -+ __ St_d(kScratchReg, MemOperand(a5, 0)); -+ __ Add_d(a0, a0, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+#endif -+ -+ // Call the [[BoundTargetFunction]] via the Call builtin. -+ __ Ld_d(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), Call_ReceiverIsAny), -+ RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the target to call (can be any Object). -+ // ----------------------------------- -+ -+ Label non_callable, non_smi; -+ __ JumpIfSmi(a1, &non_callable); -+ __ bind(&non_smi); -+ __ GetObjectType(a1, t1, t2); -+ __ Jump(masm->isolate()->builtins()->CallFunction(mode), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); -+ -+ // Check if target has a [[Call]] internal method. -+ __ Ld_bu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t1, t1, Operand(Map::Bits1::IsCallableBit::kMask)); -+ __ Branch(&non_callable, eq, t1, Operand(zero_reg)); -+ -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallProxy), RelocInfo::CODE_TARGET, eq, -+ t2, Operand(JS_PROXY_TYPE)); -+ -+ // 2. Call to something else, which might have a [[Call]] internal method (if -+ // not we raise an exception). -+ // Overwrite the original receiver with the (original) target. -+ __ StoreReceiver(a1, a0, kScratchReg); -+ // Let the "call_as_function_delegate" take care of the rest. -+ __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, a1); -+ __ Jump(masm->isolate()->builtins()->CallFunction( -+ ConvertReceiverMode::kNotNullOrUndefined), -+ RelocInfo::CODE_TARGET); -+ -+ // 3. Call to something that is not callable. -+ __ bind(&non_callable); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowCalledNonCallable); -+ } -+} -+ -+void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the constructor to call (checked to be a JSFunction) -+ // -- a3 : the new target (checked to be a constructor) -+ // ----------------------------------- -+ __ AssertConstructor(a1); -+ __ AssertFunction(a1); -+ -+ // Calling convention for function specific ConstructStubs require -+ // a2 to contain either an AllocationSite or undefined. -+ __ LoadRoot(a2, RootIndex::kUndefinedValue); -+ -+ Label call_generic_stub; -+ -+ // Jump to JSBuiltinsConstructStub or JSConstructStubGeneric. -+ __ Ld_d(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_wu(a4, FieldMemOperand(a4, SharedFunctionInfo::kFlagsOffset)); -+ __ And(a4, a4, Operand(SharedFunctionInfo::ConstructAsBuiltinBit::kMask)); -+ __ Branch(&call_generic_stub, eq, a4, Operand(zero_reg)); -+ -+ __ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub), -+ RelocInfo::CODE_TARGET); -+ -+ __ bind(&call_generic_stub); -+ __ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric), -+ RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a3 : the new target (checked to be a constructor) -+ // ----------------------------------- -+ __ AssertConstructor(a1); -+ __ AssertBoundFunction(a1); -+ -+ // Load [[BoundArguments]] into a2 and length of that into a4. -+ __ Ld_d(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) -+ // -- a3 : the new target (checked to be a constructor) -+ // -- a4 : the number of [[BoundArguments]] -+ // ----------------------------------- -+ -+ // Reserve stack space for the [[BoundArguments]]. -+ { -+ Label done; -+ __ slli_d(a5, a4, kPointerSizeLog2); -+ __ Sub_d(t0, sp, Operand(a5)); -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&done, hs, t0, Operand(kScratchReg)); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ } -+ __ bind(&done); -+ } -+ -+#ifdef V8_REVERSE_JSARGS -+ // Pop receiver. -+ __ Pop(t0); -+ -+ // Push [[BoundArguments]]. -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add_d(a0, a0, Operand(a4)); -+ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub_d(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a5, 0)); -+ __ Push(kScratchReg); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Push receiver. -+ __ Push(t0); -+#else -+ __ mov(sp, t0); -+ // Relocate arguments down the stack. -+ { -+ Label loop, done_loop; -+ __ mov(a5, zero_reg); -+ __ bind(&loop); -+ __ Branch(&done_loop, ge, a5, Operand(a0)); -+ __ Alsl_d(a6, a4, sp, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a6, 0)); -+ __ Alsl_d(a6, a5, sp, kPointerSizeLog2, t7); -+ __ St_d(kScratchReg, MemOperand(a6, 0)); -+ __ Add_d(a4, a4, Operand(1)); -+ __ Add_d(a5, a5, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Copy [[BoundArguments]] to the stack (below the arguments). -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub_d(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); -+ __ Ld_d(kScratchReg, MemOperand(a5, 0)); -+ __ Alsl_d(a5, a0, sp, kPointerSizeLog2, t7); -+ __ St_d(kScratchReg, MemOperand(a5, 0)); -+ __ Add_d(a0, a0, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+#endif -+ -+ // Patch new.target to [[BoundTargetFunction]] if new.target equals target. -+ { -+ Label skip_load; -+ __ Branch(&skip_load, ne, a1, Operand(a3)); -+ __ Ld_d(a3, -+ FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ bind(&skip_load); -+ } -+ -+ // Construct the [[BoundTargetFunction]] via the Construct builtin. -+ __ Ld_d(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_Construct(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the constructor to call (can be any Object) -+ // -- a3 : the new target (either the same as the constructor or -+ // the JSFunction on which new was invoked initially) -+ // ----------------------------------- -+ -+ // Check if target is a Smi. -+ Label non_constructor, non_proxy; -+ __ JumpIfSmi(a1, &non_constructor); -+ -+ // Check if target has a [[Construct]] internal method. -+ __ Ld_d(t1, FieldMemOperand(a1, HeapObject::kMapOffset)); -+ __ Ld_bu(t3, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t3, t3, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ __ Branch(&non_constructor, eq, t3, Operand(zero_reg)); -+ -+ // Dispatch based on instance type. -+ __ Ld_hu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); -+ -+ // Only dispatch to bound functions after checking whether they are -+ // constructors. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructBoundFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); -+ -+ // Only dispatch to proxies after checking whether they are constructors. -+ __ Branch(&non_proxy, ne, t2, Operand(JS_PROXY_TYPE)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy), -+ RelocInfo::CODE_TARGET); -+ -+ // Called Construct on an exotic Object with a [[Construct]] internal method. -+ __ bind(&non_proxy); -+ { -+ // Overwrite the original receiver with the (original) target. -+ __ StoreReceiver(a1, a0, kScratchReg); -+ // Let the "call_as_constructor_delegate" take care of the rest. -+ __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); -+ __ Jump(masm->isolate()->builtins()->CallFunction(), -+ RelocInfo::CODE_TARGET); -+ } -+ -+ // Called Construct on an Object that doesn't have a [[Construct]] internal -+ // method. -+ __ bind(&non_constructor); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructedNonConstructable), -+ RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { -+ // State setup as expected by MacroAssembler::InvokePrologue. -+ // ----------- S t a t e ------------- -+ // -- a0: actual arguments count -+ // -- a1: function (passed through to callee) -+ // -- a2: expected arguments count -+ // -- a3: new target (passed through to callee) -+ // ----------------------------------- -+ -+ Label invoke, dont_adapt_arguments, stack_overflow; -+ -+ Label enough, too_few; -+ __ Branch(&dont_adapt_arguments, eq, a2, -+ Operand(kDontAdaptArgumentsSentinel)); -+ // We use Uless as the number of argument should always be greater than 0. -+ __ Branch(&too_few, Uless, a0, Operand(a2)); -+ -+ { // Enough parameters: actual >= expected. -+ // a0: actual number of arguments as a smi -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ bind(&enough); -+ EnterArgumentsAdaptorFrame(masm); -+ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); -+ -+ // Calculate copy start address into a0 and copy end address into a4. -+#ifdef V8_REVERSE_JSARGS -+ __ slli_d(a0, a2, kPointerSizeLog2); -+ __ Add_d(a0, fp, a0); -+#else -+ __ SmiScale(a0, a0, kPointerSizeLog2); -+ __ Add_d(a0, fp, a0); -+#endif -+ -+ // Adjust for return address and receiver. -+ __ Add_d(a0, a0, Operand(2 * kPointerSize)); -+ // Compute copy end address. -+ __ slli_d(a4, a2, kPointerSizeLog2); -+ __ sub_d(a4, a0, a4); -+ -+ // Copy the arguments (including the receiver) to the new stack frame. -+ // a0: copy start address -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ // a4: copy end address -+ -+ Label copy; -+ __ bind(©); -+ __ Ld_d(a5, MemOperand(a0, 0)); -+ __ push(a5); -+ __ addi_d(a0, a0, -kPointerSize); -+ __ Branch(©, ge, a0, Operand(a4)); -+ -+ __ jmp(&invoke); -+ } -+ -+ { // Too few parameters: Actual < expected. -+ __ bind(&too_few); -+ EnterArgumentsAdaptorFrame(masm); -+ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); -+ -+#ifdef V8_REVERSE_JSARGS -+ // Fill the remaining expected arguments with undefined. -+ __ LoadRoot(t0, RootIndex::kUndefinedValue); -+ __ SmiUntag(t1, a0); -+ __ Sub_d(t2, a2, Operand(t1)); -+ __ slli_d(a4, t2, kSystemPointerSizeLog2); -+ __ Sub_d(a4, fp, a4); -+ // Adjust for frame. -+ __ Sub_d(a4, a4, -+ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + -+ kSystemPointerSize)); -+ -+ Label fill; -+ __ bind(&fill); -+ __ push(t0); -+ __ Branch(&fill, ne, sp, Operand(a4)); -+ -+ // Calculate copy start address into r0 and copy end address is fp. -+ __ SmiScale(a0, a0, kPointerSizeLog2); -+ __ Add_d(a0, fp, a0); -+ -+ // Copy the arguments (including the receiver) to the new stack frame. -+ Label copy; -+ __ bind(©); -+ -+ // Adjust load for return address and receiver. -+ __ Ld_d(t0, MemOperand(a0, 2 * kSystemPointerSize)); -+ __ push(t0); -+ -+ __ Sub_d(a0, a0, Operand(kSystemPointerSize)); -+ __ Branch(©, ge, a0, Operand(fp)); -+#else -+ // Calculate copy start address into a0 and copy end address into a7. -+ // a0: actual number of arguments as a smi -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ SmiScale(a0, a0, kPointerSizeLog2); -+ __ Add_d(a0, fp, a0); -+ // Adjust for return address and receiver. -+ __ Add_d(a0, a0, Operand(2 * kPointerSize)); -+ // Compute copy end address. Also adjust for return address. -+ __ Add_d(a7, fp, kPointerSize); -+ -+ // Copy the arguments (including the receiver) to the new stack frame. -+ // a0: copy start address -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ // a7: copy end address -+ Label copy; -+ __ bind(©); -+ __ Ld_d(a4, -+ MemOperand(a0, 0)); // Adjusted above for return addr and receiver. -+ __ Sub_d(sp, sp, kPointerSize); -+ __ Sub_d(a0, a0, kPointerSize); -+ __ St_d(a4, MemOperand(sp, 0)); -+ __ Branch(©, ne, a0, Operand(a7)); -+ -+ // Fill the remaining expected arguments with undefined. -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ slli_d(a6, a2, kPointerSizeLog2); -+ __ Sub_d(a4, fp, Operand(a6)); -+ // Adjust for frame. -+ __ Sub_d(a4, a4, -+ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + -+ kPointerSize)); -+ -+ Label fill; -+ __ bind(&fill); -+ __ Sub_d(sp, sp, kPointerSize); -+ __ St_d(a5, MemOperand(sp, 0)); -+ __ Branch(&fill, ne, sp, Operand(a4)); -+#endif -+ } -+ -+ // Call the entry point. -+ __ bind(&invoke); -+ __ mov(a0, a2); -+ // a0 : expected number of arguments -+ // a1 : function (passed through to callee) -+ // a3: new target (passed through to callee) -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Call(a2); -+ -+ // Store offset of return address for deoptimizer. -+ masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); -+ -+ // Exit frame and return. -+ LeaveArgumentsAdaptorFrame(masm); -+ __ Ret(); -+ -+ // ------------------------------------------- -+ // Don't adapt arguments. -+ // ------------------------------------------- -+ __ bind(&dont_adapt_arguments); -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ -+ __ bind(&stack_overflow); -+ { -+ FrameScope frame(masm, StackFrame::MANUAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ __ break_(0xCC); -+ } -+} -+ -+void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { -+ // The function index was put in t0 by the jump table trampoline. -+ // Convert to Smi for the runtime call -+ __ SmiTag(kWasmCompileLazyFuncIndexRegister); -+ { -+ HardAbortScope hard_abort(masm); // Avoid calls to Abort. -+ FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); -+ -+ // Save all parameter registers (see wasm-linkage.cc). They might be -+ // overwritten in the runtime call below. We don't have any callee-saved -+ // registers in wasm, so no need to store anything else. -+ constexpr RegList gp_regs = Register::ListOf(a0, a2, a3, a4, a5, a6, a7); -+ constexpr RegList fp_regs = -+ DoubleRegister::ListOf(f2, f4, f6, f8, f10, f12, f14); -+ constexpr int16_t num_to_push = base::bits::CountPopulation(gp_regs) + -+ base::bits::CountPopulation(fp_regs); -+ // The number of regs to be pushed before kWasmInstanceRegister should be -+ // equal to kNumberOfSavedAllParamRegs. -+ STATIC_ASSERT(num_to_push == -+ WasmCompileLazyFrameConstants::kNumberOfSavedAllParamRegs); -+ __ MultiPush(gp_regs); -+ __ MultiPushFPU(fp_regs); -+ -+ // Pass instance and function index as an explicit arguments to the runtime -+ // function. -+ __ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister); -+ // Initialize the JavaScript context with 0. CEntry will use it to -+ // set the current context on the isolate. -+ __ Move(kContextRegister, Smi::zero()); -+ __ CallRuntime(Runtime::kWasmCompileLazy, 2); -+ __ mov(t8, a0); -+ -+ // Restore registers. -+ __ MultiPopFPU(fp_regs); -+ __ MultiPop(gp_regs); -+ } -+ // Finally, jump to the entrypoint. -+ __ Jump(t8); -+} -+ -+void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) { -+ HardAbortScope hard_abort(masm); // Avoid calls to Abort. -+ { -+ FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK); -+ -+ // Save all parameter registers. They might hold live values, we restore -+ // them after the runtime call. -+ __ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs); -+ __ MultiPushFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); -+ -+ // Initialize the JavaScript context with 0. CEntry will use it to -+ // set the current context on the isolate. -+ __ Move(cp, Smi::zero()); -+ __ CallRuntime(Runtime::kWasmDebugBreak, 0); -+ -+ // Restore registers. -+ __ MultiPopFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); -+ __ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs); -+ } -+ __ Ret(); -+} -+ -+void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, -+ SaveFPRegsMode save_doubles, ArgvMode argv_mode, -+ bool builtin_exit_frame) { -+ // Called from JavaScript; parameters are on stack as if calling JS function -+ // a0: number of arguments including receiver -+ // a1: pointer to builtin function -+ // fp: frame pointer (restored after C call) -+ // sp: stack pointer (restored as callee's sp after C call) -+ // cp: current context (C callee-saved) -+ // -+ // If argv_mode == kArgvInRegister: -+ // a2: pointer to the first argument -+ -+ if (argv_mode == kArgvInRegister) { -+ // Move argv into the correct register. -+ __ mov(s1, a2); -+ } else { -+ // Compute the argv pointer in a callee-saved register. -+ __ Alsl_d(s1, a0, sp, kPointerSizeLog2, t7); -+ __ Sub_d(s1, s1, kPointerSize); -+ } -+ -+ // Enter the exit frame that transitions from JavaScript to C++. -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame( -+ save_doubles == kSaveFPRegs, 0, -+ builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT); -+ -+ // s0: number of arguments including receiver (C callee-saved) -+ // s1: pointer to first argument (C callee-saved) -+ // s2: pointer to builtin function (C callee-saved) -+ -+ // Prepare arguments for C routine. -+ // a0 = argc -+ __ mov(s0, a0); -+ __ mov(s2, a1); -+ -+ // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We -+ // also need to reserve the 4 argument slots on the stack. -+ -+ __ AssertStackIsAligned(); -+ -+ // a0 = argc, a1 = argv, a2 = isolate -+ __ li(a2, ExternalReference::isolate_address(masm->isolate())); -+ __ mov(a1, s1); -+ -+ __ StoreReturnAddressAndCall(s2); -+ -+ // Result returned in a0 or a1:a0 - do not destroy these registers! -+ -+ // Check result for exception sentinel. -+ Label exception_returned; -+ __ LoadRoot(a4, RootIndex::kException); -+ __ Branch(&exception_returned, eq, a4, Operand(a0)); -+ -+ // Check that there is no pending exception, otherwise we -+ // should have returned the exception sentinel. -+ if (FLAG_debug_code) { -+ Label okay; -+ ExternalReference pending_exception_address = ExternalReference::Create( -+ IsolateAddressId::kPendingExceptionAddress, masm->isolate()); -+ __ li(a2, pending_exception_address); -+ __ Ld_d(a2, MemOperand(a2, 0)); -+ __ LoadRoot(a4, RootIndex::kTheHoleValue); -+ // Cannot use check here as it attempts to generate call into runtime. -+ __ Branch(&okay, eq, a4, Operand(a2)); -+ __ stop(); -+ __ bind(&okay); -+ } -+ -+ // Exit C frame and return. -+ // a0:a1: result -+ // sp: stack pointer -+ // fp: frame pointer -+ Register argc = argv_mode == kArgvInRegister -+ // We don't want to pop arguments so set argc to no_reg. -+ ? no_reg -+ // s0: still holds argc (callee-saved). -+ : s0; -+ __ LeaveExitFrame(save_doubles == kSaveFPRegs, argc, EMIT_RETURN); -+ -+ // Handling of exception. -+ __ bind(&exception_returned); -+ -+ ExternalReference pending_handler_context_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerContextAddress, masm->isolate()); -+ ExternalReference pending_handler_entrypoint_address = -+ ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate()); -+ ExternalReference pending_handler_fp_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerFPAddress, masm->isolate()); -+ ExternalReference pending_handler_sp_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerSPAddress, masm->isolate()); -+ -+ // Ask the runtime for help to determine the handler. This will set a0 to -+ // contain the current pending exception, don't clobber it. -+ ExternalReference find_handler = -+ ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ PrepareCallCFunction(3, 0, a0); -+ __ mov(a0, zero_reg); -+ __ mov(a1, zero_reg); -+ __ li(a2, ExternalReference::isolate_address(masm->isolate())); -+ __ CallCFunction(find_handler, 3); -+ } -+ -+ // Retrieve the handler context, SP and FP. -+ __ li(cp, pending_handler_context_address); -+ __ Ld_d(cp, MemOperand(cp, 0)); -+ __ li(sp, pending_handler_sp_address); -+ __ Ld_d(sp, MemOperand(sp, 0)); -+ __ li(fp, pending_handler_fp_address); -+ __ Ld_d(fp, MemOperand(fp, 0)); -+ -+ // If the handler is a JS frame, restore the context to the frame. Note that -+ // the context will be set to (cp == 0) for non-JS frames. -+ Label zero; -+ __ Branch(&zero, eq, cp, Operand(zero_reg)); -+ __ St_d(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); -+ __ bind(&zero); -+ -+ // Reset the masking register. This is done independent of the underlying -+ // feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work -+ // with both configurations. It is safe to always do this, because the -+ // underlying register is caller-saved and can be arbitrarily clobbered. -+ __ ResetSpeculationPoisonRegister(); -+ -+ // Compute the handler entry address and jump to it. -+ __ li(t7, pending_handler_entrypoint_address); -+ __ Ld_d(t7, MemOperand(t7, 0)); -+ __ Jump(t7); -+} -+ -+void Builtins::Generate_DoubleToI(MacroAssembler* masm) { -+ Label done; -+ Register result_reg = t0; -+ -+ Register scratch = GetRegisterThatIsNotOneOf(result_reg); -+ Register scratch2 = GetRegisterThatIsNotOneOf(result_reg, scratch); -+ Register scratch3 = GetRegisterThatIsNotOneOf(result_reg, scratch, scratch2); -+ DoubleRegister double_scratch = kScratchDoubleReg; -+ -+ // Account for saved regs. -+ const int kArgumentOffset = 4 * kPointerSize; -+ -+ __ Push(result_reg); -+ __ Push(scratch, scratch2, scratch3); -+ -+ // Load double input. -+ __ Fld_d(double_scratch, MemOperand(sp, kArgumentOffset)); -+ -+ // Clear cumulative exception flags and save the FCSR. -+ // __ movfcsr2gr(scratch2, FCSR); -+ // __ movgr2fcsr(FCSR, zero_reg); -+ -+ // Try a conversion to a signed integer. -+ __ ftintrz_w_d(double_scratch, double_scratch); -+ // Move the converted value into the result register. -+ __ movfr2gr_s(scratch3, double_scratch); -+ -+ // Retrieve and restore the FCSR. -+ __ movfcsr2gr(scratch); // __ cfc1(scratch, FCSR); -+ // __ ctc1(scratch2, FCSR); -+ -+ // Check for overflow and NaNs. -+ __ And( -+ scratch, scratch, -+ kFCSROverflowFlagMask | kFCSRUnderflowFlagMask | kFCSRInvalidOpFlagMask); -+ // If we had no exceptions then set result_reg and we are done. -+ Label error; -+ __ Branch(&error, ne, scratch, Operand(zero_reg)); -+ __ Move(result_reg, scratch3); -+ __ Branch(&done); -+ __ bind(&error); -+ -+ // Load the double value and perform a manual truncation. -+ Register input_high = scratch2; -+ Register input_low = scratch3; -+ -+ __ Ld_w(input_low, -+ MemOperand(sp, kArgumentOffset + Register::kMantissaOffset)); -+ __ Ld_w(input_high, -+ MemOperand(sp, kArgumentOffset + Register::kExponentOffset)); -+ -+ Label normal_exponent; -+ // Extract the biased exponent in result. -+ __ bstrpick_w(result_reg, input_high, -+ HeapNumber::kExponentShift + HeapNumber::kExponentBits - 1, -+ HeapNumber::kExponentShift); -+ -+ // Check for Infinity and NaNs, which should return 0. -+ __ Sub_w(scratch, result_reg, HeapNumber::kExponentMask); -+ __ Movz(result_reg, zero_reg, scratch); -+ __ Branch(&done, eq, scratch, Operand(zero_reg)); -+ -+ // Express exponent as delta to (number of mantissa bits + 31). -+ __ Sub_w(result_reg, result_reg, -+ Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits + 31)); -+ -+ // If the delta is strictly positive, all bits would be shifted away, -+ // which means that we can return 0. -+ __ Branch(&normal_exponent, le, result_reg, Operand(zero_reg)); -+ __ mov(result_reg, zero_reg); -+ __ Branch(&done); -+ -+ __ bind(&normal_exponent); -+ const int kShiftBase = HeapNumber::kNonMantissaBitsInTopWord - 1; -+ // Calculate shift. -+ __ Add_w(scratch, result_reg, -+ Operand(kShiftBase + HeapNumber::kMantissaBits)); -+ -+ // Save the sign. -+ Register sign = result_reg; -+ result_reg = no_reg; -+ __ And(sign, input_high, Operand(HeapNumber::kSignMask)); -+ -+ // On ARM shifts > 31 bits are valid and will result in zero. On MIPS we need -+ // to check for this specific case. -+ Label high_shift_needed, high_shift_done; -+ __ Branch(&high_shift_needed, lt, scratch, Operand(32)); -+ __ mov(input_high, zero_reg); -+ __ Branch(&high_shift_done); -+ __ bind(&high_shift_needed); -+ -+ // Set the implicit 1 before the mantissa part in input_high. -+ __ Or(input_high, input_high, -+ Operand(1 << HeapNumber::kMantissaBitsInTopWord)); -+ // Shift the mantissa bits to the correct position. -+ // We don't need to clear non-mantissa bits as they will be shifted away. -+ // If they weren't, it would mean that the answer is in the 32bit range. -+ __ sll_w(input_high, input_high, scratch); -+ -+ __ bind(&high_shift_done); -+ -+ // Replace the shifted bits with bits from the lower mantissa word. -+ Label pos_shift, shift_done; -+ __ li(kScratchReg, 32); -+ __ sub_w(scratch, kScratchReg, scratch); -+ __ Branch(&pos_shift, ge, scratch, Operand(zero_reg)); -+ -+ // Negate scratch. -+ __ Sub_w(scratch, zero_reg, scratch); -+ __ sll_w(input_low, input_low, scratch); -+ __ Branch(&shift_done); -+ -+ __ bind(&pos_shift); -+ __ srl_w(input_low, input_low, scratch); -+ -+ __ bind(&shift_done); -+ __ Or(input_high, input_high, Operand(input_low)); -+ // Restore sign if necessary. -+ __ mov(scratch, sign); -+ result_reg = sign; -+ sign = no_reg; -+ __ Sub_w(result_reg, zero_reg, input_high); -+ __ Movz(result_reg, input_high, scratch); -+ -+ __ bind(&done); -+ -+ __ St_d(result_reg, MemOperand(sp, kArgumentOffset)); -+ __ Pop(scratch, scratch2, scratch3); -+ __ Pop(result_reg); -+ __ Ret(); -+} -+ -+void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) { -+ // TODO(v8:10701): Implement for this platform. -+ __ Trap(); -+} -+ -+namespace { -+ -+int AddressOffset(ExternalReference ref0, ExternalReference ref1) { -+ int64_t offset = (ref0.address() - ref1.address()); -+ DCHECK(static_cast(offset) == offset); -+ return static_cast(offset); -+} -+ -+// Calls an API function. Allocates HandleScope, extracts returned value -+// from handle and propagates exceptions. Restores context. stack_space -+// - space to be unwound on exit (includes the call JS arguments space and -+// the additional space allocated for the fast call). -+void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address, -+ ExternalReference thunk_ref, int stack_space, -+ MemOperand* stack_space_operand, -+ MemOperand return_value_operand) { -+ Isolate* isolate = masm->isolate(); -+ ExternalReference next_address = -+ ExternalReference::handle_scope_next_address(isolate); -+ const int kNextOffset = 0; -+ const int kLimitOffset = AddressOffset( -+ ExternalReference::handle_scope_limit_address(isolate), next_address); -+ const int kLevelOffset = AddressOffset( -+ ExternalReference::handle_scope_level_address(isolate), next_address); -+ -+ DCHECK(function_address == a1 || function_address == a2); -+ -+ Label profiler_enabled, end_profiler_check; -+ __ li(t7, ExternalReference::is_profiling_address(isolate)); -+ __ Ld_b(t7, MemOperand(t7, 0)); -+ __ Branch(&profiler_enabled, ne, t7, Operand(zero_reg)); -+ __ li(t7, ExternalReference::address_of_runtime_stats_flag()); -+ __ Ld_w(t7, MemOperand(t7, 0)); -+ __ Branch(&profiler_enabled, ne, t7, Operand(zero_reg)); -+ { -+ // Call the api function directly. -+ __ mov(t7, function_address); -+ __ Branch(&end_profiler_check); -+ } -+ -+ __ bind(&profiler_enabled); -+ { -+ // Additional parameter is the address of the actual callback. -+ __ li(t7, thunk_ref); -+ } -+ __ bind(&end_profiler_check); -+ -+ // Allocate HandleScope in callee-save registers. -+ __ li(s5, next_address); -+ __ Ld_d(s0, MemOperand(s5, kNextOffset)); -+ __ Ld_d(s1, MemOperand(s5, kLimitOffset)); -+ __ Ld_w(s2, MemOperand(s5, kLevelOffset)); -+ __ Add_w(s2, s2, Operand(1)); -+ __ St_w(s2, MemOperand(s5, kLevelOffset)); -+ -+ __ StoreReturnAddressAndCall(t7); -+ -+ Label promote_scheduled_exception; -+ Label delete_allocated_handles; -+ Label leave_exit_frame; -+ Label return_value_loaded; -+ -+ // Load value from ReturnValue. -+ __ Ld_d(a0, return_value_operand); -+ __ bind(&return_value_loaded); -+ -+ // No more valid handles (the result handle was the last one). Restore -+ // previous handle scope. -+ __ St_d(s0, MemOperand(s5, kNextOffset)); -+ if (__ emit_debug_code()) { -+ __ Ld_w(a1, MemOperand(s5, kLevelOffset)); -+ __ Check(eq, AbortReason::kUnexpectedLevelAfterReturnFromApiCall, a1, -+ Operand(s2)); -+ } -+ __ Sub_w(s2, s2, Operand(1)); -+ __ St_w(s2, MemOperand(s5, kLevelOffset)); -+ __ Ld_d(kScratchReg, MemOperand(s5, kLimitOffset)); -+ __ Branch(&delete_allocated_handles, ne, s1, Operand(kScratchReg)); -+ -+ // Leave the API exit frame. -+ __ bind(&leave_exit_frame); -+ -+ if (stack_space_operand == nullptr) { -+ DCHECK_NE(stack_space, 0); -+ __ li(s0, Operand(stack_space)); -+ } else { -+ DCHECK_EQ(stack_space, 0); -+ STATIC_ASSERT(kCArgSlotCount == 0); -+ __ Ld_d(s0, *stack_space_operand); -+ } -+ -+ static constexpr bool kDontSaveDoubles = false; -+ static constexpr bool kRegisterContainsSlotCount = false; -+ __ LeaveExitFrame(kDontSaveDoubles, s0, NO_EMIT_RETURN, -+ kRegisterContainsSlotCount); -+ -+ // Check if the function scheduled an exception. -+ __ LoadRoot(a4, RootIndex::kTheHoleValue); -+ __ li(kScratchReg, ExternalReference::scheduled_exception_address(isolate)); -+ __ Ld_d(a5, MemOperand(kScratchReg, 0)); -+ __ Branch(&promote_scheduled_exception, ne, a4, Operand(a5)); -+ -+ __ Ret(); -+ -+ // Re-throw by promoting a scheduled exception. -+ __ bind(&promote_scheduled_exception); -+ __ TailCallRuntime(Runtime::kPromoteScheduledException); -+ -+ // HandleScope limit has changed. Delete allocated extensions. -+ __ bind(&delete_allocated_handles); -+ __ St_d(s1, MemOperand(s5, kLimitOffset)); -+ __ mov(s0, a0); -+ __ PrepareCallCFunction(1, s1); -+ __ li(a0, ExternalReference::isolate_address(isolate)); -+ __ CallCFunction(ExternalReference::delete_handle_scope_extensions(), 1); -+ __ mov(a0, s0); -+ __ jmp(&leave_exit_frame); -+} -+ -+} // namespace -+ -+void Builtins::Generate_CallApiCallback(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- cp : context -+ // -- a1 : api function address -+ // -- a2 : arguments count (not including the receiver) -+ // -- a3 : call data -+ // -- a0 : holder -+ // -- -+ // -- sp[0] : last argument -+ // -- ... -+ // -- sp[(argc - 1) * 8] : first argument -+ // -- sp[(argc + 0) * 8] : receiver -+ // ----------------------------------- -+ -+ Register api_function_address = a1; -+ Register argc = a2; -+ Register call_data = a3; -+ Register holder = a0; -+ Register scratch = t0; -+ Register base = t1; // For addressing MemOperands on the stack. -+ -+ DCHECK(!AreAliased(api_function_address, argc, call_data, holder, scratch, -+ base)); -+ -+ using FCA = FunctionCallbackArguments; -+ -+ STATIC_ASSERT(FCA::kArgsLength == 6); -+ STATIC_ASSERT(FCA::kNewTargetIndex == 5); -+ STATIC_ASSERT(FCA::kDataIndex == 4); -+ STATIC_ASSERT(FCA::kReturnValueOffset == 3); -+ STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); -+ STATIC_ASSERT(FCA::kIsolateIndex == 1); -+ STATIC_ASSERT(FCA::kHolderIndex == 0); -+ -+ // Set up FunctionCallbackInfo's implicit_args on the stack as follows: -+ // -+ // Target state: -+ // sp[0 * kPointerSize]: kHolder -+ // sp[1 * kPointerSize]: kIsolate -+ // sp[2 * kPointerSize]: undefined (kReturnValueDefaultValue) -+ // sp[3 * kPointerSize]: undefined (kReturnValue) -+ // sp[4 * kPointerSize]: kData -+ // sp[5 * kPointerSize]: undefined (kNewTarget) -+ -+ // Set up the base register for addressing through MemOperands. It will point -+ // at the receiver (located at sp + argc * kPointerSize). -+ __ Alsl_d(base, argc, sp, kPointerSizeLog2, t7); -+ -+ // Reserve space on the stack. -+ __ Sub_d(sp, sp, Operand(FCA::kArgsLength * kPointerSize)); -+ -+ // kHolder. -+ __ St_d(holder, MemOperand(sp, 0 * kPointerSize)); -+ -+ // kIsolate. -+ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); -+ __ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); -+ -+ // kReturnValueDefaultValue and kReturnValue. -+ __ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ __ St_d(scratch, MemOperand(sp, 2 * kPointerSize)); -+ __ St_d(scratch, MemOperand(sp, 3 * kPointerSize)); -+ -+ // kData. -+ __ St_d(call_data, MemOperand(sp, 4 * kPointerSize)); -+ -+ // kNewTarget. -+ __ St_d(scratch, MemOperand(sp, 5 * kPointerSize)); -+ -+ // Keep a pointer to kHolder (= implicit_args) in a scratch register. -+ // We use it below to set up the FunctionCallbackInfo object. -+ __ mov(scratch, sp); -+ -+ // Allocate the v8::Arguments structure in the arguments' space since -+ // it's not controlled by GC. -+ static constexpr int kApiStackSpace = 4; -+ static constexpr bool kDontSaveDoubles = false; -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame(kDontSaveDoubles, kApiStackSpace); -+ -+ // EnterExitFrame may align the sp. -+ -+ // FunctionCallbackInfo::implicit_args_ (points at kHolder as set up above). -+ // Arguments are after the return address (pushed by EnterExitFrame()). -+ __ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); -+ -+ // FunctionCallbackInfo::values_ (points at the first varargs argument passed -+ // on the stack). -+#ifdef V8_REVERSE_JSARGS -+ __ Add_d(scratch, scratch, -+ Operand((FCA::kArgsLength + 1) * kSystemPointerSize)); -+#else -+ __ Add_d(scratch, scratch, -+ Operand((FCA::kArgsLength - 1) * kSystemPointerSize)); -+ __ slli_d(t2, argc, kSystemPointerSizeLog2); -+ __ Add_d(scratch, scratch, t2); -+#endif -+ -+ __ St_d(scratch, MemOperand(sp, 2 * kPointerSize)); -+ -+ // FunctionCallbackInfo::length_. -+ // Stored as int field, 32-bit integers within struct on stack always left -+ // justified by n64 ABI. -+ __ St_w(argc, MemOperand(sp, 3 * kPointerSize)); -+ -+ // We also store the number of bytes to drop from the stack after returning -+ // from the API function here. -+ // Note: Unlike on other architectures, this stores the number of slots to -+ // drop, not the number of bytes. -+ __ Add_d(scratch, argc, Operand(FCA::kArgsLength + 1 /* receiver */)); -+ __ St_d(scratch, MemOperand(sp, 4 * kPointerSize)); -+ -+ // v8::InvocationCallback's argument. -+ DCHECK(!AreAliased(api_function_address, scratch, a0)); -+ __ Add_d(a0, sp, Operand(1 * kPointerSize)); -+ -+ ExternalReference thunk_ref = ExternalReference::invoke_function_callback(); -+ -+ // There are two stack slots above the arguments we constructed on the stack. -+ // TODO(jgruber): Document what these arguments are. -+ static constexpr int kStackSlotsAboveFCA = 2; -+ MemOperand return_value_operand( -+ fp, (kStackSlotsAboveFCA + FCA::kReturnValueOffset) * kPointerSize); -+ -+ static constexpr int kUseStackSpaceOperand = 0; -+ MemOperand stack_space_operand(sp, 4 * kPointerSize); -+ -+ AllowExternalCallThatCantCauseGC scope(masm); -+ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, -+ kUseStackSpaceOperand, &stack_space_operand, -+ return_value_operand); -+} -+ -+void Builtins::Generate_CallApiGetter(MacroAssembler* masm) { -+ // Build v8::PropertyCallbackInfo::args_ array on the stack and push property -+ // name below the exit frame to make GC aware of them. -+ STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); -+ STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); -+ STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); -+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); -+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); -+ STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); -+ STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); -+ STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); -+ -+ Register receiver = ApiGetterDescriptor::ReceiverRegister(); -+ Register holder = ApiGetterDescriptor::HolderRegister(); -+ Register callback = ApiGetterDescriptor::CallbackRegister(); -+ Register scratch = a4; -+ DCHECK(!AreAliased(receiver, holder, callback, scratch)); -+ -+ Register api_function_address = a2; -+ -+ // Here and below +1 is for name() pushed after the args_ array. -+ using PCA = PropertyCallbackArguments; -+ __ Sub_d(sp, sp, (PCA::kArgsLength + 1) * kPointerSize); -+ __ St_d(receiver, MemOperand(sp, (PCA::kThisIndex + 1) * kPointerSize)); -+ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kDataOffset)); -+ __ St_d(scratch, MemOperand(sp, (PCA::kDataIndex + 1) * kPointerSize)); -+ __ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ __ St_d(scratch, -+ MemOperand(sp, (PCA::kReturnValueOffset + 1) * kPointerSize)); -+ __ St_d(scratch, MemOperand(sp, (PCA::kReturnValueDefaultValueIndex + 1) * -+ kPointerSize)); -+ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); -+ __ St_d(scratch, MemOperand(sp, (PCA::kIsolateIndex + 1) * kPointerSize)); -+ __ St_d(holder, MemOperand(sp, (PCA::kHolderIndex + 1) * kPointerSize)); -+ // should_throw_on_error -> false -+ DCHECK_EQ(0, Smi::zero().ptr()); -+ __ St_d(zero_reg, -+ MemOperand(sp, (PCA::kShouldThrowOnErrorIndex + 1) * kPointerSize)); -+ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kNameOffset)); -+ __ St_d(scratch, MemOperand(sp, 0 * kPointerSize)); -+ -+ // v8::PropertyCallbackInfo::args_ array and name handle. -+ const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; -+ -+ // Load address of v8::PropertyAccessorInfo::args_ array and name handle. -+ __ mov(a0, sp); // a0 = Handle -+ __ Add_d(a1, a0, Operand(1 * kPointerSize)); // a1 = v8::PCI::args_ -+ -+ const int kApiStackSpace = 1; -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame(false, kApiStackSpace); -+ -+ // Create v8::PropertyCallbackInfo object on the stack and initialize -+ // it's args_ field. -+ __ St_d(a1, MemOperand(sp, 1 * kPointerSize)); -+ __ Add_d(a1, sp, Operand(1 * kPointerSize)); -+ // a1 = v8::PropertyCallbackInfo& -+ -+ ExternalReference thunk_ref = -+ ExternalReference::invoke_accessor_getter_callback(); -+ -+ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kJsGetterOffset)); -+ __ Ld_d(api_function_address, -+ FieldMemOperand(scratch, Foreign::kForeignAddressOffset)); -+ -+ // +3 is to skip prolog, return address and name handle. -+ MemOperand return_value_operand( -+ fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); -+ MemOperand* const kUseStackSpaceConstant = nullptr; -+ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, -+ kStackUnwindSpace, kUseStackSpaceConstant, -+ return_value_operand); -+} -+ -+void Builtins::Generate_DirectCEntry(MacroAssembler* masm) { -+ // The sole purpose of DirectCEntry is for movable callers (e.g. any general -+ // purpose Code object) to be able to call into C functions that may trigger -+ // GC and thus move the caller. -+ // -+ // DirectCEntry places the return address on the stack (updated by the GC), -+ // making the call GC safe. The irregexp backend relies on this. -+ -+ // Make place for arguments to fit C calling convention. Callers use -+ // EnterExitFrame/LeaveExitFrame so they handle stack restoring and we don't -+ // have to do that here. Any caller must drop kCArgsSlotsSize stack space -+ // after the call. -+ __ addi_d(sp, sp, -kCArgsSlotsSize); -+ -+ __ St_d(ra, MemOperand(sp, kCArgsSlotsSize)); // Store the return address. -+ __ Call(t7); // Call the C++ function. -+ __ Ld_d(t7, MemOperand(sp, kCArgsSlotsSize)); // Return to calling code. -+ -+ if (FLAG_debug_code && FLAG_enable_slow_asserts) { -+ // In case of an error the return address may point to a memory area -+ // filled with kZapValue by the GC. Dereference the address and check for -+ // this. -+ __ Ld_d(a4, MemOperand(t7, 0)); -+ __ Assert(ne, AbortReason::kReceivedInvalidReturnAddress, a4, -+ Operand(reinterpret_cast(kZapValue))); -+ } -+ -+ __ Jump(t7); -+} -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h b/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h -index d56b37250..85a477e1d 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h -@@ -17,6 +17,8 @@ - #include "src/codegen/arm/assembler-arm.h" - #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 - #include "src/codegen/ppc/assembler-ppc.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/codegen/loongarch64/assembler-loongarch64.h" - #elif V8_TARGET_ARCH_MIPS - #include "src/codegen/mips/assembler-mips.h" - #elif V8_TARGET_ARCH_MIPS64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h b/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h -index 8c81315d5..e8a6271ed 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h -+++ b/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h -@@ -21,6 +21,8 @@ - #include "src/codegen/mips/assembler-mips-inl.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/codegen/mips64/assembler-mips64-inl.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/assembler-s390-inl.h" - #else -diff --git a/src/3rdparty/chromium/v8/src/codegen/assembler.h b/src/3rdparty/chromium/v8/src/codegen/assembler.h -index 6419e55ce..1e7604e14 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/assembler.h -+++ b/src/3rdparty/chromium/v8/src/codegen/assembler.h -@@ -258,7 +258,8 @@ class V8_EXPORT_PRIVATE AssemblerBase : public Malloced { - int pc_offset() const { return static_cast(pc_ - buffer_start_); } - - int pc_offset_for_safepoint() { --#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) -+#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ -+ defined(V8_TARGET_ARCH_LOONGARCH64) - // Mips needs it's own implementation to avoid trampoline's influence. - UNREACHABLE(); - #else -diff --git a/src/3rdparty/chromium/v8/src/codegen/constants-arch.h b/src/3rdparty/chromium/v8/src/codegen/constants-arch.h -index 7a222c960..67654757e 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/constants-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/constants-arch.h -@@ -11,6 +11,8 @@ - #include "src/codegen/arm64/constants-arm64.h" // NOLINT - #elif V8_TARGET_ARCH_IA32 - #include "src/codegen/ia32/constants-ia32.h" // NOLINT -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/codegen/loongarch64/constants-loongarch64.h" // NOLINT - #elif V8_TARGET_ARCH_MIPS - #include "src/codegen/mips/constants-mips.h" // NOLINT - #elif V8_TARGET_ARCH_MIPS64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/cpu-features.h b/src/3rdparty/chromium/v8/src/codegen/cpu-features.h -index eef98f77e..e6252d105 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/cpu-features.h -+++ b/src/3rdparty/chromium/v8/src/codegen/cpu-features.h -@@ -50,6 +50,9 @@ enum CpuFeature { - MIPSr6, - MIPS_SIMD, // MSA instructions - -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ FPU, // TODO -+ - #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 - FPU, - FPR_GPR_MOV, -diff --git a/src/3rdparty/chromium/v8/src/codegen/external-reference.cc b/src/3rdparty/chromium/v8/src/codegen/external-reference.cc -index ba71702e7..a51db28b6 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/external-reference.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/external-reference.cc -@@ -500,6 +500,8 @@ ExternalReference ExternalReference::invoke_accessor_getter_callback() { - #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState - #elif V8_TARGET_ARCH_MIPS64 - #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#define re_stack_check_func RegExpMacroAssemblerLA64::CheckStackGuardState - #elif V8_TARGET_ARCH_S390 - #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState - #else -diff --git a/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc b/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc -index 8a6235fa0..90b1d4695 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc -@@ -131,7 +131,8 @@ const char* CallInterfaceDescriptor::DebugName() const { - return ""; - } - --#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) -+#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ -+ !defined(V8_TARGET_ARCH_LOONGARCH64) - bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) { - return true; - } -@@ -397,7 +398,8 @@ void WasmFloat64ToNumberDescriptor::InitializePlatformSpecific( - } - #endif // !V8_TARGET_ARCH_IA32 - --#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) -+#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ -+ !defined(V8_TARGET_ARCH_LOONGARCH64) - void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( - CallInterfaceDescriptorData* data) { - DefaultInitializePlatformSpecific(data, kParameterCount); -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64-inl.h b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64-inl.h -new file mode 100644 -index 000000000..1093c7b6c ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64-inl.h -@@ -0,0 +1,267 @@ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#ifndef V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ -+#define V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/loongarch64/assembler-loongarch64.h" -+#include "src/debug/debug.h" -+#include "src/objects/objects-inl.h" -+ -+namespace v8 { -+namespace internal { -+ -+bool CpuFeatures::SupportsOptimizer() { return IsSupported(FPU); } -+ -+bool CpuFeatures::SupportsWasmSimd128() { return false; } -+ -+// ----------------------------------------------------------------------------- -+// Operand and MemOperand. -+ -+bool Operand::is_reg() const { return rm_.is_valid(); } -+ -+int64_t Operand::immediate() const { -+ DCHECK(!is_reg()); -+ DCHECK(!IsHeapObjectRequest()); -+ return value_.immediate; -+} -+ -+// ----------------------------------------------------------------------------- -+// RelocInfo. -+ -+void RelocInfo::apply(intptr_t delta) { -+ if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { -+ // Absolute code pointer inside code object moves with the code object. -+ Assembler::RelocateInternalReference(rmode_, pc_, delta); -+ } -+} -+ -+Address RelocInfo::target_address() { -+ DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+Address RelocInfo::target_address_address() { -+ DCHECK(HasTargetAddressAddress()); -+ // Read the address of the word containing the target_address in an -+ // instruction stream. -+ // The only architecture-independent user of this function is the serializer. -+ // The serializer uses it to find out how many raw bytes of instruction to -+ // output before the next target. -+ // For an instruction like LUI/ORI where the target bits are mixed into the -+ // instruction bits, the size of the target will be zero, indicating that the -+ // serializer should not step forward in memory after a target is resolved -+ // and written. In this case the target_address_address function should -+ // return the end of the instructions to be patched, allowing the -+ // deserializer to deserialize the instructions as raw bytes and put them in -+ // place, ready to be patched with the target. After jump optimization, -+ // that is the address of the instruction that follows J/JAL/JR/JALR -+ // instruction. -+ return pc_ + Assembler::kInstructionsFor64BitConstant * kInstrSize; -+} -+ -+Address RelocInfo::constant_pool_entry_address() { UNREACHABLE(); } -+ -+int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } -+ -+void Assembler::deserialization_set_special_target_at( -+ Address instruction_payload, Code code, Address target) { -+ set_target_address_at(instruction_payload, -+ !code.is_null() ? code.constant_pool() : kNullAddress, -+ target); -+} -+ -+int Assembler::deserialization_special_target_size( -+ Address instruction_payload) { -+ return kSpecialTargetSize; -+} -+ -+void Assembler::set_target_internal_reference_encoded_at(Address pc, -+ Address target) { -+ // TODO, see AssembleJumpTable, la64 does not generate internal reference? -+ abort(); -+} -+ -+void Assembler::deserialization_set_target_internal_reference_at( -+ Address pc, Address target, RelocInfo::Mode mode) { -+ if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { -+ DCHECK(IsJ(instr_at(pc))); -+ set_target_internal_reference_encoded_at(pc, target); -+ } else { -+ DCHECK(mode == RelocInfo::INTERNAL_REFERENCE); -+ Memory
(pc) = target; -+ } -+} -+ -+HeapObject RelocInfo::target_object() { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ return HeapObject::cast( -+ Object(Assembler::target_address_at(pc_, constant_pool_))); -+} -+ -+HeapObject RelocInfo::target_object_no_host(Isolate* isolate) { -+ return target_object(); -+} -+ -+Handle RelocInfo::target_object_handle(Assembler* origin) { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ return Handle(reinterpret_cast( -+ Assembler::target_address_at(pc_, constant_pool_))); -+} -+ -+void RelocInfo::set_target_object(Heap* heap, HeapObject target, -+ WriteBarrierMode write_barrier_mode, -+ ICacheFlushMode icache_flush_mode) { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(), -+ icache_flush_mode); -+ if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null() && -+ !FLAG_disable_write_barriers) { -+ WriteBarrierForCode(host(), this, target); -+ } -+} -+ -+Address RelocInfo::target_external_reference() { -+ DCHECK(rmode_ == EXTERNAL_REFERENCE); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+void RelocInfo::set_target_external_reference( -+ Address target, ICacheFlushMode icache_flush_mode) { -+ DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); -+ Assembler::set_target_address_at(pc_, constant_pool_, target, -+ icache_flush_mode); -+} -+ -+Address RelocInfo::target_internal_reference() { -+ if (rmode_ == INTERNAL_REFERENCE) { -+ return Memory
(pc_); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+Address RelocInfo::target_internal_reference_address() { -+ DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); -+ return pc_; -+} -+ -+Address RelocInfo::target_runtime_entry(Assembler* origin) { -+ DCHECK(IsRuntimeEntry(rmode_)); -+ return target_address(); -+} -+ -+void RelocInfo::set_target_runtime_entry(Address target, -+ WriteBarrierMode write_barrier_mode, -+ ICacheFlushMode icache_flush_mode) { -+ DCHECK(IsRuntimeEntry(rmode_)); -+ if (target_address() != target) -+ set_target_address(target, write_barrier_mode, icache_flush_mode); -+} -+ -+Address RelocInfo::target_off_heap_target() { -+ DCHECK(IsOffHeapTarget(rmode_)); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+void RelocInfo::WipeOut() { -+ DCHECK(IsFullEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || -+ IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || -+ IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_) || -+ IsOffHeapTarget(rmode_)); -+ if (IsInternalReference(rmode_)) { -+ Memory
(pc_) = kNullAddress; -+ } else if (IsInternalReferenceEncoded(rmode_)) { -+ Assembler::set_target_internal_reference_encoded_at(pc_, kNullAddress); -+ } else { -+ Assembler::set_target_address_at(pc_, constant_pool_, kNullAddress); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Assembler. -+ -+void Assembler::CheckBuffer() { -+ if (buffer_space() <= kGap) { -+ GrowBuffer(); -+ } -+} -+ -+void Assembler::EmitHelper(Instr x) { -+ *reinterpret_cast(pc_) = x; -+ pc_ += kInstrSize; -+ CheckTrampolinePoolQuick(); -+} -+ -+template <> -+inline void Assembler::EmitHelper(uint8_t x); -+ -+template -+void Assembler::EmitHelper(T x) { -+ *reinterpret_cast(pc_) = x; -+ pc_ += sizeof(x); -+ CheckTrampolinePoolQuick(); -+} -+ -+template <> -+void Assembler::EmitHelper(uint8_t x) { -+ *reinterpret_cast(pc_) = x; -+ pc_ += sizeof(x); -+ if (reinterpret_cast(pc_) % kInstrSize == 0) { -+ CheckTrampolinePoolQuick(); -+ } -+} -+ -+void Assembler::emit(Instr x) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ EmitHelper(x); -+} -+ -+void Assembler::emit(uint64_t data) { -+ // CheckForEmitInForbiddenSlot(); -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ EmitHelper(data); -+} -+ -+EnsureSpace::EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.cc b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.cc -new file mode 100644 -index 000000000..4971eecf6 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.cc -@@ -0,0 +1,2689 @@ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/codegen/loongarch64/assembler-loongarch64.h" -+ -+#include "src/base/cpu.h" -+#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" -+#include "src/codegen/safepoint-table.h" -+#include "src/codegen/string-constants.h" -+#include "src/deoptimizer/deoptimizer.h" -+#include "src/objects/heap-number-inl.h" -+ -+namespace v8 { -+namespace internal { -+ -+void CpuFeatures::ProbeImpl(bool cross_compile) { -+ supported_ |= 1u << FPU; -+ -+ // Only use statically determined features for cross compile (snapshot). -+ if (cross_compile) return; -+ -+#if defined(_loongisa_vec) -+ supported_ |= 0u; -+#endif -+ // If the compiler is allowed to use fpu then we can use fpu too in our -+ // code generation. -+#ifdef __loongarch__ -+ // Probe for additional features at runtime. -+ base::CPU cpu; -+ supported_ |= 0u; -+#endif -+} -+ -+void CpuFeatures::PrintTarget() {} -+void CpuFeatures::PrintFeatures() {} -+ -+int ToNumber(Register reg) { -+ DCHECK(reg.is_valid()); -+ const int kNumbers[] = { -+ 0, // zero_reg -+ 1, // r1 ra -+ 2, // r2 gp -+ 3, // r3 sp -+ 4, // a0 v0 -+ 5, // a1 v1 -+ 6, // a2 -+ 7, // a3 -+ 8, // a4 -+ 9, // a5 -+ 10, // a6 -+ 11, // a7 -+ 12, // t0 -+ 13, // t1 -+ 14, // t2 -+ 15, // t3 -+ 16, // t4 -+ 17, // t5 -+ 18, // t6 -+ 19, // t7 -+ 20, // t8 -+ 21, // tp -+ 22, // fp -+ 23, // s0 -+ 24, // s1 -+ 25, // s2 -+ 26, // s3 -+ 27, // s4 -+ 28, // s5 -+ 29, // s6 -+ 30, // s7 -+ 31, // s8 -+ }; -+ return kNumbers[reg.code()]; -+} -+ -+Register ToRegister(int num) { -+ DCHECK(num >= 0 && num < kNumRegisters); -+ const Register kRegisters[] = { -+ zero_reg, ra, gp, sp, a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, t3, -+ t4, t5, t6, t7, t8, tp, fp, s0, s1, s2, s3, s4, s5, s6, s7, s8}; -+ return kRegisters[num]; -+} -+ -+// ----------------------------------------------------------------------------- -+// Implementation of RelocInfo. -+ -+const int RelocInfo::kApplyMask = -+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | -+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); -+ -+bool RelocInfo::IsCodedSpecially() { -+ // The deserializer needs to know whether a pointer is specially coded. Being -+ // specially coded on loongisa means that it is a lui/ori instruction, and -+ // that is always the case inside code objects. -+ return true; -+} -+ -+bool RelocInfo::IsInConstantPool() { return false; } -+ -+uint32_t RelocInfo::wasm_call_tag() const { -+ DCHECK(rmode_ == WASM_CALL || rmode_ == WASM_STUB_CALL); -+ return static_cast( -+ Assembler::target_address_at(pc_, constant_pool_)); -+} -+ -+// ----------------------------------------------------------------------------- -+// Implementation of Operand and MemOperand. -+// See assembler-la64-inl.h for inlined constructors. -+ -+Operand::Operand(Handle handle) -+ : rm_(no_reg), rmode_(RelocInfo::FULL_EMBEDDED_OBJECT) { -+ value_.immediate = static_cast(handle.address()); -+} -+ -+Operand Operand::EmbeddedNumber(double value) { -+ int32_t smi; -+ if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi)); -+ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); -+ result.is_heap_object_request_ = true; -+ result.value_.heap_object_request = HeapObjectRequest(value); -+ return result; -+} -+ -+Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) { -+ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); -+ result.is_heap_object_request_ = true; -+ result.value_.heap_object_request = HeapObjectRequest(str); -+ return result; -+} -+ -+MemOperand::MemOperand(Register base, int32_t offset) -+ : base_(base), index_(no_reg), offset_(offset) {} -+ -+MemOperand::MemOperand(Register base, Register index) -+ : base_(base), index_(index), offset_(0) {} -+ -+void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { -+ DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty()); -+ for (auto& request : heap_object_requests_) { -+ Handle object; -+ switch (request.kind()) { -+ case HeapObjectRequest::kHeapNumber: -+ object = isolate->factory()->NewHeapNumber( -+ request.heap_number()); -+ break; -+ case HeapObjectRequest::kStringConstant: -+ const StringConstantBase* str = request.string(); -+ CHECK_NOT_NULL(str); -+ object = str->AllocateStringConstant(isolate); -+ break; -+ } -+ Address pc = reinterpret_cast
(buffer_start_) + request.offset(); -+ set_target_value_at(pc, reinterpret_cast(object.location())); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Specific instructions, constants, and masks. -+ -+// addi_d(sp, sp, 8) aka Pop() operation or part of Pop(r) -+// operations as post-increment of sp. -+const Instr kPopInstruction = ADDI_D | (kPointerSize & kImm12Mask) << kRkShift | -+ (sp.code() << kRjShift) | sp.code(); // NOLINT -+// addi_d(sp, sp, -8) part of Push(r) operation as pre-decrement of sp. -+const Instr kPushInstruction = ADDI_D | -+ (-kPointerSize & kImm12Mask) << kRkShift | -+ (sp.code() << kRjShift) | sp.code(); // NOLINT -+// St_d(r, MemOperand(sp, 0)) -+const Instr kPushRegPattern = ST_D | (sp.code() << kRjShift); // NOLINT -+// Ld_d(r, MemOperand(sp, 0)) -+const Instr kPopRegPattern = LD_D | (sp.code() << kRjShift); // NOLINT -+ -+Assembler::Assembler(const AssemblerOptions& options, -+ std::unique_ptr buffer) -+ : AssemblerBase(options, std::move(buffer)), -+ scratch_register_list_(t7.bit() | t6.bit()) { -+ reloc_info_writer.Reposition(buffer_start_ + buffer_->size(), pc_); -+ -+ last_trampoline_pool_end_ = 0; -+ no_trampoline_pool_before_ = 0; -+ trampoline_pool_blocked_nesting_ = 0; -+ // We leave space (16 * kTrampolineSlotsSize) -+ // for BlockTrampolinePoolScope buffer. -+ next_buffer_check_ = FLAG_force_long_branches -+ ? kMaxInt -+ : kMax16BranchOffset - kTrampolineSlotsSize * 16; -+ internal_trampoline_exception_ = false; -+ last_bound_pos_ = 0; -+ -+ trampoline_emitted_ = FLAG_force_long_branches; // TODO remove this -+ unbound_labels_count_ = 0; -+ block_buffer_growth_ = false; -+} -+ -+void Assembler::GetCode(Isolate* isolate, CodeDesc* desc, -+ SafepointTableBuilder* safepoint_table_builder, -+ int handler_table_offset) { -+ // EmitForbiddenSlotInstruction(); // TODO why? -+ -+ int code_comments_size = WriteCodeComments(); -+ -+ DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. -+ -+ AllocateAndInstallRequestedHeapObjects(isolate); -+ -+ // Set up code descriptor. -+ // TODO(jgruber): Reconsider how these offsets and sizes are maintained up to -+ // this point to make CodeDesc initialization less fiddly. -+ -+ static constexpr int kConstantPoolSize = 0; -+ const int instruction_size = pc_offset(); -+ const int code_comments_offset = instruction_size - code_comments_size; -+ const int constant_pool_offset = code_comments_offset - kConstantPoolSize; -+ const int handler_table_offset2 = (handler_table_offset == kNoHandlerTable) -+ ? constant_pool_offset -+ : handler_table_offset; -+ const int safepoint_table_offset = -+ (safepoint_table_builder == kNoSafepointTable) -+ ? handler_table_offset2 -+ : safepoint_table_builder->GetCodeOffset(); -+ const int reloc_info_offset = -+ static_cast(reloc_info_writer.pos() - buffer_->start()); -+ CodeDesc::Initialize(desc, this, safepoint_table_offset, -+ handler_table_offset2, constant_pool_offset, -+ code_comments_offset, reloc_info_offset); -+} -+ -+void Assembler::Align(int m) { -+ DCHECK(m >= 4 && base::bits::IsPowerOfTwo(m)); -+ while ((pc_offset() & (m - 1)) != 0) { -+ nop(); -+ } -+} -+ -+void Assembler::CodeTargetAlign() { -+ // No advantage to aligning branch/call targets to more than -+ // single instruction, that I am aware of. -+ Align(4); -+} -+ -+Register Assembler::GetRkReg(Instr instr) { -+ return Register::from_code((instr & kRkFieldMask) >> kRkShift); -+} -+ -+Register Assembler::GetRjReg(Instr instr) { -+ return Register::from_code((instr & kRjFieldMask) >> kRjShift); -+} -+ -+Register Assembler::GetRdReg(Instr instr) { -+ return Register::from_code((instr & kRdFieldMask) >> kRdShift); -+} -+ -+uint32_t Assembler::GetRk(Instr instr) { -+ return (instr & kRkFieldMask) >> kRkShift; -+} -+ -+uint32_t Assembler::GetRkField(Instr instr) { return instr & kRkFieldMask; } -+ -+uint32_t Assembler::GetRj(Instr instr) { -+ return (instr & kRjFieldMask) >> kRjShift; -+} -+ -+uint32_t Assembler::GetRjField(Instr instr) { return instr & kRjFieldMask; } -+ -+uint32_t Assembler::GetRd(Instr instr) { -+ return (instr & kRdFieldMask) >> kRdShift; -+} -+ -+uint32_t Assembler::GetRdField(Instr instr) { return instr & kRdFieldMask; } -+ -+uint32_t Assembler::GetSa2(Instr instr) { -+ return (instr & kSa2FieldMask) >> kSaShift; -+} -+ -+uint32_t Assembler::GetSa2Field(Instr instr) { return instr & kSa2FieldMask; } -+ -+uint32_t Assembler::GetSa3(Instr instr) { -+ return (instr & kSa3FieldMask) >> kSaShift; -+} -+ -+uint32_t Assembler::GetSa3Field(Instr instr) { return instr & kSa3FieldMask; } -+ -+bool Assembler::IsPop(Instr instr) { -+ return (instr & 0xffc003e0) == kPopRegPattern; -+} -+ -+bool Assembler::IsPush(Instr instr) { -+ return (instr & 0xffc003e0) == kPushRegPattern; -+} -+ -+// Labels refer to positions in the (to be) generated code. -+// There are bound, linked, and unused labels. -+// -+// Bound labels refer to known positions in the already -+// generated code. pos() is the position the label refers to. -+// -+// Linked labels refer to unknown positions in the code -+// to be generated; pos() is the position of the last -+// instruction using the label. -+ -+// The link chain is terminated by a value in the instruction of -1, -+// which is an otherwise illegal value (branch -1 is inf loop). -+// The instruction 16-bit offset field addresses 32-bit words, but in -+// code is conv to an 18-bit value addressing bytes, hence the -4 value. -+ -+const int kEndOfChain = 0; -+// Determines the end of the Jump chain (a subset of the label link chain). -+const int kEndOfJumpChain = 0; -+ -+bool Assembler::IsBranch(Instr instr) { -+ uint32_t opcode = (instr >> 26) << 26; -+ // Checks if the instruction is a branch. -+ bool isBranch = opcode == BEQZ || opcode == BNEZ || opcode == BCZ || -+ opcode == B || opcode == BL || opcode == BEQ || -+ opcode == BNE || opcode == BLT || opcode == BGE || -+ opcode == BLTU || opcode == BGEU; -+ return isBranch; -+} -+ -+bool Assembler::IsB(Instr instr) { -+ uint32_t opcode = (instr >> 26) << 26; -+ // Checks if the instruction is a b. -+ bool isBranch = opcode == B || opcode == BL; -+ return isBranch; -+} -+ -+bool Assembler::IsBz(Instr instr) { -+ uint32_t opcode = (instr >> 26) << 26; -+ // Checks if the instruction is a branch. -+ bool isBranch = opcode == BEQZ || opcode == BNEZ || opcode == BCZ; -+ return isBranch; -+} -+ -+bool Assembler::IsEmittedConstant(Instr instr) { -+ // Add GetLabelConst function? -+ uint32_t label_constant = instr & ~kImm16Mask; -+ return label_constant == 0; // Emitted label const in reg-exp engine. -+} -+ -+bool Assembler::IsJ(Instr instr) { -+ uint32_t opcode = (instr >> 26) << 26; -+ // Checks if the instruction is a jump. -+ return opcode == JIRL; -+} -+ -+bool Assembler::IsLu12i_w(Instr instr) { -+ uint32_t opcode = (instr >> 25) << 25; -+ return opcode == LU12I_W; -+} -+ -+bool Assembler::IsOri(Instr instr) { -+ uint32_t opcode = (instr >> 22) << 22; -+ return opcode == ORI; -+} -+ -+bool Assembler::IsLu32i_d(Instr instr) { -+ uint32_t opcode = (instr >> 25) << 25; -+ return opcode == LU32I_D; -+} -+ -+bool Assembler::IsLu52i_d(Instr instr) { -+ uint32_t opcode = (instr >> 22) << 22; -+ return opcode == LU52I_D; -+} -+ -+bool Assembler::IsMov(Instr instr, Register rd, Register rj) { -+ // Checks if the instruction is a OR with zero_reg argument (aka MOV). -+ Instr instr1 = -+ OR | zero_reg.code() << kRkShift | rj.code() << kRjShift | rd.code(); -+ return instr == instr1; -+} -+ -+bool Assembler::IsPcAddi(Instr instr, Register rd, int32_t si20) { -+ DCHECK(is_int20(si20)); -+ Instr instr1 = PCADDI | (si20 & 0xfffff) << kRjShift | rd.code(); -+ return instr == instr1; -+} -+ -+bool Assembler::IsNop(Instr instr, unsigned int type) { -+ // See Assembler::nop(type). -+ DCHECK_LT(type, 32); -+ // Traditional loongisa nop == andi(zero_reg, zero_reg, 0) -+ // When marking non-zero type, use andi(zero_reg, t7, type) -+ // to avoid use of ssnop and ehb special encodings of the -+ // andi instruction. -+ -+ Register nop_rt_reg = (type == 0) ? zero_reg : t7; -+ Instr instr1 = ANDI | ((type & kImm12Mask) << kRkShift) | -+ (nop_rt_reg.code() << kRjShift); -+ -+ return instr == instr1; -+} -+ -+static inline int32_t GetOffsetOfBranch(Instr instr, -+ Assembler::OffsetSize bits) { -+ int32_t result = 0; -+ if (bits == 16) { -+ result = (instr << 6) >> 16; -+ } else if (bits == 21) { -+ uint32_t low16 = instr << 6; -+ low16 = low16 >> 16; -+ low16 &= 0xffff; -+ int32_t hi5 = (instr << 27) >> 11; -+ result = hi5 | low16; -+ } else { -+ uint32_t low16 = instr << 6; -+ low16 = low16 >> 16; -+ low16 &= 0xffff; -+ int32_t hi10 = (instr << 22) >> 6; -+ result = hi10 | low16; -+ DCHECK_EQ(bits, 26); -+ } -+ return result << 2; -+} -+ -+static Assembler::OffsetSize OffsetSizeInBits(Instr instr) { -+ if (Assembler::IsB(instr)) { -+ return Assembler::OffsetSize::kOffset26; -+ } else if (Assembler::IsBz(instr)) { -+ return Assembler::OffsetSize::kOffset21; -+ } else { -+ DCHECK(Assembler::IsBranch(instr)); -+ return Assembler::OffsetSize::kOffset16; -+ } -+} -+ -+static inline int32_t AddBranchOffset(int pos, Instr instr) { -+ Assembler::OffsetSize bits = OffsetSizeInBits(instr); -+ -+ int32_t imm = GetOffsetOfBranch(instr, bits); -+ -+ if (imm == kEndOfChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or pos. -+ return kEndOfChain; -+ } else { -+ // Handle the case that next branch position is 0. -+ // TODO: Define -4 as a constant -+ int32_t offset = pos + Assembler::kBranchPCOffset + imm; -+ return offset == 0 ? -4 : offset; -+ } -+} -+ -+int Assembler::target_at(int pos, bool is_internal) { -+ if (is_internal) { -+ int64_t* p = reinterpret_cast(buffer_start_ + pos); -+ int64_t address = *p; -+ if (address == kEndOfJumpChain) { -+ return kEndOfChain; -+ } else { -+ int64_t instr_address = reinterpret_cast(p); -+ DCHECK(instr_address - address < INT_MAX); -+ int delta = static_cast(instr_address - address); -+ DCHECK(pos > delta); -+ return pos - delta; -+ } -+ } -+ Instr instr = instr_at(pos); -+ -+ // TODO remove after remove label_at_put? -+ if ((instr & ~kImm16Mask) == 0) { -+ // Emitted label constant, not part of a branch. -+ if (instr == 0) { -+ return kEndOfChain; -+ } else { -+ int32_t imm18 = ((instr & static_cast(kImm16Mask)) << 16) >> 14; -+ return (imm18 + pos); -+ } -+ } -+ -+ // Check we have a branch or jump instruction. -+ DCHECK(IsBranch(instr) || IsJ(instr) || IsLu12i_w(instr) || -+ IsPcAddi(instr, t8, 16)); -+ // Do NOT change this to <<2. We rely on arithmetic shifts here, assuming -+ // the compiler uses arithmetic shifts for signed integers. -+ if (IsBranch(instr)) { -+ return AddBranchOffset(pos, instr); -+ } else if (IsPcAddi(instr, t8, 16)) { -+ // see BranchLong(Label* L) and BranchAndLinkLong ?? -+ int32_t imm32; -+ Instr instr_lu12i_w = instr_at(pos + 1 * kInstrSize); -+ Instr instr_ori = instr_at(pos + 2 * kInstrSize); -+ DCHECK(IsLu12i_w(instr_lu12i_w)); -+ // DCHECK(IsOri(instr_ori)); -+ imm32 = ((instr_lu12i_w >> 5) & 0xfffff) << 12; -+ imm32 |= ((instr_ori >> 10) & static_cast(kImm12Mask)); -+ if (imm32 == kEndOfJumpChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or pos. -+ return kEndOfChain; -+ } -+ return pos + imm32; -+ } else if (IsLu12i_w(instr)) { -+ abort(); -+ // TODO no used?? -+ /* Instr instr_lui = instr_at(pos + 0 * kInstrSize); -+ Instr instr_ori = instr_at(pos + 1 * kInstrSize); -+ Instr instr_ori2 = instr_at(pos + 3 * kInstrSize); -+ DCHECK(IsOri(instr_ori)); -+ DCHECK(IsOri(instr_ori2)); -+ -+ // TODO(plind) create named constants for shift values. -+ int64_t imm = static_cast(instr_lui & kImm16Mask) << 48; -+ imm |= static_cast(instr_ori & kImm16Mask) << 32; -+ imm |= static_cast(instr_ori2 & kImm16Mask) << 16; -+ // Sign extend address; -+ imm >>= 16; -+ -+ if (imm == kEndOfJumpChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or -+ pos. return kEndOfChain; } else { uint64_t instr_address = -+ reinterpret_cast(buffer_start_ + pos); DCHECK(instr_address - -+ imm < INT_MAX); int delta = static_cast(instr_address - imm); -+ DCHECK(pos > delta); -+ return pos - delta; -+ }*/ -+ } else { -+ DCHECK(IsJ(instr)); -+ // TODO not used??? -+ abort(); -+ } -+} -+ -+static inline Instr SetBranchOffset(int32_t pos, int32_t target_pos, -+ Instr instr) { -+ int32_t bits = OffsetSizeInBits(instr); -+ int32_t imm = target_pos - pos; -+ DCHECK_EQ(imm & 3, 0); -+ imm >>= 2; -+ -+ DCHECK(is_intn(imm, bits)); -+ -+ if (bits == 16) { -+ const int32_t mask = ((1 << 16) - 1) << 10; -+ instr &= ~mask; -+ return instr | ((imm << 10) & mask); -+ } else if (bits == 21) { -+ const int32_t mask = 0x3fffc1f; -+ instr &= ~mask; -+ uint32_t low16 = (imm & kImm16Mask) << 10; -+ int32_t hi5 = (imm >> 16) & 0x1f; -+ return instr | low16 | hi5; -+ } else { -+ DCHECK_EQ(bits, 26); -+ const int32_t mask = 0x3ffffff; -+ instr &= ~mask; -+ uint32_t low16 = (imm & kImm16Mask) << 10; -+ int32_t hi10 = (imm >> 16) & 0x3ff; -+ return instr | low16 | hi10; -+ } -+} -+ -+void Assembler::target_at_put(int pos, int target_pos, bool is_internal) { -+ if (is_internal) { -+ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; -+ *reinterpret_cast(buffer_start_ + pos) = imm; -+ return; -+ } -+ Instr instr = instr_at(pos); -+ if ((instr & ~kImm16Mask) == 0) { -+ DCHECK(target_pos == kEndOfChain || target_pos >= 0); -+ // Emitted label constant, not part of a branch. -+ // Make label relative to Code pointer of generated Code object. -+ instr_at_put(pos, target_pos + (Code::kHeaderSize - kHeapObjectTag)); -+ return; -+ } -+ -+ if (IsBranch(instr)) { -+ instr = SetBranchOffset(pos, target_pos, instr); -+ instr_at_put(pos, instr); -+ } else if (0 == 1 /*IsLui(instr)*/) { -+ /* if (IsPcAddi(instr, t8, 16)) { -+ Instr instr_lui = instr_at(pos + 0 * kInstrSize); -+ Instr instr_ori = instr_at(pos + 2 * kInstrSize); -+ DCHECK(IsLui(instr_lui)); -+ DCHECK(IsOri(instr_ori)); -+ int32_t imm = target_pos - (pos + Assembler::kLongBranchPCOffset); -+ DCHECK_EQ(imm & 3, 0); -+ if (is_int16(imm + Assembler::kLongBranchPCOffset - -+ Assembler::kBranchPCOffset)) { -+ // Optimize by converting to regular branch and link with 16-bit -+ // offset. -+ Instr instr_b = REGIMM | BGEZAL; // Branch and link. -+ instr_b = SetBranchOffset(pos, target_pos, instr_b); -+ // Correct ra register to point to one instruction after jalr from -+ // TurboAssembler::BranchAndLinkLong. -+ Instr instr_a = DADDIU | ra.code() << kRsShift | ra.code() << kRtShift -+ | kOptimizedBranchAndLinkLongReturnOffset; -+ -+ instr_at_put(pos, instr_b); -+ instr_at_put(pos + 1 * kInstrSize, instr_a); -+ } else { -+ instr_lui &= ~kImm16Mask; -+ instr_ori &= ~kImm16Mask; -+ -+ instr_at_put(pos + 0 * kInstrSize, -+ instr_lui | ((imm >> kLuiShift) & kImm16Mask)); -+ instr_at_put(pos + 2 * kInstrSize, instr_ori | (imm & kImm16Mask)); -+ } -+ } else { -+ Instr instr_lui = instr_at(pos + 0 * kInstrSize); -+ Instr instr_ori = instr_at(pos + 1 * kInstrSize); -+ Instr instr_ori2 = instr_at(pos + 3 * kInstrSize); -+ DCHECK(IsOri(instr_ori)); -+ DCHECK(IsOri(instr_ori2)); -+ -+ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; -+ DCHECK_EQ(imm & 3, 0); -+ -+ instr_lui &= ~kImm16Mask; -+ instr_ori &= ~kImm16Mask; -+ instr_ori2 &= ~kImm16Mask; -+ -+ instr_at_put(pos + 0 * kInstrSize, -+ instr_lui | ((imm >> 32) & kImm16Mask)); -+ instr_at_put(pos + 1 * kInstrSize, -+ instr_ori | ((imm >> 16) & kImm16Mask)); -+ instr_at_put(pos + 3 * kInstrSize, instr_ori2 | (imm & kImm16Mask)); -+ }*/ -+ } else if (IsPcAddi(instr, t8, 16)) { -+ abort(); /* -+ Instr instr_lu12i_w = instr_at(pos + 1 * kInstrSize); -+ Instr instr_ori = instr_at(pos + 2 * kInstrSize); -+ DCHECK(IsLu12i_w(instr_lu12i_w)); -+ //DCHECK(IsOri(instr_ori)); -+ -+ int32_t imm_short = target_pos - (pos + Assembler::kBranchPCOffset); -+ -+ if (is_int21(imm_short)) { -+ // Optimize by converting to regular branch with 21-bit -+ // offset -+ Instr instr_b = B; -+ instr_b = SetBranchOffset(pos, target_pos, instr_b); -+ -+ instr_at_put(pos, instr_b); -+ } else { -+ int32_t imm = target_pos - (pos + Assembler::kLongBranchPCOffset); -+ DCHECK_EQ(imm & 3, 0); -+ -+ instr_lu12i_w &= 0xfe00001fu; // opcode:7 | bit20 | rd:5 -+ instr_ori &= 0xffc003ffu; // opcode:10 | bit12 | rj:5 | rd:5 -+ -+ instr_at_put(pos + 1 * kInstrSize, -+ instr_lu12i_w | (((imm >> 12) & 0xfffff) << 5)); -+ instr_at_put(pos + 2 * kInstrSize, instr_ori | -+ ((imm & 0xfff) << 10)); -+ }*/ -+ } else if (IsJ(instr)) { -+ /* -+ int32_t imm28 = target_pos - pos; -+ DCHECK_EQ(imm28 & 3, 0); -+ -+ uint32_t imm26 = static_cast(imm28 >> 2); -+ DCHECK(is_uint26(imm26)); -+ // Place 26-bit signed offset with markings. -+ // When code is committed it will be resolved to j/jal. -+ int32_t mark = IsJ(instr) ? kJRawMark : kJalRawMark; -+ instr_at_put(pos, mark | (imm26 & kImm26Mask));*/ -+ abort(); -+ } else { -+ /* int32_t imm28 = target_pos - pos; -+ DCHECK_EQ(imm28 & 3, 0); -+ -+ uint32_t imm26 = static_cast(imm28 >> 2); -+ DCHECK(is_uint26(imm26)); -+ // Place raw 26-bit signed offset. -+ // When code is committed it will be resolved to j/jal. -+ instr &= ~kImm26Mask; -+ instr_at_put(pos, instr | (imm26 & kImm26Mask));*/ -+ abort(); -+ } -+} -+ -+void Assembler::print(const Label* L) { -+ if (L->is_unused()) { -+ PrintF("unused label\n"); -+ } else if (L->is_bound()) { -+ PrintF("bound label to %d\n", L->pos()); -+ } else if (L->is_linked()) { -+ Label l; -+ l.link_to(L->pos()); -+ PrintF("unbound label"); -+ while (l.is_linked()) { -+ PrintF("@ %d ", l.pos()); -+ Instr instr = instr_at(l.pos()); -+ if ((instr & ~kImm16Mask) == 0) { -+ PrintF("value\n"); -+ } else { -+ PrintF("%d\n", instr); -+ } -+ next(&l, is_internal_reference(&l)); -+ } -+ } else { -+ PrintF("label in inconsistent state (pos = %d)\n", L->pos_); -+ } -+} -+ -+void Assembler::bind_to(Label* L, int pos) { -+ DCHECK(0 <= pos && pos <= pc_offset()); // Must have valid binding position. -+ int trampoline_pos = kInvalidSlotPos; -+ bool is_internal = false; -+ if (L->is_linked() && !trampoline_emitted_) { -+ unbound_labels_count_--; -+ if (!is_internal_reference(L)) { -+ next_buffer_check_ += kTrampolineSlotsSize; -+ } -+ } -+ -+ while (L->is_linked()) { -+ int fixup_pos = L->pos(); -+ int dist = pos - fixup_pos; -+ is_internal = is_internal_reference(L); -+ next(L, is_internal); // Call next before overwriting link with target at -+ // fixup_pos. -+ Instr instr = instr_at(fixup_pos); -+ if (is_internal) { -+ target_at_put(fixup_pos, pos, is_internal); -+ } else { -+ if (IsBranch(instr)) { -+ int branch_offset = BranchOffset(instr); -+ if (dist > branch_offset) { -+ if (trampoline_pos == kInvalidSlotPos) { -+ trampoline_pos = get_trampoline_entry(fixup_pos); -+ CHECK_NE(trampoline_pos, kInvalidSlotPos); -+ } -+ CHECK((trampoline_pos - fixup_pos) <= branch_offset); -+ target_at_put(fixup_pos, trampoline_pos, false); -+ fixup_pos = trampoline_pos; -+ } -+ target_at_put(fixup_pos, pos, false); -+ } else { -+ DCHECK(IsJ(instr) || IsLu12i_w(instr) || IsEmittedConstant(instr) || -+ IsPcAddi(instr, t8, 8)); -+ target_at_put(fixup_pos, pos, false); -+ } -+ } -+ } -+ L->bind_to(pos); -+ -+ // Keep track of the last bound label so we don't eliminate any instructions -+ // before a bound label. -+ if (pos > last_bound_pos_) last_bound_pos_ = pos; -+} -+ -+void Assembler::bind(Label* L) { -+ DCHECK(!L->is_bound()); // Label can only be bound once. -+ bind_to(L, pc_offset()); -+} -+ -+void Assembler::next(Label* L, bool is_internal) { -+ DCHECK(L->is_linked()); -+ int link = target_at(L->pos(), is_internal); -+ if (link == kEndOfChain) { -+ L->Unuse(); -+ } else if (link == -4) { -+ // Next position is pc_offset == 0 -+ L->link_to(0); -+ } else { -+ DCHECK_GE(link, 0); -+ L->link_to(link); -+ } -+} -+ -+bool Assembler::is_near_c(Label* L) { -+ DCHECK(L->is_bound()); -+ return pc_offset() - L->pos() < kMax16BranchOffset - 4 * kInstrSize; -+} -+ -+bool Assembler::is_near(Label* L, OffsetSize bits) { -+ DCHECK(L->is_bound()); -+ return ((pc_offset() - L->pos()) < -+ (1 << (bits + 2 - 1)) - 1 - 5 * kInstrSize); -+} -+ -+bool Assembler::is_near_a(Label* L) { -+ DCHECK(L->is_bound()); -+ return pc_offset() - L->pos() <= kMax26BranchOffset - 4 * kInstrSize; -+} -+ -+int Assembler::BranchOffset(Instr instr) { -+ int bits = OffsetSize::kOffset16; -+ -+ uint32_t opcode = (instr >> 26) << 26; -+ switch (opcode) { -+ case B: -+ case BL: -+ bits = OffsetSize::kOffset26; -+ break; -+ case BNEZ: -+ case BEQZ: -+ case BCZ: -+ bits = OffsetSize::kOffset21; -+ break; -+ case BNE: -+ case BEQ: -+ case BLT: -+ case BGE: -+ case BLTU: -+ case BGEU: -+ case JIRL: -+ bits = OffsetSize::kOffset16; -+ break; -+ default: -+ break; -+ } -+ -+ return (1 << (bits + 2 - 1)) - 1; -+} -+ -+// We have to use a temporary register for things that can be relocated even -+// if they can be encoded in the LA's 16 bits of immediate-offset instruction -+// space. There is no guarantee that the relocated location can be similarly -+// encoded. -+bool Assembler::MustUseReg(RelocInfo::Mode rmode) { -+ return !RelocInfo::IsNone(rmode); -+} -+ -+void Assembler::GenB(Opcode opcode, Register rj, int32_t si21) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK((BEQZ == opcode || BNEZ == opcode) && is_int21(si21) && rj.is_valid()); -+ Instr instr = opcode | (si21 & kImm16Mask) << kRkShift | -+ (rj.code() << kRjShift) | ((si21 & 0x1fffff) >> 16); -+ emit(instr); -+} -+ -+void Assembler::GenB(Opcode opcode, CFRegister cj, int32_t si21, bool isEq) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(BCZ == opcode && is_int21(si21)); -+ DCHECK(cj >= 0 && cj <= 7); -+ int32_t sc = (isEq ? cj : cj + 8); -+ Instr instr = opcode | (si21 & kImm16Mask) << kRkShift | (sc << kRjShift) | -+ ((si21 & 0x1fffff) >> 16); -+ emit(instr); -+} -+ -+void Assembler::GenB(Opcode opcode, int32_t si26) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK((B == opcode || BL == opcode) && is_int26(si26)); -+ Instr instr = -+ opcode | ((si26 & kImm16Mask) << kRkShift) | ((si26 & kImm26Mask) >> 16); -+ emit(instr); -+} -+ -+void Assembler::GenBJ(Opcode opcode, Register rj, Register rd, int32_t si16) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(is_int16(si16)); -+ Instr instr = opcode | ((si16 & kImm16Mask) << kRkShift) | -+ (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenCmp(Opcode opcode, FPUCondition cond, FPURegister fk, -+ FPURegister fj, CFRegister cd) { -+ DCHECK(opcode == FCMP_COND_S || opcode == FCMP_COND_D); -+ Instr instr = opcode | cond << kCondShift | (fk.code() << kFkShift) | -+ (fj.code() << kFjShift) | cd; -+ emit(instr); -+} -+ -+void Assembler::GenSel(Opcode opcode, CFRegister ca, FPURegister fk, -+ FPURegister fj, FPURegister rd) { -+ DCHECK((opcode == FSEL)); -+ Instr instr = opcode | ca << kCondShift | (fk.code() << kFkShift) | -+ (fj.code() << kFjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rj, Register rd, -+ bool rjrd) { -+ DCHECK(rjrd); -+ Instr instr = 0; -+ instr = opcode | (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPURegister fj, FPURegister fd) { -+ Instr instr = opcode | (fj.code() << kFjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rj, FPURegister fd) { -+ DCHECK((opcode == MOVGR2FR_W) || (opcode == MOVGR2FR_D) || -+ (opcode == MOVGR2FRH_W)); -+ Instr instr = opcode | (rj.code() << kRjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPURegister fj, Register rd) { -+ DCHECK((opcode == MOVFR2GR_S) || (opcode == MOVFR2GR_D) || -+ (opcode == MOVFRH2GR_S)); -+ Instr instr = opcode | (fj.code() << kFjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rj, FPUControlRegister fd) { -+ DCHECK((opcode == MOVGR2FCSR)); -+ Instr instr = opcode | (rj.code() << kRjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPUControlRegister fj, Register rd) { -+ DCHECK((opcode == MOVFCSR2GR)); -+ Instr instr = opcode | (fj.code() << kFjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPURegister fj, CFRegister cd) { -+ DCHECK((opcode == MOVFR2CF)); -+ Instr instr = opcode | (fj.code() << kFjShift) | cd; -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, CFRegister cj, FPURegister fd) { -+ DCHECK((opcode == MOVCF2FR)); -+ Instr instr = opcode | cj << kFjShift | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rj, CFRegister cd) { -+ DCHECK((opcode == MOVGR2CF)); -+ Instr instr = opcode | (rj.code() << kRjShift) | cd; -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, CFRegister cj, Register rd) { -+ DCHECK((opcode == MOVCF2GR)); -+ Instr instr = opcode | cj << kFjShift | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rk, Register rj, -+ Register rd) { -+ Instr instr = -+ opcode | (rk.code() << kRkShift) | (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPURegister fk, FPURegister fj, -+ FPURegister fd) { -+ Instr instr = -+ opcode | (fk.code() << kFkShift) | (fj.code() << kFjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, FPURegister fa, FPURegister fk, -+ FPURegister fj, FPURegister fd) { -+ Instr instr = opcode | (fa.code() << kFaShift) | (fk.code() << kFkShift) | -+ (fj.code() << kFjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenRegister(Opcode opcode, Register rk, Register rj, -+ FPURegister fd) { -+ Instr instr = -+ opcode | (rk.code() << kRkShift) | (rj.code() << kRjShift) | fd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t bit3, Register rk, Register rj, -+ Register rd) { -+ DCHECK(is_uint3(bit3)); -+ Instr instr = opcode | (bit3 & 0x7) << kSaShift | (rk.code() << kRkShift) | -+ (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t bit6m, int32_t bit6l, Register rj, -+ Register rd) { -+ DCHECK(is_uint6(bit6m) && is_uint6(bit6l)); -+ Instr instr = opcode | (bit6m & 0x3f) << 16 | (bit6l & 0x3f) << kRkShift | -+ (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t bit20, Register rd) { -+ // DCHECK(is_uint20(bit20) || is_int20(bit20)); -+ Instr instr = opcode | (bit20 & 0xfffff) << kRjShift | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t bit15) { -+ DCHECK(is_uint15(bit15)); -+ Instr instr = opcode | (bit15 & 0x7fff); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t value, Register rj, Register rd, -+ int32_t value_bits) { -+ DCHECK(value_bits == 6 || value_bits == 12 || value_bits == 14 || -+ value_bits == 16); -+ uint32_t imm = value & 0x3f; -+ if (value_bits == 12) { -+ imm = value & kImm12Mask; -+ } else if (value_bits == 14) { -+ imm = value & 0x3fff; -+ } else if (value_bits == 16) { -+ imm = value & kImm16Mask; -+ } -+ Instr instr = opcode | imm << kRkShift | (rj.code() << kRjShift) | rd.code(); -+ emit(instr); -+} -+ -+void Assembler::GenImm(Opcode opcode, int32_t bit12, Register rj, -+ FPURegister fd) { -+ DCHECK(is_int12(bit12)); -+ Instr instr = opcode | ((bit12 & kImm12Mask) << kRkShift) | -+ (rj.code() << kRjShift) | fd.code(); -+ emit(instr); -+} -+ -+// Returns the next free trampoline entry. -+int32_t Assembler::get_trampoline_entry(int32_t pos) { -+ int32_t trampoline_entry = kInvalidSlotPos; -+ if (!internal_trampoline_exception_) { -+ if (trampoline_.start() > pos) { -+ trampoline_entry = trampoline_.take_slot(); -+ } -+ -+ if (kInvalidSlotPos == trampoline_entry) { -+ internal_trampoline_exception_ = true; -+ } -+ } -+ return trampoline_entry; -+} -+ -+uint64_t Assembler::jump_address(Label* L) { -+ int64_t target_pos; -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ L->link_to(pc_offset()); -+ } else { -+ L->link_to(pc_offset()); -+ return kEndOfJumpChain; -+ } -+ } -+ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; -+ DCHECK_EQ(imm & 3, 0); -+ -+ return imm; -+} -+ -+uint64_t Assembler::branch_long_offset(Label* L) { -+ int64_t target_pos; -+ -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ L->link_to(pc_offset()); -+ } else { -+ L->link_to(pc_offset()); -+ return kEndOfJumpChain; -+ } -+ } -+ int64_t offset = target_pos - (pc_offset() + kLongBranchPCOffset); -+ DCHECK_EQ(offset & 3, 0); -+ -+ return static_cast(offset); -+} -+ -+int32_t Assembler::branch_offset_helper(Label* L, OffsetSize bits) { -+ int32_t target_pos; -+ -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); -+ L->link_to(pc_offset()); -+ } else { -+ L->link_to(pc_offset()); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ return kEndOfChain; -+ } -+ } -+ -+ int32_t offset = target_pos - (pc_offset() + kBranchPCOffset); -+ DCHECK(is_intn(offset, bits + 2)); -+ DCHECK_EQ(offset & 3, 0); -+ -+ return offset; -+} -+ -+void Assembler::label_at_put(Label* L, int at_offset) { -+ int target_pos; -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ instr_at_put(at_offset, target_pos + (Code::kHeaderSize - kHeapObjectTag)); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ int32_t imm18 = target_pos - at_offset; -+ DCHECK_EQ(imm18 & 3, 0); -+ int32_t imm16 = imm18 >> 2; -+ DCHECK(is_int16(imm16)); -+ instr_at_put(at_offset, (imm16 & kImm16Mask)); -+ } else { -+ target_pos = kEndOfChain; -+ instr_at_put(at_offset, 0); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ } -+ L->link_to(at_offset); -+ } -+ // TODO PushBackTrack() -+} -+ -+//------- Branch and jump instructions -------- -+ -+void Assembler::b(int32_t offset) { GenB(B, offset); } -+ -+void Assembler::bl(int32_t offset) { GenB(BL, offset); } -+ -+void Assembler::beq(Register rj, Register rd, int32_t offset) { -+ GenBJ(BEQ, rj, rd, offset); -+} -+ -+void Assembler::bne(Register rj, Register rd, int32_t offset) { -+ GenBJ(BNE, rj, rd, offset); -+} -+ -+void Assembler::blt(Register rj, Register rd, int32_t offset) { -+ GenBJ(BLT, rj, rd, offset); -+} -+ -+void Assembler::bge(Register rj, Register rd, int32_t offset) { -+ GenBJ(BGE, rj, rd, offset); -+} -+ -+void Assembler::bltu(Register rj, Register rd, int32_t offset) { -+ GenBJ(BLTU, rj, rd, offset); -+} -+ -+void Assembler::bgeu(Register rj, Register rd, int32_t offset) { -+ GenBJ(BGEU, rj, rd, offset); -+} -+ -+void Assembler::beqz(Register rj, int32_t offset) { GenB(BEQZ, rj, offset); } -+void Assembler::bnez(Register rj, int32_t offset) { GenB(BNEZ, rj, offset); } -+ -+void Assembler::jirl(Register rd, Register rj, int32_t offset) { -+ GenBJ(JIRL, rj, rd, offset); -+} -+ -+void Assembler::bceqz(CFRegister cj, int32_t si21) { -+ GenB(BCZ, cj, si21, true); -+} -+ -+void Assembler::bcnez(CFRegister cj, int32_t si21) { -+ GenB(BCZ, cj, si21, false); -+} -+ -+// -------Data-processing-instructions--------- -+ -+// Arithmetic. -+void Assembler::add_w(Register rd, Register rj, Register rk) { -+ GenRegister(ADD_W, rk, rj, rd); -+} -+ -+void Assembler::add_d(Register rd, Register rj, Register rk) { -+ GenRegister(ADD_D, rk, rj, rd); -+} -+ -+void Assembler::sub_w(Register rd, Register rj, Register rk) { -+ GenRegister(SUB_W, rk, rj, rd); -+} -+ -+void Assembler::sub_d(Register rd, Register rj, Register rk) { -+ GenRegister(SUB_D, rk, rj, rd); -+} -+ -+void Assembler::addi_w(Register rd, Register rj, int32_t si12) { -+ GenImm(ADDI_W, si12, rj, rd, 12); -+} -+ -+void Assembler::addi_d(Register rd, Register rj, int32_t si12) { -+ GenImm(ADDI_D, si12, rj, rd, 12); -+} -+ -+void Assembler::addu16i_d(Register rd, Register rj, int32_t si16) { -+ GenImm(ADDU16I_D, si16, rj, rd, 16); -+} -+ -+void Assembler::alsl_w(Register rd, Register rj, Register rk, int32_t sa2) { -+ DCHECK(is_uint2(sa2 - 1)); -+ GenImm(ALSL_W, sa2 - 1, rk, rj, rd); -+} -+ -+void Assembler::alsl_wu(Register rd, Register rj, Register rk, int32_t sa2) { -+ DCHECK(is_uint2(sa2 - 1)); -+ GenImm(ALSL_WU, sa2 + 3, rk, rj, rd); -+} -+ -+void Assembler::alsl_d(Register rd, Register rj, Register rk, int32_t sa2) { -+ DCHECK(is_uint2(sa2 - 1)); -+ GenImm(ALSL_D, sa2 - 1, rk, rj, rd); -+} -+ -+void Assembler::lu12i_w(Register rd, int32_t si20) { -+ GenImm(LU12I_W, si20, rd); -+} -+ -+void Assembler::lu32i_d(Register rd, int32_t si20) { -+ GenImm(LU32I_D, si20, rd); -+} -+ -+void Assembler::lu52i_d(Register rd, Register rj, int32_t si12) { -+ GenImm(LU52I_D, si12, rj, rd, 12); -+} -+ -+void Assembler::slt(Register rd, Register rj, Register rk) { -+ GenRegister(SLT, rk, rj, rd); -+} -+ -+void Assembler::sltu(Register rd, Register rj, Register rk) { -+ GenRegister(SLTU, rk, rj, rd); -+} -+ -+void Assembler::slti(Register rd, Register rj, int32_t si12) { -+ GenImm(SLTI, si12, rj, rd, 12); -+} -+ -+void Assembler::sltui(Register rd, Register rj, int32_t si12) { -+ GenImm(SLTUI, si12, rj, rd, 12); -+} -+ -+void Assembler::pcaddi(Register rd, int32_t si20) { GenImm(PCADDI, si20, rd); } -+ -+void Assembler::pcaddu12i(Register rd, int32_t si20) { -+ GenImm(PCADDU12I, si20, rd); -+} -+ -+void Assembler::pcaddu18i(Register rd, int32_t si20) { -+ GenImm(PCADDU18I, si20, rd); -+} -+ -+void Assembler::pcalau12i(Register rd, int32_t si20) { -+ GenImm(PCALAU12I, si20, rd); -+} -+ -+void Assembler::and_(Register rd, Register rj, Register rk) { -+ GenRegister(AND, rk, rj, rd); -+} -+ -+void Assembler::or_(Register rd, Register rj, Register rk) { -+ GenRegister(OR, rk, rj, rd); -+} -+ -+void Assembler::xor_(Register rd, Register rj, Register rk) { -+ GenRegister(XOR, rk, rj, rd); -+} -+ -+void Assembler::nor(Register rd, Register rj, Register rk) { -+ GenRegister(NOR, rk, rj, rd); -+} -+ -+void Assembler::andn(Register rd, Register rj, Register rk) { -+ GenRegister(ANDN, rk, rj, rd); -+} -+ -+void Assembler::orn(Register rd, Register rj, Register rk) { -+ GenRegister(ORN, rk, rj, rd); -+} -+ -+void Assembler::andi(Register rd, Register rj, int32_t ui12) { -+ GenImm(ANDI, ui12, rj, rd, 12); -+} -+ -+void Assembler::ori(Register rd, Register rj, int32_t ui12) { -+ GenImm(ORI, ui12, rj, rd, 12); -+} -+ -+void Assembler::xori(Register rd, Register rj, int32_t ui12) { -+ GenImm(XORI, ui12, rj, rd, 12); -+} -+ -+void Assembler::mul_w(Register rd, Register rj, Register rk) { -+ GenRegister(MUL_W, rk, rj, rd); -+} -+ -+void Assembler::mulh_w(Register rd, Register rj, Register rk) { -+ GenRegister(MULH_W, rk, rj, rd); -+} -+ -+void Assembler::mulh_wu(Register rd, Register rj, Register rk) { -+ GenRegister(MULH_WU, rk, rj, rd); -+} -+ -+void Assembler::mul_d(Register rd, Register rj, Register rk) { -+ GenRegister(MUL_D, rk, rj, rd); -+} -+ -+void Assembler::mulh_d(Register rd, Register rj, Register rk) { -+ GenRegister(MULH_D, rk, rj, rd); -+} -+ -+void Assembler::mulh_du(Register rd, Register rj, Register rk) { -+ GenRegister(MULH_DU, rk, rj, rd); -+} -+ -+void Assembler::mulw_d_w(Register rd, Register rj, Register rk) { -+ GenRegister(MULW_D_W, rk, rj, rd); -+} -+ -+void Assembler::mulw_d_wu(Register rd, Register rj, Register rk) { -+ GenRegister(MULW_D_WU, rk, rj, rd); -+} -+ -+void Assembler::div_w(Register rd, Register rj, Register rk) { -+ GenRegister(DIV_W, rk, rj, rd); -+} -+ -+void Assembler::mod_w(Register rd, Register rj, Register rk) { -+ GenRegister(MOD_W, rk, rj, rd); -+} -+ -+void Assembler::div_wu(Register rd, Register rj, Register rk) { -+ GenRegister(DIV_WU, rk, rj, rd); -+} -+ -+void Assembler::mod_wu(Register rd, Register rj, Register rk) { -+ GenRegister(MOD_WU, rk, rj, rd); -+} -+ -+void Assembler::div_d(Register rd, Register rj, Register rk) { -+ GenRegister(DIV_D, rk, rj, rd); -+} -+ -+void Assembler::mod_d(Register rd, Register rj, Register rk) { -+ GenRegister(MOD_D, rk, rj, rd); -+} -+ -+void Assembler::div_du(Register rd, Register rj, Register rk) { -+ GenRegister(DIV_DU, rk, rj, rd); -+} -+ -+void Assembler::mod_du(Register rd, Register rj, Register rk) { -+ GenRegister(MOD_DU, rk, rj, rd); -+} -+ -+// Shifts. -+void Assembler::sll_w(Register rd, Register rj, Register rk) { -+ GenRegister(SLL_W, rk, rj, rd); -+} -+ -+void Assembler::srl_w(Register rd, Register rj, Register rk) { -+ GenRegister(SRL_W, rk, rj, rd); -+} -+ -+void Assembler::sra_w(Register rd, Register rj, Register rk) { -+ GenRegister(SRA_W, rk, rj, rd); -+} -+ -+void Assembler::rotr_w(Register rd, Register rj, Register rk) { -+ GenRegister(ROTR_W, rk, rj, rd); -+} -+ -+void Assembler::slli_w(Register rd, Register rj, int32_t ui5) { -+ DCHECK(is_uint5(ui5)); -+ GenImm(SLLI_W, ui5 + 0x20, rj, rd, 6); -+} -+ -+void Assembler::srli_w(Register rd, Register rj, int32_t ui5) { -+ DCHECK(is_uint5(ui5)); -+ GenImm(SRLI_W, ui5 + 0x20, rj, rd, 6); -+} -+ -+void Assembler::srai_w(Register rd, Register rj, int32_t ui5) { -+ DCHECK(is_uint5(ui5)); -+ GenImm(SRAI_W, ui5 + 0x20, rj, rd, 6); -+} -+ -+void Assembler::rotri_w(Register rd, Register rj, int32_t ui5) { -+ DCHECK(is_uint5(ui5)); -+ GenImm(ROTRI_W, ui5 + 0x20, rj, rd, 6); -+} -+ -+void Assembler::sll_d(Register rd, Register rj, Register rk) { -+ GenRegister(SLL_D, rk, rj, rd); -+} -+ -+void Assembler::srl_d(Register rd, Register rj, Register rk) { -+ GenRegister(SRL_D, rk, rj, rd); -+} -+ -+void Assembler::sra_d(Register rd, Register rj, Register rk) { -+ GenRegister(SRA_D, rk, rj, rd); -+} -+ -+void Assembler::rotr_d(Register rd, Register rj, Register rk) { -+ GenRegister(ROTR_D, rk, rj, rd); -+} -+ -+void Assembler::slli_d(Register rd, Register rj, int32_t ui6) { -+ GenImm(SLLI_D, ui6, rj, rd, 6); -+} -+ -+void Assembler::srli_d(Register rd, Register rj, int32_t ui6) { -+ GenImm(SRLI_D, ui6, rj, rd, 6); -+} -+ -+void Assembler::srai_d(Register rd, Register rj, int32_t ui6) { -+ GenImm(SRAI_D, ui6, rj, rd, 6); -+} -+ -+void Assembler::rotri_d(Register rd, Register rj, int32_t ui6) { -+ GenImm(ROTRI_D, ui6, rj, rd, 6); -+} -+ -+// Bit twiddling. -+void Assembler::ext_w_b(Register rd, Register rj) { -+ GenRegister(EXT_W_B, rj, rd); -+} -+ -+void Assembler::ext_w_h(Register rd, Register rj) { -+ GenRegister(EXT_W_H, rj, rd); -+} -+ -+void Assembler::clo_w(Register rd, Register rj) { GenRegister(CLO_W, rj, rd); } -+ -+void Assembler::clz_w(Register rd, Register rj) { GenRegister(CLZ_W, rj, rd); } -+ -+void Assembler::cto_w(Register rd, Register rj) { GenRegister(CTO_W, rj, rd); } -+ -+void Assembler::ctz_w(Register rd, Register rj) { GenRegister(CTZ_W, rj, rd); } -+ -+void Assembler::clo_d(Register rd, Register rj) { GenRegister(CLO_D, rj, rd); } -+ -+void Assembler::clz_d(Register rd, Register rj) { GenRegister(CLZ_D, rj, rd); } -+ -+void Assembler::cto_d(Register rd, Register rj) { GenRegister(CTO_D, rj, rd); } -+ -+void Assembler::ctz_d(Register rd, Register rj) { GenRegister(CTZ_D, rj, rd); } -+ -+void Assembler::bytepick_w(Register rd, Register rj, Register rk, int32_t sa2) { -+ DCHECK(is_uint2(sa2)); -+ GenImm(BYTEPICK_W, sa2, rk, rj, rd); -+} -+ -+void Assembler::bytepick_d(Register rd, Register rj, Register rk, int32_t sa3) { -+ GenImm(BYTEPICK_D, sa3, rk, rj, rd); -+} -+ -+void Assembler::revb_2h(Register rd, Register rj) { -+ GenRegister(REVB_2H, rj, rd); -+} -+ -+void Assembler::revb_4h(Register rd, Register rj) { -+ GenRegister(REVB_4H, rj, rd); -+} -+ -+void Assembler::revb_2w(Register rd, Register rj) { -+ GenRegister(REVB_2W, rj, rd); -+} -+ -+void Assembler::revb_d(Register rd, Register rj) { -+ GenRegister(REVB_D, rj, rd); -+} -+ -+void Assembler::revh_2w(Register rd, Register rj) { -+ GenRegister(REVH_2W, rj, rd); -+} -+ -+void Assembler::revh_d(Register rd, Register rj) { -+ GenRegister(REVH_D, rj, rd); -+} -+ -+void Assembler::bitrev_4b(Register rd, Register rj) { -+ GenRegister(BITREV_4B, rj, rd); -+} -+ -+void Assembler::bitrev_8b(Register rd, Register rj) { -+ GenRegister(BITREV_8B, rj, rd); -+} -+ -+void Assembler::bitrev_w(Register rd, Register rj) { -+ GenRegister(BITREV_W, rj, rd); -+} -+ -+void Assembler::bitrev_d(Register rd, Register rj) { -+ GenRegister(BITREV_D, rj, rd); -+} -+ -+void Assembler::bstrins_w(Register rd, Register rj, int32_t msbw, -+ int32_t lsbw) { -+ DCHECK(is_uint5(msbw) && is_uint5(lsbw)); -+ GenImm(BSTR_W, msbw + 0x20, lsbw, rj, rd); -+} -+ -+void Assembler::bstrins_d(Register rd, Register rj, int32_t msbd, -+ int32_t lsbd) { -+ GenImm(BSTRINS_D, msbd, lsbd, rj, rd); -+} -+ -+void Assembler::bstrpick_w(Register rd, Register rj, int32_t msbw, -+ int32_t lsbw) { -+ DCHECK(is_uint5(msbw) && is_uint5(lsbw)); -+ GenImm(BSTR_W, msbw + 0x20, lsbw + 0x20, rj, rd); -+} -+ -+void Assembler::bstrpick_d(Register rd, Register rj, int32_t msbd, -+ int32_t lsbd) { -+ GenImm(BSTRPICK_D, msbd, lsbd, rj, rd); -+} -+ -+void Assembler::maskeqz(Register rd, Register rj, Register rk) { -+ GenRegister(MASKEQZ, rk, rj, rd); -+} -+ -+void Assembler::masknez(Register rd, Register rj, Register rk) { -+ GenRegister(MASKNEZ, rk, rj, rd); -+} -+ -+// Memory-instructions -+void Assembler::ld_b(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_B, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_h(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_H, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_w(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_W, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_d(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_D, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_bu(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_BU, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_hu(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_HU, si12, rj, rd, 12); -+} -+ -+void Assembler::ld_wu(Register rd, Register rj, int32_t si12) { -+ GenImm(LD_WU, si12, rj, rd, 12); -+} -+ -+void Assembler::st_b(Register rd, Register rj, int32_t si12) { -+ GenImm(ST_B, si12, rj, rd, 12); -+} -+ -+void Assembler::st_h(Register rd, Register rj, int32_t si12) { -+ GenImm(ST_H, si12, rj, rd, 12); -+} -+ -+void Assembler::st_w(Register rd, Register rj, int32_t si12) { -+ GenImm(ST_W, si12, rj, rd, 12); -+} -+ -+void Assembler::st_d(Register rd, Register rj, int32_t si12) { -+ GenImm(ST_D, si12, rj, rd, 12); -+} -+ -+void Assembler::ldx_b(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_B, rk, rj, rd); -+} -+ -+void Assembler::ldx_h(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_H, rk, rj, rd); -+} -+ -+void Assembler::ldx_w(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_W, rk, rj, rd); -+} -+ -+void Assembler::ldx_d(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_D, rk, rj, rd); -+} -+ -+void Assembler::ldx_bu(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_BU, rk, rj, rd); -+} -+ -+void Assembler::ldx_hu(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_HU, rk, rj, rd); -+} -+ -+void Assembler::ldx_wu(Register rd, Register rj, Register rk) { -+ GenRegister(LDX_WU, rk, rj, rd); -+} -+ -+void Assembler::stx_b(Register rd, Register rj, Register rk) { -+ GenRegister(STX_B, rk, rj, rd); -+} -+ -+void Assembler::stx_h(Register rd, Register rj, Register rk) { -+ GenRegister(STX_H, rk, rj, rd); -+} -+ -+void Assembler::stx_w(Register rd, Register rj, Register rk) { -+ GenRegister(STX_W, rk, rj, rd); -+} -+ -+void Assembler::stx_d(Register rd, Register rj, Register rk) { -+ GenRegister(STX_D, rk, rj, rd); -+} -+ -+void Assembler::ldptr_w(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(LDPTR_W, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::ldptr_d(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(LDPTR_D, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::stptr_w(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(STPTR_W, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::stptr_d(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(STPTR_D, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::amswap_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMSWAP_W, rk, rj, rd); -+} -+ -+void Assembler::amswap_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMSWAP_D, rk, rj, rd); -+} -+ -+void Assembler::amadd_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMADD_W, rk, rj, rd); -+} -+ -+void Assembler::amadd_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMADD_D, rk, rj, rd); -+} -+ -+void Assembler::amand_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMAND_W, rk, rj, rd); -+} -+ -+void Assembler::amand_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMAND_D, rk, rj, rd); -+} -+ -+void Assembler::amor_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMOR_W, rk, rj, rd); -+} -+ -+void Assembler::amor_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMOR_D, rk, rj, rd); -+} -+ -+void Assembler::amxor_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMXOR_W, rk, rj, rd); -+} -+ -+void Assembler::amxor_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMXOR_D, rk, rj, rd); -+} -+ -+void Assembler::ammax_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_W, rk, rj, rd); -+} -+ -+void Assembler::ammax_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_D, rk, rj, rd); -+} -+ -+void Assembler::ammin_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_W, rk, rj, rd); -+} -+ -+void Assembler::ammin_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_D, rk, rj, rd); -+} -+ -+void Assembler::ammax_wu(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_WU, rk, rj, rd); -+} -+ -+void Assembler::ammax_du(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_DU, rk, rj, rd); -+} -+ -+void Assembler::ammin_wu(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_WU, rk, rj, rd); -+} -+ -+void Assembler::ammin_du(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_DU, rk, rj, rd); -+} -+ -+void Assembler::amswap_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMSWAP_DB_W, rk, rj, rd); -+} -+ -+void Assembler::amswap_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMSWAP_DB_D, rk, rj, rd); -+} -+ -+void Assembler::amadd_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMADD_DB_W, rk, rj, rd); -+} -+ -+void Assembler::amadd_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMADD_DB_D, rk, rj, rd); -+} -+ -+void Assembler::amand_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMAND_DB_W, rk, rj, rd); -+} -+ -+void Assembler::amand_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMAND_DB_D, rk, rj, rd); -+} -+ -+void Assembler::amor_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMOR_DB_W, rk, rj, rd); -+} -+ -+void Assembler::amor_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMOR_DB_D, rk, rj, rd); -+} -+ -+void Assembler::amxor_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMXOR_DB_W, rk, rj, rd); -+} -+ -+void Assembler::amxor_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMXOR_DB_D, rk, rj, rd); -+} -+ -+void Assembler::ammax_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_DB_W, rk, rj, rd); -+} -+ -+void Assembler::ammax_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_DB_D, rk, rj, rd); -+} -+ -+void Assembler::ammin_db_w(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_DB_W, rk, rj, rd); -+} -+ -+void Assembler::ammin_db_d(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_DB_D, rk, rj, rd); -+} -+ -+void Assembler::ammax_db_wu(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_DB_WU, rk, rj, rd); -+} -+ -+void Assembler::ammax_db_du(Register rd, Register rk, Register rj) { -+ GenRegister(AMMAX_DB_DU, rk, rj, rd); -+} -+ -+void Assembler::ammin_db_wu(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_DB_WU, rk, rj, rd); -+} -+ -+void Assembler::ammin_db_du(Register rd, Register rk, Register rj) { -+ GenRegister(AMMIN_DB_DU, rk, rj, rd); -+} -+ -+void Assembler::ll_w(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(LL_W, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::ll_d(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(LL_D, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::sc_w(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(SC_W, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::sc_d(Register rd, Register rj, int32_t si14) { -+ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); -+ GenImm(SC_D, si14 >> 2, rj, rd, 14); -+} -+ -+void Assembler::dbar(int32_t hint) { GenImm(DBAR, hint); } -+ -+void Assembler::ibar(int32_t hint) { GenImm(IBAR, hint); } -+ -+// Break / Trap instructions. -+void Assembler::break_(uint32_t code, bool break_as_stop) { -+ DCHECK( -+ (break_as_stop && code <= kMaxStopCode && code > kMaxWatchpointCode) || -+ (!break_as_stop && (code > kMaxStopCode || code <= kMaxWatchpointCode))); -+ GenImm(BREAK, code); -+} -+ -+void Assembler::stop(uint32_t code) { -+ DCHECK_GT(code, kMaxWatchpointCode); -+ DCHECK_LE(code, kMaxStopCode); -+#if defined(V8_HOST_ARCH_LA64) -+ break_(0x4321); -+#else // V8_HOST_ARCH_LA64 -+ break_(code, true); -+#endif -+} -+ -+void Assembler::fadd_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FADD_S, fk, fj, fd); -+} -+ -+void Assembler::fadd_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FADD_D, fk, fj, fd); -+} -+ -+void Assembler::fsub_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FSUB_S, fk, fj, fd); -+} -+ -+void Assembler::fsub_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FSUB_D, fk, fj, fd); -+} -+ -+void Assembler::fmul_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMUL_S, fk, fj, fd); -+} -+ -+void Assembler::fmul_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMUL_D, fk, fj, fd); -+} -+ -+void Assembler::fdiv_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FDIV_S, fk, fj, fd); -+} -+ -+void Assembler::fdiv_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FDIV_D, fk, fj, fd); -+} -+ -+void Assembler::fmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FMADD_S, fa, fk, fj, fd); -+} -+ -+void Assembler::fmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FMADD_D, fa, fk, fj, fd); -+} -+ -+void Assembler::fmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FMSUB_S, fa, fk, fj, fd); -+} -+ -+void Assembler::fmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FMSUB_D, fa, fk, fj, fd); -+} -+ -+void Assembler::fnmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FNMADD_S, fa, fk, fj, fd); -+} -+ -+void Assembler::fnmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FNMADD_D, fa, fk, fj, fd); -+} -+ -+void Assembler::fnmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FNMSUB_S, fa, fk, fj, fd); -+} -+ -+void Assembler::fnmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, -+ FPURegister fa) { -+ GenRegister(FNMSUB_D, fa, fk, fj, fd); -+} -+ -+void Assembler::fmax_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMAX_S, fk, fj, fd); -+} -+ -+void Assembler::fmax_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMAX_D, fk, fj, fd); -+} -+ -+void Assembler::fmin_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMIN_S, fk, fj, fd); -+} -+ -+void Assembler::fmin_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMIN_D, fk, fj, fd); -+} -+ -+void Assembler::fmaxa_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMAXA_S, fk, fj, fd); -+} -+ -+void Assembler::fmaxa_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMAXA_D, fk, fj, fd); -+} -+ -+void Assembler::fmina_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMINA_S, fk, fj, fd); -+} -+ -+void Assembler::fmina_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FMINA_D, fk, fj, fd); -+} -+ -+void Assembler::fabs_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FABS_S, fj, fd); -+} -+ -+void Assembler::fabs_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FABS_D, fj, fd); -+} -+ -+void Assembler::fneg_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FNEG_S, fj, fd); -+} -+ -+void Assembler::fneg_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FNEG_D, fj, fd); -+} -+ -+void Assembler::fsqrt_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FSQRT_S, fj, fd); -+} -+ -+void Assembler::fsqrt_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FSQRT_D, fj, fd); -+} -+ -+void Assembler::frecip_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FRECIP_S, fj, fd); -+} -+ -+void Assembler::frecip_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FRECIP_D, fj, fd); -+} -+ -+void Assembler::frsqrt_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FRSQRT_S, fj, fd); -+} -+ -+void Assembler::frsqrt_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FRSQRT_D, fj, fd); -+} -+ -+void Assembler::fscaleb_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FSCALEB_S, fk, fj, fd); -+} -+ -+void Assembler::fscaleb_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FSCALEB_D, fk, fj, fd); -+} -+ -+void Assembler::flogb_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FLOGB_S, fj, fd); -+} -+ -+void Assembler::flogb_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FLOGB_D, fj, fd); -+} -+ -+void Assembler::fcopysign_s(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FCOPYSIGN_S, fk, fj, fd); -+} -+ -+void Assembler::fcopysign_d(FPURegister fd, FPURegister fj, FPURegister fk) { -+ GenRegister(FCOPYSIGN_D, fk, fj, fd); -+} -+ -+void Assembler::fclass_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FCLASS_S, fj, fd); -+} -+ -+void Assembler::fclass_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FCLASS_D, fj, fd); -+} -+ -+void Assembler::fcmp_cond_s(FPUCondition cc, FPURegister fj, FPURegister fk, -+ CFRegister cd) { -+ GenCmp(FCMP_COND_S, cc, fk, fj, cd); -+} -+ -+void Assembler::fcmp_cond_d(FPUCondition cc, FPURegister fj, FPURegister fk, -+ CFRegister cd) { -+ GenCmp(FCMP_COND_D, cc, fk, fj, cd); -+} -+ -+void Assembler::fcvt_s_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FCVT_S_D, fj, fd); -+} -+ -+void Assembler::fcvt_d_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FCVT_D_S, fj, fd); -+} -+ -+void Assembler::ffint_s_w(FPURegister fd, FPURegister fj) { -+ GenRegister(FFINT_S_W, fj, fd); -+} -+ -+void Assembler::ffint_s_l(FPURegister fd, FPURegister fj) { -+ GenRegister(FFINT_S_L, fj, fd); -+} -+ -+void Assembler::ffint_d_w(FPURegister fd, FPURegister fj) { -+ GenRegister(FFINT_D_W, fj, fd); -+} -+ -+void Assembler::ffint_d_l(FPURegister fd, FPURegister fj) { -+ GenRegister(FFINT_D_L, fj, fd); -+} -+ -+void Assembler::ftint_w_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINT_W_S, fj, fd); -+} -+ -+void Assembler::ftint_w_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINT_W_D, fj, fd); -+} -+ -+void Assembler::ftint_l_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINT_L_S, fj, fd); -+} -+ -+void Assembler::ftint_l_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINT_L_D, fj, fd); -+} -+ -+void Assembler::ftintrm_w_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRM_W_S, fj, fd); -+} -+ -+void Assembler::ftintrm_w_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRM_W_D, fj, fd); -+} -+ -+void Assembler::ftintrm_l_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRM_L_S, fj, fd); -+} -+ -+void Assembler::ftintrm_l_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRM_L_D, fj, fd); -+} -+ -+void Assembler::ftintrp_w_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRP_W_S, fj, fd); -+} -+ -+void Assembler::ftintrp_w_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRP_W_D, fj, fd); -+} -+ -+void Assembler::ftintrp_l_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRP_L_S, fj, fd); -+} -+ -+void Assembler::ftintrp_l_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRP_L_D, fj, fd); -+} -+ -+void Assembler::ftintrz_w_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRZ_W_S, fj, fd); -+} -+ -+void Assembler::ftintrz_w_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRZ_W_D, fj, fd); -+} -+ -+void Assembler::ftintrz_l_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRZ_L_S, fj, fd); -+} -+ -+void Assembler::ftintrz_l_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRZ_L_D, fj, fd); -+} -+ -+void Assembler::ftintrne_w_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRNE_W_S, fj, fd); -+} -+ -+void Assembler::ftintrne_w_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRNE_W_D, fj, fd); -+} -+ -+void Assembler::ftintrne_l_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRNE_L_S, fj, fd); -+} -+ -+void Assembler::ftintrne_l_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FTINTRNE_L_D, fj, fd); -+} -+ -+void Assembler::frint_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FRINT_S, fj, fd); -+} -+ -+void Assembler::frint_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FRINT_D, fj, fd); -+} -+ -+void Assembler::fmov_s(FPURegister fd, FPURegister fj) { -+ GenRegister(FMOV_S, fj, fd); -+} -+ -+void Assembler::fmov_d(FPURegister fd, FPURegister fj) { -+ GenRegister(FMOV_D, fj, fd); -+} -+ -+void Assembler::fsel(CFRegister ca, FPURegister fd, FPURegister fj, -+ FPURegister fk) { -+ GenSel(FSEL, ca, fk, fj, fd); -+} -+ -+void Assembler::movgr2fr_w(FPURegister fd, Register rj) { -+ GenRegister(MOVGR2FR_W, rj, fd); -+} -+ -+void Assembler::movgr2fr_d(FPURegister fd, Register rj) { -+ GenRegister(MOVGR2FR_D, rj, fd); -+} -+ -+void Assembler::movgr2frh_w(FPURegister fd, Register rj) { -+ GenRegister(MOVGR2FRH_W, rj, fd); -+} -+ -+void Assembler::movfr2gr_s(Register rd, FPURegister fj) { -+ GenRegister(MOVFR2GR_S, fj, rd); -+} -+ -+void Assembler::movfr2gr_d(Register rd, FPURegister fj) { -+ GenRegister(MOVFR2GR_D, fj, rd); -+} -+ -+void Assembler::movfrh2gr_s(Register rd, FPURegister fj) { -+ GenRegister(MOVFRH2GR_S, fj, rd); -+} -+ -+void Assembler::movgr2fcsr(Register rj) { GenRegister(MOVGR2FCSR, rj, FCSR); } -+ -+void Assembler::movfcsr2gr(Register rd) { GenRegister(MOVFCSR2GR, FCSR, rd); } -+ -+void Assembler::movfr2cf(CFRegister cd, FPURegister fj) { -+ GenRegister(MOVFR2CF, fj, cd); -+} -+ -+void Assembler::movcf2fr(FPURegister fd, CFRegister cj) { -+ GenRegister(MOVCF2FR, cj, fd); -+} -+ -+void Assembler::movgr2cf(CFRegister cd, Register rj) { -+ GenRegister(MOVGR2CF, rj, cd); -+} -+ -+void Assembler::movcf2gr(Register rd, CFRegister cj) { -+ GenRegister(MOVCF2GR, cj, rd); -+} -+ -+void Assembler::fld_s(FPURegister fd, Register rj, int32_t si12) { -+ GenImm(FLD_S, si12, rj, fd); -+} -+ -+void Assembler::fld_d(FPURegister fd, Register rj, int32_t si12) { -+ GenImm(FLD_D, si12, rj, fd); -+} -+ -+void Assembler::fst_s(FPURegister fd, Register rj, int32_t si12) { -+ GenImm(FST_S, si12, rj, fd); -+} -+ -+void Assembler::fst_d(FPURegister fd, Register rj, int32_t si12) { -+ GenImm(FST_D, si12, rj, fd); -+} -+ -+void Assembler::fldx_s(FPURegister fd, Register rj, Register rk) { -+ GenRegister(FLDX_S, rk, rj, fd); -+} -+ -+void Assembler::fldx_d(FPURegister fd, Register rj, Register rk) { -+ GenRegister(FLDX_D, rk, rj, fd); -+} -+ -+void Assembler::fstx_s(FPURegister fd, Register rj, Register rk) { -+ GenRegister(FSTX_S, rk, rj, fd); -+} -+ -+void Assembler::fstx_d(FPURegister fd, Register rj, Register rk) { -+ GenRegister(FSTX_D, rk, rj, fd); -+} -+ -+// ------------Memory-instructions------------- -+ -+/*void Assembler::AdjustBaseAndOffset(MemOperand* src, -+ OffsetAccessType access_type, -+ int second_access_add_to_offset) { -+ // TODO should be optimized. -+ // This method is used to adjust the base register and offset pair -+ // for a load/store when the offset doesn't fit into int12_t. -+ -+ bool doubleword_aligned = (src->offset() & (kDoubleSize - 1)) == 0; -+ bool two_accesses = static_cast(access_type) || !doubleword_aligned; -+ DCHECK_LE(second_access_add_to_offset, 7); // Must be <= 7. -+ -+ // is_int12 must be passed a signed value, hence the static cast below. -+ if (is_int12(src->offset()) && -+ (!two_accesses || is_int12(static_cast( -+ src->offset() + second_access_add_to_offset)))) { -+ // Nothing to do: 'offset' (and, if needed, 'offset + 4', or other specified -+ // value) fits into int16_t. -+ return; -+ } -+ -+ DCHECK(src->rm() != -+ at); // Must not overwrite the register 'base' while loading 'offset'. -+ -+#ifdef DEBUG -+ // Remember the "(mis)alignment" of 'offset', it will be checked at the end. -+ uint32_t misalignment = src->offset() & (kDoubleSize - 1); -+#endif -+ -+ // Do not load the whole 32-bit 'offset' if it can be represented as -+ // a sum of two 16-bit signed offsets. This can save an instruction or two. -+ // To simplify matters, only do this for a symmetric range of offsets from -+ // about -64KB to about +64KB, allowing further addition of 4 when accessing -+ // 64-bit variables with two 32-bit accesses. -+ constexpr int32_t kMinOffsetForSimpleAdjustment = -+ 0x7FF8; // Max int16_t that's a multiple of 8. -+ constexpr int32_t kMaxOffsetForSimpleAdjustment = -+ 2 * kMinOffsetForSimpleAdjustment; -+ -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ if (0 <= src->offset() && src->offset() <= kMaxOffsetForSimpleAdjustment) { -+ daddiu(scratch, src->rm(), kMinOffsetForSimpleAdjustment); -+ src->offset_ -= kMinOffsetForSimpleAdjustment; -+ } else if (-kMaxOffsetForSimpleAdjustment <= src->offset() && -+ src->offset() < 0) { -+ daddiu(scratch, src->rm(), -kMinOffsetForSimpleAdjustment); -+ src->offset_ += kMinOffsetForSimpleAdjustment; -+ } else if (kArchVariant == kMips64r6) { -+ // On r6 take advantage of the daui instruction, e.g.: -+ // daui at, base, offset_high -+ // [dahi at, 1] // When `offset` is close to +2GB. -+ // lw reg_lo, offset_low(at) -+ // [lw reg_hi, (offset_low+4)(at)] // If misaligned 64-bit load. -+ // or when offset_low+4 overflows int16_t: -+ // daui at, base, offset_high -+ // daddiu at, at, 8 -+ // lw reg_lo, (offset_low-8)(at) -+ // lw reg_hi, (offset_low-4)(at) -+ int16_t offset_low = static_cast(src->offset()); -+ int32_t offset_low32 = offset_low; -+ int16_t offset_high = static_cast(src->offset() >> 16); -+ bool increment_hi16 = offset_low < 0; -+ bool overflow_hi16 = false; -+ -+ if (increment_hi16) { -+ offset_high++; -+ overflow_hi16 = (offset_high == -32768); -+ } -+ daui(scratch, src->rm(), static_cast(offset_high)); -+ -+ if (overflow_hi16) { -+ dahi(scratch, 1); -+ } -+ -+ if (two_accesses && !is_int16(static_cast( -+ offset_low32 + second_access_add_to_offset))) { -+ // Avoid overflow in the 16-bit offset of the load/store instruction when -+ // adding 4. -+ daddiu(scratch, scratch, kDoubleSize); -+ offset_low32 -= kDoubleSize; -+ } -+ -+ src->offset_ = offset_low32; -+ } else { -+ // Do not load the whole 32-bit 'offset' if it can be represented as -+ // a sum of three 16-bit signed offsets. This can save an instruction. -+ // To simplify matters, only do this for a symmetric range of offsets from -+ // about -96KB to about +96KB, allowing further addition of 4 when accessing -+ // 64-bit variables with two 32-bit accesses. -+ constexpr int32_t kMinOffsetForMediumAdjustment = -+ 2 * kMinOffsetForSimpleAdjustment; -+ constexpr int32_t kMaxOffsetForMediumAdjustment = -+ 3 * kMinOffsetForSimpleAdjustment; -+ if (0 <= src->offset() && src->offset() <= kMaxOffsetForMediumAdjustment) { -+ daddiu(scratch, src->rm(), kMinOffsetForMediumAdjustment / 2); -+ daddiu(scratch, scratch, kMinOffsetForMediumAdjustment / 2); -+ src->offset_ -= kMinOffsetForMediumAdjustment; -+ } else if (-kMaxOffsetForMediumAdjustment <= src->offset() && -+ src->offset() < 0) { -+ daddiu(scratch, src->rm(), -kMinOffsetForMediumAdjustment / 2); -+ daddiu(scratch, scratch, -kMinOffsetForMediumAdjustment / 2); -+ src->offset_ += kMinOffsetForMediumAdjustment; -+ } else { -+ // Now that all shorter options have been exhausted, load the full 32-bit -+ // offset. -+ int32_t loaded_offset = RoundDown(src->offset(), kDoubleSize); -+ lui(scratch, (loaded_offset >> kLuiShift) & kImm16Mask); -+ ori(scratch, scratch, loaded_offset & kImm16Mask); // Load 32-bit offset. -+ daddu(scratch, scratch, src->rm()); -+ src->offset_ -= loaded_offset; -+ } -+ } -+ src->rm_ = scratch; -+ -+ DCHECK(is_int16(src->offset())); -+ if (two_accesses) { -+ DCHECK(is_int16( -+ static_cast(src->offset() + second_access_add_to_offset))); -+ } -+ DCHECK(misalignment == (src->offset() & (kDoubleSize - 1))); -+}*/ -+ -+void Assembler::AdjustBaseAndOffset(MemOperand* src) { -+ // is_int12 must be passed a signed value, hence the static cast below. -+ if ((!src->hasIndexReg() && is_int12(src->offset())) || src->hasIndexReg()) { -+ return; -+ } -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ if (is_uint12(static_cast(src->offset()))) { -+ ori(scratch, zero_reg, src->offset() & kImm12Mask); -+ } else { -+ lu12i_w(scratch, src->offset() >> 12 & 0xfffff); -+ if (src->offset() & kImm12Mask) { -+ ori(scratch, scratch, src->offset() & kImm12Mask); -+ } -+ } -+ src->index_ = scratch; -+ src->offset_ = 0; -+ // TODO can be optimized, for example 2 * [int12_min, int12_max] -+ // addi_d scratch base, offset/2 only on instr -+ // base = scratch -+ // offset = offset - offset / 2 -+} -+ -+int Assembler::RelocateInternalReference(RelocInfo::Mode rmode, Address pc, -+ intptr_t pc_delta) { -+ if (RelocInfo::IsInternalReference(rmode)) { -+ int64_t* p = reinterpret_cast(pc); -+ if (*p == kEndOfJumpChain) { -+ return 0; // Number of instructions patched. -+ } -+ *p += pc_delta; -+ return 2; // Number of instructions patched. -+ } -+ abort(); -+ /* Instr instr = instr_at(pc); -+ DCHECK(RelocInfo::IsInternalReferenceEncoded(rmode)); -+ if (IsLui(instr)) { -+ Instr instr_lui = instr_at(pc + 0 * kInstrSize); -+ Instr instr_ori = instr_at(pc + 1 * kInstrSize); -+ Instr instr_ori2 = instr_at(pc + 3 * kInstrSize); -+ DCHECK(IsOri(instr_ori)); -+ DCHECK(IsOri(instr_ori2)); -+ // TODO(plind): symbolic names for the shifts. -+ int64_t imm = (instr_lui & static_cast(kImm16Mask)) << 48; -+ imm |= (instr_ori & static_cast(kImm16Mask)) << 32; -+ imm |= (instr_ori2 & static_cast(kImm16Mask)) << 16; -+ // Sign extend address. -+ imm >>= 16; -+ -+ if (imm == kEndOfJumpChain) { -+ return 0; // Number of instructions patched. -+ } -+ imm += pc_delta; -+ DCHECK_EQ(imm & 3, 0); -+ -+ instr_lui &= ~kImm16Mask; -+ instr_ori &= ~kImm16Mask; -+ instr_ori2 &= ~kImm16Mask; -+ -+ instr_at_put(pc + 0 * kInstrSize, instr_lui | ((imm >> 32) & kImm16Mask)); -+ instr_at_put(pc + 1 * kInstrSize, instr_ori | (imm >> 16 & kImm16Mask)); -+ instr_at_put(pc + 3 * kInstrSize, instr_ori2 | (imm & kImm16Mask)); -+ return 4; // Number of instructions patched. -+ } else if (IsJ(instr) || IsJal(instr)) { -+ // Regular j/jal relocation. -+ uint32_t imm28 = (instr & static_cast(kImm26Mask)) << 2; -+ imm28 += pc_delta; -+ imm28 &= kImm28Mask; -+ instr &= ~kImm26Mask; -+ DCHECK_EQ(imm28 & 3, 0); -+ uint32_t imm26 = static_cast(imm28 >> 2); -+ instr_at_put(pc, instr | (imm26 & kImm26Mask)); -+ return 1; // Number of instructions patched. -+ } else { -+ DCHECK(((instr & kJumpRawMask) == kJRawMark) || -+ ((instr & kJumpRawMask) == kJalRawMark)); -+ // Unbox raw offset and emit j/jal. -+ int32_t imm28 = (instr & static_cast(kImm26Mask)) << 2; -+ // Sign extend 28-bit offset to 32-bit. -+ imm28 = (imm28 << 4) >> 4; -+ uint64_t target = -+ static_cast(imm28) + reinterpret_cast(pc); -+ target &= kImm28Mask; -+ DCHECK_EQ(imm28 & 3, 0); -+ uint32_t imm26 = static_cast(target >> 2); -+ // Check markings whether to emit j or jal. -+ uint32_t unbox = (instr & kJRawMark) ? J : JAL; -+ instr_at_put(pc, unbox | (imm26 & kImm26Mask)); -+ return 1; // Number of instructions patched. -+ }*/ -+} -+ -+void Assembler::GrowBuffer() { -+ // Compute new buffer size. -+ int old_size = buffer_->size(); -+ int new_size = std::min(2 * old_size, old_size + 1 * MB); -+ -+ // Some internal data structures overflow for very large buffers, -+ // they must ensure that kMaximalBufferSize is not too large. -+ if (new_size > kMaximalBufferSize) { -+ V8::FatalProcessOutOfMemory(nullptr, "Assembler::GrowBuffer"); -+ } -+ -+ // Set up new buffer. -+ std::unique_ptr new_buffer = buffer_->Grow(new_size); -+ DCHECK_EQ(new_size, new_buffer->size()); -+ byte* new_start = new_buffer->start(); -+ -+ // Copy the data. -+ intptr_t pc_delta = new_start - buffer_start_; -+ intptr_t rc_delta = (new_start + new_size) - (buffer_start_ + old_size); -+ size_t reloc_size = (buffer_start_ + old_size) - reloc_info_writer.pos(); -+ MemMove(new_start, buffer_start_, pc_offset()); -+ MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(), -+ reloc_size); -+ -+ // Switch buffers. -+ buffer_ = std::move(new_buffer); -+ buffer_start_ = new_start; -+ pc_ += pc_delta; -+ last_call_pc_ += pc_delta; -+ reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, -+ reloc_info_writer.last_pc() + pc_delta); -+ -+ // Relocate runtime entries. -+ Vector instructions{buffer_start_, pc_offset()}; -+ Vector reloc_info{reloc_info_writer.pos(), reloc_size}; -+ for (RelocIterator it(instructions, reloc_info, 0); !it.done(); it.next()) { -+ RelocInfo::Mode rmode = it.rinfo()->rmode(); -+ if (rmode == RelocInfo::INTERNAL_REFERENCE) { -+ RelocateInternalReference(rmode, it.rinfo()->pc(), pc_delta); -+ } -+ } -+ DCHECK(!overflow()); -+} -+ -+void Assembler::db(uint8_t data) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ *reinterpret_cast(pc_) = data; -+ pc_ += sizeof(uint8_t); -+} -+ -+void Assembler::dd(uint32_t data) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ *reinterpret_cast(pc_) = data; -+ pc_ += sizeof(uint32_t); -+} -+ -+void Assembler::dq(uint64_t data) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ *reinterpret_cast(pc_) = data; -+ pc_ += sizeof(uint64_t); -+} -+ -+void Assembler::dd(Label* label) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ uint64_t data; -+ if (label->is_bound()) { -+ data = reinterpret_cast(buffer_start_ + label->pos()); -+ } else { -+ data = jump_address(label); -+ unbound_labels_count_++; -+ internal_reference_positions_.insert(label->pos()); -+ } -+ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE); -+ EmitHelper(data); -+} -+ -+void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { -+ if (!ShouldRecordRelocInfo(rmode)) return; -+ // We do not try to reuse pool constants. -+ RelocInfo rinfo(reinterpret_cast
(pc_), rmode, data, Code()); -+ DCHECK_GE(buffer_space(), kMaxRelocSize); // Too late to grow buffer here. -+ reloc_info_writer.Write(&rinfo); -+} -+ -+void Assembler::BlockTrampolinePoolFor(int instructions) { -+ CheckTrampolinePoolQuick(instructions); -+ BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); -+} -+ -+void Assembler::CheckTrampolinePool() { -+ // Some small sequences of instructions must not be broken up by the -+ // insertion of a trampoline pool; such sequences are protected by setting -+ // either trampoline_pool_blocked_nesting_ or no_trampoline_pool_before_, -+ // which are both checked here. Also, recursive calls to CheckTrampolinePool -+ // are blocked by trampoline_pool_blocked_nesting_. -+ if ((trampoline_pool_blocked_nesting_ > 0) || -+ (pc_offset() < no_trampoline_pool_before_)) { -+ // Emission is currently blocked; make sure we try again as soon as -+ // possible. -+ if (trampoline_pool_blocked_nesting_ > 0) { -+ next_buffer_check_ = pc_offset() + kInstrSize; -+ } else { -+ next_buffer_check_ = no_trampoline_pool_before_; -+ } -+ return; -+ } -+ -+ DCHECK(!trampoline_emitted_); -+ DCHECK_GE(unbound_labels_count_, 0); -+ if (unbound_labels_count_ > 0) { -+ // First we emit jump (2 instructions), then we emit trampoline pool. -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Label after_pool; -+ b(&after_pool); -+ nop(); // TODO remove this -+ -+ int pool_start = pc_offset(); -+ for (int i = 0; i < unbound_labels_count_; i++) { -+ { -+ b(&after_pool); -+ nop(); // TODO remove this -+ } -+ } -+ nop(); -+ trampoline_ = Trampoline(pool_start, unbound_labels_count_); -+ bind(&after_pool); -+ -+ trampoline_emitted_ = true; -+ // As we are only going to emit trampoline once, we need to prevent any -+ // further emission. -+ next_buffer_check_ = kMaxInt; -+ } -+ } else { -+ // Number of branches to unbound label at this point is zero, so we can -+ // move next buffer check to maximum. -+ next_buffer_check_ = -+ pc_offset() + kMax16BranchOffset - kTrampolineSlotsSize * 16; -+ } -+ return; -+} -+ -+Address Assembler::target_address_at(Address pc) { -+ Instr instr0 = instr_at(pc); -+ Instr instr1 = instr_at(pc + 1 * kInstrSize); -+ Instr instr2 = instr_at(pc + 2 * kInstrSize); -+ -+ // Interpret 4 instructions for address generated by li: See listing in -+ // Assembler::set_target_address_at() just below. -+ DCHECK((IsLu12i_w(instr0) && (IsOri(instr1)) && (IsLu32i_d(instr2)))); -+ -+ // Assemble the 48 bit value. -+ uint64_t hi20 = ((uint64_t)(instr2 >> 5) & 0xfffff) << 32; -+ uint64_t mid20 = ((uint64_t)(instr0 >> 5) & 0xfffff) << 12; -+ uint64_t low12 = ((uint64_t)(instr1 >> 10) & 0xfff); -+ int64_t addr = static_cast(hi20 | mid20 | low12); -+ -+ // Sign extend to get canonical address. -+ addr = (addr << 16) >> 16; -+ // printf("add : 0x%lx 0x%lx 0x%lx 0x%lx\n", addr, hi20, mid20, low12); -+ return static_cast
(addr); -+} -+ -+// On la64, a target address is stored in a 3-instruction sequence: -+// 0: lu12i_w(rd, (j.imm64_ >> 12) & kImm20Mask); -+// 1: ori(rd, rd, j.imm64_ & kImm12Mask); -+// 2: lu32i_d(rd, (j.imm64_ >> 32) & kImm20Mask); -+// -+// Patching the address must replace all the lui & ori instructions, -+// and flush the i-cache. -+// -+// There is an optimization below, which emits a nop when the address -+// fits in just 16 bits. This is unlikely to help, and should be benchmarked, -+// and possibly removed. -+void Assembler::set_target_value_at(Address pc, uint64_t target, -+ ICacheFlushMode icache_flush_mode) { -+ // There is an optimization where only 3 instructions are used to load address -+ // in code on LA64 because only 48-bits of address is effectively used. -+ // It relies on fact the upper [63:48] bits are not used for virtual address -+ // translation and they have to be set according to value of bit 47 in order -+ // get canonical address. -+#ifdef DEBUG -+ // Check we have the result from a li macro-instruction. -+ Instr instr0 = instr_at(pc); -+ Instr instr1 = instr_at(pc + kInstrSize); -+ Instr instr2 = instr_at(pc + kInstrSize * 2); -+ DCHECK(IsLu12i_w(instr0) && IsOri(instr1) && IsLu32i_d(instr2)); -+#endif -+ -+ Instr instr = instr_at(pc); -+ uint32_t rd_code = GetRd(instr); -+ uint32_t* p = reinterpret_cast(pc); -+ -+ // Must use 3 instructions to insure patchable code. -+ // lu12i_w rd, middle-20. -+ // ori rd, rd, low-12. -+ // li32i_d rd, high-20. -+ *p = LU12I_W | (((target >> 12) & 0xfffff) << kRjShift) | rd_code; -+ *(p + 1) = -+ ORI | (target & 0xfff) << kRkShift | (rd_code << kRjShift) | rd_code; -+ *(p + 2) = LU32I_D | (((target >> 32) & 0xfffff) << kRjShift) | rd_code; -+ -+ if (icache_flush_mode != SKIP_ICACHE_FLUSH) { -+ FlushInstructionCache(pc, 3 * kInstrSize); -+ } -+} -+ -+UseScratchRegisterScope::UseScratchRegisterScope(Assembler* assembler) -+ : available_(assembler->GetScratchRegisterList()), -+ old_available_(*available_) {} -+ -+UseScratchRegisterScope::~UseScratchRegisterScope() { -+ *available_ = old_available_; -+} -+ -+Register UseScratchRegisterScope::Acquire() { -+ DCHECK_NOT_NULL(available_); -+ DCHECK_NE(*available_, 0); -+ int index = static_cast(base::bits::CountTrailingZeros32(*available_)); -+ *available_ &= ~(1UL << index); -+ -+ return Register::from_code(index); -+} -+ -+bool UseScratchRegisterScope::hasAvailable() const { return *available_ != 0; } -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.h b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.h -new file mode 100644 -index 000000000..1c93e6459 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.h -@@ -0,0 +1,1138 @@ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#ifndef V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ -+#define V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ -+ -+#include -+ -+#include -+#include -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/external-reference.h" -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/loongarch64/register-loongarch64.h" -+#include "src/codegen/label.h" -+#include "src/objects/contexts.h" -+#include "src/objects/smi.h" -+ -+namespace v8 { -+namespace internal { -+ -+class SafepointTableBuilder; -+ -+// ----------------------------------------------------------------------------- -+// Machine instruction Operands. -+constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize; -+constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; -+// Class Operand represents a shifter operand in data processing instructions. -+class Operand { -+ public: -+ // Immediate. -+ V8_INLINE explicit Operand(int64_t immediate, -+ RelocInfo::Mode rmode = RelocInfo::NONE) -+ : rm_(no_reg), rmode_(rmode) { -+ value_.immediate = immediate; -+ } -+ V8_INLINE explicit Operand(const ExternalReference& f) -+ : rm_(no_reg), rmode_(RelocInfo::EXTERNAL_REFERENCE) { -+ value_.immediate = static_cast(f.address()); -+ } -+ V8_INLINE explicit Operand(const char* s); -+ explicit Operand(Handle handle); -+ V8_INLINE explicit Operand(Smi value) : rm_(no_reg), rmode_(RelocInfo::NONE) { -+ value_.immediate = static_cast(value.ptr()); -+ } -+ -+ static Operand EmbeddedNumber(double number); // Smi or HeapNumber. -+ static Operand EmbeddedStringConstant(const StringConstantBase* str); -+ -+ // Register. -+ V8_INLINE explicit Operand(Register rm) : rm_(rm) {} -+ -+ // Return true if this is a register operand. -+ V8_INLINE bool is_reg() const; -+ -+ inline int64_t immediate() const; -+ -+ bool IsImmediate() const { return !rm_.is_valid(); } -+ -+ HeapObjectRequest heap_object_request() const { -+ DCHECK(IsHeapObjectRequest()); -+ return value_.heap_object_request; -+ } -+ -+ bool IsHeapObjectRequest() const { -+ DCHECK_IMPLIES(is_heap_object_request_, IsImmediate()); -+ DCHECK_IMPLIES(is_heap_object_request_, -+ rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT || -+ rmode_ == RelocInfo::CODE_TARGET); -+ return is_heap_object_request_; -+ } -+ -+ Register rm() const { return rm_; } -+ -+ RelocInfo::Mode rmode() const { return rmode_; } -+ -+ private: -+ Register rm_; -+ union Value { -+ Value() {} -+ HeapObjectRequest heap_object_request; // if is_heap_object_request_ -+ int64_t immediate; // otherwise -+ } value_; // valid if rm_ == no_reg -+ bool is_heap_object_request_ = false; -+ RelocInfo::Mode rmode_; -+ -+ friend class Assembler; -+ friend class MacroAssembler; -+}; -+ -+// Class MemOperand represents a memory operand in load and store instructions. -+// 1: base_reg + off_imm( si12 | si14<<2) -+// 2: base_reg + offset_reg -+class V8_EXPORT_PRIVATE MemOperand { -+ public: -+ explicit MemOperand(Register rj, int32_t offset = 0); -+ explicit MemOperand(Register rj, Register offset = no_reg); -+ Register base() const { return base_; } -+ Register index() const { return index_; } -+ int32_t offset() const { return offset_; } -+ -+ bool hasIndexReg() const { return index_ != no_reg; } -+ -+ private: -+ Register base_; // base -+ Register index_; // index -+ int32_t offset_; // offset -+ -+ friend class Assembler; -+}; -+ -+class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { -+ public: -+ // Create an assembler. Instructions and relocation information are emitted -+ // into a buffer, with the instructions starting from the beginning and the -+ // relocation information starting from the end of the buffer. See CodeDesc -+ // for a detailed comment on the layout (globals.h). -+ // -+ // If the provided buffer is nullptr, the assembler allocates and grows its -+ // own buffer. Otherwise it takes ownership of the provided buffer. -+ explicit Assembler(const AssemblerOptions&, -+ std::unique_ptr = {}); -+ -+ virtual ~Assembler() {} -+ -+ // GetCode emits any pending (non-emitted) code and fills the descriptor desc. -+ static constexpr int kNoHandlerTable = 0; -+ static constexpr SafepointTableBuilder* kNoSafepointTable = nullptr; -+ void GetCode(Isolate* isolate, CodeDesc* desc, -+ SafepointTableBuilder* safepoint_table_builder, -+ int handler_table_offset); -+ -+ // Convenience wrapper for code without safepoint or handler tables. -+ void GetCode(Isolate* isolate, CodeDesc* desc) { -+ GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable); -+ } -+ -+ // Unused on this architecture. -+ void MaybeEmitOutOfLineConstantPool() {} -+ -+ // La64 uses BlockTrampolinePool to prevent generating trampoline inside a -+ // continuous instruction block. For Call instruction, it prevents generating -+ // trampoline between jalr and delay slot instruction. In the destructor of -+ // BlockTrampolinePool, it must check if it needs to generate trampoline -+ // immediately, if it does not do this, the branch range will go beyond the -+ // max branch offset, that means the pc_offset after call CheckTrampolinePool -+ // may be not the Call instruction's location. So we use last_call_pc here for -+ // safepoint record. -+ int pc_offset_for_safepoint() { -+ return static_cast(last_call_pc_ - buffer_start_); -+ } -+ -+ // Label operations & relative jumps (PPUM Appendix D). -+ // -+ // Takes a branch opcode (cc) and a label (L) and generates -+ // either a backward branch or a forward branch and links it -+ // to the label fixup chain. Usage: -+ // -+ // Label L; // unbound label -+ // j(cc, &L); // forward branch to unbound label -+ // bind(&L); // bind label to the current pc -+ // j(cc, &L); // backward branch to bound label -+ // bind(&L); // illegal: a label may be bound only once -+ // -+ // Note: The same Label can be used for forward and backward branches -+ // but it may be bound only once. -+ void bind(Label* L); // Binds an unbound label L to current code position. -+ -+ enum OffsetSize : int { kOffset26 = 26, kOffset21 = 21, kOffset16 = 16 }; -+ -+ // Determines if Label is bound and near enough so that branch instruction -+ // can be used to reach it, instead of jump instruction. -+ // c means conditinal branch, a means always branch. -+ bool is_near_c(Label* L); -+ bool is_near(Label* L, OffsetSize bits); -+ bool is_near_a(Label* L); -+ -+ int BranchOffset(Instr instr); -+ -+ // Returns the branch offset to the given label from the current code -+ // position. Links the label to the current position if it is still unbound. -+ // Manages the jump elimination optimization if the second parameter is true. -+ int32_t branch_offset_helper(Label* L, OffsetSize bits); -+ inline int32_t branch_offset(Label* L) { -+ return branch_offset_helper(L, OffsetSize::kOffset16); -+ } -+ inline int32_t branch_offset21(Label* L) { -+ return branch_offset_helper(L, OffsetSize::kOffset21); -+ } -+ inline int32_t branch_offset26(Label* L) { -+ return branch_offset_helper(L, OffsetSize::kOffset26); -+ } -+ inline int32_t shifted_branch_offset(Label* L) { -+ return branch_offset(L) >> 2; -+ } -+ inline int32_t shifted_branch_offset21(Label* L) { -+ return branch_offset21(L) >> 2; -+ } -+ inline int32_t shifted_branch_offset26(Label* L) { -+ return branch_offset26(L) >> 2; -+ } -+ uint64_t jump_address(Label* L); -+ uint64_t jump_offset(Label* L); -+ uint64_t branch_long_offset(Label* L); -+ -+ // Puts a labels target address at the given position. -+ // The high 8 bits are set to zero. -+ void label_at_put(Label* L, int at_offset); -+ -+ // Read/Modify the code target address in the branch/call instruction at pc. -+ // The isolate argument is unused (and may be nullptr) when skipping flushing. -+ static Address target_address_at(Address pc); -+ V8_INLINE static void set_target_address_at( -+ Address pc, Address target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { -+ set_target_value_at(pc, target, icache_flush_mode); -+ } -+ // On MIPS there is no Constant Pool so we skip that parameter. -+ V8_INLINE static Address target_address_at(Address pc, -+ Address constant_pool) { -+ return target_address_at(pc); -+ } -+ V8_INLINE static void set_target_address_at( -+ Address pc, Address constant_pool, Address target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { -+ set_target_address_at(pc, target, icache_flush_mode); -+ } -+ -+ static void set_target_value_at( -+ Address pc, uint64_t target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); -+ -+ static void JumpLabelToJumpRegister(Address pc); -+ -+ // This sets the branch destination (which gets loaded at the call address). -+ // This is for calls and branches within generated code. The serializer -+ // has already deserialized the lui/ori instructions etc. -+ inline static void deserialization_set_special_target_at( -+ Address instruction_payload, Code code, Address target); -+ -+ // Get the size of the special target encoded at 'instruction_payload'. -+ inline static int deserialization_special_target_size( -+ Address instruction_payload); -+ -+ // This sets the internal reference at the pc. -+ inline static void deserialization_set_target_internal_reference_at( -+ Address pc, Address target, -+ RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); -+ -+ // Here we are patching the address in the LUI/ORI instruction pair. -+ // These values are used in the serialization process and must be zero for -+ // LA platform, as Code, Embedded Object or External-reference pointers -+ // are split across two consecutive instructions and don't exist separately -+ // in the code, so the serializer should not step forwards in memory after -+ // a target is resolved and written. -+ static constexpr int kSpecialTargetSize = 0; -+ -+ // Number of consecutive instructions used to store 32bit/64bit constant. -+ // This constant was used in RelocInfo::target_address_address() function -+ // to tell serializer address of the instruction that follows -+ // LUI/ORI instruction pair. -+ // TODO check this -+ static constexpr int kInstructionsFor64BitConstant = 4; -+ -+ // Difference between address of current opcode and target address offset. -+ static constexpr int kBranchPCOffset = 0; -+ -+ // Difference between address of current opcode and target address offset, -+ // when we are generatinga sequence of instructions for long relative PC -+ // branches -+ static constexpr int kLongBranchPCOffset = 0; // 3 * kInstrSize; -+ -+ // Max offset for instructions with 16-bit offset field -+ static constexpr int kMax16BranchOffset = (1 << (18 - 1)) - 1; -+ -+ // Max offset for instructions with 21-bit offset field -+ static constexpr int kMax21BranchOffset = (1 << (23 - 1)) - 1; -+ -+ // Max offset for compact branch instructions with 26-bit offset field -+ static constexpr int kMax26BranchOffset = (1 << (28 - 1)) - 1; -+ -+ static constexpr int kTrampolineSlotsSize = 2 * kInstrSize; -+ -+ RegList* GetScratchRegisterList() { return &scratch_register_list_; } -+ -+ // --------------------------------------------------------------------------- -+ // Code generation. -+ -+ // Insert the smallest number of nop instructions -+ // possible to align the pc offset to a multiple -+ // of m. m must be a power of 2 (>= 4). -+ void Align(int m); -+ // Insert the smallest number of zero bytes possible to align the pc offset -+ // to a mulitple of m. m must be a power of 2 (>= 2). -+ void DataAlign(int m); -+ // Aligns code to something that's optimal for a jump target for the platform. -+ void CodeTargetAlign(); -+ -+ // Different nop operations are used by the code generator to detect certain -+ // states of the generated code. -+ enum NopMarkerTypes { -+ NON_MARKING_NOP = 0, -+ DEBUG_BREAK_NOP, -+ // IC markers. -+ PROPERTY_ACCESS_INLINED, -+ PROPERTY_ACCESS_INLINED_CONTEXT, -+ PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, -+ // Helper values. -+ LAST_CODE_MARKER, -+ FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED, -+ }; -+ -+ // Type == 0 is the default non-marking nop. For loongisa this is a -+ // andi(zero_reg, zero_reg, 0). We use rt_reg == r1 for non-zero -+ // marking, to avoid conflict with ssnop and ehb instructions. -+ void nop(unsigned int type = 0) { -+ DCHECK_LT(type, 32); -+ Register nop_rt_reg = (type == 0) ? zero_reg : t7; -+ andi(zero_reg, nop_rt_reg, type); -+ } -+ -+ // --------Branch-and-jump-instructions---------- -+ // We don't use likely variant of instructions. -+ void b(int32_t offset); -+ inline void b(Label* L) { b(shifted_branch_offset26(L)); } -+ void bl(int32_t offset); -+ inline void bl(Label* L) { bl(shifted_branch_offset26(L)); } -+ -+ void beq(Register rj, Register rd, int32_t offset); -+ inline void beq(Register rj, Register rd, Label* L) { -+ beq(rj, rd, shifted_branch_offset(L)); -+ } -+ void bne(Register rj, Register rd, int32_t offset); -+ inline void bne(Register rj, Register rd, Label* L) { -+ bne(rj, rd, shifted_branch_offset(L)); -+ } -+ void blt(Register rj, Register rd, int32_t offset); -+ inline void blt(Register rj, Register rd, Label* L) { -+ blt(rj, rd, shifted_branch_offset(L)); -+ } -+ void bge(Register rj, Register rd, int32_t offset); -+ inline void bge(Register rj, Register rd, Label* L) { -+ bge(rj, rd, shifted_branch_offset(L)); -+ } -+ void bltu(Register rj, Register rd, int32_t offset); -+ inline void bltu(Register rj, Register rd, Label* L) { -+ bltu(rj, rd, shifted_branch_offset(L)); -+ } -+ void bgeu(Register rj, Register rd, int32_t offset); -+ inline void bgeu(Register rj, Register rd, Label* L) { -+ bgeu(rj, rd, shifted_branch_offset(L)); -+ } -+ void beqz(Register rj, int32_t offset); -+ inline void beqz(Register rj, Label* L) { -+ beqz(rj, shifted_branch_offset21(L)); -+ } -+ void bnez(Register rj, int32_t offset); -+ inline void bnez(Register rj, Label* L) { -+ bnez(rj, shifted_branch_offset21(L)); -+ } -+ -+ void jirl(Register rd, Register rj, int32_t offset); -+ -+ void bceqz(CFRegister cj, int32_t si21); -+ inline void bceqz(CFRegister cj, Label* L) { -+ bceqz(cj, shifted_branch_offset21(L)); -+ } -+ void bcnez(CFRegister cj, int32_t si21); -+ inline void bcnez(CFRegister cj, Label* L) { -+ bcnez(cj, shifted_branch_offset21(L)); -+ } -+ -+ // -------Data-processing-instructions--------- -+ -+ // Arithmetic. -+ void add_w(Register rd, Register rj, Register rk); -+ void add_d(Register rd, Register rj, Register rk); -+ void sub_w(Register rd, Register rj, Register rk); -+ void sub_d(Register rd, Register rj, Register rk); -+ -+ void addi_w(Register rd, Register rj, int32_t si12); -+ void addi_d(Register rd, Register rj, int32_t si12); -+ -+ void addu16i_d(Register rd, Register rj, int32_t si16); -+ -+ void alsl_w(Register rd, Register rj, Register rk, int32_t sa2); -+ void alsl_wu(Register rd, Register rj, Register rk, int32_t sa2); -+ void alsl_d(Register rd, Register rj, Register rk, int32_t sa2); -+ -+ void lu12i_w(Register rd, int32_t si20); -+ void lu32i_d(Register rd, int32_t si20); -+ void lu52i_d(Register rd, Register rj, int32_t si12); -+ -+ void slt(Register rd, Register rj, Register rk); -+ void sltu(Register rd, Register rj, Register rk); -+ void slti(Register rd, Register rj, int32_t si12); -+ void sltui(Register rd, Register rj, int32_t si12); -+ -+ void pcaddi(Register rd, int32_t si20); -+ void pcaddu12i(Register rd, int32_t si20); -+ void pcaddu18i(Register rd, int32_t si20); -+ void pcalau12i(Register rd, int32_t si20); -+ -+ void and_(Register rd, Register rj, Register rk); -+ void or_(Register rd, Register rj, Register rk); -+ void xor_(Register rd, Register rj, Register rk); -+ void nor(Register rd, Register rj, Register rk); -+ void andn(Register rd, Register rj, Register rk); -+ void orn(Register rd, Register rj, Register rk); -+ -+ void andi(Register rd, Register rj, int32_t ui12); -+ void ori(Register rd, Register rj, int32_t ui12); -+ void xori(Register rd, Register rj, int32_t ui12); -+ -+ void mul_w(Register rd, Register rj, Register rk); -+ void mulh_w(Register rd, Register rj, Register rk); -+ void mulh_wu(Register rd, Register rj, Register rk); -+ void mul_d(Register rd, Register rj, Register rk); -+ void mulh_d(Register rd, Register rj, Register rk); -+ void mulh_du(Register rd, Register rj, Register rk); -+ -+ void mulw_d_w(Register rd, Register rj, Register rk); -+ void mulw_d_wu(Register rd, Register rj, Register rk); -+ -+ void div_w(Register rd, Register rj, Register rk); -+ void mod_w(Register rd, Register rj, Register rk); -+ void div_wu(Register rd, Register rj, Register rk); -+ void mod_wu(Register rd, Register rj, Register rk); -+ void div_d(Register rd, Register rj, Register rk); -+ void mod_d(Register rd, Register rj, Register rk); -+ void div_du(Register rd, Register rj, Register rk); -+ void mod_du(Register rd, Register rj, Register rk); -+ -+ // Shifts. -+ void sll_w(Register rd, Register rj, Register rk); -+ void srl_w(Register rd, Register rj, Register rk); -+ void sra_w(Register rd, Register rj, Register rk); -+ void rotr_w(Register rd, Register rj, Register rk); -+ -+ void slli_w(Register rd, Register rj, int32_t ui5); -+ void srli_w(Register rd, Register rj, int32_t ui5); -+ void srai_w(Register rd, Register rj, int32_t ui5); -+ void rotri_w(Register rd, Register rj, int32_t ui5); -+ -+ void sll_d(Register rd, Register rj, Register rk); -+ void srl_d(Register rd, Register rj, Register rk); -+ void sra_d(Register rd, Register rj, Register rk); -+ void rotr_d(Register rd, Register rj, Register rk); -+ -+ void slli_d(Register rd, Register rj, int32_t ui6); -+ void srli_d(Register rd, Register rj, int32_t ui6); -+ void srai_d(Register rd, Register rj, int32_t ui6); -+ void rotri_d(Register rd, Register rj, int32_t ui6); -+ -+ // Bit twiddling. -+ void ext_w_b(Register rd, Register rj); -+ void ext_w_h(Register rd, Register rj); -+ -+ void clo_w(Register rd, Register rj); -+ void clz_w(Register rd, Register rj); -+ void cto_w(Register rd, Register rj); -+ void ctz_w(Register rd, Register rj); -+ void clo_d(Register rd, Register rj); -+ void clz_d(Register rd, Register rj); -+ void cto_d(Register rd, Register rj); -+ void ctz_d(Register rd, Register rj); -+ -+ void bytepick_w(Register rd, Register rj, Register rk, int32_t sa2); -+ void bytepick_d(Register rd, Register rj, Register rk, int32_t sa3); -+ -+ void revb_2h(Register rd, Register rj); -+ void revb_4h(Register rd, Register rj); -+ void revb_2w(Register rd, Register rj); -+ void revb_d(Register rd, Register rj); -+ -+ void revh_2w(Register rd, Register rj); -+ void revh_d(Register rd, Register rj); -+ -+ void bitrev_4b(Register rd, Register rj); -+ void bitrev_8b(Register rd, Register rj); -+ -+ void bitrev_w(Register rd, Register rj); -+ void bitrev_d(Register rd, Register rj); -+ -+ void bstrins_w(Register rd, Register rj, int32_t msbw, int32_t lsbw); -+ void bstrins_d(Register rd, Register rj, int32_t msbd, int32_t lsbd); -+ -+ void bstrpick_w(Register rd, Register rj, int32_t msbw, int32_t lsbw); -+ void bstrpick_d(Register rd, Register rj, int32_t msbd, int32_t lsbd); -+ -+ void maskeqz(Register rd, Register rj, Register rk); -+ void masknez(Register rd, Register rj, Register rk); -+ -+ // Memory-instructions -+ void ld_b(Register rd, Register rj, int32_t si12); -+ void ld_h(Register rd, Register rj, int32_t si12); -+ void ld_w(Register rd, Register rj, int32_t si12); -+ void ld_d(Register rd, Register rj, int32_t si12); -+ void ld_bu(Register rd, Register rj, int32_t si12); -+ void ld_hu(Register rd, Register rj, int32_t si12); -+ void ld_wu(Register rd, Register rj, int32_t si12); -+ void st_b(Register rd, Register rj, int32_t si12); -+ void st_h(Register rd, Register rj, int32_t si12); -+ void st_w(Register rd, Register rj, int32_t si12); -+ void st_d(Register rd, Register rj, int32_t si12); -+ -+ void ldx_b(Register rd, Register rj, Register rk); -+ void ldx_h(Register rd, Register rj, Register rk); -+ void ldx_w(Register rd, Register rj, Register rk); -+ void ldx_d(Register rd, Register rj, Register rk); -+ void ldx_bu(Register rd, Register rj, Register rk); -+ void ldx_hu(Register rd, Register rj, Register rk); -+ void ldx_wu(Register rd, Register rj, Register rk); -+ void stx_b(Register rd, Register rj, Register rk); -+ void stx_h(Register rd, Register rj, Register rk); -+ void stx_w(Register rd, Register rj, Register rk); -+ void stx_d(Register rd, Register rj, Register rk); -+ -+ void ldptr_w(Register rd, Register rj, int32_t si14); -+ void ldptr_d(Register rd, Register rj, int32_t si14); -+ void stptr_w(Register rd, Register rj, int32_t si14); -+ void stptr_d(Register rd, Register rj, int32_t si14); -+ -+ void amswap_w(Register rd, Register rk, Register rj); -+ void amswap_d(Register rd, Register rk, Register rj); -+ void amadd_w(Register rd, Register rk, Register rj); -+ void amadd_d(Register rd, Register rk, Register rj); -+ void amand_w(Register rd, Register rk, Register rj); -+ void amand_d(Register rd, Register rk, Register rj); -+ void amor_w(Register rd, Register rk, Register rj); -+ void amor_d(Register rd, Register rk, Register rj); -+ void amxor_w(Register rd, Register rk, Register rj); -+ void amxor_d(Register rd, Register rk, Register rj); -+ void ammax_w(Register rd, Register rk, Register rj); -+ void ammax_d(Register rd, Register rk, Register rj); -+ void ammin_w(Register rd, Register rk, Register rj); -+ void ammin_d(Register rd, Register rk, Register rj); -+ void ammax_wu(Register rd, Register rk, Register rj); -+ void ammax_du(Register rd, Register rk, Register rj); -+ void ammin_wu(Register rd, Register rk, Register rj); -+ void ammin_du(Register rd, Register rk, Register rj); -+ -+ void amswap_db_w(Register rd, Register rk, Register rj); -+ void amswap_db_d(Register rd, Register rk, Register rj); -+ void amadd_db_w(Register rd, Register rk, Register rj); -+ void amadd_db_d(Register rd, Register rk, Register rj); -+ void amand_db_w(Register rd, Register rk, Register rj); -+ void amand_db_d(Register rd, Register rk, Register rj); -+ void amor_db_w(Register rd, Register rk, Register rj); -+ void amor_db_d(Register rd, Register rk, Register rj); -+ void amxor_db_w(Register rd, Register rk, Register rj); -+ void amxor_db_d(Register rd, Register rk, Register rj); -+ void ammax_db_w(Register rd, Register rk, Register rj); -+ void ammax_db_d(Register rd, Register rk, Register rj); -+ void ammin_db_w(Register rd, Register rk, Register rj); -+ void ammin_db_d(Register rd, Register rk, Register rj); -+ void ammax_db_wu(Register rd, Register rk, Register rj); -+ void ammax_db_du(Register rd, Register rk, Register rj); -+ void ammin_db_wu(Register rd, Register rk, Register rj); -+ void ammin_db_du(Register rd, Register rk, Register rj); -+ -+ void ll_w(Register rd, Register rj, int32_t si14); -+ void ll_d(Register rd, Register rj, int32_t si14); -+ void sc_w(Register rd, Register rj, int32_t si14); -+ void sc_d(Register rd, Register rj, int32_t si14); -+ -+ void dbar(int32_t hint); -+ void ibar(int32_t hint); -+ -+ // Break / Trap instructions. -+ void break_(uint32_t code, bool break_as_stop = false); -+ void stop(uint32_t code = kMaxStopCode); -+ -+ // Arithmetic. -+ void fadd_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fadd_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fsub_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fsub_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmul_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmul_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fdiv_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fdiv_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ -+ void fmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fnmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fnmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fnmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ void fnmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); -+ -+ void fmax_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmax_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmin_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmin_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ -+ void fmaxa_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmaxa_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmina_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fmina_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ -+ void fabs_s(FPURegister fd, FPURegister fj); -+ void fabs_d(FPURegister fd, FPURegister fj); -+ void fneg_s(FPURegister fd, FPURegister fj); -+ void fneg_d(FPURegister fd, FPURegister fj); -+ -+ void fsqrt_s(FPURegister fd, FPURegister fj); -+ void fsqrt_d(FPURegister fd, FPURegister fj); -+ void frecip_s(FPURegister fd, FPURegister fj); -+ void frecip_d(FPURegister fd, FPURegister fj); -+ void frsqrt_s(FPURegister fd, FPURegister fj); -+ void frsqrt_d(FPURegister fd, FPURegister fj); -+ -+ void fscaleb_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fscaleb_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ void flogb_s(FPURegister fd, FPURegister fj); -+ void flogb_d(FPURegister fd, FPURegister fj); -+ void fcopysign_s(FPURegister fd, FPURegister fj, FPURegister fk); -+ void fcopysign_d(FPURegister fd, FPURegister fj, FPURegister fk); -+ -+ void fclass_s(FPURegister fd, FPURegister fj); -+ void fclass_d(FPURegister fd, FPURegister fj); -+ -+ void fcmp_cond_s(FPUCondition cc, FPURegister fj, FPURegister fk, -+ CFRegister cd); -+ void fcmp_cond_d(FPUCondition cc, FPURegister fj, FPURegister fk, -+ CFRegister cd); -+ -+ void fcvt_s_d(FPURegister fd, FPURegister fj); -+ void fcvt_d_s(FPURegister fd, FPURegister fj); -+ -+ void ffint_s_w(FPURegister fd, FPURegister fj); -+ void ffint_s_l(FPURegister fd, FPURegister fj); -+ void ffint_d_w(FPURegister fd, FPURegister fj); -+ void ffint_d_l(FPURegister fd, FPURegister fj); -+ void ftint_w_s(FPURegister fd, FPURegister fj); -+ void ftint_w_d(FPURegister fd, FPURegister fj); -+ void ftint_l_s(FPURegister fd, FPURegister fj); -+ void ftint_l_d(FPURegister fd, FPURegister fj); -+ -+ void ftintrm_w_s(FPURegister fd, FPURegister fj); -+ void ftintrm_w_d(FPURegister fd, FPURegister fj); -+ void ftintrm_l_s(FPURegister fd, FPURegister fj); -+ void ftintrm_l_d(FPURegister fd, FPURegister fj); -+ void ftintrp_w_s(FPURegister fd, FPURegister fj); -+ void ftintrp_w_d(FPURegister fd, FPURegister fj); -+ void ftintrp_l_s(FPURegister fd, FPURegister fj); -+ void ftintrp_l_d(FPURegister fd, FPURegister fj); -+ void ftintrz_w_s(FPURegister fd, FPURegister fj); -+ void ftintrz_w_d(FPURegister fd, FPURegister fj); -+ void ftintrz_l_s(FPURegister fd, FPURegister fj); -+ void ftintrz_l_d(FPURegister fd, FPURegister fj); -+ void ftintrne_w_s(FPURegister fd, FPURegister fj); -+ void ftintrne_w_d(FPURegister fd, FPURegister fj); -+ void ftintrne_l_s(FPURegister fd, FPURegister fj); -+ void ftintrne_l_d(FPURegister fd, FPURegister fj); -+ -+ void frint_s(FPURegister fd, FPURegister fj); -+ void frint_d(FPURegister fd, FPURegister fj); -+ -+ void fmov_s(FPURegister fd, FPURegister fj); -+ void fmov_d(FPURegister fd, FPURegister fj); -+ -+ void fsel(CFRegister ca, FPURegister fd, FPURegister fj, FPURegister fk); -+ -+ void movgr2fr_w(FPURegister fd, Register rj); -+ void movgr2fr_d(FPURegister fd, Register rj); -+ void movgr2frh_w(FPURegister fd, Register rj); -+ -+ void movfr2gr_s(Register rd, FPURegister fj); -+ void movfr2gr_d(Register rd, FPURegister fj); -+ void movfrh2gr_s(Register rd, FPURegister fj); -+ -+ void movgr2fcsr(Register rj); -+ void movfcsr2gr(Register rd); -+ -+ void movfr2cf(CFRegister cd, FPURegister fj); -+ void movcf2fr(FPURegister fd, CFRegister cj); -+ -+ void movgr2cf(CFRegister cd, Register rj); -+ void movcf2gr(Register rd, CFRegister cj); -+ -+ void fld_s(FPURegister fd, Register rj, int32_t si12); -+ void fld_d(FPURegister fd, Register rj, int32_t si12); -+ void fst_s(FPURegister fd, Register rj, int32_t si12); -+ void fst_d(FPURegister fd, Register rj, int32_t si12); -+ -+ void fldx_s(FPURegister fd, Register rj, Register rk); -+ void fldx_d(FPURegister fd, Register rj, Register rk); -+ void fstx_s(FPURegister fd, Register rj, Register rk); -+ void fstx_d(FPURegister fd, Register rj, Register rk); -+ -+ // Check the code size generated from label to here. -+ int SizeOfCodeGeneratedSince(Label* label) { -+ return pc_offset() - label->pos(); -+ } -+ -+ // Check the number of instructions generated from label to here. -+ int InstructionsGeneratedSince(Label* label) { -+ return SizeOfCodeGeneratedSince(label) / kInstrSize; -+ } -+ -+ // Class for scoping postponing the trampoline pool generation. -+ class BlockTrampolinePoolScope { -+ public: -+ explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) { -+ assem_->StartBlockTrampolinePool(); -+ } -+ ~BlockTrampolinePoolScope() { assem_->EndBlockTrampolinePool(); } -+ -+ private: -+ Assembler* assem_; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope); -+ }; -+ -+ // Class for postponing the assembly buffer growth. Typically used for -+ // sequences of instructions that must be emitted as a unit, before -+ // buffer growth (and relocation) can occur. -+ // This blocking scope is not nestable. -+ class BlockGrowBufferScope { -+ public: -+ explicit BlockGrowBufferScope(Assembler* assem) : assem_(assem) { -+ assem_->StartBlockGrowBuffer(); -+ } -+ ~BlockGrowBufferScope() { assem_->EndBlockGrowBuffer(); } -+ -+ private: -+ Assembler* assem_; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope); -+ }; -+ -+ // Record a deoptimization reason that can be used by a log or cpu profiler. -+ // Use --trace-deopt to enable. -+ void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, -+ int id); -+ -+ static int RelocateInternalReference(RelocInfo::Mode rmode, Address pc, -+ intptr_t pc_delta); -+ -+ // Writes a single byte or word of data in the code stream. Used for -+ // inline tables, e.g., jump-tables. -+ void db(uint8_t data); -+ void dd(uint32_t data); -+ void dq(uint64_t data); -+ void dp(uintptr_t data) { dq(data); } -+ void dd(Label* label); -+ -+ // Postpone the generation of the trampoline pool for the specified number of -+ // instructions. -+ void BlockTrampolinePoolFor(int instructions); -+ -+ // Check if there is less than kGap bytes available in the buffer. -+ // If this is the case, we need to grow the buffer before emitting -+ // an instruction or relocation information. -+ inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } -+ -+ // Get the number of bytes available in the buffer. -+ inline intptr_t available_space() const { -+ return reloc_info_writer.pos() - pc_; -+ } -+ -+ // Read/patch instructions. -+ static Instr instr_at(Address pc) { return *reinterpret_cast(pc); } -+ static void instr_at_put(Address pc, Instr instr) { -+ *reinterpret_cast(pc) = instr; -+ } -+ Instr instr_at(int pos) { -+ return *reinterpret_cast(buffer_start_ + pos); -+ } -+ void instr_at_put(int pos, Instr instr) { -+ *reinterpret_cast(buffer_start_ + pos) = instr; -+ } -+ -+ // Check if an instruction is a branch of some kind. -+ static bool IsBranch(Instr instr); -+ static bool IsB(Instr instr); -+ static bool IsBz(Instr instr); -+ static bool IsNal(Instr instr); -+ -+ static bool IsBeq(Instr instr); -+ static bool IsBne(Instr instr); -+ -+ static bool IsJump(Instr instr); -+ static bool IsMov(Instr instr, Register rd, Register rs); -+ static bool IsPcAddi(Instr instr, Register rd, int32_t si20); -+ -+ static bool IsJ(Instr instr); -+ static bool IsLu12i_w(Instr instr); -+ static bool IsOri(Instr instr); -+ static bool IsLu32i_d(Instr instr); -+ static bool IsLu52i_d(Instr instr); -+ -+ static bool IsNop(Instr instr, unsigned int type); -+ static bool IsPop(Instr instr); -+ static bool IsPush(Instr instr); -+ // static bool IsLwRegFpOffset(Instr instr); -+ // static bool IsSwRegFpOffset(Instr instr); -+ // static bool IsLwRegFpNegOffset(Instr instr); -+ // static bool IsSwRegFpNegOffset(Instr instr); -+ -+ static Register GetRjReg(Instr instr); -+ static Register GetRkReg(Instr instr); -+ static Register GetRdReg(Instr instr); -+ -+ static uint32_t GetRj(Instr instr); -+ static uint32_t GetRjField(Instr instr); -+ static uint32_t GetRk(Instr instr); -+ static uint32_t GetRkField(Instr instr); -+ static uint32_t GetRd(Instr instr); -+ static uint32_t GetRdField(Instr instr); -+ static uint32_t GetSa2(Instr instr); -+ static uint32_t GetSa3(Instr instr); -+ static uint32_t GetSa2Field(Instr instr); -+ static uint32_t GetSa3Field(Instr instr); -+ static uint32_t GetOpcodeField(Instr instr); -+ static uint32_t GetFunction(Instr instr); -+ static uint32_t GetFunctionField(Instr instr); -+ static uint32_t GetImmediate16(Instr instr); -+ static uint32_t GetLabelConst(Instr instr); -+ -+ static bool IsAddImmediate(Instr instr); -+ static Instr SetAddImmediateOffset(Instr instr, int16_t offset); -+ -+ static bool IsAndImmediate(Instr instr); -+ static bool IsEmittedConstant(Instr instr); -+ -+ void CheckTrampolinePool(); -+ -+ inline int UnboundLabelsCount() { return unbound_labels_count_; } -+ -+ protected: -+ // Helper function for memory load/store. -+ void AdjustBaseAndOffset(MemOperand* src); -+ -+ inline static void set_target_internal_reference_encoded_at(Address pc, -+ Address target); -+ -+ int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } -+ -+ // Decode branch instruction at pos and return branch target pos. -+ int target_at(int pos, bool is_internal); -+ -+ // Patch branch instruction at pos to branch to given branch target pos. -+ void target_at_put(int pos, int target_pos, bool is_internal); -+ -+ // Say if we need to relocate with this mode. -+ bool MustUseReg(RelocInfo::Mode rmode); -+ -+ // Record reloc info for current pc_. -+ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); -+ -+ // Block the emission of the trampoline pool before pc_offset. -+ void BlockTrampolinePoolBefore(int pc_offset) { -+ if (no_trampoline_pool_before_ < pc_offset) -+ no_trampoline_pool_before_ = pc_offset; -+ } -+ -+ void StartBlockTrampolinePool() { trampoline_pool_blocked_nesting_++; } -+ -+ void EndBlockTrampolinePool() { -+ trampoline_pool_blocked_nesting_--; -+ if (trampoline_pool_blocked_nesting_ == 0) { -+ CheckTrampolinePoolQuick(1); -+ } -+ } -+ -+ bool is_trampoline_pool_blocked() const { -+ return trampoline_pool_blocked_nesting_ > 0; -+ } -+ -+ bool has_exception() const { return internal_trampoline_exception_; } -+ -+ bool is_trampoline_emitted() const { return trampoline_emitted_; } -+ -+ // Temporarily block automatic assembly buffer growth. -+ void StartBlockGrowBuffer() { -+ DCHECK(!block_buffer_growth_); -+ block_buffer_growth_ = true; -+ } -+ -+ void EndBlockGrowBuffer() { -+ DCHECK(block_buffer_growth_); -+ block_buffer_growth_ = false; -+ } -+ -+ bool is_buffer_growth_blocked() const { return block_buffer_growth_; } -+ -+ void CheckTrampolinePoolQuick(int extra_instructions = 0) { -+ if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { -+ CheckTrampolinePool(); -+ } -+ } -+ -+ void set_last_call_pc_(byte* pc) { last_call_pc_ = pc; } -+ -+ private: -+ // Avoid overflows for displacements etc. -+ static const int kMaximalBufferSize = 512 * MB; -+ -+ // Buffer size and constant pool distance are checked together at regular -+ // intervals of kBufferCheckInterval emitted bytes. -+ static constexpr int kBufferCheckInterval = 1 * KB / 2; -+ -+ // Code generation. -+ // The relocation writer's position is at least kGap bytes below the end of -+ // the generated instructions. This is so that multi-instruction sequences do -+ // not have to check for overflow. The same is true for writes of large -+ // relocation info entries. -+ static constexpr int kGap = 64; -+ STATIC_ASSERT(AssemblerBase::kMinimalBufferSize >= 2 * kGap); -+ -+ // Repeated checking whether the trampoline pool should be emitted is rather -+ // expensive. By default we only check again once a number of instructions -+ // has been generated. -+ static constexpr int kCheckConstIntervalInst = 32; -+ static constexpr int kCheckConstInterval = -+ kCheckConstIntervalInst * kInstrSize; -+ -+ int next_buffer_check_; // pc offset of next buffer check. -+ -+ // Emission of the trampoline pool may be blocked in some code sequences. -+ int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. -+ int no_trampoline_pool_before_; // Block emission before this pc offset. -+ -+ // Keep track of the last emitted pool to guarantee a maximal distance. -+ int last_trampoline_pool_end_; // pc offset of the end of the last pool. -+ -+ // Automatic growth of the assembly buffer may be blocked for some sequences. -+ bool block_buffer_growth_; // Block growth when true. -+ -+ // Relocation information generation. -+ // Each relocation is encoded as a variable size value. -+ static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; -+ RelocInfoWriter reloc_info_writer; -+ -+ // The bound position, before this we cannot do instruction elimination. -+ int last_bound_pos_; -+ -+ // Code emission. -+ inline void CheckBuffer(); -+ void GrowBuffer(); -+ inline void emit(Instr x); -+ inline void emit(uint64_t x); -+ // inline void CheckForEmitInForbiddenSlot(); -+ template -+ inline void EmitHelper(T x); -+ inline void EmitHelper(Instr x); -+ -+ void GenB(Opcode opcode, Register rj, int32_t si21); // opcode:6 -+ void GenB(Opcode opcode, CFRegister cj, int32_t si21, bool isEq); -+ void GenB(Opcode opcode, int32_t si26); -+ void GenBJ(Opcode opcode, Register rj, Register rd, int32_t si16); -+ void GenCmp(Opcode opcode, FPUCondition cond, FPURegister fk, FPURegister fj, -+ CFRegister cd); -+ void GenSel(Opcode opcode, CFRegister ca, FPURegister fk, FPURegister fj, -+ FPURegister rd); -+ -+ void GenRegister(Opcode opcode, Register rj, Register rd, bool rjrd = true); -+ void GenRegister(Opcode opcode, FPURegister fj, FPURegister fd); -+ void GenRegister(Opcode opcode, Register rj, FPURegister fd); -+ void GenRegister(Opcode opcode, FPURegister fj, Register rd); -+ void GenRegister(Opcode opcode, Register rj, FPUControlRegister fd); -+ void GenRegister(Opcode opcode, FPUControlRegister fj, Register rd); -+ void GenRegister(Opcode opcode, FPURegister fj, CFRegister cd); -+ void GenRegister(Opcode opcode, CFRegister cj, FPURegister fd); -+ void GenRegister(Opcode opcode, Register rj, CFRegister cd); -+ void GenRegister(Opcode opcode, CFRegister cj, Register rd); -+ -+ void GenRegister(Opcode opcode, Register rk, Register rj, Register rd); -+ void GenRegister(Opcode opcode, FPURegister fk, FPURegister fj, -+ FPURegister fd); -+ -+ void GenRegister(Opcode opcode, FPURegister fa, FPURegister fk, -+ FPURegister fj, FPURegister fd); -+ void GenRegister(Opcode opcode, Register rk, Register rj, FPURegister fd); -+ -+ void GenImm(Opcode opcode, int32_t bit3, Register rk, Register rj, -+ Register rd); -+ void GenImm(Opcode opcode, int32_t bit6m, int32_t bit6l, Register rj, -+ Register rd); -+ void GenImm(Opcode opcode, int32_t bit20, Register rd); -+ void GenImm(Opcode opcode, int32_t bit15); -+ void GenImm(Opcode opcode, int32_t value, Register rj, Register rd, -+ int32_t value_bits); // 6 | 12 | 14 | 16 -+ void GenImm(Opcode opcode, int32_t bit12, Register rj, FPURegister fd); -+ -+ // Labels. -+ void print(const Label* L); -+ void bind_to(Label* L, int pos); -+ void next(Label* L, bool is_internal); -+ -+ // One trampoline consists of: -+ // - space for trampoline slots, -+ // - space for labels. -+ // -+ // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. -+ // Space for trampoline slots precedes space for labels. Each label is of one -+ // instruction size, so total amount for labels is equal to -+ // label_count * kInstrSize. -+ class Trampoline { -+ public: -+ Trampoline() { -+ start_ = 0; -+ next_slot_ = 0; -+ free_slot_count_ = 0; -+ end_ = 0; -+ } -+ Trampoline(int start, int slot_count) { -+ start_ = start; -+ next_slot_ = start; -+ free_slot_count_ = slot_count; -+ end_ = start + slot_count * kTrampolineSlotsSize; -+ } -+ int start() { return start_; } -+ int end() { return end_; } -+ int take_slot() { -+ int trampoline_slot = kInvalidSlotPos; -+ if (free_slot_count_ <= 0) { -+ // We have run out of space on trampolines. -+ // Make sure we fail in debug mode, so we become aware of each case -+ // when this happens. -+ DCHECK(0); -+ // Internal exception will be caught. -+ } else { -+ trampoline_slot = next_slot_; -+ free_slot_count_--; -+ next_slot_ += kTrampolineSlotsSize; -+ } -+ return trampoline_slot; -+ } -+ -+ private: -+ int start_; -+ int end_; -+ int next_slot_; -+ int free_slot_count_; -+ }; -+ -+ int32_t get_trampoline_entry(int32_t pos); -+ int unbound_labels_count_; -+ // After trampoline is emitted, long branches are used in generated code for -+ // the forward branches whose target offsets could be beyond reach of branch -+ // instruction. We use this information to trigger different mode of -+ // branch instruction generation, where we use jump instructions rather -+ // than regular branch instructions. -+ bool trampoline_emitted_; -+ static constexpr int kInvalidSlotPos = -1; -+ -+ // Internal reference positions, required for unbounded internal reference -+ // labels. -+ std::set internal_reference_positions_; -+ bool is_internal_reference(Label* L) { -+ return internal_reference_positions_.find(L->pos()) != -+ internal_reference_positions_.end(); -+ } -+ -+ void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } -+ void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } -+ bool prev_instr_compact_branch_ = false; -+ -+ Trampoline trampoline_; -+ bool internal_trampoline_exception_; -+ -+ // Keep track of the last Call's position to ensure that safepoint can get the -+ // correct information even if there is a trampoline immediately after the -+ // Call. -+ byte* last_call_pc_; -+ -+ RegList scratch_register_list_; -+ -+ private: -+ void AllocateAndInstallRequestedHeapObjects(Isolate* isolate); -+ -+ int WriteCodeComments(); -+ -+ friend class RegExpMacroAssemblerMIPS; -+ friend class RelocInfo; -+ friend class BlockTrampolinePoolScope; -+ friend class EnsureSpace; -+}; -+ -+class EnsureSpace { -+ public: -+ explicit inline EnsureSpace(Assembler* assembler); -+}; -+ -+class V8_EXPORT_PRIVATE UseScratchRegisterScope { -+ public: -+ explicit UseScratchRegisterScope(Assembler* assembler); -+ ~UseScratchRegisterScope(); -+ -+ Register Acquire(); -+ bool hasAvailable() const; -+ -+ private: -+ RegList* available_; -+ RegList old_available_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.cc b/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.cc -new file mode 100644 -index 000000000..307e2e72e ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.cc -@@ -0,0 +1,100 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+ -+namespace v8 { -+namespace internal { -+ -+// ----------------------------------------------------------------------------- -+// Registers. -+ -+// These register names are defined in a way to match the native disassembler -+// formatting. See for example the command "objdump -d ". -+const char* Registers::names_[kNumSimuRegisters] = { -+ "zero_reg", "ra", "gp", "sp", "a0", "a1", "a2", "a3", "a4", "a5", "a6", -+ "a7", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "tp", -+ "fp", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "pc"}; -+ -+// List of alias names which can be used when referring to MIPS registers. -+const Registers::RegisterAlias Registers::aliases_[] = { -+ {0, "zero"}, {23, "cp"}, {kInvalidRegister, nullptr}}; -+ -+const char* Registers::Name(int reg) { -+ const char* result; -+ if ((0 <= reg) && (reg < kNumSimuRegisters)) { -+ result = names_[reg]; -+ } else { -+ result = "noreg"; -+ } -+ return result; -+} -+ -+int Registers::Number(const char* name) { -+ // Look through the canonical names. -+ for (int i = 0; i < kNumSimuRegisters; i++) { -+ if (strcmp(names_[i], name) == 0) { -+ return i; -+ } -+ } -+ -+ // Look through the alias names. -+ int i = 0; -+ while (aliases_[i].reg != kInvalidRegister) { -+ if (strcmp(aliases_[i].name, name) == 0) { -+ return aliases_[i].reg; -+ } -+ i++; -+ } -+ -+ // No register with the reguested name found. -+ return kInvalidRegister; -+} -+ -+const char* FPURegisters::names_[kNumFPURegisters] = { -+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", -+ "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", -+ "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"}; -+ -+// List of alias names which can be used when referring to MIPS registers. -+const FPURegisters::RegisterAlias FPURegisters::aliases_[] = { -+ {kInvalidRegister, nullptr}}; -+ -+const char* FPURegisters::Name(int creg) { -+ const char* result; -+ if ((0 <= creg) && (creg < kNumFPURegisters)) { -+ result = names_[creg]; -+ } else { -+ result = "nocreg"; -+ } -+ return result; -+} -+ -+int FPURegisters::Number(const char* name) { -+ // Look through the canonical names. -+ for (int i = 0; i < kNumFPURegisters; i++) { -+ if (strcmp(names_[i], name) == 0) { -+ return i; -+ } -+ } -+ -+ // Look through the alias names. -+ int i = 0; -+ while (aliases_[i].creg != kInvalidRegister) { -+ if (strcmp(aliases_[i].name, name) == 0) { -+ return aliases_[i].creg; -+ } -+ i++; -+ } -+ -+ // No Cregister with the reguested name found. -+ return kInvalidFPURegister; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.h b/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.h -new file mode 100644 -index 000000000..0bac68014 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.h -@@ -0,0 +1,1340 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ -+#define V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ -+ -+#include "src/base/logging.h" -+#include "src/base/macros.h" -+#include "src/common/globals.h" -+ -+// UNIMPLEMENTED_ macro for LOONGISA. -+#ifdef DEBUG -+#define UNIMPLEMENTED_LOONGISA() \ -+ v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ -+ __FILE__, __LINE__, __func__) -+#else -+#define UNIMPLEMENTED_LOONGISA() -+#endif -+ -+#define UNSUPPORTED_LOONGISA() \ -+ v8::internal::PrintF("Unsupported instruction.\n") -+ -+const uint32_t kLeastSignificantByteInInt32Offset = 0; -+const uint32_t kLessSignificantWordInDoublewordOffset = 0; -+ -+#ifndef __STDC_FORMAT_MACROS -+#define __STDC_FORMAT_MACROS -+#endif -+#include -+ -+// Defines constants and accessor classes to assemble, disassemble and -+// simulate LA64 instructions. -+ -+namespace v8 { -+namespace internal { -+ -+constexpr size_t kMaxPCRelativeCodeRangeInMB = 128; -+ -+// ----------------------------------------------------------------------------- -+// Registers and FPURegisters. -+ -+// Number of general purpose registers. -+const int kNumRegisters = 32; -+const int kInvalidRegister = -1; -+ -+// Number of registers with pc. -+const int kNumSimuRegisters = 33; -+ -+// In the simulator, the PC register is simulated as the 34th register. -+const int kPCRegister = 32; -+ -+// Number coprocessor registers. -+const int kNumFPURegisters = 32; -+const int kInvalidFPURegister = -1; -+ -+// FPU (coprocessor 1) control registers. Currently only FCSR is implemented. -+// TODO fcsr0 fcsr1 fcsr2 fcsr3 -+const int kFCSRRegister = 0; -+const int kInvalidFPUControlRegister = -1; -+const uint32_t kFPUInvalidResult = static_cast(1u << 31) - 1; -+const int32_t kFPUInvalidResultNegative = static_cast(1u << 31); -+const uint64_t kFPU64InvalidResult = -+ static_cast(static_cast(1) << 63) - 1; -+const int64_t kFPU64InvalidResultNegative = -+ static_cast(static_cast(1) << 63); -+ -+// FCSR constants. -+// TODO -+const uint32_t kFCSRInexactFlagBit = 16; -+const uint32_t kFCSRUnderflowFlagBit = 17; -+const uint32_t kFCSROverflowFlagBit = 18; -+const uint32_t kFCSRDivideByZeroFlagBit = 19; -+const uint32_t kFCSRInvalidOpFlagBit = 20; -+ -+const uint32_t kFCSRInexactFlagMask = 1 << kFCSRInexactFlagBit; -+const uint32_t kFCSRUnderflowFlagMask = 1 << kFCSRUnderflowFlagBit; -+const uint32_t kFCSROverflowFlagMask = 1 << kFCSROverflowFlagBit; -+const uint32_t kFCSRDivideByZeroFlagMask = 1 << kFCSRDivideByZeroFlagBit; -+const uint32_t kFCSRInvalidOpFlagMask = 1 << kFCSRInvalidOpFlagBit; -+ -+const uint32_t kFCSRFlagMask = -+ kFCSRInexactFlagMask | kFCSRUnderflowFlagMask | kFCSROverflowFlagMask | -+ kFCSRDivideByZeroFlagMask | kFCSRInvalidOpFlagMask; -+ -+const uint32_t kFCSRExceptionFlagMask = kFCSRFlagMask ^ kFCSRInexactFlagMask; -+ -+// Actual value of root register is offset from the root array's start -+// to take advantage of negative displacement values. -+// TODO(sigurds): Choose best value. -+constexpr int kRootRegisterBias = 256; -+ -+// Helper functions for converting between register numbers and names. -+class Registers { -+ public: -+ // Return the name of the register. -+ static const char* Name(int reg); -+ -+ // Lookup the register number for the name provided. -+ static int Number(const char* name); -+ -+ struct RegisterAlias { -+ int reg; -+ const char* name; -+ }; -+ -+ static const int64_t kMaxValue = 0x7fffffffffffffffl; -+ static const int64_t kMinValue = 0x8000000000000000l; -+ -+ private: -+ static const char* names_[kNumSimuRegisters]; -+ static const RegisterAlias aliases_[]; -+}; -+ -+// Helper functions for converting between register numbers and names. -+class FPURegisters { -+ public: -+ // Return the name of the register. -+ static const char* Name(int reg); -+ -+ // Lookup the register number for the name provided. -+ static int Number(const char* name); -+ -+ struct RegisterAlias { -+ int creg; -+ const char* name; -+ }; -+ -+ private: -+ static const char* names_[kNumFPURegisters]; -+ static const RegisterAlias aliases_[]; -+}; -+ -+// ----------------------------------------------------------------------------- -+// Instructions encoding constants. -+ -+// On LoongISA all instructions are 32 bits. -+using Instr = int32_t; -+ -+// Special Software Interrupt codes when used in the presence of the LA64 -+// simulator. -+enum SoftwareInterruptCodes { -+ // Transition to C code. -+ call_rt_redirected = 0x7fff -+}; -+ -+// On LA64 Simulator breakpoints can have different codes: -+// - Breaks between 0 and kMaxWatchpointCode are treated as simple watchpoints, -+// the simulator will run through them and print the registers. -+// - Breaks between kMaxWatchpointCode and kMaxStopCode are treated as stop() -+// instructions (see Assembler::stop()). -+// - Breaks larger than kMaxStopCode are simple breaks, dropping you into the -+// debugger. -+const uint32_t kMaxWatchpointCode = 31; -+const uint32_t kMaxStopCode = 127; -+STATIC_ASSERT(kMaxWatchpointCode < kMaxStopCode); -+ -+// ----- Fields offset and length. -+const int kRjShift = 5; -+const int kRjBits = 5; -+const int kRkShift = 10; -+const int kRkBits = 5; -+const int kRdShift = 0; -+const int kRdBits = 5; -+const int kSaShift = 15; -+const int kSa2Bits = 2; -+const int kSa3Bits = 3; -+const int kCdShift = 0; -+const int kCdBits = 3; -+const int kCjShift = 5; -+const int kCjBits = 3; -+const int kCodeShift = 0; -+const int kCodeBits = 15; -+const int kCondShift = 15; -+const int kCondBits = 5; -+const int kUi5Shift = 10; -+const int kUi5Bits = 5; -+const int kUi6Shift = 10; -+const int kUi6Bits = 6; -+const int kUi12Shift = 10; -+const int kUi12Bits = 12; -+const int kSi12Shift = 10; -+const int kSi12Bits = 12; -+const int kSi14Shift = 10; -+const int kSi14Bits = 14; -+const int kSi16Shift = 10; -+const int kSi16Bits = 16; -+const int kSi20Shift = 5; -+const int kSi20Bits = 20; -+const int kMsbwShift = 16; -+const int kMsbwBits = 5; -+const int kLsbwShift = 10; -+const int kLsbwBits = 5; -+const int kMsbdShift = 16; -+const int kMsbdBits = 6; -+const int kLsbdShift = 10; -+const int kLsbdBits = 6; -+const int kFdShift = 0; -+const int kFdBits = 5; -+const int kFjShift = 5; -+const int kFjBits = 5; -+const int kFkShift = 10; -+const int kFkBits = 5; -+const int kFaShift = 15; -+const int kFaBits = 5; -+const int kCaShift = 15; -+const int kCaBits = 3; -+const int kHint15Shift = 0; -+const int kHint15Bits = 15; -+const int kHint5Shift = 0; -+const int kHint5Bits = 5; -+const int kOffsLowShift = 10; -+const int kOffsLowBits = 16; -+const int kOffs26HighShift = 0; -+const int kOffs26HighBits = 10; -+const int kOffs21HighShift = 0; -+const int kOffs21HighBits = 5; -+const int kImm12Shift = 0; -+const int kImm12Bits = 12; -+const int kImm16Shift = 0; -+const int kImm16Bits = 16; -+const int kImm26Shift = 0; -+const int kImm26Bits = 26; -+const int kImm28Shift = 0; -+const int kImm28Bits = 28; -+const int kImm32Shift = 0; -+const int kImm32Bits = 32; -+ -+// ----- Miscellaneous useful masks. -+// Instruction bit masks. -+const int kRjFieldMask = ((1 << kRjBits) - 1) << kRjShift; -+const int kRkFieldMask = ((1 << kRkBits) - 1) << kRkShift; -+const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; -+const int kSa2FieldMask = ((1 << kSa2Bits) - 1) << kSaShift; -+const int kSa3FieldMask = ((1 << kSa3Bits) - 1) << kSaShift; -+// Misc masks. -+const int kHiMaskOf32 = 0xffff << 16; // Only to be used with 32-bit values -+const int kLoMaskOf32 = 0xffff; -+const int kSignMaskOf32 = 0x80000000; // Only to be used with 32-bit values -+const int64_t kTop16MaskOf64 = (int64_t)0xffff << 48; -+const int64_t kHigher16MaskOf64 = (int64_t)0xffff << 32; -+const int64_t kUpper16MaskOf64 = (int64_t)0xffff << 16; -+ -+const int kImm12Mask = ((1 << kImm12Bits) - 1) << kImm12Shift; -+const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; -+const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; -+const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; -+ -+// ----- LA64 Opcodes and Function Fields. -+enum Opcode : uint32_t { -+ BEQZ = 0x10U << 26, -+ BNEZ = 0x11U << 26, -+ BCZ = 0x12U << 26, // BCEQZ & BCNEZ -+ JIRL = 0x13U << 26, -+ B = 0x14U << 26, -+ BL = 0x15U << 26, -+ BEQ = 0x16U << 26, -+ BNE = 0x17U << 26, -+ BLT = 0x18U << 26, -+ BGE = 0x19U << 26, -+ BLTU = 0x1aU << 26, -+ BGEU = 0x1bU << 26, -+ -+ ADDU16I_D = 0x4U << 26, -+ -+ LU12I_W = 0xaU << 25, -+ LU32I_D = 0xbU << 25, -+ PCADDI = 0xcU << 25, -+ PCALAU12I = 0xdU << 25, -+ PCADDU12I = 0xeU << 25, -+ PCADDU18I = 0xfU << 25, -+ -+ LL_W = 0x20U << 24, -+ SC_W = 0x21U << 24, -+ LL_D = 0x22U << 24, -+ SC_D = 0x23U << 24, -+ LDPTR_W = 0x24U << 24, -+ STPTR_W = 0x25U << 24, -+ LDPTR_D = 0x26U << 24, -+ STPTR_D = 0x27U << 24, -+ -+ BSTR_W = 0x1U << 22, // BSTRINS_W & BSTRPICK_W -+ BSTRINS_W = BSTR_W, -+ BSTRPICK_W = BSTR_W, -+ BSTRINS_D = 0x2U << 22, -+ BSTRPICK_D = 0x3U << 22, -+ -+ SLTI = 0x8U << 22, -+ SLTUI = 0x9U << 22, -+ ADDI_W = 0xaU << 22, -+ ADDI_D = 0xbU << 22, -+ LU52I_D = 0xcU << 22, -+ ANDI = 0xdU << 22, -+ ORI = 0xeU << 22, -+ XORI = 0xfU << 22, -+ -+ LD_B = 0xa0U << 22, -+ LD_H = 0xa1U << 22, -+ LD_W = 0xa2U << 22, -+ LD_D = 0xa3U << 22, -+ ST_B = 0xa4U << 22, -+ ST_H = 0xa5U << 22, -+ ST_W = 0xa6U << 22, -+ ST_D = 0xa7U << 22, -+ LD_BU = 0xa8U << 22, -+ LD_HU = 0xa9U << 22, -+ LD_WU = 0xaaU << 22, -+ FLD_S = 0xacU << 22, -+ FST_S = 0xadU << 22, -+ FLD_D = 0xaeU << 22, -+ FST_D = 0xafU << 22, -+ -+ FMADD_S = 0x81U << 20, -+ FMADD_D = 0x82U << 20, -+ FMSUB_S = 0x85U << 20, -+ FMSUB_D = 0x86U << 20, -+ FNMADD_S = 0x89U << 20, -+ FNMADD_D = 0x8aU << 20, -+ FNMSUB_S = 0x8dU << 20, -+ FNMSUB_D = 0x8eU << 20, -+ FCMP_COND_S = 0xc1U << 20, -+ FCMP_COND_D = 0xc2U << 20, -+ -+ BYTEPICK_D = 0x3U << 18, -+ BYTEPICK_W = 0x2U << 18, -+ -+ FSEL = 0x340U << 18, -+ -+ ALSL = 0x1U << 18, -+ ALSL_W = ALSL, -+ ALSL_WU = ALSL, -+ -+ ALSL_D = 0xbU << 18, -+ -+ SLLI_W = 0x40U << 16, -+ SRLI_W = 0x44U << 16, -+ SRAI_W = 0x48U << 16, -+ ROTRI_W = 0x4cU << 16, -+ -+ SLLI_D = 0x41U << 16, -+ SRLI_D = 0x45U << 16, -+ SRAI_D = 0x49U << 16, -+ ROTRI_D = 0x4dU << 16, -+ -+ SLLI = 0x10U << 18, -+ SRLI = 0x11U << 18, -+ SRAI = 0x12U << 18, -+ ROTRI = 0x13U << 18, -+ -+ ADD_W = 0x20U << 15, -+ ADD_D = 0x21U << 15, -+ SUB_W = 0x22U << 15, -+ SUB_D = 0x23U << 15, -+ SLT = 0x24U << 15, -+ SLTU = 0x25U << 15, -+ MASKNEZ = 0x26U << 15, -+ MASKEQZ = 0x27U << 15, -+ NOR = 0x28U << 15, -+ AND = 0x29U << 15, -+ OR = 0x2aU << 15, -+ XOR = 0x2bU << 15, -+ ORN = 0x2cU << 15, -+ ANDN = 0x2dU << 15, -+ SLL_W = 0x2eU << 15, -+ SRL_W = 0x2fU << 15, -+ SRA_W = 0x30U << 15, -+ SLL_D = 0x31U << 15, -+ SRL_D = 0x32U << 15, -+ SRA_D = 0x33U << 15, -+ ROTR_W = 0x36U << 15, -+ ROTR_D = 0x37U << 15, -+ MUL_W = 0x38U << 15, -+ MULH_W = 0x39U << 15, -+ MULH_WU = 0x3aU << 15, -+ MUL_D = 0x3bU << 15, -+ MULH_D = 0x3cU << 15, -+ MULH_DU = 0x3dU << 15, -+ MULW_D_W = 0x3eU << 15, -+ MULW_D_WU = 0x3fU << 15, -+ -+ DIV_W = 0x40U << 15, -+ MOD_W = 0x41U << 15, -+ DIV_WU = 0x42U << 15, -+ MOD_WU = 0x43U << 15, -+ DIV_D = 0x44U << 15, -+ MOD_D = 0x45U << 15, -+ DIV_DU = 0x46U << 15, -+ MOD_DU = 0x47U << 15, -+ -+ BREAK = 0x54U << 15, -+ -+ FADD_S = 0x201U << 15, -+ FADD_D = 0x202U << 15, -+ FSUB_S = 0x205U << 15, -+ FSUB_D = 0x206U << 15, -+ FMUL_S = 0x209U << 15, -+ FMUL_D = 0x20aU << 15, -+ FDIV_S = 0x20dU << 15, -+ FDIV_D = 0x20eU << 15, -+ FMAX_S = 0x211U << 15, -+ FMAX_D = 0x212U << 15, -+ FMIN_S = 0x215U << 15, -+ FMIN_D = 0x216U << 15, -+ FMAXA_S = 0x219U << 15, -+ FMAXA_D = 0x21aU << 15, -+ FMINA_S = 0x21dU << 15, -+ FMINA_D = 0x21eU << 15, -+ FSCALEB_S = 0x221U << 15, -+ FSCALEB_D = 0x222U << 15, -+ FCOPYSIGN_S = 0x225U << 15, -+ FCOPYSIGN_D = 0x226U << 15, -+ -+ LDX_B = 0x7000U << 15, -+ LDX_H = 0x7008U << 15, -+ LDX_W = 0x7010U << 15, -+ LDX_D = 0x7018U << 15, -+ STX_B = 0x7020U << 15, -+ STX_H = 0x7028U << 15, -+ STX_W = 0x7030U << 15, -+ STX_D = 0x7038U << 15, -+ LDX_BU = 0x7040U << 15, -+ LDX_HU = 0x7048U << 15, -+ LDX_WU = 0x7050U << 15, -+ FLDX_S = 0x7060U << 15, -+ FLDX_D = 0x7068U << 15, -+ FSTX_S = 0x7070U << 15, -+ FSTX_D = 0x7078U << 15, -+ -+ AMSWAP_W = 0x70c0U << 15, -+ AMSWAP_D = 0x70c1U << 15, -+ AMADD_W = 0x70c2U << 15, -+ AMADD_D = 0x70c3U << 15, -+ AMAND_W = 0x70c4U << 15, -+ AMAND_D = 0x70c5U << 15, -+ AMOR_W = 0x70c6U << 15, -+ AMOR_D = 0x70c7U << 15, -+ AMXOR_W = 0x70c8U << 15, -+ AMXOR_D = 0x70c9U << 15, -+ AMMAX_W = 0x70caU << 15, -+ AMMAX_D = 0x70cbU << 15, -+ AMMIN_W = 0x70ccU << 15, -+ AMMIN_D = 0x70cdU << 15, -+ AMMAX_WU = 0x70ceU << 15, -+ AMMAX_DU = 0x70cfU << 15, -+ AMMIN_WU = 0x70d0U << 15, -+ AMMIN_DU = 0x70d1U << 15, -+ AMSWAP_DB_W = 0x70d2U << 15, -+ AMSWAP_DB_D = 0x70d3U << 15, -+ AMADD_DB_W = 0x70d4U << 15, -+ AMADD_DB_D = 0x70d5U << 15, -+ AMAND_DB_W = 0x70d6U << 15, -+ AMAND_DB_D = 0x70d7U << 15, -+ AMOR_DB_W = 0x70d8U << 15, -+ AMOR_DB_D = 0x70d9U << 15, -+ AMXOR_DB_W = 0x70daU << 15, -+ AMXOR_DB_D = 0x70dbU << 15, -+ AMMAX_DB_W = 0x70dcU << 15, -+ AMMAX_DB_D = 0x70ddU << 15, -+ AMMIN_DB_W = 0x70deU << 15, -+ AMMIN_DB_D = 0x70dfU << 15, -+ AMMAX_DB_WU = 0x70e0U << 15, -+ AMMAX_DB_DU = 0x70e1U << 15, -+ AMMIN_DB_WU = 0x70e2U << 15, -+ AMMIN_DB_DU = 0x70e3U << 15, -+ -+ DBAR = 0x70e4U << 15, -+ IBAR = 0x70e5U << 15, -+ -+ CLO_W = 0X4U << 10, -+ CLZ_W = 0X5U << 10, -+ CTO_W = 0X6U << 10, -+ CTZ_W = 0X7U << 10, -+ CLO_D = 0X8U << 10, -+ CLZ_D = 0X9U << 10, -+ CTO_D = 0XaU << 10, -+ CTZ_D = 0XbU << 10, -+ REVB_2H = 0XcU << 10, -+ REVB_4H = 0XdU << 10, -+ REVB_2W = 0XeU << 10, -+ REVB_D = 0XfU << 10, -+ REVH_2W = 0X10U << 10, -+ REVH_D = 0X11U << 10, -+ BITREV_4B = 0X12U << 10, -+ BITREV_8B = 0X13U << 10, -+ BITREV_W = 0X14U << 10, -+ BITREV_D = 0X15U << 10, -+ EXT_W_H = 0X16U << 10, -+ EXT_W_B = 0X17U << 10, -+ -+ FABS_S = 0X4501U << 10, -+ FABS_D = 0X4502U << 10, -+ FNEG_S = 0X4505U << 10, -+ FNEG_D = 0X4506U << 10, -+ FLOGB_S = 0X4509U << 10, -+ FLOGB_D = 0X450aU << 10, -+ FCLASS_S = 0X450dU << 10, -+ FCLASS_D = 0X450eU << 10, -+ FSQRT_S = 0X4511U << 10, -+ FSQRT_D = 0X4512U << 10, -+ FRECIP_S = 0X4515U << 10, -+ FRECIP_D = 0X4516U << 10, -+ FRSQRT_S = 0X4519U << 10, -+ FRSQRT_D = 0X451aU << 10, -+ FMOV_S = 0X4525U << 10, -+ FMOV_D = 0X4526U << 10, -+ MOVGR2FR_W = 0X4529U << 10, -+ MOVGR2FR_D = 0X452aU << 10, -+ MOVGR2FRH_W = 0X452bU << 10, -+ MOVFR2GR_S = 0X452dU << 10, -+ MOVFR2GR_D = 0X452eU << 10, -+ MOVFRH2GR_S = 0X452fU << 10, -+ MOVGR2FCSR = 0X4530U << 10, -+ MOVFCSR2GR = 0X4532U << 10, -+ MOVFR2CF = 0X4534U << 10, -+ MOVGR2CF = 0X4536U << 10, -+ -+ FCVT_S_D = 0x4646U << 10, -+ FCVT_D_S = 0x4649U << 10, -+ FTINTRM_W_S = 0x4681U << 10, -+ FTINTRM_W_D = 0x4682U << 10, -+ FTINTRM_L_S = 0x4689U << 10, -+ FTINTRM_L_D = 0x468aU << 10, -+ FTINTRP_W_S = 0x4691U << 10, -+ FTINTRP_W_D = 0x4692U << 10, -+ FTINTRP_L_S = 0x4699U << 10, -+ FTINTRP_L_D = 0x469aU << 10, -+ FTINTRZ_W_S = 0x46a1U << 10, -+ FTINTRZ_W_D = 0x46a2U << 10, -+ FTINTRZ_L_S = 0x46a9U << 10, -+ FTINTRZ_L_D = 0x46aaU << 10, -+ FTINTRNE_W_S = 0x46b1U << 10, -+ FTINTRNE_W_D = 0x46b2U << 10, -+ FTINTRNE_L_S = 0x46b9U << 10, -+ FTINTRNE_L_D = 0x46baU << 10, -+ FTINT_W_S = 0x46c1U << 10, -+ FTINT_W_D = 0x46c2U << 10, -+ FTINT_L_S = 0x46c9U << 10, -+ FTINT_L_D = 0x46caU << 10, -+ FFINT_S_W = 0x4744U << 10, -+ FFINT_S_L = 0x4746U << 10, -+ FFINT_D_W = 0x4748U << 10, -+ FFINT_D_L = 0x474aU << 10, -+ FRINT_S = 0x4791U << 10, -+ FRINT_D = 0x4792U << 10, -+ -+ MOVCF2FR = 0x4535U << 10, -+ MOVCF2GR = 0x4537U << 10, -+}; -+ -+// ----- Emulated conditions. -+// On LA64 we use this enum to abstract from conditional branch instructions. -+// The 'U' prefix is used to specify unsigned comparisons. -+enum Condition { -+ // Any value < 0 is considered no_condition. -+ kNoCondition = -1, -+ overflow = 0, -+ no_overflow = 1, -+ Uless = 2, -+ Ugreater_equal = 3, -+ Uless_equal = 4, -+ Ugreater = 5, -+ equal = 6, -+ not_equal = 7, // Unordered or Not Equal. -+ negative = 8, -+ positive = 9, -+ parity_even = 10, -+ parity_odd = 11, -+ less = 12, -+ greater_equal = 13, -+ less_equal = 14, -+ greater = 15, -+ ueq = 16, // Unordered or Equal. -+ ogl = 17, // Ordered and Not Equal. -+ cc_always = 18, -+ -+ // Aliases. -+ carry = Uless, -+ not_carry = Ugreater_equal, -+ zero = equal, -+ eq = equal, -+ not_zero = not_equal, -+ ne = not_equal, -+ nz = not_equal, -+ sign = negative, -+ not_sign = positive, -+ mi = negative, -+ pl = positive, -+ hi = Ugreater, -+ ls = Uless_equal, -+ ge = greater_equal, -+ lt = less, -+ gt = greater, -+ le = less_equal, -+ hs = Ugreater_equal, -+ lo = Uless, -+ al = cc_always, -+ ult = Uless, -+ uge = Ugreater_equal, -+ ule = Uless_equal, -+ ugt = Ugreater, -+ cc_default = kNoCondition -+}; -+ -+// Returns the equivalent of !cc. -+// Negation of the default kNoCondition (-1) results in a non-default -+// no_condition value (-2). As long as tests for no_condition check -+// for condition < 0, this will work as expected. -+inline Condition NegateCondition(Condition cc) { -+ DCHECK(cc != cc_always); -+ return static_cast(cc ^ 1); -+} -+ -+inline Condition NegateFpuCondition(Condition cc) { -+ DCHECK(cc != cc_always); -+ switch (cc) { -+ case ult: -+ return ge; -+ case ugt: -+ return le; -+ case uge: -+ return lt; -+ case ule: -+ return gt; -+ case lt: -+ return uge; -+ case gt: -+ return ule; -+ case ge: -+ return ult; -+ case le: -+ return ugt; -+ case eq: -+ return ne; -+ case ne: -+ return eq; -+ case ueq: -+ return ogl; -+ case ogl: -+ return ueq; -+ default: -+ return cc; -+ } -+} -+ -+// ----- Coprocessor conditions. -+enum FPUCondition { -+ kNoFPUCondition = -1, -+ -+ CAF = 0x00, // False. -+ SAF = 0x01, // False. -+ CLT = 0x02, // Less Than quiet -+ // SLT = 0x03, // Less Than signaling -+ CEQ = 0x04, -+ SEQ = 0x05, -+ CLE = 0x06, -+ SLE = 0x07, -+ CUN = 0x08, -+ SUN = 0x09, -+ CULT = 0x0a, -+ SULT = 0x0b, -+ CUEQ = 0x0c, -+ SUEQ = 0x0d, -+ CULE = 0x0e, -+ SULE = 0x0f, -+ CNE = 0x10, -+ SNE = 0x11, -+ COR = 0x14, -+ SOR = 0x15, -+ CUNE = 0x18, -+ SUNE = 0x19, -+}; -+ -+const uint32_t kFPURoundingModeShift = 8; -+const uint32_t kFPURoundingModeMask = 0b11 << kFPURoundingModeShift; -+ -+// FPU rounding modes. -+enum FPURoundingMode { -+ RN = 0b00 << kFPURoundingModeShift, // Round to Nearest. -+ RZ = 0b01 << kFPURoundingModeShift, // Round towards zero. -+ RP = 0b10 << kFPURoundingModeShift, // Round towards Plus Infinity. -+ RM = 0b11 << kFPURoundingModeShift, // Round towards Minus Infinity. -+ -+ // Aliases. -+ kRoundToNearest = RN, -+ kRoundToZero = RZ, -+ kRoundToPlusInf = RP, -+ kRoundToMinusInf = RM, -+ -+ mode_round = RN, -+ mode_ceil = RP, -+ mode_floor = RM, -+ mode_trunc = RZ -+}; -+ -+enum CheckForInexactConversion { -+ kCheckForInexactConversion, -+ kDontCheckForInexactConversion -+}; -+ -+enum class MaxMinKind : int { kMin = 0, kMax = 1 }; -+ -+// ----------------------------------------------------------------------------- -+// Hints. -+ -+// Branch hints are not used on the LA64. They are defined so that they can -+// appear in shared function signatures, but will be ignored in LA64 -+// implementations. -+enum Hint { no_hint = 0 }; -+ -+inline Hint NegateHint(Hint hint) { return no_hint; } -+ -+// ----------------------------------------------------------------------------- -+// Specific instructions, constants, and masks. -+// These constants are declared in assembler-mips.cc, as they use named -+// registers and other constants. -+ -+// addi_d(sp, sp, 8) aka Pop() operation or part of Pop(r) -+// operations as post-increment of sp. -+extern const Instr kPopInstruction; -+// addi_d(sp, sp, -8) part of Push(r) operation as pre-decrement of sp. -+extern const Instr kPushInstruction; -+// St_d(r, MemOperand(sp, 0)) -+extern const Instr kPushRegPattern; -+// Ld_d(r, MemOperand(sp, 0)) -+extern const Instr kPopRegPattern; -+// extern const Instr kLwRegFpOffsetPattern; -+// extern const Instr kSwRegFpOffsetPattern; -+// extern const Instr kLwRegFpNegOffsetPattern; -+// extern const Instr kSwRegFpNegOffsetPattern; -+// A mask for the Rk register for push, pop, lw, sw instructions. -+extern const Instr kRtMask; -+// extern const Instr kLwSwInstrTypeMask; -+// extern const Instr kLwSwInstrArgumentMask; -+// extern const Instr kLwSwOffsetMask; -+ -+// Break 0xfffff, reserved for redirected real time call. -+const Instr rtCallRedirInstr = BREAK | call_rt_redirected; -+// A nop instruction. (Encoding of addi_w 0 0 0). -+const Instr nopInstr = ADDI_W; -+ -+constexpr uint8_t kInstrSize = 4; -+constexpr uint8_t kInstrSizeLog2 = 2; -+ -+class InstructionBase { -+ public: -+ enum { -+ // On Loonisa PC cannot actually be directly accessed. We behave as if PC -+ // was -+ // always the value of the current instruction being executed. -+ kPCReadOffset = 0 -+ }; -+ -+ enum Type { -+ kOp6Type, -+ kOp7Type, -+ kOp8Type, -+ kOp10Type, -+ kOp12Type, -+ kOp14Type, -+ kOp17Type, -+ kOp22Type, -+ kUnsupported = -1 -+ }; -+ -+ // Get the raw instruction bits. -+ inline Instr InstructionBits() const { -+ return *reinterpret_cast(this); -+ } -+ -+ // Set the raw instruction bits to value. -+ inline void SetInstructionBits(Instr value) { -+ *reinterpret_cast(this) = value; -+ } -+ -+ // Read one particular bit out of the instruction bits. -+ inline int Bit(int nr) const { return (InstructionBits() >> nr) & 1; } -+ -+ // Read a bit field out of the instruction bits. -+ inline int Bits(int hi, int lo) const { -+ return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); -+ } -+ -+ // Safe to call within InstructionType(). -+ inline int RjFieldRawNoAssert() const { -+ return InstructionBits() & kRjFieldMask; -+ } -+ -+ // Get the encoding type of the instruction. -+ inline Type InstructionType() const; -+ -+ protected: -+ InstructionBase() {} -+}; -+ -+template -+class InstructionGetters : public T { -+ public: -+ inline int RjValue() const { -+ return this->Bits(kRjShift + kRjBits - 1, kRjShift); -+ } -+ -+ inline int RkValue() const { -+ return this->Bits(kRkShift + kRkBits - 1, kRkShift); -+ } -+ -+ inline int RdValue() const { -+ return this->Bits(kRdShift + kRdBits - 1, kRdShift); -+ } -+ -+ inline int Sa2Value() const { -+ return this->Bits(kSaShift + kSa2Bits - 1, kSaShift); -+ } -+ -+ inline int Sa3Value() const { -+ return this->Bits(kSaShift + kSa3Bits - 1, kSaShift); -+ } -+ -+ inline int Ui5Value() const { -+ return this->Bits(kUi5Shift + kUi5Bits - 1, kUi5Shift); -+ } -+ -+ inline int Ui6Value() const { -+ return this->Bits(kUi6Shift + kUi6Bits - 1, kUi6Shift); -+ } -+ -+ inline int Ui12Value() const { -+ return this->Bits(kUi12Shift + kUi12Bits - 1, kUi12Shift); -+ } -+ -+ inline int LsbwValue() const { -+ return this->Bits(kLsbwShift + kLsbwBits - 1, kLsbwShift); -+ } -+ -+ inline int MsbwValue() const { -+ return this->Bits(kMsbwShift + kMsbwBits - 1, kMsbwShift); -+ } -+ -+ inline int LsbdValue() const { -+ return this->Bits(kLsbdShift + kLsbdBits - 1, kLsbdShift); -+ } -+ -+ inline int MsbdValue() const { -+ return this->Bits(kMsbdShift + kMsbdBits - 1, kMsbdShift); -+ } -+ -+ inline int CondValue() const { -+ return this->Bits(kCondShift + kCondBits - 1, kCondShift); -+ } -+ -+ inline int Si12Value() const { -+ return this->Bits(kSi12Shift + kSi12Bits - 1, kSi12Shift); -+ } -+ -+ inline int Si14Value() const { -+ return this->Bits(kSi14Shift + kSi14Bits - 1, kSi14Shift); -+ } -+ -+ inline int Si16Value() const { -+ return this->Bits(kSi16Shift + kSi16Bits - 1, kSi16Shift); -+ } -+ -+ inline int Si20Value() const { -+ return this->Bits(kSi20Shift + kSi20Bits - 1, kSi20Shift); -+ } -+ -+ inline int FdValue() const { -+ return this->Bits(kFdShift + kFdBits - 1, kFdShift); -+ } -+ -+ inline int FaValue() const { -+ return this->Bits(kFaShift + kFaBits - 1, kFaShift); -+ } -+ -+ inline int FjValue() const { -+ return this->Bits(kFjShift + kFjBits - 1, kFjShift); -+ } -+ -+ inline int FkValue() const { -+ return this->Bits(kFkShift + kFkBits - 1, kFkShift); -+ } -+ -+ inline int CjValue() const { -+ return this->Bits(kCjShift + kCjBits - 1, kCjShift); -+ } -+ -+ inline int CdValue() const { -+ return this->Bits(kCdShift + kCdBits - 1, kCdShift); -+ } -+ -+ inline int CaValue() const { -+ return this->Bits(kCaShift + kCaBits - 1, kCaShift); -+ } -+ -+ inline int CodeValue() const { -+ return this->Bits(kCodeShift + kCodeBits - 1, kCodeShift); -+ } -+ -+ inline int Hint5Value() const { -+ return this->Bits(kHint5Shift + kHint5Bits - 1, kHint5Shift); -+ } -+ -+ inline int Hint15Value() const { -+ return this->Bits(kHint15Shift + kHint15Bits - 1, kHint15Shift); -+ } -+ -+ inline int Offs16Value() const { -+ return this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); -+ } -+ -+ inline int Offs21Value() const { -+ int low = this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); -+ int high = -+ this->Bits(kOffs21HighShift + kOffs21HighBits - 1, kOffs21HighShift); -+ return ((high << kOffsLowBits) + low); -+ } -+ -+ inline int Offs26Value() const { -+ int low = this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); -+ int high = -+ this->Bits(kOffs26HighShift + kOffs26HighBits - 1, kOffs26HighShift); -+ return ((high << kOffsLowBits) + low); -+ } -+ -+ inline int RjFieldRaw() const { -+ return this->InstructionBits() & kRjFieldMask; -+ } -+ -+ inline int RkFieldRaw() const { -+ return this->InstructionBits() & kRkFieldMask; -+ } -+ -+ inline int RdFieldRaw() const { -+ return this->InstructionBits() & kRdFieldMask; -+ } -+ -+ inline int32_t ImmValue(int bits) const { return this->Bits(bits - 1, 0); } -+ -+ /*TODO*/ -+ inline int32_t Imm12Value() const { abort(); } -+ -+ inline int32_t Imm14Value() const { abort(); } -+ -+ inline int32_t Imm16Value() const { abort(); } -+ -+ // Say if the instruction 'links'. e.g. jal, bal. -+ bool IsLinkingInstruction() const; -+ // Say if the instruction is a break or a trap. -+ bool IsTrap() const; -+}; -+ -+class Instruction : public InstructionGetters { -+ public: -+ // Instructions are read of out a code stream. The only way to get a -+ // reference to an instruction is to convert a pointer. There is no way -+ // to allocate or create instances of class Instruction. -+ // Use the At(pc) function to create references to Instruction. -+ static Instruction* At(byte* pc) { -+ return reinterpret_cast(pc); -+ } -+ -+ private: -+ // We need to prevent the creation of instances of class Instruction. -+ DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); -+}; -+ -+// ----------------------------------------------------------------------------- -+// LA64 assembly various constants. -+ -+// C/C++ argument slots size. -+const int kCArgSlotCount = 0; -+ -+const int kCArgsSlotsSize = kCArgSlotCount * kInstrSize * 2; -+ -+const int kInvalidStackOffset = -1; -+ -+static const int kNegOffset = 0x00008000; -+ -+InstructionBase::Type InstructionBase::InstructionType() const { -+ InstructionBase::Type kType = kUnsupported; -+ -+ // Check for kOp6Type -+ switch (Bits(31, 26) << 26) { -+ case ADDU16I_D: -+ case BEQZ: -+ case BNEZ: -+ case BCZ: -+ case JIRL: -+ case B: -+ case BL: -+ case BEQ: -+ case BNE: -+ case BLT: -+ case BGE: -+ case BLTU: -+ case BGEU: -+ kType = kOp6Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp7Type -+ switch (Bits(31, 25) << 25) { -+ case LU12I_W: -+ case LU32I_D: -+ case PCADDI: -+ case PCALAU12I: -+ case PCADDU12I: -+ case PCADDU18I: -+ kType = kOp7Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp8Type -+ switch (Bits(31, 24) << 24) { -+ case LDPTR_W: -+ case STPTR_W: -+ case LDPTR_D: -+ case STPTR_D: -+ case LL_W: -+ case SC_W: -+ case LL_D: -+ case SC_D: -+ kType = kOp8Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp10Type -+ switch (Bits(31, 22) << 22) { -+ case BSTR_W: { -+ // If Bit(21) = 0, then the Opcode is not BSTR_W. -+ if (Bit(21) == 0) -+ kType = kUnsupported; -+ else -+ kType = kOp10Type; -+ break; -+ } -+ case BSTRINS_D: -+ case BSTRPICK_D: -+ case SLTI: -+ case SLTUI: -+ case ADDI_W: -+ case ADDI_D: -+ case LU52I_D: -+ case ANDI: -+ case ORI: -+ case XORI: -+ case LD_B: -+ case LD_H: -+ case LD_W: -+ case LD_D: -+ case ST_B: -+ case ST_H: -+ case ST_W: -+ case ST_D: -+ case LD_BU: -+ case LD_HU: -+ case LD_WU: -+ case FLD_S: -+ case FST_S: -+ case FLD_D: -+ case FST_D: -+ kType = kOp10Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp12Type -+ switch (Bits(31, 20) << 20) { -+ case FMADD_S: -+ case FMADD_D: -+ case FMSUB_S: -+ case FMSUB_D: -+ case FNMADD_S: -+ case FNMADD_D: -+ case FNMSUB_S: -+ case FNMSUB_D: -+ case FCMP_COND_S: -+ case FCMP_COND_D: -+ case FSEL: -+ kType = kOp12Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp14Type -+ switch (Bits(31, 18) << 18) { -+ case ALSL: -+ case BYTEPICK_W: -+ case BYTEPICK_D: -+ case ALSL_D: -+ case SLLI: -+ case SRLI: -+ case SRAI: -+ case ROTRI: -+ kType = kOp14Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp17Type -+ switch (Bits(31, 15) << 15) { -+ case ADD_W: -+ case ADD_D: -+ case SUB_W: -+ case SUB_D: -+ case SLT: -+ case SLTU: -+ case MASKEQZ: -+ case MASKNEZ: -+ case NOR: -+ case AND: -+ case OR: -+ case XOR: -+ case ORN: -+ case ANDN: -+ case SLL_W: -+ case SRL_W: -+ case SRA_W: -+ case SLL_D: -+ case SRL_D: -+ case SRA_D: -+ case ROTR_D: -+ case ROTR_W: -+ case MUL_W: -+ case MULH_W: -+ case MULH_WU: -+ case MUL_D: -+ case MULH_D: -+ case MULH_DU: -+ case MULW_D_W: -+ case MULW_D_WU: -+ case DIV_W: -+ case MOD_W: -+ case DIV_WU: -+ case MOD_WU: -+ case DIV_D: -+ case MOD_D: -+ case DIV_DU: -+ case MOD_DU: -+ case BREAK: -+ case FADD_S: -+ case FADD_D: -+ case FSUB_S: -+ case FSUB_D: -+ case FMUL_S: -+ case FMUL_D: -+ case FDIV_S: -+ case FDIV_D: -+ case FMAX_S: -+ case FMAX_D: -+ case FMIN_S: -+ case FMIN_D: -+ case FMAXA_S: -+ case FMAXA_D: -+ case FMINA_S: -+ case FMINA_D: -+ case LDX_B: -+ case LDX_H: -+ case LDX_W: -+ case LDX_D: -+ case STX_B: -+ case STX_H: -+ case STX_W: -+ case STX_D: -+ case LDX_BU: -+ case LDX_HU: -+ case LDX_WU: -+ case FLDX_S: -+ case FLDX_D: -+ case FSTX_S: -+ case FSTX_D: -+ case AMSWAP_W: -+ case AMSWAP_D: -+ case AMADD_W: -+ case AMADD_D: -+ case AMAND_W: -+ case AMAND_D: -+ case AMOR_W: -+ case AMOR_D: -+ case AMXOR_W: -+ case AMXOR_D: -+ case AMMAX_W: -+ case AMMAX_D: -+ case AMMIN_W: -+ case AMMIN_D: -+ case AMMAX_WU: -+ case AMMAX_DU: -+ case AMMIN_WU: -+ case AMMIN_DU: -+ case AMSWAP_DB_W: -+ case AMSWAP_DB_D: -+ case AMADD_DB_W: -+ case AMADD_DB_D: -+ case AMAND_DB_W: -+ case AMAND_DB_D: -+ case AMOR_DB_W: -+ case AMOR_DB_D: -+ case AMXOR_DB_W: -+ case AMXOR_DB_D: -+ case AMMAX_DB_W: -+ case AMMAX_DB_D: -+ case AMMIN_DB_W: -+ case AMMIN_DB_D: -+ case AMMAX_DB_WU: -+ case AMMAX_DB_DU: -+ case AMMIN_DB_WU: -+ case AMMIN_DB_DU: -+ case DBAR: -+ case IBAR: -+ case FSCALEB_S: -+ case FSCALEB_D: -+ case FCOPYSIGN_S: -+ case FCOPYSIGN_D: -+ kType = kOp17Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ if (kType == kUnsupported) { -+ // Check for kOp22Type -+ switch (Bits(31, 10) << 10) { -+ case CLZ_W: -+ case CTZ_W: -+ case CLZ_D: -+ case CTZ_D: -+ case REVB_2H: -+ case REVB_4H: -+ case REVB_2W: -+ case REVB_D: -+ case REVH_2W: -+ case REVH_D: -+ case BITREV_4B: -+ case BITREV_8B: -+ case BITREV_W: -+ case BITREV_D: -+ case EXT_W_B: -+ case EXT_W_H: -+ case FABS_S: -+ case FABS_D: -+ case FNEG_S: -+ case FNEG_D: -+ case FSQRT_S: -+ case FSQRT_D: -+ case FMOV_S: -+ case FMOV_D: -+ case MOVGR2FR_W: -+ case MOVGR2FR_D: -+ case MOVGR2FRH_W: -+ case MOVFR2GR_S: -+ case MOVFR2GR_D: -+ case MOVFRH2GR_S: -+ case MOVGR2FCSR: -+ case MOVFCSR2GR: -+ case FCVT_S_D: -+ case FCVT_D_S: -+ case FTINTRM_W_S: -+ case FTINTRM_W_D: -+ case FTINTRM_L_S: -+ case FTINTRM_L_D: -+ case FTINTRP_W_S: -+ case FTINTRP_W_D: -+ case FTINTRP_L_S: -+ case FTINTRP_L_D: -+ case FTINTRZ_W_S: -+ case FTINTRZ_W_D: -+ case FTINTRZ_L_S: -+ case FTINTRZ_L_D: -+ case FTINTRNE_W_S: -+ case FTINTRNE_W_D: -+ case FTINTRNE_L_S: -+ case FTINTRNE_L_D: -+ case FTINT_W_S: -+ case FTINT_W_D: -+ case FTINT_L_S: -+ case FTINT_L_D: -+ case FFINT_S_W: -+ case FFINT_S_L: -+ case FFINT_D_W: -+ case FFINT_D_L: -+ case FRINT_S: -+ case FRINT_D: -+ case MOVFR2CF: -+ case MOVCF2FR: -+ case MOVGR2CF: -+ case MOVCF2GR: -+ case FRECIP_S: -+ case FRECIP_D: -+ case FRSQRT_S: -+ case FRSQRT_D: -+ case FCLASS_S: -+ case FCLASS_D: -+ case FLOGB_S: -+ case FLOGB_D: -+ case CLO_W: -+ case CTO_W: -+ case CLO_D: -+ case CTO_D: -+ kType = kOp22Type; -+ break; -+ default: -+ kType = kUnsupported; -+ } -+ } -+ -+ return kType; -+} -+ -+// ----------------------------------------------------------------------------- -+// Instructions. -+ -+template -+bool InstructionGetters

::IsTrap() const { -+ return true; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/cpu-loongarch64.cc b/src/3rdparty/chromium/v8/src/codegen/loongarch64/cpu-loongarch64.cc -new file mode 100644 -index 000000000..8a454c247 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/cpu-loongarch64.cc -@@ -0,0 +1,38 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// CPU specific code for loongisa independent of OS goes here. -+ -+#include -+#include -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/codegen/cpu-features.h" -+ -+namespace v8 { -+namespace internal { -+ -+void CpuFeatures::FlushICache(void* start, size_t size) { -+#if !defined(USE_SIMULATOR) -+ // Nothing to do, flushing no instructions. -+ if (size == 0) { -+ return; -+ } -+ -+#if defined(ANDROID) && !defined(__LP64__) -+ // Bionic cacheflush can typically run in userland, avoiding kernel call. -+ char* end = reinterpret_cast(start) + size; -+ cacheflush(reinterpret_cast(start), reinterpret_cast(end), -+ 0); -+#else // ANDROID -+ asm("ibar 0\n"); -+#endif // ANDROID -+#endif // !USE_SIMULATOR. -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/interface-descriptors-loongarch64.cc b/src/3rdparty/chromium/v8/src/codegen/loongarch64/interface-descriptors-loongarch64.cc -new file mode 100644 -index 000000000..6e63852e3 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/interface-descriptors-loongarch64.cc -@@ -0,0 +1,357 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/codegen/interface-descriptors.h" -+#include "src/execution/frames.h" -+ -+namespace v8 { -+namespace internal { -+ -+const Register CallInterfaceDescriptor::ContextRegister() { return cp; } -+ -+void CallInterfaceDescriptor::DefaultInitializePlatformSpecific( -+ CallInterfaceDescriptorData* data, int register_parameter_count) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ CHECK_LE(static_cast(register_parameter_count), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(register_parameter_count, -+ default_stub_registers); -+} -+ -+// On MIPS it is not allowed to use odd numbered floating point registers -+// (e.g. f1, f3, etc.) for parameters. This can happen if we use -+// DefaultInitializePlatformSpecific to assign float registers for parameters. -+// E.g if fourth parameter goes to float register, f7 would be assigned for -+// parameter (a3 casted to int is 7). -+bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) { -+ return reg.code() % 2 == 0; -+} -+ -+void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3}; -+ CHECK_EQ(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+void WasmI64AtomicWait32Descriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ CHECK_EQ(static_cast(kParameterCount - kStackArgumentsCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount - kStackArgumentsCount, -+ default_stub_registers); -+} -+ -+void RecordWriteDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ -+ data->RestrictAllocatableRegisters(default_stub_registers, -+ arraysize(default_stub_registers)); -+ -+ CHECK_LE(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ -+ data->RestrictAllocatableRegisters(default_stub_registers, -+ arraysize(default_stub_registers)); -+ -+ CHECK_LE(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+const Register LoadDescriptor::ReceiverRegister() { return a1; } -+const Register LoadDescriptor::NameRegister() { return a2; } -+const Register LoadDescriptor::SlotRegister() { return a0; } -+ -+const Register LoadWithVectorDescriptor::VectorRegister() { return a3; } -+ -+const Register -+LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() { -+ return a4; -+} -+ -+const Register StoreDescriptor::ReceiverRegister() { return a1; } -+const Register StoreDescriptor::NameRegister() { return a2; } -+const Register StoreDescriptor::ValueRegister() { return a0; } -+const Register StoreDescriptor::SlotRegister() { return a4; } -+ -+const Register StoreWithVectorDescriptor::VectorRegister() { return a3; } -+ -+const Register StoreTransitionDescriptor::SlotRegister() { return a4; } -+const Register StoreTransitionDescriptor::VectorRegister() { return a3; } -+const Register StoreTransitionDescriptor::MapRegister() { return a5; } -+ -+const Register ApiGetterDescriptor::HolderRegister() { return a0; } -+const Register ApiGetterDescriptor::CallbackRegister() { return a3; } -+ -+const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } -+const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } -+ -+// static -+const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } -+ -+void TypeofDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a3}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallTrampolineDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: target -+ // a0: number of arguments -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a4 : arguments list length (untagged) -+ // a2 : arguments list (FixedArray) -+ Register registers[] = {a1, a0, a4, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallForwardVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: the target to call -+ // a0: number of arguments -+ // a2: start index (to support rest parameters) -+ Register registers[] = {a1, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallFunctionTemplateDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : function template info -+ // a0 : number of arguments (on the stack, not including receiver) -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallWithSpreadDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a2 : the object to spread -+ Register registers[] = {a1, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallWithArrayLikeDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : the target to call -+ // a2 : the arguments list -+ Register registers[] = {a1, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a3 : the new target -+ // a4 : arguments list length (untagged) -+ // a2 : arguments list (FixedArray) -+ Register registers[] = {a1, a3, a0, a4, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: the target to call -+ // a3: new target -+ // a0: number of arguments -+ // a2: start index (to support rest parameters) -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructWithSpreadDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a3 : the new target -+ // a2 : the object to spread -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : the target to call -+ // a3 : the new target -+ // a2 : the arguments list -+ Register registers[] = {a1, a3, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructStubDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: target -+ // a3: new target -+ // a0: number of arguments -+ // a2: allocation site or undefined -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void AbortDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CompareDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void BinaryOpDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ArgumentsAdaptorDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // JSFunction -+ a3, // the new target -+ a0, // actual number of arguments -+ a2, // expected number of arguments -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ApiCallbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // kApiFunctionAddress -+ a2, // kArgc -+ a3, // kCallData -+ a0, // kHolder -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterDispatchDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister, -+ kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // argument count (not including receiver) -+ a2, // address of first argument -+ a1 // the target callable to be call -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // argument count (not including receiver) -+ a4, // address of the first argument -+ a1, // constructor to call -+ a3, // new target -+ a2, // allocation site feedback if available, undefined otherwise -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ResumeGeneratorDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // the value to pass to the generator -+ a1 // the JSGeneratorObject to resume -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void FrameDropperTrampolineDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // loaded new FP -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void RunMicrotasksEntryDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a0, a1}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void BinaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallTrampoline_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void ConstructWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void ConstructWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void Compare_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void UnaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 3); -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LA64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.cc b/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.cc -new file mode 100644 -index 000000000..85d503a68 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.cc -@@ -0,0 +1,4021 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include // For LONG_MIN, LONG_MAX. -+ -+#include "src/base/bits.h" -+#include "src/base/division-by-constant.h" -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/callable.h" -+#include "src/codegen/code-factory.h" -+#include "src/codegen/external-reference-table.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/register-configuration.h" -+#include "src/debug/debug.h" -+#include "src/execution/frames-inl.h" -+#include "src/heap/memory-chunk.h" -+#include "src/init/bootstrapper.h" -+#include "src/logging/counters.h" -+#include "src/objects/heap-number.h" -+#include "src/runtime/runtime.h" -+#include "src/snapshot/embedded/embedded-data.h" -+#include "src/snapshot/snapshot.h" -+#include "src/wasm/wasm-code-manager.h" -+ -+// Satisfy cpplint check, but don't include platform-specific header. It is -+// included recursively via macro-assembler.h. -+#if 0 -+#include "src/codegen/loongarch64/macro-assembler-loongarch64.h" -+#endif -+ -+namespace v8 { -+namespace internal { -+ -+static inline bool IsZero(const Operand& rk) { -+ if (rk.is_reg()) { -+ return rk.rm() == zero_reg; -+ } else { -+ return rk.immediate() == 0; -+ } -+} -+ -+int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, -+ Register exclusion1, -+ Register exclusion2, -+ Register exclusion3) const { -+ int bytes = 0; -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ bytes += NumRegs(list) * kPointerSize; -+ -+ if (fp_mode == kSaveFPRegs) { -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ return bytes; -+} -+ -+int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, -+ Register exclusion2, Register exclusion3) { -+ int bytes = 0; -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ MultiPush(list); -+ bytes += NumRegs(list) * kPointerSize; -+ -+ if (fp_mode == kSaveFPRegs) { -+ MultiPushFPU(kCallerSavedFPU); -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ return bytes; -+} -+ -+int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, -+ Register exclusion2, Register exclusion3) { -+ int bytes = 0; -+ if (fp_mode == kSaveFPRegs) { -+ MultiPopFPU(kCallerSavedFPU); -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ MultiPop(list); -+ bytes += NumRegs(list) * kPointerSize; -+ -+ return bytes; -+} -+ -+void TurboAssembler::LoadRoot(Register destination, RootIndex index) { -+ Ld_d(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); -+} -+ -+void TurboAssembler::PushCommonFrame(Register marker_reg) { -+ if (marker_reg.is_valid()) { -+ Push(ra, fp, marker_reg); -+ Add_d(fp, sp, Operand(kPointerSize)); -+ } else { -+ Push(ra, fp); -+ mov(fp, sp); -+ } -+} -+ -+void TurboAssembler::PushStandardFrame(Register function_reg) { -+ int offset = -StandardFrameConstants::kContextOffset; -+ if (function_reg.is_valid()) { -+ Push(ra, fp, cp, function_reg, kJavaScriptCallArgCountRegister); -+ offset += 2 * kPointerSize; -+ } else { -+ Push(ra, fp, cp, kJavaScriptCallArgCountRegister); -+ offset += kPointerSize; -+ } -+ Add_d(fp, sp, Operand(offset)); -+} -+ -+int MacroAssembler::SafepointRegisterStackIndex(int reg_code) { -+ // The registers are pushed starting with the highest encoding, -+ // which means that lowest encodings are closest to the stack pointer. -+ return kSafepointRegisterStackIndexMap[reg_code]; -+} -+ -+// Clobbers object, dst, value, and ra, if (ra_status == kRAHasBeenSaved) -+// The register 'object' contains a heap object pointer. The heap object -+// tag is shifted away. -+void MacroAssembler::RecordWriteField(Register object, int offset, -+ Register value, Register dst, -+ RAStatus ra_status, -+ SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action, -+ SmiCheck smi_check) { -+ DCHECK(!AreAliased(value, dst, t8, object)); -+ // First, check if a write barrier is even needed. The tests below -+ // catch stores of Smis. -+ Label done; -+ -+ // Skip barrier if writing a smi. -+ if (smi_check == INLINE_SMI_CHECK) { -+ JumpIfSmi(value, &done); -+ } -+ -+ // Although the object register is tagged, the offset is relative to the start -+ // of the object, so so offset must be a multiple of kPointerSize. -+ DCHECK(IsAligned(offset, kPointerSize)); -+ -+ Add_d(dst, object, Operand(offset - kHeapObjectTag)); -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Label ok; -+ And(t8, dst, Operand(kPointerSize - 1)); -+ Branch(&ok, eq, t8, Operand(zero_reg)); -+ stop(); -+ bind(&ok); -+ } -+ -+ RecordWrite(object, dst, value, ra_status, save_fp, remembered_set_action, -+ OMIT_SMI_CHECK); -+ -+ bind(&done); -+ -+ // Clobber clobbered input registers when running with the debug-code flag -+ // turned on to provoke errors. -+ if (emit_debug_code()) { -+ li(value, Operand(bit_cast(kZapValue + 4))); -+ li(dst, Operand(bit_cast(kZapValue + 8))); -+ } -+} -+ -+void TurboAssembler::SaveRegisters(RegList registers) { -+ DCHECK_GT(NumRegs(registers), 0); -+ RegList regs = 0; -+ for (int i = 0; i < Register::kNumRegisters; ++i) { -+ if ((registers >> i) & 1u) { -+ regs |= Register::from_code(i).bit(); -+ } -+ } -+ MultiPush(regs); -+} -+ -+void TurboAssembler::RestoreRegisters(RegList registers) { -+ DCHECK_GT(NumRegs(registers), 0); -+ RegList regs = 0; -+ for (int i = 0; i < Register::kNumRegisters; ++i) { -+ if ((registers >> i) & 1u) { -+ regs |= Register::from_code(i).bit(); -+ } -+ } -+ MultiPop(regs); -+} -+ -+void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address, -+ SaveFPRegsMode fp_mode) { -+ EphemeronKeyBarrierDescriptor descriptor; -+ RegList registers = descriptor.allocatable_registers(); -+ -+ SaveRegisters(registers); -+ -+ Register object_parameter( -+ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kObject)); -+ Register slot_parameter(descriptor.GetRegisterParameter( -+ EphemeronKeyBarrierDescriptor::kSlotAddress)); -+ Register fp_mode_parameter( -+ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kFPMode)); -+ -+ Push(object); -+ Push(address); -+ -+ Pop(slot_parameter); -+ Pop(object_parameter); -+ -+ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); -+ Call(isolate()->builtins()->builtin_handle(Builtins::kEphemeronKeyBarrier), -+ RelocInfo::CODE_TARGET); -+ RestoreRegisters(registers); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) { -+ CallRecordWriteStub( -+ object, address, remembered_set_action, fp_mode, -+ isolate()->builtins()->builtin_handle(Builtins::kRecordWrite), -+ kNullAddress); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, -+ Address wasm_target) { -+ CallRecordWriteStub(object, address, remembered_set_action, fp_mode, -+ Handle::null(), wasm_target); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, -+ Handle code_target, Address wasm_target) { -+ DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress); -+ // TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode, -+ // i.e. always emit remember set and save FP registers in RecordWriteStub. If -+ // large performance regression is observed, we should use these values to -+ // avoid unnecessary work. -+ -+ RecordWriteDescriptor descriptor; -+ RegList registers = descriptor.allocatable_registers(); -+ -+ SaveRegisters(registers); -+ Register object_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kObject)); -+ Register slot_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kSlot)); -+ Register remembered_set_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kRememberedSet)); -+ Register fp_mode_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kFPMode)); -+ -+ Push(object); -+ Push(address); -+ -+ Pop(slot_parameter); -+ Pop(object_parameter); -+ -+ Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action)); -+ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); -+ if (code_target.is_null()) { -+ Call(wasm_target, RelocInfo::WASM_STUB_CALL); -+ } else { -+ Call(code_target, RelocInfo::CODE_TARGET); -+ } -+ -+ RestoreRegisters(registers); -+} -+ -+// Clobbers object, address, value, and ra, if (ra_status == kRAHasBeenSaved) -+// The register 'object' contains a heap object pointer. The heap object -+// tag is shifted away. -+void MacroAssembler::RecordWrite(Register object, Register address, -+ Register value, RAStatus ra_status, -+ SaveFPRegsMode fp_mode, -+ RememberedSetAction remembered_set_action, -+ SmiCheck smi_check) { -+ DCHECK(!AreAliased(object, address, value)); -+ -+ if (emit_debug_code()) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Ld_d(scratch, MemOperand(address, 0)); -+ Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, -+ Operand(value)); -+ } -+ -+ if ((remembered_set_action == OMIT_REMEMBERED_SET && -+ !FLAG_incremental_marking) || -+ FLAG_disable_write_barriers) { -+ return; -+ } -+ -+ // First, check if a write barrier is even needed. The tests below -+ // catch stores of smis and stores into the young generation. -+ Label done; -+ -+ if (smi_check == INLINE_SMI_CHECK) { -+ DCHECK_EQ(0, kSmiTag); -+ JumpIfSmi(value, &done); -+ } -+ -+ CheckPageFlag(value, -+ value, // Used as scratch. -+ MemoryChunk::kPointersToHereAreInterestingMask, eq, &done); -+ CheckPageFlag(object, -+ value, // Used as scratch. -+ MemoryChunk::kPointersFromHereAreInterestingMask, eq, &done); -+ -+ // Record the actual write. -+ if (ra_status == kRAHasNotBeenSaved) { -+ push(ra); -+ } -+ CallRecordWriteStub(object, address, remembered_set_action, fp_mode); -+ if (ra_status == kRAHasNotBeenSaved) { -+ pop(ra); -+ } -+ -+ bind(&done); -+ -+ // Clobber clobbered registers when running with the debug-code flag -+ // turned on to provoke errors. -+ if (emit_debug_code()) { -+ li(address, Operand(bit_cast(kZapValue + 12))); -+ li(value, Operand(bit_cast(kZapValue + 16))); -+ } -+} -+ -+// --------------------------------------------------------------------------- -+// Instruction macros. -+ -+void TurboAssembler::Add_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ add_w(rd, rj, rk.rm()); -+ } else { -+ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ addi_w(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ add_w(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Add_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ add_d(rd, rj, rk.rm()); -+ } else { -+ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ addi_d(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ add_d(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sub_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ sub_w(rd, rj, rk.rm()); -+ } else { -+ DCHECK(is_int32(rk.immediate())); -+ if (is_int12(-rk.immediate()) && !MustUseReg(rk.rmode())) { -+ addi_w(rd, rj, -+ static_cast( -+ -rk.immediate())); // No subi_w instr, use addi_w(x, y, -imm). -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ if (-rk.immediate() >> 12 == 0 && !MustUseReg(rk.rmode())) { -+ // Use load -imm and addu when loading -imm generates one instruction. -+ li(scratch, -rk.immediate()); -+ add_w(rd, rj, scratch); -+ } else { -+ // li handles the relocation. -+ li(scratch, rk); -+ sub_w(rd, rj, scratch); -+ } -+ } -+ } -+} -+ -+void TurboAssembler::Sub_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ sub_d(rd, rj, rk.rm()); -+ } else if (is_int12(-rk.immediate()) && !MustUseReg(rk.rmode())) { -+ addi_d(rd, rj, -+ static_cast( -+ -rk.immediate())); // No subi_d instr, use addi_d(x, y, -imm). -+ } else { -+ DCHECK(rj != t7); -+ int li_count = InstrCountForLi64Bit(rk.immediate()); -+ int li_neg_count = InstrCountForLi64Bit(-rk.immediate()); -+ if (li_neg_count < li_count && !MustUseReg(rk.rmode())) { -+ // Use load -imm and add_d when loading -imm generates one instruction. -+ DCHECK(rk.immediate() != std::numeric_limits::min()); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(-rk.immediate())); -+ add_d(rd, rj, scratch); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, rk); -+ sub_d(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Mul_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mul_w(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mul_w(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mulh_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mulh_w(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mulh_w(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mulh_wu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mulh_wu(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mulh_wu(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mul_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mul_d(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mul_d(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mulh_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mulh_d(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mulh_d(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Div_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ div_w(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ div_w(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mod_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mod_w(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mod_w(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mod_wu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mod_wu(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mod_wu(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Div_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ div_d(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ div_d(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Div_wu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ div_wu(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ div_wu(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Div_du(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ div_du(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ div_du(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mod_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mod_d(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mod_d(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Mod_du(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ mod_du(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ mod_du(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::And(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ and_(rd, rj, rk.rm()); -+ } else { -+ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ andi(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ and_(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Or(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ or_(rd, rj, rk.rm()); -+ } else { -+ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ ori(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ or_(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Xor(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ xor_(rd, rj, rk.rm()); -+ } else { -+ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ xori(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ xor_(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Nor(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ nor(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ nor(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Andn(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ andn(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ andn(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Orn(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ orn(rd, rj, rk.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ orn(rd, rj, scratch); -+ } -+} -+ -+void TurboAssembler::Neg(Register rj, const Operand& rk) { -+ DCHECK(rk.is_reg()); -+ sub_d(rj, zero_reg, rk.rm()); -+} -+ -+void TurboAssembler::Slt(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ slt(rd, rj, rk.rm()); -+ } else { -+ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ slti(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ // TODO why?? -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ slt(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sltu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ sltu(rd, rj, rk.rm()); -+ } else { -+ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { -+ sltui(rd, rj, static_cast(rk.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ sltu(rd, rj, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sle(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ slt(rd, rk.rm(), rj); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ slt(rd, scratch, rj); -+ } -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sleu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ sltu(rd, rk.rm(), rj); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ sltu(rd, scratch, rj); -+ } -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sge(Register rd, Register rj, const Operand& rk) { -+ Slt(rd, rj, rk); -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sgeu(Register rd, Register rj, const Operand& rk) { -+ Sltu(rd, rj, rk); -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sgt(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ slt(rd, rk.rm(), rj); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ slt(rd, scratch, rj); -+ } -+} -+ -+void TurboAssembler::Sgtu(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ sltu(rd, rk.rm(), rj); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rj != scratch); -+ li(scratch, rk); -+ sltu(rd, scratch, rj); -+ } -+} -+ -+void TurboAssembler::Rotr_w(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ rotr_w(rd, rj, rk.rm()); -+ } else { -+ int64_t ror_value = rk.immediate() % 32; -+ if (ror_value < 0) { -+ ror_value += 32; -+ } -+ rotri_w(rd, rj, ror_value); -+ } -+} -+ -+void TurboAssembler::Rotr_d(Register rd, Register rj, const Operand& rk) { -+ if (rk.is_reg()) { -+ rotr_d(rd, rj, rk.rm()); -+ } else { -+ int64_t dror_value = rk.immediate() % 64; -+ if (dror_value < 0) dror_value += 64; -+ rotri_d(rd, rj, dror_value); -+ } -+} -+ -+void MacroAssembler::Pref(int32_t hint, const MemOperand& rj) { -+ // TODO -+ // pref(hint); -+} -+ -+void TurboAssembler::Alsl_w(Register rd, Register rj, Register rk, uint8_t sa, -+ Register scratch) { -+ DCHECK(sa >= 1 && sa <= 31); -+ if (sa <= 4) { -+ alsl_w(rd, rj, rk, sa); -+ } else { -+ Register tmp = rd == rk ? scratch : rd; -+ DCHECK(tmp != rk); -+ slli_w(tmp, rj, sa); -+ add_w(rd, rk, tmp); -+ } -+} -+ -+void TurboAssembler::Alsl_d(Register rd, Register rj, Register rk, uint8_t sa, -+ Register scratch) { -+ DCHECK(sa >= 1 && sa <= 31); -+ if (sa <= 4) { -+ alsl_d(rd, rj, rk, sa); -+ } else { -+ Register tmp = rd == rk ? scratch : rd; -+ DCHECK(tmp != rk); -+ slli_d(tmp, rj, sa); -+ add_d(rd, rk, tmp); -+ } -+} -+ -+// ------------Pseudo-instructions------------- -+ -+// Change endianness -+void TurboAssembler::ByteSwapSigned(Register dest, Register src, -+ int operand_size) { -+ DCHECK(operand_size == 2 || operand_size == 4 || operand_size == 8); -+ if (operand_size == 2) { -+ revb_2h(dest, src); -+ ext_w_h(dest, dest); -+ } else if (operand_size == 4) { -+ revb_2w(dest, src); -+ slli_w(dest, dest, 0); -+ } else { -+ revb_d(dest, dest); -+ } -+} -+ -+void TurboAssembler::ByteSwapUnsigned(Register dest, Register src, -+ int operand_size) { -+ DCHECK(operand_size == 2 || operand_size == 4); -+ if (operand_size == 2) { -+ revb_2h(dest, src); -+ bstrins_d(dest, zero_reg, 63, 16); -+ } else { -+ revb_2w(dest, src); -+ bstrins_d(dest, zero_reg, 63, 32); -+ } -+} -+ -+void TurboAssembler::Ld_b(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_b(rd, source.base(), source.index()); -+ } else { -+ ld_b(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_bu(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_bu(rd, source.base(), source.index()); -+ } else { -+ ld_bu(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::St_b(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ stx_b(rd, source.base(), source.index()); -+ } else { -+ st_b(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_h(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_h(rd, source.base(), source.index()); -+ } else { -+ ld_h(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_hu(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_hu(rd, source.base(), source.index()); -+ } else { -+ ld_hu(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::St_h(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ stx_h(rd, source.base(), source.index()); -+ } else { -+ st_h(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_w(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); // TODO ldptr_w ?? -+ if (source.hasIndexReg()) { -+ ldx_w(rd, source.base(), source.index()); -+ } else { -+ ld_w(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_wu(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_wu(rd, source.base(), source.index()); -+ } else { -+ ld_wu(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::St_w(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ stx_w(rd, source.base(), source.index()); -+ } else { -+ st_w(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Ld_d(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ ldx_d(rd, source.base(), source.index()); -+ } else { -+ ld_d(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::St_d(Register rd, const MemOperand& rj) { -+ MemOperand source = rj; -+ AdjustBaseAndOffset(&source); -+ if (source.hasIndexReg()) { -+ stx_d(rd, source.base(), source.index()); -+ } else { -+ st_d(rd, source.base(), source.offset()); -+ } -+} -+ -+void TurboAssembler::Fld_s(FPURegister fd, const MemOperand& src) { -+ MemOperand tmp = src; -+ AdjustBaseAndOffset(&tmp); -+ if (tmp.hasIndexReg()) { -+ fldx_s(fd, tmp.base(), tmp.index()); -+ } else { -+ fld_s(fd, tmp.base(), tmp.offset()); -+ } -+} -+ -+void TurboAssembler::Fst_s(FPURegister fs, const MemOperand& src) { -+ MemOperand tmp = src; -+ AdjustBaseAndOffset(&tmp); -+ if (tmp.hasIndexReg()) { -+ fstx_s(fs, tmp.base(), tmp.index()); -+ } else { -+ fst_s(fs, tmp.base(), tmp.offset()); -+ } -+} -+ -+void TurboAssembler::Fld_d(FPURegister fd, const MemOperand& src) { -+ MemOperand tmp = src; -+ AdjustBaseAndOffset(&tmp); -+ if (tmp.hasIndexReg()) { -+ fldx_d(fd, tmp.base(), tmp.index()); -+ } else { -+ fld_d(fd, tmp.base(), tmp.offset()); -+ } -+} -+ -+void TurboAssembler::Fst_d(FPURegister fs, const MemOperand& src) { -+ MemOperand tmp = src; -+ AdjustBaseAndOffset(&tmp); -+ if (tmp.hasIndexReg()) { -+ fstx_d(fs, tmp.base(), tmp.index()); -+ } else { -+ fst_d(fs, tmp.base(), tmp.offset()); -+ } -+} -+ -+void TurboAssembler::Ll_w(Register rd, const MemOperand& rj) { -+ DCHECK(!rj.hasIndexReg()); -+ bool is_one_instruction = is_int14(rj.offset()); -+ if (is_one_instruction) { -+ ll_w(rd, rj.base(), rj.offset()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, rj.offset()); -+ add_d(scratch, scratch, rj.base()); -+ ll_w(rd, scratch, 0); -+ } -+} -+ -+void TurboAssembler::Ll_d(Register rd, const MemOperand& rj) { -+ DCHECK(!rj.hasIndexReg()); -+ bool is_one_instruction = is_int14(rj.offset()); -+ if (is_one_instruction) { -+ ll_d(rd, rj.base(), rj.offset()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, rj.offset()); -+ add_d(scratch, scratch, rj.base()); -+ ll_d(rd, scratch, 0); -+ } -+} -+ -+void TurboAssembler::Sc_w(Register rd, const MemOperand& rj) { -+ DCHECK(!rj.hasIndexReg()); -+ bool is_one_instruction = is_int14(rj.offset()); -+ if (is_one_instruction) { -+ sc_w(rd, rj.base(), rj.offset()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, rj.offset()); -+ add_d(scratch, scratch, rj.base()); -+ sc_w(rd, scratch, 0); -+ } -+} -+ -+void TurboAssembler::Sc_d(Register rd, const MemOperand& rj) { -+ DCHECK(!rj.hasIndexReg()); -+ bool is_one_instruction = is_int14(rj.offset()); -+ if (is_one_instruction) { -+ sc_d(rd, rj.base(), rj.offset()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, rj.offset()); -+ add_d(scratch, scratch, rj.base()); -+ sc_d(rd, scratch, 0); -+ } -+} -+ -+void TurboAssembler::li(Register dst, Handle value, LiFlags mode) { -+ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating -+ // non-isolate-independent code. In many cases it might be cheaper than -+ // embedding the relocatable value. -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(dst, value); -+ return; -+ } -+ li(dst, Operand(value), mode); -+} -+ -+void TurboAssembler::li(Register dst, ExternalReference value, LiFlags mode) { -+ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating -+ // non-isolate-independent code. In many cases it might be cheaper than -+ // embedding the relocatable value. -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadExternalReference(dst, value); -+ return; -+ } -+ li(dst, Operand(value), mode); -+} -+ -+void TurboAssembler::li(Register dst, const StringConstantBase* string, -+ LiFlags mode) { -+ li(dst, Operand::EmbeddedStringConstant(string), mode); -+} -+ -+static inline int InstrCountForLiLower32Bit(int64_t value) { -+ if (is_int12(static_cast(value)) || -+ is_uint12(static_cast(value)) || !(value & kImm12Mask)) { -+ return 1; -+ } else { -+ return 2; -+ } -+} -+ -+void TurboAssembler::LiLower32BitHelper(Register rd, Operand j) { -+ if (is_int12(static_cast(j.immediate()))) { -+ addi_d(rd, zero_reg, j.immediate()); -+ } else if (is_uint12(static_cast(j.immediate()))) { -+ ori(rd, zero_reg, j.immediate() & kImm12Mask); -+ } else { -+ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); -+ if (j.immediate() & kImm12Mask) { -+ ori(rd, rd, j.immediate() & kImm12Mask); -+ } -+ } -+} -+ -+int TurboAssembler::InstrCountForLi64Bit(int64_t value) { -+ if (is_int32(value)) { -+ return InstrCountForLiLower32Bit(value); -+ } else if (is_int52(value)) { -+ return InstrCountForLiLower32Bit(value) + 1; -+ } else if ((value & 0xffffffffL) == 0) { -+ // 32 LSBs (Least Significant Bits) all set to zero. -+ uint8_t tzc = base::bits::CountTrailingZeros32(value >> 32); -+ uint8_t lzc = base::bits::CountLeadingZeros32(value >> 32); -+ if (tzc >= 20) { -+ return 1; -+ } else if (tzc + lzc > 12) { -+ return 2; -+ } else { -+ return 3; -+ } -+ } else { -+ int64_t imm21 = (value >> 31) & 0x1fffffL; -+ if (imm21 != 0x1fffffL && imm21 != 0) { -+ return InstrCountForLiLower32Bit(value) + 2; -+ } else { -+ return InstrCountForLiLower32Bit(value) + 1; -+ } -+ } -+ UNREACHABLE(); -+ return INT_MAX; -+} -+ -+// All changes to if...else conditions here must be added to -+// InstrCountForLi64Bit as well. -+void TurboAssembler::li_optimized(Register rd, Operand j, LiFlags mode) { -+ DCHECK(!j.is_reg()); -+ DCHECK(!MustUseReg(j.rmode())); -+ DCHECK(mode == OPTIMIZE_SIZE); -+ int64_t imm = j.immediate(); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Normal load of an immediate value which does not need Relocation Info. -+ if (is_int32(imm)) { -+ LiLower32BitHelper(rd, j); -+ } else if (is_int52(imm)) { -+ LiLower32BitHelper(rd, j); -+ lu32i_d(rd, imm >> 32 & 0xfffff); -+ } else if ((imm & 0xffffffffL) == 0) { -+ // 32 LSBs (Least Significant Bits) all set to zero. -+ uint8_t tzc = base::bits::CountTrailingZeros32(imm >> 32); -+ uint8_t lzc = base::bits::CountLeadingZeros32(imm >> 32); -+ if (tzc >= 20) { -+ lu52i_d(rd, zero_reg, imm >> 52 & kImm12Mask); -+ } else if (tzc + lzc > 12) { -+ int32_t mask = (1 << (32 - tzc)) - 1; -+ lu12i_w(rd, imm >> (tzc + 32) & mask); -+ slli_d(rd, rd, tzc + 20); -+ } else { -+ xor_(rd, rd, rd); -+ lu32i_d(rd, imm >> 32 & 0xfffff); -+ lu52i_d(rd, rd, imm >> 52 & kImm12Mask); -+ } -+ } else { -+ int64_t imm21 = (imm >> 31) & 0x1fffffL; -+ LiLower32BitHelper(rd, j); -+ if (imm21 != 0x1fffffL && imm21 != 0) lu32i_d(rd, imm >> 32 & 0xfffff); -+ lu52i_d(rd, rd, imm >> 52 & kImm12Mask); -+ } -+} -+ -+void TurboAssembler::li(Register rd, Operand j, LiFlags mode) { -+ DCHECK(!j.is_reg()); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (!MustUseReg(j.rmode()) && mode == OPTIMIZE_SIZE) { -+ li_optimized(rd, j, mode); -+ } else if (MustUseReg(j.rmode())) { -+ int64_t immediate; -+ if (j.IsHeapObjectRequest()) { -+ RequestHeapObject(j.heap_object_request()); -+ immediate = 0; -+ } else { -+ immediate = j.immediate(); -+ } -+ -+ RecordRelocInfo(j.rmode(), immediate); -+ lu12i_w(rd, immediate >> 12 & 0xfffff); -+ ori(rd, rd, immediate & kImm12Mask); -+ lu32i_d(rd, immediate >> 32 & 0xfffff); -+ } else if (mode == ADDRESS_LOAD) { -+ // We always need the same number of instructions as we may need to patch -+ // this code to load another value which may need all 3 instructions. -+ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); -+ ori(rd, rd, j.immediate() & kImm12Mask); -+ lu32i_d(rd, j.immediate() >> 32 & 0xfffff); -+ } else { // mode == CONSTANT_SIZE - always emit the same instruction -+ // sequence. -+ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); -+ ori(rd, rd, j.immediate() & kImm12Mask); -+ lu32i_d(rd, j.immediate() >> 32 & 0xfffff); -+ lu52i_d(rd, rd, j.immediate() >> 52 & kImm12Mask); -+ } -+} -+ -+void TurboAssembler::MultiPush(RegList regs) { -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPush(RegList regs1, RegList regs2) { -+ DCHECK_EQ(regs1 & regs2, 0); -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs1 & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs2 & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPush(RegList regs1, RegList regs2, RegList regs3) { -+ DCHECK_EQ(regs1 & regs2, 0); -+ DCHECK_EQ(regs1 & regs3, 0); -+ DCHECK_EQ(regs2 & regs3, 0); -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs1 & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs2 & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs3 & (1 << i)) != 0) { -+ stack_offset -= kPointerSize; -+ St_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPop(RegList regs) { -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPop(RegList regs1, RegList regs2) { -+ DCHECK_EQ(regs1 & regs2, 0); -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs2 & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs1 & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPop(RegList regs1, RegList regs2, RegList regs3) { -+ DCHECK_EQ(regs1 & regs2, 0); -+ DCHECK_EQ(regs1 & regs3, 0); -+ DCHECK_EQ(regs2 & regs3, 0); -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs3 & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs2 & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs1 & (1 << i)) != 0) { -+ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); -+ stack_offset += kPointerSize; -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::MultiPushFPU(RegList regs) { -+ int16_t num_to_push = base::bits::CountPopulation(regs); -+ int16_t stack_offset = num_to_push * kDoubleSize; -+ -+ Sub_d(sp, sp, Operand(stack_offset)); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs & (1 << i)) != 0) { -+ stack_offset -= kDoubleSize; -+ Fst_d(FPURegister::from_code(i), MemOperand(sp, stack_offset)); -+ } -+ } -+} -+ -+void TurboAssembler::MultiPopFPU(RegList regs) { -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs & (1 << i)) != 0) { -+ Fld_d(FPURegister::from_code(i), MemOperand(sp, stack_offset)); -+ stack_offset += kDoubleSize; -+ } -+ } -+ addi_d(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::Bstrpick_w(Register rk, Register rj, uint16_t msbw, -+ uint16_t lsbw) { -+ DCHECK_LT(lsbw, msbw); -+ DCHECK_LT(lsbw, 32); -+ DCHECK_LT(msbw, 32); -+ bstrpick_w(rk, rj, msbw, lsbw); -+} -+ -+void TurboAssembler::Bstrpick_d(Register rk, Register rj, uint16_t msbw, -+ uint16_t lsbw) { -+ DCHECK_LT(lsbw, msbw); -+ DCHECK_LT(lsbw, 64); -+ DCHECK_LT(msbw, 64); -+ bstrpick_d(rk, rj, msbw, lsbw); -+} -+ -+void TurboAssembler::Neg_s(FPURegister fd, FPURegister fj) { fneg_s(fd, fj); } -+ -+void TurboAssembler::Neg_d(FPURegister fd, FPURegister fj) { fneg_d(fd, fj); } -+ -+void TurboAssembler::Ffint_d_uw(FPURegister fd, FPURegister fj) { -+ // Move the data from fs to t8. -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ movfr2gr_s(t8, fj); -+ Ffint_d_uw(fd, t8); -+} -+ -+void TurboAssembler::Ffint_d_uw(FPURegister fd, Register rj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ -+ // Convert rj to a FP value in fd. -+ DCHECK(rj != t7); -+ -+ // Zero extend int32 in rj. -+ Bstrpick_d(t7, rj, 31, 0); -+ movgr2fr_d(fd, t7); -+ ffint_d_l(fd, fd); -+} -+ -+void TurboAssembler::Ffint_d_ul(FPURegister fd, FPURegister fj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Move the data from fs to t8. -+ movfr2gr_d(t8, fj); -+ Ffint_d_ul(fd, t8); -+} -+ -+void TurboAssembler::Ffint_d_ul(FPURegister fd, Register rj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Convert rj to a FP value in fd. -+ -+ DCHECK(rj != t7); -+ -+ Label msb_clear, conversion_done; -+ -+ Branch(&msb_clear, ge, rj, Operand(zero_reg)); -+ -+ // Rj >= 2^63 -+ andi(t7, rj, 1); -+ srli_d(rj, rj, 1); -+ or_(t7, t7, rj); -+ movgr2fr_d(fd, t7); -+ ffint_d_l(fd, fd); -+ fadd_d(fd, fd, fd); -+ Branch(&conversion_done); -+ -+ bind(&msb_clear); -+ // Rs < 2^63, we can do simple conversion. -+ movgr2fr_d(fd, rj); -+ ffint_d_l(fd, fd); -+ -+ bind(&conversion_done); -+} -+ -+void TurboAssembler::Ffint_s_uw(FPURegister fd, FPURegister fj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Move the data from fs to t8. -+ movfr2gr_d(t8, fj); -+ Ffint_s_uw(fd, t8); -+} -+ -+void TurboAssembler::Ffint_s_uw(FPURegister fd, Register rj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Convert rj to a FP value in fd. -+ DCHECK(rj != t7); -+ -+ // Zero extend int32 in rj. -+ bstrpick_d(t7, rj, 31, 0); -+ movgr2fr_d(fd, t7); -+ ffint_s_l(fd, fd); -+} -+ -+void TurboAssembler::Ffint_s_ul(FPURegister fd, FPURegister fj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Move the data from fs to t8. -+ movfr2gr_d(t8, fj); -+ Ffint_s_ul(fd, t8); -+} -+ -+void TurboAssembler::Ffint_s_ul(FPURegister fd, Register rj) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Convert rj to a FP value in fd. -+ -+ DCHECK(rj != t7); -+ -+ Label positive, conversion_done; -+ -+ Branch(&positive, ge, rj, Operand(zero_reg)); -+ -+ // Rs >= 2^31. -+ andi(t7, rj, 1); -+ srli_d(rj, rj, 1); -+ or_(t7, t7, rj); -+ movgr2fr_d(fd, t7); -+ ffint_s_l(fd, fd); -+ fadd_s(fd, fd, fd); -+ Branch(&conversion_done); -+ -+ bind(&positive); -+ // Rs < 2^31, we can do simple conversion. -+ movgr2fr_d(fd, rj); -+ ffint_s_l(fd, fd); -+ -+ bind(&conversion_done); -+} -+ -+void MacroAssembler::Ftintrne_l_d(FPURegister fd, FPURegister fj) { -+ ftintrne_l_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrm_l_d(FPURegister fd, FPURegister fj) { -+ ftintrm_l_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrp_l_d(FPURegister fd, FPURegister fj) { -+ ftintrp_l_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrz_l_d(FPURegister fd, FPURegister fj) { -+ ftintrz_l_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrz_l_ud(FPURegister fd, FPURegister fj, -+ FPURegister scratch) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Load to GPR. -+ movfr2gr_d(t8, fj); -+ // Reset sign bit. -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ li(scratch1, 0x7FFFFFFFFFFFFFFFl); -+ and_(t8, t8, scratch1); -+ } -+ movgr2fr_d(scratch, t8); -+ Ftintrz_l_d(fd, scratch); -+} -+ -+void TurboAssembler::Ftintrz_uw_d(FPURegister fd, FPURegister fj, -+ FPURegister scratch) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Ftintrz_uw_d(t8, fj, scratch); -+ movgr2fr_w(fd, t8); -+} -+ -+void TurboAssembler::Ftintrz_uw_s(FPURegister fd, FPURegister fj, -+ FPURegister scratch) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Ftintrz_uw_s(t8, fj, scratch); -+ movgr2fr_w(fd, t8); -+} -+ -+void TurboAssembler::Ftintrz_ul_d(FPURegister fd, FPURegister fj, -+ FPURegister scratch, Register result) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Ftintrz_ul_d(t8, fj, scratch, result); -+ movgr2fr_d(fd, t8); -+} -+ -+void TurboAssembler::Ftintrz_ul_s(FPURegister fd, FPURegister fj, -+ FPURegister scratch, Register result) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Ftintrz_ul_s(t8, fj, scratch, result); -+ movgr2fr_d(fd, t8); -+} -+ -+void MacroAssembler::Ftintrz_w_d(FPURegister fd, FPURegister fj) { -+ ftintrz_w_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrne_w_d(FPURegister fd, FPURegister fj) { -+ ftintrne_w_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrm_w_d(FPURegister fd, FPURegister fj) { -+ ftintrm_w_d(fd, fj); -+} -+ -+void MacroAssembler::Ftintrp_w_d(FPURegister fd, FPURegister fj) { -+ ftintrp_w_d(fd, fj); -+} -+ -+void TurboAssembler::Ftintrz_uw_d(Register rd, FPURegister fj, -+ FPURegister scratch) { -+ DCHECK(fj != scratch); -+ DCHECK(rd != t7); -+ -+ { -+ // Load 2^31 into scratch as its float representation. -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ li(scratch1, 0x41E00000); -+ movgr2fr_w(scratch, zero_reg); -+ movgr2frh_w(scratch, scratch1); -+ } -+ // Test if scratch > fd. -+ // If fd < 2^31 we can convert it normally. -+ Label simple_convert; -+ CompareF64(fj, scratch, CLT); -+ BranchTrueShortF(&simple_convert); -+ -+ // First we subtract 2^31 from fd, then trunc it to rs -+ // and add 2^31 to rj. -+ fsub_d(scratch, fj, scratch); -+ ftintrz_w_d(scratch, scratch); -+ movfr2gr_s(rd, scratch); -+ Or(rd, rd, 1 << 31); -+ -+ Label done; -+ Branch(&done); -+ // Simple conversion. -+ bind(&simple_convert); -+ ftintrz_w_d(scratch, fj); -+ movfr2gr_s(rd, scratch); -+ -+ bind(&done); -+} -+ -+void TurboAssembler::Ftintrz_uw_s(Register rd, FPURegister fj, -+ FPURegister scratch) { -+ DCHECK(fj != scratch); -+ DCHECK(rd != t7); -+ { -+ // Load 2^31 into scratch as its float representation. -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ li(scratch1, 0x4F000000); -+ movgr2fr_w(scratch, scratch1); -+ } -+ // Test if scratch > fs. -+ // If fs < 2^31 we can convert it normally. -+ Label simple_convert; -+ CompareF32(fj, scratch, CLT); -+ BranchTrueShortF(&simple_convert); -+ -+ // First we subtract 2^31 from fs, then trunc it to rd -+ // and add 2^31 to rd. -+ fsub_s(scratch, fj, scratch); -+ ftintrz_w_s(scratch, scratch); -+ movfr2gr_s(rd, scratch); -+ Or(rd, rd, 1 << 31); -+ -+ Label done; -+ Branch(&done); -+ // Simple conversion. -+ bind(&simple_convert); -+ ftintrz_w_s(scratch, fj); -+ movfr2gr_s(rd, scratch); -+ -+ bind(&done); -+} -+ -+void TurboAssembler::Ftintrz_ul_d(Register rd, FPURegister fj, -+ FPURegister scratch, Register result) { -+ DCHECK(fj != scratch); -+ DCHECK(result.is_valid() ? !AreAliased(rd, result, t7) : !AreAliased(rd, t7)); -+ -+ Label simple_convert, done, fail; -+ if (result.is_valid()) { -+ mov(result, zero_reg); -+ Move(scratch, -1.0); -+ // If fd =< -1 or unordered, then the conversion fails. -+ CompareF64(fj, scratch, CLE); -+ BranchTrueShortF(&fail); -+ CompareIsNanF64(fj, scratch); -+ BranchTrueShortF(&fail); -+ } -+ -+ // Load 2^63 into scratch as its double representation. -+ li(t7, 0x43E0000000000000); -+ movgr2fr_d(scratch, t7); -+ -+ // Test if scratch > fs. -+ // If fs < 2^63 we can convert it normally. -+ CompareF64(fj, scratch, CLT); -+ BranchTrueShortF(&simple_convert); -+ -+ // First we subtract 2^63 from fs, then trunc it to rd -+ // and add 2^63 to rd. -+ fsub_d(scratch, fj, scratch); -+ ftintrz_l_d(scratch, scratch); -+ movfr2gr_d(rd, scratch); -+ Or(rd, rd, Operand(1UL << 63)); -+ Branch(&done); -+ -+ // Simple conversion. -+ bind(&simple_convert); -+ ftintrz_l_d(scratch, fj); -+ movfr2gr_d(rd, scratch); -+ -+ bind(&done); -+ if (result.is_valid()) { -+ // Conversion is failed if the result is negative. -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ addi_d(scratch1, zero_reg, -1); -+ srli_d(scratch1, scratch1, 1); // Load 2^62. -+ movfr2gr_d(result, scratch); -+ xor_(result, result, scratch1); -+ } -+ Slt(result, zero_reg, result); -+ } -+ -+ bind(&fail); -+} -+ -+void TurboAssembler::Ftintrz_ul_s(Register rd, FPURegister fj, -+ FPURegister scratch, Register result) { -+ DCHECK(fj != scratch); -+ DCHECK(result.is_valid() ? !AreAliased(rd, result, t7) : !AreAliased(rd, t7)); -+ -+ Label simple_convert, done, fail; -+ if (result.is_valid()) { -+ mov(result, zero_reg); -+ Move(scratch, -1.0f); -+ // If fd =< -1 or unordered, then the conversion fails. -+ CompareF32(fj, scratch, CLE); -+ BranchTrueShortF(&fail); -+ CompareIsNanF32(fj, scratch); -+ BranchTrueShortF(&fail); -+ } -+ -+ { -+ // Load 2^63 into scratch as its float representation. -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ li(scratch1, 0x5F000000); -+ movgr2fr_w(scratch, scratch1); -+ } -+ -+ // Test if scratch > fs. -+ // If fs < 2^63 we can convert it normally. -+ CompareF32(fj, scratch, CLT); -+ BranchTrueShortF(&simple_convert); -+ -+ // First we subtract 2^63 from fs, then trunc it to rd -+ // and add 2^63 to rd. -+ fsub_s(scratch, fj, scratch); -+ ftintrz_l_s(scratch, scratch); -+ movfr2gr_d(rd, scratch); -+ Or(rd, rd, Operand(1UL << 63)); -+ Branch(&done); -+ -+ // Simple conversion. -+ bind(&simple_convert); -+ ftintrz_l_s(scratch, fj); -+ movfr2gr_d(rd, scratch); -+ -+ bind(&done); -+ if (result.is_valid()) { -+ // Conversion is failed if the result is negative or unordered. -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch1 = temps.Acquire(); -+ addi_d(scratch1, zero_reg, -1); -+ srli_d(scratch1, scratch1, 1); // Load 2^62. -+ movfr2gr_d(result, scratch); -+ xor_(result, result, scratch1); -+ } -+ Slt(result, zero_reg, result); -+ } -+ -+ bind(&fail); -+} -+ -+void TurboAssembler::RoundDouble(FPURegister dst, FPURegister src, -+ FPURoundingMode mode) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = t8; -+ movfcsr2gr(scratch); -+ li(t7, Operand(mode)); -+ movgr2fcsr(t7); -+ frint_d(dst, src); -+ movgr2fcsr(scratch); -+} -+ -+void TurboAssembler::Floor_d(FPURegister dst, FPURegister src) { -+ RoundDouble(dst, src, mode_floor); -+} -+ -+void TurboAssembler::Ceil_d(FPURegister dst, FPURegister src) { -+ RoundDouble(dst, src, mode_ceil); -+} -+ -+void TurboAssembler::Trunc_d(FPURegister dst, FPURegister src) { -+ RoundDouble(dst, src, mode_trunc); -+} -+ -+void TurboAssembler::Round_d(FPURegister dst, FPURegister src) { -+ RoundDouble(dst, src, mode_round); -+} -+ -+void TurboAssembler::RoundFloat(FPURegister dst, FPURegister src, -+ FPURoundingMode mode) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = t8; -+ movfcsr2gr(scratch); -+ li(t7, Operand(mode)); -+ movgr2fcsr(t7); -+ frint_s(dst, src); -+ movgr2fcsr(scratch); -+} -+ -+void TurboAssembler::Floor_s(FPURegister dst, FPURegister src) { -+ RoundFloat(dst, src, mode_floor); -+} -+ -+void TurboAssembler::Ceil_s(FPURegister dst, FPURegister src) { -+ RoundFloat(dst, src, mode_ceil); -+} -+ -+void TurboAssembler::Trunc_s(FPURegister dst, FPURegister src) { -+ RoundFloat(dst, src, mode_trunc); -+} -+ -+void TurboAssembler::Round_s(FPURegister dst, FPURegister src) { -+ RoundFloat(dst, src, mode_round); -+} -+ -+void TurboAssembler::CompareF(FPURegister cmp1, FPURegister cmp2, -+ FPUCondition cc, CFRegister cd, bool f32) { -+ if (f32) { -+ fcmp_cond_s(cc, cmp1, cmp2, cd); -+ } else { -+ fcmp_cond_d(cc, cmp1, cmp2, cd); -+ } -+} -+ -+void TurboAssembler::CompareIsNanF(FPURegister cmp1, FPURegister cmp2, -+ CFRegister cd, bool f32) { -+ CompareF(cmp1, cmp2, CUN, cd, f32); -+} -+ -+void TurboAssembler::BranchTrueShortF(Label* target, CFRegister cj) { -+ bcnez(cj, target); -+} -+ -+void TurboAssembler::BranchFalseShortF(Label* target, CFRegister cj) { -+ bceqz(cj, target); -+} -+ -+void TurboAssembler::BranchTrueF(Label* target, CFRegister cj) { -+ // TODO can be optimzed -+ bool long_branch = target->is_bound() -+ ? !is_near(target, OffsetSize::kOffset21) -+ : is_trampoline_emitted(); -+ if (long_branch) { -+ Label skip; -+ BranchFalseShortF(&skip, cj); -+ Branch(target); -+ bind(&skip); -+ } else { -+ BranchTrueShortF(target, cj); -+ } -+} -+ -+void TurboAssembler::BranchFalseF(Label* target, CFRegister cj) { -+ bool long_branch = target->is_bound() -+ ? !is_near(target, OffsetSize::kOffset21) -+ : is_trampoline_emitted(); -+ if (long_branch) { -+ Label skip; -+ BranchTrueShortF(&skip, cj); -+ Branch(target); -+ bind(&skip); -+ } else { -+ BranchFalseShortF(target, cj); -+ } -+} -+ -+void TurboAssembler::FmoveLow(FPURegister dst, Register src_low) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(src_low != scratch); -+ movfrh2gr_s(scratch, dst); -+ movgr2fr_w(dst, src_low); -+ movgr2frh_w(dst, scratch); -+} -+ -+void TurboAssembler::Move(FPURegister dst, uint32_t src) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(static_cast(src))); -+ movgr2fr_w(dst, scratch); -+} -+ -+void TurboAssembler::Move(FPURegister dst, uint64_t src) { -+ // Handle special values first. -+ if (src == bit_cast(0.0) && has_double_zero_reg_set_) { -+ fmov_d(dst, kDoubleRegZero); -+ } else if (src == bit_cast(-0.0) && has_double_zero_reg_set_) { -+ Neg_d(dst, kDoubleRegZero); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(static_cast(src))); -+ movgr2fr_d(dst, scratch); -+ if (dst == kDoubleRegZero) has_double_zero_reg_set_ = true; -+ } -+} -+ -+void TurboAssembler::Movz(Register rd, Register rj, Register rk) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ maskeqz(scratch, rj, rk); -+ masknez(rd, rd, rk); -+ or_(rd, rd, scratch); -+} -+ -+void TurboAssembler::Movn(Register rd, Register rj, Register rk) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ masknez(scratch, rj, rk); -+ maskeqz(rd, rd, rk); -+ or_(rd, rd, scratch); -+} -+ -+void TurboAssembler::LoadZeroOnCondition(Register rd, Register rj, -+ const Operand& rk, Condition cond) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ switch (cond) { -+ case cc_always: -+ mov(rd, zero_reg); -+ break; -+ case eq: -+ if (rj == zero_reg) { -+ if (rk.is_reg()) { -+ LoadZeroIfConditionZero(rd, rk.rm()); -+ } else { -+ if (rk.immediate() == 0) { -+ mov(rd, zero_reg); -+ } else { -+ // nop(); -+ } -+ } -+ } else if (IsZero(rk)) { -+ LoadZeroIfConditionZero(rd, rj); -+ } else { -+ Sub_d(t7, rj, rk); -+ LoadZeroIfConditionZero(rd, t7); -+ } -+ break; -+ case ne: -+ if (rj == zero_reg) { -+ if (rk.is_reg()) { -+ LoadZeroIfConditionNotZero(rd, rk.rm()); -+ } else { -+ if (rk.immediate() != 0) { -+ mov(rd, zero_reg); -+ } else { -+ // nop(); -+ } -+ } -+ } else if (IsZero(rk)) { -+ LoadZeroIfConditionNotZero(rd, rj); -+ } else { -+ Sub_d(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ } -+ break; -+ -+ // Signed comparison. -+ case greater: -+ Sgt(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ break; -+ case greater_equal: -+ Sge(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj >= rk -+ break; -+ case less: -+ Slt(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj < rk -+ break; -+ case less_equal: -+ Sle(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj <= rk -+ break; -+ -+ // Unsigned comparison. -+ case Ugreater: -+ Sgtu(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj > rk -+ break; -+ -+ case Ugreater_equal: -+ Sgeu(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj >= rk -+ break; -+ case Uless: -+ Sltu(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj < rk -+ break; -+ case Uless_equal: -+ Sleu(t7, rj, rk); -+ LoadZeroIfConditionNotZero(rd, t7); -+ // rj <= rk -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void TurboAssembler::LoadZeroIfConditionNotZero(Register dest, -+ Register condition) { -+ maskeqz(dest, dest, condition); -+} -+ -+void TurboAssembler::LoadZeroIfConditionZero(Register dest, -+ Register condition) { -+ masknez(dest, dest, condition); -+} -+ -+void TurboAssembler::LoadZeroIfFPUCondition(Register dest, CFRegister cc) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ movcf2gr(scratch, cc); -+ LoadZeroIfConditionNotZero(dest, scratch); -+} -+ -+void TurboAssembler::LoadZeroIfNotFPUCondition(Register dest, CFRegister cc) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ movcf2gr(scratch, cc); -+ LoadZeroIfConditionZero(dest, scratch); -+} -+ -+void TurboAssembler::Clz_w(Register rd, Register rj) { clz_w(rd, rj); } -+ -+void TurboAssembler::Clz_d(Register rd, Register rj) { clz_d(rd, rj); } -+ -+void TurboAssembler::Ctz_w(Register rd, Register rj) { ctz_w(rd, rj); } -+ -+void TurboAssembler::Ctz_d(Register rd, Register rj) { ctz_d(rd, rj); } -+ -+// TODO: Optimize like arm64, use simd instruction -+void TurboAssembler::Popcnt_w(Register rd, Register rj) { -+ // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel -+ // -+ // A generalization of the best bit counting method to integers of -+ // bit-widths up to 128 (parameterized by type T) is this: -+ // -+ // v = v - ((v >> 1) & (T)~(T)0/3); // temp -+ // v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); // temp -+ // v = (v + (v >> 4)) & (T)~(T)0/255*15; // temp -+ // c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * BITS_PER_BYTE; //count -+ // -+ // For comparison, for 32-bit quantities, this algorithm can be executed -+ // using 20 MIPS instructions (the calls to LoadConst32() generate two -+ // machine instructions each for the values being used in this algorithm). -+ // A(n unrolled) loop-based algorithm requires 25 instructions. -+ // -+ // For a 64-bit operand this can be performed in 24 instructions compared -+ // to a(n unrolled) loop based algorithm which requires 38 instructions. -+ // -+ // There are algorithms which are faster in the cases where very few -+ // bits are set but the algorithm here attempts to minimize the total -+ // number of instructions executed even when a large number of bits -+ // are set. -+ int32_t B0 = 0x55555555; // (T)~(T)0/3 -+ int32_t B1 = 0x33333333; // (T)~(T)0/15*3 -+ int32_t B2 = 0x0F0F0F0F; // (T)~(T)0/255*15 -+ int32_t value = 0x01010101; // (T)~(T)0/255 -+ uint32_t shift = 24; // (sizeof(T) - 1) * BITS_PER_BYTE -+ -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.Acquire(); -+ Register scratch2 = t8; -+ srli_w(scratch, rj, 1); -+ li(scratch2, B0); -+ And(scratch, scratch, scratch2); -+ Sub_w(scratch, rj, scratch); -+ li(scratch2, B1); -+ And(rd, scratch, scratch2); -+ srli_w(scratch, scratch, 2); -+ And(scratch, scratch, scratch2); -+ Add_w(scratch, rd, scratch); -+ srli_w(rd, scratch, 4); -+ Add_w(rd, rd, scratch); -+ li(scratch2, B2); -+ And(rd, rd, scratch2); -+ li(scratch, value); -+ Mul_w(rd, rd, scratch); -+ srli_w(rd, rd, shift); -+} -+ -+void TurboAssembler::Popcnt_d(Register rd, Register rj) { -+ int64_t B0 = 0x5555555555555555l; // (T)~(T)0/3 -+ int64_t B1 = 0x3333333333333333l; // (T)~(T)0/15*3 -+ int64_t B2 = 0x0F0F0F0F0F0F0F0Fl; // (T)~(T)0/255*15 -+ int64_t value = 0x0101010101010101l; // (T)~(T)0/255 -+ uint32_t shift = 56; // (sizeof(T) - 1) * BITS_PER_BYTE -+ -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.Acquire(); -+ Register scratch2 = t8; -+ srli_d(scratch, rj, 1); -+ li(scratch2, B0); -+ And(scratch, scratch, scratch2); -+ Sub_d(scratch, rj, scratch); -+ li(scratch2, B1); -+ And(rd, scratch, scratch2); -+ srli_d(scratch, scratch, 2); -+ And(scratch, scratch, scratch2); -+ Add_d(scratch, rd, scratch); -+ srli_d(rd, scratch, 4); -+ Add_d(rd, rd, scratch); -+ li(scratch2, B2); -+ And(rd, rd, scratch2); -+ li(scratch, value); -+ Mul_d(rd, rd, scratch); -+ srli_d(rd, rd, shift); -+} -+ -+void TurboAssembler::ExtractBits(Register dest, Register source, Register pos, -+ int size, bool sign_extend) { -+ sra_d(dest, source, pos); -+ bstrpick_d(dest, dest, size - 1, 0); -+ if (sign_extend) { -+ switch (size) { -+ case 8: -+ ext_w_b(dest, dest); -+ break; -+ case 16: -+ ext_w_h(dest, dest); -+ break; -+ case 32: -+ // sign-extend word -+ slli_w(dest, dest, 0); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+void TurboAssembler::InsertBits(Register dest, Register source, Register pos, -+ int size) { -+ Rotr_d(dest, dest, pos); -+ bstrins_d(dest, source, size - 1, 0); -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Sub_d(scratch, zero_reg, pos); -+ Rotr_d(dest, dest, scratch); -+ } -+} -+ -+void MacroAssembler::EmitFPUTruncate( -+ FPURoundingMode rounding_mode, Register result, DoubleRegister double_input, -+ Register scratch, DoubleRegister double_scratch, Register except_flag, -+ CheckForInexactConversion check_inexact) { -+ break_(3); -+} -+ -+void TurboAssembler::TryInlineTruncateDoubleToI(Register result, -+ DoubleRegister double_input, -+ Label* done) { -+ DoubleRegister single_scratch = kScratchDoubleReg.low(); -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.Acquire(); -+ Register scratch2 = t7; -+ -+ // Clear cumulative exception flags and save the FCSR. -+ /* movfcsr2gr(scratch2, FCSR); -+ movgr2fcsr(FCSR, zero_reg); -+ // Try a conversion to a signed integer. -+ ftintrz_w_d(single_scratch, double_input); -+ movfr2gr_w(result, single_scratch); -+ // Retrieve and restore the FCSR. -+ movfcsr2gr(scratch, FCSR); -+ movgr2fcsr(FCSR, scratch2); -+ // Check for overflow and NaNs. -+ And(scratch, scratch, -+ kFCSROverflowFlagMask | kFCSRUnderflowFlagMask | -+ kFCSRInvalidOpFlagMask); -+ // If we had no exceptions we are done. -+ Branch(done, eq, scratch, Operand(zero_reg));*/ -+ -+ CompareIsNanF64(double_input, double_input); -+ Move(result, zero_reg); -+ bcnez(FCC0, done); -+ ftintrz_l_d(single_scratch, double_input); -+ movfr2gr_d(scratch2, single_scratch); -+ li(scratch, 1L << 63); -+ Xor(scratch, scratch, scratch2); -+ rotri_d(scratch2, scratch, 1); -+ movfr2gr_s(result, single_scratch); -+ Branch(done, ne, scratch, Operand(scratch2)); -+} -+ -+void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone, -+ Register result, -+ DoubleRegister double_input, -+ StubCallMode stub_mode) { -+ Label done; -+ -+ TryInlineTruncateDoubleToI(result, double_input, &done); -+ -+ // If we fell through then inline version didn't succeed - call stub instead. -+ Sub_d(sp, sp, -+ Operand(kDoubleSize + kSystemPointerSize)); // Put input on stack. -+ St_d(ra, MemOperand(sp, kSystemPointerSize)); -+ Fst_d(double_input, MemOperand(sp, 0)); -+ -+ if (stub_mode == StubCallMode::kCallWasmRuntimeStub) { -+ Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL); -+ } else { -+ Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET); -+ } -+ -+ Pop(ra, result); -+ bind(&done); -+} -+ -+// BRANCH_ARGS_CHECK checks that conditional jump arguments are correct. -+#define BRANCH_ARGS_CHECK(cond, rj, rk) \ -+ DCHECK((cond == cc_always && rj == zero_reg && rk.rm() == zero_reg) || \ -+ (cond != cc_always && (rj != zero_reg || rk.rm() != zero_reg))) -+ -+void TurboAssembler::Branch(Label* L, bool need_link) { -+ int offset = GetOffset(L, OffsetSize::kOffset26); -+ if (need_link) { -+ bl(offset); -+ } else { -+ b(offset); -+ } -+} -+ -+void TurboAssembler::Branch(Label* L, Condition cond, Register rj, -+ const Operand& rk, bool need_link) { -+ if (L->is_bound()) { -+ BRANCH_ARGS_CHECK(cond, rj, rk); -+ if (!BranchShortOrFallback(L, cond, rj, rk, need_link)) { -+ if (cond != cc_always) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rj, rk, need_link); -+ Branch(L, need_link); -+ bind(&skip); -+ } else { -+ Branch(L); -+ } -+ } -+ } else { -+ if (is_trampoline_emitted()) { -+ if (cond != cc_always) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rj, rk, need_link); -+ Branch(L, need_link); -+ bind(&skip); -+ } else { -+ Branch(L); -+ } -+ } else { -+ BranchShort(L, cond, rj, rk, need_link); -+ } -+ } -+} -+ -+void TurboAssembler::Branch(Label* L, Condition cond, Register rj, -+ RootIndex index) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(L, cond, rj, Operand(scratch)); -+} -+ -+int32_t TurboAssembler::GetOffset(Label* L, OffsetSize bits) { -+ return branch_offset_helper(L, bits) >> 2; -+} -+ -+Register TurboAssembler::GetRkAsRegisterHelper(const Operand& rk, -+ Register scratch) { -+ Register r2 = no_reg; -+ if (rk.is_reg()) { -+ r2 = rk.rm(); -+ } else { -+ r2 = scratch; -+ li(r2, rk); -+ } -+ -+ return r2; -+} -+ -+bool TurboAssembler::BranchShortOrFallback(Label* L, Condition cond, -+ Register rj, const Operand& rk, -+ bool need_link) { -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; -+ -+ // Be careful to always use shifted_branch_offset only just before the -+ // branch instruction, as the location will be remember for patching the -+ // target. -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ int offset = 0; -+ switch (cond) { -+ case cc_always: -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ if (need_link) { -+ bl(offset); -+ } else { -+ b(offset); -+ } -+ break; -+ case eq: -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ // beq is used here to make the code patchable. Otherwise b should -+ // be used which has no condition field so is not patchable. -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ beq(rj, rj, offset); -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset21)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset21); -+ beqz(rj, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ // We don't want any other register but scratch clobbered. -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ beq(rj, sc, offset); -+ } -+ break; -+ case ne: -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ // bne is used here to make the code patchable. Otherwise we -+ // should not generate any instruction. -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bne(rj, rj, offset); -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset21)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset21); -+ bnez(rj, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ // We don't want any other register but scratch clobbered. -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bne(rj, sc, offset); -+ } -+ break; -+ -+ // Signed comparison. -+ case greater: -+ // rj > rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ // No code needs to be emitted. -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ blt(zero_reg, rj, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ blt(sc, rj, offset); -+ } -+ break; -+ case greater_equal: -+ // rj >= rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bge(rj, zero_reg, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bge(rj, sc, offset); -+ } -+ break; -+ case less: -+ // rj < rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ // No code needs to be emitted. -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ blt(rj, zero_reg, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ blt(rj, sc, offset); -+ } -+ break; -+ case less_equal: -+ // rj <= rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bge(zero_reg, rj, offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bge(sc, rj, offset); -+ } -+ break; -+ -+ // Unsigned comparison. -+ case Ugreater: -+ // rj > rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ // No code needs to be emitted. -+ } else if (rj == zero_reg) { -+ // No code needs to be emitted. -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bltu(sc, rj, offset); -+ } -+ break; -+ case Ugreater_equal: -+ // rj >= rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (IsZero(rk)) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (rj == zero_reg) { -+ // No code needs to be emitted. -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bgeu(rj, sc, offset); -+ } -+ break; -+ case Uless: -+ // rj < rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ // No code needs to be emitted. -+ } else if (IsZero(rk)) { -+ // No code needs to be emitted. -+ } else if (rj == zero_reg) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bltu(rj, sc, offset); -+ } -+ break; -+ case Uless_equal: -+ // rj <= rk -+ if (rk.is_reg() && rj.code() == rk.rm().code()) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (rj == zero_reg) { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; -+ if (need_link) pcaddi(ra, 2); -+ offset = GetOffset(L, OffsetSize::kOffset26); -+ b(offset); -+ } else if (IsZero(rk)) { -+ // No code needs to be emitted. -+ } else { -+ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; -+ if (need_link) pcaddi(ra, 2); -+ Register sc = GetRkAsRegisterHelper(rk, scratch); -+ DCHECK(rj != sc); -+ offset = GetOffset(L, OffsetSize::kOffset16); -+ bgeu(sc, rj, offset); -+ } -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ return true; -+} -+ -+void TurboAssembler::BranchShort(Label* L, Condition cond, Register rj, -+ const Operand& rk, bool need_link) { -+ BRANCH_ARGS_CHECK(cond, rj, rk); -+ bool result = BranchShortOrFallback(L, cond, rj, rk, need_link); -+ DCHECK(result); -+ USE(result); -+} -+ -+void TurboAssembler::LoadFromConstantsTable(Register destination, -+ int constant_index) { -+ DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kBuiltinsConstantsTable)); -+ LoadRoot(destination, RootIndex::kBuiltinsConstantsTable); -+ Ld_d(destination, -+ FieldMemOperand(destination, FixedArray::kHeaderSize + -+ constant_index * kPointerSize)); -+} -+ -+void TurboAssembler::LoadRootRelative(Register destination, int32_t offset) { -+ Ld_d(destination, MemOperand(kRootRegister, offset)); -+} -+ -+void TurboAssembler::LoadRootRegisterOffset(Register destination, -+ intptr_t offset) { -+ if (offset == 0) { -+ Move(destination, kRootRegister); -+ } else { -+ Add_d(destination, kRootRegister, Operand(offset)); -+ } -+} -+ -+void TurboAssembler::Jump(Register target, Condition cond, Register rj, -+ const Operand& rk) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (cond == cc_always) { -+ jirl(zero_reg, target, 0); -+ } else { -+ BRANCH_ARGS_CHECK(cond, rj, rk); -+ Label skip; -+ Branch(&skip, NegateCondition(cond), rj, rk); -+ jirl(zero_reg, target, 0); -+ bind(&skip); -+ } -+} -+ -+void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode, -+ Condition cond, Register rj, const Operand& rk) { -+ Label skip; -+ if (cond != cc_always) { -+ Branch(&skip, NegateCondition(cond), rj, rk); -+ } -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t7, Operand(target, rmode)); -+ jirl(zero_reg, t7, 0); -+ bind(&skip); -+ } -+} -+ -+void TurboAssembler::Jump(Address target, RelocInfo::Mode rmode, Condition cond, -+ Register rj, const Operand& rk) { -+ DCHECK(!RelocInfo::IsCodeTarget(rmode)); -+ Jump(static_cast(target), rmode, cond, rj, rk); -+} -+ -+void TurboAssembler::Jump(Handle code, RelocInfo::Mode rmode, -+ Condition cond, Register rj, const Operand& rk) { -+ DCHECK(RelocInfo::IsCodeTarget(rmode)); -+ -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(t7, code); -+ Add_d(t7, t7, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Jump(t7, cond, rj, rk); -+ return; -+ } else if (options().inline_offheap_trampolines) { -+ int builtin_index = Builtins::kNoBuiltinId; -+ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && -+ Builtins::IsIsolateIndependent(builtin_index)) { -+ // Inline the trampoline. -+ RecordCommentForOffHeapTrampoline(builtin_index); -+ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ Address entry = d.InstructionStartOfBuiltin(builtin_index); -+ li(t7, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Jump(t7, cond, rj, rk); -+ return; -+ } -+ } -+ -+ Jump(static_cast(code.address()), rmode, cond, rj, rk); -+} -+ -+void TurboAssembler::Jump(const ExternalReference& reference) { -+ li(t7, reference); -+ Jump(t7); -+} -+ -+// Note: To call gcc-compiled C code on loonarch, you must call through t[0-8]. -+void TurboAssembler::Call(Register target, Condition cond, Register rj, -+ const Operand& rk) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (cond == cc_always) { -+ jirl(ra, target, 0); -+ } else { -+ BRANCH_ARGS_CHECK(cond, rj, rk); -+ Label skip; -+ Branch(&skip, NegateCondition(cond), rj, rk); -+ jirl(ra, target, 0); -+ bind(&skip); -+ } -+ set_last_call_pc_(pc_); -+} -+ -+void MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit, -+ unsigned higher_limit, -+ Label* on_in_range) { -+ if (lower_limit != 0) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Sub_d(scratch, value, Operand(lower_limit)); -+ Branch(on_in_range, ls, scratch, Operand(higher_limit - lower_limit)); -+ } else { -+ Branch(on_in_range, ls, value, Operand(higher_limit - lower_limit)); -+ } -+} -+ -+void TurboAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond, -+ Register rj, const Operand& rk) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t7, Operand(static_cast(target), rmode), ADDRESS_LOAD); -+ Call(t7, cond, rj, rk); -+} -+ -+void TurboAssembler::Call(Handle code, RelocInfo::Mode rmode, -+ Condition cond, Register rj, const Operand& rk) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(t7, code); -+ Add_d(t7, t7, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Call(t7, cond, rj, rk); -+ return; -+ } else if (options().inline_offheap_trampolines) { -+ int builtin_index = Builtins::kNoBuiltinId; -+ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && -+ Builtins::IsIsolateIndependent(builtin_index)) { -+ // Inline the trampoline. -+ RecordCommentForOffHeapTrampoline(builtin_index); -+ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ Address entry = d.InstructionStartOfBuiltin(builtin_index); -+ li(t7, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Call(t7, cond, rj, rk); -+ return; -+ } -+ } -+ -+ DCHECK(RelocInfo::IsCodeTarget(rmode)); -+ DCHECK(code->IsExecutable()); -+ Call(code.address(), rmode, cond, rj, rk); -+} -+ -+void TurboAssembler::LoadEntryFromBuiltinIndex(Register builtin_index) { -+ STATIC_ASSERT(kSystemPointerSize == 8); -+ STATIC_ASSERT(kSmiTagSize == 1); -+ STATIC_ASSERT(kSmiTag == 0); -+ -+ // The builtin_index register contains the builtin index as a Smi. -+ SmiUntag(builtin_index, builtin_index); -+ Alsl_d(builtin_index, builtin_index, kRootRegister, kSystemPointerSizeLog2, -+ t7); -+ Ld_d(builtin_index, -+ MemOperand(builtin_index, IsolateData::builtin_entry_table_offset())); -+} -+ -+void TurboAssembler::CallBuiltinByIndex(Register builtin_index) { -+ LoadEntryFromBuiltinIndex(builtin_index); -+ Call(builtin_index); -+} -+ -+void TurboAssembler::PatchAndJump(Address target) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ pcaddi(scratch, 4); -+ Ld_d(t7, MemOperand(scratch, 0)); -+ jirl(zero_reg, t7, 0); -+ nop(); -+ DCHECK_EQ(reinterpret_cast(pc_) % 8, 0); -+ *reinterpret_cast(pc_) = target; // pc_ should be align. -+ pc_ += sizeof(uint64_t); -+} -+ -+void TurboAssembler::StoreReturnAddressAndCall(Register target) { -+ // This generates the final instruction sequence for calls to C functions -+ // once an exit frame has been constructed. -+ // -+ // Note that this assumes the caller code (i.e. the Code object currently -+ // being generated) is immovable or that the callee function cannot trigger -+ // GC, since the callee function will return to it. -+ -+ Assembler::BlockTrampolinePoolScope block_trampoline_pool(this); -+ static constexpr int kNumInstructionsToJump = 2; -+ Label find_ra; -+ // Adjust the value in ra to point to the correct return location, 2nd -+ // instruction past the real call into C code (the jirl)), and push it. -+ // This is the return address of the exit frame. -+ pcaddi(ra, kNumInstructionsToJump + 1); -+ bind(&find_ra); -+ -+ // This spot was reserved in EnterExitFrame. -+ St_d(ra, MemOperand(sp, 0)); -+ // Stack is still aligned. -+ -+ // TODO can be jirl target? a0 -- a7? -+ jirl(zero_reg, target, 0); -+ // Make sure the stored 'ra' points to this position. -+ DCHECK_EQ(kNumInstructionsToJump, InstructionsGeneratedSince(&find_ra)); -+} -+ -+void TurboAssembler::Ret(Condition cond, Register rj, const Operand& rk) { -+ Jump(ra, cond, rj, rk); -+} -+ -+void TurboAssembler::DropAndRet(int drop) { -+ DCHECK(is_int16(drop * kPointerSize)); -+ addi_d(sp, sp, drop * kPointerSize); -+ Ret(); -+} -+ -+void TurboAssembler::DropAndRet(int drop, Condition cond, Register r1, -+ const Operand& r2) { -+ // Both Drop and Ret need to be conditional. -+ Label skip; -+ if (cond != cc_always) { -+ Branch(&skip, NegateCondition(cond), r1, r2); -+ } -+ -+ Drop(drop); -+ Ret(); -+ -+ if (cond != cc_always) { -+ bind(&skip); -+ } -+} -+ -+void TurboAssembler::Drop(int count, Condition cond, Register reg, -+ const Operand& op) { -+ if (count <= 0) { -+ return; -+ } -+ -+ Label skip; -+ -+ if (cond != al) { -+ Branch(&skip, NegateCondition(cond), reg, op); -+ } -+ -+ Add_d(sp, sp, Operand(count * kPointerSize)); -+ -+ if (cond != al) { -+ bind(&skip); -+ } -+} -+ -+void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) { -+ if (scratch == no_reg) { -+ Xor(reg1, reg1, Operand(reg2)); -+ Xor(reg2, reg2, Operand(reg1)); -+ Xor(reg1, reg1, Operand(reg2)); -+ } else { -+ mov(scratch, reg1); -+ mov(reg1, reg2); -+ mov(reg2, scratch); -+ } -+} -+ -+void TurboAssembler::Call(Label* target) { Branch(target, true); } -+ -+void TurboAssembler::Push(Smi smi) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(smi)); -+ push(scratch); -+} -+ -+void TurboAssembler::Push(Handle handle) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(handle)); -+ push(scratch); -+} -+ -+void TurboAssembler::PushArray(Register array, Register size, Register scratch, -+ Register scratch2, PushArrayOrder order) { -+ DCHECK(!AreAliased(array, size, scratch, scratch2)); -+ Label loop, entry; -+ if (order == PushArrayOrder::kReverse) { -+ mov(scratch, zero_reg); -+ jmp(&entry); -+ bind(&loop); -+ Alsl_d(scratch2, scratch, array, kPointerSizeLog2, t7); -+ Ld_d(scratch2, MemOperand(scratch2, 0)); -+ push(scratch2); -+ Add_d(scratch, scratch, Operand(1)); -+ bind(&entry); -+ Branch(&loop, less, scratch, Operand(size)); -+ } else { -+ mov(scratch, size); -+ jmp(&entry); -+ bind(&loop); -+ Alsl_d(scratch2, scratch, array, kPointerSizeLog2, t7); -+ Ld_d(scratch2, MemOperand(scratch2, 0)); -+ push(scratch2); -+ bind(&entry); -+ Add_d(scratch, scratch, Operand(-1)); -+ Branch(&loop, greater_equal, scratch, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::MaybeDropFrames() { -+ // Check whether we need to drop frames to restart a function on the stack. -+ li(a1, ExternalReference::debug_restart_fp_address(isolate())); -+ Ld_d(a1, MemOperand(a1, 0)); -+ Jump(BUILTIN_CODE(isolate(), FrameDropperTrampoline), RelocInfo::CODE_TARGET, -+ ne, a1, Operand(zero_reg)); -+} -+ -+// --------------------------------------------------------------------------- -+// Exception handling. -+ -+void MacroAssembler::PushStackHandler() { -+ // Adjust this code if not the case. -+ STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize); -+ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); -+ -+ Push(Smi::zero()); // Padding. -+ -+ // Link the current handler as the next handler. -+ li(t2, -+ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); -+ Ld_d(t1, MemOperand(t2, 0)); -+ push(t1); -+ -+ // Set this new handler as the current one. -+ St_d(sp, MemOperand(t2, 0)); -+} -+ -+void MacroAssembler::PopStackHandler() { -+ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); -+ pop(a1); -+ Add_d(sp, sp, -+ Operand( -+ static_cast(StackHandlerConstants::kSize - kPointerSize))); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, -+ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); -+ St_d(a1, MemOperand(scratch, 0)); -+} -+ -+void TurboAssembler::FPUCanonicalizeNaN(const DoubleRegister dst, -+ const DoubleRegister src) { -+ fsub_d(dst, src, kDoubleRegZero); -+} -+ -+void TurboAssembler::MovFromFloatResult(const DoubleRegister dst) { -+ Move(dst, f0); // Reg f0 is loongarch return value -+} -+ -+void TurboAssembler::MovFromFloatParameter(const DoubleRegister dst) { -+ Move(dst, f0); // Reg f0 is loongarch first argument value. -+} -+ -+void TurboAssembler::MovToFloatParameter(DoubleRegister src) { Move(f0, src); } -+ -+void TurboAssembler::MovToFloatResult(DoubleRegister src) { Move(f0, src); } -+ -+void TurboAssembler::MovToFloatParameters(DoubleRegister src1, -+ DoubleRegister src2) { -+ const DoubleRegister fparg2 = f1; -+ if (src2 == f0) { -+ DCHECK(src1 != fparg2); -+ Move(fparg2, src2); -+ Move(f0, src1); -+ } else { -+ Move(f0, src1); -+ Move(fparg2, src2); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// JavaScript invokes. -+ -+void TurboAssembler::PrepareForTailCall(Register callee_args_count, -+ Register caller_args_count, -+ Register scratch0, Register scratch1) { -+ // Calculate the end of destination area where we will put the arguments -+ // after we drop current frame. We add kPointerSize to count the receiver -+ // argument which is not included into formal parameters count. -+ Register dst_reg = scratch0; -+ Alsl_d(dst_reg, caller_args_count, fp, kPointerSizeLog2, t7); -+ Add_d(dst_reg, dst_reg, -+ Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); -+ -+ Register src_reg = caller_args_count; -+ // Calculate the end of source area. +kPointerSize is for the receiver. -+ Alsl_d(src_reg, callee_args_count, sp, kPointerSizeLog2, t7); -+ Add_d(src_reg, src_reg, Operand(kPointerSize)); -+ -+ if (FLAG_debug_code) { -+ Check(lo, AbortReason::kStackAccessBelowStackPointer, src_reg, -+ Operand(dst_reg)); -+ } -+ -+ // Restore caller's frame pointer and return address now as they will be -+ // overwritten by the copying loop. -+ Ld_d(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); -+ Ld_d(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ -+ // Now copy callee arguments to the caller frame going backwards to avoid -+ // callee arguments corruption (source and destination areas could overlap). -+ -+ // Both src_reg and dst_reg are pointing to the word after the one to copy, -+ // so they must be pre-decremented in the loop. -+ Register tmp_reg = scratch1; -+ Label loop, entry; -+ Branch(&entry); -+ bind(&loop); -+ Sub_d(src_reg, src_reg, Operand(kPointerSize)); -+ Sub_d(dst_reg, dst_reg, Operand(kPointerSize)); -+ Ld_d(tmp_reg, MemOperand(src_reg, 0)); -+ St_d(tmp_reg, MemOperand(dst_reg, 0)); -+ bind(&entry); -+ Branch(&loop, ne, sp, Operand(src_reg)); -+ -+ // Leave current frame. -+ mov(sp, dst_reg); -+} -+ -+void MacroAssembler::InvokePrologue(Register expected_parameter_count, -+ Register actual_parameter_count, -+ Label* done, InvokeFlag flag) { -+ Label regular_invoke; -+ -+ // Check whether the expected and actual arguments count match. The registers -+ // are set up according to contract with ArgumentsAdaptorTrampoline: -+ // a0: actual arguments count -+ // a1: function (passed through to callee) -+ // a2: expected arguments count -+ -+ // The code below is made a lot easier because the calling code already sets -+ // up actual and expected registers according to the contract. -+ -+ DCHECK_EQ(actual_parameter_count, a0); -+ DCHECK_EQ(expected_parameter_count, a2); -+ -+ Branch(®ular_invoke, eq, expected_parameter_count, -+ Operand(actual_parameter_count)); -+ -+ Handle adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline); -+ if (flag == CALL_FUNCTION) { -+ Call(adaptor); -+ Branch(done); -+ } else { -+ Jump(adaptor, RelocInfo::CODE_TARGET); -+ } -+ -+ bind(®ular_invoke); -+} -+ -+void MacroAssembler::CheckDebugHook(Register fun, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count) { -+ Label skip_hook; -+ -+ li(t0, ExternalReference::debug_hook_on_function_call_address(isolate())); -+ Ld_b(t0, MemOperand(t0, 0)); -+ Branch(&skip_hook, eq, t0, Operand(zero_reg)); -+ -+ { -+ // Load receiver to pass it later to DebugOnFunctionCall hook. -+ LoadReceiver(t0, actual_parameter_count); -+ -+ FrameScope frame(this, -+ has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); -+ SmiTag(expected_parameter_count); -+ Push(expected_parameter_count); -+ -+ SmiTag(actual_parameter_count); -+ Push(actual_parameter_count); -+ -+ if (new_target.is_valid()) { -+ Push(new_target); -+ } -+ // TODO: MultiPush/Pop -+ Push(fun); -+ Push(fun); -+ Push(t0); -+ CallRuntime(Runtime::kDebugOnFunctionCall); -+ Pop(fun); -+ if (new_target.is_valid()) { -+ Pop(new_target); -+ } -+ -+ Pop(actual_parameter_count); -+ SmiUntag(actual_parameter_count); -+ -+ Pop(expected_parameter_count); -+ SmiUntag(expected_parameter_count); -+ } -+ bind(&skip_hook); -+} -+ -+void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ DCHECK_EQ(function, a1); -+ DCHECK_IMPLIES(new_target.is_valid(), new_target == a3); -+ -+ // On function call, call into the debugger if necessary. -+ CheckDebugHook(function, new_target, expected_parameter_count, -+ actual_parameter_count); -+ -+ // Clear the new.target register if not given. -+ if (!new_target.is_valid()) { -+ LoadRoot(a3, RootIndex::kUndefinedValue); -+ } -+ -+ Label done; -+ InvokePrologue(expected_parameter_count, actual_parameter_count, &done, flag); -+ // We call indirectly through the code field in the function to -+ // allow recompilation to take effect without changing any of the -+ // call sites. -+ Register code = kJavaScriptCallCodeStartRegister; -+ Ld_d(code, FieldMemOperand(function, JSFunction::kCodeOffset)); -+ if (flag == CALL_FUNCTION) { -+ Add_d(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Call(code); -+ } else { -+ DCHECK(flag == JUMP_FUNCTION); -+ Add_d(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Jump(code); -+ } -+ -+ // Continue here if InvokePrologue does handle the invocation due to -+ // mismatched parameter counts. -+ bind(&done); -+} -+ -+void MacroAssembler::InvokeFunctionWithNewTarget( -+ Register function, Register new_target, Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ -+ // Contract with called JS functions requires that function is passed in a1. -+ DCHECK_EQ(function, a1); -+ Register expected_parameter_count = a2; -+ Register temp_reg = t0; -+ Ld_d(temp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ // The argument count is stored as uint16_t -+ Ld_hu(expected_parameter_count, -+ FieldMemOperand(temp_reg, -+ SharedFunctionInfo::kFormalParameterCountOffset)); -+ -+ InvokeFunctionCode(a1, new_target, expected_parameter_count, -+ actual_parameter_count, flag); -+} -+ -+void MacroAssembler::InvokeFunction(Register function, -+ Register expected_parameter_count, -+ Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ -+ // Contract with called JS functions requires that function is passed in a1. -+ DCHECK_EQ(function, a1); -+ -+ // Get the function and setup the context. -+ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ -+ InvokeFunctionCode(a1, no_reg, expected_parameter_count, -+ actual_parameter_count, flag); -+} -+ -+// --------------------------------------------------------------------------- -+// Support functions. -+ -+void MacroAssembler::GetObjectType(Register object, Register map, -+ Register type_reg) { -+ LoadMap(map, object); -+ Ld_hu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); -+} -+ -+// ----------------------------------------------------------------------------- -+// Runtime calls. -+ -+void TurboAssembler::AdddOverflow(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t8; -+ if (!right.is_reg()) { -+ li(t7, Operand(right)); -+ right_reg = t7; -+ } else { -+ right_reg = right.rm(); -+ } -+ -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ -+ if (dst == left || dst == right_reg) { -+ add_d(scratch, left, right_reg); -+ xor_(overflow, scratch, left); -+ xor_(t7, scratch, right_reg); -+ and_(overflow, overflow, t7); -+ mov(dst, scratch); -+ } else { -+ add_d(dst, left, right_reg); -+ xor_(overflow, dst, left); -+ xor_(t7, dst, right_reg); -+ and_(overflow, overflow, t7); -+ } -+} -+ -+void TurboAssembler::SubdOverflow(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t8; -+ if (!right.is_reg()) { -+ li(t7, Operand(right)); -+ right_reg = t7; -+ } else { -+ right_reg = right.rm(); -+ } -+ -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ -+ if (dst == left || dst == right_reg) { -+ Sub_d(scratch, left, right_reg); -+ xor_(overflow, left, scratch); -+ xor_(t7, left, right_reg); -+ and_(overflow, overflow, t7); -+ mov(dst, scratch); -+ } else { -+ sub_d(dst, left, right_reg); -+ xor_(overflow, left, dst); -+ xor_(t7, left, right_reg); -+ and_(overflow, overflow, t7); -+ } -+} -+ -+void TurboAssembler::MulOverflow(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t8; -+ if (!right.is_reg()) { -+ li(t7, Operand(right)); -+ right_reg = t7; -+ } else { -+ right_reg = right.rm(); -+ } -+ -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ -+ if (dst == left || dst == right_reg) { -+ Mul_w(scratch, left, right_reg); -+ Mulh_w(overflow, left, right_reg); -+ mov(dst, scratch); -+ } else { -+ Mul_w(dst, left, right_reg); -+ Mulh_w(overflow, left, right_reg); -+ } -+ -+ srai_d(scratch, dst, 32); -+ xor_(overflow, overflow, scratch); -+} -+ -+void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, -+ SaveFPRegsMode save_doubles) { -+ // All parameters are on the stack. v0 has the return value after call. -+ -+ // If the expected number of arguments of the runtime function is -+ // constant, we check that the actual number of arguments match the -+ // expectation. -+ CHECK(f->nargs < 0 || f->nargs == num_arguments); -+ -+ // TODO(1236192): Most runtime routines don't need the number of -+ // arguments passed in because it is constant. At some point we -+ // should remove this need and make the runtime routine entry code -+ // smarter. -+ PrepareCEntryArgs(num_arguments); -+ PrepareCEntryFunction(ExternalReference::Create(f)); -+ Handle code = -+ CodeFactory::CEntry(isolate(), f->result_size, save_doubles); -+ Call(code, RelocInfo::CODE_TARGET); -+} -+ -+void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { -+ const Runtime::Function* function = Runtime::FunctionForId(fid); -+ DCHECK_EQ(1, function->result_size); -+ if (function->nargs >= 0) { -+ PrepareCEntryArgs(function->nargs); -+ } -+ JumpToExternalReference(ExternalReference::Create(fid)); -+} -+ -+void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, -+ bool builtin_exit_frame) { -+ PrepareCEntryFunction(builtin); -+ Handle code = CodeFactory::CEntry(isolate(), 1, kDontSaveFPRegs, -+ kArgvOnStack, builtin_exit_frame); -+ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg)); -+} -+ -+void MacroAssembler::JumpToInstructionStream(Address entry) { -+ li(kOffHeapTrampolineRegister, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Jump(kOffHeapTrampolineRegister); -+} -+ -+void MacroAssembler::LoadWeakValue(Register out, Register in, -+ Label* target_if_cleared) { -+ Branch(target_if_cleared, eq, in, Operand(kClearedWeakHeapObjectLower32)); -+ -+ And(out, in, Operand(~kWeakHeapObjectMask)); -+} -+ -+void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, -+ Register scratch1, Register scratch2) { -+ DCHECK_GT(value, 0); -+ if (FLAG_native_code_counters && counter->Enabled()) { -+ // This operation has to be exactly 32-bit wide in case the external -+ // reference table redirects the counter to a uint32_t dummy_stats_counter_ -+ // field. -+ li(scratch2, ExternalReference::Create(counter)); -+ Ld_w(scratch1, MemOperand(scratch2, 0)); -+ Add_w(scratch1, scratch1, Operand(value)); -+ St_w(scratch1, MemOperand(scratch2, 0)); -+ } -+} -+ -+void MacroAssembler::DecrementCounter(StatsCounter* counter, int value, -+ Register scratch1, Register scratch2) { -+ DCHECK_GT(value, 0); -+ if (FLAG_native_code_counters && counter->Enabled()) { -+ // This operation has to be exactly 32-bit wide in case the external -+ // reference table redirects the counter to a uint32_t dummy_stats_counter_ -+ // field. -+ li(scratch2, ExternalReference::Create(counter)); -+ Ld_w(scratch1, MemOperand(scratch2, 0)); -+ Sub_w(scratch1, scratch1, Operand(value)); -+ St_w(scratch1, MemOperand(scratch2, 0)); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Debugging. -+ -+void TurboAssembler::Trap() { stop(); } -+void TurboAssembler::DebugBreak() { stop(); } -+ -+void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs, -+ Operand rk) { -+ if (emit_debug_code()) Check(cc, reason, rs, rk); -+} -+ -+void TurboAssembler::Check(Condition cc, AbortReason reason, Register rj, -+ Operand rk) { -+ Label L; -+ Branch(&L, cc, rj, rk); -+ Abort(reason); -+ // Will not return here. -+ bind(&L); -+} -+ -+void TurboAssembler::Abort(AbortReason reason) { -+ Label abort_start; -+ bind(&abort_start); -+#ifdef DEBUG -+ const char* msg = GetAbortReason(reason); -+ RecordComment("Abort message: "); -+ RecordComment(msg); -+#endif -+ -+ // Avoid emitting call to builtin if requested. -+ if (trap_on_abort()) { -+ stop(); -+ return; -+ } -+ -+ if (should_abort_hard()) { -+ // We don't care if we constructed a frame. Just pretend we did. -+ FrameScope assume_frame(this, StackFrame::NONE); -+ PrepareCallCFunction(0, a0); -+ li(a0, Operand(static_cast(reason))); -+ CallCFunction(ExternalReference::abort_with_reason(), 1); -+ return; -+ } -+ -+ Move(a0, Smi::FromInt(static_cast(reason))); -+ -+ // Disable stub call restrictions to always allow calls to abort. -+ if (!has_frame()) { -+ // We don't actually want to generate a pile of code for this, so just -+ // claim there is a stack frame, without generating one. -+ FrameScope scope(this, StackFrame::NONE); -+ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); -+ } else { -+ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); -+ } -+ // Will not return here. -+ if (is_trampoline_pool_blocked()) { -+ // If the calling code cares about the exact number of -+ // instructions generated, we insert padding here to keep the size -+ // of the Abort macro constant. -+ // Currently in debug mode with debug_code enabled the number of -+ // generated instructions is 10, so we use this as a maximum value. -+ static const int kExpectedAbortInstructions = 10; -+ int abort_instructions = InstructionsGeneratedSince(&abort_start); -+ DCHECK_LE(abort_instructions, kExpectedAbortInstructions); -+ while (abort_instructions++ < kExpectedAbortInstructions) { -+ nop(); -+ } -+ } -+} -+ -+void MacroAssembler::LoadMap(Register destination, Register object) { -+ Ld_d(destination, FieldMemOperand(object, HeapObject::kMapOffset)); -+} -+ -+void MacroAssembler::LoadNativeContextSlot(int index, Register dst) { -+ LoadMap(dst, cp); -+ Ld_d(dst, FieldMemOperand( -+ dst, Map::kConstructorOrBackPointerOrNativeContextOffset)); -+ Ld_d(dst, MemOperand(dst, Context::SlotOffset(index))); -+} -+ -+void TurboAssembler::StubPrologue(StackFrame::Type type) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(StackFrame::TypeToMarker(type))); -+ PushCommonFrame(scratch); -+} -+ -+void TurboAssembler::Prologue() { PushStandardFrame(a1); } -+ -+void TurboAssembler::EnterFrame(StackFrame::Type type) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ int stack_offset = -3 * kPointerSize; -+ const int fp_offset = 1 * kPointerSize; -+ addi_d(sp, sp, stack_offset); -+ stack_offset = -stack_offset - kPointerSize; -+ St_d(ra, MemOperand(sp, stack_offset)); -+ stack_offset -= kPointerSize; -+ St_d(fp, MemOperand(sp, stack_offset)); -+ stack_offset -= kPointerSize; -+ li(t7, Operand(StackFrame::TypeToMarker(type))); -+ St_d(t7, MemOperand(sp, stack_offset)); -+ // Adjust FP to point to saved FP. -+ DCHECK_EQ(stack_offset, 0); -+ Add_d(fp, sp, Operand(fp_offset)); -+} -+ -+void TurboAssembler::LeaveFrame(StackFrame::Type type) { -+ addi_d(sp, fp, 2 * kPointerSize); -+ Ld_d(ra, MemOperand(fp, 1 * kPointerSize)); -+ Ld_d(fp, MemOperand(fp, 0 * kPointerSize)); -+} -+ -+void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, -+ StackFrame::Type frame_type) { -+ DCHECK(frame_type == StackFrame::EXIT || -+ frame_type == StackFrame::BUILTIN_EXIT); -+ -+ // Set up the frame structure on the stack. -+ STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); -+ STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); -+ STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); -+ -+ // This is how the stack will look: -+ // fp + 2 (==kCallerSPDisplacement) - old stack's end -+ // [fp + 1 (==kCallerPCOffset)] - saved old ra -+ // [fp + 0 (==kCallerFPOffset)] - saved old fp -+ // [fp - 1 StackFrame::EXIT Smi -+ // [fp - 2 (==kSPOffset)] - sp of the called function -+ // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the -+ // new stack (will contain saved ra) -+ -+ // Save registers and reserve room for saved entry sp. -+ addi_d(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp); -+ St_d(ra, MemOperand(sp, 3 * kPointerSize)); -+ St_d(fp, MemOperand(sp, 2 * kPointerSize)); -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(StackFrame::TypeToMarker(frame_type))); -+ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); -+ } -+ // Set up new frame pointer. -+ addi_d(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp); -+ -+ if (emit_debug_code()) { -+ St_d(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); -+ } -+ -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Save the frame pointer and the context in top. -+ li(t8, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, -+ isolate())); -+ St_d(fp, MemOperand(t8, 0)); -+ li(t8, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ St_d(cp, MemOperand(t8, 0)); -+ } -+ -+ const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); -+ if (save_doubles) { -+ // The stack is already aligned to 0 modulo 8 for stores with sdc1. -+ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; -+ int space = kNumOfSavedRegisters * kDoubleSize; -+ Sub_d(sp, sp, Operand(space)); -+ // Remember: we only need to save every 2nd double FPU value. -+ for (int i = 0; i < kNumOfSavedRegisters; i++) { -+ FPURegister reg = FPURegister::from_code(2 * i); -+ Fst_d(reg, MemOperand(sp, i * kDoubleSize)); -+ } -+ } -+ -+ // Reserve place for the return address, stack space and an optional slot -+ // (used by DirectCEntry to hold the return value if a struct is -+ // returned) and align the frame preparing for calling the runtime function. -+ DCHECK_GE(stack_space, 0); -+ Sub_d(sp, sp, Operand((stack_space + 2) * kPointerSize)); -+ if (frame_alignment > 0) { -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ And(sp, sp, Operand(-frame_alignment)); // Align stack. -+ } -+ -+ // Set the exit frame sp value to point just before the return address -+ // location. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ addi_d(scratch, sp, kPointerSize); -+ St_d(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); -+} -+ -+void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count, -+ bool do_return, -+ bool argument_count_is_length) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Optionally restore all double registers. -+ if (save_doubles) { -+ // Remember: we only need to restore every 2nd double FPU value. -+ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; -+ Sub_d(t8, fp, -+ Operand(ExitFrameConstants::kFixedFrameSizeFromFp + -+ kNumOfSavedRegisters * kDoubleSize)); -+ for (int i = 0; i < kNumOfSavedRegisters; i++) { -+ FPURegister reg = FPURegister::from_code(2 * i); -+ Fld_d(reg, MemOperand(t8, i * kDoubleSize)); -+ } -+ } -+ -+ // Clear top frame. -+ li(t8, -+ ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate())); -+ St_d(zero_reg, MemOperand(t8, 0)); -+ -+ // Restore current context from top and clear it in debug mode. -+ li(t8, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ Ld_d(cp, MemOperand(t8, 0)); -+ -+#ifdef DEBUG -+ li(t8, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ St_d(a3, MemOperand(t8, 0)); -+#endif -+ -+ // Pop the arguments, restore registers, and return. -+ mov(sp, fp); // Respect ABI stack constraint. -+ Ld_d(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); -+ Ld_d(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); -+ -+ if (argument_count.is_valid()) { -+ if (argument_count_is_length) { -+ add_d(sp, sp, argument_count); -+ } else { -+ Alsl_d(sp, argument_count, sp, kPointerSizeLog2, t8); -+ } -+ } -+ -+ addi_d(sp, sp, 2 * kPointerSize); -+ if (do_return) { -+ Ret(); -+ } -+} -+ -+int TurboAssembler::ActivationFrameAlignment() { -+#if V8_HOST_ARCH_LA64 -+ // Running on the real platform. Use the alignment as mandated by the local -+ // environment. -+ // Note: This will break if we ever start generating snapshots on one Mips -+ // platform for another Mips platform with a different alignment. -+ return base::OS::ActivationFrameAlignment(); -+#else // V8_HOST_ARCH_LA64 -+ // If we are using the simulator then we should always align to the expected -+ // alignment. As the simulator is used to generate snapshots we do not know -+ // if the target platform will need alignment, so this is controlled from a -+ // flag. -+ return FLAG_sim_stack_alignment; -+#endif // V8_HOST_ARCH_LA64 -+} -+ -+void MacroAssembler::AssertStackIsAligned() { -+ if (emit_debug_code()) { -+ const int frame_alignment = ActivationFrameAlignment(); -+ const int frame_alignment_mask = frame_alignment - 1; -+ -+ if (frame_alignment > kPointerSize) { -+ Label alignment_as_expected; -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, sp, frame_alignment_mask); -+ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); -+ } -+ // Don't use Check here, as it will call Runtime_Abort re-entering here. -+ stop(); -+ bind(&alignment_as_expected); -+ } -+ } -+} -+ -+void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { -+ if (SmiValuesAre32Bits()) { -+ Ld_w(dst, MemOperand(src.base(), SmiWordOffset(src.offset()))); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ Ld_w(dst, src); -+ SmiUntag(dst); -+ } -+} -+ -+void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, -+ Register scratch) { -+ DCHECK_EQ(0, kSmiTag); -+ andi(scratch, value, kSmiTagMask); -+ Branch(smi_label, eq, scratch, Operand(zero_reg)); -+} -+ -+void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, -+ Register scratch) { -+ DCHECK_EQ(0, kSmiTag); -+ andi(scratch, value, kSmiTagMask); -+ Branch(not_smi_label, ne, scratch, Operand(zero_reg)); -+} -+ -+void MacroAssembler::AssertNotSmi(Register object) { -+ if (emit_debug_code()) { -+ STATIC_ASSERT(kSmiTag == 0); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, object, kSmiTagMask); -+ Check(ne, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertSmi(Register object) { -+ if (emit_debug_code()) { -+ STATIC_ASSERT(kSmiTag == 0); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, object, kSmiTagMask); -+ Check(eq, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertConstructor(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t8); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor, t8, -+ Operand(zero_reg)); -+ -+ LoadMap(t8, object); -+ Ld_bu(t8, FieldMemOperand(t8, Map::kBitFieldOffset)); -+ And(t8, t8, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ Check(ne, AbortReason::kOperandIsNotAConstructor, t8, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertFunction(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t8); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8, -+ Operand(zero_reg)); -+ GetObjectType(object, t8, t8); -+ Check(eq, AbortReason::kOperandIsNotAFunction, t8, -+ Operand(JS_FUNCTION_TYPE)); -+ } -+} -+ -+void MacroAssembler::AssertBoundFunction(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t8); -+ Check(ne, AbortReason::kOperandIsASmiAndNotABoundFunction, t8, -+ Operand(zero_reg)); -+ GetObjectType(object, t8, t8); -+ Check(eq, AbortReason::kOperandIsNotABoundFunction, t8, -+ Operand(JS_BOUND_FUNCTION_TYPE)); -+ } -+} -+ -+void MacroAssembler::AssertGeneratorObject(Register object) { -+ if (!emit_debug_code()) return; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t8); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAGeneratorObject, t8, -+ Operand(zero_reg)); -+ -+ GetObjectType(object, t8, t8); -+ -+ Label done; -+ -+ // Check if JSGeneratorObject -+ Branch(&done, eq, t8, Operand(JS_GENERATOR_OBJECT_TYPE)); -+ -+ // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) -+ Branch(&done, eq, t8, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); -+ -+ // Check if JSAsyncGeneratorObject -+ Branch(&done, eq, t8, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); -+ -+ Abort(AbortReason::kOperandIsNotAGeneratorObject); -+ -+ bind(&done); -+} -+ -+void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, -+ Register scratch) { -+ if (emit_debug_code()) { -+ Label done_checking; -+ AssertNotSmi(object); -+ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ Branch(&done_checking, eq, object, Operand(scratch)); -+ GetObjectType(object, scratch, scratch); -+ Assert(eq, AbortReason::kExpectedUndefinedOrCell, scratch, -+ Operand(ALLOCATION_SITE_TYPE)); -+ bind(&done_checking); -+ } -+} -+ -+void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1, -+ FPURegister src2, Label* out_of_line) { -+ if (src1 == src2) { -+ Move_s(dst, src1); -+ return; -+ } -+ -+ // Check if one of operands is NaN. -+ CompareIsNanF32(src1, src2); -+ BranchTrueF(out_of_line); -+ -+ fmax_s(dst, src1, src2); -+} -+ -+void TurboAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ fadd_s(dst, src1, src2); -+} -+ -+void TurboAssembler::Float32Min(FPURegister dst, FPURegister src1, -+ FPURegister src2, Label* out_of_line) { -+ if (src1 == src2) { -+ Move_s(dst, src1); -+ return; -+ } -+ -+ // Check if one of operands is NaN. -+ CompareIsNanF32(src1, src2); -+ BranchTrueF(out_of_line); -+ -+ fmin_s(dst, src1, src2); -+} -+ -+void TurboAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ fadd_s(dst, src1, src2); -+} -+ -+void TurboAssembler::Float64Max(FPURegister dst, FPURegister src1, -+ FPURegister src2, Label* out_of_line) { -+ if (src1 == src2) { -+ Move_d(dst, src1); -+ return; -+ } -+ -+ // Check if one of operands is NaN. -+ CompareIsNanF64(src1, src2); -+ BranchTrueF(out_of_line); -+ -+ fmax_d(dst, src1, src2); -+} -+ -+void TurboAssembler::Float64MaxOutOfLine(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ fadd_d(dst, src1, src2); -+} -+ -+void TurboAssembler::Float64Min(FPURegister dst, FPURegister src1, -+ FPURegister src2, Label* out_of_line) { -+ if (src1 == src2) { -+ Move_d(dst, src1); -+ return; -+ } -+ -+ // Check if one of operands is NaN. -+ CompareIsNanF64(src1, src2); -+ BranchTrueF(out_of_line); -+ -+ fmin_d(dst, src1, src2); -+} -+ -+void TurboAssembler::Float64MinOutOfLine(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ fadd_d(dst, src1, src2); -+} -+ -+static const int kRegisterPassedArguments = 8; -+ -+int TurboAssembler::CalculateStackPassedWords(int num_reg_arguments, -+ int num_double_arguments) { -+ int stack_passed_words = 0; -+ num_reg_arguments += 2 * num_double_arguments; -+ -+ // O32: Up to four simple arguments are passed in registers a0..a3. -+ // N64: Up to eight simple arguments are passed in registers a0..a7. -+ if (num_reg_arguments > kRegisterPassedArguments) { -+ stack_passed_words += num_reg_arguments - kRegisterPassedArguments; -+ } -+ stack_passed_words += kCArgSlotCount; -+ return stack_passed_words; -+} -+ -+void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, -+ int num_double_arguments, -+ Register scratch) { -+ int frame_alignment = ActivationFrameAlignment(); -+ -+ // n64: Up to eight simple arguments in a0..a3, a4..a7, No argument slots. -+ // O32: Up to four simple arguments are passed in registers a0..a3. -+ // Those four arguments must have reserved argument slots on the stack for -+ // mips, even though those argument slots are not normally used. -+ // Both ABIs: Remaining arguments are pushed on the stack, above (higher -+ // address than) the (O32) argument slots. (arg slot calculation handled by -+ // CalculateStackPassedWords()). -+ int stack_passed_arguments = -+ CalculateStackPassedWords(num_reg_arguments, num_double_arguments); -+ if (frame_alignment > kPointerSize) { -+ // Make stack end at alignment and make room for num_arguments - 4 words -+ // and the original value of sp. -+ mov(scratch, sp); -+ Sub_d(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ bstrins_d(sp, zero_reg, std::log2(frame_alignment) - 1, 0); -+ St_d(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); -+ } else { -+ Sub_d(sp, sp, Operand(stack_passed_arguments * kPointerSize)); -+ } -+} -+ -+void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, -+ Register scratch) { -+ PrepareCallCFunction(num_reg_arguments, 0, scratch); -+} -+ -+void TurboAssembler::CallCFunction(ExternalReference function, -+ int num_reg_arguments, -+ int num_double_arguments) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t7, function); -+ CallCFunctionHelper(t7, num_reg_arguments, num_double_arguments); -+} -+ -+void TurboAssembler::CallCFunction(Register function, int num_reg_arguments, -+ int num_double_arguments) { -+ CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); -+} -+ -+void TurboAssembler::CallCFunction(ExternalReference function, -+ int num_arguments) { -+ CallCFunction(function, num_arguments, 0); -+} -+ -+void TurboAssembler::CallCFunction(Register function, int num_arguments) { -+ CallCFunction(function, num_arguments, 0); -+} -+ -+void TurboAssembler::CallCFunctionHelper(Register function, -+ int num_reg_arguments, -+ int num_double_arguments) { -+ DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); -+ DCHECK(has_frame()); -+ // Make sure that the stack is aligned before calling a C function unless -+ // running in the simulator. The simulator has its own alignment check which -+ // provides more information. -+ // The argument stots are presumed to have been set up by -+ // PrepareCallCFunction. The C function must be called via t9, for mips ABI. -+ -+#if V8_HOST_ARCH_LA64 -+ if (emit_debug_code()) { -+ int frame_alignment = base::OS::ActivationFrameAlignment(); -+ int frame_alignment_mask = frame_alignment - 1; -+ if (frame_alignment > kPointerSize) { -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ Label alignment_as_expected; -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ And(scratch, sp, Operand(frame_alignment_mask)); -+ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); -+ } -+ // Don't use Check here, as it will call Runtime_Abort possibly -+ // re-entering here. -+ stop(); -+ bind(&alignment_as_expected); -+ } -+ } -+#endif // V8_HOST_ARCH_LA64 -+ -+ // Just call directly. The function called cannot cause a GC, or -+ // allow preemption, so the return address in the link register -+ // stays correct. -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (function != t7) { -+ mov(t7, function); -+ function = t7; -+ } -+ -+ // Save the frame pointer and PC so that the stack layout remains iterable, -+ // even without an ExitFrame which normally exists between JS and C frames. -+ // 't' registers are caller-saved so this is safe as a scratch register. -+ Register pc_scratch = t1; -+ Register scratch = t2; -+ DCHECK(!AreAliased(pc_scratch, scratch, function)); -+ -+ pcaddi(pc_scratch, 1); -+ -+ // See x64 code for reasoning about how to address the isolate data fields. -+ if (root_array_available()) { -+ St_d(pc_scratch, MemOperand(kRootRegister, -+ IsolateData::fast_c_call_caller_pc_offset())); -+ St_d(fp, MemOperand(kRootRegister, -+ IsolateData::fast_c_call_caller_fp_offset())); -+ } else { -+ DCHECK_NOT_NULL(isolate()); -+ li(scratch, ExternalReference::fast_c_call_caller_pc_address(isolate())); -+ St_d(pc_scratch, MemOperand(scratch, 0)); -+ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); -+ St_d(fp, MemOperand(scratch, 0)); -+ } -+ -+ Call(function); -+ -+ // We don't unset the PC; the FP is the source of truth. -+ if (root_array_available()) { -+ St_d(zero_reg, MemOperand(kRootRegister, -+ IsolateData::fast_c_call_caller_fp_offset())); -+ } else { -+ DCHECK_NOT_NULL(isolate()); -+ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); -+ St_d(zero_reg, MemOperand(scratch, 0)); -+ } -+ } -+ -+ int stack_passed_arguments = -+ CalculateStackPassedWords(num_reg_arguments, num_double_arguments); -+ -+ if (base::OS::ActivationFrameAlignment() > kPointerSize) { -+ Ld_d(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); -+ } else { -+ Add_d(sp, sp, Operand(stack_passed_arguments * kPointerSize)); -+ } -+} -+ -+#undef BRANCH_ARGS_CHECK -+ -+void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask, -+ Condition cc, Label* condition_met) { -+ And(scratch, object, Operand(~kPageAlignmentMask)); -+ Ld_d(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); -+ And(scratch, scratch, Operand(mask)); -+ Branch(condition_met, cc, scratch, Operand(zero_reg)); -+} -+ -+Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, -+ Register reg4, Register reg5, -+ Register reg6) { -+ RegList regs = 0; -+ if (reg1.is_valid()) regs |= reg1.bit(); -+ if (reg2.is_valid()) regs |= reg2.bit(); -+ if (reg3.is_valid()) regs |= reg3.bit(); -+ if (reg4.is_valid()) regs |= reg4.bit(); -+ if (reg5.is_valid()) regs |= reg5.bit(); -+ if (reg6.is_valid()) regs |= reg6.bit(); -+ -+ const RegisterConfiguration* config = RegisterConfiguration::Default(); -+ for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { -+ int code = config->GetAllocatableGeneralCode(i); -+ Register candidate = Register::from_code(code); -+ if (regs & candidate.bit()) continue; -+ return candidate; -+ } -+ UNREACHABLE(); -+} -+ -+void TurboAssembler::ComputeCodeStartAddress(Register dst) { -+ // TODO: range check, add Pcadd macro function? -+ pcaddi(dst, -pc_offset() >> 2); -+} -+ -+void TurboAssembler::ResetSpeculationPoisonRegister() { -+ li(kSpeculationPoisonRegister, -1); -+} -+ -+void TurboAssembler::CallForDeoptimization(Address target, int deopt_id, -+ Label* exit, DeoptimizeKind kind) { -+ USE(exit, kind); -+ NoRootArrayScope no_root_array(this); -+ -+ // Save the deopt id in kRootRegister (we don't need the roots array from now -+ // on). -+ DCHECK_LE(deopt_id, 0xFFFF); -+ li(kRootRegister, deopt_id); -+ Call(target, RelocInfo::RUNTIME_ENTRY); -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.h b/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.h -new file mode 100644 -index 000000000..5089d280b ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.h -@@ -0,0 +1,1110 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef INCLUDED_FROM_MACRO_ASSEMBLER_H -+#error This header must be included via macro-assembler.h -+#endif -+ -+#ifndef V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ -+#define V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/loongarch64/assembler-loongarch64.h" -+#include "src/common/globals.h" -+ -+namespace v8 { -+namespace internal { -+ -+// Forward declarations. -+enum class AbortReason : uint8_t; -+ -+// Reserved Register Usage Summary. -+// -+// Registers t8 and t7 are reserved for use by the MacroAssembler. -+// -+// The programmer should know that the MacroAssembler may clobber these two, -+// but won't touch other registers except in special cases. -+// -+// Per the MIPS ABI, register t0 -- t8 must be used for indirect function call -+// via 'jirl t[0-8]' instructions. gcc? -+ -+// Flags used for LeaveExitFrame function. -+enum LeaveExitFrameMode { EMIT_RETURN = true, NO_EMIT_RETURN = false }; -+ -+// Flags used for the li macro-assembler function. -+enum LiFlags { -+ // If the constant value can be represented in just 12 bits, then -+ // optimize the li to use a single instruction, rather than lu12i_w/lu32i_d/ -+ // lu52i_d/ori sequence. A number of other optimizations that emits less than -+ // maximum number of instructions exists. -+ OPTIMIZE_SIZE = 0, -+ // Always use 4 instructions (lu12i_w/ori/lu32i_d/lu52i_d sequence), -+ // even if the constant could be loaded with just one, so that this value is -+ // patchable later. -+ CONSTANT_SIZE = 1, -+ // For address loads only 3 instruction are required. Used to mark -+ // constant load that will be used as address without relocation -+ // information. It ensures predictable code size, so specific sites -+ // in code are patchable. -+ ADDRESS_LOAD = 2 -+}; -+ -+enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; -+enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; -+enum RAStatus { kRAHasNotBeenSaved, kRAHasBeenSaved }; -+ -+Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg, -+ Register reg3 = no_reg, -+ Register reg4 = no_reg, -+ Register reg5 = no_reg, -+ Register reg6 = no_reg); -+ -+// ----------------------------------------------------------------------------- -+// Static helper functions. -+ -+#define SmiWordOffset(offset) (offset + kPointerSize / 2) -+ -+// Generate a MemOperand for loading a field from an object. -+inline MemOperand FieldMemOperand(Register object, int offset) { -+ return MemOperand(object, offset - kHeapObjectTag); -+} -+ -+class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { -+ public: -+ using TurboAssemblerBase::TurboAssemblerBase; -+ -+ // Activation support. -+ void EnterFrame(StackFrame::Type type); -+ void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) { -+ // Out-of-line constant pool not implemented on la64. -+ UNREACHABLE(); -+ } -+ void LeaveFrame(StackFrame::Type type); -+ -+ // Generates function and stub prologue code. -+ void StubPrologue(StackFrame::Type type); -+ void Prologue(); -+ -+ void InitializeRootRegister() { -+ ExternalReference isolate_root = ExternalReference::isolate_root(isolate()); -+ li(kRootRegister, Operand(isolate_root)); -+ } -+ -+ // Jump unconditionally to given label. -+ // Use rather b(Label) for code generation. -+ void jmp(Label* L) { Branch(L); } -+ -+ // ------------------------------------------------------------------------- -+ // Debugging. -+ -+ void Trap() override; -+ void DebugBreak() override; -+ -+ // Calls Abort(msg) if the condition cc is not satisfied. -+ // Use --debug_code to enable. -+ void Assert(Condition cc, AbortReason reason, Register rj, Operand rk); -+ -+ // Like Assert(), but always enabled. -+ void Check(Condition cc, AbortReason reason, Register rj, Operand rk); -+ -+ // Print a message to stdout and abort execution. -+ void Abort(AbortReason msg); -+ -+ void Branch(Label* label, bool need_link = false); -+ void Branch(Label* label, Condition cond, Register r1, const Operand& r2, -+ bool need_link = false); -+ void BranchShort(Label* label, Condition cond, Register r1, const Operand& r2, -+ bool need_link = false); -+ void Branch(Label* L, Condition cond, Register rj, RootIndex index); -+ -+ // Floating point branches -+ void CompareF32(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, -+ CFRegister cd = FCC0) { -+ CompareF(cmp1, cmp2, cc, cd, true); -+ } -+ -+ void CompareIsNanF32(FPURegister cmp1, FPURegister cmp2, -+ CFRegister cd = FCC0) { -+ CompareIsNanF(cmp1, cmp2, cd, true); -+ } -+ -+ void CompareF64(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, -+ CFRegister cd = FCC0) { -+ CompareF(cmp1, cmp2, cc, cd, false); -+ } -+ -+ void CompareIsNanF64(FPURegister cmp1, FPURegister cmp2, -+ CFRegister cd = FCC0) { -+ CompareIsNanF(cmp1, cmp2, cd, false); -+ } -+ -+ void BranchTrueShortF(Label* target, CFRegister cc = FCC0); -+ void BranchFalseShortF(Label* target, CFRegister cc = FCC0); -+ -+ void BranchTrueF(Label* target, CFRegister cc = FCC0); -+ void BranchFalseF(Label* target, CFRegister cc = FCC0); -+ -+ static int InstrCountForLi64Bit(int64_t value); -+ inline void LiLower32BitHelper(Register rd, Operand j); -+ void li_optimized(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); -+ void li(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); -+ inline void li(Register rd, int64_t j, LiFlags mode = OPTIMIZE_SIZE) { -+ li(rd, Operand(j), mode); -+ } -+ inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) { -+ li(rd, Operand(static_cast(j)), mode); -+ } -+ void li(Register dst, Handle value, LiFlags mode = OPTIMIZE_SIZE); -+ void li(Register dst, ExternalReference value, LiFlags mode = OPTIMIZE_SIZE); -+ void li(Register dst, const StringConstantBase* string, -+ LiFlags mode = OPTIMIZE_SIZE); -+ -+ void LoadFromConstantsTable(Register destination, -+ int constant_index) override; -+ void LoadRootRegisterOffset(Register destination, intptr_t offset) override; -+ void LoadRootRelative(Register destination, int32_t offset) override; -+ -+// Jump, Call, and Ret pseudo instructions implementing inter-working. -+#define COND_ARGS \ -+ Condition cond = al, Register rj = zero_reg, \ -+ const Operand &rk = Operand(zero_reg) -+ -+ void Jump(Register target, COND_ARGS); -+ void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS); -+ void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS); -+ // Deffer from li, this method save target to the memory, and then load -+ // it to register use ld_d, it can be used in wasm jump table for concurrent -+ // patching. -+ void PatchAndJump(Address target); -+ void Jump(Handle code, RelocInfo::Mode rmode, COND_ARGS); -+ void Jump(const ExternalReference& reference) override; -+ void Call(Register target, COND_ARGS); -+ void Call(Address target, RelocInfo::Mode rmode, COND_ARGS); -+ void Call(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, -+ COND_ARGS); -+ void Call(Label* target); -+ void LoadAddress(Register dst, Label* target); -+ -+ // Load the builtin given by the Smi in |builtin_index| into the same -+ // register. -+ void LoadEntryFromBuiltinIndex(Register builtin_index); -+ void CallBuiltinByIndex(Register builtin_index) override; -+ -+ void LoadCodeObjectEntry(Register destination, -+ Register code_object) override { -+ // TODO(mips): Implement. -+ UNIMPLEMENTED(); -+ } -+ void CallCodeObject(Register code_object) override { -+ // TODO(mips): Implement. -+ UNIMPLEMENTED(); -+ } -+ void JumpCodeObject(Register code_object) override { -+ // TODO(mips): Implement. -+ UNIMPLEMENTED(); -+ } -+ -+ // Generates an instruction sequence s.t. the return address points to the -+ // instruction following the call. -+ // The return address on the stack is used by frame iteration. -+ void StoreReturnAddressAndCall(Register target); -+ -+ void CallForDeoptimization(Address target, int deopt_id, Label* exit, -+ DeoptimizeKind kind); -+ -+ void Ret(COND_ARGS); -+ -+ // Emit code to discard a non-negative number of pointer-sized elements -+ // from the stack, clobbering only the sp register. -+ void Drop(int count, Condition cond = cc_always, Register reg = no_reg, -+ const Operand& op = Operand(no_reg)); -+ -+ // Trivial case of DropAndRet that utilizes the delay slot and only emits -+ // 2 instructions. -+ void DropAndRet(int drop); -+ -+ void DropAndRet(int drop, Condition cond, Register reg, const Operand& op); -+ -+ void Ld_d(Register rd, const MemOperand& rj); -+ void St_d(Register rd, const MemOperand& rj); -+ -+ void push(Register src) { -+ Add_d(sp, sp, Operand(-kPointerSize)); -+ St_d(src, MemOperand(sp, 0)); -+ } -+ void Push(Register src) { push(src); } -+ void Push(Handle handle); -+ void Push(Smi smi); -+ -+ // Push two registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2) { -+ Sub_d(sp, sp, Operand(2 * kPointerSize)); -+ St_d(src1, MemOperand(sp, 1 * kPointerSize)); -+ St_d(src2, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push three registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3) { -+ Sub_d(sp, sp, Operand(3 * kPointerSize)); -+ St_d(src1, MemOperand(sp, 2 * kPointerSize)); -+ St_d(src2, MemOperand(sp, 1 * kPointerSize)); -+ St_d(src3, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push four registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3, Register src4) { -+ Sub_d(sp, sp, Operand(4 * kPointerSize)); -+ St_d(src1, MemOperand(sp, 3 * kPointerSize)); -+ St_d(src2, MemOperand(sp, 2 * kPointerSize)); -+ St_d(src3, MemOperand(sp, 1 * kPointerSize)); -+ St_d(src4, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push five registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3, Register src4, -+ Register src5) { -+ Sub_d(sp, sp, Operand(5 * kPointerSize)); -+ St_d(src1, MemOperand(sp, 4 * kPointerSize)); -+ St_d(src2, MemOperand(sp, 3 * kPointerSize)); -+ St_d(src3, MemOperand(sp, 2 * kPointerSize)); -+ St_d(src4, MemOperand(sp, 1 * kPointerSize)); -+ St_d(src5, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ void Push(Register src, Condition cond, Register tst1, Register tst2) { -+ // Since we don't have conditional execution we use a Branch. -+ Label skip; -+ Branch(&skip, cond, tst1, Operand(tst2)); -+ addi_d(sp, sp, -kPointerSize); -+ st_d(src, sp, 0); -+ bind(&skip); -+ } -+ -+ enum PushArrayOrder { kNormal, kReverse }; -+ void PushArray(Register array, Register size, Register scratch, -+ Register scratch2, PushArrayOrder order = kNormal); -+ -+ void SaveRegisters(RegList registers); -+ void RestoreRegisters(RegList registers); -+ -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode); -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode, Address wasm_target); -+ void CallEphemeronKeyBarrier(Register object, Register address, -+ SaveFPRegsMode fp_mode); -+ -+ // Push multiple registers on the stack. -+ // Registers are saved in numerical order, with higher numbered registers -+ // saved in higher memory addresses. -+ void MultiPush(RegList regs); -+ void MultiPush(RegList regs1, RegList regs2); -+ void MultiPush(RegList regs1, RegList regs2, RegList regs3); -+ void MultiPushFPU(RegList regs); -+ -+ // Calculate how much stack space (in bytes) are required to store caller -+ // registers excluding those specified in the arguments. -+ int RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, -+ Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg) const; -+ -+ // Push caller saved registers on the stack, and return the number of bytes -+ // stack pointer is adjusted. -+ int PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg); -+ // Restore caller saved registers from the stack, and return the number of -+ // bytes stack pointer is adjusted. -+ int PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg); -+ -+ void pop(Register dst) { -+ Ld_d(dst, MemOperand(sp, 0)); -+ Add_d(sp, sp, Operand(kPointerSize)); -+ } -+ void Pop(Register dst) { pop(dst); } -+ -+ // Pop two registers. Pops rightmost register first (from lower address). -+ void Pop(Register src1, Register src2) { -+ DCHECK(src1 != src2); -+ Ld_d(src2, MemOperand(sp, 0 * kPointerSize)); -+ Ld_d(src1, MemOperand(sp, 1 * kPointerSize)); -+ Add_d(sp, sp, 2 * kPointerSize); -+ } -+ -+ // Pop three registers. Pops rightmost register first (from lower address). -+ void Pop(Register src1, Register src2, Register src3) { -+ Ld_d(src3, MemOperand(sp, 0 * kPointerSize)); -+ Ld_d(src2, MemOperand(sp, 1 * kPointerSize)); -+ Ld_d(src1, MemOperand(sp, 2 * kPointerSize)); -+ Add_d(sp, sp, 3 * kPointerSize); -+ } -+ -+ void Pop(uint32_t count = 1) { Add_d(sp, sp, Operand(count * kPointerSize)); } -+ -+ // Pops multiple values from the stack and load them in the -+ // registers specified in regs. Pop order is the opposite as in MultiPush. -+ void MultiPop(RegList regs); -+ void MultiPop(RegList regs1, RegList regs2); -+ void MultiPop(RegList regs1, RegList regs2, RegList regs3); -+ -+ void MultiPopFPU(RegList regs); -+ -+#define DEFINE_INSTRUCTION(instr) \ -+ void instr(Register rd, Register rj, const Operand& rk); \ -+ void instr(Register rd, Register rj, Register rk) { \ -+ instr(rd, rj, Operand(rk)); \ -+ } \ -+ void instr(Register rj, Register rk, int32_t j) { instr(rj, rk, Operand(j)); } -+ -+#define DEFINE_INSTRUCTION2(instr) \ -+ void instr(Register rj, const Operand& rk); \ -+ void instr(Register rj, Register rk) { instr(rj, Operand(rk)); } \ -+ void instr(Register rj, int32_t j) { instr(rj, Operand(j)); } -+ -+ DEFINE_INSTRUCTION(Add_w) -+ DEFINE_INSTRUCTION(Add_d) -+ DEFINE_INSTRUCTION(Div_w) -+ DEFINE_INSTRUCTION(Div_wu) -+ DEFINE_INSTRUCTION(Div_du) -+ DEFINE_INSTRUCTION(Mod_w) -+ DEFINE_INSTRUCTION(Mod_wu) -+ DEFINE_INSTRUCTION(Div_d) -+ DEFINE_INSTRUCTION(Sub_w) -+ DEFINE_INSTRUCTION(Sub_d) -+ DEFINE_INSTRUCTION(Mod_d) -+ DEFINE_INSTRUCTION(Mod_du) -+ DEFINE_INSTRUCTION(Mul_w) -+ DEFINE_INSTRUCTION(Mulh_w) -+ DEFINE_INSTRUCTION(Mulh_wu) -+ DEFINE_INSTRUCTION(Mul_d) -+ DEFINE_INSTRUCTION(Mulh_d) -+ DEFINE_INSTRUCTION2(Div_w) -+ DEFINE_INSTRUCTION2(Div_d) -+ DEFINE_INSTRUCTION2(Div_wu) -+ DEFINE_INSTRUCTION2(Div_du) -+ -+ DEFINE_INSTRUCTION(And) -+ DEFINE_INSTRUCTION(Or) -+ DEFINE_INSTRUCTION(Xor) -+ DEFINE_INSTRUCTION(Nor) -+ DEFINE_INSTRUCTION2(Neg) -+ DEFINE_INSTRUCTION(Andn) -+ DEFINE_INSTRUCTION(Orn) -+ -+ DEFINE_INSTRUCTION(Slt) -+ DEFINE_INSTRUCTION(Sltu) -+ DEFINE_INSTRUCTION(Slti) -+ DEFINE_INSTRUCTION(Sltiu) -+ DEFINE_INSTRUCTION(Sle) -+ DEFINE_INSTRUCTION(Sleu) -+ DEFINE_INSTRUCTION(Sgt) -+ DEFINE_INSTRUCTION(Sgtu) -+ DEFINE_INSTRUCTION(Sge) -+ DEFINE_INSTRUCTION(Sgeu) -+ -+ DEFINE_INSTRUCTION(Rotr_w) -+ DEFINE_INSTRUCTION(Rotr_d) -+ -+#undef DEFINE_INSTRUCTION -+#undef DEFINE_INSTRUCTION2 -+#undef DEFINE_INSTRUCTION3 -+ -+ void SmiUntag(Register dst, const MemOperand& src); -+ void SmiUntag(Register dst, Register src) { -+ if (SmiValuesAre32Bits()) { -+ srai_d(dst, src, kSmiShift); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ srai_w(dst, src, kSmiShift); -+ } -+ } -+ -+ void SmiUntag(Register reg) { SmiUntag(reg, reg); } -+ -+ // Removes current frame and its arguments from the stack preserving -+ // the arguments and a return address pushed to the stack for the next call. -+ // Both |callee_args_count| and |caller_args_count| do not include -+ // receiver. |callee_args_count| is not modified. |caller_args_count| -+ // is trashed. -+ void PrepareForTailCall(Register callee_args_count, -+ Register caller_args_count, Register scratch0, -+ Register scratch1); -+ -+ int CalculateStackPassedWords(int num_reg_arguments, -+ int num_double_arguments); -+ -+ // Before calling a C-function from generated code, align arguments on stack -+ // and add space for the four mips argument slots. -+ // After aligning the frame, non-register arguments must be stored on the -+ // stack, after the argument-slots using helper: CFunctionArgumentOperand(). -+ // The argument count assumes all arguments are word sized. -+ // Some compilers/platforms require the stack to be aligned when calling -+ // C++ code. -+ // Needs a scratch register to do some arithmetic. This register will be -+ // trashed. -+ void PrepareCallCFunction(int num_reg_arguments, int num_double_registers, -+ Register scratch); -+ void PrepareCallCFunction(int num_reg_arguments, Register scratch); -+ -+ // Calls a C function and cleans up the space for arguments allocated -+ // by PrepareCallCFunction. The called function is not allowed to trigger a -+ // garbage collection, since that might move the code and invalidate the -+ // return address (unless this is somehow accounted for by the called -+ // function). -+ void CallCFunction(ExternalReference function, int num_arguments); -+ void CallCFunction(Register function, int num_arguments); -+ void CallCFunction(ExternalReference function, int num_reg_arguments, -+ int num_double_arguments); -+ void CallCFunction(Register function, int num_reg_arguments, -+ int num_double_arguments); -+ void MovFromFloatResult(DoubleRegister dst); -+ void MovFromFloatParameter(DoubleRegister dst); -+ -+ // There are two ways of passing double arguments on MIPS, depending on -+ // whether soft or hard floating point ABI is used. These functions -+ // abstract parameter passing for the three different ways we call -+ // C functions from generated code. -+ void MovToFloatParameter(DoubleRegister src); -+ void MovToFloatParameters(DoubleRegister src1, DoubleRegister src2); -+ void MovToFloatResult(DoubleRegister src); -+ -+ // See comments at the beginning of Builtins::Generate_CEntry. -+ inline void PrepareCEntryArgs(int num_args) { li(a0, num_args); } -+ inline void PrepareCEntryFunction(const ExternalReference& ref) { -+ li(a1, ref); -+ } -+ -+ void CheckPageFlag(Register object, Register scratch, int mask, Condition cc, -+ Label* condition_met); -+#undef COND_ARGS -+ -+ // Performs a truncating conversion of a floating point number as used by -+ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. -+ // Exits with 'result' holding the answer. -+ void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result, -+ DoubleRegister double_input, StubCallMode stub_mode); -+ -+ // Conditional move. -+ void Movz(Register rd, Register rj, Register rk); -+ void Movn(Register rd, Register rj, Register rk); -+ -+ void LoadZeroIfFPUCondition(Register dest, CFRegister = FCC0); -+ void LoadZeroIfNotFPUCondition(Register dest, CFRegister = FCC0); -+ -+ void LoadZeroIfConditionNotZero(Register dest, Register condition); -+ void LoadZeroIfConditionZero(Register dest, Register condition); -+ void LoadZeroOnCondition(Register rd, Register rj, const Operand& rk, -+ Condition cond); -+ -+ void Clz_w(Register rd, Register rj); -+ void Clz_d(Register rd, Register rj); -+ void Ctz_w(Register rd, Register rj); -+ void Ctz_d(Register rd, Register rj); -+ void Popcnt_w(Register rd, Register rj); -+ void Popcnt_d(Register rd, Register rj); -+ -+ void ExtractBits(Register dest, Register source, Register pos, int size, -+ bool sign_extend = false); -+ void InsertBits(Register dest, Register source, Register pos, int size); -+ -+ void Bstrins_w(Register rk, Register rj, uint16_t msbw, uint16_t lswb); -+ void Bstrins_d(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); -+ void Bstrpick_w(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); -+ void Bstrpick_d(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); -+ void Neg_s(FPURegister fd, FPURegister fj); -+ void Neg_d(FPURegister fd, FPURegister fk); -+ -+ // Convert single to unsigned word. -+ void Trunc_uw_s(FPURegister fd, FPURegister fj, FPURegister scratch); -+ void Trunc_uw_s(Register rd, FPURegister fj, FPURegister scratch); -+ -+ // Change endianness -+ void ByteSwapSigned(Register dest, Register src, int operand_size); -+ void ByteSwapUnsigned(Register dest, Register src, int operand_size); -+ -+ void Ld_b(Register rd, const MemOperand& rj); -+ void Ld_bu(Register rd, const MemOperand& rj); -+ void St_b(Register rd, const MemOperand& rj); -+ -+ void Ld_h(Register rd, const MemOperand& rj); -+ void Ld_hu(Register rd, const MemOperand& rj); -+ void St_h(Register rd, const MemOperand& rj); -+ -+ void Ld_w(Register rd, const MemOperand& rj); -+ void Ld_wu(Register rd, const MemOperand& rj); -+ void St_w(Register rd, const MemOperand& rj); -+ -+ void Fld_s(FPURegister fd, const MemOperand& src); -+ void Fst_s(FPURegister fj, const MemOperand& dst); -+ -+ void Fld_d(FPURegister fd, const MemOperand& src); -+ void Fst_d(FPURegister fj, const MemOperand& dst); -+ -+ void Ll_w(Register rd, const MemOperand& rj); -+ void Sc_w(Register rd, const MemOperand& rj); -+ -+ void Ll_d(Register rd, const MemOperand& rj); -+ void Sc_d(Register rd, const MemOperand& rj); -+ -+ // These functions assume (and assert) that src1!=src2. It is permitted -+ // for the result to alias either input register. -+ void Float32Max(FPURegister dst, FPURegister src1, FPURegister src2, -+ Label* out_of_line); -+ void Float32Min(FPURegister dst, FPURegister src1, FPURegister src2, -+ Label* out_of_line); -+ void Float64Max(FPURegister dst, FPURegister src1, FPURegister src2, -+ Label* out_of_line); -+ void Float64Min(FPURegister dst, FPURegister src1, FPURegister src2, -+ Label* out_of_line); -+ -+ // Generate out-of-line cases for the macros above. -+ void Float32MaxOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float32MinOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float64MaxOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float64MinOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); -+ -+ bool IsDoubleZeroRegSet() { return has_double_zero_reg_set_; } -+ -+ void mov(Register rd, Register rj) { or_(rd, rj, zero_reg); } -+ -+ inline void Move(Register dst, Handle handle) { li(dst, handle); } -+ inline void Move(Register dst, Smi smi) { li(dst, Operand(smi)); } -+ -+ inline void Move(Register dst, Register src) { -+ if (dst != src) { -+ mov(dst, src); -+ } -+ } -+ -+ inline void FmoveLow(Register dst_low, FPURegister src) { -+ movfr2gr_s(dst_low, src); -+ } -+ -+ void FmoveLow(FPURegister dst, Register src_low); -+ -+ inline void Move(FPURegister dst, FPURegister src) { Move_d(dst, src); } -+ -+ inline void Move_d(FPURegister dst, FPURegister src) { -+ if (dst != src) { -+ fmov_d(dst, src); -+ } -+ } -+ -+ inline void Move_s(FPURegister dst, FPURegister src) { -+ if (dst != src) { -+ fmov_s(dst, src); -+ } -+ } -+ -+ void Move(FPURegister dst, float imm) { Move(dst, bit_cast(imm)); } -+ void Move(FPURegister dst, double imm) { Move(dst, bit_cast(imm)); } -+ void Move(FPURegister dst, uint32_t src); -+ void Move(FPURegister dst, uint64_t src); -+ -+ // AdddOverflow sets overflow register to a negative value if -+ // overflow occured, otherwise it is zero or positive -+ void AdddOverflow(Register dst, Register left, const Operand& right, -+ Register overflow); -+ // SubdOverflow sets overflow register to a negative value if -+ // overflow occured, otherwise it is zero or positive -+ void SubdOverflow(Register dst, Register left, const Operand& right, -+ Register overflow); -+ // MulOverflow sets overflow register to zero if no overflow occured -+ void MulOverflow(Register dst, Register left, const Operand& right, -+ Register overflow); -+ -+ // Number of instructions needed for calculation of switch table entry address -+ static const int kSwitchTablePrologueSize = 5; -+ -+ // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a -+ // functor/function with 'Label *func(size_t index)' declaration. -+ template -+ void GenerateSwitchTable(Register index, size_t case_count, -+ Func GetLabelFunction); -+ -+ // Load an object from the root table. -+ void LoadRoot(Register destination, RootIndex index) override; -+ void LoadRoot(Register destination, RootIndex index, Condition cond, -+ Register src1, const Operand& src2); -+ -+ // If the value is a NaN, canonicalize the value, src must be nan. -+ void FPUCanonicalizeNaN(const DoubleRegister dst, const DoubleRegister src); -+ -+ // --------------------------------------------------------------------------- -+ // FPU macros. These do not handle special cases like NaN or +- inf. -+ -+ // Convert unsigned word to double. -+ void Ffint_d_uw(FPURegister fd, FPURegister fj); -+ void Ffint_d_uw(FPURegister fd, Register rj); -+ -+ // Convert unsigned long to double. -+ void Ffint_d_ul(FPURegister fd, FPURegister fj); -+ void Ffint_d_ul(FPURegister fd, Register rj); -+ -+ // Convert unsigned word to float. -+ void Ffint_s_uw(FPURegister fd, FPURegister fj); -+ void Ffint_s_uw(FPURegister fd, Register rj); -+ -+ // Convert unsigned long to float. -+ void Ffint_s_ul(FPURegister fd, FPURegister fj); -+ void Ffint_s_ul(FPURegister fd, Register rj); -+ -+ // Convert double to unsigned word. -+ void Ftintrz_uw_d(FPURegister fd, FPURegister fj, FPURegister scratch); -+ void Ftintrz_uw_d(Register rd, FPURegister fj, FPURegister scratch); -+ -+ // Convert single to unsigned word. -+ void Ftintrz_uw_s(FPURegister fd, FPURegister fs, FPURegister scratch); -+ void Ftintrz_uw_s(Register rd, FPURegister fs, FPURegister scratch); -+ -+ // Convert double to unsigned long. -+ void Ftintrz_ul_d(FPURegister fd, FPURegister fj, FPURegister scratch, -+ Register result = no_reg); -+ void Ftintrz_ul_d(Register rd, FPURegister fj, FPURegister scratch, -+ Register result = no_reg); -+ -+ // Convert single to unsigned long. -+ void Ftintrz_ul_s(FPURegister fd, FPURegister fj, FPURegister scratch, -+ Register result = no_reg); -+ void Ftintrz_ul_s(Register rd, FPURegister fj, FPURegister scratch, -+ Register result = no_reg); -+ -+ // Round double functions -+ void Trunc_d(FPURegister fd, FPURegister fj); -+ void Round_d(FPURegister fd, FPURegister fj); -+ void Floor_d(FPURegister fd, FPURegister fj); -+ void Ceil_d(FPURegister fd, FPURegister fj); -+ -+ // Round float functions -+ void Trunc_s(FPURegister fd, FPURegister fj); -+ void Round_s(FPURegister fd, FPURegister fj); -+ void Floor_s(FPURegister fd, FPURegister fj); -+ void Ceil_s(FPURegister fd, FPURegister fj); -+ -+ // Jump the register contains a smi. -+ void JumpIfSmi(Register value, Label* smi_label, Register scratch = t7); -+ -+ void JumpIfEqual(Register a, int32_t b, Label* dest) { -+ li(kScratchReg, Operand(b)); -+ Branch(dest, eq, a, Operand(kScratchReg)); -+ } -+ -+ void JumpIfLessThan(Register a, int32_t b, Label* dest) { -+ li(kScratchReg, Operand(b)); -+ Branch(dest, lt, a, Operand(kScratchReg)); -+ } -+ -+ // Push a standard frame, consisting of ra, fp, context and JS function. -+ void PushStandardFrame(Register function_reg); -+ -+ // Get the actual activation frame alignment for target environment. -+ static int ActivationFrameAlignment(); -+ -+ // Load Scaled Address instructions. Parameter sa (shift argument) must be -+ // between [1, 31] (inclusive). The scratch register may be clobbered. -+ void Alsl_w(Register rd, Register rj, Register rk, uint8_t sa, -+ Register scratch = t7); -+ void Alsl_d(Register rd, Register rj, Register rk, uint8_t sa, -+ Register scratch = t7); -+ -+ // Compute the start of the generated instruction stream from the current PC. -+ // This is an alternative to embedding the {CodeObject} handle as a reference. -+ void ComputeCodeStartAddress(Register dst); -+ -+ void ResetSpeculationPoisonRegister(); -+ -+ // Control-flow integrity: -+ -+ // Define a function entrypoint. This doesn't emit any code for this -+ // architecture, as control-flow integrity is not supported for it. -+ void CodeEntry() {} -+ // Define an exception handler. -+ void ExceptionHandler() {} -+ // Define an exception handler and bind a label. -+ void BindExceptionHandler(Label* label) { bind(label); } -+ -+ protected: -+ inline Register GetRkAsRegisterHelper(const Operand& rk, Register scratch); -+ inline int32_t GetOffset(Label* L, OffsetSize bits); -+ -+ private: -+ bool has_double_zero_reg_set_ = false; -+ -+ // Performs a truncating conversion of a floating point number as used by -+ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it -+ // succeeds, otherwise falls through if result is saturated. On return -+ // 'result' either holds answer, or is clobbered on fall through. -+ void TryInlineTruncateDoubleToI(Register result, DoubleRegister input, -+ Label* done); -+ -+ bool BranchShortOrFallback(Label* L, Condition cond, Register rj, -+ const Operand& rk, bool need_link); -+ -+ // f32 or f64 -+ void CompareF(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, -+ CFRegister cd, bool f32 = true); -+ -+ void CompareIsNanF(FPURegister cmp1, FPURegister cmp2, CFRegister cd, -+ bool f32 = true); -+ -+ void CallCFunctionHelper(Register function, int num_reg_arguments, -+ int num_double_arguments); -+ -+ void RoundDouble(FPURegister dst, FPURegister src, FPURoundingMode mode); -+ -+ void RoundFloat(FPURegister dst, FPURegister src, FPURoundingMode mode); -+ -+ // Push a fixed frame, consisting of ra, fp. -+ void PushCommonFrame(Register marker_reg = no_reg); -+ -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode, Handle code_target, -+ Address wasm_target); -+}; -+ -+// MacroAssembler implements a collection of frequently used macros. -+class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { -+ public: -+ using TurboAssembler::TurboAssembler; -+ -+ // It assumes that the arguments are located below the stack pointer. -+ // argc is the number of arguments not including the receiver. -+ // TODO(victorgomes): Remove this function once we stick with the reversed -+ // arguments order. -+ void LoadReceiver(Register dest, Register argc) { -+#ifdef V8_REVERSE_JSARGS -+ Ld_d(dest, MemOperand(sp, 0)); -+#else -+ Alsl_d(dest, argc, sp, kPointerSizeLog2, t7); -+ Ld_d(dest, MemOperand(dest, 0)); -+#endif -+ } -+ -+ void StoreReceiver(Register rec, Register argc, Register scratch) { -+#ifdef V8_REVERSE_JSARGS -+ St_d(rec, MemOperand(sp, 0)); -+#else -+ Alsl_d(scratch, argc, sp, kPointerSizeLog2, t7); -+ St_d(rec, MemOperand(scratch, 0)); -+#endif -+ } -+ -+ bool IsNear(Label* L, Condition cond, int rs_reg); -+ -+ // Swap two registers. If the scratch register is omitted then a slightly -+ // less efficient form using xor instead of mov is emitted. -+ void Swap(Register reg1, Register reg2, Register scratch = no_reg); -+ -+ void PushRoot(RootIndex index) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Push(scratch); -+ } -+ -+ // Compare the object in a register to a value and jump if they are equal. -+ void JumpIfRoot(Register with, RootIndex index, Label* if_equal) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(if_equal, eq, with, Operand(scratch)); -+ } -+ -+ // Compare the object in a register to a value and jump if they are not equal. -+ void JumpIfNotRoot(Register with, RootIndex index, Label* if_not_equal) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(if_not_equal, ne, with, Operand(scratch)); -+ } -+ -+ // Checks if value is in range [lower_limit, higher_limit] using a single -+ // comparison. -+ void JumpIfIsInRange(Register value, unsigned lower_limit, -+ unsigned higher_limit, Label* on_in_range); -+ -+ // --------------------------------------------------------------------------- -+ // GC Support -+ -+ // Notify the garbage collector that we wrote a pointer into an object. -+ // |object| is the object being stored into, |value| is the object being -+ // stored. value and scratch registers are clobbered by the operation. -+ // The offset is the offset from the start of the object, not the offset from -+ // the tagged HeapObject pointer. For use with FieldOperand(reg, off). -+ void RecordWriteField( -+ Register object, int offset, Register value, Register scratch, -+ RAStatus ra_status, SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, -+ SmiCheck smi_check = INLINE_SMI_CHECK); -+ -+ // For a given |object| notify the garbage collector that the slot |address| -+ // has been written. |value| is the object being stored. The value and -+ // address registers are clobbered by the operation. -+ void RecordWrite( -+ Register object, Register address, Register value, RAStatus ra_status, -+ SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, -+ SmiCheck smi_check = INLINE_SMI_CHECK); -+ -+ void Pref(int32_t hint, const MemOperand& rs); -+ -+ // --------------------------------------------------------------------------- -+ // Pseudo-instructions. -+ -+ void LoadWordPair(Register rd, const MemOperand& rj, Register scratch); -+ void StoreWordPair(Register rd, const MemOperand& rj, Register scratch); -+ -+ // Convert double to unsigned long. -+ void Ftintrz_l_ud(FPURegister fd, FPURegister fj, FPURegister scratch); -+ -+ void Ftintrz_l_d(FPURegister fd, FPURegister fj); -+ void Ftintrne_l_d(FPURegister fd, FPURegister fj); -+ void Ftintrm_l_d(FPURegister fd, FPURegister fj); -+ void Ftintrp_l_d(FPURegister fd, FPURegister fj); -+ -+ void Ftintrz_w_d(FPURegister fd, FPURegister fj); -+ void Ftintrne_w_d(FPURegister fd, FPURegister fj); -+ void Ftintrm_w_d(FPURegister fd, FPURegister fj); -+ void Ftintrp_w_d(FPURegister fd, FPURegister fj); -+ -+ void Madd_s(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); -+ void Madd_d(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); -+ void Msub_s(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); -+ void Msub_d(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); -+ -+ // Truncates a double using a specific rounding mode, and writes the value -+ // to the result register. -+ // The except_flag will contain any exceptions caused by the instruction. -+ // If check_inexact is kDontCheckForInexactConversion, then the inexact -+ // exception is masked. -+ void EmitFPUTruncate( -+ FPURoundingMode rounding_mode, Register result, -+ DoubleRegister double_input, Register scratch, -+ DoubleRegister double_scratch, Register except_flag, -+ CheckForInexactConversion check_inexact = kDontCheckForInexactConversion); -+ -+ // Enter exit frame. -+ // argc - argument count to be dropped by LeaveExitFrame. -+ // save_doubles - saves FPU registers on stack, currently disabled. -+ // stack_space - extra stack space. -+ void EnterExitFrame(bool save_doubles, int stack_space = 0, -+ StackFrame::Type frame_type = StackFrame::EXIT); -+ -+ // Leave the current exit frame. -+ void LeaveExitFrame(bool save_doubles, Register arg_count, -+ bool do_return = NO_EMIT_RETURN, -+ bool argument_count_is_length = false); -+ -+ void LoadMap(Register destination, Register object); -+ -+ // Make sure the stack is aligned. Only emits code in debug mode. -+ void AssertStackIsAligned(); -+ -+ // Load the global proxy from the current context. -+ void LoadGlobalProxy(Register dst) { -+ LoadNativeContextSlot(Context::GLOBAL_PROXY_INDEX, dst); -+ } -+ -+ void LoadNativeContextSlot(int index, Register dst); -+ -+ // Load the initial map from the global function. The registers -+ // function and map can be the same, function is then overwritten. -+ void LoadGlobalFunctionInitialMap(Register function, Register map, -+ Register scratch); -+ -+ // ------------------------------------------------------------------------- -+ // JavaScript invokes. -+ -+ // Invoke the JavaScript function code by either calling or jumping. -+ void InvokeFunctionCode(Register function, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count, InvokeFlag flag); -+ -+ // On function call, call into the debugger if necessary. -+ void CheckDebugHook(Register fun, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count); -+ -+ // Invoke the JavaScript function in the given register. Changes the -+ // current context to the context in the function before invoking. -+ void InvokeFunctionWithNewTarget(Register function, Register new_target, -+ Register actual_parameter_count, -+ InvokeFlag flag); -+ void InvokeFunction(Register function, Register expected_parameter_count, -+ Register actual_parameter_count, InvokeFlag flag); -+ -+ // Frame restart support. -+ void MaybeDropFrames(); -+ -+ // Exception handling. -+ -+ // Push a new stack handler and link into stack handler chain. -+ void PushStackHandler(); -+ -+ // Unlink the stack handler on top of the stack from the stack handler chain. -+ // Must preserve the result register. -+ void PopStackHandler(); -+ -+ // ------------------------------------------------------------------------- -+ // Support functions. -+ -+ void GetObjectType(Register function, Register map, Register type_reg); -+ -+ // ------------------------------------------------------------------------- -+ // Runtime calls. -+ -+ // Call a runtime routine. -+ void CallRuntime(const Runtime::Function* f, int num_arguments, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs); -+ -+ // Convenience function: Same as above, but takes the fid instead. -+ void CallRuntime(Runtime::FunctionId fid, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { -+ const Runtime::Function* function = Runtime::FunctionForId(fid); -+ CallRuntime(function, function->nargs, save_doubles); -+ } -+ -+ // Convenience function: Same as above, but takes the fid instead. -+ void CallRuntime(Runtime::FunctionId fid, int num_arguments, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { -+ CallRuntime(Runtime::FunctionForId(fid), num_arguments, save_doubles); -+ } -+ -+ // Convenience function: tail call a runtime routine (jump). -+ void TailCallRuntime(Runtime::FunctionId fid); -+ -+ // Jump to the builtin routine. -+ void JumpToExternalReference(const ExternalReference& builtin, -+ bool builtin_exit_frame = false); -+ -+ // Generates a trampoline to jump to the off-heap instruction stream. -+ void JumpToInstructionStream(Address entry); -+ -+ // --------------------------------------------------------------------------- -+ // In-place weak references. -+ void LoadWeakValue(Register out, Register in, Label* target_if_cleared); -+ -+ // ------------------------------------------------------------------------- -+ // StatsCounter support. -+ -+ void IncrementCounter(StatsCounter* counter, int value, Register scratch1, -+ Register scratch2); -+ void DecrementCounter(StatsCounter* counter, int value, Register scratch1, -+ Register scratch2); -+ -+ // ------------------------------------------------------------------------- -+ // Smi utilities. -+ -+ void SmiTag(Register dst, Register src) { -+ STATIC_ASSERT(kSmiTag == 0); -+ if (SmiValuesAre32Bits()) { -+ slli_d(dst, src, 32); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ add_w(dst, src, src); -+ } -+ } -+ -+ void SmiTag(Register reg) { SmiTag(reg, reg); } -+ -+ // Left-shifted from int32 equivalent of Smi. -+ void SmiScale(Register dst, Register src, int scale) { -+ if (SmiValuesAre32Bits()) { -+ // The int portion is upper 32-bits of 64-bit word. -+ srai_d(dst, src, kSmiShift - scale); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ DCHECK_GE(scale, kSmiTagSize); -+ slli_w(dst, src, scale - kSmiTagSize); -+ } -+ } -+ -+ // Test if the register contains a smi. -+ inline void SmiTst(Register value, Register scratch) { -+ And(scratch, value, Operand(kSmiTagMask)); -+ } -+ -+ // Jump if the register contains a non-smi. -+ void JumpIfNotSmi(Register value, Label* not_smi_label, Register scratch); -+ -+ // Abort execution if argument is a smi, enabled via --debug-code. -+ void AssertNotSmi(Register object); -+ void AssertSmi(Register object); -+ -+ // Abort execution if argument is not a Constructor, enabled via --debug-code. -+ void AssertConstructor(Register object); -+ -+ // Abort execution if argument is not a JSFunction, enabled via --debug-code. -+ void AssertFunction(Register object); -+ -+ // Abort execution if argument is not a JSBoundFunction, -+ // enabled via --debug-code. -+ void AssertBoundFunction(Register object); -+ -+ // Abort execution if argument is not a JSGeneratorObject (or subclass), -+ // enabled via --debug-code. -+ void AssertGeneratorObject(Register object); -+ -+ // Abort execution if argument is not undefined or an AllocationSite, enabled -+ // via --debug-code. -+ void AssertUndefinedOrAllocationSite(Register object, Register scratch); -+ -+ template -+ void DecodeField(Register dst, Register src) { -+ Bstrpick_d(dst, src, Field::kShift + Field::kSize - 1, Field::kShift); -+ } -+ -+ template -+ void DecodeField(Register reg) { -+ DecodeField(reg, reg); -+ } -+ -+ private: -+ // Helper functions for generating invokes. -+ void InvokePrologue(Register expected_parameter_count, -+ Register actual_parameter_count, Label* done, -+ InvokeFlag flag); -+ -+ // Compute memory operands for safepoint stack slots. -+ static int SafepointRegisterStackIndex(int reg_code); -+ -+ // Needs access to SafepointRegisterStackIndex for compiled frame -+ // traversal. -+ friend class StandardFrame; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(MacroAssembler); -+}; -+ -+template -+void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count, -+ Func GetLabelFunction) { -+ // Ensure that dd-ed labels following this instruction use 8 bytes aligned -+ // addresses. -+ BlockTrampolinePoolFor(static_cast(case_count) * 2 + -+ kSwitchTablePrologueSize); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Align(8); // next is 4 instrs. -+ pcaddi(scratch, 4); -+ // alsl_d will do sa -+ alsl_d(scratch, index, scratch, kPointerSizeLog2); -+ Ld_d(scratch, MemOperand(scratch, 0)); -+ jirl(zero_reg, scratch, 0); -+ for (size_t index = 0; index < case_count; ++index) { -+ dd(GetLabelFunction(index)); -+ } -+} -+ -+#define ACCESS_MASM(masm) masm-> -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/codegen/loongarch64/register-loongarch64.h b/src/3rdparty/chromium/v8/src/codegen/loongarch64/register-loongarch64.h -new file mode 100644 -index 000000000..6999f1936 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/loongarch64/register-loongarch64.h -@@ -0,0 +1,330 @@ -+// Copyright 2018 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ -+#define V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ -+ -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/register.h" -+#include "src/codegen/reglist.h" -+ -+namespace v8 { -+namespace internal { -+ -+// clang-format off -+#define GENERAL_REGISTERS(V) \ -+ V(zero_reg) V(ra) V(gp) V(sp) \ -+ V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) \ -+ V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) V(t7) V(t8) \ -+ V(tp) V(fp) \ -+ V(s0) V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) \ -+ -+#define ALLOCATABLE_GENERAL_REGISTERS(V) \ -+ V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) \ -+ V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(s7) -+ -+#define DOUBLE_REGISTERS(V) \ -+ V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ -+ V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) \ -+ V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ -+ V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) -+ -+#define FLOAT_REGISTERS DOUBLE_REGISTERS -+#define SIMD128_REGISTERS(V) \ -+ V(w0) V(w1) V(w2) V(w3) V(w4) V(w5) V(w6) V(w7) \ -+ V(w8) V(w9) V(w10) V(w11) V(w12) V(w13) V(w14) V(w15) \ -+ V(w16) V(w17) V(w18) V(w19) V(w20) V(w21) V(w22) V(w23) \ -+ V(w24) V(w25) V(w26) V(w27) V(w28) V(w29) V(w30) V(w31) -+ -+#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ -+ V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ -+ V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) V(f16) \ -+ V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) -+// clang-format on -+ -+// Note that the bit values must match those used in actual instruction -+// encoding. -+const int kNumRegs = 32; -+ -+const RegList kJSCallerSaved = 1 << 4 | // a0 -+ 1 << 5 | // a1 -+ 1 << 6 | // a2 -+ 1 << 7 | // a3 -+ 1 << 8 | // a4 -+ 1 << 9 | // a5 -+ 1 << 10 | // a6 -+ 1 << 11 | // a7 -+ 1 << 12 | // t0 -+ 1 << 13 | // t1 -+ 1 << 14 | // t2 -+ 1 << 15 | // t3 -+ 1 << 16 | // t4 -+ 1 << 17 | // t5 -+ 1 << 20; // t8 -+ -+const int kNumJSCallerSaved = 15; -+ -+// Callee-saved registers preserved when switching from C to JavaScript. -+const RegList kCalleeSaved = 1 << 22 | // fp -+ 1 << 23 | // s0 -+ 1 << 24 | // s1 -+ 1 << 25 | // s2 -+ 1 << 26 | // s3 -+ 1 << 27 | // s4 -+ 1 << 28 | // s5 -+ 1 << 29 | // s6 (roots in Javascript code) -+ 1 << 30 | // s7 (cp in Javascript code) -+ 1 << 31; // s8 -+ -+const int kNumCalleeSaved = 10; -+ -+const RegList kCalleeSavedFPU = 1 << 24 | // f24 -+ 1 << 25 | // f25 -+ 1 << 26 | // f26 -+ 1 << 27 | // f27 -+ 1 << 28 | // f28 -+ 1 << 29 | // f29 -+ 1 << 30 | // f30 -+ 1 << 31; // f31 -+ -+const int kNumCalleeSavedFPU = 8; -+ -+const RegList kCallerSavedFPU = 1 << 0 | // f0 -+ 1 << 1 | // f1 -+ 1 << 2 | // f2 -+ 1 << 3 | // f3 -+ 1 << 4 | // f4 -+ 1 << 5 | // f5 -+ 1 << 6 | // f6 -+ 1 << 7 | // f7 -+ 1 << 8 | // f8 -+ 1 << 9 | // f9 -+ 1 << 10 | // f10 -+ 1 << 11 | // f11 -+ 1 << 12 | // f12 -+ 1 << 13 | // f13 -+ 1 << 14 | // f14 -+ 1 << 15 | // f15 -+ 1 << 16 | // f16 -+ 1 << 17 | // f17 -+ 1 << 18 | // f18 -+ 1 << 19 | // f19 -+ 1 << 20 | // f20 -+ 1 << 21 | // f21 -+ 1 << 22 | // f22 -+ 1 << 23; // f23 -+ -+// Number of registers for which space is reserved in safepoints. Must be a -+// multiple of 8. -+const int kNumSafepointRegisters = 32; -+ -+// Define the list of registers actually saved at safepoints. -+// Note that the number of saved registers may be smaller than the reserved -+// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. -+const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; -+const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; -+ -+const int kUndefIndex = -1; -+// Map with indexes on stack that corresponds to codes of saved registers. -+const int kSafepointRegisterStackIndexMap[kNumRegs] = {kUndefIndex, // zero_reg -+ kUndefIndex, // ra -+ kUndefIndex, // gp -+ kUndefIndex, // sp -+ 0, // a0 -+ 1, // a1 -+ 2, // a2 -+ 3, // a3 -+ 4, // a4 -+ 5, // a5 -+ 6, // a6 -+ 7, // a7 -+ 8, // t0 -+ 9, // t1 -+ 10, // t2 -+ 11, // t3 -+ 12, // t4 -+ 13, // t5 -+ kUndefIndex, // t6 -+ kUndefIndex, // t7 -+ 14, // t8 -+ kUndefIndex, // tp -+ 15, // fp -+ 16, // s0 -+ 17, // s1 -+ 28, // s2 -+ 29, // s3 -+ 20, // s4 -+ 21, // s5 -+ 22, // s6 -+ 23, // s7 -+ 24}; // s8 -+ -+// CPU Registers. -+// -+// 1) We would prefer to use an enum, but enum values are assignment- -+// compatible with int, which has caused code-generation bugs. -+// -+// 2) We would prefer to use a class instead of a struct but we don't like -+// the register initialization to depend on the particular initialization -+// order (which appears to be different on OS X, Linux, and Windows for the -+// installed versions of C++ we tried). Using a struct permits C-style -+// "initialization". Also, the Register objects cannot be const as this -+// forces initialization stubs in MSVC, making us dependent on initialization -+// order. -+// -+// 3) By not using an enum, we are possibly preventing the compiler from -+// doing certain constant folds, which may significantly reduce the -+// code generated for some assembly instructions (because they boil down -+// to a few constants). If this is a problem, we could change the code -+// such that we use an enum in optimized mode, and the struct in debug -+// mode. This way we get the compile-time error checking in debug mode -+// and best performance in optimized code. -+ -+// ----------------------------------------------------------------------------- -+// Implementation of Register and FPURegister. -+ -+enum RegisterCode { -+#define REGISTER_CODE(R) kRegCode_##R, -+ GENERAL_REGISTERS(REGISTER_CODE) -+#undef REGISTER_CODE -+ kRegAfterLast -+}; -+ -+class Register : public RegisterBase { -+ public: -+ static constexpr int kMantissaOffset = 0; -+ static constexpr int kExponentOffset = 4; -+ -+ private: -+ friend class RegisterBase; -+ explicit constexpr Register(int code) : RegisterBase(code) {} -+}; -+ -+// s7: context register -+// s3: scratch register -+// s4: scratch register 2 -+#define DECLARE_REGISTER(R) \ -+ constexpr Register R = Register::from_code(kRegCode_##R); -+GENERAL_REGISTERS(DECLARE_REGISTER) -+#undef DECLARE_REGISTER -+ -+constexpr Register no_reg = Register::no_reg(); -+ -+int ToNumber(Register reg); -+ -+Register ToRegister(int num); -+ -+constexpr bool kPadArguments = false; -+constexpr bool kSimpleFPAliasing = true; -+constexpr bool kSimdMaskRegisters = false; -+ -+enum DoubleRegisterCode { -+#define REGISTER_CODE(R) kDoubleCode_##R, -+ DOUBLE_REGISTERS(REGISTER_CODE) -+#undef REGISTER_CODE -+ kDoubleAfterLast -+}; -+ -+// Coprocessor register. -+class FPURegister : public RegisterBase { -+ public: -+ FPURegister low() const { -+ // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. -+ // Find low reg of a Double-reg pair, which is the reg itself. -+ DCHECK_EQ(code() % 2, 0); // Specified Double reg must be even. -+ return FPURegister::from_code(code()); -+ } -+ -+ private: -+ friend class RegisterBase; -+ explicit constexpr FPURegister(int code) : RegisterBase(code) {} -+}; -+ -+enum CFRegister { FCC0, FCC1, FCC2, FCC3, FCC4, FCC5, FCC6, FCC7 }; -+ -+using FloatRegister = FPURegister; -+ -+using DoubleRegister = FPURegister; -+ -+// TODO here only for build success -+using Simd128Register = FPURegister; -+ -+#define DECLARE_DOUBLE_REGISTER(R) \ -+ constexpr DoubleRegister R = DoubleRegister::from_code(kDoubleCode_##R); -+DOUBLE_REGISTERS(DECLARE_DOUBLE_REGISTER) -+#undef DECLARE_DOUBLE_REGISTER -+ -+constexpr DoubleRegister no_dreg = DoubleRegister::no_reg(); -+ -+// Register aliases. -+// cp is assumed to be a callee saved register. -+constexpr Register kRootRegister = s6; -+constexpr Register cp = s7; -+constexpr Register kScratchReg = s3; -+constexpr Register kScratchReg2 = s4; -+constexpr DoubleRegister kScratchDoubleReg = f30; -+// FPU zero reg is often used to hold 0.0, but it's not hardwired to 0.0. -+constexpr DoubleRegister kDoubleRegZero = f28; -+ -+// FPU (coprocessor 1) control registers. -+// Currently only FCSR0 is implemented. -+// TODO fscr0 fcsr1 fcsr2 fscsr3 -+struct FPUControlRegister { -+ bool is_valid() const { return reg_code == kFCSRRegister; } -+ bool is(FPUControlRegister creg) const { return reg_code == creg.reg_code; } -+ int code() const { -+ DCHECK(is_valid()); -+ return reg_code; -+ } -+ int bit() const { -+ DCHECK(is_valid()); -+ return 1 << reg_code; -+ } -+ void setcode(int f) { -+ reg_code = f; -+ DCHECK(is_valid()); -+ } -+ // Unfortunately we can't make this private in a struct. -+ int reg_code; -+}; -+ -+constexpr FPUControlRegister no_fpucreg = {kInvalidFPUControlRegister}; -+constexpr FPUControlRegister FCSR = {kFCSRRegister}; -+ -+// Define {RegisterName} methods for the register types. -+DEFINE_REGISTER_NAMES(Register, GENERAL_REGISTERS) -+DEFINE_REGISTER_NAMES(FPURegister, DOUBLE_REGISTERS) -+ -+// Give alias names to registers for calling conventions. -+constexpr Register kReturnRegister0 = a0; -+constexpr Register kReturnRegister1 = a1; -+constexpr Register kReturnRegister2 = a2; -+constexpr Register kJSFunctionRegister = a1; -+constexpr Register kContextRegister = s7; -+constexpr Register kAllocateSizeRegister = a0; -+constexpr Register kSpeculationPoisonRegister = t3; -+constexpr Register kInterpreterAccumulatorRegister = a0; -+constexpr Register kInterpreterBytecodeOffsetRegister = t0; -+constexpr Register kInterpreterBytecodeArrayRegister = t1; -+constexpr Register kInterpreterDispatchTableRegister = t2; -+ -+constexpr Register kJavaScriptCallArgCountRegister = a0; -+constexpr Register kJavaScriptCallCodeStartRegister = a2; -+constexpr Register kJavaScriptCallTargetRegister = kJSFunctionRegister; -+constexpr Register kJavaScriptCallNewTargetRegister = a3; -+constexpr Register kJavaScriptCallExtraArg1Register = a2; -+ -+constexpr Register kOffHeapTrampolineRegister = t7; -+constexpr Register kRuntimeCallFunctionRegister = a1; -+constexpr Register kRuntimeCallArgCountRegister = a0; -+constexpr Register kRuntimeCallArgvRegister = a2; -+constexpr Register kWasmInstanceRegister = a0; -+constexpr Register kWasmCompileLazyFuncIndexRegister = t0; -+ -+constexpr DoubleRegister kFPReturnRegister0 = f0; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h b/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h -index a213fc504..7532a4ab7 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h -+++ b/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h -@@ -49,6 +49,9 @@ enum AllocationFlags { - #elif V8_TARGET_ARCH_MIPS64 - #include "src/codegen/mips64/constants-mips64.h" - #include "src/codegen/mips64/macro-assembler-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/loongarch64/macro-assembler-loongarch64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/constants-s390.h" - #include "src/codegen/s390/macro-assembler-s390.h" -diff --git a/src/3rdparty/chromium/v8/src/codegen/register-arch.h b/src/3rdparty/chromium/v8/src/codegen/register-arch.h -index 21a723301..f61f3cf01 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/register-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/register-arch.h -@@ -22,6 +22,8 @@ - #include "src/codegen/mips/register-mips.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/codegen/mips64/register-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/codegen/loongarch64/register-loongarch64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/register-s390.h" - #else -diff --git a/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc b/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc -index 5752b4633..3253bd2c9 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc -@@ -58,6 +58,8 @@ static int get_num_allocatable_double_registers() { - kMaxAllocatableDoubleRegisterCount; - #elif V8_TARGET_ARCH_MIPS64 - kMaxAllocatableDoubleRegisterCount; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ kMaxAllocatableDoubleRegisterCount; - #elif V8_TARGET_ARCH_PPC - kMaxAllocatableDoubleRegisterCount; - #elif V8_TARGET_ARCH_PPC64 -diff --git a/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc b/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc -index d984b1e91..4af5914a6 100644 ---- a/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc -@@ -330,7 +330,8 @@ bool RelocInfo::OffHeapTargetIsCodedSpecially() { - return false; - #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \ - defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) || \ -- defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) -+ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) || \ -+ defined(V8_TARGET_ARCH_LOONGARCH64) - return true; - #endif - } -diff --git a/src/3rdparty/chromium/v8/src/common/globals.h b/src/3rdparty/chromium/v8/src/common/globals.h -index 0e9d81520..4656ff32f 100644 ---- a/src/3rdparty/chromium/v8/src/common/globals.h -+++ b/src/3rdparty/chromium/v8/src/common/globals.h -@@ -58,6 +58,9 @@ constexpr int GB = MB * 1024; - #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) - #define USE_SIMULATOR 1 - #endif -+#if (V8_TARGET_ARCH_LOONGARCH64 && !V8_HOST_ARCH_LOONGARCH64) -+#define USE_SIMULATOR 1 -+#endif - #endif - - // Determine whether the architecture uses an embedded constant pool -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h -index 8772a78df..c17db99f2 100644 ---- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h -@@ -17,6 +17,8 @@ - #include "src/compiler/backend/mips/instruction-codes-mips.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/compiler/backend/mips64/instruction-codes-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h" - #elif V8_TARGET_ARCH_X64 - #include "src/compiler/backend/x64/instruction-codes-x64.h" - #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc -index c8f34c14f..0835b9b60 100644 ---- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc -@@ -2624,7 +2624,7 @@ void InstructionSelector::VisitWord32AtomicPairCompareExchange(Node* node) { - #endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS - - #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && \ -- !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 -+ !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_LOONGARCH64 - void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); } - - void InstructionSelector::VisitWord64AtomicStore(Node* node) { -@@ -2649,7 +2649,8 @@ void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { - UNIMPLEMENTED(); - } - #endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_PPC64 -- // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 -+ // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 && -+ // !V8_TARGET_ARCH_LOONGARCH64 - - #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM - // This is only needed on 32-bit to split the 64-bit value into two operands. -@@ -2663,11 +2664,11 @@ void InstructionSelector::VisitI64x2ReplaceLaneI32Pair(Node* node) { - - #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_S390X - #if !V8_TARGET_ARCH_ARM64 --#if !V8_TARGET_ARCH_MIPS64 -+#if !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 - void InstructionSelector::VisitI64x2Splat(Node* node) { UNIMPLEMENTED(); } - void InstructionSelector::VisitI64x2ExtractLane(Node* node) { UNIMPLEMENTED(); } - void InstructionSelector::VisitI64x2ReplaceLane(Node* node) { UNIMPLEMENTED(); } --#endif // !V8_TARGET_ARCH_MIPS64 -+#endif // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 - void InstructionSelector::VisitI64x2Eq(Node* node) { UNIMPLEMENTED(); } - void InstructionSelector::VisitI64x2Ne(Node* node) { UNIMPLEMENTED(); } - void InstructionSelector::VisitI64x2GtS(Node* node) { UNIMPLEMENTED(); } -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/code-generator-loongarch64.cc b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/code-generator-loongarch64.cc -new file mode 100644 -index 000000000..b84eb556e ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/code-generator-loongarch64.cc -@@ -0,0 +1,2846 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/callable.h" -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/optimized-compilation-info.h" -+#include "src/compiler/backend/code-generator-impl.h" -+#include "src/compiler/backend/code-generator.h" -+#include "src/compiler/backend/gap-resolver.h" -+#include "src/compiler/node-matchers.h" -+#include "src/compiler/osr.h" -+#include "src/heap/memory-chunk.h" -+#include "src/wasm/wasm-code-manager.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+#define __ tasm()-> -+ -+// TODO(plind): consider renaming these macros. -+#define TRACE_MSG(msg) \ -+ PrintF("code_gen: \'%s\' in function %s at line %d\n", msg, __FUNCTION__, \ -+ __LINE__) -+ -+#define TRACE_UNIMPL() \ -+ PrintF("UNIMPLEMENTED code_generator_la64: %s at line %d\n", __FUNCTION__, \ -+ __LINE__) -+ -+// Adds La64-specific methods to convert InstructionOperands. -+class La64OperandConverter final : public InstructionOperandConverter { -+ public: -+ La64OperandConverter(CodeGenerator* gen, Instruction* instr) -+ : InstructionOperandConverter(gen, instr) {} -+ -+ FloatRegister OutputSingleRegister(size_t index = 0) { -+ return ToSingleRegister(instr_->OutputAt(index)); -+ } -+ -+ FloatRegister InputSingleRegister(size_t index) { -+ return ToSingleRegister(instr_->InputAt(index)); -+ } -+ -+ FloatRegister ToSingleRegister(InstructionOperand* op) { -+ // Single (Float) and Double register namespace is same on LA64, -+ // both are typedefs of FPURegister. -+ return ToDoubleRegister(op); -+ } -+ -+ Register InputOrZeroRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) { -+ DCHECK_EQ(0, InputInt32(index)); -+ return zero_reg; -+ } -+ return InputRegister(index); -+ } -+ -+ DoubleRegister InputOrZeroDoubleRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; -+ -+ return InputDoubleRegister(index); -+ } -+ -+ DoubleRegister InputOrZeroSingleRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; -+ -+ return InputSingleRegister(index); -+ } -+ -+ Operand InputImmediate(size_t index) { -+ Constant constant = ToConstant(instr_->InputAt(index)); -+ switch (constant.type()) { -+ case Constant::kInt32: -+ return Operand(constant.ToInt32()); -+ case Constant::kInt64: -+ return Operand(constant.ToInt64()); -+ case Constant::kFloat32: -+ return Operand::EmbeddedNumber(constant.ToFloat32()); -+ case Constant::kFloat64: -+ return Operand::EmbeddedNumber(constant.ToFloat64().value()); -+ case Constant::kExternalReference: -+ case Constant::kCompressedHeapObject: -+ case Constant::kHeapObject: -+ // TODO(plind): Maybe we should handle ExtRef & HeapObj here? -+ // maybe not done on arm due to const pool ?? -+ break; -+ case Constant::kDelayedStringConstant: -+ return Operand::EmbeddedStringConstant( -+ constant.ToDelayedStringConstant()); -+ case Constant::kRpoNumber: -+ UNREACHABLE(); // TODO(titzer): RPO immediates on la64? -+ break; -+ } -+ UNREACHABLE(); -+ } -+ -+ Operand InputOperand(size_t index) { -+ InstructionOperand* op = instr_->InputAt(index); -+ if (op->IsRegister()) { -+ return Operand(ToRegister(op)); -+ } -+ return InputImmediate(index); -+ } -+ -+ MemOperand MemoryOperand(size_t* first_index) { -+ const size_t index = *first_index; -+ switch (AddressingModeField::decode(instr_->opcode())) { -+ case kMode_None: -+ break; -+ case kMode_MRI: -+ *first_index += 2; -+ return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); -+ case kMode_MRR: -+ *first_index += 2; -+ return MemOperand(InputRegister(index + 0), InputRegister(index + 1)); -+ } -+ UNREACHABLE(); -+ } -+ -+ MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } -+ -+ MemOperand ToMemOperand(InstructionOperand* op) const { -+ DCHECK_NOT_NULL(op); -+ DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); -+ return SlotToMemOperand(AllocatedOperand::cast(op)->index()); -+ } -+ -+ MemOperand SlotToMemOperand(int slot) const { -+ FrameOffset offset = frame_access_state()->GetFrameOffset(slot); -+ return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); -+ } -+}; -+ -+static inline bool HasRegisterInput(Instruction* instr, size_t index) { -+ return instr->InputAt(index)->IsRegister(); -+} -+ -+namespace { -+ -+class OutOfLineRecordWrite final : public OutOfLineCode { -+ public: -+ OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, -+ Register value, Register scratch0, Register scratch1, -+ RecordWriteMode mode, StubCallMode stub_mode) -+ : OutOfLineCode(gen), -+ object_(object), -+ index_(index), -+ value_(value), -+ scratch0_(scratch0), -+ scratch1_(scratch1), -+ mode_(mode), -+ stub_mode_(stub_mode), -+ must_save_lr_(!gen->frame_access_state()->has_frame()), -+ zone_(gen->zone()) {} -+ -+ void Generate() final { -+ if (mode_ > RecordWriteMode::kValueIsPointer) { -+ __ JumpIfSmi(value_, exit()); -+ } -+ __ CheckPageFlag(value_, scratch0_, -+ MemoryChunk::kPointersToHereAreInterestingMask, eq, -+ exit()); -+ __ Add_d(scratch1_, object_, index_); -+ RememberedSetAction const remembered_set_action = -+ mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET -+ : OMIT_REMEMBERED_SET; -+ SaveFPRegsMode const save_fp_mode = -+ frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; -+ if (must_save_lr_) { -+ // We need to save and restore ra if the frame was elided. -+ __ Push(ra); -+ } -+ if (mode_ == RecordWriteMode::kValueIsEphemeronKey) { -+ __ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode); -+ } else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) { -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched when the code -+ // is added to the native module and copied into wasm code space. -+ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, -+ save_fp_mode, wasm::WasmCode::kRecordWrite); -+ } else { -+ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, -+ save_fp_mode); -+ } -+ if (must_save_lr_) { -+ __ Pop(ra); -+ } -+ } -+ -+ private: -+ Register const object_; -+ Register const index_; -+ Register const value_; -+ Register const scratch0_; -+ Register const scratch1_; -+ RecordWriteMode const mode_; -+ StubCallMode const stub_mode_; -+ bool must_save_lr_; -+ Zone* zone_; -+}; -+ -+#define CREATE_OOL_CLASS(ool_name, tasm_ool_name, T) \ -+ class ool_name final : public OutOfLineCode { \ -+ public: \ -+ ool_name(CodeGenerator* gen, T dst, T src1, T src2) \ -+ : OutOfLineCode(gen), dst_(dst), src1_(src1), src2_(src2) {} \ -+ \ -+ void Generate() final { __ tasm_ool_name(dst_, src1_, src2_); } \ -+ \ -+ private: \ -+ T const dst_; \ -+ T const src1_; \ -+ T const src2_; \ -+ } -+ -+CREATE_OOL_CLASS(OutOfLineFloat32Max, Float32MaxOutOfLine, FPURegister); -+CREATE_OOL_CLASS(OutOfLineFloat32Min, Float32MinOutOfLine, FPURegister); -+CREATE_OOL_CLASS(OutOfLineFloat64Max, Float64MaxOutOfLine, FPURegister); -+CREATE_OOL_CLASS(OutOfLineFloat64Min, Float64MinOutOfLine, FPURegister); -+ -+#undef CREATE_OOL_CLASS -+ -+Condition FlagsConditionToConditionCmp(FlagsCondition condition) { -+ switch (condition) { -+ case kEqual: -+ return eq; -+ case kNotEqual: -+ return ne; -+ case kSignedLessThan: -+ return lt; -+ case kSignedGreaterThanOrEqual: -+ return ge; -+ case kSignedLessThanOrEqual: -+ return le; -+ case kSignedGreaterThan: -+ return gt; -+ case kUnsignedLessThan: -+ return lo; -+ case kUnsignedGreaterThanOrEqual: -+ return hs; -+ case kUnsignedLessThanOrEqual: -+ return ls; -+ case kUnsignedGreaterThan: -+ return hi; -+ case kUnorderedEqual: -+ case kUnorderedNotEqual: -+ break; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+Condition FlagsConditionToConditionTst(FlagsCondition condition) { -+ switch (condition) { -+ case kNotEqual: -+ return ne; -+ case kEqual: -+ return eq; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+Condition FlagsConditionToConditionOvf(FlagsCondition condition) { -+ switch (condition) { -+ case kOverflow: -+ return ne; -+ case kNotOverflow: -+ return eq; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+FPUCondition FlagsConditionToConditionCmpFPU(bool* predicate, -+ FlagsCondition condition) { -+ switch (condition) { -+ case kEqual: -+ *predicate = true; -+ return CEQ; -+ case kNotEqual: -+ *predicate = false; -+ return CEQ; -+ case kUnsignedLessThan: -+ *predicate = true; -+ return CLT; -+ case kUnsignedGreaterThanOrEqual: -+ *predicate = false; -+ return CLT; -+ case kUnsignedLessThanOrEqual: -+ *predicate = true; -+ return CLE; -+ case kUnsignedGreaterThan: -+ *predicate = false; -+ return CLE; -+ case kUnorderedEqual: -+ case kUnorderedNotEqual: -+ *predicate = true; -+ break; -+ default: -+ *predicate = true; -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, -+ InstructionCode opcode, Instruction* instr, -+ La64OperandConverter const& i) { -+ const MemoryAccessMode access_mode = -+ static_cast(MiscField::decode(opcode)); -+ if (access_mode == kMemoryAccessPoisoned) { -+ Register value = i.OutputRegister(); -+ codegen->tasm()->And(value, value, kSpeculationPoisonRegister); -+ } -+} -+ -+} // namespace -+ -+#define ASSEMBLE_ATOMIC_LOAD_INTEGER(asm_instr) \ -+ do { \ -+ __ asm_instr(i.OutputRegister(), i.MemoryOperand()); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// TODO remove second dbar? -+#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ -+ do { \ -+ __ dbar(0); \ -+ __ asm_instr(i.InputOrZeroRegister(2), i.MemoryOperand()); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// only use for sub_w and sub_d -+#define ASSEMBLE_ATOMIC_BINOP(load_linked, store_conditional, bin_instr) \ -+ do { \ -+ Label binop; \ -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ __ dbar(0); \ -+ __ bind(&binop); \ -+ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ -+ __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \ -+ Operand(i.InputRegister(2))); \ -+ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&binop, eq, i.TempRegister(1), Operand(zero_reg)); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// TODO remove second dbar? -+#define ASSEMBLE_ATOMIC_BINOP_EXT(load_linked, store_conditional, sign_extend, \ -+ size, bin_instr, representation) \ -+ do { \ -+ Label binop; \ -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ andi(i.TempRegister(3), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ andi(i.TempRegister(3), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(3))); \ -+ __ slli_w(i.TempRegister(3), i.TempRegister(3), 3); \ -+ __ dbar(0); \ -+ __ bind(&binop); \ -+ __ load_linked(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(1), i.TempRegister(3), \ -+ size, sign_extend); \ -+ __ bin_instr(i.TempRegister(2), i.OutputRegister(0), \ -+ Operand(i.InputRegister(2))); \ -+ __ InsertBits(i.TempRegister(1), i.TempRegister(2), i.TempRegister(3), \ -+ size); \ -+ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&binop, eq, i.TempRegister(1), Operand(zero_reg)); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// TODO remove second dbar? -+#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT( \ -+ load_linked, store_conditional, sign_extend, size, representation) \ -+ do { \ -+ Label exchange; \ -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ andi(i.TempRegister(1), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ andi(i.TempRegister(1), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(1))); \ -+ __ slli_w(i.TempRegister(1), i.TempRegister(1), 3); \ -+ __ dbar(0); \ -+ __ bind(&exchange); \ -+ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ InsertBits(i.TempRegister(2), i.InputRegister(2), i.TempRegister(1), \ -+ size); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&exchange, eq, i.TempRegister(2), Operand(zero_reg)); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// TODO remove second dbar? -+#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_linked, \ -+ store_conditional) \ -+ do { \ -+ Label compareExchange; \ -+ Label exit; \ -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ __ dbar(0); \ -+ __ bind(&compareExchange); \ -+ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&exit, ne, i.InputRegister(2), \ -+ Operand(i.OutputRegister(0))); \ -+ __ mov(i.TempRegister(2), i.InputRegister(3)); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&compareExchange, eq, i.TempRegister(2), \ -+ Operand(zero_reg)); \ -+ __ bind(&exit); \ -+ __ dbar(0); \ -+ } while (0) -+ -+// TODO remove second dbar? -+#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT( \ -+ load_linked, store_conditional, sign_extend, size, representation) \ -+ do { \ -+ Label compareExchange; \ -+ Label exit; \ -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ andi(i.TempRegister(1), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ andi(i.TempRegister(1), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(1))); \ -+ __ slli_w(i.TempRegister(1), i.TempRegister(1), 3); \ -+ __ dbar(0); \ -+ __ bind(&compareExchange); \ -+ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ ExtractBits(i.InputRegister(2), i.InputRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ BranchShort(&exit, ne, i.InputRegister(2), \ -+ Operand(i.OutputRegister(0))); \ -+ __ InsertBits(i.TempRegister(2), i.InputRegister(3), i.TempRegister(1), \ -+ size); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&compareExchange, eq, i.TempRegister(2), \ -+ Operand(zero_reg)); \ -+ __ bind(&exit); \ -+ __ dbar(0); \ -+ } while (0) -+ -+#define ASSEMBLE_IEEE754_BINOP(name) \ -+ do { \ -+ FrameScope scope(tasm(), StackFrame::MANUAL); \ -+ __ PrepareCallCFunction(0, 2, kScratchReg); \ -+ __ MovToFloatParameters(i.InputDoubleRegister(0), \ -+ i.InputDoubleRegister(1)); \ -+ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 2); \ -+ /* Move the result in the double result register. */ \ -+ __ MovFromFloatResult(i.OutputDoubleRegister()); \ -+ } while (0) -+ -+#define ASSEMBLE_IEEE754_UNOP(name) \ -+ do { \ -+ FrameScope scope(tasm(), StackFrame::MANUAL); \ -+ __ PrepareCallCFunction(0, 1, kScratchReg); \ -+ __ MovToFloatParameter(i.InputDoubleRegister(0)); \ -+ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 1); \ -+ /* Move the result in the double result register. */ \ -+ __ MovFromFloatResult(i.OutputDoubleRegister()); \ -+ } while (0) -+ -+#define ASSEMBLE_F64X2_ARITHMETIC_BINOP(op) \ -+ do { \ -+ __ op(i.OutputSimd128Register(), i.InputSimd128Register(0), \ -+ i.InputSimd128Register(1)); \ -+ } while (0) -+ -+void CodeGenerator::AssembleDeconstructFrame() { -+ __ mov(sp, fp); -+ __ Pop(ra, fp); -+} -+ -+void CodeGenerator::AssemblePrepareTailCall() { -+ if (frame_access_state()->has_frame()) { -+ __ Ld_d(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); -+ __ Ld_d(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ } -+ frame_access_state()->SetFrameAccessToSP(); -+} -+ -+void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, -+ Register scratch1, -+ Register scratch2, -+ Register scratch3) { -+ DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); -+ Label done; -+ -+ // Check if current frame is an arguments adaptor frame. -+ __ Ld_d(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset)); -+ __ Branch(&done, ne, scratch3, -+ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ -+ // Load arguments count from current arguments adaptor frame (note, it -+ // does not include receiver). -+ Register caller_args_count_reg = scratch1; -+ __ Ld_d(caller_args_count_reg, -+ MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ __ SmiUntag(caller_args_count_reg); -+ -+ __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3); -+ __ bind(&done); -+} -+ -+namespace { -+ -+void AdjustStackPointerForTailCall(TurboAssembler* tasm, -+ FrameAccessState* state, -+ int new_slot_above_sp, -+ bool allow_shrinkage = true) { -+ int current_sp_offset = state->GetSPToFPSlotCount() + -+ StandardFrameConstants::kFixedSlotCountAboveFp; -+ int stack_slot_delta = new_slot_above_sp - current_sp_offset; -+ if (stack_slot_delta > 0) { -+ tasm->Sub_d(sp, sp, stack_slot_delta * kSystemPointerSize); -+ state->IncreaseSPDelta(stack_slot_delta); -+ } else if (allow_shrinkage && stack_slot_delta < 0) { -+ tasm->Add_d(sp, sp, -stack_slot_delta * kSystemPointerSize); -+ state->IncreaseSPDelta(stack_slot_delta); -+ } -+} -+ -+} // namespace -+ -+void CodeGenerator::AssembleTailCallBeforeGap(Instruction* instr, -+ int first_unused_stack_slot) { -+ AdjustStackPointerForTailCall(tasm(), frame_access_state(), -+ first_unused_stack_slot, false); -+} -+ -+void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr, -+ int first_unused_stack_slot) { -+ AdjustStackPointerForTailCall(tasm(), frame_access_state(), -+ first_unused_stack_slot); -+} -+ -+// Check that {kJavaScriptCallCodeStartRegister} is correct. -+void CodeGenerator::AssembleCodeStartRegisterCheck() { -+ __ ComputeCodeStartAddress(kScratchReg); -+ __ Assert(eq, AbortReason::kWrongFunctionCodeStart, -+ kJavaScriptCallCodeStartRegister, Operand(kScratchReg)); -+} -+ -+// Check if the code object is marked for deoptimization. If it is, then it -+// jumps to the CompileLazyDeoptimizedCode builtin. In order to do this we need -+// to: -+// 1. read from memory the word that contains that bit, which can be found in -+// the flags in the referenced {CodeDataContainer} object; -+// 2. test kMarkedForDeoptimizationBit in those flags; and -+// 3. if it is not zero then it jumps to the builtin. -+void CodeGenerator::BailoutIfDeoptimized() { -+ int offset = Code::kCodeDataContainerOffset - Code::kHeaderSize; -+ __ Ld_d(kScratchReg, MemOperand(kJavaScriptCallCodeStartRegister, offset)); -+ __ Ld_w(kScratchReg, -+ FieldMemOperand(kScratchReg, -+ CodeDataContainer::kKindSpecificFlagsOffset)); -+ __ And(kScratchReg, kScratchReg, -+ Operand(1 << Code::kMarkedForDeoptimizationBit)); -+ __ Jump(BUILTIN_CODE(isolate(), CompileLazyDeoptimizedCode), -+ RelocInfo::CODE_TARGET, ne, kScratchReg, Operand(zero_reg)); -+} -+ -+void CodeGenerator::GenerateSpeculationPoisonFromCodeStartRegister() { -+ // Calculate a mask which has all bits set in the normal case, but has all -+ // bits cleared if we are speculatively executing the wrong PC. -+ __ li(kSpeculationPoisonRegister, -1); -+ __ ComputeCodeStartAddress(kScratchReg); -+ __ sub_d(kScratchReg, kScratchReg, kJavaScriptCallCodeStartRegister); -+ __ maskeqz(kSpeculationPoisonRegister, kSpeculationPoisonRegister, -+ kScratchReg); -+} -+ -+void CodeGenerator::AssembleRegisterArgumentPoisoning() { -+ __ And(kJSFunctionRegister, kJSFunctionRegister, kSpeculationPoisonRegister); -+ __ And(kContextRegister, kContextRegister, kSpeculationPoisonRegister); -+ __ And(sp, sp, kSpeculationPoisonRegister); -+} -+ -+// Assembles an instruction after register allocation, producing machine code. -+CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( -+ Instruction* instr) { -+ La64OperandConverter i(this, instr); -+ InstructionCode opcode = instr->opcode(); -+ ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); -+ switch (arch_opcode) { -+ case kArchCallCodeObject: { -+ if (instr->InputAt(0)->IsImmediate()) { -+ __ Call(i.InputCode(0), RelocInfo::CODE_TARGET); -+ } else { -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ addi_d(reg, reg, Code::kHeaderSize - kHeapObjectTag); -+ __ Call(reg); -+ } -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchCallBuiltinPointer: { -+ DCHECK(!instr->InputAt(0)->IsImmediate()); -+ Register builtin_index = i.InputRegister(0); -+ __ CallBuiltinByIndex(builtin_index); -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchCallWasmFunction: { -+ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { -+ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, -+ i.TempRegister(0), i.TempRegister(1), -+ i.TempRegister(2)); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ Constant constant = i.ToConstant(instr->InputAt(0)); -+ Address wasm_code = static_cast

(constant.ToInt64()); -+ __ Call(wasm_code, constant.rmode()); -+ } else { -+ __ addi_d(kScratchReg, i.InputRegister(0), 0); -+ __ Call(kScratchReg); -+ } -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchTailCallCodeObjectFromJSFunction: -+ case kArchTailCallCodeObject: { -+ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { -+ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, -+ i.TempRegister(0), i.TempRegister(1), -+ i.TempRegister(2)); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ __ Jump(i.InputCode(0), RelocInfo::CODE_TARGET); -+ } else { -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ addi_d(reg, reg, Code::kHeaderSize - kHeapObjectTag); -+ __ Jump(reg); -+ } -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchTailCallWasm: { -+ if (instr->InputAt(0)->IsImmediate()) { -+ Constant constant = i.ToConstant(instr->InputAt(0)); -+ Address wasm_code = static_cast
(constant.ToInt64()); -+ __ Jump(wasm_code, constant.rmode()); -+ } else { -+ __ addi_d(kScratchReg, i.InputRegister(0), 0); -+ __ Jump(kScratchReg); -+ } -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchTailCallAddress: { -+ CHECK(!instr->InputAt(0)->IsImmediate()); -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ Jump(reg); -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchCallJSFunction: { -+ Register func = i.InputRegister(0); -+ if (FLAG_debug_code) { -+ // Check the function's context matches the context argument. -+ __ Ld_d(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); -+ __ Assert(eq, AbortReason::kWrongFunctionContext, cp, -+ Operand(kScratchReg)); -+ } -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld_d(a2, FieldMemOperand(func, JSFunction::kCodeOffset)); -+ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Call(a2); -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchPrepareCallCFunction: { -+ int const num_parameters = MiscField::decode(instr->opcode()); -+ __ PrepareCallCFunction(num_parameters, kScratchReg); -+ // Frame alignment requires using FP-relative frame addressing. -+ frame_access_state()->SetFrameAccessToFP(); -+ break; -+ } -+ case kArchSaveCallerRegisters: { -+ fp_mode_ = -+ static_cast(MiscField::decode(instr->opcode())); -+ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); -+ // kReturnRegister0 should have been saved before entering the stub. -+ int bytes = __ PushCallerSaved(fp_mode_, kReturnRegister0); -+ DCHECK(IsAligned(bytes, kSystemPointerSize)); -+ DCHECK_EQ(0, frame_access_state()->sp_delta()); -+ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); -+ DCHECK(!caller_registers_saved_); -+ caller_registers_saved_ = true; -+ break; -+ } -+ case kArchRestoreCallerRegisters: { -+ DCHECK(fp_mode_ == -+ static_cast(MiscField::decode(instr->opcode()))); -+ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); -+ // Don't overwrite the returned value. -+ int bytes = __ PopCallerSaved(fp_mode_, kReturnRegister0); -+ frame_access_state()->IncreaseSPDelta(-(bytes / kSystemPointerSize)); -+ DCHECK_EQ(0, frame_access_state()->sp_delta()); -+ DCHECK(caller_registers_saved_); -+ caller_registers_saved_ = false; -+ break; -+ } -+ case kArchPrepareTailCall: -+ AssemblePrepareTailCall(); -+ break; -+ case kArchCallCFunction: { -+ int const num_parameters = MiscField::decode(instr->opcode()); -+ Label start_call; -+ bool isWasmCapiFunction = -+ linkage()->GetIncomingDescriptor()->IsWasmCapiFunction(); -+ // from start_call to return address. -+ int offset = __ root_array_available() ? 44 : 80; // 11 or 20 instrs -+#if V8_HOST_ARCH_LA64 -+ if (__ emit_debug_code()) { -+ offset += 12; // see CallCFunction -+ } -+#endif -+ if (isWasmCapiFunction) { -+ // Put the return address in a stack slot. -+ // __ mov(kScratchReg, ra); -+ __ bind(&start_call); -+ __ pcaddi(t7, -4); // __ nal(); -+ //__ nop(); -+ //__ Daddu(ra, ra, offset - 8); // 8 = nop + nal -+ __ St_d(t7, MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset)); -+ // __ mov(ra, kScratchReg); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ ExternalReference ref = i.InputExternalReference(0); -+ __ CallCFunction(ref, num_parameters); -+ } else { -+ Register func = i.InputRegister(0); -+ __ CallCFunction(func, num_parameters); -+ } -+ if (isWasmCapiFunction) { -+ CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call)); -+ RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt); -+ } -+ -+ frame_access_state()->SetFrameAccessToDefault(); -+ // Ideally, we should decrement SP delta to match the change of stack -+ // pointer in CallCFunction. However, for certain architectures (e.g. -+ // ARM), there may be more strict alignment requirement, causing old SP -+ // to be saved on the stack. In those cases, we can not calculate the SP -+ // delta statically. -+ frame_access_state()->ClearSPDelta(); -+ if (caller_registers_saved_) { -+ // Need to re-sync SP delta introduced in kArchSaveCallerRegisters. -+ // Here, we assume the sequence to be: -+ // kArchSaveCallerRegisters; -+ // kArchCallCFunction; -+ // kArchRestoreCallerRegisters; -+ int bytes = -+ __ RequiredStackSizeForCallerSaved(fp_mode_, kReturnRegister0); -+ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); -+ } -+ break; -+ } -+ case kArchJmp: -+ AssembleArchJump(i.InputRpo(0)); -+ break; -+ case kArchBinarySearchSwitch: -+ AssembleArchBinarySearchSwitch(instr); -+ break; -+ break; -+ case kArchTableSwitch: -+ AssembleArchTableSwitch(instr); -+ break; -+ case kArchAbortCSAAssert: -+ DCHECK(i.InputRegister(0) == a0); -+ { -+ // We don't actually want to generate a pile of code for this, so just -+ // claim there is a stack frame, without generating one. -+ FrameScope scope(tasm(), StackFrame::NONE); -+ __ Call( -+ isolate()->builtins()->builtin_handle(Builtins::kAbortCSAAssert), -+ RelocInfo::CODE_TARGET); -+ } -+ __ stop(); -+ break; -+ case kArchDebugBreak: -+ __ DebugBreak(); -+ break; -+ case kArchComment: -+ __ RecordComment(reinterpret_cast(i.InputInt64(0))); -+ break; -+ case kArchNop: -+ case kArchThrowTerminator: -+ // don't emit code for nops. -+ break; -+ case kArchDeoptimize: { -+ DeoptimizationExit* exit = -+ BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); -+ CodeGenResult result = AssembleDeoptimizerCall(exit); -+ if (result != kSuccess) return result; -+ break; -+ } -+ case kArchRet: -+ AssembleReturn(instr->InputAt(0)); -+ break; -+ case kArchStackPointerGreaterThan: -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kArchStackCheckOffset: -+ __ Move(i.OutputRegister(), Smi::FromInt(GetStackCheckOffset())); -+ break; -+ case kArchFramePointer: -+ __ mov(i.OutputRegister(), fp); -+ break; -+ case kArchParentFramePointer: -+ if (frame_access_state()->has_frame()) { -+ __ Ld_d(i.OutputRegister(), MemOperand(fp, 0)); -+ } else { -+ __ mov(i.OutputRegister(), fp); -+ } -+ break; -+ case kArchTruncateDoubleToI: -+ __ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(), -+ i.InputDoubleRegister(0), DetermineStubCallMode()); -+ break; -+ case kArchStoreWithWriteBarrier: { -+ RecordWriteMode mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ Register object = i.InputRegister(0); -+ Register index = i.InputRegister(1); -+ Register value = i.InputRegister(2); -+ Register scratch0 = i.TempRegister(0); -+ Register scratch1 = i.TempRegister(1); -+ auto ool = zone()->New(this, object, index, value, -+ scratch0, scratch1, mode, -+ DetermineStubCallMode()); -+ __ Add_d(kScratchReg, object, index); -+ __ St_d(value, MemOperand(kScratchReg, 0)); -+ __ CheckPageFlag(object, scratch0, -+ MemoryChunk::kPointersFromHereAreInterestingMask, ne, -+ ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kArchStackSlot: { -+ FrameOffset offset = -+ frame_access_state()->GetFrameOffset(i.InputInt32(0)); -+ Register base_reg = offset.from_stack_pointer() ? sp : fp; -+ __ Add_d(i.OutputRegister(), base_reg, Operand(offset.offset())); -+ int alignment = i.InputInt32(1); -+ DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || -+ alignment == 16); -+ if (FLAG_debug_code && alignment > 0) { -+ // Verify that the output_register is properly aligned -+ __ And(kScratchReg, i.OutputRegister(), -+ Operand(kSystemPointerSize - 1)); -+ __ Assert(eq, AbortReason::kAllocationIsNotDoubleAligned, kScratchReg, -+ Operand(zero_reg)); -+ } -+ if (alignment == 2 * kSystemPointerSize) { -+ Label done; -+ __ Add_d(kScratchReg, base_reg, Operand(offset.offset())); -+ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); -+ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); -+ __ Add_d(i.OutputRegister(), i.OutputRegister(), kSystemPointerSize); -+ __ bind(&done); -+ } else if (alignment > 2 * kSystemPointerSize) { -+ Label done; -+ __ Add_d(kScratchReg, base_reg, Operand(offset.offset())); -+ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); -+ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); -+ __ li(kScratchReg2, alignment); -+ __ Sub_d(kScratchReg2, kScratchReg2, Operand(kScratchReg)); -+ __ Add_d(i.OutputRegister(), i.OutputRegister(), kScratchReg2); -+ __ bind(&done); -+ } -+ -+ break; -+ } -+ case kArchWordPoisonOnSpeculation: -+ __ And(i.OutputRegister(), i.InputRegister(0), -+ kSpeculationPoisonRegister); -+ break; -+ case kIeee754Float64Acos: -+ ASSEMBLE_IEEE754_UNOP(acos); -+ break; -+ case kIeee754Float64Acosh: -+ ASSEMBLE_IEEE754_UNOP(acosh); -+ break; -+ case kIeee754Float64Asin: -+ ASSEMBLE_IEEE754_UNOP(asin); -+ break; -+ case kIeee754Float64Asinh: -+ ASSEMBLE_IEEE754_UNOP(asinh); -+ break; -+ case kIeee754Float64Atan: -+ ASSEMBLE_IEEE754_UNOP(atan); -+ break; -+ case kIeee754Float64Atanh: -+ ASSEMBLE_IEEE754_UNOP(atanh); -+ break; -+ case kIeee754Float64Atan2: -+ ASSEMBLE_IEEE754_BINOP(atan2); -+ break; -+ case kIeee754Float64Cos: -+ ASSEMBLE_IEEE754_UNOP(cos); -+ break; -+ case kIeee754Float64Cosh: -+ ASSEMBLE_IEEE754_UNOP(cosh); -+ break; -+ case kIeee754Float64Cbrt: -+ ASSEMBLE_IEEE754_UNOP(cbrt); -+ break; -+ case kIeee754Float64Exp: -+ ASSEMBLE_IEEE754_UNOP(exp); -+ break; -+ case kIeee754Float64Expm1: -+ ASSEMBLE_IEEE754_UNOP(expm1); -+ break; -+ case kIeee754Float64Log: -+ ASSEMBLE_IEEE754_UNOP(log); -+ break; -+ case kIeee754Float64Log1p: -+ ASSEMBLE_IEEE754_UNOP(log1p); -+ break; -+ case kIeee754Float64Log2: -+ ASSEMBLE_IEEE754_UNOP(log2); -+ break; -+ case kIeee754Float64Log10: -+ ASSEMBLE_IEEE754_UNOP(log10); -+ break; -+ case kIeee754Float64Pow: -+ ASSEMBLE_IEEE754_BINOP(pow); -+ break; -+ case kIeee754Float64Sin: -+ ASSEMBLE_IEEE754_UNOP(sin); -+ break; -+ case kIeee754Float64Sinh: -+ ASSEMBLE_IEEE754_UNOP(sinh); -+ break; -+ case kIeee754Float64Tan: -+ ASSEMBLE_IEEE754_UNOP(tan); -+ break; -+ case kIeee754Float64Tanh: -+ ASSEMBLE_IEEE754_UNOP(tanh); -+ break; -+ case kLa64Add: -+ __ Add_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Dadd: -+ __ Add_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64DaddOvf: -+ __ AdddOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), -+ kScratchReg); -+ break; -+ case kLa64Sub: -+ __ Sub_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Dsub: -+ __ Sub_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64DsubOvf: -+ __ SubdOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), -+ kScratchReg); -+ break; -+ case kLa64Mul: -+ __ Mul_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64MulOvf: -+ __ MulOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), -+ kScratchReg); -+ break; -+ case kLa64MulHigh: -+ __ Mulh_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64MulHighU: -+ __ Mulh_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64DMulHigh: -+ __ Mulh_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Div: -+ __ Div_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ break; -+ case kLa64DivU: -+ __ Div_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ break; -+ case kLa64Mod: -+ __ Mod_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64ModU: -+ __ Mod_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Dmul: -+ __ Mul_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Ddiv: -+ __ Div_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ break; -+ case kLa64DdivU: -+ __ Div_du(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ break; -+ case kLa64Dmod: -+ __ Mod_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64DmodU: -+ __ Mod_du(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Dlsa: -+ DCHECK(instr->InputAt(2)->IsImmediate()); -+ __ Alsl_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), -+ i.InputInt8(2), t7); -+ break; -+ case kLa64Lsa: -+ DCHECK(instr->InputAt(2)->IsImmediate()); -+ __ Alsl_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), -+ i.InputInt8(2), t7); -+ break; -+ case kLa64And: -+ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64And32: -+ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kLa64Or: -+ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Or32: -+ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kLa64Nor: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ } else { -+ DCHECK_EQ(0, i.InputOperand(1).immediate()); -+ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); -+ } -+ break; -+ case kLa64Nor32: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); -+ } else { -+ DCHECK_EQ(0, i.InputOperand(1).immediate()); -+ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); -+ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); -+ } -+ break; -+ case kLa64Xor: -+ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Xor32: -+ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kLa64Clz: -+ __ Clz_w(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kLa64Dclz: -+ __ clz_d(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kLa64Ctz: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Ctz_w(dst, src); -+ } break; -+ case kLa64Dctz: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Ctz_d(dst, src); -+ } break; -+ case kLa64Popcnt: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Popcnt_w(dst, src); -+ } break; -+ case kLa64Dpopcnt: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Popcnt_d(dst, src); -+ } break; -+ case kLa64Shl: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ sll_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ slli_w(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kLa64Shr: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ slli_w(i.InputRegister(0), i.InputRegister(0), 0x0); -+ __ srl_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ slli_w(i.OutputRegister(), i.InputRegister(0), 0x0); -+ __ srli_w(i.OutputRegister(), i.OutputRegister(), -+ static_cast(imm)); -+ } -+ break; -+ case kLa64Sar: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ slli_w(i.InputRegister(0), i.InputRegister(0), 0x0); -+ __ sra_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ slli_w(i.OutputRegister(), i.InputRegister(0), 0x0); -+ __ srai_w(i.OutputRegister(), i.OutputRegister(), -+ static_cast(imm)); -+ } -+ break; -+ case kLa64Ext: -+ __ bstrpick_w(i.OutputRegister(), i.InputRegister(0), -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ break; -+ case kLa64Ins: -+ if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { -+ __ bstrins_w(i.OutputRegister(), zero_reg, -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ } else { -+ __ bstrins_w(i.OutputRegister(), i.InputRegister(0), -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ } -+ break; -+ case kLa64Dext: { -+ __ bstrpick_d(i.OutputRegister(), i.InputRegister(0), -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ break; -+ } -+ case kLa64Dins: -+ if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { -+ __ bstrins_d(i.OutputRegister(), zero_reg, -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ } else { -+ __ bstrins_d(i.OutputRegister(), i.InputRegister(0), -+ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); -+ } -+ break; -+ case kLa64Dshl: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ sll_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ slli_d(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kLa64Dshr: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ srl_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ srli_d(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kLa64Dsar: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ sra_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ srai_d(i.OutputRegister(), i.InputRegister(0), imm); -+ } -+ break; -+ case kLa64Ror: -+ __ Rotr_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Dror: -+ __ Rotr_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kLa64Tst: -+ __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kLa64Cmp: -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kLa64Mov: -+ // TODO(plind): Should we combine mov/li like this, or use separate instr? -+ // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType -+ if (HasRegisterInput(instr, 0)) { -+ __ mov(i.OutputRegister(), i.InputRegister(0)); -+ } else { -+ __ li(i.OutputRegister(), i.InputOperand(0)); -+ } -+ break; -+ -+ case kLa64CmpS: { -+ FPURegister left = i.InputOrZeroSingleRegister(0); -+ FPURegister right = i.InputOrZeroSingleRegister(1); -+ bool predicate; -+ FPUCondition cc = -+ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); -+ -+ if ((left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ CompareF32(left, right, cc); -+ } break; -+ case kLa64AddS: -+ // TODO(plind): add special case: combine mult & add. -+ __ fadd_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64SubS: -+ __ fsub_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64MulS: -+ // TODO(plind): add special case: right op is -1.0, see arm port. -+ __ fmul_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64DivS: -+ __ fdiv_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64ModS: { -+ // TODO(bmeurer): We should really get rid of this special instruction, -+ // and generate a CallAddress instruction instead. -+ FrameScope scope(tasm(), StackFrame::MANUAL); -+ __ PrepareCallCFunction(0, 2, kScratchReg); -+ __ MovToFloatParameters(i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ // TODO(balazs.kilvady): implement mod_two_floats_operation(isolate()) -+ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); -+ // Move the result in the double result register. -+ __ MovFromFloatResult(i.OutputSingleRegister()); -+ break; -+ } -+ case kLa64AbsS: -+ __ fabs_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kLa64NegS: -+ __ Neg_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kLa64SqrtS: { -+ __ fsqrt_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64MaxS: -+ __ fmax_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64MinS: -+ __ fmin_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64CmpD: { -+ FPURegister left = i.InputOrZeroDoubleRegister(0); -+ FPURegister right = i.InputOrZeroDoubleRegister(1); -+ bool predicate; -+ FPUCondition cc = -+ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); -+ if ((left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ CompareF64(left, right, cc); -+ } break; -+ case kLa64AddD: -+ // TODO(plind): add special case: combine mult & add. -+ __ fadd_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64SubD: -+ __ fsub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64MulD: -+ // TODO(plind): add special case: right op is -1.0, see arm port. -+ __ fmul_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64DivD: -+ __ fdiv_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64ModD: { -+ // TODO(bmeurer): We should really get rid of this special instruction, -+ // and generate a CallAddress instruction instead. -+ FrameScope scope(tasm(), StackFrame::MANUAL); -+ __ PrepareCallCFunction(0, 2, kScratchReg); -+ __ MovToFloatParameters(i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); -+ // Move the result in the double result register. -+ __ MovFromFloatResult(i.OutputDoubleRegister()); -+ break; -+ } -+ case kLa64AbsD: -+ __ fabs_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64NegD: -+ __ Neg_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64SqrtD: { -+ __ fsqrt_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64MaxD: -+ __ fmax_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64MinD: -+ __ fmin_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kLa64Float64RoundDown: { -+ __ Floor_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64Float32RoundDown: { -+ __ Floor_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ } -+ case kLa64Float64RoundTruncate: { -+ __ Trunc_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64Float32RoundTruncate: { -+ __ Trunc_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ } -+ case kLa64Float64RoundUp: { -+ __ Ceil_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64Float32RoundUp: { -+ __ Ceil_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ } -+ case kLa64Float64RoundTiesEven: { -+ __ Round_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kLa64Float32RoundTiesEven: { -+ __ Round_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ } -+ case kLa64Float32Max: { -+ FPURegister dst = i.OutputSingleRegister(); -+ FPURegister src1 = i.InputSingleRegister(0); -+ FPURegister src2 = i.InputSingleRegister(1); -+ auto ool = zone()->New(this, dst, src1, src2); -+ __ Float32Max(dst, src1, src2, ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kLa64Float64Max: { -+ FPURegister dst = i.OutputDoubleRegister(); -+ FPURegister src1 = i.InputDoubleRegister(0); -+ FPURegister src2 = i.InputDoubleRegister(1); -+ auto ool = zone()->New(this, dst, src1, src2); -+ __ Float64Max(dst, src1, src2, ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kLa64Float32Min: { -+ FPURegister dst = i.OutputSingleRegister(); -+ FPURegister src1 = i.InputSingleRegister(0); -+ FPURegister src2 = i.InputSingleRegister(1); -+ auto ool = zone()->New(this, dst, src1, src2); -+ __ Float32Min(dst, src1, src2, ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kLa64Float64Min: { -+ FPURegister dst = i.OutputDoubleRegister(); -+ FPURegister src1 = i.InputDoubleRegister(0); -+ FPURegister src2 = i.InputDoubleRegister(1); -+ auto ool = zone()->New(this, dst, src1, src2); -+ __ Float64Min(dst, src1, src2, ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kLa64Float64SilenceNaN: -+ __ FPUCanonicalizeNaN(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64CvtSD: -+ __ fcvt_s_d(i.OutputSingleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64CvtDS: -+ __ fcvt_d_s(i.OutputDoubleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kLa64CvtDW: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ movgr2fr_w(scratch, i.InputRegister(0)); -+ __ ffint_d_w(i.OutputDoubleRegister(), scratch); -+ break; -+ } -+ case kLa64CvtSW: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ movgr2fr_w(scratch, i.InputRegister(0)); -+ __ ffint_s_w(i.OutputDoubleRegister(), scratch); -+ break; -+ } -+ case kLa64CvtSUw: { -+ __ Ffint_s_uw(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kLa64CvtSL: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ movgr2fr_d(scratch, i.InputRegister(0)); -+ __ ffint_s_l(i.OutputDoubleRegister(), scratch); -+ break; -+ } -+ case kLa64CvtDL: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ movgr2fr_d(scratch, i.InputRegister(0)); -+ __ ffint_d_l(i.OutputDoubleRegister(), scratch); -+ break; -+ } -+ case kLa64CvtDUw: { -+ __ Ffint_d_uw(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kLa64CvtDUl: { -+ __ Ffint_d_ul(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kLa64CvtSUl: { -+ __ Ffint_s_ul(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kLa64FloorWD: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrm_w_d(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64CeilWD: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrp_w_d(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64RoundWD: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrne_w_d(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64TruncWD: { -+ FPURegister scratch = kScratchDoubleReg; -+ // Other arches use round to zero here, so we follow. -+ __ ftintrz_w_d(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64FloorWS: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrm_w_s(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64CeilWS: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrp_w_s(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64RoundWS: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrne_w_s(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ break; -+ } -+ case kLa64TruncWS: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ ftintrz_w_s(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_s(i.OutputRegister(), scratch); -+ // Avoid INT32_MAX as an overflow indicator and use INT32_MIN instead, -+ // because INT32_MIN allows easier out-of-bounds detection. -+ __ addi_w(kScratchReg, i.OutputRegister(), 1); -+ __ slt(kScratchReg2, kScratchReg, i.OutputRegister()); -+ __ Movn(i.OutputRegister(), kScratchReg, kScratchReg2); -+ break; -+ } -+ case kLa64TruncLS: { -+ FPURegister scratch = kScratchDoubleReg; -+ Register tmp_fcsr = kScratchReg; -+ Register result = kScratchReg2; -+ -+ bool load_status = instr->OutputCount() > 1; -+ if (load_status) { -+ // Save FCSR. -+ __ movfcsr2gr(tmp_fcsr); // __ cfc1(tmp_fcsr, FCSR); -+ // Clear FPU flags. -+ __ movgr2fcsr(zero_reg); // __ ctc1(zero_reg, FCSR); -+ } -+ // Other arches use round to zero here, so we follow. -+ __ ftintrz_l_s(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_d(i.OutputRegister(), scratch); -+ if (load_status) { -+ __ movfcsr2gr(result); // __ cfc1(result, FCSR); -+ // Check for overflow and NaNs. -+ __ And(result, result, -+ (kFCSROverflowFlagMask | kFCSRInvalidOpFlagMask)); -+ __ Slt(result, zero_reg, result); -+ __ xori(result, result, 1); -+ __ mov(i.OutputRegister(1), result); -+ // Restore FCSR -+ __ movgr2fcsr(tmp_fcsr); // __ ctc1(tmp_fcsr, FCSR); -+ } -+ break; -+ } -+ case kLa64TruncLD: { -+ FPURegister scratch = kScratchDoubleReg; -+ Register tmp_fcsr = kScratchReg; -+ Register result = kScratchReg2; -+ -+ bool load_status = instr->OutputCount() > 1; -+ if (load_status) { -+ // Save FCSR. -+ __ movfcsr2gr(tmp_fcsr); // __ cfc1(tmp_fcsr, FCSR); -+ // Clear FPU flags. -+ __ movgr2fcsr(zero_reg); // __ ctc1(zero_reg, FCSR); -+ } -+ // Other arches use round to zero here, so we follow. -+ __ ftintrz_l_d(scratch, i.InputDoubleRegister(0)); -+ __ movfr2gr_d(i.OutputRegister(0), scratch); -+ if (load_status) { -+ __ movfcsr2gr(result); // __ cfc1(result, FCSR); -+ // Check for overflow and NaNs. -+ __ And(result, result, -+ (kFCSROverflowFlagMask | kFCSRInvalidOpFlagMask)); -+ __ Slt(result, zero_reg, result); -+ __ xori(result, result, 1); -+ __ mov(i.OutputRegister(1), result); -+ // Restore FCSR -+ __ movgr2fcsr(tmp_fcsr); // __ ctc1(tmp_fcsr, FCSR); -+ } -+ break; -+ } -+ case kLa64TruncUwD: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ Ftintrz_uw_d(i.OutputRegister(), i.InputDoubleRegister(0), scratch); -+ break; -+ } -+ case kLa64TruncUwS: { -+ FPURegister scratch = kScratchDoubleReg; -+ __ Ftintrz_uw_s(i.OutputRegister(), i.InputDoubleRegister(0), scratch); -+ // Avoid UINT32_MAX as an overflow indicator and use 0 instead, -+ // because 0 allows easier out-of-bounds detection. -+ __ addi_w(kScratchReg, i.OutputRegister(), 1); -+ __ Movz(i.OutputRegister(), zero_reg, kScratchReg); -+ break; -+ } -+ case kLa64TruncUlS: { -+ FPURegister scratch = kScratchDoubleReg; -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Ftintrz_ul_s(i.OutputRegister(), i.InputDoubleRegister(0), scratch, -+ result); -+ break; -+ } -+ case kLa64TruncUlD: { -+ FPURegister scratch = kScratchDoubleReg; -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Ftintrz_ul_d(i.OutputRegister(0), i.InputDoubleRegister(0), scratch, -+ result); -+ break; -+ } -+ case kLa64BitcastDL: -+ __ movfr2gr_d(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64BitcastLD: -+ __ movgr2fr_d(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ case kLa64Float64ExtractLowWord32: -+ __ FmoveLow(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64Float64ExtractHighWord32: -+ __ movfrh2gr_s(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kLa64Float64InsertLowWord32: -+ __ FmoveLow(i.OutputDoubleRegister(), i.InputRegister(1)); -+ break; -+ case kLa64Float64InsertHighWord32: -+ __ movgr2frh_w(i.OutputDoubleRegister(), i.InputRegister(1)); -+ break; -+ // ... more basic instructions ... -+ -+ case kLa64Seb: -+ __ ext_w_b(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kLa64Seh: -+ __ ext_w_h(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kLa64Lbu: -+ __ Ld_bu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Lb: -+ __ Ld_b(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Sb: -+ __ St_b(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Lhu: -+ __ Ld_hu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Ulhu: -+ __ Ld_hu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Lh: -+ __ Ld_h(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Ulh: -+ __ Ld_h(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Sh: -+ __ St_h(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Ush: -+ __ St_h(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Lw: -+ __ Ld_w(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Ulw: -+ __ Ld_w(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Lwu: -+ __ Ld_wu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Ulwu: -+ __ Ld_wu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Ld: -+ __ Ld_d(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Uld: -+ __ Ld_d(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kLa64Sw: -+ __ St_w(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Usw: -+ __ St_w(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Sd: -+ __ St_d(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Usd: -+ __ St_d(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kLa64Lwc1: { -+ __ Fld_s(i.OutputSingleRegister(), i.MemoryOperand()); -+ break; -+ } -+ case kLa64Ulwc1: { -+ __ Fld_s(i.OutputSingleRegister(), i.MemoryOperand()); -+ break; -+ } -+ case kLa64Swc1: { -+ size_t index = 0; -+ MemOperand operand = i.MemoryOperand(&index); -+ FPURegister ft = i.InputOrZeroSingleRegister(index); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ Fst_s(ft, operand); -+ break; -+ } -+ case kLa64Uswc1: { -+ size_t index = 0; -+ MemOperand operand = i.MemoryOperand(&index); -+ FPURegister ft = i.InputOrZeroSingleRegister(index); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ Fst_s(ft, operand); -+ break; -+ } -+ case kLa64Ldc1: -+ __ Fld_d(i.OutputDoubleRegister(), i.MemoryOperand()); -+ break; -+ case kLa64Uldc1: -+ __ Fld_d(i.OutputDoubleRegister(), i.MemoryOperand()); -+ break; -+ case kLa64Sdc1: { -+ FPURegister ft = i.InputOrZeroDoubleRegister(2); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ Fst_d(ft, i.MemoryOperand()); -+ break; -+ } -+ case kLa64Usdc1: { -+ FPURegister ft = i.InputOrZeroDoubleRegister(2); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ -+ __ Fst_d(ft, i.MemoryOperand()); -+ break; -+ } -+ case kLa64Sync: { -+ __ dbar(0); -+ break; -+ } -+ case kLa64Push: -+ if (instr->InputAt(0)->IsFPRegister()) { -+ __ Fst_d(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); -+ __ Sub_d(sp, sp, Operand(kDoubleSize)); -+ frame_access_state()->IncreaseSPDelta(kDoubleSize / kSystemPointerSize); -+ } else { -+ __ Push(i.InputRegister(0)); -+ frame_access_state()->IncreaseSPDelta(1); -+ } -+ break; -+ case kLa64Peek: { -+ int reverse_slot = i.InputInt32(0); -+ int offset = -+ FrameSlotToFPOffset(frame()->GetTotalFrameSlotCount() - reverse_slot); -+ if (instr->OutputAt(0)->IsFPRegister()) { -+ LocationOperand* op = LocationOperand::cast(instr->OutputAt(0)); -+ if (op->representation() == MachineRepresentation::kFloat64) { -+ __ Fld_d(i.OutputDoubleRegister(), MemOperand(fp, offset)); -+ } else if (op->representation() == MachineRepresentation::kFloat32) { -+ __ Fld_s( -+ i.OutputSingleRegister(0), -+ MemOperand(fp, offset + kLessSignificantWordInDoublewordOffset)); -+ } else { -+ DCHECK_EQ(MachineRepresentation::kSimd128, op->representation()); -+ abort(); -+ } -+ } else { -+ __ Ld_d(i.OutputRegister(0), MemOperand(fp, offset)); -+ } -+ break; -+ } -+ case kLa64StackClaim: { -+ __ Sub_d(sp, sp, Operand(i.InputInt32(0))); -+ frame_access_state()->IncreaseSPDelta(i.InputInt32(0) / -+ kSystemPointerSize); -+ break; -+ } -+ case kLa64StoreToStackSlot: { -+ if (instr->InputAt(0)->IsFPRegister()) { -+ __ Fst_d(i.InputDoubleRegister(0), MemOperand(sp, i.InputInt32(1))); -+ } else { -+ __ St_d(i.InputRegister(0), MemOperand(sp, i.InputInt32(1))); -+ } -+ break; -+ } -+ case kLa64ByteSwap64: { -+ __ ByteSwapSigned(i.OutputRegister(0), i.InputRegister(0), 8); -+ break; -+ } -+ case kLa64ByteSwap32: { -+ __ ByteSwapSigned(i.OutputRegister(0), i.InputRegister(0), 4); -+ break; -+ } -+ case kWord32AtomicLoadInt8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_b); -+ break; -+ case kWord32AtomicLoadUint8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_bu); -+ break; -+ case kWord32AtomicLoadInt16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_h); -+ break; -+ case kWord32AtomicLoadUint16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_hu); -+ break; -+ case kWord32AtomicLoadWord32: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_w); -+ break; -+ case kLa64Word64AtomicLoadUint8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_bu); -+ break; -+ case kLa64Word64AtomicLoadUint16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_hu); -+ break; -+ case kLa64Word64AtomicLoadUint32: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_wu); -+ break; -+ case kLa64Word64AtomicLoadUint64: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_d); -+ break; -+ case kWord32AtomicStoreWord8: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_b); -+ break; -+ case kWord32AtomicStoreWord16: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_h); -+ break; -+ case kWord32AtomicStoreWord32: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_w); -+ break; -+ case kLa64Word64AtomicStoreWord8: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_b); -+ break; -+ case kLa64Word64AtomicStoreWord16: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_h); -+ break; -+ case kLa64Word64AtomicStoreWord32: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_w); -+ break; -+ case kLa64Word64AtomicStoreWord64: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(St_d); -+ break; -+ case kWord32AtomicExchangeInt8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 8, 32); -+ break; -+ case kWord32AtomicExchangeUint8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 8, 32); -+ break; -+ case kWord32AtomicExchangeInt16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 16, 32); -+ break; -+ case kWord32AtomicExchangeUint16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 16, 32); -+ break; -+ case kWord32AtomicExchangeWord32: -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amswap_db_w(i.OutputRegister(0), i.InputRegister(2), -+ i.TempRegister(0)); -+ break; -+ case kLa64Word64AtomicExchangeUint8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 8, 64); -+ break; -+ case kLa64Word64AtomicExchangeUint16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 16, 64); -+ break; -+ case kLa64Word64AtomicExchangeUint32: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 32, 64); -+ break; -+ case kLa64Word64AtomicExchangeUint64: -+ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amswap_db_d(i.OutputRegister(0), i.InputRegister(2), -+ i.TempRegister(0)); -+ break; -+ case kWord32AtomicCompareExchangeInt8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 8, 32); -+ break; -+ case kWord32AtomicCompareExchangeUint8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 8, 32); -+ break; -+ case kWord32AtomicCompareExchangeInt16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 16, 32); -+ break; -+ case kWord32AtomicCompareExchangeUint16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 16, 32); -+ break; -+ case kWord32AtomicCompareExchangeWord32: -+ __ slli_w(i.InputRegister(2), i.InputRegister(2), 0); -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll_w, Sc_w); -+ break; -+ case kLa64Word64AtomicCompareExchangeUint8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 8, 64); -+ break; -+ case kLa64Word64AtomicCompareExchangeUint16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 16, 64); -+ break; -+ case kLa64Word64AtomicCompareExchangeUint32: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 32, 64); -+ break; -+ case kLa64Word64AtomicCompareExchangeUint64: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll_d, Sc_d); -+ break; -+ case kWord32AtomicAddWord32: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amadd_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kWord32AtomicSubWord32: -+ ASSEMBLE_ATOMIC_BINOP(Ll_w, Sc_w, Sub_w); -+ break; -+ case kWord32AtomicAndWord32: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amand_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kWord32AtomicOrWord32: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amor_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kWord32AtomicXorWord32: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amxor_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+#define ATOMIC_BINOP_CASE(op, inst) \ -+ case kWord32Atomic##op##Int8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, true, 8, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Uint8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, false, 8, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Int16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, true, 16, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Uint16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, false, 16, inst, 32); \ -+ break; -+ ATOMIC_BINOP_CASE(Add, Add_w) -+ ATOMIC_BINOP_CASE(Sub, Sub_w) -+ ATOMIC_BINOP_CASE(And, And) -+ ATOMIC_BINOP_CASE(Or, Or) -+ ATOMIC_BINOP_CASE(Xor, Xor) -+#undef ATOMIC_BINOP_CASE -+ -+ case kLa64Word64AtomicAddUint64: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amadd_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kLa64Word64AtomicSubUint64: -+ ASSEMBLE_ATOMIC_BINOP(Ll_d, Sc_d, Sub_d); -+ break; -+ case kLa64Word64AtomicAndUint64: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amand_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kLa64Word64AtomicOrUint64: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amor_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+ case kLa64Word64AtomicXorUint64: -+ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); -+ __ amxor_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); -+ break; -+#define ATOMIC_BINOP_CASE(op, inst) \ -+ case kLa64Word64Atomic##op##Uint8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 8, inst, 64); \ -+ break; \ -+ case kLa64Word64Atomic##op##Uint16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 16, inst, 64); \ -+ break; \ -+ case kLa64Word64Atomic##op##Uint32: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 32, inst, 64); \ -+ break; -+ ATOMIC_BINOP_CASE(Add, Add_d) -+ ATOMIC_BINOP_CASE(Sub, Sub_d) -+ ATOMIC_BINOP_CASE(And, And) -+ ATOMIC_BINOP_CASE(Or, Or) -+ ATOMIC_BINOP_CASE(Xor, Xor) -+#undef ATOMIC_BINOP_CASE -+ case kLa64AssertEqual: -+ __ Assert(eq, static_cast(i.InputOperand(2).immediate()), -+ i.InputRegister(0), Operand(i.InputRegister(1))); -+ break; -+ case kLa64S128Const: -+ case kLa64S128Zero: -+ case kLa64I32x4Splat: -+ case kLa64I32x4ExtractLane: -+ case kLa64I32x4AddHoriz: -+ case kLa64I32x4Add: -+ case kLa64I32x4ReplaceLane: -+ case kLa64I32x4Sub: -+ case kLa64F64x2Abs: -+ default: -+ break; -+ } -+ return kSuccess; -+} // NOLINT(readability/fn_size) -+ -+#define UNSUPPORTED_COND(opcode, condition) \ -+ StdoutStream{} << "Unsupported " << #opcode << " condition: \"" << condition \ -+ << "\""; \ -+ UNIMPLEMENTED(); -+ -+void AssembleBranchToLabels(CodeGenerator* gen, TurboAssembler* tasm, -+ Instruction* instr, FlagsCondition condition, -+ Label* tlabel, Label* flabel, bool fallthru) { -+#undef __ -+#define __ tasm-> -+ La64OperandConverter i(gen, instr); -+ -+ Condition cc = kNoCondition; -+ // LA64 does not have condition code flags, so compare and branch are -+ // implemented differently than on the other arch's. The compare operations -+ // emit la64 pseudo-instructions, which are handled here by branch -+ // instructions that do the actual comparison. Essential that the input -+ // registers to compare pseudo-op are not modified before this branch op, as -+ // they are tested here. -+ -+ if (instr->arch_opcode() == kLa64Tst) { -+ cc = FlagsConditionToConditionTst(condition); -+ __ Branch(tlabel, cc, kScratchReg, Operand(zero_reg)); -+ } else if (instr->arch_opcode() == kLa64Dadd || -+ instr->arch_opcode() == kLa64Dsub) { -+ cc = FlagsConditionToConditionOvf(condition); -+ __ srai_d(kScratchReg, i.OutputRegister(), 32); -+ __ srai_w(kScratchReg2, i.OutputRegister(), 31); -+ __ Branch(tlabel, cc, kScratchReg2, Operand(kScratchReg)); -+ } else if (instr->arch_opcode() == kLa64DaddOvf || -+ instr->arch_opcode() == kLa64DsubOvf) { -+ switch (condition) { -+ // Overflow occurs if overflow register is negative -+ case kOverflow: -+ __ Branch(tlabel, lt, kScratchReg, Operand(zero_reg)); -+ break; -+ case kNotOverflow: -+ __ Branch(tlabel, ge, kScratchReg, Operand(zero_reg)); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ break; -+ } -+ } else if (instr->arch_opcode() == kLa64MulOvf) { -+ // Overflow occurs if overflow register is not zero -+ switch (condition) { -+ case kOverflow: -+ __ Branch(tlabel, ne, kScratchReg, Operand(zero_reg)); -+ break; -+ case kNotOverflow: -+ __ Branch(tlabel, eq, kScratchReg, Operand(zero_reg)); -+ break; -+ default: -+ UNSUPPORTED_COND(kLa64MulOvf, condition); -+ break; -+ } -+ } else if (instr->arch_opcode() == kLa64Cmp) { -+ cc = FlagsConditionToConditionCmp(condition); -+ __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); -+ } else if (instr->arch_opcode() == kArchStackPointerGreaterThan) { -+ cc = FlagsConditionToConditionCmp(condition); -+ Register lhs_register = sp; -+ uint32_t offset; -+ if (gen->ShouldApplyOffsetToStackCheck(instr, &offset)) { -+ lhs_register = i.TempRegister(0); -+ __ Sub_d(lhs_register, sp, offset); -+ } -+ __ Branch(tlabel, cc, lhs_register, Operand(i.InputRegister(0))); -+ } else if (instr->arch_opcode() == kLa64CmpS || -+ instr->arch_opcode() == kLa64CmpD) { -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ if (predicate) { -+ __ BranchTrueF(tlabel); -+ } else { -+ __ BranchFalseF(tlabel); -+ } -+ } else { -+ PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", -+ instr->arch_opcode()); -+ UNIMPLEMENTED(); -+ } -+ if (!fallthru) __ Branch(flabel); // no fallthru to flabel. -+#undef __ -+#define __ tasm()-> -+} -+ -+// Assembles branches after an instruction. -+void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { -+ Label* tlabel = branch->true_label; -+ Label* flabel = branch->false_label; -+ -+ AssembleBranchToLabels(this, tasm(), instr, branch->condition, tlabel, flabel, -+ branch->fallthru); -+} -+ -+void CodeGenerator::AssembleBranchPoisoning(FlagsCondition condition, -+ Instruction* instr) { -+ // TODO(jarin) Handle float comparisons (kUnordered[Not]Equal). -+ if (condition == kUnorderedEqual || condition == kUnorderedNotEqual) { -+ return; -+ } -+ -+ La64OperandConverter i(this, instr); -+ condition = NegateFlagsCondition(condition); -+ -+ switch (instr->arch_opcode()) { -+ case kLa64Cmp: { -+ __ LoadZeroOnCondition(kSpeculationPoisonRegister, i.InputRegister(0), -+ i.InputOperand(1), -+ FlagsConditionToConditionCmp(condition)); -+ } -+ return; -+ case kLa64Tst: { -+ switch (condition) { -+ case kEqual: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); -+ break; -+ case kNotEqual: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ return; -+ case kLa64Dadd: -+ case kLa64Dsub: { -+ // Check for overflow creates 1 or 0 for result. -+ __ srli_d(kScratchReg, i.OutputRegister(), 63); -+ __ srli_w(kScratchReg2, i.OutputRegister(), 31); -+ __ xor_(kScratchReg2, kScratchReg, kScratchReg2); -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg2); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kLa64DaddOvf: -+ case kLa64DsubOvf: { -+ // Overflow occurs if overflow register is negative -+ __ Slt(kScratchReg2, kScratchReg, zero_reg); -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg2); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kLa64MulOvf: { -+ // Overflow occurs if overflow register is not zero -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kLa64CmpS: -+ case kLa64CmpD: { -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ if (predicate) { -+ __ LoadZeroIfFPUCondition(kSpeculationPoisonRegister); -+ } else { -+ __ LoadZeroIfNotFPUCondition(kSpeculationPoisonRegister); -+ } -+ } -+ return; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+#undef UNSUPPORTED_COND -+ -+void CodeGenerator::AssembleArchDeoptBranch(Instruction* instr, -+ BranchInfo* branch) { -+ AssembleArchBranch(instr, branch); -+} -+ -+void CodeGenerator::AssembleArchJump(RpoNumber target) { -+ if (!IsNextInAssemblyOrder(target)) __ Branch(GetLabel(target)); -+} -+ -+void CodeGenerator::AssembleArchTrap(Instruction* instr, -+ FlagsCondition condition) { -+ class OutOfLineTrap final : public OutOfLineCode { -+ public: -+ OutOfLineTrap(CodeGenerator* gen, Instruction* instr) -+ : OutOfLineCode(gen), instr_(instr), gen_(gen) {} -+ void Generate() final { -+ La64OperandConverter i(gen_, instr_); -+ TrapId trap_id = -+ static_cast(i.InputInt32(instr_->InputCount() - 1)); -+ GenerateCallToTrap(trap_id); -+ } -+ -+ private: -+ void GenerateCallToTrap(TrapId trap_id) { -+ if (trap_id == TrapId::kInvalid) { -+ // We cannot test calls to the runtime in cctest/test-run-wasm. -+ // Therefore we emit a call to C here instead of a call to the runtime. -+ // We use the context register as the scratch register, because we do -+ // not have a context here. -+ __ PrepareCallCFunction(0, 0, cp); -+ __ CallCFunction( -+ ExternalReference::wasm_call_trap_callback_for_testing(), 0); -+ __ LeaveFrame(StackFrame::WASM); -+ auto call_descriptor = gen_->linkage()->GetIncomingDescriptor(); -+ int pop_count = -+ static_cast(call_descriptor->StackParameterCount()); -+ pop_count += (pop_count & 1); // align -+ __ Drop(pop_count); -+ __ Ret(); -+ } else { -+ gen_->AssembleSourcePosition(instr_); -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched when the code -+ // is added to the native module and copied into wasm code space. -+ __ Call(static_cast
(trap_id), RelocInfo::WASM_STUB_CALL); -+ ReferenceMap* reference_map = -+ gen_->zone()->New(gen_->zone()); -+ gen_->RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); -+ if (FLAG_debug_code) { -+ __ stop(); -+ } -+ } -+ } -+ Instruction* instr_; -+ CodeGenerator* gen_; -+ }; -+ auto ool = zone()->New(this, instr); -+ Label* tlabel = ool->entry(); -+ AssembleBranchToLabels(this, tasm(), instr, condition, tlabel, nullptr, true); -+} -+ -+// Assembles boolean materializations after an instruction. -+void CodeGenerator::AssembleArchBoolean(Instruction* instr, -+ FlagsCondition condition) { -+ La64OperandConverter i(this, instr); -+ -+ // Materialize a full 32-bit 1 or 0 value. The result register is always the -+ // last output of the instruction. -+ DCHECK_NE(0u, instr->OutputCount()); -+ Register result = i.OutputRegister(instr->OutputCount() - 1); -+ Condition cc = kNoCondition; -+ // La64 does not have condition code flags, so compare and branch are -+ // implemented differently than on the other arch's. The compare operations -+ // emit la64 pseudo-instructions, which are checked and handled here. -+ -+ if (instr->arch_opcode() == kLa64Tst) { -+ cc = FlagsConditionToConditionTst(condition); -+ if (cc == eq) { -+ __ Sltu(result, kScratchReg, 1); -+ } else { -+ __ Sltu(result, zero_reg, kScratchReg); -+ } -+ return; -+ } else if (instr->arch_opcode() == kLa64Dadd || -+ instr->arch_opcode() == kLa64Dsub) { -+ cc = FlagsConditionToConditionOvf(condition); -+ // Check for overflow creates 1 or 0 for result. -+ __ srli_d(kScratchReg, i.OutputRegister(), 63); -+ __ srli_w(kScratchReg2, i.OutputRegister(), 31); -+ __ xor_(result, kScratchReg, kScratchReg2); -+ if (cc == eq) // Toggle result for not overflow. -+ __ xori(result, result, 1); -+ return; -+ } else if (instr->arch_opcode() == kLa64DaddOvf || -+ instr->arch_opcode() == kLa64DsubOvf) { -+ // Overflow occurs if overflow register is negative -+ __ slt(result, kScratchReg, zero_reg); -+ } else if (instr->arch_opcode() == kLa64MulOvf) { -+ // Overflow occurs if overflow register is not zero -+ __ Sgtu(result, kScratchReg, zero_reg); -+ } else if (instr->arch_opcode() == kLa64Cmp) { -+ cc = FlagsConditionToConditionCmp(condition); -+ switch (cc) { -+ case eq: -+ case ne: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ if (instr->InputAt(1)->IsImmediate()) { -+ if (is_int12(-right.immediate())) { -+ if (right.immediate() == 0) { -+ if (cc == eq) { -+ __ Sltu(result, left, 1); -+ } else { -+ __ Sltu(result, zero_reg, left); -+ } -+ } else { -+ __ Add_d(result, left, Operand(-right.immediate())); -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } else { -+ if (is_uint12(right.immediate())) { -+ __ Xor(result, left, right); -+ } else { -+ __ li(kScratchReg, right); -+ __ Xor(result, left, kScratchReg); -+ } -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } else { -+ __ Xor(result, left, right); -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } break; -+ case lt: -+ case ge: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ __ Slt(result, left, right); -+ if (cc == ge) { -+ __ xori(result, result, 1); -+ } -+ } break; -+ case gt: -+ case le: { -+ Register left = i.InputRegister(1); -+ Operand right = i.InputOperand(0); -+ __ Slt(result, left, right); -+ if (cc == le) { -+ __ xori(result, result, 1); -+ } -+ } break; -+ case lo: -+ case hs: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ __ Sltu(result, left, right); -+ if (cc == hs) { -+ __ xori(result, result, 1); -+ } -+ } break; -+ case hi: -+ case ls: { -+ Register left = i.InputRegister(1); -+ Operand right = i.InputOperand(0); -+ __ Sltu(result, left, right); -+ if (cc == ls) { -+ __ xori(result, result, 1); -+ } -+ } break; -+ default: -+ UNREACHABLE(); -+ } -+ return; -+ } else if (instr->arch_opcode() == kLa64CmpD || -+ instr->arch_opcode() == kLa64CmpS) { -+ FPURegister left = i.InputOrZeroDoubleRegister(0); -+ FPURegister right = i.InputOrZeroDoubleRegister(1); -+ if ((left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsDoubleZeroRegSet()) { -+ __ Move(kDoubleRegZero, 0.0); -+ } -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ { -+ __ movcf2gr(result, FCC0); -+ if (!predicate) { -+ __ xori(result, result, 1); -+ } -+ } -+ return; -+ } else { -+ PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", -+ instr->arch_opcode()); -+ TRACE_UNIMPL(); -+ UNIMPLEMENTED(); -+ } -+} -+ -+void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) { -+ La64OperandConverter i(this, instr); -+ Register input = i.InputRegister(0); -+ std::vector> cases; -+ for (size_t index = 2; index < instr->InputCount(); index += 2) { -+ cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))}); -+ } -+ AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(), -+ cases.data() + cases.size()); -+} -+ -+void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { -+ La64OperandConverter i(this, instr); -+ Register input = i.InputRegister(0); -+ size_t const case_count = instr->InputCount() - 2; -+ -+ __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); -+ __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { -+ return GetLabel(i.InputRpo(index + 2)); -+ }); -+} -+ -+void CodeGenerator::FinishFrame(Frame* frame) { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ if (saves_fpu != 0) { -+ int count = base::bits::CountPopulation(saves_fpu); -+ DCHECK_EQ(kNumCalleeSavedFPU, count); -+ frame->AllocateSavedCalleeRegisterSlots(count * -+ (kDoubleSize / kSystemPointerSize)); -+ } -+ -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ if (saves != 0) { -+ int count = base::bits::CountPopulation(saves); -+ DCHECK_EQ(kNumCalleeSaved, count + 1); -+ frame->AllocateSavedCalleeRegisterSlots(count); -+ } -+} -+ -+void CodeGenerator::AssembleConstructFrame() { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ if (frame_access_state()->has_frame()) { -+ if (call_descriptor->IsCFunctionCall()) { -+ if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) { -+ __ StubPrologue(StackFrame::C_WASM_ENTRY); -+ // Reserve stack space for saving the c_entry_fp later. -+ __ Sub_d(sp, sp, Operand(kSystemPointerSize)); -+ } else { -+ __ Push(ra, fp); -+ __ mov(fp, sp); -+ } -+ } else if (call_descriptor->IsJSFunctionCall()) { -+ __ Prologue(); -+ } else { -+ __ StubPrologue(info()->GetOutputStackFrameType()); -+ if (call_descriptor->IsWasmFunctionCall()) { -+ __ Push(kWasmInstanceRegister); -+ } else if (call_descriptor->IsWasmImportWrapper() || -+ call_descriptor->IsWasmCapiFunction()) { -+ // Wasm import wrappers are passed a tuple in the place of the instance. -+ // Unpack the tuple into the instance and the target callable. -+ // This must be done here in the codegen because it cannot be expressed -+ // properly in the graph. -+ __ Ld_d(kJSFunctionRegister, -+ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset)); -+ __ Ld_d(kWasmInstanceRegister, -+ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); -+ __ Push(kWasmInstanceRegister); -+ if (call_descriptor->IsWasmCapiFunction()) { -+ // Reserve space for saving the PC later. -+ __ Sub_d(sp, sp, Operand(kSystemPointerSize)); -+ } -+ } -+ } -+ } -+ -+ int required_slots = -+ frame()->GetTotalFrameSlotCount() - frame()->GetFixedSlotCount(); -+ -+ if (info()->is_osr()) { -+ // TurboFan OSR-compiled functions cannot be entered directly. -+ __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); -+ -+ // Unoptimized code jumps directly to this entrypoint while the unoptimized -+ // frame is still on the stack. Optimized code uses OSR values directly from -+ // the unoptimized frame. Thus, all that needs to be done is to allocate the -+ // remaining stack slots. -+ if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); -+ osr_pc_offset_ = __ pc_offset(); -+ required_slots -= osr_helper()->UnoptimizedFrameSlots(); -+ ResetSpeculationPoison(); -+ } -+ -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ -+ if (required_slots > 0) { -+ DCHECK(frame_access_state()->has_frame()); -+ if (info()->IsWasm() && required_slots > 128) { -+ // For WebAssembly functions with big frames we have to do the stack -+ // overflow check before we construct the frame. Otherwise we may not -+ // have enough space on the stack to call the runtime for the stack -+ // overflow. -+ Label done; -+ -+ // If the frame is bigger than the stack, we throw the stack overflow -+ // exception unconditionally. Thereby we can avoid the integer overflow -+ // check in the condition code. -+ if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { -+ __ Ld_d( -+ kScratchReg, -+ FieldMemOperand(kWasmInstanceRegister, -+ WasmInstanceObject::kRealStackLimitAddressOffset)); -+ __ Ld_d(kScratchReg, MemOperand(kScratchReg, 0)); -+ __ Add_d(kScratchReg, kScratchReg, -+ Operand(required_slots * kSystemPointerSize)); -+ __ Branch(&done, uge, sp, Operand(kScratchReg)); -+ } -+ -+ __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); -+ // We come from WebAssembly, there are no references for the GC. -+ ReferenceMap* reference_map = zone()->New(zone()); -+ RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); -+ if (FLAG_debug_code) { -+ __ stop(); -+ } -+ -+ __ bind(&done); -+ } -+ } -+ -+ const int returns = frame()->GetReturnSlotCount(); -+ -+ // Skip callee-saved and return slots, which are pushed below. -+ required_slots -= base::bits::CountPopulation(saves); -+ required_slots -= base::bits::CountPopulation(saves_fpu); -+ required_slots -= returns; -+ if (required_slots > 0) { -+ __ Sub_d(sp, sp, Operand(required_slots * kSystemPointerSize)); -+ } -+ -+ if (saves_fpu != 0) { -+ // Save callee-saved FPU registers. -+ __ MultiPushFPU(saves_fpu); -+ DCHECK_EQ(kNumCalleeSavedFPU, base::bits::CountPopulation(saves_fpu)); -+ } -+ -+ if (saves != 0) { -+ // Save callee-saved registers. -+ __ MultiPush(saves); -+ DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1); -+ } -+ -+ if (returns != 0) { -+ // Create space for returns. -+ __ Sub_d(sp, sp, Operand(returns * kSystemPointerSize)); -+ } -+} -+ -+void CodeGenerator::AssembleReturn(InstructionOperand* pop) { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ const int returns = frame()->GetReturnSlotCount(); -+ if (returns != 0) { -+ __ Add_d(sp, sp, Operand(returns * kSystemPointerSize)); -+ } -+ -+ // Restore GP registers. -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ if (saves != 0) { -+ __ MultiPop(saves); -+ } -+ -+ // Restore FPU registers. -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ if (saves_fpu != 0) { -+ __ MultiPopFPU(saves_fpu); -+ } -+ -+ La64OperandConverter g(this, nullptr); -+ if (call_descriptor->IsCFunctionCall()) { -+ AssembleDeconstructFrame(); -+ } else if (frame_access_state()->has_frame()) { -+ // Canonicalize JSFunction return sites for now unless they have an variable -+ // number of stack slot pops. -+ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { -+ if (return_label_.is_bound()) { -+ __ Branch(&return_label_); -+ return; -+ } else { -+ __ bind(&return_label_); -+ AssembleDeconstructFrame(); -+ } -+ } else { -+ AssembleDeconstructFrame(); -+ } -+ } -+ int pop_count = static_cast(call_descriptor->StackParameterCount()); -+ if (pop->IsImmediate()) { -+ pop_count += g.ToConstant(pop).ToInt32(); -+ } else { -+ Register pop_reg = g.ToRegister(pop); -+ __ slli_d(pop_reg, pop_reg, kSystemPointerSizeLog2); -+ __ Add_d(sp, sp, pop_reg); -+ } -+ if (pop_count != 0) { -+ __ DropAndRet(pop_count); -+ } else { -+ __ Ret(); -+ } -+} -+ -+void CodeGenerator::FinishCode() {} -+ -+void CodeGenerator::PrepareForDeoptimizationExits(int deopt_count) {} -+ -+void CodeGenerator::AssembleMove(InstructionOperand* source, -+ InstructionOperand* destination) { -+ La64OperandConverter g(this, nullptr); -+ // Dispatch on the source and destination operand kinds. Not all -+ // combinations are possible. -+ if (source->IsRegister()) { -+ DCHECK(destination->IsRegister() || destination->IsStackSlot()); -+ Register src = g.ToRegister(source); -+ if (destination->IsRegister()) { -+ __ mov(g.ToRegister(destination), src); -+ } else { -+ __ St_d(src, g.ToMemOperand(destination)); -+ } -+ } else if (source->IsStackSlot()) { -+ DCHECK(destination->IsRegister() || destination->IsStackSlot()); -+ MemOperand src = g.ToMemOperand(source); -+ if (destination->IsRegister()) { -+ __ Ld_d(g.ToRegister(destination), src); -+ } else { -+ Register temp = kScratchReg; -+ __ Ld_d(temp, src); -+ __ St_d(temp, g.ToMemOperand(destination)); -+ } -+ } else if (source->IsConstant()) { -+ Constant src = g.ToConstant(source); -+ if (destination->IsRegister() || destination->IsStackSlot()) { -+ Register dst = -+ destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; -+ switch (src.type()) { -+ case Constant::kInt32: -+ __ li(dst, Operand(src.ToInt32())); -+ break; -+ case Constant::kFloat32: -+ __ li(dst, Operand::EmbeddedNumber(src.ToFloat32())); -+ break; -+ case Constant::kInt64: -+ if (RelocInfo::IsWasmReference(src.rmode())) { -+ __ li(dst, Operand(src.ToInt64(), src.rmode())); -+ } else { -+ __ li(dst, Operand(src.ToInt64())); -+ } -+ break; -+ case Constant::kFloat64: -+ __ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value())); -+ break; -+ case Constant::kExternalReference: -+ __ li(dst, src.ToExternalReference()); -+ break; -+ case Constant::kDelayedStringConstant: -+ __ li(dst, src.ToDelayedStringConstant()); -+ break; -+ case Constant::kHeapObject: { -+ Handle src_object = src.ToHeapObject(); -+ RootIndex index; -+ if (IsMaterializableFromRoot(src_object, &index)) { -+ __ LoadRoot(dst, index); -+ } else { -+ __ li(dst, src_object); -+ } -+ break; -+ } -+ case Constant::kCompressedHeapObject: -+ UNREACHABLE(); -+ case Constant::kRpoNumber: -+ UNREACHABLE(); // TODO(titzer): loading RPO numbers on LA64. -+ break; -+ } -+ if (destination->IsStackSlot()) __ St_d(dst, g.ToMemOperand(destination)); -+ } else if (src.type() == Constant::kFloat32) { -+ if (destination->IsFPStackSlot()) { -+ MemOperand dst = g.ToMemOperand(destination); -+ if (bit_cast(src.ToFloat32()) == 0) { -+ __ St_d(zero_reg, dst); -+ } else { -+ __ li(kScratchReg, Operand(bit_cast(src.ToFloat32()))); -+ __ St_d(kScratchReg, dst); -+ } -+ } else { -+ DCHECK(destination->IsFPRegister()); -+ FloatRegister dst = g.ToSingleRegister(destination); -+ __ Move(dst, src.ToFloat32()); -+ } -+ } else { -+ DCHECK_EQ(Constant::kFloat64, src.type()); -+ DoubleRegister dst = destination->IsFPRegister() -+ ? g.ToDoubleRegister(destination) -+ : kScratchDoubleReg; -+ __ Move(dst, src.ToFloat64().value()); -+ if (destination->IsFPStackSlot()) { -+ __ Fst_d(dst, g.ToMemOperand(destination)); -+ } -+ } -+ } else if (source->IsFPRegister()) { -+ FPURegister src = g.ToDoubleRegister(source); -+ if (destination->IsFPRegister()) { -+ FPURegister dst = g.ToDoubleRegister(destination); -+ __ Move(dst, src); -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ __ Fst_d(src, g.ToMemOperand(destination)); -+ } -+ } else if (source->IsFPStackSlot()) { -+ DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); -+ MemOperand src = g.ToMemOperand(source); -+ if (destination->IsFPRegister()) { -+ __ Fld_d(g.ToDoubleRegister(destination), src); -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ FPURegister temp = kScratchDoubleReg; -+ __ Fld_d(temp, src); -+ __ Fst_d(temp, g.ToMemOperand(destination)); -+ } -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void CodeGenerator::AssembleSwap(InstructionOperand* source, -+ InstructionOperand* destination) { -+ La64OperandConverter g(this, nullptr); -+ // Dispatch on the source and destination operand kinds. Not all -+ // combinations are possible. -+ if (source->IsRegister()) { -+ // Register-register. -+ Register temp = kScratchReg; -+ Register src = g.ToRegister(source); -+ if (destination->IsRegister()) { -+ Register dst = g.ToRegister(destination); -+ __ Move(temp, src); -+ __ Move(src, dst); -+ __ Move(dst, temp); -+ } else { -+ DCHECK(destination->IsStackSlot()); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ mov(temp, src); -+ __ Ld_d(src, dst); -+ __ St_d(temp, dst); -+ } -+ } else if (source->IsStackSlot()) { -+ DCHECK(destination->IsStackSlot()); -+ Register temp_0 = kScratchReg; -+ Register temp_1 = kScratchReg2; -+ MemOperand src = g.ToMemOperand(source); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ Ld_d(temp_0, src); -+ __ Ld_d(temp_1, dst); -+ __ St_d(temp_0, dst); -+ __ St_d(temp_1, src); -+ } else if (source->IsFPRegister()) { -+ FPURegister temp = kScratchDoubleReg; -+ FPURegister src = g.ToDoubleRegister(source); -+ if (destination->IsFPRegister()) { -+ FPURegister dst = g.ToDoubleRegister(destination); -+ __ Move(temp, src); -+ __ Move(src, dst); -+ __ Move(dst, temp); -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ Move(temp, src); -+ __ Fld_d(src, dst); -+ __ Fst_d(temp, dst); -+ } -+ } else if (source->IsFPStackSlot()) { -+ DCHECK(destination->IsFPStackSlot()); -+ Register temp_0 = kScratchReg; -+ MemOperand src0 = g.ToMemOperand(source); -+ MemOperand src1(src0.base(), src0.offset() + kIntSize); -+ MemOperand dst0 = g.ToMemOperand(destination); -+ MemOperand dst1(dst0.base(), dst0.offset() + kIntSize); -+ FPURegister temp_1 = kScratchDoubleReg; -+ __ Fld_d(temp_1, dst0); // Save destination in temp_1. -+ __ Ld_w(temp_0, src0); // Then use temp_0 to copy source to destination. -+ __ St_w(temp_0, dst0); -+ __ Ld_w(temp_0, src1); -+ __ St_w(temp_0, dst1); -+ __ Fst_d(temp_1, src0); -+ } else { -+ // No other combinations are possible. -+ UNREACHABLE(); -+ } -+} -+ -+void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { -+ // On 64-bit LA64 we emit the jump tables inline. -+ UNREACHABLE(); -+} -+ -+#undef ASSEMBLE_ATOMIC_LOAD_INTEGER -+#undef ASSEMBLE_ATOMIC_STORE_INTEGER -+#undef ASSEMBLE_ATOMIC_BINOP -+#undef ASSEMBLE_ATOMIC_BINOP_EXT -+#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER -+#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT -+#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER -+#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT -+#undef ASSEMBLE_IEEE754_BINOP -+#undef ASSEMBLE_IEEE754_UNOP -+ -+#undef TRACE_MSG -+#undef TRACE_UNIMPL -+#undef __ -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-codes-loongarch64.h b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-codes-loongarch64.h -new file mode 100644 -index 000000000..128ee2801 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-codes-loongarch64.h -@@ -0,0 +1,432 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ -+#define V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+// LA64-specific opcodes that specify which assembly sequence to emit. -+// Most opcodes specify a single instruction. -+#define TARGET_ARCH_OPCODE_LIST(V) \ -+ V(La64Add) \ -+ V(La64Dadd) \ -+ V(La64DaddOvf) \ -+ V(La64Sub) \ -+ V(La64Dsub) \ -+ V(La64DsubOvf) \ -+ V(La64Mul) \ -+ V(La64MulOvf) \ -+ V(La64MulHigh) \ -+ V(La64DMulHigh) \ -+ V(La64MulHighU) \ -+ V(La64Dmul) \ -+ V(La64Div) \ -+ V(La64Ddiv) \ -+ V(La64DivU) \ -+ V(La64DdivU) \ -+ V(La64Mod) \ -+ V(La64Dmod) \ -+ V(La64ModU) \ -+ V(La64DmodU) \ -+ V(La64And) \ -+ V(La64And32) \ -+ V(La64Or) \ -+ V(La64Or32) \ -+ V(La64Nor) \ -+ V(La64Nor32) \ -+ V(La64Xor) \ -+ V(La64Xor32) \ -+ V(La64Clz) \ -+ V(La64Lsa) \ -+ V(La64Dlsa) \ -+ V(La64Shl) \ -+ V(La64Shr) \ -+ V(La64Sar) \ -+ V(La64Ext) \ -+ V(La64Ins) \ -+ V(La64Dext) \ -+ V(La64Dins) \ -+ V(La64Dclz) \ -+ V(La64Ctz) \ -+ V(La64Dctz) \ -+ V(La64Popcnt) \ -+ V(La64Dpopcnt) \ -+ V(La64Dshl) \ -+ V(La64Dshr) \ -+ V(La64Dsar) \ -+ V(La64Ror) \ -+ V(La64Dror) \ -+ V(La64Mov) \ -+ V(La64Tst) \ -+ V(La64Cmp) \ -+ V(La64CmpS) \ -+ V(La64AddS) \ -+ V(La64SubS) \ -+ V(La64MulS) \ -+ V(La64DivS) \ -+ V(La64ModS) \ -+ V(La64AbsS) \ -+ V(La64NegS) \ -+ V(La64SqrtS) \ -+ V(La64MaxS) \ -+ V(La64MinS) \ -+ V(La64CmpD) \ -+ V(La64AddD) \ -+ V(La64SubD) \ -+ V(La64MulD) \ -+ V(La64DivD) \ -+ V(La64ModD) \ -+ V(La64AbsD) \ -+ V(La64NegD) \ -+ V(La64SqrtD) \ -+ V(La64MaxD) \ -+ V(La64MinD) \ -+ V(La64Float64RoundDown) \ -+ V(La64Float64RoundTruncate) \ -+ V(La64Float64RoundUp) \ -+ V(La64Float64RoundTiesEven) \ -+ V(La64Float32RoundDown) \ -+ V(La64Float32RoundTruncate) \ -+ V(La64Float32RoundUp) \ -+ V(La64Float32RoundTiesEven) \ -+ V(La64CvtSD) \ -+ V(La64CvtDS) \ -+ V(La64TruncWD) \ -+ V(La64RoundWD) \ -+ V(La64FloorWD) \ -+ V(La64CeilWD) \ -+ V(La64TruncWS) \ -+ V(La64RoundWS) \ -+ V(La64FloorWS) \ -+ V(La64CeilWS) \ -+ V(La64TruncLS) \ -+ V(La64TruncLD) \ -+ V(La64TruncUwD) \ -+ V(La64TruncUwS) \ -+ V(La64TruncUlS) \ -+ V(La64TruncUlD) \ -+ V(La64CvtDW) \ -+ V(La64CvtSL) \ -+ V(La64CvtSW) \ -+ V(La64CvtSUw) \ -+ V(La64CvtSUl) \ -+ V(La64CvtDL) \ -+ V(La64CvtDUw) \ -+ V(La64CvtDUl) \ -+ V(La64Lb) \ -+ V(La64Lbu) \ -+ V(La64Sb) \ -+ V(La64Lh) \ -+ V(La64Ulh) \ -+ V(La64Lhu) \ -+ V(La64Ulhu) \ -+ V(La64Sh) \ -+ V(La64Ush) \ -+ V(La64Ld) \ -+ V(La64Uld) \ -+ V(La64Lw) \ -+ V(La64Ulw) \ -+ V(La64Lwu) \ -+ V(La64Ulwu) \ -+ V(La64Sw) \ -+ V(La64Usw) \ -+ V(La64Sd) \ -+ V(La64Usd) \ -+ V(La64Lwc1) \ -+ V(La64Ulwc1) \ -+ V(La64Swc1) \ -+ V(La64Uswc1) \ -+ V(La64Ldc1) \ -+ V(La64Uldc1) \ -+ V(La64Sdc1) \ -+ V(La64Usdc1) \ -+ V(La64BitcastDL) \ -+ V(La64BitcastLD) \ -+ V(La64Float64ExtractLowWord32) \ -+ V(La64Float64ExtractHighWord32) \ -+ V(La64Float64InsertLowWord32) \ -+ V(La64Float64InsertHighWord32) \ -+ V(La64Float32Max) \ -+ V(La64Float64Max) \ -+ V(La64Float32Min) \ -+ V(La64Float64Min) \ -+ V(La64Float64SilenceNaN) \ -+ V(La64Push) \ -+ V(La64Peek) \ -+ V(La64StoreToStackSlot) \ -+ V(La64ByteSwap64) \ -+ V(La64ByteSwap32) \ -+ V(La64StackClaim) \ -+ V(La64Seb) \ -+ V(La64Seh) \ -+ V(La64Sync) \ -+ V(La64AssertEqual) \ -+ V(La64S128Const) \ -+ V(La64S128Zero) \ -+ V(La64S128AllOnes) \ -+ V(La64I32x4Splat) \ -+ V(La64I32x4ExtractLane) \ -+ V(La64I32x4ReplaceLane) \ -+ V(La64I32x4Add) \ -+ V(La64I32x4AddHoriz) \ -+ V(La64I32x4Sub) \ -+ V(La64F64x2Abs) \ -+ V(La64F64x2Neg) \ -+ V(La64F32x4Splat) \ -+ V(La64F32x4ExtractLane) \ -+ V(La64F32x4ReplaceLane) \ -+ V(La64F32x4SConvertI32x4) \ -+ V(La64F32x4UConvertI32x4) \ -+ V(La64I32x4Mul) \ -+ V(La64I32x4MaxS) \ -+ V(La64I32x4MinS) \ -+ V(La64I32x4Eq) \ -+ V(La64I32x4Ne) \ -+ V(La64I32x4Shl) \ -+ V(La64I32x4ShrS) \ -+ V(La64I32x4ShrU) \ -+ V(La64I32x4MaxU) \ -+ V(La64I32x4MinU) \ -+ V(La64F64x2Sqrt) \ -+ V(La64F64x2Add) \ -+ V(La64F64x2Sub) \ -+ V(La64F64x2Mul) \ -+ V(La64F64x2Div) \ -+ V(La64F64x2Min) \ -+ V(La64F64x2Max) \ -+ V(La64F64x2Eq) \ -+ V(La64F64x2Ne) \ -+ V(La64F64x2Lt) \ -+ V(La64F64x2Le) \ -+ V(La64F64x2Splat) \ -+ V(La64F64x2ExtractLane) \ -+ V(La64F64x2ReplaceLane) \ -+ V(La64F64x2Pmin) \ -+ V(La64F64x2Pmax) \ -+ V(La64F64x2Ceil) \ -+ V(La64F64x2Floor) \ -+ V(La64F64x2Trunc) \ -+ V(La64F64x2NearestInt) \ -+ V(La64I64x2Splat) \ -+ V(La64I64x2ExtractLane) \ -+ V(La64I64x2ReplaceLane) \ -+ V(La64I64x2Add) \ -+ V(La64I64x2Sub) \ -+ V(La64I64x2Mul) \ -+ V(La64I64x2Neg) \ -+ V(La64I64x2Shl) \ -+ V(La64I64x2ShrS) \ -+ V(La64I64x2ShrU) \ -+ V(La64F32x4Abs) \ -+ V(La64F32x4Neg) \ -+ V(La64F32x4Sqrt) \ -+ V(La64F32x4RecipApprox) \ -+ V(La64F32x4RecipSqrtApprox) \ -+ V(La64F32x4Add) \ -+ V(La64F32x4AddHoriz) \ -+ V(La64F32x4Sub) \ -+ V(La64F32x4Mul) \ -+ V(La64F32x4Div) \ -+ V(La64F32x4Max) \ -+ V(La64F32x4Min) \ -+ V(La64F32x4Eq) \ -+ V(La64F32x4Ne) \ -+ V(La64F32x4Lt) \ -+ V(La64F32x4Le) \ -+ V(La64F32x4Pmin) \ -+ V(La64F32x4Pmax) \ -+ V(La64F32x4Ceil) \ -+ V(La64F32x4Floor) \ -+ V(La64F32x4Trunc) \ -+ V(La64F32x4NearestInt) \ -+ V(La64I32x4SConvertF32x4) \ -+ V(La64I32x4UConvertF32x4) \ -+ V(La64I32x4Neg) \ -+ V(La64I32x4GtS) \ -+ V(La64I32x4GeS) \ -+ V(La64I32x4GtU) \ -+ V(La64I32x4GeU) \ -+ V(La64I32x4Abs) \ -+ V(La64I32x4BitMask) \ -+ V(La64I16x8Splat) \ -+ V(La64I16x8ExtractLaneU) \ -+ V(La64I16x8ExtractLaneS) \ -+ V(La64I16x8ReplaceLane) \ -+ V(La64I16x8Neg) \ -+ V(La64I16x8Shl) \ -+ V(La64I16x8ShrS) \ -+ V(La64I16x8ShrU) \ -+ V(La64I16x8Add) \ -+ V(La64I16x8AddSaturateS) \ -+ V(La64I16x8AddHoriz) \ -+ V(La64I16x8Sub) \ -+ V(La64I16x8SubSaturateS) \ -+ V(La64I16x8Mul) \ -+ V(La64I16x8MaxS) \ -+ V(La64I16x8MinS) \ -+ V(La64I16x8Eq) \ -+ V(La64I16x8Ne) \ -+ V(La64I16x8GtS) \ -+ V(La64I16x8GeS) \ -+ V(La64I16x8AddSaturateU) \ -+ V(La64I16x8SubSaturateU) \ -+ V(La64I16x8MaxU) \ -+ V(La64I16x8MinU) \ -+ V(La64I16x8GtU) \ -+ V(La64I16x8GeU) \ -+ V(La64I16x8RoundingAverageU) \ -+ V(La64I16x8Abs) \ -+ V(La64I16x8BitMask) \ -+ V(La64I8x16Splat) \ -+ V(La64I8x16ExtractLaneU) \ -+ V(La64I8x16ExtractLaneS) \ -+ V(La64I8x16ReplaceLane) \ -+ V(La64I8x16Neg) \ -+ V(La64I8x16Shl) \ -+ V(La64I8x16ShrS) \ -+ V(La64I8x16Add) \ -+ V(La64I8x16AddSaturateS) \ -+ V(La64I8x16Sub) \ -+ V(La64I8x16SubSaturateS) \ -+ V(La64I8x16Mul) \ -+ V(La64I8x16MaxS) \ -+ V(La64I8x16MinS) \ -+ V(La64I8x16Eq) \ -+ V(La64I8x16Ne) \ -+ V(La64I8x16GtS) \ -+ V(La64I8x16GeS) \ -+ V(La64I8x16ShrU) \ -+ V(La64I8x16AddSaturateU) \ -+ V(La64I8x16SubSaturateU) \ -+ V(La64I8x16MaxU) \ -+ V(La64I8x16MinU) \ -+ V(La64I8x16GtU) \ -+ V(La64I8x16GeU) \ -+ V(La64I8x16RoundingAverageU) \ -+ V(La64I8x16Abs) \ -+ V(La64I8x16BitMask) \ -+ V(La64S128And) \ -+ V(La64S128Or) \ -+ V(La64S128Xor) \ -+ V(La64S128Not) \ -+ V(La64S128Select) \ -+ V(La64S128AndNot) \ -+ V(La64V32x4AnyTrue) \ -+ V(La64V32x4AllTrue) \ -+ V(La64V16x8AnyTrue) \ -+ V(La64V16x8AllTrue) \ -+ V(La64V8x16AnyTrue) \ -+ V(La64V8x16AllTrue) \ -+ V(La64S32x4InterleaveRight) \ -+ V(La64S32x4InterleaveLeft) \ -+ V(La64S32x4PackEven) \ -+ V(La64S32x4PackOdd) \ -+ V(La64S32x4InterleaveEven) \ -+ V(La64S32x4InterleaveOdd) \ -+ V(La64S32x4Shuffle) \ -+ V(La64S16x8InterleaveRight) \ -+ V(La64S16x8InterleaveLeft) \ -+ V(La64S16x8PackEven) \ -+ V(La64S16x8PackOdd) \ -+ V(La64S16x8InterleaveEven) \ -+ V(La64S16x8InterleaveOdd) \ -+ V(La64S16x4Reverse) \ -+ V(La64S16x2Reverse) \ -+ V(La64S8x16InterleaveRight) \ -+ V(La64S8x16InterleaveLeft) \ -+ V(La64S8x16PackEven) \ -+ V(La64S8x16PackOdd) \ -+ V(La64S8x16InterleaveEven) \ -+ V(La64S8x16InterleaveOdd) \ -+ V(La64I8x16Shuffle) \ -+ V(La64I8x16Swizzle) \ -+ V(La64S8x16Concat) \ -+ V(La64S8x8Reverse) \ -+ V(La64S8x4Reverse) \ -+ V(La64S8x2Reverse) \ -+ V(La64S8x16LoadSplat) \ -+ V(La64S16x8LoadSplat) \ -+ V(La64S32x4LoadSplat) \ -+ V(La64S64x2LoadSplat) \ -+ V(La64I16x8Load8x8S) \ -+ V(La64I16x8Load8x8U) \ -+ V(La64I32x4Load16x4S) \ -+ V(La64I32x4Load16x4U) \ -+ V(La64I64x2Load32x2S) \ -+ V(La64I64x2Load32x2U) \ -+ V(La64I32x4SConvertI16x8Low) \ -+ V(La64I32x4SConvertI16x8High) \ -+ V(La64I32x4UConvertI16x8Low) \ -+ V(La64I32x4UConvertI16x8High) \ -+ V(La64I16x8SConvertI8x16Low) \ -+ V(La64I16x8SConvertI8x16High) \ -+ V(La64I16x8SConvertI32x4) \ -+ V(La64I16x8UConvertI32x4) \ -+ V(La64I16x8UConvertI8x16Low) \ -+ V(La64I16x8UConvertI8x16High) \ -+ V(La64I8x16SConvertI16x8) \ -+ V(La64I8x16UConvertI16x8) \ -+ V(La64Word64AtomicLoadUint8) \ -+ V(La64Word64AtomicLoadUint16) \ -+ V(La64Word64AtomicLoadUint32) \ -+ V(La64Word64AtomicLoadUint64) \ -+ V(La64Word64AtomicStoreWord8) \ -+ V(La64Word64AtomicStoreWord16) \ -+ V(La64Word64AtomicStoreWord32) \ -+ V(La64Word64AtomicStoreWord64) \ -+ V(La64Word64AtomicAddUint8) \ -+ V(La64Word64AtomicAddUint16) \ -+ V(La64Word64AtomicAddUint32) \ -+ V(La64Word64AtomicAddUint64) \ -+ V(La64Word64AtomicSubUint8) \ -+ V(La64Word64AtomicSubUint16) \ -+ V(La64Word64AtomicSubUint32) \ -+ V(La64Word64AtomicSubUint64) \ -+ V(La64Word64AtomicAndUint8) \ -+ V(La64Word64AtomicAndUint16) \ -+ V(La64Word64AtomicAndUint32) \ -+ V(La64Word64AtomicAndUint64) \ -+ V(La64Word64AtomicOrUint8) \ -+ V(La64Word64AtomicOrUint16) \ -+ V(La64Word64AtomicOrUint32) \ -+ V(La64Word64AtomicOrUint64) \ -+ V(La64Word64AtomicXorUint8) \ -+ V(La64Word64AtomicXorUint16) \ -+ V(La64Word64AtomicXorUint32) \ -+ V(La64Word64AtomicXorUint64) \ -+ V(La64Word64AtomicExchangeUint8) \ -+ V(La64Word64AtomicExchangeUint16) \ -+ V(La64Word64AtomicExchangeUint32) \ -+ V(La64Word64AtomicExchangeUint64) \ -+ V(La64Word64AtomicCompareExchangeUint8) \ -+ V(La64Word64AtomicCompareExchangeUint16) \ -+ V(La64Word64AtomicCompareExchangeUint32) \ -+ V(La64Word64AtomicCompareExchangeUint64) -+ -+// Addressing modes represent the "shape" of inputs to an instruction. -+// Many instructions support multiple addressing modes. Addressing modes -+// are encoded into the InstructionCode of the instruction and tell the -+// code generator after register allocation which assembler method to call. -+// -+// We use the following local notation for addressing modes: -+// -+// R = register -+// O = register or stack slot -+// D = double register -+// I = immediate (handle, external, int32) -+// MRI = [register + immediate] -+// MRR = [register + register] -+// TODO(plind): Add the new r6 address modes. -+#define TARGET_ADDRESSING_MODE_LIST(V) \ -+ V(MRI) /* [%r0 + K] */ \ -+ V(MRR) /* [%r0 + %r1] */ -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc -new file mode 100644 -index 000000000..3e0dd4397 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc -@@ -0,0 +1,1554 @@ -+// Copyright 2015 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/compiler/backend/instruction-scheduler.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+bool InstructionScheduler::SchedulerSupported() { return true; } -+ -+int InstructionScheduler::GetTargetInstructionFlags( -+ const Instruction* instr) const { -+ switch (instr->arch_opcode()) { -+ case kLa64AbsD: -+ case kLa64AbsS: -+ case kLa64Add: -+ case kLa64AddD: -+ case kLa64AddS: -+ case kLa64And: -+ case kLa64And32: -+ case kLa64AssertEqual: -+ case kLa64BitcastDL: -+ case kLa64BitcastLD: -+ case kLa64ByteSwap32: -+ case kLa64ByteSwap64: -+ case kLa64CeilWD: -+ case kLa64CeilWS: -+ case kLa64Clz: -+ case kLa64Cmp: -+ case kLa64CmpD: -+ case kLa64CmpS: -+ case kLa64Ctz: -+ case kLa64CvtDL: -+ case kLa64CvtDS: -+ case kLa64CvtDUl: -+ case kLa64CvtDUw: -+ case kLa64CvtDW: -+ case kLa64CvtSD: -+ case kLa64CvtSL: -+ case kLa64CvtSUl: -+ case kLa64CvtSUw: -+ case kLa64CvtSW: -+ case kLa64DMulHigh: -+ case kLa64MulHighU: -+ case kLa64Dadd: -+ case kLa64DaddOvf: -+ case kLa64Dclz: -+ case kLa64Dctz: -+ case kLa64Ddiv: -+ case kLa64DdivU: -+ case kLa64Dext: -+ case kLa64Dins: -+ case kLa64Div: -+ case kLa64DivD: -+ case kLa64DivS: -+ case kLa64DivU: -+ case kLa64Dlsa: -+ case kLa64Dmod: -+ case kLa64DmodU: -+ case kLa64Dmul: -+ case kLa64Dpopcnt: -+ case kLa64Dror: -+ case kLa64Dsar: -+ case kLa64Dshl: -+ case kLa64Dshr: -+ case kLa64Dsub: -+ case kLa64DsubOvf: -+ case kLa64Ext: -+ case kLa64F64x2Abs: -+ case kLa64F64x2Neg: -+ case kLa64F64x2Sqrt: -+ case kLa64F64x2Add: -+ case kLa64F64x2Sub: -+ case kLa64F64x2Mul: -+ case kLa64F64x2Div: -+ case kLa64F64x2Min: -+ case kLa64F64x2Max: -+ case kLa64F64x2Eq: -+ case kLa64F64x2Ne: -+ case kLa64F64x2Lt: -+ case kLa64F64x2Le: -+ case kLa64F64x2Pmin: -+ case kLa64F64x2Pmax: -+ case kLa64F64x2Ceil: -+ case kLa64F64x2Floor: -+ case kLa64F64x2Trunc: -+ case kLa64F64x2NearestInt: -+ case kLa64I64x2Splat: -+ case kLa64I64x2ExtractLane: -+ case kLa64I64x2ReplaceLane: -+ case kLa64I64x2Add: -+ case kLa64I64x2Sub: -+ case kLa64I64x2Mul: -+ case kLa64I64x2Neg: -+ case kLa64I64x2Shl: -+ case kLa64I64x2ShrS: -+ case kLa64I64x2ShrU: -+ case kLa64F32x4Abs: -+ case kLa64F32x4Add: -+ case kLa64F32x4AddHoriz: -+ case kLa64F32x4Eq: -+ case kLa64F32x4ExtractLane: -+ case kLa64F32x4Lt: -+ case kLa64F32x4Le: -+ case kLa64F32x4Max: -+ case kLa64F32x4Min: -+ case kLa64F32x4Mul: -+ case kLa64F32x4Div: -+ case kLa64F32x4Ne: -+ case kLa64F32x4Neg: -+ case kLa64F32x4Sqrt: -+ case kLa64F32x4RecipApprox: -+ case kLa64F32x4RecipSqrtApprox: -+ case kLa64F32x4ReplaceLane: -+ case kLa64F32x4SConvertI32x4: -+ case kLa64F32x4Splat: -+ case kLa64F32x4Sub: -+ case kLa64F32x4UConvertI32x4: -+ case kLa64F32x4Pmin: -+ case kLa64F32x4Pmax: -+ case kLa64F32x4Ceil: -+ case kLa64F32x4Floor: -+ case kLa64F32x4Trunc: -+ case kLa64F32x4NearestInt: -+ case kLa64F64x2Splat: -+ case kLa64F64x2ExtractLane: -+ case kLa64F64x2ReplaceLane: -+ case kLa64Float32Max: -+ case kLa64Float32Min: -+ case kLa64Float32RoundDown: -+ case kLa64Float32RoundTiesEven: -+ case kLa64Float32RoundTruncate: -+ case kLa64Float32RoundUp: -+ case kLa64Float64ExtractLowWord32: -+ case kLa64Float64ExtractHighWord32: -+ case kLa64Float64InsertLowWord32: -+ case kLa64Float64InsertHighWord32: -+ case kLa64Float64Max: -+ case kLa64Float64Min: -+ case kLa64Float64RoundDown: -+ case kLa64Float64RoundTiesEven: -+ case kLa64Float64RoundTruncate: -+ case kLa64Float64RoundUp: -+ case kLa64Float64SilenceNaN: -+ case kLa64FloorWD: -+ case kLa64FloorWS: -+ case kLa64I16x8Add: -+ case kLa64I16x8AddHoriz: -+ case kLa64I16x8AddSaturateS: -+ case kLa64I16x8AddSaturateU: -+ case kLa64I16x8Eq: -+ case kLa64I16x8ExtractLaneU: -+ case kLa64I16x8ExtractLaneS: -+ case kLa64I16x8GeS: -+ case kLa64I16x8GeU: -+ case kLa64I16x8GtS: -+ case kLa64I16x8GtU: -+ case kLa64I16x8MaxS: -+ case kLa64I16x8MaxU: -+ case kLa64I16x8MinS: -+ case kLa64I16x8MinU: -+ case kLa64I16x8Mul: -+ case kLa64I16x8Ne: -+ case kLa64I16x8Neg: -+ case kLa64I16x8ReplaceLane: -+ case kLa64I8x16SConvertI16x8: -+ case kLa64I16x8SConvertI32x4: -+ case kLa64I16x8SConvertI8x16High: -+ case kLa64I16x8SConvertI8x16Low: -+ case kLa64I16x8Shl: -+ case kLa64I16x8ShrS: -+ case kLa64I16x8ShrU: -+ case kLa64I16x8Splat: -+ case kLa64I16x8Sub: -+ case kLa64I16x8SubSaturateS: -+ case kLa64I16x8SubSaturateU: -+ case kLa64I8x16UConvertI16x8: -+ case kLa64I16x8UConvertI32x4: -+ case kLa64I16x8UConvertI8x16High: -+ case kLa64I16x8UConvertI8x16Low: -+ case kLa64I16x8RoundingAverageU: -+ case kLa64I16x8Abs: -+ case kLa64I16x8BitMask: -+ case kLa64I32x4Add: -+ case kLa64I32x4AddHoriz: -+ case kLa64I32x4Eq: -+ case kLa64I32x4ExtractLane: -+ case kLa64I32x4GeS: -+ case kLa64I32x4GeU: -+ case kLa64I32x4GtS: -+ case kLa64I32x4GtU: -+ case kLa64I32x4MaxS: -+ case kLa64I32x4MaxU: -+ case kLa64I32x4MinS: -+ case kLa64I32x4MinU: -+ case kLa64I32x4Mul: -+ case kLa64I32x4Ne: -+ case kLa64I32x4Neg: -+ case kLa64I32x4ReplaceLane: -+ case kLa64I32x4SConvertF32x4: -+ case kLa64I32x4SConvertI16x8High: -+ case kLa64I32x4SConvertI16x8Low: -+ case kLa64I32x4Shl: -+ case kLa64I32x4ShrS: -+ case kLa64I32x4ShrU: -+ case kLa64I32x4Splat: -+ case kLa64I32x4Sub: -+ case kLa64I32x4UConvertF32x4: -+ case kLa64I32x4UConvertI16x8High: -+ case kLa64I32x4UConvertI16x8Low: -+ case kLa64I32x4Abs: -+ case kLa64I32x4BitMask: -+ case kLa64I8x16Add: -+ case kLa64I8x16AddSaturateS: -+ case kLa64I8x16AddSaturateU: -+ case kLa64I8x16Eq: -+ case kLa64I8x16ExtractLaneU: -+ case kLa64I8x16ExtractLaneS: -+ case kLa64I8x16GeS: -+ case kLa64I8x16GeU: -+ case kLa64I8x16GtS: -+ case kLa64I8x16GtU: -+ case kLa64I8x16MaxS: -+ case kLa64I8x16MaxU: -+ case kLa64I8x16MinS: -+ case kLa64I8x16MinU: -+ case kLa64I8x16Mul: -+ case kLa64I8x16Ne: -+ case kLa64I8x16Neg: -+ case kLa64I8x16ReplaceLane: -+ case kLa64I8x16Shl: -+ case kLa64I8x16ShrS: -+ case kLa64I8x16ShrU: -+ case kLa64I8x16Splat: -+ case kLa64I8x16Sub: -+ case kLa64I8x16SubSaturateS: -+ case kLa64I8x16SubSaturateU: -+ case kLa64I8x16RoundingAverageU: -+ case kLa64I8x16Abs: -+ case kLa64I8x16BitMask: -+ case kLa64Ins: -+ case kLa64Lsa: -+ case kLa64MaxD: -+ case kLa64MaxS: -+ case kLa64MinD: -+ case kLa64MinS: -+ case kLa64Mod: -+ case kLa64ModU: -+ case kLa64Mov: -+ case kLa64Mul: -+ case kLa64MulD: -+ case kLa64MulHigh: -+ case kLa64MulOvf: -+ case kLa64MulS: -+ case kLa64NegD: -+ case kLa64NegS: -+ case kLa64Nor: -+ case kLa64Nor32: -+ case kLa64Or: -+ case kLa64Or32: -+ case kLa64Popcnt: -+ case kLa64Ror: -+ case kLa64RoundWD: -+ case kLa64RoundWS: -+ case kLa64S128And: -+ case kLa64S128Or: -+ case kLa64S128Not: -+ case kLa64S128Select: -+ case kLa64S128AndNot: -+ case kLa64S128Xor: -+ case kLa64S128Const: -+ case kLa64S128Zero: -+ case kLa64S128AllOnes: -+ case kLa64S16x8InterleaveEven: -+ case kLa64S16x8InterleaveOdd: -+ case kLa64S16x8InterleaveLeft: -+ case kLa64S16x8InterleaveRight: -+ case kLa64S16x8PackEven: -+ case kLa64S16x8PackOdd: -+ case kLa64S16x2Reverse: -+ case kLa64S16x4Reverse: -+ case kLa64V8x16AllTrue: -+ case kLa64V8x16AnyTrue: -+ case kLa64V32x4AllTrue: -+ case kLa64V32x4AnyTrue: -+ case kLa64V16x8AllTrue: -+ case kLa64V16x8AnyTrue: -+ case kLa64S32x4InterleaveEven: -+ case kLa64S32x4InterleaveOdd: -+ case kLa64S32x4InterleaveLeft: -+ case kLa64S32x4InterleaveRight: -+ case kLa64S32x4PackEven: -+ case kLa64S32x4PackOdd: -+ case kLa64S32x4Shuffle: -+ case kLa64S8x16Concat: -+ case kLa64S8x16InterleaveEven: -+ case kLa64S8x16InterleaveOdd: -+ case kLa64S8x16InterleaveLeft: -+ case kLa64S8x16InterleaveRight: -+ case kLa64S8x16PackEven: -+ case kLa64S8x16PackOdd: -+ case kLa64S8x2Reverse: -+ case kLa64S8x4Reverse: -+ case kLa64S8x8Reverse: -+ case kLa64I8x16Shuffle: -+ case kLa64I8x16Swizzle: -+ case kLa64Sar: -+ case kLa64Seb: -+ case kLa64Seh: -+ case kLa64Shl: -+ case kLa64Shr: -+ case kLa64SqrtD: -+ case kLa64SqrtS: -+ case kLa64Sub: -+ case kLa64SubD: -+ case kLa64SubS: -+ case kLa64TruncLD: -+ case kLa64TruncLS: -+ case kLa64TruncUlD: -+ case kLa64TruncUlS: -+ case kLa64TruncUwD: -+ case kLa64TruncUwS: -+ case kLa64TruncWD: -+ case kLa64TruncWS: -+ case kLa64Tst: -+ case kLa64Xor: -+ case kLa64Xor32: -+ return kNoOpcodeFlags; -+ -+ case kLa64Lb: -+ case kLa64Lbu: -+ case kLa64Ld: -+ case kLa64Ldc1: -+ case kLa64Lh: -+ case kLa64Lhu: -+ case kLa64Lw: -+ case kLa64Lwc1: -+ case kLa64Lwu: -+ case kLa64Peek: -+ case kLa64Uld: -+ case kLa64Uldc1: -+ case kLa64Ulh: -+ case kLa64Ulhu: -+ case kLa64Ulw: -+ case kLa64Ulwu: -+ case kLa64Ulwc1: -+ case kLa64S8x16LoadSplat: -+ case kLa64S16x8LoadSplat: -+ case kLa64S32x4LoadSplat: -+ case kLa64S64x2LoadSplat: -+ case kLa64I16x8Load8x8S: -+ case kLa64I16x8Load8x8U: -+ case kLa64I32x4Load16x4S: -+ case kLa64I32x4Load16x4U: -+ case kLa64I64x2Load32x2S: -+ case kLa64I64x2Load32x2U: -+ case kLa64Word64AtomicLoadUint8: -+ case kLa64Word64AtomicLoadUint16: -+ case kLa64Word64AtomicLoadUint32: -+ case kLa64Word64AtomicLoadUint64: -+ -+ return kIsLoadOperation; -+ -+ case kLa64ModD: -+ case kLa64ModS: -+ case kLa64Push: -+ case kLa64Sb: -+ case kLa64Sd: -+ case kLa64Sdc1: -+ case kLa64Sh: -+ case kLa64StackClaim: -+ case kLa64StoreToStackSlot: -+ case kLa64Sw: -+ case kLa64Swc1: -+ case kLa64Usd: -+ case kLa64Usdc1: -+ case kLa64Ush: -+ case kLa64Usw: -+ case kLa64Uswc1: -+ case kLa64Sync: -+ case kLa64Word64AtomicStoreWord8: -+ case kLa64Word64AtomicStoreWord16: -+ case kLa64Word64AtomicStoreWord32: -+ case kLa64Word64AtomicStoreWord64: -+ case kLa64Word64AtomicAddUint8: -+ case kLa64Word64AtomicAddUint16: -+ case kLa64Word64AtomicAddUint32: -+ case kLa64Word64AtomicAddUint64: -+ case kLa64Word64AtomicSubUint8: -+ case kLa64Word64AtomicSubUint16: -+ case kLa64Word64AtomicSubUint32: -+ case kLa64Word64AtomicSubUint64: -+ case kLa64Word64AtomicAndUint8: -+ case kLa64Word64AtomicAndUint16: -+ case kLa64Word64AtomicAndUint32: -+ case kLa64Word64AtomicAndUint64: -+ case kLa64Word64AtomicOrUint8: -+ case kLa64Word64AtomicOrUint16: -+ case kLa64Word64AtomicOrUint32: -+ case kLa64Word64AtomicOrUint64: -+ case kLa64Word64AtomicXorUint8: -+ case kLa64Word64AtomicXorUint16: -+ case kLa64Word64AtomicXorUint32: -+ case kLa64Word64AtomicXorUint64: -+ case kLa64Word64AtomicExchangeUint8: -+ case kLa64Word64AtomicExchangeUint16: -+ case kLa64Word64AtomicExchangeUint32: -+ case kLa64Word64AtomicExchangeUint64: -+ case kLa64Word64AtomicCompareExchangeUint8: -+ case kLa64Word64AtomicCompareExchangeUint16: -+ case kLa64Word64AtomicCompareExchangeUint32: -+ case kLa64Word64AtomicCompareExchangeUint64: -+ return kHasSideEffect; -+ -+#define CASE(Name) case k##Name: -+ COMMON_ARCH_OPCODE_LIST(CASE) -+#undef CASE -+ // Already covered in architecture independent code. -+ UNREACHABLE(); -+ } -+ -+ UNREACHABLE(); -+} -+ -+enum Latency { -+ BRANCH = 4, // Estimated max. -+ RINT_S = 4, // Estimated. -+ RINT_D = 4, // Estimated. -+ -+ MULT = 4, -+ MULTU = 4, -+ DMULT = 4, -+ DMULTU = 4, -+ -+ MUL = 7, -+ DMUL = 7, -+ MUH = 7, -+ MUHU = 7, -+ DMUH = 7, -+ DMUHU = 7, -+ -+ DIV = 50, // Min:11 Max:50 -+ DDIV = 50, -+ DIVU = 50, -+ DDIVU = 50, -+ -+ ABS_S = 4, -+ ABS_D = 4, -+ NEG_S = 4, -+ NEG_D = 4, -+ ADD_S = 4, -+ ADD_D = 4, -+ SUB_S = 4, -+ SUB_D = 4, -+ MAX_S = 4, // Estimated. -+ MIN_S = 4, -+ MAX_D = 4, // Estimated. -+ MIN_D = 4, -+ C_cond_S = 4, -+ C_cond_D = 4, -+ MUL_S = 4, -+ -+ MADD_S = 4, -+ MSUB_S = 4, -+ NMADD_S = 4, -+ NMSUB_S = 4, -+ -+ CABS_cond_S = 4, -+ CABS_cond_D = 4, -+ -+ CVT_D_S = 4, -+ CVT_PS_PW = 4, -+ -+ CVT_S_W = 4, -+ CVT_S_L = 4, -+ CVT_D_W = 4, -+ CVT_D_L = 4, -+ -+ CVT_S_D = 4, -+ -+ CVT_W_S = 4, -+ CVT_W_D = 4, -+ CVT_L_S = 4, -+ CVT_L_D = 4, -+ -+ CEIL_W_S = 4, -+ CEIL_W_D = 4, -+ CEIL_L_S = 4, -+ CEIL_L_D = 4, -+ -+ FLOOR_W_S = 4, -+ FLOOR_W_D = 4, -+ FLOOR_L_S = 4, -+ FLOOR_L_D = 4, -+ -+ ROUND_W_S = 4, -+ ROUND_W_D = 4, -+ ROUND_L_S = 4, -+ ROUND_L_D = 4, -+ -+ TRUNC_W_S = 4, -+ TRUNC_W_D = 4, -+ TRUNC_L_S = 4, -+ TRUNC_L_D = 4, -+ -+ MOV_S = 4, -+ MOV_D = 4, -+ -+ MOVF_S = 4, -+ MOVF_D = 4, -+ -+ MOVN_S = 4, -+ MOVN_D = 4, -+ -+ MOVT_S = 4, -+ MOVT_D = 4, -+ -+ MOVZ_S = 4, -+ MOVZ_D = 4, -+ -+ MUL_D = 5, -+ MADD_D = 5, -+ MSUB_D = 5, -+ NMADD_D = 5, -+ NMSUB_D = 5, -+ -+ RECIP_S = 13, -+ RECIP_D = 26, -+ -+ RSQRT_S = 17, -+ RSQRT_D = 36, -+ -+ DIV_S = 17, -+ SQRT_S = 17, -+ -+ DIV_D = 32, -+ SQRT_D = 32, -+ -+ MTC1 = 4, -+ MTHC1 = 4, -+ DMTC1 = 4, -+ LWC1 = 4, -+ LDC1 = 4, -+ -+ MFC1 = 1, -+ MFHC1 = 1, -+ DMFC1 = 1, -+ MFHI = 1, -+ MFLO = 1, -+ SWC1 = 1, -+ SDC1 = 1, -+}; -+ -+int DadduLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int DsubuLatency(bool is_operand_register = true) { -+ return DadduLatency(is_operand_register); -+} -+ -+int AndLatency(bool is_operand_register = true) { -+ return DadduLatency(is_operand_register); -+} -+ -+int OrLatency(bool is_operand_register = true) { -+ return DadduLatency(is_operand_register); -+} -+ -+int NorLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int XorLatency(bool is_operand_register = true) { -+ return DadduLatency(is_operand_register); -+} -+ -+int MulLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::MUL; -+ } else { -+ return Latency::MUL + 1; -+ } -+} -+ -+int DmulLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::DMUL; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int MulhLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::MUH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int MulhuLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::MUH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int DMulhLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::DMUH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int DivLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::DIV; -+ } else { -+ return Latency::DIV + 1; -+ } -+} -+ -+int DivuLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::DIVU; -+ } else { -+ return Latency::DIVU + 1; -+ } -+} -+ -+int DdivLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::DDIV; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int DdivuLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = Latency::DDIVU; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int ModLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = 1; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int ModuLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = 1; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int DmodLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = 1; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int DmoduLatency(bool is_operand_register = true) { -+ int latency = 0; -+ latency = 1; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int MovzLatency() { return Latency::BRANCH + 1; } -+ -+int MovnLatency() { return Latency::BRANCH + 1; } -+ -+int DlsaLatency() { -+ // Estimated max. -+ return DadduLatency() + 1; -+} -+ -+int CallLatency() { -+ // Estimated. -+ return DadduLatency(false) + Latency::BRANCH + 5; -+} -+ -+int JumpLatency() { -+ // Estimated max. -+ return 1 + DadduLatency() + Latency::BRANCH + 2; -+} -+ -+int SmiUntagLatency() { return 1; } -+ -+int PrepareForTailCallLatency() { -+ // Estimated max. -+ return 2 * (DlsaLatency() + DadduLatency(false)) + 2 + Latency::BRANCH + -+ Latency::BRANCH + 2 * DsubuLatency(false) + 2 + Latency::BRANCH + 1; -+} -+ -+int AssemblePopArgumentsAdoptFrameLatency() { -+ return 1 + Latency::BRANCH + 1 + SmiUntagLatency() + -+ PrepareForTailCallLatency(); -+} -+ -+int AssertLatency() { return 1; } -+ -+int PrepareCallCFunctionLatency() { -+ int frame_alignment = TurboAssembler::ActivationFrameAlignment(); -+ if (frame_alignment > kSystemPointerSize) { -+ return 1 + DsubuLatency(false) + AndLatency(false) + 1; -+ } else { -+ return DsubuLatency(false); -+ } -+} -+ -+int AdjustBaseAndOffsetLatency() { -+ return 3; // Estimated max. -+} -+ -+int AlignedMemoryLatency() { return AdjustBaseAndOffsetLatency() + 1; } -+ -+int UlhuLatency() { return AlignedMemoryLatency(); } -+ -+int UlwLatency() { return AlignedMemoryLatency(); } -+ -+int UlwuLatency() { return AlignedMemoryLatency(); } -+ -+int UldLatency() { return AlignedMemoryLatency(); } -+ -+int Ulwc1Latency() { return AlignedMemoryLatency(); } -+ -+int Uldc1Latency() { return AlignedMemoryLatency(); } -+ -+int UshLatency() { return AlignedMemoryLatency(); } -+ -+int UswLatency() { return AlignedMemoryLatency(); } -+ -+int UsdLatency() { return AlignedMemoryLatency(); } -+ -+int Uswc1Latency() { return AlignedMemoryLatency(); } -+ -+int Usdc1Latency() { return AlignedMemoryLatency(); } -+ -+int Lwc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::LWC1; } -+ -+int Swc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::SWC1; } -+ -+int Sdc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::SDC1; } -+ -+int Ldc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::LDC1; } -+ -+int MultiPushLatency() { -+ int latency = DsubuLatency(false); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ latency++; -+ } -+ return latency; -+} -+ -+int MultiPushFPULatency() { -+ int latency = DsubuLatency(false); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ latency += Sdc1Latency(); -+ } -+ return latency; -+} -+ -+int PushCallerSavedLatency(SaveFPRegsMode fp_mode) { -+ int latency = MultiPushLatency(); -+ if (fp_mode == kSaveFPRegs) { -+ latency += MultiPushFPULatency(); -+ } -+ return latency; -+} -+ -+int MultiPopLatency() { -+ int latency = DadduLatency(false); -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ latency++; -+ } -+ return latency; -+} -+ -+int MultiPopFPULatency() { -+ int latency = DadduLatency(false); -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ latency += Ldc1Latency(); -+ } -+ return latency; -+} -+ -+int PopCallerSavedLatency(SaveFPRegsMode fp_mode) { -+ int latency = MultiPopLatency(); -+ if (fp_mode == kSaveFPRegs) { -+ latency += MultiPopFPULatency(); -+ } -+ return latency; -+} -+ -+int CallCFunctionHelperLatency() { -+ // Estimated. -+ int latency = AndLatency(false) + Latency::BRANCH + 2 + CallLatency(); -+ if (base::OS::ActivationFrameAlignment() > kSystemPointerSize) { -+ latency++; -+ } else { -+ latency += DadduLatency(false); -+ } -+ return latency; -+} -+ -+int CallCFunctionLatency() { return 1 + CallCFunctionHelperLatency(); } -+ -+int AssembleArchJumpLatency() { -+ // Estimated max. -+ return Latency::BRANCH; -+} -+ -+int GenerateSwitchTableLatency() { -+ int latency = 0; -+ latency = DlsaLatency() + 2; -+ latency += 2; -+ return latency; -+} -+ -+int AssembleArchTableSwitchLatency() { -+ return Latency::BRANCH + GenerateSwitchTableLatency(); -+} -+ -+int DropAndRetLatency() { -+ // Estimated max. -+ return DadduLatency(false) + JumpLatency(); -+} -+ -+int AssemblerReturnLatency() { -+ // Estimated max. -+ return DadduLatency(false) + MultiPopLatency() + MultiPopFPULatency() + -+ Latency::BRANCH + DadduLatency() + 1 + DropAndRetLatency(); -+} -+ -+int TryInlineTruncateDoubleToILatency() { -+ return 2 + Latency::TRUNC_W_D + Latency::MFC1 + 2 + AndLatency(false) + -+ Latency::BRANCH; -+} -+ -+int CallStubDelayedLatency() { return 1 + CallLatency(); } -+ -+int TruncateDoubleToIDelayedLatency() { -+ // TODO(la64): This no longer reflects how TruncateDoubleToI is called. -+ return TryInlineTruncateDoubleToILatency() + 1 + DsubuLatency(false) + -+ Sdc1Latency() + CallStubDelayedLatency() + DadduLatency(false) + 1; -+} -+ -+int CheckPageFlagLatency() { -+ return AndLatency(false) + AlignedMemoryLatency() + AndLatency(false) + -+ Latency::BRANCH; -+} -+ -+int SltuLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int BranchShortHelperLatency() { -+ return 2; // Estimated max. -+} -+ -+int BranchShortLatency() { return BranchShortHelperLatency(); } -+ -+int MoveLatency() { return 1; } -+ -+int MovToFloatParametersLatency() { return 2 * MoveLatency(); } -+ -+int MovFromFloatResultLatency() { return MoveLatency(); } -+ -+int DaddOverflowLatency() { -+ // Estimated max. -+ return 6; -+} -+ -+int DsubOverflowLatency() { -+ // Estimated max. -+ return 6; -+} -+ -+int MulOverflowLatency() { -+ // Estimated max. -+ return MulLatency() + MulhLatency() + 2; -+} -+ -+int DclzLatency() { return 1; } -+ -+int CtzLatency() { return 3 + DclzLatency(); } -+ -+int DctzLatency() { return 4; } -+ -+int PopcntLatency() { -+ return 2 + AndLatency() + DsubuLatency() + 1 + AndLatency() + 1 + -+ AndLatency() + DadduLatency() + 1 + DadduLatency() + 1 + AndLatency() + -+ 1 + MulLatency() + 1; -+} -+ -+int DpopcntLatency() { -+ return 2 + AndLatency() + DsubuLatency() + 1 + AndLatency() + 1 + -+ AndLatency() + DadduLatency() + 1 + DadduLatency() + 1 + AndLatency() + -+ 1 + DmulLatency() + 1; -+} -+ -+int CompareFLatency() { return Latency::C_cond_S; } -+ -+int CompareF32Latency() { return CompareFLatency(); } -+ -+int CompareF64Latency() { return CompareFLatency(); } -+ -+int CompareIsNanFLatency() { return CompareFLatency(); } -+ -+int CompareIsNanF32Latency() { return CompareIsNanFLatency(); } -+ -+int CompareIsNanF64Latency() { return CompareIsNanFLatency(); } -+ -+int NegsLatency() { return Latency::NEG_S; } -+ -+int NegdLatency() { return Latency::NEG_D; } -+ -+int Float64RoundLatency() { return Latency::RINT_D + 4; } -+ -+int Float32RoundLatency() { return Latency::RINT_S + 4; } -+ -+int Float32MaxLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF32Latency() + Latency::BRANCH; -+ return latency + Latency::MAX_S; -+} -+ -+int Float64MaxLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF64Latency() + Latency::BRANCH; -+ return latency + Latency::MAX_D; -+} -+ -+int Float32MinLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF32Latency() + Latency::BRANCH; -+ return latency + Latency::MIN_S; -+} -+ -+int Float64MinLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF64Latency() + Latency::BRANCH; -+ return latency + Latency::MIN_D; -+} -+ -+int TruncLSLatency(bool load_status) { -+ int latency = Latency::TRUNC_L_S + Latency::DMFC1; -+ if (load_status) { -+ latency += SltuLatency() + 7; -+ } -+ return latency; -+} -+ -+int TruncLDLatency(bool load_status) { -+ int latency = Latency::TRUNC_L_D + Latency::DMFC1; -+ if (load_status) { -+ latency += SltuLatency() + 7; -+ } -+ return latency; -+} -+ -+int TruncUlSLatency() { -+ // Estimated max. -+ return 2 * CompareF32Latency() + CompareIsNanF32Latency() + -+ 4 * Latency::BRANCH + Latency::SUB_S + 2 * Latency::TRUNC_L_S + -+ 3 * Latency::DMFC1 + OrLatency() + Latency::MTC1 + Latency::MOV_S + -+ SltuLatency() + 4; -+} -+ -+int TruncUlDLatency() { -+ // Estimated max. -+ return 2 * CompareF64Latency() + CompareIsNanF64Latency() + -+ 4 * Latency::BRANCH + Latency::SUB_D + 2 * Latency::TRUNC_L_D + -+ 3 * Latency::DMFC1 + OrLatency() + Latency::DMTC1 + Latency::MOV_D + -+ SltuLatency() + 4; -+} -+ -+int PushLatency() { return DadduLatency() + AlignedMemoryLatency(); } -+ -+int ByteSwapSignedLatency() { return 2; } -+ -+int LlLatency(int offset) { -+ bool is_one_instruction = is_int14(offset); -+ if (is_one_instruction) { -+ return 1; -+ } else { -+ return 3; -+ } -+} -+ -+int ExtractBitsLatency(bool sign_extend, int size) { -+ int latency = 2; -+ if (sign_extend) { -+ switch (size) { -+ case 8: -+ case 16: -+ case 32: -+ latency += 1; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ return latency; -+} -+ -+int InsertBitsLatency() { return 2 + DsubuLatency(false) + 2; } -+ -+int ScLatency(int offset) { -+ bool is_one_instruction = is_int14(offset); -+ if (is_one_instruction) { -+ return 1; -+ } else { -+ return 3; -+ } -+} -+ -+int Word32AtomicExchangeLatency(bool sign_extend, int size) { -+ return DadduLatency(false) + 1 + DsubuLatency() + 2 + LlLatency(0) + -+ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + -+ ScLatency(0) + BranchShortLatency() + 1; -+} -+ -+int Word32AtomicCompareExchangeLatency(bool sign_extend, int size) { -+ return 2 + DsubuLatency() + 2 + LlLatency(0) + -+ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + -+ ScLatency(0) + BranchShortLatency() + 1; -+} -+ -+int InstructionScheduler::GetInstructionLatency(const Instruction* instr) { -+ // Basic latency modeling for LA64 instructions. They have been determined -+ // in empirical way. -+ switch (instr->arch_opcode()) { -+ case kArchCallCodeObject: -+ case kArchCallWasmFunction: -+ return CallLatency(); -+ case kArchTailCallCodeObjectFromJSFunction: -+ case kArchTailCallCodeObject: { -+ int latency = 0; -+ if (instr->arch_opcode() == kArchTailCallCodeObjectFromJSFunction) { -+ latency = AssemblePopArgumentsAdoptFrameLatency(); -+ } -+ return latency + JumpLatency(); -+ } -+ case kArchTailCallWasm: -+ case kArchTailCallAddress: -+ return JumpLatency(); -+ case kArchCallJSFunction: { -+ int latency = 0; -+ if (FLAG_debug_code) { -+ latency = 1 + AssertLatency(); -+ } -+ return latency + 1 + DadduLatency(false) + CallLatency(); -+ } -+ case kArchPrepareCallCFunction: -+ return PrepareCallCFunctionLatency(); -+ case kArchSaveCallerRegisters: { -+ auto fp_mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ return PushCallerSavedLatency(fp_mode); -+ } -+ case kArchRestoreCallerRegisters: { -+ auto fp_mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ return PopCallerSavedLatency(fp_mode); -+ } -+ case kArchPrepareTailCall: -+ return 2; -+ case kArchCallCFunction: -+ return CallCFunctionLatency(); -+ case kArchJmp: -+ return AssembleArchJumpLatency(); -+ case kArchTableSwitch: -+ return AssembleArchTableSwitchLatency(); -+ case kArchAbortCSAAssert: -+ return CallLatency() + 1; -+ case kArchDebugBreak: -+ return 1; -+ case kArchComment: -+ case kArchNop: -+ case kArchThrowTerminator: -+ case kArchDeoptimize: -+ return 0; -+ case kArchRet: -+ return AssemblerReturnLatency(); -+ case kArchFramePointer: -+ return 1; -+ case kArchParentFramePointer: -+ // Estimated max. -+ return AlignedMemoryLatency(); -+ case kArchTruncateDoubleToI: -+ return TruncateDoubleToIDelayedLatency(); -+ case kArchStoreWithWriteBarrier: -+ return DadduLatency() + 1 + CheckPageFlagLatency(); -+ case kArchStackSlot: -+ // Estimated max. -+ return DadduLatency(false) + AndLatency(false) + AssertLatency() + -+ DadduLatency(false) + AndLatency(false) + BranchShortLatency() + -+ 1 + DsubuLatency() + DadduLatency(); -+ case kArchWordPoisonOnSpeculation: -+ return AndLatency(); -+ case kIeee754Float64Acos: -+ case kIeee754Float64Acosh: -+ case kIeee754Float64Asin: -+ case kIeee754Float64Asinh: -+ case kIeee754Float64Atan: -+ case kIeee754Float64Atanh: -+ case kIeee754Float64Atan2: -+ case kIeee754Float64Cos: -+ case kIeee754Float64Cosh: -+ case kIeee754Float64Cbrt: -+ case kIeee754Float64Exp: -+ case kIeee754Float64Expm1: -+ case kIeee754Float64Log: -+ case kIeee754Float64Log1p: -+ case kIeee754Float64Log10: -+ case kIeee754Float64Log2: -+ case kIeee754Float64Pow: -+ case kIeee754Float64Sin: -+ case kIeee754Float64Sinh: -+ case kIeee754Float64Tan: -+ case kIeee754Float64Tanh: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kLa64Add: -+ case kLa64Dadd: -+ return DadduLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64DaddOvf: -+ return DaddOverflowLatency(); -+ case kLa64Sub: -+ case kLa64Dsub: -+ return DsubuLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64DsubOvf: -+ return DsubOverflowLatency(); -+ case kLa64Mul: -+ return MulLatency(); -+ case kLa64MulOvf: -+ return MulOverflowLatency(); -+ case kLa64MulHigh: -+ return MulhLatency(); -+ case kLa64MulHighU: -+ return MulhuLatency(); -+ case kLa64DMulHigh: -+ return DMulhLatency(); -+ case kLa64Div: { -+ int latency = DivLatency(instr->InputAt(1)->IsRegister()); -+ return latency++; -+ } -+ case kLa64DivU: { -+ int latency = DivuLatency(instr->InputAt(1)->IsRegister()); -+ return latency++; -+ } -+ case kLa64Mod: -+ return ModLatency(); -+ case kLa64ModU: -+ return ModuLatency(); -+ case kLa64Dmul: -+ return DmulLatency(); -+ case kLa64Ddiv: { -+ int latency = DdivLatency(); -+ return latency++; -+ } -+ case kLa64DdivU: { -+ int latency = DdivuLatency(); -+ return latency++; -+ } -+ case kLa64Dmod: -+ return DmodLatency(); -+ case kLa64DmodU: -+ return DmoduLatency(); -+ case kLa64Dlsa: -+ case kLa64Lsa: -+ return DlsaLatency(); -+ case kLa64And: -+ return AndLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64And32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = AndLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kLa64Or: -+ return OrLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64Or32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = OrLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kLa64Nor: -+ return NorLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64Nor32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = NorLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kLa64Xor: -+ return XorLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64Xor32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = XorLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kLa64Clz: -+ case kLa64Dclz: -+ return DclzLatency(); -+ case kLa64Ctz: -+ return CtzLatency(); -+ case kLa64Dctz: -+ return DctzLatency(); -+ case kLa64Popcnt: -+ return PopcntLatency(); -+ case kLa64Dpopcnt: -+ return DpopcntLatency(); -+ case kLa64Shl: -+ return 1; -+ case kLa64Shr: -+ case kLa64Sar: -+ return 2; -+ case kLa64Ext: -+ case kLa64Ins: -+ case kLa64Dext: -+ case kLa64Dins: -+ case kLa64Dshl: -+ case kLa64Dshr: -+ case kLa64Dsar: -+ case kLa64Ror: -+ case kLa64Dror: -+ return 1; -+ case kLa64Tst: -+ return AndLatency(instr->InputAt(1)->IsRegister()); -+ case kLa64Mov: -+ return 1; -+ case kLa64CmpS: -+ return MoveLatency() + CompareF32Latency(); -+ case kLa64AddS: -+ return Latency::ADD_S; -+ case kLa64SubS: -+ return Latency::SUB_S; -+ case kLa64MulS: -+ return Latency::MUL_S; -+ case kLa64DivS: -+ return Latency::DIV_S; -+ case kLa64ModS: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kLa64AbsS: -+ return Latency::ABS_S; -+ case kLa64NegS: -+ return NegdLatency(); -+ case kLa64SqrtS: -+ return Latency::SQRT_S; -+ case kLa64MaxS: -+ return Latency::MAX_S; -+ case kLa64MinS: -+ return Latency::MIN_S; -+ case kLa64CmpD: -+ return MoveLatency() + CompareF64Latency(); -+ case kLa64AddD: -+ return Latency::ADD_D; -+ case kLa64SubD: -+ return Latency::SUB_D; -+ case kLa64MulD: -+ return Latency::MUL_D; -+ case kLa64DivD: -+ return Latency::DIV_D; -+ case kLa64ModD: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kLa64AbsD: -+ return Latency::ABS_D; -+ case kLa64NegD: -+ return NegdLatency(); -+ case kLa64SqrtD: -+ return Latency::SQRT_D; -+ case kLa64MaxD: -+ return Latency::MAX_D; -+ case kLa64MinD: -+ return Latency::MIN_D; -+ case kLa64Float64RoundDown: -+ case kLa64Float64RoundTruncate: -+ case kLa64Float64RoundUp: -+ case kLa64Float64RoundTiesEven: -+ return Float64RoundLatency(); -+ case kLa64Float32RoundDown: -+ case kLa64Float32RoundTruncate: -+ case kLa64Float32RoundUp: -+ case kLa64Float32RoundTiesEven: -+ return Float32RoundLatency(); -+ case kLa64Float32Max: -+ return Float32MaxLatency(); -+ case kLa64Float64Max: -+ return Float64MaxLatency(); -+ case kLa64Float32Min: -+ return Float32MinLatency(); -+ case kLa64Float64Min: -+ return Float64MinLatency(); -+ case kLa64Float64SilenceNaN: -+ return Latency::SUB_D; -+ case kLa64CvtSD: -+ return Latency::CVT_S_D; -+ case kLa64CvtDS: -+ return Latency::CVT_D_S; -+ case kLa64CvtDW: -+ return Latency::MTC1 + Latency::CVT_D_W; -+ case kLa64CvtSW: -+ return Latency::MTC1 + Latency::CVT_S_W; -+ case kLa64CvtSUw: -+ return 1 + Latency::DMTC1 + Latency::CVT_S_L; -+ case kLa64CvtSL: -+ return Latency::DMTC1 + Latency::CVT_S_L; -+ case kLa64CvtDL: -+ return Latency::DMTC1 + Latency::CVT_D_L; -+ case kLa64CvtDUw: -+ return 1 + Latency::DMTC1 + Latency::CVT_D_L; -+ case kLa64CvtDUl: -+ return 2 * Latency::BRANCH + 3 + 2 * Latency::DMTC1 + -+ 2 * Latency::CVT_D_L + Latency::ADD_D; -+ case kLa64CvtSUl: -+ return 2 * Latency::BRANCH + 3 + 2 * Latency::DMTC1 + -+ 2 * Latency::CVT_S_L + Latency::ADD_S; -+ case kLa64FloorWD: -+ return Latency::FLOOR_W_D + Latency::MFC1; -+ case kLa64CeilWD: -+ return Latency::CEIL_W_D + Latency::MFC1; -+ case kLa64RoundWD: -+ return Latency::ROUND_W_D + Latency::MFC1; -+ case kLa64TruncWD: -+ return Latency::TRUNC_W_D + Latency::MFC1; -+ case kLa64FloorWS: -+ return Latency::FLOOR_W_S + Latency::MFC1; -+ case kLa64CeilWS: -+ return Latency::CEIL_W_S + Latency::MFC1; -+ case kLa64RoundWS: -+ return Latency::ROUND_W_S + Latency::MFC1; -+ case kLa64TruncWS: -+ return Latency::TRUNC_W_S + Latency::MFC1 + 2 + MovnLatency(); -+ case kLa64TruncLS: -+ return TruncLSLatency(instr->OutputCount() > 1); -+ case kLa64TruncLD: -+ return TruncLDLatency(instr->OutputCount() > 1); -+ case kLa64TruncUwD: -+ // Estimated max. -+ return CompareF64Latency() + 2 * Latency::BRANCH + -+ 2 * Latency::TRUNC_W_D + Latency::SUB_D + OrLatency() + -+ Latency::MTC1 + Latency::MFC1 + Latency::MTHC1 + 1; -+ case kLa64TruncUwS: -+ // Estimated max. -+ return CompareF32Latency() + 2 * Latency::BRANCH + -+ 2 * Latency::TRUNC_W_S + Latency::SUB_S + OrLatency() + -+ Latency::MTC1 + 2 * Latency::MFC1 + 2 + MovzLatency(); -+ case kLa64TruncUlS: -+ return TruncUlSLatency(); -+ case kLa64TruncUlD: -+ return TruncUlDLatency(); -+ case kLa64BitcastDL: -+ return Latency::DMFC1; -+ case kLa64BitcastLD: -+ return Latency::DMTC1; -+ case kLa64Float64ExtractLowWord32: -+ return Latency::MFC1; -+ case kLa64Float64InsertLowWord32: -+ return Latency::MFHC1 + Latency::MTC1 + Latency::MTHC1; -+ case kLa64Float64ExtractHighWord32: -+ return Latency::MFHC1; -+ case kLa64Float64InsertHighWord32: -+ return Latency::MTHC1; -+ case kLa64Seb: -+ case kLa64Seh: -+ return 1; -+ case kLa64Lbu: -+ case kLa64Lb: -+ case kLa64Lhu: -+ case kLa64Lh: -+ case kLa64Lwu: -+ case kLa64Lw: -+ case kLa64Ld: -+ case kLa64Sb: -+ case kLa64Sh: -+ case kLa64Sw: -+ case kLa64Sd: -+ return AlignedMemoryLatency(); -+ case kLa64Lwc1: -+ return Lwc1Latency(); -+ case kLa64Ldc1: -+ return Ldc1Latency(); -+ case kLa64Swc1: -+ return Swc1Latency(); -+ case kLa64Sdc1: -+ return Sdc1Latency(); -+ case kLa64Ulhu: -+ case kLa64Ulh: -+ return UlhuLatency(); -+ case kLa64Ulwu: -+ return UlwuLatency(); -+ case kLa64Ulw: -+ return UlwLatency(); -+ case kLa64Uld: -+ return UldLatency(); -+ case kLa64Ulwc1: -+ return Ulwc1Latency(); -+ case kLa64Uldc1: -+ return Uldc1Latency(); -+ case kLa64Ush: -+ return UshLatency(); -+ case kLa64Usw: -+ return UswLatency(); -+ case kLa64Usd: -+ return UsdLatency(); -+ case kLa64Uswc1: -+ return Uswc1Latency(); -+ case kLa64Usdc1: -+ return Usdc1Latency(); -+ case kLa64Push: { -+ int latency = 0; -+ if (instr->InputAt(0)->IsFPRegister()) { -+ latency = Sdc1Latency() + DsubuLatency(false); -+ } else { -+ latency = PushLatency(); -+ } -+ return latency; -+ } -+ case kLa64Peek: { -+ int latency = 0; -+ if (instr->OutputAt(0)->IsFPRegister()) { -+ auto op = LocationOperand::cast(instr->OutputAt(0)); -+ switch (op->representation()) { -+ case MachineRepresentation::kFloat64: -+ latency = Ldc1Latency(); -+ break; -+ case MachineRepresentation::kFloat32: -+ latency = Latency::LWC1; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } else { -+ latency = AlignedMemoryLatency(); -+ } -+ return latency; -+ } -+ case kLa64StackClaim: -+ return DsubuLatency(false); -+ case kLa64StoreToStackSlot: { -+ int latency = 0; -+ if (instr->InputAt(0)->IsFPRegister()) { -+ if (instr->InputAt(0)->IsSimd128Register()) { -+ latency = 1; // Estimated value. -+ } else { -+ latency = Sdc1Latency(); -+ } -+ } else { -+ latency = AlignedMemoryLatency(); -+ } -+ return latency; -+ } -+ case kLa64ByteSwap64: -+ return ByteSwapSignedLatency(); -+ case kLa64ByteSwap32: -+ return ByteSwapSignedLatency(); -+ case kWord32AtomicLoadInt8: -+ case kWord32AtomicLoadUint8: -+ case kWord32AtomicLoadInt16: -+ case kWord32AtomicLoadUint16: -+ case kWord32AtomicLoadWord32: -+ return 2; -+ case kWord32AtomicStoreWord8: -+ case kWord32AtomicStoreWord16: -+ case kWord32AtomicStoreWord32: -+ return 3; -+ case kWord32AtomicExchangeInt8: -+ return Word32AtomicExchangeLatency(true, 8); -+ case kWord32AtomicExchangeUint8: -+ return Word32AtomicExchangeLatency(false, 8); -+ case kWord32AtomicExchangeInt16: -+ return Word32AtomicExchangeLatency(true, 16); -+ case kWord32AtomicExchangeUint16: -+ return Word32AtomicExchangeLatency(false, 16); -+ case kWord32AtomicExchangeWord32: -+ return 2 + LlLatency(0) + 1 + ScLatency(0) + BranchShortLatency() + 1; -+ case kWord32AtomicCompareExchangeInt8: -+ return Word32AtomicCompareExchangeLatency(true, 8); -+ case kWord32AtomicCompareExchangeUint8: -+ return Word32AtomicCompareExchangeLatency(false, 8); -+ case kWord32AtomicCompareExchangeInt16: -+ return Word32AtomicCompareExchangeLatency(true, 16); -+ case kWord32AtomicCompareExchangeUint16: -+ return Word32AtomicCompareExchangeLatency(false, 16); -+ case kWord32AtomicCompareExchangeWord32: -+ return 3 + LlLatency(0) + BranchShortLatency() + 1 + ScLatency(0) + -+ BranchShortLatency() + 1; -+ case kLa64AssertEqual: -+ return AssertLatency(); -+ default: -+ return 1; -+ } -+} -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 -diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc -new file mode 100644 -index 000000000..ff0a617ca ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc -@@ -0,0 +1,3170 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/base/bits.h" -+#include "src/compiler/backend/instruction-selector-impl.h" -+#include "src/compiler/node-matchers.h" -+#include "src/compiler/node-properties.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+#define TRACE_UNIMPL() \ -+ PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) -+ -+#define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) -+ -+// Adds la64-specific methods for generating InstructionOperands. -+class La64OperandGenerator final : public OperandGenerator { -+ public: -+ explicit La64OperandGenerator(InstructionSelector* selector) -+ : OperandGenerator(selector) {} -+ -+ InstructionOperand UseOperand(Node* node, InstructionCode opcode) { -+ if (CanBeImmediate(node, opcode)) { -+ return UseImmediate(node); -+ } -+ return UseRegister(node); -+ } -+ -+ // Use the zero register if the node has the immediate value zero, otherwise -+ // assign a register. -+ InstructionOperand UseRegisterOrImmediateZero(Node* node) { -+ if ((IsIntegerConstant(node) && (GetIntegerConstantValue(node) == 0)) || -+ (IsFloatConstant(node) && -+ (bit_cast(GetFloatConstantValue(node)) == 0))) { -+ return UseImmediate(node); -+ } -+ return UseRegister(node); -+ } -+ -+ bool IsIntegerConstant(Node* node) { -+ return (node->opcode() == IrOpcode::kInt32Constant) || -+ (node->opcode() == IrOpcode::kInt64Constant); -+ } -+ -+ int64_t GetIntegerConstantValue(Node* node) { -+ if (node->opcode() == IrOpcode::kInt32Constant) { -+ return OpParameter(node->op()); -+ } -+ DCHECK_EQ(IrOpcode::kInt64Constant, node->opcode()); -+ return OpParameter(node->op()); -+ } -+ -+ bool IsFloatConstant(Node* node) { -+ return (node->opcode() == IrOpcode::kFloat32Constant) || -+ (node->opcode() == IrOpcode::kFloat64Constant); -+ } -+ -+ double GetFloatConstantValue(Node* node) { -+ if (node->opcode() == IrOpcode::kFloat32Constant) { -+ return OpParameter(node->op()); -+ } -+ DCHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); -+ return OpParameter(node->op()); -+ } -+ -+ bool CanBeImmediate(Node* node, InstructionCode mode) { -+ return IsIntegerConstant(node) && -+ CanBeImmediate(GetIntegerConstantValue(node), mode); -+ } -+ -+ bool CanBeImmediate(int64_t value, InstructionCode opcode) { -+ switch (ArchOpcodeField::decode(opcode)) { -+ case kLa64Shl: -+ case kLa64Sar: -+ case kLa64Shr: -+ return is_uint5(value); -+ case kLa64Dshl: -+ case kLa64Dsar: -+ case kLa64Dshr: -+ return is_uint6(value); -+ case kLa64Add: -+ case kLa64And32: -+ case kLa64And: -+ case kLa64Dadd: -+ case kLa64Or32: -+ case kLa64Or: -+ case kLa64Tst: -+ case kLa64Xor: -+ return is_uint12(value); -+ case kLa64Lb: -+ case kLa64Lbu: -+ case kLa64Sb: -+ case kLa64Lh: -+ case kLa64Lhu: -+ case kLa64Sh: -+ case kLa64Lw: -+ case kLa64Sw: -+ case kLa64Ld: -+ case kLa64Sd: -+ case kLa64Lwc1: -+ case kLa64Swc1: -+ case kLa64Ldc1: -+ case kLa64Sdc1: -+ return is_int12(value); -+ default: -+ return is_int12(value); -+ } -+ } -+ -+ private: -+ bool ImmediateFitsAddrMode1Instruction(int32_t imm) const { -+ TRACE_UNIMPL(); -+ return false; -+ } -+}; -+ -+static void VisitRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+static void VisitRRI(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ int32_t imm = OpParameter(node->op()); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm)); -+} -+ -+static void VisitSimdShift(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ if (g.IsIntegerConstant(node->InputAt(1))) { -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseImmediate(node->InputAt(1))); -+ } else { -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+ } -+} -+ -+static void VisitRRIR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ int32_t imm = OpParameter(node->op()); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm), -+ g.UseRegister(node->InputAt(1))); -+} -+ -+static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+} -+ -+static void VisitUniqueRRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseUniqueRegister(node->InputAt(0)), -+ g.UseUniqueRegister(node->InputAt(1))); -+} -+ -+void VisitRRRR(InstructionSelector* selector, ArchOpcode opcode, Node* node) { -+ La64OperandGenerator g(selector); -+ selector->Emit( -+ opcode, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(2))); -+} -+ -+static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ La64OperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseOperand(node->InputAt(1), opcode)); -+} -+ -+struct ExtendingLoadMatcher { -+ ExtendingLoadMatcher(Node* node, InstructionSelector* selector) -+ : matches_(false), selector_(selector), base_(nullptr), immediate_(0) { -+ Initialize(node); -+ } -+ -+ bool Matches() const { return matches_; } -+ -+ Node* base() const { -+ DCHECK(Matches()); -+ return base_; -+ } -+ int64_t immediate() const { -+ DCHECK(Matches()); -+ return immediate_; -+ } -+ ArchOpcode opcode() const { -+ DCHECK(Matches()); -+ return opcode_; -+ } -+ -+ private: -+ bool matches_; -+ InstructionSelector* selector_; -+ Node* base_; -+ int64_t immediate_; -+ ArchOpcode opcode_; -+ -+ void Initialize(Node* node) { -+ Int64BinopMatcher m(node); -+ // When loading a 64-bit value and shifting by 32, we should -+ // just load and sign-extend the interesting 4 bytes instead. -+ // This happens, for example, when we're loading and untagging SMIs. -+ DCHECK(m.IsWord64Sar()); -+ if (m.left().IsLoad() && m.right().Is(32) && -+ selector_->CanCover(m.node(), m.left().node())) { -+ DCHECK_EQ(selector_->GetEffectLevel(node), -+ selector_->GetEffectLevel(m.left().node())); -+ MachineRepresentation rep = -+ LoadRepresentationOf(m.left().node()->op()).representation(); -+ DCHECK_EQ(3, ElementSizeLog2Of(rep)); -+ if (rep != MachineRepresentation::kTaggedSigned && -+ rep != MachineRepresentation::kTaggedPointer && -+ rep != MachineRepresentation::kTagged && -+ rep != MachineRepresentation::kWord64) { -+ return; -+ } -+ -+ La64OperandGenerator g(selector_); -+ Node* load = m.left().node(); -+ Node* offset = load->InputAt(1); -+ base_ = load->InputAt(0); -+ opcode_ = kLa64Lw; -+ if (g.CanBeImmediate(offset, opcode_)) { -+ immediate_ = g.GetIntegerConstantValue(offset) + 4; -+ matches_ = g.CanBeImmediate(immediate_, kLa64Lw); -+ } -+ } -+ } -+}; -+ -+bool TryEmitExtendingLoad(InstructionSelector* selector, Node* node, -+ Node* output_node) { -+ ExtendingLoadMatcher m(node, selector); -+ La64OperandGenerator g(selector); -+ if (m.Matches()) { -+ InstructionOperand inputs[2]; -+ inputs[0] = g.UseRegister(m.base()); -+ InstructionCode opcode = -+ m.opcode() | AddressingModeField::encode(kMode_MRI); -+ DCHECK(is_int32(m.immediate())); -+ inputs[1] = g.TempImmediate(static_cast(m.immediate())); -+ InstructionOperand outputs[] = {g.DefineAsRegister(output_node)}; -+ selector->Emit(opcode, arraysize(outputs), outputs, arraysize(inputs), -+ inputs); -+ return true; -+ } -+ return false; -+} -+ -+bool TryMatchImmediate(InstructionSelector* selector, -+ InstructionCode* opcode_return, Node* node, -+ size_t* input_count_return, InstructionOperand* inputs) { -+ La64OperandGenerator g(selector); -+ if (g.CanBeImmediate(node, *opcode_return)) { -+ *opcode_return |= AddressingModeField::encode(kMode_MRI); -+ inputs[0] = g.UseImmediate(node); -+ *input_count_return = 1; -+ return true; -+ } -+ return false; -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, bool has_reverse_opcode, -+ InstructionCode reverse_opcode, -+ FlagsContinuation* cont) { -+ La64OperandGenerator g(selector); -+ Int32BinopMatcher m(node); -+ InstructionOperand inputs[2]; -+ size_t input_count = 0; -+ InstructionOperand outputs[1]; -+ size_t output_count = 0; -+ -+ if (TryMatchImmediate(selector, &opcode, m.right().node(), &input_count, -+ &inputs[1])) { -+ inputs[0] = g.UseRegister(m.left().node()); -+ input_count++; -+ } else if (has_reverse_opcode && -+ TryMatchImmediate(selector, &reverse_opcode, m.left().node(), -+ &input_count, &inputs[1])) { -+ inputs[0] = g.UseRegister(m.right().node()); -+ opcode = reverse_opcode; -+ input_count++; -+ } else { -+ inputs[input_count++] = g.UseRegister(m.left().node()); -+ inputs[input_count++] = g.UseOperand(m.right().node(), opcode); -+ } -+ -+ if (cont->IsDeoptimize()) { -+ // If we can deoptimize as a result of the binop, we need to make sure that -+ // the deopt inputs are not overwritten by the binop result. One way -+ // to achieve that is to declare the output register as same-as-first. -+ outputs[output_count++] = g.DefineSameAsFirst(node); -+ } else { -+ outputs[output_count++] = g.DefineAsRegister(node); -+ } -+ -+ DCHECK_NE(0u, input_count); -+ DCHECK_EQ(1u, output_count); -+ DCHECK_GE(arraysize(inputs), input_count); -+ DCHECK_GE(arraysize(outputs), output_count); -+ -+ selector->EmitWithContinuation(opcode, output_count, outputs, input_count, -+ inputs, cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, bool has_reverse_opcode, -+ InstructionCode reverse_opcode) { -+ FlagsContinuation cont; -+ VisitBinop(selector, node, opcode, has_reverse_opcode, reverse_opcode, &cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont) { -+ VisitBinop(selector, node, opcode, false, kArchNop, cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode) { -+ VisitBinop(selector, node, opcode, false, kArchNop); -+} -+ -+void InstructionSelector::VisitStackSlot(Node* node) { -+ StackSlotRepresentation rep = StackSlotRepresentationOf(node->op()); -+ int alignment = rep.alignment(); -+ int slot = frame_->AllocateSpillSlot(rep.size(), alignment); -+ OperandGenerator g(this); -+ -+ Emit(kArchStackSlot, g.DefineAsRegister(node), -+ sequence()->AddImmediate(Constant(slot)), -+ sequence()->AddImmediate(Constant(alignment)), 0, nullptr); -+} -+ -+void InstructionSelector::VisitAbortCSAAssert(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), a0)); -+} -+ -+void EmitLoad(InstructionSelector* selector, Node* node, InstructionCode opcode, -+ Node* output = nullptr) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(output == nullptr ? node : output), -+ g.UseRegister(base), g.UseImmediate(index)); -+ } else { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRR), -+ g.DefineAsRegister(output == nullptr ? node : output), -+ g.UseRegister(base), g.UseRegister(index)); -+ } -+} -+ -+void InstructionSelector::VisitLoadTransform(Node* node) { -+ LoadTransformParameters params = LoadTransformParametersOf(node->op()); -+ -+ InstructionCode opcode = kArchNop; -+ switch (params.transformation) { -+ case LoadTransformation::kS8x16LoadSplat: -+ opcode = kLa64S8x16LoadSplat; -+ break; -+ case LoadTransformation::kS16x8LoadSplat: -+ opcode = kLa64S16x8LoadSplat; -+ break; -+ case LoadTransformation::kS32x4LoadSplat: -+ opcode = kLa64S32x4LoadSplat; -+ break; -+ case LoadTransformation::kS64x2LoadSplat: -+ opcode = kLa64S64x2LoadSplat; -+ break; -+ case LoadTransformation::kI16x8Load8x8S: -+ opcode = kLa64I16x8Load8x8S; -+ break; -+ case LoadTransformation::kI16x8Load8x8U: -+ opcode = kLa64I16x8Load8x8U; -+ break; -+ case LoadTransformation::kI32x4Load16x4S: -+ opcode = kLa64I32x4Load16x4S; -+ break; -+ case LoadTransformation::kI32x4Load16x4U: -+ opcode = kLa64I32x4Load16x4U; -+ break; -+ case LoadTransformation::kI64x2Load32x2S: -+ opcode = kLa64I64x2Load32x2S; -+ break; -+ case LoadTransformation::kI64x2Load32x2U: -+ opcode = kLa64I64x2Load32x2U; -+ break; -+ default: -+ UNIMPLEMENTED(); -+ } -+ -+ EmitLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ -+ InstructionCode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kFloat32: -+ opcode = kLa64Lwc1; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kLa64Ldc1; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kLa64Lhu : kLa64Lh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = load_rep.IsUnsigned() ? kLa64Lwu : kLa64Lw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Ld; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ case MachineRepresentation::kSimd128: -+ UNREACHABLE(); -+ } -+ if (node->opcode() == IrOpcode::kPoisonedLoad) { -+ CHECK_NE(poisoning_level_, PoisoningMitigationLevel::kDontPoison); -+ opcode |= MiscField::encode(kMemoryAccessPoisoned); -+ } -+ -+ EmitLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitPoisonedLoad(Node* node) { VisitLoad(node); } -+ -+void InstructionSelector::VisitProtectedLoad(Node* node) { -+ // TODO(eholk) -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitStore(Node* node) { -+ La64OperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ StoreRepresentation store_rep = StoreRepresentationOf(node->op()); -+ WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); -+ MachineRepresentation rep = store_rep.representation(); -+ -+ if (FLAG_enable_unconditional_write_barriers && CanBeTaggedPointer(rep)) { -+ write_barrier_kind = kFullWriteBarrier; -+ } -+ -+ // TODO(la64): I guess this could be done in a better way. -+ if (write_barrier_kind != kNoWriteBarrier && -+ V8_LIKELY(!FLAG_disable_write_barriers)) { -+ DCHECK(CanBeTaggedPointer(rep)); -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ RecordWriteMode record_write_mode = -+ WriteBarrierKindToRecordWriteMode(write_barrier_kind); -+ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; -+ size_t const temp_count = arraysize(temps); -+ InstructionCode code = kArchStoreWithWriteBarrier; -+ code |= MiscField::encode(static_cast(record_write_mode)); -+ Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); -+ } else { -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kFloat32: -+ opcode = kLa64Swc1; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kLa64Sdc1; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = kLa64Sb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kLa64Sh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kLa64Sw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Sd; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ case MachineRepresentation::kSimd128: -+ UNREACHABLE(); -+ return; -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ Emit(opcode | AddressingModeField::encode(kMode_MRR), g.NoOutput(), -+ g.UseRegister(base), g.UseRegister(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } -+ } -+} -+ -+void InstructionSelector::VisitProtectedStore(Node* node) { -+ // TODO(eholk) -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitWord32And(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32Shr() && CanCover(node, m.left().node()) && -+ m.right().HasValue()) { -+ uint32_t mask = m.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { -+ // The mask must be contiguous, and occupy the least-significant bits. -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); -+ -+ // Select Ext for And(Shr(x, imm), mask) where the mask is in the least -+ // significant bits. -+ Int32BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue()) { -+ // Any shift value can match; int32 shifts use `value % 32`. -+ uint32_t lsb = mleft.right().Value() & 0x1F; -+ -+ // Ext cannot extract bits past the register size, however since -+ // shifting the original value would have introduced some zeros we can -+ // still use Ext with a smaller mask and the remaining bits will be -+ // zeros. -+ if (lsb + mask_width > 32) mask_width = 32 - lsb; -+ -+ Emit(kLa64Ext, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), -+ g.TempImmediate(mask_width)); -+ return; -+ } -+ // Other cases fall through to the normal And operation. -+ } -+ } -+ if (m.right().HasValue()) { -+ uint32_t mask = m.right().Value(); -+ uint32_t shift = base::bits::CountPopulation(~mask); -+ uint32_t msb = base::bits::CountLeadingZeros32(~mask); -+ if (shift != 0 && shift != 32 && msb + shift == 32) { -+ // Insert zeros for (x >> K) << K => x & ~(2^K - 1) expression reduction -+ // and remove constant loading of inverted mask. -+ Emit(kLa64Ins, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0), g.TempImmediate(shift)); -+ return; -+ } -+ } -+ VisitBinop(this, node, kLa64And32, true, kLa64And32); -+} -+ -+void InstructionSelector::VisitWord64And(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ if (m.left().IsWord64Shr() && CanCover(node, m.left().node()) && -+ m.right().HasValue()) { -+ uint64_t mask = m.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { -+ // The mask must be contiguous, and occupy the least-significant bits. -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); -+ -+ // Select Dext for And(Shr(x, imm), mask) where the mask is in the least -+ // significant bits. -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue()) { -+ // Any shift value can match; int64 shifts use `value % 64`. -+ uint32_t lsb = static_cast(mleft.right().Value() & 0x3F); -+ -+ // Dext cannot extract bits past the register size, however since -+ // shifting the original value would have introduced some zeros we can -+ // still use Dext with a smaller mask and the remaining bits will be -+ // zeros. -+ if (lsb + mask_width > 64) mask_width = 64 - lsb; -+ -+ if (lsb == 0 && mask_width == 64) { -+ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(mleft.left().node())); -+ } else { -+ Emit(kLa64Dext, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), -+ g.TempImmediate(static_cast(mask_width))); -+ } -+ return; -+ } -+ // Other cases fall through to the normal And operation. -+ } -+ } -+ if (m.right().HasValue()) { -+ uint64_t mask = m.right().Value(); -+ uint32_t shift = base::bits::CountPopulation(~mask); -+ uint32_t msb = base::bits::CountLeadingZeros64(~mask); -+ if (shift != 0 && shift < 32 && msb + shift == 64) { -+ // Insert zeros for (x >> K) << K => x & ~(2^K - 1) expression reduction -+ // and remove constant loading of inverted mask. Dins cannot insert bits -+ // past word size, so shifts smaller than 32 are covered. -+ Emit(kLa64Dins, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0), g.TempImmediate(shift)); -+ return; -+ } -+ } -+ VisitBinop(this, node, kLa64And, true, kLa64And); -+} -+ -+void InstructionSelector::VisitWord32Or(Node* node) { -+ VisitBinop(this, node, kLa64Or32, true, kLa64Or32); -+} -+ -+void InstructionSelector::VisitWord64Or(Node* node) { -+ VisitBinop(this, node, kLa64Or, true, kLa64Or); -+} -+ -+void InstructionSelector::VisitWord32Xor(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32Or() && CanCover(node, m.left().node()) && -+ m.right().Is(-1)) { -+ Int32BinopMatcher mleft(m.left().node()); -+ if (!mleft.right().HasValue()) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Nor32, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(mleft.right().node())); -+ return; -+ } -+ } -+ if (m.right().Is(-1)) { -+ // Use Nor for bit negation and eliminate constant loading for xori. -+ La64OperandGenerator g(this); -+ Emit(kLa64Nor32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0)); -+ return; -+ } -+ VisitBinop(this, node, kLa64Xor32, true, kLa64Xor32); -+} -+ -+void InstructionSelector::VisitWord64Xor(Node* node) { -+ Int64BinopMatcher m(node); -+ if (m.left().IsWord64Or() && CanCover(node, m.left().node()) && -+ m.right().Is(-1)) { -+ Int64BinopMatcher mleft(m.left().node()); -+ if (!mleft.right().HasValue()) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Nor, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(mleft.right().node())); -+ return; -+ } -+ } -+ if (m.right().Is(-1)) { -+ // Use Nor for bit negation and eliminate constant loading for xori. -+ La64OperandGenerator g(this); -+ Emit(kLa64Nor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0)); -+ return; -+ } -+ VisitBinop(this, node, kLa64Xor, true, kLa64Xor); -+} -+ -+void InstructionSelector::VisitWord32Shl(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32And() && CanCover(node, m.left().node()) && -+ m.right().IsInRange(1, 31)) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher mleft(m.left().node()); -+ // Match Word32Shl(Word32And(x, mask), imm) to Shl where the mask is -+ // contiguous, and the shift immediate non-zero. -+ if (mleft.right().HasValue()) { -+ uint32_t mask = mleft.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { -+ uint32_t shift = m.right().Value(); -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); -+ DCHECK_NE(0u, shift); -+ if ((shift + mask_width) >= 32) { -+ // If the mask is contiguous and reaches or extends beyond the top -+ // bit, only the shift is needed. -+ Emit(kLa64Shl, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ } -+ } -+ VisitRRO(this, kLa64Shl, node); -+} -+ -+void InstructionSelector::VisitWord32Shr(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32And() && m.right().HasValue()) { -+ uint32_t lsb = m.right().Value() & 0x1F; -+ Int32BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue() && mleft.right().Value() != 0) { -+ // Select Ext for Shr(And(x, mask), imm) where the result of the mask is -+ // shifted into the least-significant bits. -+ uint32_t mask = (mleft.right().Value() >> lsb) << lsb; -+ unsigned mask_width = base::bits::CountPopulation(mask); -+ unsigned mask_msb = base::bits::CountLeadingZeros32(mask); -+ if ((mask_msb + mask_width + lsb) == 32) { -+ La64OperandGenerator g(this); -+ DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); -+ Emit(kLa64Ext, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), -+ g.TempImmediate(mask_width)); -+ return; -+ } -+ } -+ } -+ VisitRRO(this, kLa64Shr, node); -+} -+ -+void InstructionSelector::VisitWord32Sar(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32Shl() && CanCover(node, m.left().node())) { -+ Int32BinopMatcher mleft(m.left().node()); -+ if (m.right().HasValue() && mleft.right().HasValue()) { -+ La64OperandGenerator g(this); -+ uint32_t sar = m.right().Value(); -+ uint32_t shl = mleft.right().Value(); -+ if ((sar == shl) && (sar == 16)) { -+ Emit(kLa64Seh, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node())); -+ return; -+ } else if ((sar == shl) && (sar == 24)) { -+ Emit(kLa64Seb, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node())); -+ return; -+ } else if ((sar == shl) && (sar == 32)) { -+ Emit(kLa64Shl, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(0)); -+ return; -+ } -+ } -+ } -+ VisitRRO(this, kLa64Sar, node); -+} -+ -+void InstructionSelector::VisitWord64Shl(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && -+ m.right().IsInRange(32, 63) && CanCover(node, m.left().node())) { -+ // There's no need to sign/zero-extend to 64-bit if we shift out the upper -+ // 32 bits anyway. -+ Emit(kLa64Dshl, g.DefineSameAsFirst(node), -+ g.UseRegister(m.left().node()->InputAt(0)), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ if (m.left().IsWord64And() && CanCover(node, m.left().node()) && -+ m.right().IsInRange(1, 63)) { -+ // Match Word64Shl(Word64And(x, mask), imm) to Dshl where the mask is -+ // contiguous, and the shift immediate non-zero. -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue()) { -+ uint64_t mask = mleft.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { -+ uint64_t shift = m.right().Value(); -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); -+ DCHECK_NE(0u, shift); -+ -+ if ((shift + mask_width) >= 64) { -+ // If the mask is contiguous and reaches or extends beyond the top -+ // bit, only the shift is needed. -+ Emit(kLa64Dshl, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ } -+ } -+ VisitRRO(this, kLa64Dshl, node); -+} -+ -+void InstructionSelector::VisitWord64Shr(Node* node) { -+ Int64BinopMatcher m(node); -+ if (m.left().IsWord64And() && m.right().HasValue()) { -+ uint32_t lsb = m.right().Value() & 0x3F; -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue() && mleft.right().Value() != 0) { -+ // Select Dext for Shr(And(x, mask), imm) where the result of the mask is -+ // shifted into the least-significant bits. -+ uint64_t mask = (mleft.right().Value() >> lsb) << lsb; -+ unsigned mask_width = base::bits::CountPopulation(mask); -+ unsigned mask_msb = base::bits::CountLeadingZeros64(mask); -+ if ((mask_msb + mask_width + lsb) == 64) { -+ La64OperandGenerator g(this); -+ DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); -+ Emit(kLa64Dext, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), -+ g.TempImmediate(mask_width)); -+ return; -+ } -+ } -+ } -+ VisitRRO(this, kLa64Dshr, node); -+} -+ -+void InstructionSelector::VisitWord64Sar(Node* node) { -+ if (TryEmitExtendingLoad(this, node, node)) return; -+ VisitRRO(this, kLa64Dsar, node); -+} -+ -+void InstructionSelector::VisitWord32Rol(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64Rol(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord32Ror(Node* node) { -+ VisitRRO(this, kLa64Ror, node); -+} -+ -+void InstructionSelector::VisitWord32Clz(Node* node) { -+ VisitRR(this, kLa64Clz, node); -+} -+ -+void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64ReverseBytes(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64ByteSwap64, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord32ReverseBytes(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64ByteSwap32, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSimd128ReverseBytes(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitWord32Ctz(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Ctz, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Ctz(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Dctz, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord32Popcnt(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Popcnt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Popcnt(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Dpopcnt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Ror(Node* node) { -+ VisitRRO(this, kLa64Dror, node); -+} -+ -+void InstructionSelector::VisitWord64Clz(Node* node) { -+ VisitRR(this, kLa64Dclz, node); -+} -+ -+void InstructionSelector::VisitInt32Add(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ -+ // Select Lsa for (left + (left_of_right << imm)). -+ if (m.right().opcode() == IrOpcode::kWord32Shl && -+ CanCover(node, m.left().node()) && CanCover(node, m.right().node())) { -+ Int32BinopMatcher mright(m.right().node()); -+ if (mright.right().HasValue() && !m.left().HasValue()) { -+ int32_t shift_value = static_cast(mright.right().Value()); -+ if (shift_value > 0 && shift_value <= 31) { -+ Emit(kLa64Lsa, g.DefineAsRegister(node), -+ g.UseRegister(mright.left().node()), -+ g.UseRegister(m.left().node()), g.TempImmediate(shift_value)); -+ return; -+ } -+ } -+ } -+ -+ // Select Lsa for ((left_of_left << imm) + right). -+ if (m.left().opcode() == IrOpcode::kWord32Shl && -+ CanCover(node, m.right().node()) && CanCover(node, m.left().node())) { -+ Int32BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue() && !m.right().HasValue()) { -+ int32_t shift_value = static_cast(mleft.right().Value()); -+ if (shift_value > 0 && shift_value <= 31) { -+ Emit(kLa64Lsa, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(m.right().node()), g.TempImmediate(shift_value)); -+ return; -+ } -+ } -+ } -+ -+ VisitBinop(this, node, kLa64Add, true, kLa64Add); -+} -+ -+void InstructionSelector::VisitInt64Add(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ -+ // Select Dlsa for (left + (left_of_right << imm)). -+ if (m.right().opcode() == IrOpcode::kWord64Shl && -+ CanCover(node, m.left().node()) && CanCover(node, m.right().node())) { -+ Int64BinopMatcher mright(m.right().node()); -+ if (mright.right().HasValue() && !m.left().HasValue()) { -+ int32_t shift_value = static_cast(mright.right().Value()); -+ if (shift_value > 0 && shift_value <= 31) { -+ Emit(kLa64Dlsa, g.DefineAsRegister(node), -+ g.UseRegister(mright.left().node()), -+ g.UseRegister(m.left().node()), g.TempImmediate(shift_value)); -+ return; -+ } -+ } -+ } -+ -+ // Select Dlsa for ((left_of_left << imm) + right). -+ if (m.left().opcode() == IrOpcode::kWord64Shl && -+ CanCover(node, m.right().node()) && CanCover(node, m.left().node())) { -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue() && !m.right().HasValue()) { -+ int32_t shift_value = static_cast(mleft.right().Value()); -+ if (shift_value > 0 && shift_value <= 31) { -+ Emit(kLa64Dlsa, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(m.right().node()), g.TempImmediate(shift_value)); -+ return; -+ } -+ } -+ } -+ -+ VisitBinop(this, node, kLa64Dadd, true, kLa64Dadd); -+} -+ -+void InstructionSelector::VisitInt32Sub(Node* node) { -+ VisitBinop(this, node, kLa64Sub); -+} -+ -+void InstructionSelector::VisitInt64Sub(Node* node) { -+ VisitBinop(this, node, kLa64Dsub); -+} -+ -+void InstructionSelector::VisitInt32Mul(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ if (m.right().HasValue() && m.right().Value() > 0) { -+ uint32_t value = static_cast(m.right().Value()); -+ if (base::bits::IsPowerOfTwo(value)) { -+ Emit(kLa64Shl | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value - 1) && /*kArchVariant == kLa64r6 &&*/ -+ value - 1 > 0 && value - 1 <= 31) { -+ Emit(kLa64Lsa, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value - 1))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value + 1)) { -+ InstructionOperand temp = g.TempRegister(); -+ Emit(kLa64Shl | AddressingModeField::encode(kMode_None), temp, -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); -+ Emit(kLa64Sub | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); -+ return; -+ } -+ } -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher leftInput(left), rightInput(right); -+ if (leftInput.right().Is(32) && rightInput.right().Is(32)) { -+ // Combine untagging shifts with Dmul high. -+ Emit(kLa64DMulHigh, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ VisitRRR(this, kLa64Mul, node); -+} -+ -+void InstructionSelector::VisitInt32MulHigh(Node* node) { -+ VisitRRR(this, kLa64MulHigh, node); -+} -+ -+void InstructionSelector::VisitUint32MulHigh(Node* node) { -+ VisitRRR(this, kLa64MulHighU, node); -+} -+ -+void InstructionSelector::VisitInt64Mul(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ // TODO(dusmil): Add optimization for shifts larger than 32. -+ if (m.right().HasValue() && m.right().Value() > 0) { -+ uint32_t value = static_cast(m.right().Value()); -+ if (base::bits::IsPowerOfTwo(value)) { -+ Emit(kLa64Dshl | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value - 1) && /*kArchVariant == kLa64r6 &&*/ -+ value - 1 > 0 && value - 1 <= 31) { -+ // Dlsa macro will handle the shifting value out of bound cases. -+ Emit(kLa64Dlsa, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value - 1))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value + 1)) { -+ InstructionOperand temp = g.TempRegister(); -+ Emit(kLa64Dshl | AddressingModeField::encode(kMode_None), temp, -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); -+ Emit(kLa64Dsub | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); -+ return; -+ } -+ } -+ Emit(kLa64Dmul, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt32Div(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher rightInput(right), leftInput(left); -+ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { -+ // Combine both shifted operands with Ddiv. -+ Emit(kLa64Ddiv, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ Emit(kLa64Div, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint32Div(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Emit(kLa64DivU, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt32Mod(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher rightInput(right), leftInput(left); -+ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { -+ // Combine both shifted operands with Dmod. -+ Emit(kLa64Dmod, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ Emit(kLa64Mod, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint32Mod(Node* node) { -+ La64OperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Emit(kLa64ModU, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt64Div(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kLa64Ddiv, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint64Div(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kLa64DdivU, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt64Mod(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kLa64Dmod, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint64Mod(Node* node) { -+ La64OperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kLa64DmodU, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDS, node); -+} -+ -+void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) { -+ VisitRR(this, kLa64CvtSW, node); -+} -+ -+void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) { -+ VisitRR(this, kLa64CvtSUw, node); -+} -+ -+void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDW, node); -+} -+ -+void InstructionSelector::VisitChangeInt64ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDL, node); -+} -+ -+void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDUw, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat32ToInt32(Node* node) { -+ VisitRR(this, kLa64TruncWS, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat32ToUint32(Node* node) { -+ VisitRR(this, kLa64TruncUwS, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { -+ La64OperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ // Match ChangeFloat64ToInt32(Float64Round##OP) to corresponding instruction -+ // which does rounding and conversion to integer format. -+ if (CanCover(node, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kFloat64RoundDown: -+ Emit(kLa64FloorWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundUp: -+ Emit(kLa64CeilWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundTiesEven: -+ Emit(kLa64RoundWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundTruncate: -+ Emit(kLa64TruncWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ default: -+ break; -+ } -+ if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) { -+ Node* next = value->InputAt(0); -+ if (CanCover(value, next)) { -+ // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP)) -+ switch (next->opcode()) { -+ case IrOpcode::kFloat32RoundDown: -+ Emit(kLa64FloorWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundUp: -+ Emit(kLa64CeilWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundTiesEven: -+ Emit(kLa64RoundWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundTruncate: -+ Emit(kLa64TruncWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ default: -+ Emit(kLa64TruncWS, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ } else { -+ // Match float32 -> float64 -> int32 representation change path. -+ Emit(kLa64TruncWS, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ } -+ } -+ VisitRR(this, kLa64TruncWD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) { -+ VisitRR(this, kLa64TruncLD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { -+ VisitRR(this, kLa64TruncUwD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) { -+ VisitRR(this, kLa64TruncUlD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToUint32(Node* node) { -+ VisitRR(this, kLa64TruncUwD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToInt64(Node* node) { -+ VisitRR(this, kLa64TruncLD, node); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) { -+ La64OperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ this->Emit(kLa64TruncLS, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat64ToInt64(Node* node) { -+ La64OperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kLa64TruncLD, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat32ToUint64(Node* node) { -+ La64OperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kLa64TruncUlS, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) { -+ La64OperandGenerator g(this); -+ -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kLa64TruncUlD, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitBitcastWord32ToWord64(Node* node) { -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitChangeInt32ToInt64(Node* node) { -+ Node* value = node->InputAt(0); -+ if (value->opcode() == IrOpcode::kLoad && CanCover(node, value)) { -+ // Generate sign-extending load. -+ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); -+ InstructionCode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kLa64Lhu : kLa64Lh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kLa64Lw; -+ break; -+ default: -+ UNREACHABLE(); -+ return; -+ } -+ EmitLoad(this, value, opcode, node); -+ } else { -+ La64OperandGenerator g(this); -+ Emit(kLa64Shl, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0)); -+ } -+} -+ -+bool InstructionSelector::ZeroExtendsWord32ToWord64NoPhis(Node* node) { -+ DCHECK_NE(node->opcode(), IrOpcode::kPhi); -+ switch (node->opcode()) { -+ // 32-bit operations will write their result in a 64 bit register, -+ // clearing the top 32 bits of the destination register. -+ case IrOpcode::kUint32Div: -+ case IrOpcode::kUint32Mod: -+ case IrOpcode::kUint32MulHigh: -+ return true; -+ case IrOpcode::kLoad: { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ if (load_rep.IsUnsigned()) { -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ case MachineRepresentation::kWord16: -+ case MachineRepresentation::kWord32: -+ return true; -+ default: -+ return false; -+ } -+ } -+ return false; -+ } -+ default: -+ return false; -+ } -+} -+ -+void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { -+ La64OperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ if (ZeroExtendsWord32ToWord64(value)) { -+ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); -+ return; -+ } -+ Emit(kLa64Dext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0), g.TempImmediate(32)); -+} -+ -+void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) { -+ La64OperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ if (CanCover(node, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kWord64Sar: { -+ if (TryEmitExtendingLoad(this, value, node)) { -+ return; -+ } else { -+ Int64BinopMatcher m(value); -+ if (m.right().IsInRange(32, 63)) { -+ // After smi untagging no need for truncate. Combine sequence. -+ Emit(kLa64Dsar, g.DefineSameAsFirst(node), -+ g.UseRegister(m.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ break; -+ } -+ default: -+ break; -+ } -+ } -+ Emit(kLa64Ext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0), g.TempImmediate(32)); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { -+ La64OperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding -+ // instruction. -+ if (CanCover(node, value) && -+ value->opcode() == IrOpcode::kChangeInt32ToFloat64) { -+ Emit(kLa64CvtSW, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ VisitRR(this, kLa64CvtSD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToWord32(Node* node) { -+ VisitRR(this, kArchTruncateDoubleToI, node); -+} -+ -+void InstructionSelector::VisitRoundFloat64ToInt32(Node* node) { -+ VisitRR(this, kLa64TruncWD, node); -+} -+ -+void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) { -+ VisitRR(this, kLa64CvtSL, node); -+} -+ -+void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDL, node); -+} -+ -+void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { -+ VisitRR(this, kLa64CvtSUl, node); -+} -+ -+void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { -+ VisitRR(this, kLa64CvtDUl, node); -+} -+ -+void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) { -+ VisitRR(this, kLa64Float64ExtractLowWord32, node); -+} -+ -+void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { -+ VisitRR(this, kLa64BitcastDL, node); -+} -+ -+void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Float64InsertLowWord32, g.DefineAsRegister(node), -+ ImmediateOperand(ImmediateOperand::INLINE, 0), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { -+ VisitRR(this, kLa64BitcastLD, node); -+} -+ -+void InstructionSelector::VisitFloat32Add(Node* node) { -+ // Optimization with Madd.S(z, x, y) is intentionally removed. -+ // See explanation for madd_s in assembler-la64.cc. -+ VisitRRR(this, kLa64AddS, node); -+} -+ -+void InstructionSelector::VisitFloat64Add(Node* node) { -+ // Optimization with Madd.D(z, x, y) is intentionally removed. -+ // See explanation for madd_d in assembler-la64.cc. -+ VisitRRR(this, kLa64AddD, node); -+} -+ -+void InstructionSelector::VisitFloat32Sub(Node* node) { -+ // Optimization with Msub.S(z, x, y) is intentionally removed. -+ // See explanation for madd_s in assembler-la64.cc. -+ VisitRRR(this, kLa64SubS, node); -+} -+ -+void InstructionSelector::VisitFloat64Sub(Node* node) { -+ // Optimization with Msub.D(z, x, y) is intentionally removed. -+ // See explanation for madd_d in assembler-la64.cc. -+ VisitRRR(this, kLa64SubD, node); -+} -+ -+void InstructionSelector::VisitFloat32Mul(Node* node) { -+ VisitRRR(this, kLa64MulS, node); -+} -+ -+void InstructionSelector::VisitFloat64Mul(Node* node) { -+ VisitRRR(this, kLa64MulD, node); -+} -+ -+void InstructionSelector::VisitFloat32Div(Node* node) { -+ VisitRRR(this, kLa64DivS, node); -+} -+ -+void InstructionSelector::VisitFloat64Div(Node* node) { -+ VisitRRR(this, kLa64DivD, node); -+} -+ -+void InstructionSelector::VisitFloat64Mod(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64ModD, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f0), -+ g.UseFixed(node->InputAt(1), f1)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::VisitFloat32Max(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Float32Max, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat64Max(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Float64Max, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat32Min(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Float32Min, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat64Min(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Float64Min, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat32Abs(Node* node) { -+ VisitRR(this, kLa64AbsS, node); -+} -+ -+void InstructionSelector::VisitFloat64Abs(Node* node) { -+ VisitRR(this, kLa64AbsD, node); -+} -+ -+void InstructionSelector::VisitFloat32Sqrt(Node* node) { -+ VisitRR(this, kLa64SqrtS, node); -+} -+ -+void InstructionSelector::VisitFloat64Sqrt(Node* node) { -+ VisitRR(this, kLa64SqrtD, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundDown(Node* node) { -+ VisitRR(this, kLa64Float32RoundDown, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundDown(Node* node) { -+ VisitRR(this, kLa64Float64RoundDown, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundUp(Node* node) { -+ VisitRR(this, kLa64Float32RoundUp, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundUp(Node* node) { -+ VisitRR(this, kLa64Float64RoundUp, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { -+ VisitRR(this, kLa64Float32RoundTruncate, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { -+ VisitRR(this, kLa64Float64RoundTruncate, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { -+ VisitRR(this, kLa64Float32RoundTiesEven, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { -+ VisitRR(this, kLa64Float64RoundTiesEven, node); -+} -+ -+void InstructionSelector::VisitFloat32Neg(Node* node) { -+ VisitRR(this, kLa64NegS, node); -+} -+ -+void InstructionSelector::VisitFloat64Neg(Node* node) { -+ VisitRR(this, kLa64NegD, node); -+} -+ -+void InstructionSelector::VisitFloat64Ieee754Binop(Node* node, -+ InstructionCode opcode) { -+ La64OperandGenerator g(this); -+ Emit(opcode, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f2), -+ g.UseFixed(node->InputAt(1), f4)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::VisitFloat64Ieee754Unop(Node* node, -+ InstructionCode opcode) { -+ La64OperandGenerator g(this); -+ Emit(opcode, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f0)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::EmitPrepareArguments( -+ ZoneVector* arguments, const CallDescriptor* call_descriptor, -+ Node* node) { -+ La64OperandGenerator g(this); -+ -+ // Prepare for C function call. -+ if (call_descriptor->IsCFunctionCall()) { -+ Emit(kArchPrepareCallCFunction | MiscField::encode(static_cast( -+ call_descriptor->ParameterCount())), -+ 0, nullptr, 0, nullptr); -+ -+ // Poke any stack arguments. -+ int slot = kCArgSlotCount; -+ for (PushParameter input : (*arguments)) { -+ Emit(kLa64StoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), -+ g.TempImmediate(slot << kSystemPointerSizeLog2)); -+ ++slot; -+ } -+ } else { -+ int push_count = static_cast(call_descriptor->StackParameterCount()); -+ if (push_count > 0) { -+ // Calculate needed space -+ int stack_size = 0; -+ for (PushParameter input : (*arguments)) { -+ if (input.node) { -+ stack_size += input.location.GetSizeInPointers(); -+ } -+ } -+ Emit(kLa64StackClaim, g.NoOutput(), -+ g.TempImmediate(stack_size << kSystemPointerSizeLog2)); -+ } -+ for (size_t n = 0; n < arguments->size(); ++n) { -+ PushParameter input = (*arguments)[n]; -+ if (input.node) { -+ Emit(kLa64StoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), -+ g.TempImmediate(static_cast(n << kSystemPointerSizeLog2))); -+ } -+ } -+ } -+} -+ -+void InstructionSelector::EmitPrepareResults( -+ ZoneVector* results, const CallDescriptor* call_descriptor, -+ Node* node) { -+ La64OperandGenerator g(this); -+ -+ int reverse_slot = 1; -+ for (PushParameter output : *results) { -+ if (!output.location.IsCallerFrameSlot()) continue; -+ // Skip any alignment holes in nodes. -+ if (output.node != nullptr) { -+ DCHECK(!call_descriptor->IsCFunctionCall()); -+ if (output.location.GetType() == MachineType::Float32()) { -+ MarkAsFloat32(output.node); -+ } else if (output.location.GetType() == MachineType::Float64()) { -+ MarkAsFloat64(output.node); -+ } else if (output.location.GetType() == MachineType::Simd128()) { -+ abort(); -+ } -+ Emit(kLa64Peek, g.DefineAsRegister(output.node), -+ g.UseImmediate(reverse_slot)); -+ } -+ reverse_slot += output.location.GetSizeInPointers(); -+ } -+} -+ -+bool InstructionSelector::IsTailCallAddressImmediate() { return false; } -+ -+int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } -+ -+void InstructionSelector::VisitUnalignedLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ La64OperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kFloat32: -+ opcode = kLa64Ulwc1; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kLa64Uldc1; -+ break; -+ case MachineRepresentation::kWord8: -+ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kLa64Ulhu : kLa64Ulh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = load_rep.IsUnsigned() ? kLa64Ulwu : kLa64Ulw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Uld; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ case MachineRepresentation::kSimd128: -+ UNREACHABLE(); -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), addr_reg, -+ g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired load opcode, using temp addr_reg. -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); -+ } -+} -+ -+void InstructionSelector::VisitUnalignedStore(Node* node) { -+ La64OperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kFloat32: -+ opcode = kLa64Uswc1; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kLa64Usdc1; -+ break; -+ case MachineRepresentation::kWord8: -+ opcode = kLa64Sb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kLa64Ush; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kLa64Usw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Usd; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ case MachineRepresentation::kSimd128: -+ UNREACHABLE(); -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), addr_reg, -+ g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired store opcode, using temp addr_reg. -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); -+ } -+} -+ -+namespace { -+ -+// Shared routine for multiple compare operations. -+static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, -+ InstructionOperand left, InstructionOperand right, -+ FlagsContinuation* cont) { -+ selector->EmitWithContinuation(opcode, left, right, cont); -+} -+ -+// Shared routine for multiple float32 compare operations. -+void VisitFloat32Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ La64OperandGenerator g(selector); -+ Float32BinopMatcher m(node); -+ InstructionOperand lhs, rhs; -+ -+ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) -+ : g.UseRegister(m.left().node()); -+ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) -+ : g.UseRegister(m.right().node()); -+ VisitCompare(selector, kLa64CmpS, lhs, rhs, cont); -+} -+ -+// Shared routine for multiple float64 compare operations. -+void VisitFloat64Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ La64OperandGenerator g(selector); -+ Float64BinopMatcher m(node); -+ InstructionOperand lhs, rhs; -+ -+ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) -+ : g.UseRegister(m.left().node()); -+ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) -+ : g.UseRegister(m.right().node()); -+ VisitCompare(selector, kLa64CmpD, lhs, rhs, cont); -+} -+ -+// Shared routine for multiple word compare operations. -+void VisitWordCompare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont, -+ bool commutative) { -+ La64OperandGenerator g(selector); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ -+ // Match immediates on left or right side of comparison. -+ if (g.CanBeImmediate(right, opcode)) { -+ if (opcode == kLa64Tst) { -+ VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), -+ cont); -+ } else { -+ switch (cont->condition()) { -+ case kEqual: -+ case kNotEqual: -+ if (cont->IsSet()) { -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseImmediate(right), cont); -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseRegister(right), cont); -+ } -+ break; -+ case kSignedLessThan: -+ case kSignedGreaterThanOrEqual: -+ case kUnsignedLessThan: -+ case kUnsignedGreaterThanOrEqual: -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseImmediate(right), cont); -+ break; -+ default: -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseRegister(right), cont); -+ } -+ } -+ } else if (g.CanBeImmediate(left, opcode)) { -+ if (!commutative) cont->Commute(); -+ if (opcode == kLa64Tst) { -+ VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), -+ cont); -+ } else { -+ switch (cont->condition()) { -+ case kEqual: -+ case kNotEqual: -+ if (cont->IsSet()) { -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseImmediate(left), cont); -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseRegister(left), cont); -+ } -+ break; -+ case kSignedLessThan: -+ case kSignedGreaterThanOrEqual: -+ case kUnsignedLessThan: -+ case kUnsignedGreaterThanOrEqual: -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseImmediate(left), cont); -+ break; -+ default: -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseRegister(left), cont); -+ } -+ } -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), -+ cont); -+ } -+} -+ -+bool IsNodeUnsigned(Node* n) { -+ NodeMatcher m(n); -+ -+ if (m.IsLoad() || m.IsUnalignedLoad() || m.IsPoisonedLoad() || -+ m.IsProtectedLoad() || m.IsWord32AtomicLoad() || m.IsWord64AtomicLoad()) { -+ LoadRepresentation load_rep = LoadRepresentationOf(n->op()); -+ return load_rep.IsUnsigned(); -+ } else { -+ return m.IsUint32Div() || m.IsUint32LessThan() || -+ m.IsUint32LessThanOrEqual() || m.IsUint32Mod() || -+ m.IsUint32MulHigh() || m.IsChangeFloat64ToUint32() || -+ m.IsTruncateFloat64ToUint32() || m.IsTruncateFloat32ToUint32(); -+ } -+} -+ -+// Shared routine for multiple word compare operations. -+void VisitFullWord32Compare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont) { -+ La64OperandGenerator g(selector); -+ InstructionOperand leftOp = g.TempRegister(); -+ InstructionOperand rightOp = g.TempRegister(); -+ -+ selector->Emit(kLa64Dshl, leftOp, g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(32)); -+ selector->Emit(kLa64Dshl, rightOp, g.UseRegister(node->InputAt(1)), -+ g.TempImmediate(32)); -+ -+ VisitCompare(selector, opcode, leftOp, rightOp, cont); -+} -+ -+void VisitOptimizedWord32Compare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, -+ FlagsContinuation* cont) { -+ if (FLAG_debug_code) { -+ La64OperandGenerator g(selector); -+ InstructionOperand leftOp = g.TempRegister(); -+ InstructionOperand rightOp = g.TempRegister(); -+ InstructionOperand optimizedResult = g.TempRegister(); -+ InstructionOperand fullResult = g.TempRegister(); -+ FlagsCondition condition = cont->condition(); -+ InstructionCode testOpcode = opcode | -+ FlagsConditionField::encode(condition) | -+ FlagsModeField::encode(kFlags_set); -+ -+ selector->Emit(testOpcode, optimizedResult, g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+ -+ selector->Emit(kLa64Dshl, leftOp, g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(32)); -+ selector->Emit(kLa64Dshl, rightOp, g.UseRegister(node->InputAt(1)), -+ g.TempImmediate(32)); -+ selector->Emit(testOpcode, fullResult, leftOp, rightOp); -+ -+ selector->Emit(kLa64AssertEqual, g.NoOutput(), optimizedResult, fullResult, -+ g.TempImmediate(static_cast( -+ AbortReason::kUnsupportedNonPrimitiveCompare))); -+ } -+ -+ VisitWordCompare(selector, node, opcode, cont, false); -+} -+ -+void VisitWord32Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ // LA64 doesn't support Word32 compare instructions. Instead it relies -+ // that the values in registers are correctly sign-extended and uses -+ // Word64 comparison instead. This behavior is correct in most cases, -+ // but doesn't work when comparing signed with unsigned operands. -+ // We could simulate full Word32 compare in all cases but this would -+ // create an unnecessary overhead since unsigned integers are rarely -+ // used in JavaScript. -+ // The solution proposed here tries to match a comparison of signed -+ // with unsigned operand, and perform full Word32Compare only -+ // in those cases. Unfortunately, the solution is not complete because -+ // it might skip cases where Word32 full compare is needed, so -+ // basically it is a hack. -+ // When call to a host function in simulator, if the function return a -+ // int32 value, the simulator do not sign-extended to int64 because in -+ // simulator we do not know the function whether return a int32 or int64. -+ // so we need do a full word32 compare in this case. -+#ifndef USE_SIMULATOR -+ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1))) { -+#else -+ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1)) || -+ node->InputAt(0)->opcode() == IrOpcode::kCall || -+ node->InputAt(1)->opcode() == IrOpcode::kCall) { -+#endif -+ VisitFullWord32Compare(selector, node, kLa64Cmp, cont); -+ } else { -+ VisitOptimizedWord32Compare(selector, node, kLa64Cmp, cont); -+ } -+} -+ -+void VisitWord64Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ VisitWordCompare(selector, node, kLa64Cmp, cont, false); -+} -+ -+void EmitWordCompareZero(InstructionSelector* selector, Node* value, -+ FlagsContinuation* cont) { -+ La64OperandGenerator g(selector); -+ selector->EmitWithContinuation(kLa64Cmp, g.UseRegister(value), -+ g.TempImmediate(0), cont); -+} -+ -+void VisitAtomicLoad(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), g.UseRegister(base), -+ g.UseImmediate(index)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ selector->Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), -+ addr_reg, g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired load opcode, using temp addr_reg. -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); -+ } -+} -+ -+void VisitAtomicStore(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.NoOutput(), g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ selector->Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), -+ addr_reg, g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired store opcode, using temp addr_reg. -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.NoOutput(), addr_reg, g.TempImmediate(0), -+ g.UseRegisterOrImmediateZero(value)); -+ } -+} -+ -+void VisitAtomicExchange(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temp[3]; -+ temp[0] = g.TempRegister(); -+ temp[1] = g.TempRegister(); -+ temp[2] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); -+} -+ -+void VisitAtomicCompareExchange(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* old_value = node->InputAt(2); -+ Node* new_value = node->InputAt(3); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[4]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(old_value); -+ inputs[input_count++] = g.UseUniqueRegister(new_value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temp[3]; -+ temp[0] = g.TempRegister(); -+ temp[1] = g.TempRegister(); -+ temp[2] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); -+} -+ -+void VisitAtomicBinop(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ La64OperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temps[4]; -+ temps[0] = g.TempRegister(); -+ temps[1] = g.TempRegister(); -+ temps[2] = g.TempRegister(); -+ temps[3] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 4, temps); -+} -+ -+} // namespace -+ -+void InstructionSelector::VisitStackPointerGreaterThan( -+ Node* node, FlagsContinuation* cont) { -+ StackCheckKind kind = StackCheckKindOf(node->op()); -+ InstructionCode opcode = -+ kArchStackPointerGreaterThan | MiscField::encode(static_cast(kind)); -+ -+ La64OperandGenerator g(this); -+ -+ // No outputs. -+ InstructionOperand* const outputs = nullptr; -+ const int output_count = 0; -+ -+ // Applying an offset to this stack check requires a temp register. Offsets -+ // are only applied to the first stack check. If applying an offset, we must -+ // ensure the input and temp registers do not alias, thus kUniqueRegister. -+ InstructionOperand temps[] = {g.TempRegister()}; -+ const int temp_count = (kind == StackCheckKind::kJSFunctionEntry ? 1 : 0); -+ const auto register_mode = (kind == StackCheckKind::kJSFunctionEntry) -+ ? OperandGenerator::kUniqueRegister -+ : OperandGenerator::kRegister; -+ -+ Node* const value = node->InputAt(0); -+ InstructionOperand inputs[] = {g.UseRegisterWithMode(value, register_mode)}; -+ static constexpr int input_count = arraysize(inputs); -+ -+ EmitWithContinuation(opcode, output_count, outputs, input_count, inputs, -+ temp_count, temps, cont); -+} -+ -+// Shared routine for word comparisons against zero. -+void InstructionSelector::VisitWordCompareZero(Node* user, Node* value, -+ FlagsContinuation* cont) { -+ // Try to combine with comparisons against 0 by simply inverting the branch. -+ while (CanCover(user, value)) { -+ if (value->opcode() == IrOpcode::kWord32Equal) { -+ Int32BinopMatcher m(value); -+ if (!m.right().Is(0)) break; -+ user = value; -+ value = m.left().node(); -+ } else if (value->opcode() == IrOpcode::kWord64Equal) { -+ Int64BinopMatcher m(value); -+ if (!m.right().Is(0)) break; -+ user = value; -+ value = m.left().node(); -+ } else { -+ break; -+ } -+ -+ cont->Negate(); -+ } -+ -+ if (CanCover(user, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kWord32Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kInt32LessThan: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThan); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kInt32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kUint32LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kUint32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kWord64Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kInt64LessThan: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThan); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kInt64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kUint64LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kUint64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kFloat32Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat32LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat64Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kFloat64LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kFloat64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kProjection: -+ // Check if this is the overflow output projection of an -+ // WithOverflow node. -+ if (ProjectionIndexOf(value->op()) == 1u) { -+ // We cannot combine the WithOverflow with this branch -+ // unless the 0th projection (the use of the actual value of the -+ // is either nullptr, which means there's no use of the -+ // actual value, or was already defined, which means it is scheduled -+ // *AFTER* this branch). -+ Node* const node = value->InputAt(0); -+ Node* const result = NodeProperties::FindProjection(node, 0); -+ if (result == nullptr || IsDefined(result)) { -+ switch (node->opcode()) { -+ case IrOpcode::kInt32AddWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kLa64Dadd, cont); -+ case IrOpcode::kInt32SubWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kLa64Dsub, cont); -+ case IrOpcode::kInt32MulWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kLa64MulOvf, cont); -+ case IrOpcode::kInt64AddWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kLa64DaddOvf, cont); -+ case IrOpcode::kInt64SubWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kLa64DsubOvf, cont); -+ default: -+ break; -+ } -+ } -+ } -+ break; -+ case IrOpcode::kWord32And: -+ case IrOpcode::kWord64And: -+ return VisitWordCompare(this, value, kLa64Tst, cont, true); -+ case IrOpcode::kStackPointerGreaterThan: -+ cont->OverwriteAndNegateIfEqual(kStackPointerGreaterThanCondition); -+ return VisitStackPointerGreaterThan(value, cont); -+ default: -+ break; -+ } -+ } -+ -+ // Continuation could not be combined with a compare, emit compare against 0. -+ EmitWordCompareZero(this, value, cont); -+} -+ -+void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { -+ La64OperandGenerator g(this); -+ InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); -+ -+ // Emit either ArchTableSwitch or ArchBinarySearchSwitch. -+ if (enable_switch_jump_table_ == kEnableSwitchJumpTable) { -+ static const size_t kMaxTableSwitchValueRange = 2 << 16; -+ size_t table_space_cost = 10 + 2 * sw.value_range(); -+ size_t table_time_cost = 3; -+ size_t lookup_space_cost = 2 + 2 * sw.case_count(); -+ size_t lookup_time_cost = sw.case_count(); -+ if (sw.case_count() > 0 && -+ table_space_cost + 3 * table_time_cost <= -+ lookup_space_cost + 3 * lookup_time_cost && -+ sw.min_value() > std::numeric_limits::min() && -+ sw.value_range() <= kMaxTableSwitchValueRange) { -+ InstructionOperand index_operand = value_operand; -+ if (sw.min_value()) { -+ index_operand = g.TempRegister(); -+ Emit(kLa64Sub, index_operand, value_operand, -+ g.TempImmediate(sw.min_value())); -+ } -+ // Generate a table lookup. -+ return EmitTableSwitch(sw, index_operand); -+ } -+ } -+ -+ // Generate a tree of conditional jumps. -+ return EmitBinarySearchSwitch(sw, value_operand); -+} -+ -+void InstructionSelector::VisitWord32Equal(Node* const node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ Int32BinopMatcher m(node); -+ if (m.right().Is(0)) { -+ return VisitWordCompareZero(m.node(), m.left().node(), &cont); -+ } -+ -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kLa64Dadd, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kLa64Dadd, &cont); -+} -+ -+void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kLa64Dsub, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kLa64Dsub, &cont); -+} -+ -+void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kLa64MulOvf, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kLa64MulOvf, &cont); -+} -+ -+void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kLa64DaddOvf, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kLa64DaddOvf, &cont); -+} -+ -+void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kLa64DsubOvf, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kLa64DsubOvf, &cont); -+} -+ -+void InstructionSelector::VisitWord64Equal(Node* const node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ Int64BinopMatcher m(node); -+ if (m.right().Is(0)) { -+ return VisitWordCompareZero(m.node(), m.left().node(), &cont); -+ } -+ -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32Equal(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64Equal(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { -+ VisitRR(this, kLa64Float64ExtractLowWord32, node); -+} -+ -+void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { -+ VisitRR(this, kLa64Float64ExtractHighWord32, node); -+} -+ -+void InstructionSelector::VisitFloat64SilenceNaN(Node* node) { -+ VisitRR(this, kLa64Float64SilenceNaN, node); -+} -+ -+void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) { -+ La64OperandGenerator g(this); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ Emit(kLa64Float64InsertLowWord32, g.DefineSameAsFirst(node), -+ g.UseRegister(left), g.UseRegister(right)); -+} -+ -+void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { -+ La64OperandGenerator g(this); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ Emit(kLa64Float64InsertHighWord32, g.DefineSameAsFirst(node), -+ g.UseRegister(left), g.UseRegister(right)); -+} -+ -+void InstructionSelector::VisitMemoryBarrier(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Sync, g.NoOutput()); -+} -+ -+void InstructionSelector::VisitWord32AtomicLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ opcode = -+ load_rep.IsSigned() ? kWord32AtomicLoadInt8 : kWord32AtomicLoadUint8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsSigned() ? kWord32AtomicLoadInt16 -+ : kWord32AtomicLoadUint16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kWord32AtomicLoadWord32; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ VisitAtomicLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicStore(Node* node) { -+ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kWord8: -+ opcode = kWord32AtomicStoreWord8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kWord32AtomicStoreWord16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kWord32AtomicStoreWord32; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ VisitAtomicStore(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ opcode = kLa64Word64AtomicLoadUint8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kLa64Word64AtomicLoadUint16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kLa64Word64AtomicLoadUint32; -+ break; -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Word64AtomicLoadUint64; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ VisitAtomicLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicStore(Node* node) { -+ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kWord8: -+ opcode = kLa64Word64AtomicStoreWord8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kLa64Word64AtomicStoreWord16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kLa64Word64AtomicStoreWord32; -+ break; -+ case MachineRepresentation::kWord64: -+ opcode = kLa64Word64AtomicStoreWord64; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ VisitAtomicStore(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = kWord32AtomicExchangeInt8; -+ } else if (type == MachineType::Uint8()) { -+ opcode = kWord32AtomicExchangeUint8; -+ } else if (type == MachineType::Int16()) { -+ opcode = kWord32AtomicExchangeInt16; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kWord32AtomicExchangeUint16; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = kWord32AtomicExchangeWord32; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = kLa64Word64AtomicExchangeUint8; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kLa64Word64AtomicExchangeUint16; -+ } else if (type == MachineType::Uint32()) { -+ opcode = kLa64Word64AtomicExchangeUint32; -+ } else if (type == MachineType::Uint64()) { -+ opcode = kLa64Word64AtomicExchangeUint64; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicCompareExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = kWord32AtomicCompareExchangeInt8; -+ } else if (type == MachineType::Uint8()) { -+ opcode = kWord32AtomicCompareExchangeUint8; -+ } else if (type == MachineType::Int16()) { -+ opcode = kWord32AtomicCompareExchangeInt16; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kWord32AtomicCompareExchangeUint16; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = kWord32AtomicCompareExchangeWord32; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicCompareExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = kLa64Word64AtomicCompareExchangeUint8; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kLa64Word64AtomicCompareExchangeUint16; -+ } else if (type == MachineType::Uint32()) { -+ opcode = kLa64Word64AtomicCompareExchangeUint32; -+ } else if (type == MachineType::Uint64()) { -+ opcode = kLa64Word64AtomicCompareExchangeUint64; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicCompareExchange(this, node, opcode); -+} -+void InstructionSelector::VisitWord32AtomicBinaryOperation( -+ Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op, -+ ArchOpcode uint16_op, ArchOpcode word32_op) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = int8_op; -+ } else if (type == MachineType::Uint8()) { -+ opcode = uint8_op; -+ } else if (type == MachineType::Int16()) { -+ opcode = int16_op; -+ } else if (type == MachineType::Uint16()) { -+ opcode = uint16_op; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = word32_op; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicBinop(this, node, opcode); -+} -+ -+#define VISIT_ATOMIC_BINOP(op) \ -+ void InstructionSelector::VisitWord32Atomic##op(Node* node) { \ -+ VisitWord32AtomicBinaryOperation( \ -+ node, kWord32Atomic##op##Int8, kWord32Atomic##op##Uint8, \ -+ kWord32Atomic##op##Int16, kWord32Atomic##op##Uint16, \ -+ kWord32Atomic##op##Word32); \ -+ } -+VISIT_ATOMIC_BINOP(Add) -+VISIT_ATOMIC_BINOP(Sub) -+VISIT_ATOMIC_BINOP(And) -+VISIT_ATOMIC_BINOP(Or) -+VISIT_ATOMIC_BINOP(Xor) -+#undef VISIT_ATOMIC_BINOP -+ -+void InstructionSelector::VisitWord64AtomicBinaryOperation( -+ Node* node, ArchOpcode uint8_op, ArchOpcode uint16_op, ArchOpcode uint32_op, -+ ArchOpcode uint64_op) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = uint8_op; -+ } else if (type == MachineType::Uint16()) { -+ opcode = uint16_op; -+ } else if (type == MachineType::Uint32()) { -+ opcode = uint32_op; -+ } else if (type == MachineType::Uint64()) { -+ opcode = uint64_op; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicBinop(this, node, opcode); -+} -+ -+#define VISIT_ATOMIC_BINOP(op) \ -+ void InstructionSelector::VisitWord64Atomic##op(Node* node) { \ -+ VisitWord64AtomicBinaryOperation( \ -+ node, kLa64Word64Atomic##op##Uint8, kLa64Word64Atomic##op##Uint16, \ -+ kLa64Word64Atomic##op##Uint32, kLa64Word64Atomic##op##Uint64); \ -+ } -+VISIT_ATOMIC_BINOP(Add) -+VISIT_ATOMIC_BINOP(Sub) -+VISIT_ATOMIC_BINOP(And) -+VISIT_ATOMIC_BINOP(Or) -+VISIT_ATOMIC_BINOP(Xor) -+#undef VISIT_ATOMIC_BINOP -+ -+void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { -+ UNREACHABLE(); -+} -+ -+#define SIMD_TYPE_LIST(V) \ -+ V(F64x2) \ -+ V(F32x4) \ -+ V(I64x2) \ -+ V(I32x4) \ -+ V(I16x8) \ -+ V(I8x16) -+ -+#define SIMD_UNOP_LIST(V) \ -+ V(F64x2Abs, kLa64F64x2Abs) \ -+ V(F64x2Neg, kLa64F64x2Neg) \ -+ V(F64x2Sqrt, kLa64F64x2Sqrt) \ -+ V(F64x2Ceil, kLa64F64x2Ceil) \ -+ V(F64x2Floor, kLa64F64x2Floor) \ -+ V(F64x2Trunc, kLa64F64x2Trunc) \ -+ V(F64x2NearestInt, kLa64F64x2NearestInt) \ -+ V(I64x2Neg, kLa64I64x2Neg) \ -+ V(F32x4SConvertI32x4, kLa64F32x4SConvertI32x4) \ -+ V(F32x4UConvertI32x4, kLa64F32x4UConvertI32x4) \ -+ V(F32x4Abs, kLa64F32x4Abs) \ -+ V(F32x4Neg, kLa64F32x4Neg) \ -+ V(F32x4Sqrt, kLa64F32x4Sqrt) \ -+ V(F32x4RecipApprox, kLa64F32x4RecipApprox) \ -+ V(F32x4RecipSqrtApprox, kLa64F32x4RecipSqrtApprox) \ -+ V(F32x4Ceil, kLa64F32x4Ceil) \ -+ V(F32x4Floor, kLa64F32x4Floor) \ -+ V(F32x4Trunc, kLa64F32x4Trunc) \ -+ V(F32x4NearestInt, kLa64F32x4NearestInt) \ -+ V(I32x4SConvertF32x4, kLa64I32x4SConvertF32x4) \ -+ V(I32x4UConvertF32x4, kLa64I32x4UConvertF32x4) \ -+ V(I32x4Neg, kLa64I32x4Neg) \ -+ V(I32x4SConvertI16x8Low, kLa64I32x4SConvertI16x8Low) \ -+ V(I32x4SConvertI16x8High, kLa64I32x4SConvertI16x8High) \ -+ V(I32x4UConvertI16x8Low, kLa64I32x4UConvertI16x8Low) \ -+ V(I32x4UConvertI16x8High, kLa64I32x4UConvertI16x8High) \ -+ V(I32x4Abs, kLa64I32x4Abs) \ -+ V(I32x4BitMask, kLa64I32x4BitMask) \ -+ V(I16x8Neg, kLa64I16x8Neg) \ -+ V(I16x8SConvertI8x16Low, kLa64I16x8SConvertI8x16Low) \ -+ V(I16x8SConvertI8x16High, kLa64I16x8SConvertI8x16High) \ -+ V(I16x8UConvertI8x16Low, kLa64I16x8UConvertI8x16Low) \ -+ V(I16x8UConvertI8x16High, kLa64I16x8UConvertI8x16High) \ -+ V(I16x8Abs, kLa64I16x8Abs) \ -+ V(I16x8BitMask, kLa64I16x8BitMask) \ -+ V(I8x16Neg, kLa64I8x16Neg) \ -+ V(I8x16Abs, kLa64I8x16Abs) \ -+ V(I8x16BitMask, kLa64I8x16BitMask) \ -+ V(S128Not, kLa64S128Not) \ -+ V(V32x4AnyTrue, kLa64V32x4AnyTrue) \ -+ V(V32x4AllTrue, kLa64V32x4AllTrue) \ -+ V(V16x8AnyTrue, kLa64V16x8AnyTrue) \ -+ V(V16x8AllTrue, kLa64V16x8AllTrue) \ -+ V(V8x16AnyTrue, kLa64V8x16AnyTrue) \ -+ V(V8x16AllTrue, kLa64V8x16AllTrue) -+ -+#define SIMD_SHIFT_OP_LIST(V) \ -+ V(I64x2Shl) \ -+ V(I64x2ShrS) \ -+ V(I64x2ShrU) \ -+ V(I32x4Shl) \ -+ V(I32x4ShrS) \ -+ V(I32x4ShrU) \ -+ V(I16x8Shl) \ -+ V(I16x8ShrS) \ -+ V(I16x8ShrU) \ -+ V(I8x16Shl) \ -+ V(I8x16ShrS) \ -+ V(I8x16ShrU) -+ -+#define SIMD_BINOP_LIST(V) \ -+ V(F64x2Add, kLa64F64x2Add) \ -+ V(F64x2Sub, kLa64F64x2Sub) \ -+ V(F64x2Mul, kLa64F64x2Mul) \ -+ V(F64x2Div, kLa64F64x2Div) \ -+ V(F64x2Min, kLa64F64x2Min) \ -+ V(F64x2Max, kLa64F64x2Max) \ -+ V(F64x2Eq, kLa64F64x2Eq) \ -+ V(F64x2Ne, kLa64F64x2Ne) \ -+ V(F64x2Lt, kLa64F64x2Lt) \ -+ V(F64x2Le, kLa64F64x2Le) \ -+ V(I64x2Add, kLa64I64x2Add) \ -+ V(I64x2Sub, kLa64I64x2Sub) \ -+ V(I64x2Mul, kLa64I64x2Mul) \ -+ V(F32x4Add, kLa64F32x4Add) \ -+ V(F32x4AddHoriz, kLa64F32x4AddHoriz) \ -+ V(F32x4Sub, kLa64F32x4Sub) \ -+ V(F32x4Mul, kLa64F32x4Mul) \ -+ V(F32x4Div, kLa64F32x4Div) \ -+ V(F32x4Max, kLa64F32x4Max) \ -+ V(F32x4Min, kLa64F32x4Min) \ -+ V(F32x4Eq, kLa64F32x4Eq) \ -+ V(F32x4Ne, kLa64F32x4Ne) \ -+ V(F32x4Lt, kLa64F32x4Lt) \ -+ V(F32x4Le, kLa64F32x4Le) \ -+ V(I32x4Add, kLa64I32x4Add) \ -+ V(I32x4AddHoriz, kLa64I32x4AddHoriz) \ -+ V(I32x4Sub, kLa64I32x4Sub) \ -+ V(I32x4Mul, kLa64I32x4Mul) \ -+ V(I32x4MaxS, kLa64I32x4MaxS) \ -+ V(I32x4MinS, kLa64I32x4MinS) \ -+ V(I32x4MaxU, kLa64I32x4MaxU) \ -+ V(I32x4MinU, kLa64I32x4MinU) \ -+ V(I32x4Eq, kLa64I32x4Eq) \ -+ V(I32x4Ne, kLa64I32x4Ne) \ -+ V(I32x4GtS, kLa64I32x4GtS) \ -+ V(I32x4GeS, kLa64I32x4GeS) \ -+ V(I32x4GtU, kLa64I32x4GtU) \ -+ V(I32x4GeU, kLa64I32x4GeU) \ -+ V(I16x8Add, kLa64I16x8Add) \ -+ V(I16x8AddSaturateS, kLa64I16x8AddSaturateS) \ -+ V(I16x8AddSaturateU, kLa64I16x8AddSaturateU) \ -+ V(I16x8AddHoriz, kLa64I16x8AddHoriz) \ -+ V(I16x8Sub, kLa64I16x8Sub) \ -+ V(I16x8SubSaturateS, kLa64I16x8SubSaturateS) \ -+ V(I16x8SubSaturateU, kLa64I16x8SubSaturateU) \ -+ V(I16x8Mul, kLa64I16x8Mul) \ -+ V(I16x8MaxS, kLa64I16x8MaxS) \ -+ V(I16x8MinS, kLa64I16x8MinS) \ -+ V(I16x8MaxU, kLa64I16x8MaxU) \ -+ V(I16x8MinU, kLa64I16x8MinU) \ -+ V(I16x8Eq, kLa64I16x8Eq) \ -+ V(I16x8Ne, kLa64I16x8Ne) \ -+ V(I16x8GtS, kLa64I16x8GtS) \ -+ V(I16x8GeS, kLa64I16x8GeS) \ -+ V(I16x8GtU, kLa64I16x8GtU) \ -+ V(I16x8GeU, kLa64I16x8GeU) \ -+ V(I16x8RoundingAverageU, kLa64I16x8RoundingAverageU) \ -+ V(I16x8SConvertI32x4, kLa64I16x8SConvertI32x4) \ -+ V(I16x8UConvertI32x4, kLa64I16x8UConvertI32x4) \ -+ V(I8x16Add, kLa64I8x16Add) \ -+ V(I8x16AddSaturateS, kLa64I8x16AddSaturateS) \ -+ V(I8x16AddSaturateU, kLa64I8x16AddSaturateU) \ -+ V(I8x16Sub, kLa64I8x16Sub) \ -+ V(I8x16SubSaturateS, kLa64I8x16SubSaturateS) \ -+ V(I8x16SubSaturateU, kLa64I8x16SubSaturateU) \ -+ V(I8x16Mul, kLa64I8x16Mul) \ -+ V(I8x16MaxS, kLa64I8x16MaxS) \ -+ V(I8x16MinS, kLa64I8x16MinS) \ -+ V(I8x16MaxU, kLa64I8x16MaxU) \ -+ V(I8x16MinU, kLa64I8x16MinU) \ -+ V(I8x16Eq, kLa64I8x16Eq) \ -+ V(I8x16Ne, kLa64I8x16Ne) \ -+ V(I8x16GtS, kLa64I8x16GtS) \ -+ V(I8x16GeS, kLa64I8x16GeS) \ -+ V(I8x16GtU, kLa64I8x16GtU) \ -+ V(I8x16GeU, kLa64I8x16GeU) \ -+ V(I8x16RoundingAverageU, kLa64I8x16RoundingAverageU) \ -+ V(I8x16SConvertI16x8, kLa64I8x16SConvertI16x8) \ -+ V(I8x16UConvertI16x8, kLa64I8x16UConvertI16x8) \ -+ V(S128And, kLa64S128And) \ -+ V(S128Or, kLa64S128Or) \ -+ V(S128Xor, kLa64S128Xor) \ -+ V(S128AndNot, kLa64S128AndNot) -+ -+void InstructionSelector::VisitS128Const(Node* node) { -+ La64OperandGenerator g(this); -+ static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t); -+ uint32_t val[kUint32Immediates]; -+ memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size); -+ // If all bytes are zeros or ones, avoid emitting code for generic constants -+ bool all_zeros = !(val[0] || val[1] || val[2] || val[3]); -+ bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX && -+ val[2] == UINT32_MAX && val[3] == UINT32_MAX; -+ InstructionOperand dst = g.DefineAsRegister(node); -+ if (all_zeros) { -+ Emit(kLa64S128Zero, dst); -+ } else if (all_ones) { -+ Emit(kLa64S128AllOnes, dst); -+ } else { -+ Emit(kLa64S128Const, dst, g.UseImmediate(val[0]), g.UseImmediate(val[1]), -+ g.UseImmediate(val[2]), g.UseImmediate(val[3])); -+ } -+} -+ -+void InstructionSelector::VisitS128Zero(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64S128Zero, g.DefineAsRegister(node)); -+} -+ -+#define SIMD_VISIT_SPLAT(Type) \ -+ void InstructionSelector::Visit##Type##Splat(Node* node) { \ -+ VisitRR(this, kLa64##Type##Splat, node); \ -+ } -+SIMD_TYPE_LIST(SIMD_VISIT_SPLAT) -+#undef SIMD_VISIT_SPLAT -+ -+#define SIMD_VISIT_EXTRACT_LANE(Type, Sign) \ -+ void InstructionSelector::Visit##Type##ExtractLane##Sign(Node* node) { \ -+ VisitRRI(this, kLa64##Type##ExtractLane##Sign, node); \ -+ } -+SIMD_VISIT_EXTRACT_LANE(F64x2, ) -+SIMD_VISIT_EXTRACT_LANE(F32x4, ) -+SIMD_VISIT_EXTRACT_LANE(I64x2, ) -+SIMD_VISIT_EXTRACT_LANE(I32x4, ) -+SIMD_VISIT_EXTRACT_LANE(I16x8, U) -+SIMD_VISIT_EXTRACT_LANE(I16x8, S) -+SIMD_VISIT_EXTRACT_LANE(I8x16, U) -+SIMD_VISIT_EXTRACT_LANE(I8x16, S) -+#undef SIMD_VISIT_EXTRACT_LANE -+ -+#define SIMD_VISIT_REPLACE_LANE(Type) \ -+ void InstructionSelector::Visit##Type##ReplaceLane(Node* node) { \ -+ VisitRRIR(this, kLa64##Type##ReplaceLane, node); \ -+ } -+SIMD_TYPE_LIST(SIMD_VISIT_REPLACE_LANE) -+#undef SIMD_VISIT_REPLACE_LANE -+ -+#define SIMD_VISIT_UNOP(Name, instruction) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitRR(this, instruction, node); \ -+ } -+SIMD_UNOP_LIST(SIMD_VISIT_UNOP) -+#undef SIMD_VISIT_UNOP -+ -+#define SIMD_VISIT_SHIFT_OP(Name) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitSimdShift(this, kLa64##Name, node); \ -+ } -+SIMD_SHIFT_OP_LIST(SIMD_VISIT_SHIFT_OP) -+#undef SIMD_VISIT_SHIFT_OP -+ -+#define SIMD_VISIT_BINOP(Name, instruction) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitRRR(this, instruction, node); \ -+ } -+SIMD_BINOP_LIST(SIMD_VISIT_BINOP) -+#undef SIMD_VISIT_BINOP -+ -+void InstructionSelector::VisitS128Select(Node* node) { -+ VisitRRRR(this, kLa64S128Select, node); -+} -+ -+namespace { -+ -+struct ShuffleEntry { -+ uint8_t shuffle[kSimd128Size]; -+ ArchOpcode opcode; -+}; -+ -+static const ShuffleEntry arch_shuffles[] = { -+ {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}, -+ kLa64S32x4InterleaveRight}, -+ {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}, -+ kLa64S32x4InterleaveLeft}, -+ {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}, -+ kLa64S32x4PackEven}, -+ {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}, -+ kLa64S32x4PackOdd}, -+ {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}, -+ kLa64S32x4InterleaveEven}, -+ {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}, -+ kLa64S32x4InterleaveOdd}, -+ -+ {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}, -+ kLa64S16x8InterleaveRight}, -+ {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}, -+ kLa64S16x8InterleaveLeft}, -+ {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}, -+ kLa64S16x8PackEven}, -+ {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}, -+ kLa64S16x8PackOdd}, -+ {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}, -+ kLa64S16x8InterleaveEven}, -+ {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}, -+ kLa64S16x8InterleaveOdd}, -+ {{6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9}, kLa64S16x4Reverse}, -+ {{2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13}, kLa64S16x2Reverse}, -+ -+ {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}, -+ kLa64S8x16InterleaveRight}, -+ {{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}, -+ kLa64S8x16InterleaveLeft}, -+ {{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}, -+ kLa64S8x16PackEven}, -+ {{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, -+ kLa64S8x16PackOdd}, -+ {{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}, -+ kLa64S8x16InterleaveEven}, -+ {{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}, -+ kLa64S8x16InterleaveOdd}, -+ {{7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}, kLa64S8x8Reverse}, -+ {{3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12}, kLa64S8x4Reverse}, -+ {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}, kLa64S8x2Reverse}}; -+ -+bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table, -+ size_t num_entries, bool is_swizzle, -+ ArchOpcode* opcode) { -+ uint8_t mask = is_swizzle ? kSimd128Size - 1 : 2 * kSimd128Size - 1; -+ for (size_t i = 0; i < num_entries; ++i) { -+ const ShuffleEntry& entry = table[i]; -+ int j = 0; -+ for (; j < kSimd128Size; ++j) { -+ if ((entry.shuffle[j] & mask) != (shuffle[j] & mask)) { -+ break; -+ } -+ } -+ if (j == kSimd128Size) { -+ *opcode = entry.opcode; -+ return true; -+ } -+ } -+ return false; -+} -+ -+} // namespace -+ -+void InstructionSelector::VisitI8x16Shuffle(Node* node) { -+ uint8_t shuffle[kSimd128Size]; -+ bool is_swizzle; -+ CanonicalizeShuffle(node, shuffle, &is_swizzle); -+ uint8_t shuffle32x4[4]; -+ ArchOpcode opcode; -+ if (TryMatchArchShuffle(shuffle, arch_shuffles, arraysize(arch_shuffles), -+ is_swizzle, &opcode)) { -+ VisitRRR(this, opcode, node); -+ return; -+ } -+ Node* input0 = node->InputAt(0); -+ Node* input1 = node->InputAt(1); -+ uint8_t offset; -+ La64OperandGenerator g(this); -+ if (wasm::SimdShuffle::TryMatchConcat(shuffle, &offset)) { -+ Emit(kLa64S8x16Concat, g.DefineSameAsFirst(node), g.UseRegister(input1), -+ g.UseRegister(input0), g.UseImmediate(offset)); -+ return; -+ } -+ if (wasm::SimdShuffle::TryMatch32x4Shuffle(shuffle, shuffle32x4)) { -+ Emit(kLa64S32x4Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), -+ g.UseRegister(input1), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4))); -+ return; -+ } -+ Emit(kLa64I8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), -+ g.UseRegister(input1), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12))); -+} -+ -+void InstructionSelector::VisitI8x16Swizzle(Node* node) { -+ La64OperandGenerator g(this); -+ InstructionOperand temps[] = {g.TempSimd128Register()}; -+ // We don't want input 0 or input 1 to be the same as output, since we will -+ // modify output before do the calculation. -+ Emit(kLa64I8x16Swizzle, g.DefineAsRegister(node), -+ g.UseUniqueRegister(node->InputAt(0)), -+ g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); -+} -+ -+void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Seb, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord16ToInt32(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Seh, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Seb, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Seh, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) { -+ La64OperandGenerator g(this); -+ Emit(kLa64Shl, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0)); -+} -+ -+void InstructionSelector::VisitF32x4Pmin(Node* node) { -+ VisitUniqueRRR(this, kLa64F32x4Pmin, node); -+} -+ -+void InstructionSelector::VisitF32x4Pmax(Node* node) { -+ VisitUniqueRRR(this, kLa64F32x4Pmax, node); -+} -+ -+void InstructionSelector::VisitF64x2Pmin(Node* node) { -+ VisitUniqueRRR(this, kLa64F64x2Pmin, node); -+} -+ -+void InstructionSelector::VisitF64x2Pmax(Node* node) { -+ VisitUniqueRRR(this, kLa64F64x2Pmax, node); -+} -+ -+// static -+MachineOperatorBuilder::Flags -+InstructionSelector::SupportedMachineOperatorFlags() { -+ MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; -+ return flags | MachineOperatorBuilder::kWord32Ctz | -+ MachineOperatorBuilder::kWord64Ctz | -+ MachineOperatorBuilder::kWord32Popcnt | -+ MachineOperatorBuilder::kWord64Popcnt | -+ MachineOperatorBuilder::kWord32ShiftIsSafe | -+ MachineOperatorBuilder::kInt32DivIsSafe | -+ MachineOperatorBuilder::kUint32DivIsSafe | -+ MachineOperatorBuilder::kFloat64RoundDown | -+ MachineOperatorBuilder::kFloat32RoundDown | -+ MachineOperatorBuilder::kFloat64RoundUp | -+ MachineOperatorBuilder::kFloat32RoundUp | -+ MachineOperatorBuilder::kFloat64RoundTruncate | -+ MachineOperatorBuilder::kFloat32RoundTruncate | -+ MachineOperatorBuilder::kFloat64RoundTiesEven | -+ MachineOperatorBuilder::kFloat32RoundTiesEven; -+} -+ -+// static -+MachineOperatorBuilder::AlignmentRequirements -+InstructionSelector::AlignmentRequirements() { -+ return MachineOperatorBuilder::AlignmentRequirements:: -+ FullUnalignedAccessSupport(); -+} -+ -+#undef SIMD_BINOP_LIST -+#undef SIMD_SHIFT_OP_LIST -+#undef SIMD_UNOP_LIST -+#undef SIMD_TYPE_LIST -+#undef TRACE_UNIMPL -+#undef TRACE -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 -diff --git a/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc b/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc -index af467f2bb..765c5244f 100644 ---- a/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc -+++ b/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc -@@ -100,6 +100,18 @@ namespace { - #define CALLEE_SAVE_FP_REGISTERS \ - f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() - -+#elif V8_TARGET_ARCH_LOONGARCH64 -+// =========================================================================== -+// == loongarch64 ============================================================ -+// =========================================================================== -+#define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 -+#define CALLEE_SAVE_REGISTERS \ -+ s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ -+ s7.bit() | fp.bit() -+#define CALLEE_SAVE_FP_REGISTERS \ -+ f24.bit() | f25.bit() | f26.bit() | f27.bit() | f28.bit() | f29.bit() | \ -+ f30.bit() | f31.bit() -+ - #elif V8_TARGET_ARCH_PPC64 - // =========================================================================== - // == ppc & ppc64 ============================================================ -diff --git a/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc b/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc -index c7d0a890c..416e95bea 100644 ---- a/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc -+++ b/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc -@@ -1061,7 +1061,7 @@ void DebugEvaluate::VerifyTransitiveBuiltins(Isolate* isolate) { - } - CHECK(!failed); - #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ -- defined(V8_TARGET_ARCH_MIPS64) -+ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) - // Isolate-independent builtin calls and jumps do not emit reloc infos - // on PPC. We try to avoid using PC relative code due to performance - // issue with especially older hardwares. -diff --git a/src/3rdparty/chromium/v8/src/debug/loongarch64/debug-loongarch64.cc b/src/3rdparty/chromium/v8/src/debug/loongarch64/debug-loongarch64.cc -new file mode 100644 -index 000000000..a62d61073 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/debug/loongarch64/debug-loongarch64.cc -@@ -0,0 +1,55 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/debug/debug.h" -+#include "src/debug/liveedit.h" -+#include "src/execution/frames-inl.h" -+ -+namespace v8 { -+namespace internal { -+ -+#define __ ACCESS_MASM(masm) -+ -+void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); -+ } -+ __ MaybeDropFrames(); -+ -+ // Return to caller. -+ __ Ret(); -+} -+ -+void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { -+ // Frame is being dropped: -+ // - Drop to the target frame specified by a1. -+ // - Look up current function on the frame. -+ // - Leave the frame. -+ // - Restart the frame by calling the function. -+ __ mov(fp, a1); -+ __ Ld_d(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ -+ // Pop return address and frame. -+ __ LeaveFrame(StackFrame::INTERNAL); -+ -+ __ Ld_d(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld_hu( -+ a0, FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ mov(a2, a0); -+ -+ __ InvokeFunction(a1, a2, a0, JUMP_FUNCTION); -+} -+ -+const bool LiveEdit::kFrameDropperSupported = true; -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc b/src/3rdparty/chromium/v8/src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc -new file mode 100644 -index 000000000..23a0051d9 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc -@@ -0,0 +1,241 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/register-configuration.h" -+#include "src/codegen/safepoint-table.h" -+#include "src/deoptimizer/deoptimizer.h" -+ -+namespace v8 { -+namespace internal { -+ -+const bool Deoptimizer::kSupportsFixedDeoptExitSizes = false; -+const int Deoptimizer::kNonLazyDeoptExitSize = 0; -+const int Deoptimizer::kLazyDeoptExitSize = 0; -+ -+#define __ masm-> -+ -+// This code tries to be close to ia32 code so that any changes can be -+// easily ported. -+void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, -+ Isolate* isolate, -+ DeoptimizeKind deopt_kind) { -+ NoRootArrayScope no_root_array(masm); -+ -+ // Unlike on ARM we don't save all the registers, just the useful ones. -+ // For the rest, there are gaps on the stack, so the offsets remain the same. -+ const int kNumberOfRegisters = Register::kNumRegisters; -+ -+ RegList restored_regs = kJSCallerSaved | kCalleeSaved; -+ RegList saved_regs = restored_regs | sp.bit() | ra.bit(); -+ -+ const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; -+ -+ // Save all double FPU registers before messing with them. -+ __ Sub_d(sp, sp, Operand(kDoubleRegsSize)); -+ const RegisterConfiguration* config = RegisterConfiguration::Default(); -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); -+ int offset = code * kDoubleSize; -+ __ Fst_d(fpu_reg, MemOperand(sp, offset)); -+ } -+ -+ // Push saved_regs (needed to populate FrameDescription::registers_). -+ // Leave gaps for other registers. -+ __ Sub_d(sp, sp, kNumberOfRegisters * kPointerSize); -+ for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { -+ if ((saved_regs & (1 << i)) != 0) { -+ __ St_d(ToRegister(i), MemOperand(sp, kPointerSize * i)); -+ } -+ } -+ -+ __ li(a2, Operand(ExternalReference::Create( -+ IsolateAddressId::kCEntryFPAddress, isolate))); -+ __ St_d(fp, MemOperand(a2, 0)); -+ -+ const int kSavedRegistersAreaSize = -+ (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; -+ -+ // Get the bailout is passed as kRootRegister by the caller. -+ __ mov(a2, kRootRegister); -+ -+ // Get the address of the location in the code object (a3) (return -+ // address for lazy deoptimization) and compute the fp-to-sp delta in -+ // register a4. -+ __ mov(a3, ra); -+ __ Add_d(a4, sp, Operand(kSavedRegistersAreaSize)); -+ -+ __ Sub_d(a4, fp, a4); -+ -+ // Allocate a new deoptimizer object. -+ __ PrepareCallCFunction(6, a5); -+ // Pass six arguments, according to n64 ABI. -+ __ mov(a0, zero_reg); -+ Label context_check; -+ __ Ld_d(a1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); -+ __ JumpIfSmi(a1, &context_check); -+ __ Ld_d(a0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ bind(&context_check); -+ __ li(a1, Operand(static_cast(deopt_kind))); -+ // a2: bailout id already loaded. -+ // a3: code address or 0 already loaded. -+ // a4: already has fp-to-sp delta. -+ __ li(a5, Operand(ExternalReference::isolate_address(isolate))); -+ -+ // Call Deoptimizer::New(). -+ { -+ AllowExternalCallThatCantCauseGC scope(masm); -+ __ CallCFunction(ExternalReference::new_deoptimizer_function(), 6); -+ } -+ -+ // Preserve "deoptimizer" object in register v0 and get the input -+ // frame descriptor pointer to a1 (deoptimizer->input_); -+ // Move deopt-obj to a0 for call to Deoptimizer::ComputeOutputFrames() below. -+ // TODO save a0 -+ //__ mov(a0, v0); -+ __ Ld_d(a1, MemOperand(a0, Deoptimizer::input_offset())); -+ -+ // Copy core registers into FrameDescription::registers_[kNumRegisters]. -+ DCHECK_EQ(Register::kNumRegisters, kNumberOfRegisters); -+ for (int i = 0; i < kNumberOfRegisters; i++) { -+ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); -+ if ((saved_regs & (1 << i)) != 0) { -+ __ Ld_d(a2, MemOperand(sp, i * kPointerSize)); -+ __ St_d(a2, MemOperand(a1, offset)); -+ } else if (FLAG_debug_code) { -+ __ li(a2, Operand(kDebugZapValue)); -+ __ St_d(a2, MemOperand(a1, offset)); -+ } -+ } -+ -+ int double_regs_offset = FrameDescription::double_registers_offset(); -+ // Copy FPU registers to -+ // double_registers_[DoubleRegister::kNumAllocatableRegisters] -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ int dst_offset = code * kDoubleSize + double_regs_offset; -+ int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; -+ __ Fld_d(f0, MemOperand(sp, src_offset)); -+ __ Fst_d(f0, MemOperand(a1, dst_offset)); -+ } -+ -+ // Remove the saved registers from the stack. -+ __ Add_d(sp, sp, Operand(kSavedRegistersAreaSize)); -+ -+ // Compute a pointer to the unwinding limit in register a2; that is -+ // the first stack slot not part of the input frame. -+ __ Ld_d(a2, MemOperand(a1, FrameDescription::frame_size_offset())); -+ __ Add_d(a2, a2, sp); -+ -+ // Unwind the stack down to - but not including - the unwinding -+ // limit and copy the contents of the activation frame to the input -+ // frame description. -+ __ Add_d(a3, a1, Operand(FrameDescription::frame_content_offset())); -+ Label pop_loop; -+ Label pop_loop_header; -+ __ Branch(&pop_loop_header); -+ __ bind(&pop_loop); -+ __ pop(a4); -+ __ St_d(a4, MemOperand(a3, 0)); -+ __ addi_d(a3, a3, sizeof(uint64_t)); -+ __ bind(&pop_loop_header); -+ __ BranchShort(&pop_loop, ne, a2, Operand(sp)); -+ // Compute the output frame in the deoptimizer. -+ __ push(a0); // Preserve deoptimizer object across call. -+ // a0: deoptimizer object; a1: scratch. -+ __ PrepareCallCFunction(1, a1); -+ // Call Deoptimizer::ComputeOutputFrames(). -+ { -+ AllowExternalCallThatCantCauseGC scope(masm); -+ __ CallCFunction(ExternalReference::compute_output_frames_function(), 1); -+ } -+ __ pop(a0); // Restore deoptimizer object (class Deoptimizer). -+ -+ __ Ld_d(sp, MemOperand(a0, Deoptimizer::caller_frame_top_offset())); -+ -+ // Replace the current (input) frame with the output frames. -+ Label outer_push_loop, inner_push_loop, outer_loop_header, inner_loop_header; -+ // Outer loop state: a4 = current "FrameDescription** output_", -+ // a1 = one past the last FrameDescription**. -+ __ Ld_w(a1, MemOperand(a0, Deoptimizer::output_count_offset())); -+ __ Ld_d(a4, MemOperand(a0, Deoptimizer::output_offset())); // a4 is output_. -+ __ Alsl_d(a1, a1, a4, kPointerSizeLog2, t7); -+ __ Branch(&outer_loop_header); -+ __ bind(&outer_push_loop); -+ // Inner loop state: a2 = current FrameDescription*, a3 = loop index. -+ __ Ld_d(a2, MemOperand(a4, 0)); // output_[ix] -+ __ Ld_d(a3, MemOperand(a2, FrameDescription::frame_size_offset())); -+ __ Branch(&inner_loop_header); -+ __ bind(&inner_push_loop); -+ __ Sub_d(a3, a3, Operand(sizeof(uint64_t))); -+ __ Add_d(a6, a2, Operand(a3)); -+ __ Ld_d(a7, MemOperand(a6, FrameDescription::frame_content_offset())); -+ __ push(a7); -+ __ bind(&inner_loop_header); -+ __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); -+ -+ __ Add_d(a4, a4, Operand(kPointerSize)); -+ __ bind(&outer_loop_header); -+ __ BranchShort(&outer_push_loop, lt, a4, Operand(a1)); -+ -+ __ Ld_d(a1, MemOperand(a0, Deoptimizer::input_offset())); -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); -+ int src_offset = code * kDoubleSize + double_regs_offset; -+ __ Fld_d(fpu_reg, MemOperand(a1, src_offset)); -+ } -+ -+ // Push pc and continuation from the last output frame. -+ __ Ld_d(a6, MemOperand(a2, FrameDescription::pc_offset())); -+ __ push(a6); -+ __ Ld_d(a6, MemOperand(a2, FrameDescription::continuation_offset())); -+ __ push(a6); -+ -+ // Technically restoring 'at' should work unless zero_reg is also restored -+ // but it's safer to check for this. -+ DCHECK(!(t7.bit() & restored_regs)); -+ // Restore the registers from the last output frame. -+ __ mov(t7, a2); -+ for (int i = kNumberOfRegisters - 1; i >= 0; i--) { -+ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); -+ if ((restored_regs & (1 << i)) != 0) { -+ __ Ld_d(ToRegister(i), MemOperand(t7, offset)); -+ } -+ } -+ -+ __ pop(t7); // Get continuation, leave pc on stack. -+ __ pop(ra); -+ __ Jump(t7); -+ __ stop(); -+} -+ -+// Maximum size of a table entry generated below. -+const int Deoptimizer::table_entry_size_ = 2 * kInstrSize; -+ -+Float32 RegisterValues::GetFloatRegister(unsigned n) const { -+ return Float32::FromBits( -+ static_cast(double_registers_[n].get_bits())); -+} -+ -+void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { -+ SetFrameSlot(offset, value); -+} -+ -+void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { -+ SetFrameSlot(offset, value); -+} -+ -+void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { -+ // No embedded constant pool support. -+ UNREACHABLE(); -+} -+ -+void FrameDescription::SetPc(intptr_t pc) { pc_ = pc; } -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -diff --git a/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc b/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc -index c9180fbaf..8f2d3cb28 100644 ---- a/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc -+++ b/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc -@@ -1077,6 +1077,8 @@ class DebugInfoSection : public DebugSection { - UNIMPLEMENTED(); - #elif V8_TARGET_ARCH_MIPS64 - UNIMPLEMENTED(); -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ UNIMPLEMENTED(); - #elif V8_TARGET_ARCH_PPC64 && V8_OS_LINUX - w->Write(DW_OP_reg31); // The frame pointer is here on PPC64. - #elif V8_TARGET_ARCH_S390 -diff --git a/src/3rdparty/chromium/v8/src/diagnostics/loongarch64/disasm-loongarch64.cc b/src/3rdparty/chromium/v8/src/diagnostics/loongarch64/disasm-loongarch64.cc -new file mode 100644 -index 000000000..0bd6efd6b ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/diagnostics/loongarch64/disasm-loongarch64.cc -@@ -0,0 +1,1694 @@ -+#include -+#include -+#include -+#include -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/base/platform/platform.h" -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/diagnostics/disasm.h" -+ -+namespace v8 { -+namespace internal { -+ -+//------------------------------------------------------------------------------ -+ -+// Decoder decodes and disassembles instructions into an output buffer. -+// It uses the converter to convert register names and call destinations into -+// more informative description. -+class Decoder { -+ public: -+ Decoder(const disasm::NameConverter& converter, -+ v8::internal::Vector out_buffer) -+ : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { -+ out_buffer_[out_buffer_pos_] = '\0'; -+ } -+ -+ ~Decoder() {} -+ -+ // Writes one disassembled instruction into 'buffer' (0-terminated). -+ // Returns the length of the disassembled machine instruction in bytes. -+ int InstructionDecode(byte* instruction); -+ -+ private: -+ // Bottleneck functions to print into the out_buffer. -+ void PrintChar(const char ch); -+ void Print(const char* str); -+ -+ // Printing of common values. -+ void PrintRegister(int reg); -+ void PrintFPURegister(int freg); -+ void PrintFPUStatusRegister(int freg); -+ void PrintRj(Instruction* instr); -+ void PrintRk(Instruction* instr); -+ void PrintRd(Instruction* instr); -+ void PrintFj(Instruction* instr); -+ void PrintFk(Instruction* instr); -+ void PrintFd(Instruction* instr); -+ void PrintFa(Instruction* instr); -+ void PrintSa2(Instruction* instr); -+ void PrintSa3(Instruction* instr); -+ void PrintUi5(Instruction* instr); -+ void PrintUi6(Instruction* instr); -+ void PrintUi12(Instruction* instr); -+ void PrintXi12(Instruction* instr); -+ void PrintMsbw(Instruction* instr); -+ void PrintLsbw(Instruction* instr); -+ void PrintMsbd(Instruction* instr); -+ void PrintLsbd(Instruction* instr); -+ // void PrintCond(Instruction* instr); -+ void PrintSi12(Instruction* instr); -+ void PrintSi14(Instruction* instr); -+ void PrintSi16(Instruction* instr); -+ void PrintSi20(Instruction* instr); -+ void PrintCj(Instruction* instr); -+ void PrintCd(Instruction* instr); -+ void PrintCa(Instruction* instr); -+ void PrintCode(Instruction* instr); -+ void PrintHint5(Instruction* instr); -+ void PrintHint15(Instruction* instr); -+ void PrintPCOffs16(Instruction* instr); -+ void PrintPCOffs21(Instruction* instr); -+ void PrintPCOffs26(Instruction* instr); -+ void PrintOffs16(Instruction* instr); -+ void PrintOffs21(Instruction* instr); -+ void PrintOffs26(Instruction* instr); -+ -+ // Handle formatting of instructions and their options. -+ int FormatRegister(Instruction* instr, const char* option); -+ int FormatFPURegister(Instruction* instr, const char* option); -+ int FormatOption(Instruction* instr, const char* option); -+ void Format(Instruction* instr, const char* format); -+ void Unknown(Instruction* instr); -+ int DecodeBreakInstr(Instruction* instr); -+ -+ // Each of these functions decodes one particular instruction type. -+ int InstructionDecode(Instruction* instr); -+ void DecodeTypekOp6(Instruction* instr); -+ void DecodeTypekOp7(Instruction* instr); -+ void DecodeTypekOp8(Instruction* instr); -+ void DecodeTypekOp10(Instruction* instr); -+ void DecodeTypekOp12(Instruction* instr); -+ void DecodeTypekOp14(Instruction* instr); -+ int DecodeTypekOp17(Instruction* instr); -+ void DecodeTypekOp22(Instruction* instr); -+ -+ const disasm::NameConverter& converter_; -+ v8::internal::Vector out_buffer_; -+ int out_buffer_pos_; -+ -+ DISALLOW_COPY_AND_ASSIGN(Decoder); -+}; -+ -+// Support for assertions in the Decoder formatting functions. -+#define STRING_STARTS_WITH(string, compare_string) \ -+ (strncmp(string, compare_string, strlen(compare_string)) == 0) -+ -+// Append the ch to the output buffer. -+void Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; } -+ -+// Append the str to the output buffer. -+void Decoder::Print(const char* str) { -+ char cur = *str++; -+ while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { -+ PrintChar(cur); -+ cur = *str++; -+ } -+ out_buffer_[out_buffer_pos_] = 0; -+} -+ -+// Print the register name according to the active name converter. -+void Decoder::PrintRegister(int reg) { -+ Print(converter_.NameOfCPURegister(reg)); -+} -+ -+void Decoder::PrintRj(Instruction* instr) { -+ int reg = instr->RjValue(); -+ PrintRegister(reg); -+} -+ -+void Decoder::PrintRk(Instruction* instr) { -+ int reg = instr->RkValue(); -+ PrintRegister(reg); -+} -+ -+void Decoder::PrintRd(Instruction* instr) { -+ int reg = instr->RdValue(); -+ PrintRegister(reg); -+} -+ -+// Print the FPUregister name according to the active name converter. -+void Decoder::PrintFPURegister(int freg) { -+ Print(converter_.NameOfXMMRegister(freg)); -+} -+ -+void Decoder::PrintFj(Instruction* instr) { -+ int freg = instr->FjValue(); -+ PrintFPURegister(freg); -+} -+ -+void Decoder::PrintFk(Instruction* instr) { -+ int freg = instr->FkValue(); -+ PrintFPURegister(freg); -+} -+ -+void Decoder::PrintFd(Instruction* instr) { -+ int freg = instr->FdValue(); -+ PrintFPURegister(freg); -+} -+ -+void Decoder::PrintFa(Instruction* instr) { -+ int freg = instr->FaValue(); -+ PrintFPURegister(freg); -+} -+ -+// Print the integer value of the sa field. -+void Decoder::PrintSa2(Instruction* instr) { -+ int sa = instr->Sa2Value(); -+ uint32_t opcode = (instr->InstructionBits() >> 18) << 18; -+ if (opcode == ALSL || opcode == ALSL_D) { -+ sa += 1; -+ } -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa); -+} -+ -+void Decoder::PrintSa3(Instruction* instr) { -+ int sa = instr->Sa3Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa); -+} -+ -+void Decoder::PrintUi5(Instruction* instr) { -+ int ui = instr->Ui5Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); -+} -+ -+void Decoder::PrintUi6(Instruction* instr) { -+ int ui = instr->Ui6Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); -+} -+ -+void Decoder::PrintUi12(Instruction* instr) { -+ int ui = instr->Ui12Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); -+} -+ -+void Decoder::PrintXi12(Instruction* instr) { -+ int xi = instr->Ui12Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi); -+} -+ -+void Decoder::PrintMsbd(Instruction* instr) { -+ int msbd = instr->MsbdValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd); -+} -+ -+void Decoder::PrintLsbd(Instruction* instr) { -+ int lsbd = instr->LsbdValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbd); -+} -+ -+void Decoder::PrintMsbw(Instruction* instr) { -+ int msbw = instr->MsbwValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbw); -+} -+ -+void Decoder::PrintLsbw(Instruction* instr) { -+ int lsbw = instr->LsbwValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbw); -+} -+ -+void Decoder::PrintSi12(Instruction* instr) { -+ int si = ((instr->Si12Value()) << (32 - kSi12Bits)) >> (32 - kSi12Bits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); -+} -+ -+void Decoder::PrintSi14(Instruction* instr) { -+ int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits); -+ si <<= 2; -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); -+} -+ -+void Decoder::PrintSi16(Instruction* instr) { -+ int si = ((instr->Si16Value()) << (32 - kSi16Bits)) >> (32 - kSi16Bits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); -+} -+ -+void Decoder::PrintSi20(Instruction* instr) { -+ int si = ((instr->Si20Value()) << (32 - kSi20Bits)) >> (32 - kSi20Bits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); -+} -+ -+void Decoder::PrintCj(Instruction* instr) { -+ int cj = instr->CjValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cj); -+} -+ -+void Decoder::PrintCd(Instruction* instr) { -+ int cd = instr->CdValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cd); -+} -+ -+void Decoder::PrintCa(Instruction* instr) { -+ int ca = instr->CaValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ca); -+} -+ -+void Decoder::PrintCode(Instruction* instr) { -+ int code = instr->CodeValue(); -+ out_buffer_pos_ += -+ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", code, code); -+} -+ -+void Decoder::PrintHint5(Instruction* instr) { -+ int hint = instr->Hint5Value(); -+ out_buffer_pos_ += -+ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint); -+} -+ -+void Decoder::PrintHint15(Instruction* instr) { -+ int hint = instr->Hint15Value(); -+ out_buffer_pos_ += -+ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint); -+} -+ -+void Decoder::PrintPCOffs16(Instruction* instr) { -+ int n_bits = 2; -+ int offs = instr->Offs16Value(); -+ int target = ((offs << n_bits) << (32 - kOffsLowBits - n_bits)) >> -+ (32 - kOffsLowBits - n_bits); -+ out_buffer_pos_ += SNPrintF( -+ out_buffer_ + out_buffer_pos_, "%s", -+ converter_.NameOfAddress(reinterpret_cast(instr) + target)); -+} -+ -+void Decoder::PrintPCOffs21(Instruction* instr) { -+ int n_bits = 2; -+ int offs = instr->Offs21Value(); -+ int target = -+ ((offs << n_bits) << (32 - kOffsLowBits - kOffs21HighBits - n_bits)) >> -+ (32 - kOffsLowBits - kOffs21HighBits - n_bits); -+ out_buffer_pos_ += SNPrintF( -+ out_buffer_ + out_buffer_pos_, "%s", -+ converter_.NameOfAddress(reinterpret_cast(instr) + target)); -+} -+ -+void Decoder::PrintPCOffs26(Instruction* instr) { -+ int n_bits = 2; -+ int offs = instr->Offs26Value(); -+ int target = -+ ((offs << n_bits) << (32 - kOffsLowBits - kOffs26HighBits - n_bits)) >> -+ (32 - kOffsLowBits - kOffs26HighBits - n_bits); -+ out_buffer_pos_ += SNPrintF( -+ out_buffer_ + out_buffer_pos_, "%s", -+ converter_.NameOfAddress(reinterpret_cast(instr) + target)); -+} -+ -+void Decoder::PrintOffs16(Instruction* instr) { -+ int offs = instr->Offs16Value(); -+ offs <<= (32 - kOffsLowBits); -+ offs >>= (32 - kOffsLowBits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); -+} -+ -+void Decoder::PrintOffs21(Instruction* instr) { -+ int offs = instr->Offs21Value(); -+ offs <<= (32 - kOffsLowBits - kOffs21HighBits); -+ offs >>= (32 - kOffsLowBits - kOffs21HighBits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); -+} -+ -+void Decoder::PrintOffs26(Instruction* instr) { -+ int offs = instr->Offs26Value(); -+ offs <<= (32 - kOffsLowBits - kOffs26HighBits); -+ offs >>= (32 - kOffsLowBits - kOffs26HighBits); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); -+} -+ -+// Handle all register based formatting in this function to reduce the -+// complexity of FormatOption. -+int Decoder::FormatRegister(Instruction* instr, const char* format) { -+ DCHECK_EQ(format[0], 'r'); -+ if (format[1] == 'j') { // 'rj: Rj register. -+ int reg = instr->RjValue(); -+ PrintRegister(reg); -+ return 2; -+ } else if (format[1] == 'k') { // 'rk: rk register. -+ int reg = instr->RkValue(); -+ PrintRegister(reg); -+ return 2; -+ } else if (format[1] == 'd') { // 'rd: rd register. -+ int reg = instr->RdValue(); -+ PrintRegister(reg); -+ return 2; -+ } -+ UNREACHABLE(); -+ return 0; -+} -+ -+// Handle all FPUregister based formatting in this function to reduce the -+// complexity of FormatOption. -+int Decoder::FormatFPURegister(Instruction* instr, const char* format) { -+ DCHECK_EQ(format[0], 'f'); -+ if (format[1] == 'j') { // 'fj: fj register. -+ int reg = instr->FjValue(); -+ PrintFPURegister(reg); -+ return 2; -+ } else if (format[1] == 'k') { // 'fk: fk register. -+ int reg = instr->FkValue(); -+ PrintFPURegister(reg); -+ return 2; -+ } else if (format[1] == 'd') { // 'fd: fd register. -+ int reg = instr->FdValue(); -+ PrintFPURegister(reg); -+ return 2; -+ } else if (format[1] == 'a') { // 'fa: fa register. -+ int reg = instr->FaValue(); -+ PrintFPURegister(reg); -+ return 2; -+ } -+ UNREACHABLE(); -+ return 0; -+} -+ -+// FormatOption takes a formatting string and interprets it based on -+// the current instructions. The format string points to the first -+// character of the option string (the option escape has already been -+// consumed by the caller.) FormatOption returns the number of -+// characters that were consumed from the formatting string. -+int Decoder::FormatOption(Instruction* instr, const char* format) { -+ switch (format[0]) { -+ case 'c': { -+ switch (format[1]) { -+ case 'a': -+ DCHECK(STRING_STARTS_WITH(format, "ca")); -+ PrintCa(instr); -+ return 2; -+ case 'd': -+ DCHECK(STRING_STARTS_WITH(format, "cd")); -+ PrintCd(instr); -+ return 2; -+ case 'j': -+ DCHECK(STRING_STARTS_WITH(format, "cj")); -+ PrintCj(instr); -+ return 2; -+ case 'o': -+ DCHECK(STRING_STARTS_WITH(format, "code")); -+ PrintCode(instr); -+ return 4; -+ } -+ } -+ case 'f': { -+ return FormatFPURegister(instr, format); -+ } -+ case 'h': { -+ if (format[4] == '5') { -+ DCHECK(STRING_STARTS_WITH(format, "hint5")); -+ PrintHint5(instr); -+ return 5; -+ } else if (format[4] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "hint15")); -+ PrintHint15(instr); -+ return 6; -+ } -+ break; -+ } -+ case 'l': { -+ switch (format[3]) { -+ case 'w': -+ DCHECK(STRING_STARTS_WITH(format, "lsbw")); -+ PrintLsbw(instr); -+ return 4; -+ case 'd': -+ DCHECK(STRING_STARTS_WITH(format, "lsbd")); -+ PrintLsbd(instr); -+ return 4; -+ default: -+ return 0; -+ } -+ } -+ case 'm': { -+ if (format[3] == 'w') { -+ DCHECK(STRING_STARTS_WITH(format, "msbw")); -+ PrintMsbw(instr); -+ } else if (format[3] == 'd') { -+ DCHECK(STRING_STARTS_WITH(format, "msbd")); -+ PrintMsbd(instr); -+ } -+ return 4; -+ } -+ case 'o': { -+ if (format[1] == 'f') { -+ if (format[4] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "offs16")); -+ PrintOffs16(instr); -+ return 6; -+ } else if (format[4] == '2') { -+ if (format[5] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "offs21")); -+ PrintOffs21(instr); -+ return 6; -+ } else if (format[5] == '6') { -+ DCHECK(STRING_STARTS_WITH(format, "offs26")); -+ PrintOffs26(instr); -+ return 6; -+ } -+ } -+ } -+ break; -+ } -+ case 'p': { -+ if (format[6] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "pcoffs16")); -+ PrintPCOffs16(instr); -+ return 8; -+ } else if (format[6] == '2') { -+ if (format[7] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "pcoffs21")); -+ PrintPCOffs21(instr); -+ return 8; -+ } else if (format[7] == '6') { -+ DCHECK(STRING_STARTS_WITH(format, "pcoffs26")); -+ PrintPCOffs26(instr); -+ return 8; -+ } -+ } -+ break; -+ } -+ case 'r': { -+ return FormatRegister(instr, format); -+ break; -+ } -+ case 's': { -+ switch (format[1]) { -+ case 'a': -+ if (format[2] == '2') { -+ DCHECK(STRING_STARTS_WITH(format, "sa2")); -+ PrintSa2(instr); -+ } else if (format[2] == '3') { -+ DCHECK(STRING_STARTS_WITH(format, "sa3")); -+ PrintSa3(instr); -+ } -+ return 3; -+ case 'i': -+ if (format[2] == '2') { -+ DCHECK(STRING_STARTS_WITH(format, "si20")); -+ PrintSi20(instr); -+ return 4; -+ } else if (format[2] == '1') { -+ switch (format[3]) { -+ case '2': -+ DCHECK(STRING_STARTS_WITH(format, "si12")); -+ PrintSi12(instr); -+ return 4; -+ case '4': -+ DCHECK(STRING_STARTS_WITH(format, "si14")); -+ PrintSi14(instr); -+ return 4; -+ case '6': -+ DCHECK(STRING_STARTS_WITH(format, "si16")); -+ PrintSi16(instr); -+ return 4; -+ default: -+ break; -+ } -+ } -+ break; -+ default: -+ break; -+ } -+ break; -+ } -+ case 'u': { -+ if (format[2] == '5') { -+ DCHECK(STRING_STARTS_WITH(format, "ui5")); -+ PrintUi5(instr); -+ return 3; -+ } else if (format[2] == '6') { -+ DCHECK(STRING_STARTS_WITH(format, "ui6")); -+ PrintUi6(instr); -+ return 3; -+ } else if (format[2] == '1') { -+ DCHECK(STRING_STARTS_WITH(format, "ui12")); -+ PrintUi12(instr); -+ return 4; -+ } -+ break; -+ } -+ case 'x': { -+ DCHECK(STRING_STARTS_WITH(format, "xi12")); -+ PrintXi12(instr); -+ return 4; -+ } -+ default: -+ UNREACHABLE(); -+ } -+ return 0; -+} -+ -+// Format takes a formatting string for a whole instruction and prints it into -+// the output buffer. All escaped options are handed to FormatOption to be -+// parsed further. -+void Decoder::Format(Instruction* instr, const char* format) { -+ char cur = *format++; -+ while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { -+ if (cur == '\'') { // Single quote is used as the formatting escape. -+ format += FormatOption(instr, format); -+ } else { -+ out_buffer_[out_buffer_pos_++] = cur; -+ } -+ cur = *format++; -+ } -+ out_buffer_[out_buffer_pos_] = '\0'; -+} -+ -+// For currently unimplemented decodings the disassembler calls Unknown(instr) -+// which will just print "unknown" of the instruction bits. -+void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); } -+ -+int Decoder::DecodeBreakInstr(Instruction* instr) { -+ // This is already known to be BREAK instr, just extract the code. -+ /*if (instr->Bits(14, 0) == static_cast(kMaxStopCode)) { -+ // This is stop(msg). -+ Format(instr, "break, code: 'code"); -+ out_buffer_pos_ += SNPrintF( -+ out_buffer_ + out_buffer_pos_, "\n%p %08" PRIx64, -+ static_cast(reinterpret_cast(instr + kInstrSize)), -+ reinterpret_cast( -+ *reinterpret_cast(instr + kInstrSize))); -+ // Size 3: the break_ instr, plus embedded 64-bit char pointer. -+ return 3 * kInstrSize; -+ } else { -+ Format(instr, "break, code: 'code"); -+ return kInstrSize; -+ }*/ -+ Format(instr, "break code: 'code"); -+ return kInstrSize; -+} //=================================================== -+ -+void Decoder::DecodeTypekOp6(Instruction* instr) { -+ switch (instr->Bits(31, 26) << 26) { -+ case ADDU16I_D: -+ Format(instr, "addu16i.d 'rd, 'rj, 'si16"); -+ break; -+ case BEQZ: -+ Format(instr, "beqz 'rj, 'offs21 -> 'pcoffs21"); -+ break; -+ case BNEZ: -+ Format(instr, "bnez 'rj, 'offs21 -> 'pcoffs21"); -+ break; -+ case BCZ: -+ if (instr->Bit(8)) -+ Format(instr, "bcnez fcc'cj, 'offs21 -> 'pcoffs21"); -+ else -+ Format(instr, "bceqz fcc'cj, 'offs21 -> 'pcoffs21"); -+ break; -+ case JIRL: -+ Format(instr, "jirl 'rd, 'rj, 'offs16"); -+ break; -+ case B: -+ Format(instr, "b 'offs26 -> 'pcoffs26"); -+ break; -+ case BL: -+ Format(instr, "bl 'offs26 -> 'pcoffs26"); -+ break; -+ case BEQ: -+ Format(instr, "beq 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ case BNE: -+ Format(instr, "bne 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ case BLT: -+ Format(instr, "blt 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ case BGE: -+ Format(instr, "bge 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ case BLTU: -+ Format(instr, "bltu 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ case BGEU: -+ Format(instr, "bgeu 'rj, 'rd, 'offs16 -> 'pcoffs16"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Decoder::DecodeTypekOp7(Instruction* instr) { -+ switch (instr->Bits(31, 25) << 25) { -+ case LU12I_W: -+ Format(instr, "lu12i.w 'rd, 'si20"); -+ break; -+ case LU32I_D: -+ Format(instr, "lu32i.d 'rd, 'si20"); -+ break; -+ case PCADDI: -+ Format(instr, "pcaddi 'rd, 'si20"); -+ break; -+ case PCALAU12I: -+ Format(instr, "pcalau12i 'rd, 'si20"); -+ break; -+ case PCADDU12I: -+ Format(instr, "pcaddu12i 'rd, 'si20"); -+ break; -+ case PCADDU18I: -+ Format(instr, "pcaddu18i 'rd, 'si20"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Decoder::DecodeTypekOp8(Instruction* instr) { -+ switch (instr->Bits(31, 24) << 24) { -+ case LDPTR_W: -+ Format(instr, "ldptr.w 'rd, 'rj, 'si14"); -+ break; -+ case STPTR_W: -+ Format(instr, "stptr.w 'rd, 'rj, 'si14"); -+ break; -+ case LDPTR_D: -+ Format(instr, "ldptr.d 'rd, 'rj, 'si14"); -+ break; -+ case STPTR_D: -+ Format(instr, "stptr.d 'rd, 'rj, 'si14"); -+ break; -+ case LL_W: -+ Format(instr, "ll.w 'rd, 'rj, 'si14"); -+ break; -+ case SC_W: -+ Format(instr, "sc.w 'rd, 'rj, 'si14"); -+ break; -+ case LL_D: -+ Format(instr, "ll.d 'rd, 'rj, 'si14"); -+ break; -+ case SC_D: -+ Format(instr, "sc.d 'rd, 'rj, 'si14"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Decoder::DecodeTypekOp10(Instruction* instr) { -+ switch (instr->Bits(31, 22) << 22) { -+ case BSTR_W: { -+ if (instr->Bit(21) != 0) { -+ if (instr->Bit(15) == 0) { -+ Format(instr, "bstrins.w 'rd, 'rj, 'msbw, 'lsbw"); -+ } else { -+ Format(instr, "bstrpick.w 'rd, 'rj, 'msbw, 'lsbw"); -+ } -+ } -+ break; -+ } -+ case BSTRINS_D: -+ Format(instr, "bstrins.d 'rd, 'rj, 'msbd, 'lsbd"); -+ break; -+ case BSTRPICK_D: -+ Format(instr, "bstrpick.d 'rd, 'rj, 'msbd, 'lsbd"); -+ break; -+ case SLTI: -+ Format(instr, "slti 'rd, 'rj, 'si12"); -+ break; -+ case SLTUI: -+ Format(instr, "sltui 'rd, 'rj, 'si12"); -+ break; -+ case ADDI_W: -+ Format(instr, "addi.w 'rd, 'rj, 'si12"); -+ break; -+ case ADDI_D: -+ Format(instr, "addi.d 'rd, 'rj, 'si12"); -+ break; -+ case LU52I_D: -+ Format(instr, "lu52i.d 'rd, 'rj, 'si12"); -+ break; -+ case ANDI: -+ Format(instr, "andi 'rd, 'rj, 'xi12"); -+ break; -+ case ORI: -+ Format(instr, "ori 'rd, 'rj, 'xi12"); -+ break; -+ case XORI: -+ Format(instr, "xori 'rd, 'rj, 'xi12"); -+ break; -+ case LD_B: -+ Format(instr, "ld.b 'rd, 'rj, 'si12"); -+ break; -+ case LD_H: -+ Format(instr, "ld.h 'rd, 'rj, 'si12"); -+ break; -+ case LD_W: -+ Format(instr, "ld.w 'rd, 'rj, 'si12"); -+ break; -+ case LD_D: -+ Format(instr, "ld.d 'rd, 'rj, 'si12"); -+ break; -+ case ST_B: -+ Format(instr, "st.b 'rd, 'rj, 'si12"); -+ break; -+ case ST_H: -+ Format(instr, "st.h 'rd, 'rj, 'si12"); -+ break; -+ case ST_W: -+ Format(instr, "st.w 'rd, 'rj, 'si12"); -+ break; -+ case ST_D: -+ Format(instr, "st.d 'rd, 'rj, 'si12"); -+ break; -+ case LD_BU: -+ Format(instr, "ld.bu 'rd, 'rj, 'si12"); -+ break; -+ case LD_HU: -+ Format(instr, "ld.hu 'rd, 'rj, 'si12"); -+ break; -+ case LD_WU: -+ Format(instr, "ld.wu 'rd, 'rj, 'si12"); -+ break; -+ case FLD_S: -+ Format(instr, "fld.s 'fd, 'rj, 'si12"); -+ break; -+ case FST_S: -+ Format(instr, "fst.s 'fd, 'rj, 'si12"); -+ break; -+ case FLD_D: -+ Format(instr, "fld.d 'fd, 'rj, 'si12"); -+ break; -+ case FST_D: -+ Format(instr, "fst.d 'fd, 'rj, 'si12"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Decoder::DecodeTypekOp12(Instruction* instr) { -+ switch (instr->Bits(31, 20) << 20) { -+ case FMADD_S: -+ Format(instr, "fmadd.s 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FMADD_D: -+ Format(instr, "fmadd.d 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FMSUB_S: -+ Format(instr, "fmsub.s 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FMSUB_D: -+ Format(instr, "fmsub.d 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FNMADD_S: -+ Format(instr, "fnmadd.s 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FNMADD_D: -+ Format(instr, "fnmadd.d 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FNMSUB_S: -+ Format(instr, "fnmsub.s 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FNMSUB_D: -+ Format(instr, "fnmsub.d 'fd, 'fj, 'fk, 'fa"); -+ break; -+ case FCMP_COND_S: -+ switch (instr->Bits(19, 15)) { -+ case CAF: -+ Format(instr, "fcmp.caf.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SAF: -+ Format(instr, "fcmp.saf.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CLT: -+ Format(instr, "fcmp.clt.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CEQ: -+ Format(instr, "fcmp.ceq.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SEQ: -+ Format(instr, "fcmp.seq.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CLE: -+ Format(instr, "fcmp.cle.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SLE: -+ Format(instr, "fcmp.sle.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CUN: -+ Format(instr, "fcmp.cun.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SUN: -+ Format(instr, "fcmp.sun.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CULT: -+ Format(instr, "fcmp.cult.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SULT: -+ Format(instr, "fcmp.sult.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CUEQ: -+ Format(instr, "fcmp.cueq.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SUEQ: -+ Format(instr, "fcmp.sueq.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CULE: -+ Format(instr, "fcmp.cule.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SULE: -+ Format(instr, "fcmp.sule.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CNE: -+ Format(instr, "fcmp.cne.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SNE: -+ Format(instr, "fcmp.sne.s fcc'cd, 'fj, 'fk"); -+ break; -+ case COR: -+ Format(instr, "fcmp.cor.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SOR: -+ Format(instr, "fcmp.sor.s fcc'cd, 'fj, 'fk"); -+ break; -+ case CUNE: -+ Format(instr, "fcmp.cune.s fcc'cd, 'fj, 'fk"); -+ break; -+ case SUNE: -+ Format(instr, "fcmp.sune.s fcc'cd, 'fj, 'fk"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ break; -+ case FCMP_COND_D: -+ switch (instr->Bits(19, 15)) { -+ case CAF: -+ Format(instr, "fcmp.caf.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SAF: -+ Format(instr, "fcmp.saf.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CLT: -+ Format(instr, "fcmp.clt.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CEQ: -+ Format(instr, "fcmp.ceq.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SEQ: -+ Format(instr, "fcmp.seq.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CLE: -+ Format(instr, "fcmp.cle.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SLE: -+ Format(instr, "fcmp.sle.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CUN: -+ Format(instr, "fcmp.cun.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SUN: -+ Format(instr, "fcmp.sun.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CULT: -+ Format(instr, "fcmp.cult.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SULT: -+ Format(instr, "fcmp.sult.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CUEQ: -+ Format(instr, "fcmp.cueq.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SUEQ: -+ Format(instr, "fcmp.sueq.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CULE: -+ Format(instr, "fcmp.cule.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SULE: -+ Format(instr, "fcmp.sule.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CNE: -+ Format(instr, "fcmp.cne.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SNE: -+ Format(instr, "fcmp.sne.d fcc'cd, 'fj, 'fk"); -+ break; -+ case COR: -+ Format(instr, "fcmp.cor.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SOR: -+ Format(instr, "fcmp.sor.d fcc'cd, 'fj, 'fk"); -+ break; -+ case CUNE: -+ Format(instr, "fcmp.cune.d fcc'cd, 'fj, 'fk"); -+ break; -+ case SUNE: -+ Format(instr, "fcmp.sune.d fcc'cd, 'fj, 'fk"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ break; -+ case FSEL: -+ Format(instr, "fsel 'fd, 'fj, 'fk, fcc'ca"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Decoder::DecodeTypekOp14(Instruction* instr) { -+ switch (instr->Bits(31, 18) << 18) { -+ case ALSL: -+ if (instr->Bit(17)) -+ Format(instr, "alsl.wu 'rd, 'rj, 'rk, 'sa2"); -+ else -+ Format(instr, "alsl.w 'rd, 'rj, 'rk, 'sa2"); -+ break; -+ case BYTEPICK_W: -+ Format(instr, "bytepick.w 'rd, 'rj, 'rk, 'sa2"); -+ break; -+ case BYTEPICK_D: -+ Format(instr, "bytepick.d 'rd, 'rj, 'rk, 'sa3"); -+ break; -+ case ALSL_D: -+ Format(instr, "alsl.d 'rd, 'rj, 'rk, 'sa2"); -+ break; -+ case SLLI: -+ if (instr->Bit(16)) -+ Format(instr, "slli.d 'rd, 'rj, 'ui6"); -+ else -+ Format(instr, "slli.w 'rd, 'rj, 'ui5"); -+ break; -+ case SRLI: -+ if (instr->Bit(16)) -+ Format(instr, "srli.d 'rd, 'rj, 'ui6"); -+ else -+ Format(instr, "srli.w 'rd, 'rj, 'ui5"); -+ break; -+ case SRAI: -+ if (instr->Bit(16)) -+ Format(instr, "srai.d 'rd, 'rj, 'ui6"); -+ else -+ Format(instr, "srai.w 'rd, 'rj, 'ui5"); -+ break; -+ case ROTRI: -+ if (instr->Bit(16)) -+ Format(instr, "rotri.d 'rd, 'rj, 'ui6"); -+ else -+ Format(instr, "rotri.w 'rd, 'rj, 'ui5"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+int Decoder::DecodeTypekOp17(Instruction* instr) { -+ switch (instr->Bits(31, 15) << 15) { -+ case ADD_W: -+ Format(instr, "add.w 'rd, 'rj, 'rk"); -+ break; -+ case ADD_D: -+ Format(instr, "add.d 'rd, 'rj, 'rk"); -+ break; -+ case SUB_W: -+ Format(instr, "sub.w 'rd, 'rj, 'rk"); -+ break; -+ case SUB_D: -+ Format(instr, "sub.d 'rd, 'rj, 'rk"); -+ break; -+ case SLT: -+ Format(instr, "slt 'rd, 'rj, 'rk"); -+ break; -+ case SLTU: -+ Format(instr, "sltu 'rd, 'rj, 'rk"); -+ break; -+ case MASKEQZ: -+ Format(instr, "maskeqz 'rd, 'rj, 'rk"); -+ break; -+ case MASKNEZ: -+ Format(instr, "masknez 'rd, 'rj, 'rk"); -+ break; -+ case NOR: -+ Format(instr, "nor 'rd, 'rj, 'rk"); -+ break; -+ case AND: -+ Format(instr, "and 'rd, 'rj, 'rk"); -+ break; -+ case OR: -+ Format(instr, "or 'rd, 'rj, 'rk"); -+ break; -+ case XOR: -+ Format(instr, "xor 'rd, 'rj, 'rk"); -+ break; -+ case ORN: -+ Format(instr, "orn 'rd, 'rj, 'rk"); -+ break; -+ case ANDN: -+ Format(instr, "andn 'rd, 'rj, 'rk"); -+ break; -+ case SLL_W: -+ Format(instr, "sll.w 'rd, 'rj, 'rk"); -+ break; -+ case SRL_W: -+ Format(instr, "srl.w 'rd, 'rj, 'rk"); -+ break; -+ case SRA_W: -+ Format(instr, "sra.w 'rd, 'rj, 'rk"); -+ break; -+ case SLL_D: -+ Format(instr, "sll.d 'rd, 'rj, 'rk"); -+ break; -+ case SRL_D: -+ Format(instr, "srl.d 'rd, 'rj, 'rk"); -+ break; -+ case SRA_D: -+ Format(instr, "sra.d 'rd, 'rj, 'rk"); -+ break; -+ case ROTR_D: -+ Format(instr, "rotr.d 'rd, 'rj, 'rk"); -+ break; -+ case ROTR_W: -+ Format(instr, "rotr.w 'rd, 'rj, 'rk"); -+ break; -+ case MUL_W: -+ Format(instr, "mul.w 'rd, 'rj, 'rk"); -+ break; -+ case MULH_W: -+ Format(instr, "mulh.w 'rd, 'rj, 'rk"); -+ break; -+ case MULH_WU: -+ Format(instr, "mulh.wu 'rd, 'rj, 'rk"); -+ break; -+ case MUL_D: -+ Format(instr, "mul.d 'rd, 'rj, 'rk"); -+ break; -+ case MULH_D: -+ Format(instr, "mulh.d 'rd, 'rj, 'rk"); -+ break; -+ case MULH_DU: -+ Format(instr, "mulh.du 'rd, 'rj, 'rk"); -+ break; -+ case MULW_D_W: -+ Format(instr, "mulw.d.w 'rd, 'rj, 'rk"); -+ break; -+ case MULW_D_WU: -+ Format(instr, "mulw.d.wu 'rd, 'rj, 'rk"); -+ break; -+ case DIV_W: -+ Format(instr, "div.w 'rd, 'rj, 'rk"); -+ break; -+ case MOD_W: -+ Format(instr, "mod.w 'rd, 'rj, 'rk"); -+ break; -+ case DIV_WU: -+ Format(instr, "div.wu 'rd, 'rj, 'rk"); -+ break; -+ case MOD_WU: -+ Format(instr, "mod.wu 'rd, 'rj, 'rk"); -+ break; -+ case DIV_D: -+ Format(instr, "div.d 'rd, 'rj, 'rk"); -+ break; -+ case MOD_D: -+ Format(instr, "mod.d 'rd, 'rj, 'rk"); -+ break; -+ case DIV_DU: -+ Format(instr, "div.du 'rd, 'rj, 'rk"); -+ break; -+ case MOD_DU: -+ Format(instr, "mod.du 'rd, 'rj, 'rk"); -+ break; -+ case BREAK: -+ return DecodeBreakInstr(instr); -+ case FADD_S: -+ Format(instr, "fadd.s 'fd, 'fj, 'fk"); -+ break; -+ case FADD_D: -+ Format(instr, "fadd.d 'fd, 'fj, 'fk"); -+ break; -+ case FSUB_S: -+ Format(instr, "fsub.s 'fd, 'fj, 'fk"); -+ break; -+ case FSUB_D: -+ Format(instr, "fsub.d 'fd, 'fj, 'fk"); -+ break; -+ case FMUL_S: -+ Format(instr, "fmul.s 'fd, 'fj, 'fk"); -+ break; -+ case FMUL_D: -+ Format(instr, "fmul.d 'fd, 'fj, 'fk"); -+ break; -+ case FDIV_S: -+ Format(instr, "fdiv.s 'fd, 'fj, 'fk"); -+ break; -+ case FDIV_D: -+ Format(instr, "fdiv.d 'fd, 'fj, 'fk"); -+ break; -+ case FMAX_S: -+ Format(instr, "fmax.s 'fd, 'fj, 'fk"); -+ break; -+ case FMAX_D: -+ Format(instr, "fmax.d 'fd, 'fj, 'fk"); -+ break; -+ case FMIN_S: -+ Format(instr, "fmin.s 'fd, 'fj, 'fk"); -+ break; -+ case FMIN_D: -+ Format(instr, "fmin.d 'fd, 'fj, 'fk"); -+ break; -+ case FMAXA_S: -+ Format(instr, "fmaxa.s 'fd, 'fj, 'fk"); -+ break; -+ case FMAXA_D: -+ Format(instr, "fmaxa.d 'fd, 'fj, 'fk"); -+ break; -+ case FMINA_S: -+ Format(instr, "fmina.s 'fd, 'fj, 'fk"); -+ break; -+ case FMINA_D: -+ Format(instr, "fmina.d 'fd, 'fj, 'fk"); -+ break; -+ case LDX_B: -+ Format(instr, "ldx.b 'rd, 'rj, 'rk"); -+ break; -+ case LDX_H: -+ Format(instr, "ldx.h 'rd, 'rj, 'rk"); -+ break; -+ case LDX_W: -+ Format(instr, "ldx.w 'rd, 'rj, 'rk"); -+ break; -+ case LDX_D: -+ Format(instr, "ldx.d 'rd, 'rj, 'rk"); -+ break; -+ case STX_B: -+ Format(instr, "stx.b 'rd, 'rj, 'rk"); -+ break; -+ case STX_H: -+ Format(instr, "stx.h 'rd, 'rj, 'rk"); -+ break; -+ case STX_W: -+ Format(instr, "stx.w 'rd, 'rj, 'rk"); -+ break; -+ case STX_D: -+ Format(instr, "stx.d 'rd, 'rj, 'rk"); -+ break; -+ case LDX_BU: -+ Format(instr, "ldx.bu 'rd, 'rj, 'rk"); -+ break; -+ case LDX_HU: -+ Format(instr, "ldx.hu 'rd, 'rj, 'rk"); -+ break; -+ case LDX_WU: -+ Format(instr, "ldx.wu 'rd, 'rj, 'rk"); -+ break; -+ case FLDX_S: -+ Format(instr, "fldx.s 'fd, 'rj, 'rk"); -+ break; -+ case FLDX_D: -+ Format(instr, "fldx.d 'fd, 'rj, 'rk"); -+ break; -+ case FSTX_S: -+ Format(instr, "fstx.s 'fd, 'rj, 'rk"); -+ break; -+ case FSTX_D: -+ Format(instr, "fstx.d 'fd, 'rj, 'rk"); -+ break; -+ case AMSWAP_W: -+ Format(instr, "amswap.w 'rd, 'rk, 'rj"); -+ break; -+ case AMSWAP_D: -+ Format(instr, "amswap.d 'rd, 'rk, 'rj"); -+ break; -+ case AMADD_W: -+ Format(instr, "amadd.w 'rd, 'rk, 'rj"); -+ break; -+ case AMADD_D: -+ Format(instr, "amadd.d 'rd, 'rk, 'rj"); -+ break; -+ case AMAND_W: -+ Format(instr, "amand.w 'rd, 'rk, 'rj"); -+ break; -+ case AMAND_D: -+ Format(instr, "amand.d 'rd, 'rk, 'rj"); -+ break; -+ case AMOR_W: -+ Format(instr, "amor.w 'rd, 'rk, 'rj"); -+ break; -+ case AMOR_D: -+ Format(instr, "amor.d 'rd, 'rk, 'rj"); -+ break; -+ case AMXOR_W: -+ Format(instr, "amxor.w 'rd, 'rk, 'rj"); -+ break; -+ case AMXOR_D: -+ Format(instr, "amxor.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_W: -+ Format(instr, "ammax.w 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_D: -+ Format(instr, "ammax.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_W: -+ Format(instr, "ammin.w 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_D: -+ Format(instr, "ammin.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_WU: -+ Format(instr, "ammax.wu 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_DU: -+ Format(instr, "ammax.du 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_WU: -+ Format(instr, "ammin.wu 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_DU: -+ Format(instr, "ammin.du 'rd, 'rk, 'rj"); -+ break; -+ case AMSWAP_DB_W: -+ Format(instr, "amswap_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMSWAP_DB_D: -+ Format(instr, "amswap_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMADD_DB_W: -+ Format(instr, "amadd_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMADD_DB_D: -+ Format(instr, "amadd_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMAND_DB_W: -+ Format(instr, "amand_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMAND_DB_D: -+ Format(instr, "amand_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMOR_DB_W: -+ Format(instr, "amor_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMOR_DB_D: -+ Format(instr, "amor_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMXOR_DB_W: -+ Format(instr, "amxor_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMXOR_DB_D: -+ Format(instr, "amxor_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_DB_W: -+ Format(instr, "ammax_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_DB_D: -+ Format(instr, "ammax_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_DB_W: -+ Format(instr, "ammin_db.w 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_DB_D: -+ Format(instr, "ammin_db.d 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_DB_WU: -+ Format(instr, "ammax_db.wu 'rd, 'rk, 'rj"); -+ break; -+ case AMMAX_DB_DU: -+ Format(instr, "ammax_db.du 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_DB_WU: -+ Format(instr, "ammin_db.wu 'rd, 'rk, 'rj"); -+ break; -+ case AMMIN_DB_DU: -+ Format(instr, "ammin_db.du 'rd, 'rk, 'rj"); -+ break; -+ case DBAR: -+ Format(instr, "dbar 'hint15"); -+ break; -+ case IBAR: -+ Format(instr, "ibar 'hint15"); -+ break; -+ case FSCALEB_S: -+ Format(instr, "fscaleb.s 'fd, 'fj, 'fk"); -+ break; -+ case FSCALEB_D: -+ Format(instr, "fscaleb.d 'fd, 'fj, 'fk"); -+ break; -+ case FCOPYSIGN_S: -+ Format(instr, "fcopysign.s 'fd, 'fj, 'fk"); -+ break; -+ case FCOPYSIGN_D: -+ Format(instr, "fcopysign.d 'fd, 'fj, 'fk"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ return kInstrSize; -+} -+ -+void Decoder::DecodeTypekOp22(Instruction* instr) { -+ switch (instr->Bits(31, 10) << 10) { -+ case CLZ_W: -+ Format(instr, "clz.w 'rd, 'rj"); -+ break; -+ case CTZ_W: -+ Format(instr, "ctz.w 'rd, 'rj"); -+ break; -+ case CLZ_D: -+ Format(instr, "clz.d 'rd, 'rj"); -+ break; -+ case CTZ_D: -+ Format(instr, "ctz.d 'rd, 'rj"); -+ break; -+ case REVB_2H: -+ Format(instr, "revb.2h 'rd, 'rj"); -+ break; -+ case REVB_4H: -+ Format(instr, "revb.4h 'rd, 'rj"); -+ break; -+ case REVB_2W: -+ Format(instr, "revb.2w 'rd, 'rj"); -+ break; -+ case REVB_D: -+ Format(instr, "revb.d 'rd, 'rj"); -+ break; -+ case REVH_2W: -+ Format(instr, "revh.2w 'rd, 'rj"); -+ break; -+ case REVH_D: -+ Format(instr, "revh.d 'rd, 'rj"); -+ break; -+ case BITREV_4B: -+ Format(instr, "bitrev.4b 'rd, 'rj"); -+ break; -+ case BITREV_8B: -+ Format(instr, "bitrev.8b 'rd, 'rj"); -+ break; -+ case BITREV_W: -+ Format(instr, "bitrev.w 'rd, 'rj"); -+ break; -+ case BITREV_D: -+ Format(instr, "bitrev.d 'rd, 'rj"); -+ break; -+ case EXT_W_B: -+ Format(instr, "ext.w.b 'rd, 'rj"); -+ break; -+ case EXT_W_H: -+ Format(instr, "ext.w.h 'rd, 'rj"); -+ break; -+ case FABS_S: -+ Format(instr, "fabs.s 'fd, 'fj"); -+ break; -+ case FABS_D: -+ Format(instr, "fabs.d 'fd, 'fj"); -+ break; -+ case FNEG_S: -+ Format(instr, "fneg.s 'fd, 'fj"); -+ break; -+ case FNEG_D: -+ Format(instr, "fneg.d 'fd, 'fj"); -+ break; -+ case FSQRT_S: -+ Format(instr, "fsqrt.s 'fd, 'fj"); -+ break; -+ case FSQRT_D: -+ Format(instr, "fsqrt.d 'fd, 'fj"); -+ break; -+ case FMOV_S: -+ Format(instr, "fmov.s 'fd, 'fj"); -+ break; -+ case FMOV_D: -+ Format(instr, "fmov.d 'fd, 'fj"); -+ break; -+ case MOVGR2FR_W: -+ Format(instr, "movgr2fr.w 'fd, 'rj"); -+ break; -+ case MOVGR2FR_D: -+ Format(instr, "movgr2fr.d 'fd, 'rj"); -+ break; -+ case MOVGR2FRH_W: -+ Format(instr, "movgr2frh.w 'fd, 'rj"); -+ break; -+ case MOVFR2GR_S: -+ Format(instr, "movfr2gr.s 'rd, 'fj"); -+ break; -+ case MOVFR2GR_D: -+ Format(instr, "movfr2gr.d 'rd, 'fj"); -+ break; -+ case MOVFRH2GR_S: -+ Format(instr, "movfrh2gr.s 'rd, 'fj"); -+ break; -+ case MOVGR2FCSR: -+ Format(instr, "movgr2fcsr fcsr, 'rj"); -+ break; -+ case MOVFCSR2GR: -+ Format(instr, "movfcsr2gr 'rd, fcsr"); -+ break; -+ case FCVT_S_D: -+ Format(instr, "fcvt.s.d 'fd, 'fj"); -+ break; -+ case FCVT_D_S: -+ Format(instr, "fcvt.d.s 'fd, 'fj"); -+ break; -+ case FTINTRM_W_S: -+ Format(instr, "ftintrm.w.s 'fd, 'fj"); -+ break; -+ case FTINTRM_W_D: -+ Format(instr, "ftintrm.w.d 'fd, 'fj"); -+ break; -+ case FTINTRM_L_S: -+ Format(instr, "ftintrm.l.s 'fd, 'fj"); -+ break; -+ case FTINTRM_L_D: -+ Format(instr, "ftintrm.l.d 'fd, 'fj"); -+ break; -+ case FTINTRP_W_S: -+ Format(instr, "ftintrp.w.s 'fd, 'fj"); -+ break; -+ case FTINTRP_W_D: -+ Format(instr, "ftintrp.w.d 'fd, 'fj"); -+ break; -+ case FTINTRP_L_S: -+ Format(instr, "ftintrp.l.s 'fd, 'fj"); -+ break; -+ case FTINTRP_L_D: -+ Format(instr, "ftintrp.l.d 'fd, 'fj"); -+ break; -+ case FTINTRZ_W_S: -+ Format(instr, "ftintrz.w.s 'fd, 'fj"); -+ break; -+ case FTINTRZ_W_D: -+ Format(instr, "ftintrz.w.d 'fd, 'fj"); -+ break; -+ case FTINTRZ_L_S: -+ Format(instr, "ftintrz.l.s 'fd, 'fj"); -+ break; -+ case FTINTRZ_L_D: -+ Format(instr, "ftintrz.l.d 'fd, 'fj"); -+ break; -+ case FTINTRNE_W_S: -+ Format(instr, "ftintrne.w.s 'fd, 'fj"); -+ break; -+ case FTINTRNE_W_D: -+ Format(instr, "ftintrne.w.d 'fd, 'fj"); -+ break; -+ case FTINTRNE_L_S: -+ Format(instr, "ftintrne.l.s 'fd, 'fj"); -+ break; -+ case FTINTRNE_L_D: -+ Format(instr, "ftintrne.l.d 'fd, 'fj"); -+ break; -+ case FTINT_W_S: -+ Format(instr, "ftint.w.s 'fd, 'fj"); -+ break; -+ case FTINT_W_D: -+ Format(instr, "ftint.w.d 'fd, 'fj"); -+ break; -+ case FTINT_L_S: -+ Format(instr, "ftint.l.s 'fd, 'fj"); -+ break; -+ case FTINT_L_D: -+ Format(instr, "ftint.l.d 'fd, 'fj"); -+ break; -+ case FFINT_S_W: -+ Format(instr, "ffint.s.w 'fd, 'fj"); -+ break; -+ case FFINT_S_L: -+ Format(instr, "ffint.s.l 'fd, 'fj"); -+ break; -+ case FFINT_D_W: -+ Format(instr, "ffint.d.w 'fd, 'fj"); -+ break; -+ case FFINT_D_L: -+ Format(instr, "ffint.d.l 'fd, 'fj"); -+ break; -+ case FRINT_S: -+ Format(instr, "frint.s 'fd, 'fj"); -+ break; -+ case FRINT_D: -+ Format(instr, "frint.d 'fd, 'fj"); -+ break; -+ case MOVFR2CF: -+ Format(instr, "movfr2cf fcc'cd, 'fj"); -+ break; -+ case MOVCF2FR: -+ Format(instr, "movcf2fr 'fd, fcc'cj"); -+ break; -+ case MOVGR2CF: -+ Format(instr, "movgr2cf fcc'cd, 'rj"); -+ break; -+ case MOVCF2GR: -+ Format(instr, "movcf2gr 'rd, fcc'cj"); -+ break; -+ case FRECIP_S: -+ Format(instr, "frecip.s 'fd, 'fj"); -+ break; -+ case FRECIP_D: -+ Format(instr, "frecip.d 'fd, 'fj"); -+ break; -+ case FRSQRT_S: -+ Format(instr, "frsqrt.s 'fd, 'fj"); -+ break; -+ case FRSQRT_D: -+ Format(instr, "frsqrt.d 'fd, 'fj"); -+ break; -+ case FCLASS_S: -+ Format(instr, "fclass.s 'fd, 'fj"); -+ break; -+ case FCLASS_D: -+ Format(instr, "fclass.d 'fd, 'fj"); -+ break; -+ case FLOGB_S: -+ Format(instr, "flogb.s 'fd, 'fj"); -+ break; -+ case FLOGB_D: -+ Format(instr, "flogb.d 'fd, 'fj"); -+ break; -+ case CLO_W: -+ Format(instr, "clo.w 'rd, 'rj"); -+ break; -+ case CTO_W: -+ Format(instr, "cto.w 'rd, 'rj"); -+ break; -+ case CLO_D: -+ Format(instr, "clo.d 'rd, 'rj"); -+ break; -+ case CTO_D: -+ Format(instr, "cto.d 'rd, 'rj"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+int Decoder::InstructionDecode(byte* instr_ptr) { -+ Instruction* instr = Instruction::At(instr_ptr); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", -+ instr->InstructionBits()); -+ switch (instr->InstructionType()) { -+ case Instruction::kOp6Type: { -+ DecodeTypekOp6(instr); -+ break; -+ } -+ case Instruction::kOp7Type: { -+ DecodeTypekOp7(instr); -+ break; -+ } -+ case Instruction::kOp8Type: { -+ DecodeTypekOp8(instr); -+ break; -+ } -+ case Instruction::kOp10Type: { -+ DecodeTypekOp10(instr); -+ break; -+ } -+ case Instruction::kOp12Type: { -+ DecodeTypekOp12(instr); -+ break; -+ } -+ case Instruction::kOp14Type: { -+ DecodeTypekOp14(instr); -+ break; -+ } -+ case Instruction::kOp17Type: { -+ return DecodeTypekOp17(instr); -+ } -+ case Instruction::kOp22Type: { -+ DecodeTypekOp22(instr); -+ break; -+ } -+ case Instruction::kUnsupported: { -+ Format(instr, "UNSUPPORTED"); -+ break; -+ } -+ default: { -+ Format(instr, "UNSUPPORTED"); -+ break; -+ } -+ } -+ return kInstrSize; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+//------------------------------------------------------------------------------ -+ -+namespace disasm { -+ -+const char* NameConverter::NameOfAddress(byte* addr) const { -+ v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast(addr)); -+ return tmp_buffer_.begin(); -+} -+ -+const char* NameConverter::NameOfConstant(byte* addr) const { -+ return NameOfAddress(addr); -+} -+ -+const char* NameConverter::NameOfCPURegister(int reg) const { -+ return v8::internal::Registers::Name(reg); -+} -+ -+const char* NameConverter::NameOfXMMRegister(int reg) const { -+ return v8::internal::FPURegisters::Name(reg); -+} -+ -+const char* NameConverter::NameOfByteCPURegister(int reg) const { -+ UNREACHABLE(); -+ return "nobytereg"; -+} -+ -+const char* NameConverter::NameInCode(byte* addr) const { -+ // The default name converter is called for unknown code. So we will not try -+ // to access any memory. -+ return ""; -+} -+ -+//------------------------------------------------------------------------------ -+ -+int Disassembler::InstructionDecode(v8::internal::Vector buffer, -+ byte* instruction) { -+ v8::internal::Decoder d(converter_, buffer); -+ return d.InstructionDecode(instruction); -+} -+ -+int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; } -+ -+void Disassembler::Disassemble(FILE* f, byte* begin, byte* end, -+ UnimplementedOpcodeAction unimplemented_action) { -+ NameConverter converter; -+ Disassembler d(converter, unimplemented_action); -+ for (byte* pc = begin; pc < end;) { -+ v8::internal::EmbeddedVector buffer; -+ buffer[0] = '\0'; -+ byte* prev_pc = pc; -+ pc += d.InstructionDecode(buffer, pc); -+ v8::internal::PrintF(f, "%p %08x %s\n", static_cast(prev_pc), -+ *reinterpret_cast(prev_pc), buffer.begin()); -+ } -+} -+ -+#undef STRING_STARTS_WITH -+ -+} // namespace disasm -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h b/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h -index dbe78ddf2..bfa3f144b 100644 ---- a/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h -+++ b/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h -@@ -83,6 +83,7 @@ class PerfJitLogger : public CodeEventLogger { - static const uint32_t kElfMachARM = 40; - static const uint32_t kElfMachMIPS = 8; - static const uint32_t kElfMachMIPS64 = 8; -+ static const uint32_t kElfMachLA64 = 258; - static const uint32_t kElfMachARM64 = 183; - static const uint32_t kElfMachS390x = 22; - static const uint32_t kElfMachPPC64 = 21; -@@ -98,6 +99,8 @@ class PerfJitLogger : public CodeEventLogger { - return kElfMachMIPS; - #elif V8_TARGET_ARCH_MIPS64 - return kElfMachMIPS64; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ return kElfMachLA64; - #elif V8_TARGET_ARCH_ARM64 - return kElfMachARM64; - #elif V8_TARGET_ARCH_S390X -diff --git a/src/3rdparty/chromium/v8/src/execution/frame-constants.h b/src/3rdparty/chromium/v8/src/execution/frame-constants.h -index 6c037451a..514d13a8a 100644 ---- a/src/3rdparty/chromium/v8/src/execution/frame-constants.h -+++ b/src/3rdparty/chromium/v8/src/execution/frame-constants.h -@@ -354,6 +354,8 @@ inline static int FrameSlotToFPOffset(int slot) { - #include "src/execution/mips/frame-constants-mips.h" // NOLINT - #elif V8_TARGET_ARCH_MIPS64 - #include "src/execution/mips64/frame-constants-mips64.h" // NOLINT -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/execution/loongarch64/frame-constants-loongarch64.h" // NOLINT - #elif V8_TARGET_ARCH_S390 - #include "src/execution/s390/frame-constants-s390.h" // NOLINT - #else -diff --git a/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.cc b/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.cc -new file mode 100644 -index 000000000..e1ccd99a1 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.cc -@@ -0,0 +1,32 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/execution/loongarch64/frame-constants-loongarch64.h" -+ -+#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" -+#include "src/execution/frame-constants.h" -+#include "src/execution/frames.h" -+ -+namespace v8 { -+namespace internal { -+ -+Register JavaScriptFrame::fp_register() { return v8::internal::fp; } -+Register JavaScriptFrame::context_register() { return cp; } -+Register JavaScriptFrame::constant_pool_pointer_register() { UNREACHABLE(); } -+ -+int InterpreterFrameConstants::RegisterStackSlotCount(int register_count) { -+ return register_count; -+} -+ -+int BuiltinContinuationFrameConstants::PaddingSlotCount(int register_count) { -+ USE(register_count); -+ return 0; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LOONGARCH64 -diff --git a/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.h b/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.h -new file mode 100644 -index 000000000..dd028aaf4 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.h -@@ -0,0 +1,77 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ -+#define V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ -+ -+#include "src/base/bits.h" -+#include "src/base/macros.h" -+#include "src/execution/frame-constants.h" -+ -+namespace v8 { -+namespace internal { -+ -+class EntryFrameConstants : public AllStatic { -+ public: -+ // This is the offset to where JSEntry pushes the current value of -+ // Isolate::c_entry_fp onto the stack. -+ static constexpr int kCallerFPOffset = -3 * kSystemPointerSize; -+}; -+ -+class WasmCompileLazyFrameConstants : public TypedFrameConstants { -+ public: -+ static constexpr int kNumberOfSavedGpParamRegs = 7; -+ static constexpr int kNumberOfSavedFpParamRegs = 7; -+ static constexpr int kNumberOfSavedAllParamRegs = 14; -+ -+ // FP-relative. -+ // See Generate_WasmCompileLazy in builtins-mips64.cc. -+ static constexpr int kWasmInstanceOffset = -+ TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs); -+ static constexpr int kFixedFrameSizeFromFp = -+ TypedFrameConstants::kFixedFrameSizeFromFp + -+ kNumberOfSavedGpParamRegs * kPointerSize + -+ kNumberOfSavedFpParamRegs * kDoubleSize; -+}; -+ -+// Frame constructed by the {WasmDebugBreak} builtin. -+// After pushing the frame type marker, the builtin pushes all Liftoff cache -+// registers (see liftoff-assembler-defs.h). -+class WasmDebugBreakFrameConstants : public TypedFrameConstants { -+ public: -+ // {a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, t3, t4, t5, t6, t7, t8} -+ static constexpr uint32_t kPushedGpRegs = 0b111111111111111110000; -+ // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26} -+ static constexpr uint32_t kPushedFpRegs = 0b101010101010101010101010101; -+ -+ static constexpr int kNumPushedGpRegisters = -+ base::bits::CountPopulation(kPushedGpRegs); -+ static constexpr int kNumPushedFpRegisters = -+ base::bits::CountPopulation(kPushedFpRegs); -+ -+ static constexpr int kLastPushedGpRegisterOffset = -+ -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; -+ static constexpr int kLastPushedFpRegisterOffset = -+ kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize; -+ -+ // Offsets are fp-relative. -+ static int GetPushedGpRegisterOffset(int reg_code) { -+ DCHECK_NE(0, kPushedGpRegs & (1 << reg_code)); -+ uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1); -+ return kLastPushedGpRegisterOffset + -+ base::bits::CountPopulation(lower_regs) * kSystemPointerSize; -+ } -+ -+ static int GetPushedFpRegisterOffset(int reg_code) { -+ DCHECK_NE(0, kPushedFpRegs & (1 << reg_code)); -+ uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1); -+ return kLastPushedFpRegisterOffset + -+ base::bits::CountPopulation(lower_regs) * kDoubleSize; -+ } -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.cc b/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.cc -new file mode 100644 -index 000000000..49907cfda ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.cc -@@ -0,0 +1,5564 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Only build the simulator if not compiling for real LA64 hardware. -+#if defined(USE_SIMULATOR) -+ -+#include "src/execution/loongarch64/simulator-loongarch64.h" -+ -+#include -+#include -+#include -+ -+#include -+ -+#include "src/base/bits.h" -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/la64/constants-la64.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/diagnostics/disasm.h" -+#include "src/heap/combined-heap.h" -+#include "src/runtime/runtime-utils.h" -+#include "src/utils/ostreams.h" -+#include "src/utils/vector.h" -+ -+namespace v8 { -+namespace internal { -+ -+DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor, -+ Simulator::GlobalMonitor::Get) -+ -+// #define PRINT_SIM_LOG -+ -+// Util functions. -+inline bool HaveSameSign(int64_t a, int64_t b) { return ((a ^ b) >= 0); } -+ -+uint32_t get_fcsr_condition_bit(uint32_t cc) { -+ if (cc == 0) { -+ return 23; -+ } else { -+ return 24 + cc; -+ } -+} -+ -+static int64_t MultiplyHighSigned(int64_t u, int64_t v) { -+ uint64_t u0, v0, w0; -+ int64_t u1, v1, w1, w2, t; -+ -+ u0 = u & 0xFFFFFFFFL; -+ u1 = u >> 32; -+ v0 = v & 0xFFFFFFFFL; -+ v1 = v >> 32; -+ -+ w0 = u0 * v0; -+ t = u1 * v0 + (w0 >> 32); -+ w1 = t & 0xFFFFFFFFL; -+ w2 = t >> 32; -+ w1 = u0 * v1 + w1; -+ -+ return u1 * v1 + w2 + (w1 >> 32); -+} -+ -+static uint64_t MultiplyHighUnsigned(uint64_t u, uint64_t v) { -+ uint64_t u0, v0, w0; -+ uint64_t u1, v1, w1, w2, t; -+ -+ u0 = u & 0xFFFFFFFFL; -+ u1 = u >> 32; -+ v0 = v & 0xFFFFFFFFL; -+ v1 = v >> 32; -+ -+ w0 = u0 * v0; -+ t = u1 * v0 + (w0 >> 32); -+ w1 = t & 0xFFFFFFFFL; -+ w2 = t >> 32; -+ w1 = u0 * v1 + w1; -+ -+ return u1 * v1 + w2 + (w1 >> 32); -+} -+ -+#ifdef PRINT_SIM_LOG -+inline void printf_instr(const char* _Format, ...) { -+ va_list varList; -+ va_start(varList, _Format); -+ vprintf(_Format, varList); -+ va_end(varList); -+} -+#else -+#define printf_instr(...) -+#endif -+ -+// This macro provides a platform independent use of sscanf. The reason for -+// SScanF not being implemented in a platform independent was through -+// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time -+// Library does not provide vsscanf. -+#define SScanF sscanf // NOLINT -+ -+// The La64Debugger class is used by the simulator while debugging simulated -+// code. -+class La64Debugger { -+ public: -+ explicit La64Debugger(Simulator* sim) : sim_(sim) {} -+ -+ void Stop(Instruction* instr); -+ void Debug(); -+ // Print all registers with a nice formatting. -+ void PrintAllRegs(); -+ void PrintAllRegsIncludingFPU(); -+ -+ private: -+ // We set the breakpoint code to 0xFFFF to easily recognize it. -+ static const Instr kBreakpointInstr = BREAK | 0xFFFF; -+ static const Instr kNopInstr = 0x0; -+ -+ Simulator* sim_; -+ -+ int64_t GetRegisterValue(int regnum); -+ int64_t GetFPURegisterValue(int regnum); -+ float GetFPURegisterValueFloat(int regnum); -+ double GetFPURegisterValueDouble(int regnum); -+ bool GetValue(const char* desc, int64_t* value); -+ -+ // Set or delete a breakpoint. Returns true if successful. -+ bool SetBreakpoint(Instruction* breakpc); -+ bool DeleteBreakpoint(Instruction* breakpc); -+ -+ // Undo and redo all breakpoints. This is needed to bracket disassembly and -+ // execution to skip past breakpoints when run from the debugger. -+ void UndoBreakpoints(); -+ void RedoBreakpoints(); -+}; -+ -+inline void UNSUPPORTED() { printf("Sim: Unsupported instruction.\n"); } -+ -+void La64Debugger::Stop(Instruction* instr) { -+ // Get the stop code. -+ uint32_t code = instr->Bits(25, 6); -+ PrintF("Simulator hit (%u)\n", code); -+ Debug(); -+} -+ -+int64_t La64Debugger::GetRegisterValue(int regnum) { -+ if (regnum == kNumSimuRegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_register(regnum); -+ } -+} -+ -+int64_t La64Debugger::GetFPURegisterValue(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register(regnum); -+ } -+} -+ -+float La64Debugger::GetFPURegisterValueFloat(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register_float(regnum); -+ } -+} -+ -+double La64Debugger::GetFPURegisterValueDouble(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register_double(regnum); -+ } -+} -+ -+bool La64Debugger::GetValue(const char* desc, int64_t* value) { -+ int regnum = Registers::Number(desc); -+ int fpuregnum = FPURegisters::Number(desc); -+ -+ if (regnum != kInvalidRegister) { -+ *value = GetRegisterValue(regnum); -+ return true; -+ } else if (fpuregnum != kInvalidFPURegister) { -+ *value = GetFPURegisterValue(fpuregnum); -+ return true; -+ } else if (strncmp(desc, "0x", 2) == 0) { -+ return SScanF(desc + 2, "%" SCNx64, reinterpret_cast(value)) == -+ 1; -+ } else { -+ return SScanF(desc, "%" SCNu64, reinterpret_cast(value)) == 1; -+ } -+ return false; -+} -+ -+bool La64Debugger::SetBreakpoint(Instruction* breakpc) { -+ // Check if a breakpoint can be set. If not return without any side-effects. -+ if (sim_->break_pc_ != nullptr) { -+ return false; -+ } -+ -+ // Set the breakpoint. -+ sim_->break_pc_ = breakpc; -+ sim_->break_instr_ = breakpc->InstructionBits(); -+ // Not setting the breakpoint instruction in the code itself. It will be set -+ // when the debugger shell continues. -+ return true; -+} -+ -+bool La64Debugger::DeleteBreakpoint(Instruction* breakpc) { -+ if (sim_->break_pc_ != nullptr) { -+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_); -+ } -+ -+ sim_->break_pc_ = nullptr; -+ sim_->break_instr_ = 0; -+ return true; -+} -+ -+void La64Debugger::UndoBreakpoints() { -+ if (sim_->break_pc_ != nullptr) { -+ sim_->break_pc_->SetInstructionBits(sim_->break_instr_); -+ } -+} -+ -+void La64Debugger::RedoBreakpoints() { -+ if (sim_->break_pc_ != nullptr) { -+ sim_->break_pc_->SetInstructionBits(kBreakpointInstr); -+ } -+} -+ -+void La64Debugger::PrintAllRegs() { -+#define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n) -+ -+ PrintF("\n"); -+ // at, v0, a0. -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 -+ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", -+ REG_INFO(1), REG_INFO(2), REG_INFO(4)); -+ // v1, a1. -+ PrintF("%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \n", -+ "", REG_INFO(3), REG_INFO(5)); -+ // a2. -+ PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "", -+ REG_INFO(6)); -+ // a3. -+ PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "", -+ REG_INFO(7)); -+ PrintF("\n"); -+ // a4-t3, s0-s7 -+ for (int i = 0; i < 8; i++) { -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \n", -+ REG_INFO(8 + i), REG_INFO(16 + i)); -+ } -+ PrintF("\n"); -+ // t8, k0, LO. -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", -+ REG_INFO(24), REG_INFO(26), REG_INFO(32)); -+ // t9, k1, HI. -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", -+ REG_INFO(25), REG_INFO(27), REG_INFO(33)); -+ // sp, fp, gp. -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", -+ REG_INFO(29), REG_INFO(30), REG_INFO(28)); -+ // pc. -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \n", -+ REG_INFO(31), REG_INFO(34)); -+ -+#undef REG_INFO -+} -+ -+void La64Debugger::PrintAllRegsIncludingFPU() { -+#define FPU_REG_INFO(n) \ -+ FPURegisters::Name(n), GetFPURegisterValue(n), GetFPURegisterValueDouble(n) -+ -+ PrintAllRegs(); -+ -+ PrintF("\n\n"); -+ // f0, f1, f2, ... f31. -+ // TODO(plind): consider printing 2 columns for space efficiency. -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(0)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(1)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(2)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(3)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(4)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(5)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(6)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(7)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(8)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(9)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(10)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(11)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(12)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(13)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(14)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(15)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(16)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(17)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(18)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(19)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(20)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(21)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(22)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(23)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(24)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(25)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(26)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(27)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(28)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(29)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(30)); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(31)); -+ -+#undef FPU_REG_INFO -+} -+ -+void La64Debugger::Debug() { -+ intptr_t last_pc = -1; -+ bool done = false; -+ -+#define COMMAND_SIZE 63 -+#define ARG_SIZE 255 -+ -+#define STR(a) #a -+#define XSTR(a) STR(a) -+ -+ char cmd[COMMAND_SIZE + 1]; -+ char arg1[ARG_SIZE + 1]; -+ char arg2[ARG_SIZE + 1]; -+ char* argv[3] = {cmd, arg1, arg2}; -+ -+ // Make sure to have a proper terminating character if reaching the limit. -+ cmd[COMMAND_SIZE] = 0; -+ arg1[ARG_SIZE] = 0; -+ arg2[ARG_SIZE] = 0; -+ -+ // Undo all set breakpoints while running in the debugger shell. This will -+ // make them invisible to all commands. -+ UndoBreakpoints(); -+ -+ while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) { -+ if (last_pc != sim_->get_pc()) { -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ dasm.InstructionDecode(buffer, reinterpret_cast(sim_->get_pc())); -+ PrintF(" 0x%016" PRIx64 " %s\n", sim_->get_pc(), buffer.begin()); -+ last_pc = sim_->get_pc(); -+ } -+ char* line = ReadLine("sim> "); -+ if (line == nullptr) { -+ break; -+ } else { -+ char* last_input = sim_->last_debugger_input(); -+ if (strcmp(line, "\n") == 0 && last_input != nullptr) { -+ line = last_input; -+ } else { -+ // Ownership is transferred to sim_; -+ sim_->set_last_debugger_input(line); -+ } -+ // Use sscanf to parse the individual parts of the command line. At the -+ // moment no command expects more than two parameters. -+ int argc = SScanF(line, -+ "%" XSTR(COMMAND_SIZE) "s " -+ "%" XSTR(ARG_SIZE) "s " -+ "%" XSTR(ARG_SIZE) "s", -+ cmd, arg1, arg2); -+ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { -+ Instruction* instr = reinterpret_cast(sim_->get_pc()); -+ if (!(instr->IsTrap()) || -+ instr->InstructionBits() == rtCallRedirInstr) { -+ sim_->InstructionDecode( -+ reinterpret_cast(sim_->get_pc())); -+ } else { -+ // Allow si to jump over generated breakpoints. -+ PrintF("/!\\ Jumping over generated breakpoint.\n"); -+ sim_->set_pc(sim_->get_pc() + kInstrSize); -+ } -+ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { -+ // Execute the one instruction we broke at with breakpoints disabled. -+ sim_->InstructionDecode(reinterpret_cast(sim_->get_pc())); -+ // Leave the debugger shell. -+ done = true; -+ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { -+ if (argc == 2) { -+ int64_t value; -+ double dvalue; -+ if (strcmp(arg1, "all") == 0) { -+ PrintAllRegs(); -+ } else if (strcmp(arg1, "allf") == 0) { -+ PrintAllRegsIncludingFPU(); -+ } else { -+ int regnum = Registers::Number(arg1); -+ int fpuregnum = FPURegisters::Number(arg1); -+ -+ if (regnum != kInvalidRegister) { -+ value = GetRegisterValue(regnum); -+ PrintF("%s: 0x%08" PRIx64 " %" PRId64 " \n", arg1, value, -+ value); -+ } else if (fpuregnum != kInvalidFPURegister) { -+ value = GetFPURegisterValue(fpuregnum); -+ dvalue = GetFPURegisterValueDouble(fpuregnum); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", -+ FPURegisters::Name(fpuregnum), value, dvalue); -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } -+ } else { -+ if (argc == 3) { -+ if (strcmp(arg2, "single") == 0) { -+ int64_t value; -+ float fvalue; -+ int fpuregnum = FPURegisters::Number(arg1); -+ -+ if (fpuregnum != kInvalidFPURegister) { -+ value = GetFPURegisterValue(fpuregnum); -+ value &= 0xFFFFFFFFUL; -+ fvalue = GetFPURegisterValueFloat(fpuregnum); -+ PrintF("%s: 0x%08" PRIx64 " %11.4e\n", arg1, value, fvalue); -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } else { -+ PrintF("print single\n"); -+ } -+ } else { -+ PrintF("print or print single\n"); -+ } -+ } -+ } else if ((strcmp(cmd, "po") == 0) || -+ (strcmp(cmd, "printobject") == 0)) { -+ if (argc == 2) { -+ int64_t value; -+ StdoutStream os; -+ if (GetValue(arg1, &value)) { -+ Object obj(value); -+ os << arg1 << ": \n"; -+#ifdef DEBUG -+ obj.Print(os); -+ os << "\n"; -+#else -+ os << Brief(obj) << "\n"; -+#endif -+ } else { -+ os << arg1 << " unrecognized\n"; -+ } -+ } else { -+ PrintF("printobject \n"); -+ } -+ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 || -+ strcmp(cmd, "dump") == 0) { -+ int64_t* cur = nullptr; -+ int64_t* end = nullptr; -+ int next_arg = 1; -+ -+ if (strcmp(cmd, "stack") == 0) { -+ cur = reinterpret_cast(sim_->get_register(Simulator::sp)); -+ } else { // Command "mem". -+ int64_t value; -+ if (!GetValue(arg1, &value)) { -+ PrintF("%s unrecognized\n", arg1); -+ continue; -+ } -+ cur = reinterpret_cast(value); -+ next_arg++; -+ } -+ -+ int64_t words; -+ if (argc == next_arg) { -+ words = 10; -+ } else { -+ if (!GetValue(argv[next_arg], &words)) { -+ words = 10; -+ } -+ } -+ end = cur + words; -+ -+ bool skip_obj_print = (strcmp(cmd, "dump") == 0); -+ while (cur < end) { -+ PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ", -+ reinterpret_cast(cur), *cur, *cur); -+ Object obj(*cur); -+ Heap* current_heap = sim_->isolate_->heap(); -+ if (!skip_obj_print) { -+ if (obj.IsSmi() || -+ IsValidHeapObject(current_heap, HeapObject::cast(obj))) { -+ PrintF(" ("); -+ if (obj.IsSmi()) { -+ PrintF("smi %d", Smi::ToInt(obj)); -+ } else { -+ obj.ShortPrint(); -+ } -+ PrintF(")"); -+ } -+ } -+ PrintF("\n"); -+ cur++; -+ } -+ -+ } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0) || -+ (strcmp(cmd, "di") == 0)) { -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ -+ byte* cur = nullptr; -+ byte* end = nullptr; -+ -+ if (argc == 1) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ end = cur + (10 * kInstrSize); -+ } else if (argc == 2) { -+ int regnum = Registers::Number(arg1); -+ if (regnum != kInvalidRegister || strncmp(arg1, "0x", 2) == 0) { -+ // The argument is an address or a register name. -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(value); -+ // Disassemble 10 instructions at . -+ end = cur + (10 * kInstrSize); -+ } -+ } else { -+ // The argument is the number of instructions. -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ // Disassemble instructions. -+ end = cur + (value * kInstrSize); -+ } -+ } -+ } else { -+ int64_t value1; -+ int64_t value2; -+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { -+ cur = reinterpret_cast(value1); -+ end = cur + (value2 * kInstrSize); -+ } -+ } -+ -+ while (cur < end) { -+ dasm.InstructionDecode(buffer, cur); -+ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), -+ buffer.begin()); -+ cur += kInstrSize; -+ } -+ } else if (strcmp(cmd, "gdb") == 0) { -+ PrintF("relinquishing control to gdb\n"); -+ v8::base::OS::DebugBreak(); -+ PrintF("regaining control from gdb\n"); -+ } else if (strcmp(cmd, "break") == 0) { -+ if (argc == 2) { -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ if (!SetBreakpoint(reinterpret_cast(value))) { -+ PrintF("setting breakpoint failed\n"); -+ } -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } else { -+ PrintF("break
\n"); -+ } -+ } else if (strcmp(cmd, "del") == 0) { -+ if (!DeleteBreakpoint(nullptr)) { -+ PrintF("deleting breakpoint failed\n"); -+ } -+ } else if (strcmp(cmd, "flags") == 0) { -+ PrintF("No flags on LA64 !\n"); -+ } else if (strcmp(cmd, "stop") == 0) { -+ int64_t value; -+ intptr_t stop_pc = sim_->get_pc() - 2 * kInstrSize; -+ Instruction* stop_instr = reinterpret_cast(stop_pc); -+ Instruction* msg_address = -+ reinterpret_cast(stop_pc + kInstrSize); -+ if ((argc == 2) && (strcmp(arg1, "unstop") == 0)) { -+ // Remove the current stop. -+ if (sim_->IsStopInstruction(stop_instr)) { -+ stop_instr->SetInstructionBits(kNopInstr); -+ msg_address->SetInstructionBits(kNopInstr); -+ } else { -+ PrintF("Not at debugger stop.\n"); -+ } -+ } else if (argc == 3) { -+ // Print information about all/the specified breakpoint(s). -+ if (strcmp(arg1, "info") == 0) { -+ if (strcmp(arg2, "all") == 0) { -+ PrintF("Stop information:\n"); -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->PrintStopInfo(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->PrintStopInfo(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } else if (strcmp(arg1, "enable") == 0) { -+ // Enable all/the specified breakpoint(s). -+ if (strcmp(arg2, "all") == 0) { -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->EnableStop(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->EnableStop(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } else if (strcmp(arg1, "disable") == 0) { -+ // Disable all/the specified breakpoint(s). -+ if (strcmp(arg2, "all") == 0) { -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->DisableStop(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->DisableStop(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } -+ } else { -+ PrintF("Wrong usage. Use help command for more information.\n"); -+ } -+ } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) { -+ // Print registers and disassemble. -+ PrintAllRegs(); -+ PrintF("\n"); -+ -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ -+ byte* cur = nullptr; -+ byte* end = nullptr; -+ -+ if (argc == 1) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ end = cur + (10 * kInstrSize); -+ } else if (argc == 2) { -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(value); -+ // no length parameter passed, assume 10 instructions -+ end = cur + (10 * kInstrSize); -+ } -+ } else { -+ int64_t value1; -+ int64_t value2; -+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { -+ cur = reinterpret_cast(value1); -+ end = cur + (value2 * kInstrSize); -+ } -+ } -+ -+ while (cur < end) { -+ dasm.InstructionDecode(buffer, cur); -+ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), -+ buffer.begin()); -+ cur += kInstrSize; -+ } -+ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { -+ PrintF("cont\n"); -+ PrintF(" continue execution (alias 'c')\n"); -+ PrintF("stepi\n"); -+ PrintF(" step one instruction (alias 'si')\n"); -+ PrintF("print \n"); -+ PrintF(" print register content (alias 'p')\n"); -+ PrintF(" use register name 'all' to print all registers\n"); -+ PrintF("printobject \n"); -+ PrintF(" print an object from a register (alias 'po')\n"); -+ PrintF("stack []\n"); -+ PrintF(" dump stack content, default dump 10 words)\n"); -+ PrintF("mem
[]\n"); -+ PrintF(" dump memory content, default dump 10 words)\n"); -+ PrintF("dump []\n"); -+ PrintF( -+ " dump memory content without pretty printing JS objects, default " -+ "dump 10 words)\n"); -+ PrintF("flags\n"); -+ PrintF(" print flags\n"); -+ PrintF("disasm []\n"); -+ PrintF("disasm [
]\n"); -+ PrintF("disasm [[
] ]\n"); -+ PrintF(" disassemble code, default is 10 instructions\n"); -+ PrintF(" from pc (alias 'di')\n"); -+ PrintF("gdb\n"); -+ PrintF(" enter gdb\n"); -+ PrintF("break
\n"); -+ PrintF(" set a break point on the address\n"); -+ PrintF("del\n"); -+ PrintF(" delete the breakpoint\n"); -+ PrintF("stop feature:\n"); -+ PrintF(" Description:\n"); -+ PrintF(" Stops are debug instructions inserted by\n"); -+ PrintF(" the Assembler::stop() function.\n"); -+ PrintF(" When hitting a stop, the Simulator will\n"); -+ PrintF(" stop and give control to the Debugger.\n"); -+ PrintF(" All stop codes are watched:\n"); -+ PrintF(" - They can be enabled / disabled: the Simulator\n"); -+ PrintF(" will / won't stop when hitting them.\n"); -+ PrintF(" - The Simulator keeps track of how many times they \n"); -+ PrintF(" are met. (See the info command.) Going over a\n"); -+ PrintF(" disabled stop still increases its counter. \n"); -+ PrintF(" Commands:\n"); -+ PrintF(" stop info all/ : print infos about number \n"); -+ PrintF(" or all stop(s).\n"); -+ PrintF(" stop enable/disable all/ : enables / disables\n"); -+ PrintF(" all or number stop(s)\n"); -+ PrintF(" stop unstop\n"); -+ PrintF(" ignore the stop instruction at the current location\n"); -+ PrintF(" from now on\n"); -+ } else { -+ PrintF("Unknown command: %s\n", cmd); -+ } -+ } -+ } -+ -+ // Add all the breakpoints back to stop execution and enter the debugger -+ // shell when hit. -+ RedoBreakpoints(); -+ -+#undef COMMAND_SIZE -+#undef ARG_SIZE -+ -+#undef STR -+#undef XSTR -+} -+ -+bool Simulator::ICacheMatch(void* one, void* two) { -+ DCHECK_EQ(reinterpret_cast(one) & CachePage::kPageMask, 0); -+ DCHECK_EQ(reinterpret_cast(two) & CachePage::kPageMask, 0); -+ return one == two; -+} -+ -+static uint32_t ICacheHash(void* key) { -+ return static_cast(reinterpret_cast(key)) >> 2; -+} -+ -+static bool AllOnOnePage(uintptr_t start, size_t size) { -+ intptr_t start_page = (start & ~CachePage::kPageMask); -+ intptr_t end_page = ((start + size) & ~CachePage::kPageMask); -+ return start_page == end_page; -+} -+ -+void Simulator::set_last_debugger_input(char* input) { -+ DeleteArray(last_debugger_input_); -+ last_debugger_input_ = input; -+} -+ -+void Simulator::SetRedirectInstruction(Instruction* instruction) { -+ instruction->SetInstructionBits(rtCallRedirInstr); -+} -+ -+void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, -+ void* start_addr, size_t size) { -+ int64_t start = reinterpret_cast(start_addr); -+ int64_t intra_line = (start & CachePage::kLineMask); -+ start -= intra_line; -+ size += intra_line; -+ size = ((size - 1) | CachePage::kLineMask) + 1; -+ int offset = (start & CachePage::kPageMask); -+ while (!AllOnOnePage(start, size - 1)) { -+ int bytes_to_flush = CachePage::kPageSize - offset; -+ FlushOnePage(i_cache, start, bytes_to_flush); -+ start += bytes_to_flush; -+ size -= bytes_to_flush; -+ DCHECK_EQ((int64_t)0, start & CachePage::kPageMask); -+ offset = 0; -+ } -+ if (size != 0) { -+ FlushOnePage(i_cache, start, size); -+ } -+} -+ -+CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, -+ void* page) { -+ base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); -+ if (entry->value == nullptr) { -+ CachePage* new_page = new CachePage(); -+ entry->value = new_page; -+ } -+ return reinterpret_cast(entry->value); -+} -+ -+// Flush from start up to and not including start + size. -+void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, -+ intptr_t start, size_t size) { -+ DCHECK_LE(size, CachePage::kPageSize); -+ DCHECK(AllOnOnePage(start, size - 1)); -+ DCHECK_EQ(start & CachePage::kLineMask, 0); -+ DCHECK_EQ(size & CachePage::kLineMask, 0); -+ void* page = reinterpret_cast(start & (~CachePage::kPageMask)); -+ int offset = (start & CachePage::kPageMask); -+ CachePage* cache_page = GetCachePage(i_cache, page); -+ char* valid_bytemap = cache_page->ValidityByte(offset); -+ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); -+} -+ -+void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, -+ Instruction* instr) { -+ int64_t address = reinterpret_cast(instr); -+ void* page = reinterpret_cast(address & (~CachePage::kPageMask)); -+ void* line = reinterpret_cast(address & (~CachePage::kLineMask)); -+ int offset = (address & CachePage::kPageMask); -+ CachePage* cache_page = GetCachePage(i_cache, page); -+ char* cache_valid_byte = cache_page->ValidityByte(offset); -+ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); -+ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); -+ if (cache_hit) { -+ // Check that the data in memory matches the contents of the I-cache. -+ CHECK_EQ(0, memcmp(reinterpret_cast(instr), -+ cache_page->CachedData(offset), kInstrSize)); -+ } else { -+ // Cache miss. Load memory into the cache. -+ memcpy(cached_line, line, CachePage::kLineLength); -+ *cache_valid_byte = CachePage::LINE_VALID; -+ } -+} -+ -+Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { -+ // Set up simulator support first. Some of this information is needed to -+ // setup the architecture state. -+ stack_size_ = FLAG_sim_stack_size * KB; -+ stack_ = reinterpret_cast(malloc(stack_size_)); -+ pc_modified_ = false; -+ icount_ = 0; -+ break_count_ = 0; -+ break_pc_ = nullptr; -+ break_instr_ = 0; -+ -+ // Set up architecture state. -+ // All registers are initialized to zero to start with. -+ for (int i = 0; i < kNumSimuRegisters; i++) { -+ registers_[i] = 0; -+ } -+ for (int i = 0; i < kNumFPURegisters; i++) { -+ FPUregisters_[i] = 0; -+ } -+ for (int i = 0; i < kNumCFRegisters; i++) { -+ CFregisters_[i] = 0; -+ } -+ -+ FCSR_ = 0; -+ -+ // The sp is initialized to point to the bottom (high address) of the -+ // allocated stack area. To be safe in potential stack underflows we leave -+ // some buffer below. -+ registers_[sp] = reinterpret_cast(stack_) + stack_size_ - 64; -+ // The ra and pc are initialized to a known bad value that will cause an -+ // access violation if the simulator ever tries to execute it. -+ registers_[pc] = bad_ra; -+ registers_[ra] = bad_ra; -+ -+ last_debugger_input_ = nullptr; -+} -+ -+Simulator::~Simulator() { -+ GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_); -+ free(stack_); -+} -+ -+// Get the active Simulator for the current thread. -+Simulator* Simulator::current(Isolate* isolate) { -+ v8::internal::Isolate::PerIsolateThreadData* isolate_data = -+ isolate->FindOrAllocatePerThreadDataForThisThread(); -+ DCHECK_NOT_NULL(isolate_data); -+ -+ Simulator* sim = isolate_data->simulator(); -+ if (sim == nullptr) { -+ // TODO(146): delete the simulator object when a thread/isolate goes away. -+ sim = new Simulator(isolate); -+ isolate_data->set_simulator(sim); -+ } -+ return sim; -+} -+ -+// Sets the register in the architecture state. It will also deal with updating -+// Simulator internal state for special registers such as PC. -+void Simulator::set_register(int reg, int64_t value) { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ if (reg == pc) { -+ pc_modified_ = true; -+ } -+ -+ // Zero register always holds 0. -+ registers_[reg] = (reg == 0) ? 0 : value; -+} -+ -+void Simulator::set_dw_register(int reg, const int* dbl) { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ registers_[reg] = dbl[1]; -+ registers_[reg] = registers_[reg] << 32; -+ registers_[reg] += dbl[0]; -+} -+ -+void Simulator::set_fpu_register(int fpureg, int64_t value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ FPUregisters_[fpureg] = value; -+} -+ -+void Simulator::set_fpu_register_word(int fpureg, int32_t value) { -+ // Set ONLY lower 32-bits, leaving upper bits untouched. -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ int32_t* pword; -+ pword = reinterpret_cast(&FPUregisters_[fpureg]); -+ -+ *pword = value; -+} -+ -+void Simulator::set_fpu_register_hi_word(int fpureg, int32_t value) { -+ // Set ONLY upper 32-bits, leaving lower bits untouched. -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ int32_t* phiword; -+ phiword = (reinterpret_cast(&FPUregisters_[fpureg])) + 1; -+ -+ *phiword = value; -+} -+ -+void Simulator::set_fpu_register_float(int fpureg, float value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ *bit_cast(&FPUregisters_[fpureg]) = value; -+} -+ -+void Simulator::set_fpu_register_double(int fpureg, double value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ *bit_cast(&FPUregisters_[fpureg]) = value; -+} -+ -+void Simulator::set_cf_register(int cfreg, bool value) { -+ DCHECK((cfreg >= 0) && (cfreg < kNumCFRegisters)); -+ CFregisters_[cfreg] = value; -+} -+ -+// Get the register from the architecture state. This function does handle -+// the special case of accessing the PC register. -+int64_t Simulator::get_register(int reg) const { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ if (reg == 0) -+ return 0; -+ else -+ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); -+} -+ -+double Simulator::get_double_from_register_pair(int reg) { -+ // TODO(plind): bad ABI stuff, refactor or remove. -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ -+ double dm_val = 0.0; -+ // Read the bits from the unsigned integer register_[] array -+ // into the double precision floating point value and return it. -+ char buffer[sizeof(registers_[0])]; -+ memcpy(buffer, ®isters_[reg], sizeof(registers_[0])); -+ memcpy(&dm_val, buffer, sizeof(registers_[0])); -+ return (dm_val); -+} -+ -+int64_t Simulator::get_fpu_register(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return FPUregisters_[fpureg]; -+} -+ -+int32_t Simulator::get_fpu_register_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); -+} -+ -+int32_t Simulator::get_fpu_register_signed_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); -+} -+ -+int32_t Simulator::get_fpu_register_hi_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast((FPUregisters_[fpureg] >> 32) & 0xFFFFFFFF); -+} -+ -+float Simulator::get_fpu_register_float(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return *bit_cast(const_cast(&FPUregisters_[fpureg])); -+} -+ -+double Simulator::get_fpu_register_double(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return *bit_cast(&FPUregisters_[fpureg]); -+} -+ -+bool Simulator::get_cf_register(int cfreg) const { -+ DCHECK((cfreg >= 0) && (cfreg < kNumCFRegisters)); -+ return CFregisters_[cfreg]; -+} -+ -+// Runtime FP routines take up to two double arguments and zero -+// or one integer arguments. All are constructed here, -+// from a0-a3 or fa0 and fa1 (n64). -+void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { -+ const int fparg2 = f1; -+ *x = get_fpu_register_double(f0); -+ *y = get_fpu_register_double(fparg2); -+ *z = static_cast(get_register(a2)); -+} -+ -+// The return value is either in v0/v1 or f0. -+void Simulator::SetFpResult(const double& result) { -+ set_fpu_register_double(0, result); -+} -+ -+// Helper functions for setting and testing the FCSR register's bits. -+void Simulator::set_fcsr_bit(uint32_t cc, bool value) { -+ if (value) { -+ FCSR_ |= (1 << cc); -+ } else { -+ FCSR_ &= ~(1 << cc); -+ } -+} -+ -+bool Simulator::test_fcsr_bit(uint32_t cc) { return FCSR_ & (1 << cc); } -+ -+void Simulator::set_fcsr_rounding_mode(FPURoundingMode mode) { -+ FCSR_ |= mode & kFPURoundingModeMask; -+} -+ -+unsigned int Simulator::get_fcsr_rounding_mode() { -+ return FCSR_ & kFPURoundingModeMask; -+} -+ -+// Sets the rounding error codes in FCSR based on the result of the rounding. -+// Returns true if the operation was invalid. -+bool Simulator::set_fcsr_round_error(double original, double rounded) { -+ bool ret = false; -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ -+ if (!std::isfinite(original) || !std::isfinite(rounded)) { -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ if (original != rounded) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ -+ if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) { -+ set_fcsr_bit(kFCSRUnderflowFlagBit, true); -+ ret = true; -+ } -+ -+ if (rounded > max_int32 || rounded < min_int32) { -+ set_fcsr_bit(kFCSROverflowFlagBit, true); -+ // The reference is not really clear but it seems this is required: -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ return ret; -+} -+ -+// Sets the rounding error codes in FCSR based on the result of the rounding. -+// Returns true if the operation was invalid. -+bool Simulator::set_fcsr_round64_error(double original, double rounded) { -+ bool ret = false; -+ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, -+ // loading the most accurate representation into max_int64, which is 2^63. -+ double max_int64 = std::numeric_limits::max(); -+ double min_int64 = std::numeric_limits::min(); -+ -+ if (!std::isfinite(original) || !std::isfinite(rounded)) { -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ if (original != rounded) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ -+ if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) { -+ set_fcsr_bit(kFCSRUnderflowFlagBit, true); -+ ret = true; -+ } -+ -+ if (rounded >= max_int64 || rounded < min_int64) { -+ set_fcsr_bit(kFCSROverflowFlagBit, true); -+ // The reference is not really clear but it seems this is required: -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ return ret; -+} -+ -+// Sets the rounding error codes in FCSR based on the result of the rounding. -+// Returns true if the operation was invalid. -+bool Simulator::set_fcsr_round_error(float original, float rounded) { -+ bool ret = false; -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ -+ if (!std::isfinite(original) || !std::isfinite(rounded)) { -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ if (original != rounded) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ -+ if (rounded < FLT_MIN && rounded > -FLT_MIN && rounded != 0) { -+ set_fcsr_bit(kFCSRUnderflowFlagBit, true); -+ ret = true; -+ } -+ -+ if (rounded > max_int32 || rounded < min_int32) { -+ set_fcsr_bit(kFCSROverflowFlagBit, true); -+ // The reference is not really clear but it seems this is required: -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ return ret; -+} -+ -+void Simulator::set_fpu_register_word_invalid_result(float original, -+ float rounded) { -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register_word(fd_reg(), 0); -+ } else if (rounded > max_int32) { -+ set_fpu_register_word(fd_reg(), kFPUInvalidResult); -+ } else if (rounded < min_int32) { -+ set_fpu_register_word(fd_reg(), kFPUInvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::set_fpu_register_invalid_result(float original, float rounded) { -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register(fd_reg(), 0); -+ } else if (rounded > max_int32) { -+ set_fpu_register(fd_reg(), kFPUInvalidResult); -+ } else if (rounded < min_int32) { -+ set_fpu_register(fd_reg(), kFPUInvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::set_fpu_register_invalid_result64(float original, -+ float rounded) { -+ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, -+ // loading the most accurate representation into max_int64, which is 2^63. -+ double max_int64 = std::numeric_limits::max(); -+ double min_int64 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register(fd_reg(), 0); -+ } else if (rounded >= max_int64) { -+ set_fpu_register(fd_reg(), kFPU64InvalidResult); -+ } else if (rounded < min_int64) { -+ set_fpu_register(fd_reg(), kFPU64InvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::set_fpu_register_word_invalid_result(double original, -+ double rounded) { -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register_word(fd_reg(), 0); -+ } else if (rounded > max_int32) { -+ set_fpu_register_word(fd_reg(), kFPUInvalidResult); -+ } else if (rounded < min_int32) { -+ set_fpu_register_word(fd_reg(), kFPUInvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::set_fpu_register_invalid_result(double original, -+ double rounded) { -+ double max_int32 = std::numeric_limits::max(); -+ double min_int32 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register(fd_reg(), 0); -+ } else if (rounded > max_int32) { -+ set_fpu_register(fd_reg(), kFPUInvalidResult); -+ } else if (rounded < min_int32) { -+ set_fpu_register(fd_reg(), kFPUInvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::set_fpu_register_invalid_result64(double original, -+ double rounded) { -+ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, -+ // loading the most accurate representation into max_int64, which is 2^63. -+ double max_int64 = std::numeric_limits::max(); -+ double min_int64 = std::numeric_limits::min(); -+ if (std::isnan(original)) { -+ set_fpu_register(fd_reg(), 0); -+ } else if (rounded >= max_int64) { -+ set_fpu_register(fd_reg(), kFPU64InvalidResult); -+ } else if (rounded < min_int64) { -+ set_fpu_register(fd_reg(), kFPU64InvalidResultNegative); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+// Sets the rounding error codes in FCSR based on the result of the rounding. -+// Returns true if the operation was invalid. -+bool Simulator::set_fcsr_round64_error(float original, float rounded) { -+ bool ret = false; -+ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, -+ // loading the most accurate representation into max_int64, which is 2^63. -+ double max_int64 = std::numeric_limits::max(); -+ double min_int64 = std::numeric_limits::min(); -+ -+ if (!std::isfinite(original) || !std::isfinite(rounded)) { -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ if (original != rounded) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ -+ if (rounded < FLT_MIN && rounded > -FLT_MIN && rounded != 0) { -+ set_fcsr_bit(kFCSRUnderflowFlagBit, true); -+ ret = true; -+ } -+ -+ if (rounded >= max_int64 || rounded < min_int64) { -+ set_fcsr_bit(kFCSROverflowFlagBit, true); -+ // The reference is not really clear but it seems this is required: -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ ret = true; -+ } -+ -+ return ret; -+} -+ -+// For ftint instructions only -+void Simulator::round_according_to_fcsr(double toRound, double* rounded, -+ int32_t* rounded_int) { -+ // 0 RN (round to nearest): Round a result to the nearest -+ // representable value; if the result is exactly halfway between -+ // two representable values, round to zero. -+ -+ // 1 RZ (round toward zero): Round a result to the closest -+ // representable value whose absolute value is less than or -+ // equal to the infinitely accurate result. -+ -+ // 2 RP (round up, or toward +infinity): Round a result to the -+ // next representable value up. -+ -+ // 3 RN (round down, or toward −infinity): Round a result to -+ // the next representable value down. -+ // switch ((FCSR_ >> 8) & 3) { -+ switch (FCSR_ & kFPURoundingModeMask) { -+ case kRoundToNearest: -+ *rounded = std::floor(toRound + 0.5); -+ *rounded_int = static_cast(*rounded); -+ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ *rounded_int -= 1; -+ *rounded -= 1.; -+ } -+ break; -+ case kRoundToZero: -+ *rounded = trunc(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToPlusInf: -+ *rounded = std::ceil(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToMinusInf: -+ *rounded = std::floor(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ } -+} -+ -+void Simulator::round64_according_to_fcsr(double toRound, double* rounded, -+ int64_t* rounded_int) { -+ // 0 RN (round to nearest): Round a result to the nearest -+ // representable value; if the result is exactly halfway between -+ // two representable values, round to zero. -+ -+ // 1 RZ (round toward zero): Round a result to the closest -+ // representable value whose absolute value is less than or. -+ // equal to the infinitely accurate result. -+ -+ // 2 RP (round up, or toward +infinity): Round a result to the -+ // next representable value up. -+ -+ // 3 RN (round down, or toward −infinity): Round a result to -+ // the next representable value down. -+ switch (FCSR_ & kFPURoundingModeMask) { -+ case kRoundToNearest: -+ *rounded = std::floor(toRound + 0.5); -+ *rounded_int = static_cast(*rounded); -+ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ *rounded_int -= 1; -+ *rounded -= 1.; -+ } -+ break; -+ case kRoundToZero: -+ *rounded = std::trunc(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToPlusInf: -+ *rounded = std::ceil(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToMinusInf: -+ *rounded = std::floor(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ } -+} -+ -+void Simulator::round_according_to_fcsr(float toRound, float* rounded, -+ int32_t* rounded_int) { -+ // 0 RN (round to nearest): Round a result to the nearest -+ // representable value; if the result is exactly halfway between -+ // two representable values, round to zero. -+ -+ // 1 RZ (round toward zero): Round a result to the closest -+ // representable value whose absolute value is less than or -+ // equal to the infinitely accurate result. -+ -+ // 2 RP (round up, or toward +infinity): Round a result to the -+ // next representable value up. -+ -+ // 3 RN (round down, or toward −infinity): Round a result to -+ // the next representable value down. -+ switch (FCSR_ & kFPURoundingModeMask) { -+ case kRoundToNearest: -+ *rounded = std::floor(toRound + 0.5); -+ *rounded_int = static_cast(*rounded); -+ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ *rounded_int -= 1; -+ *rounded -= 1.f; -+ } -+ break; -+ case kRoundToZero: -+ *rounded = std::trunc(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToPlusInf: -+ *rounded = std::ceil(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToMinusInf: -+ *rounded = std::floor(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ } -+} -+ -+void Simulator::round64_according_to_fcsr(float toRound, float* rounded, -+ int64_t* rounded_int) { -+ // 0 RN (round to nearest): Round a result to the nearest -+ // representable value; if the result is exactly halfway between -+ // two representable values, round to zero. -+ -+ // 1 RZ (round toward zero): Round a result to the closest -+ // representable value whose absolute value is less than or. -+ // equal to the infinitely accurate result. -+ -+ // 2 RP (round up, or toward +infinity): Round a result to the -+ // next representable value up. -+ -+ // 3 RN (round down, or toward −infinity): Round a result to -+ // the next representable value down. -+ switch (FCSR_ & kFPURoundingModeMask) { -+ case kRoundToNearest: -+ *rounded = std::floor(toRound + 0.5); -+ *rounded_int = static_cast(*rounded); -+ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ *rounded_int -= 1; -+ *rounded -= 1.f; -+ } -+ break; -+ case kRoundToZero: -+ *rounded = trunc(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToPlusInf: -+ *rounded = std::ceil(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ case kRoundToMinusInf: -+ *rounded = std::floor(toRound); -+ *rounded_int = static_cast(*rounded); -+ break; -+ } -+} -+ -+// Raw access to the PC register. -+void Simulator::set_pc(int64_t value) { -+ pc_modified_ = true; -+ registers_[pc] = value; -+} -+ -+bool Simulator::has_bad_pc() const { -+ return ((registers_[pc] == bad_ra) || (registers_[pc] == end_sim_pc)); -+} -+ -+// Raw access to the PC register without the special adjustment when reading. -+int64_t Simulator::get_pc() const { return registers_[pc]; } -+ -+// TODO(plind): refactor this messy debug code when we do unaligned access. -+void Simulator::DieOrDebug() { -+ if ((1)) { // Flag for this was removed. -+ La64Debugger dbg(this); -+ dbg.Debug(); -+ } else { -+ base::OS::Abort(); -+ } -+} -+ -+void Simulator::TraceRegWr(int64_t value, TraceType t) { -+ if (::v8::internal::FLAG_trace_sim) { -+ union { -+ int64_t fmt_int64; -+ int32_t fmt_int32[2]; -+ float fmt_float[2]; -+ double fmt_double; -+ } v; -+ v.fmt_int64 = value; -+ -+ switch (t) { -+ case WORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 -+ " uint32:%" PRIu32, -+ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0]); -+ break; -+ case DWORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 -+ " uint64:%" PRIu64, -+ value, icount_, value, value); -+ break; -+ case FLOAT: -+ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e", -+ v.fmt_int64, icount_, v.fmt_float[0]); -+ break; -+ case DOUBLE: -+ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") dbl:%e", -+ v.fmt_int64, icount_, v.fmt_double); -+ break; -+ case FLOAT_DOUBLE: -+ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e dbl:%e", -+ v.fmt_int64, icount_, v.fmt_float[0], v.fmt_double); -+ break; -+ case WORD_DWORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 -+ " uint32:%" PRIu32 " int64:%" PRId64 " uint64:%" PRIu64, -+ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0], -+ v.fmt_int64, v.fmt_int64); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+// TODO(plind): consider making icount_ printing a flag option. -+void Simulator::TraceMemRd(int64_t addr, int64_t value, TraceType t) { -+ if (::v8::internal::FLAG_trace_sim) { -+ union { -+ int64_t fmt_int64; -+ int32_t fmt_int32[2]; -+ float fmt_float[2]; -+ double fmt_double; -+ } v; -+ v.fmt_int64 = value; -+ -+ switch (t) { -+ case WORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 -+ ") int32:%" PRId32 " uint32:%" PRIu32, -+ v.fmt_int64, addr, icount_, v.fmt_int32[0], v.fmt_int32[0]); -+ break; -+ case DWORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 -+ ") int64:%" PRId64 " uint64:%" PRIu64, -+ value, addr, icount_, value, value); -+ break; -+ case FLOAT: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 -+ ") flt:%e", -+ v.fmt_int64, addr, icount_, v.fmt_float[0]); -+ break; -+ case DOUBLE: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 -+ ") dbl:%e", -+ v.fmt_int64, addr, icount_, v.fmt_double); -+ break; -+ case FLOAT_DOUBLE: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 -+ ") flt:%e dbl:%e", -+ v.fmt_int64, addr, icount_, v.fmt_float[0], v.fmt_double); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+void Simulator::TraceMemWr(int64_t addr, int64_t value, TraceType t) { -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (t) { -+ case BYTE: -+ SNPrintF(trace_buf_, -+ " %02" PRIx8 " --> [%016" PRIx64 "] (%" PRId64 -+ ")", -+ static_cast(value), addr, icount_); -+ break; -+ case HALF: -+ SNPrintF(trace_buf_, -+ " %04" PRIx16 " --> [%016" PRIx64 "] (%" PRId64 -+ ")", -+ static_cast(value), addr, icount_); -+ break; -+ case WORD: -+ SNPrintF(trace_buf_, -+ " %08" PRIx32 " --> [%016" PRIx64 "] (%" PRId64 ")", -+ static_cast(value), addr, icount_); -+ break; -+ case DWORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " --> [%016" PRIx64 "] (%" PRId64 " )", -+ value, addr, icount_); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+template -+void Simulator::TraceMemRd(int64_t addr, T value) { -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (sizeof(T)) { -+ case 1: -+ SNPrintF(trace_buf_, -+ "%08" PRIx8 " <-- [%08" PRIx64 "] (%" PRIu64 -+ ") int8:%" PRId8 " uint8:%" PRIu8, -+ static_cast(value), addr, icount_, -+ static_cast(value), static_cast(value)); -+ break; -+ case 2: -+ SNPrintF(trace_buf_, -+ "%08" PRIx16 " <-- [%08" PRIx64 "] (%" PRIu64 -+ ") int16:%" PRId16 " uint16:%" PRIu16, -+ static_cast(value), addr, icount_, -+ static_cast(value), static_cast(value)); -+ break; -+ case 4: -+ SNPrintF(trace_buf_, -+ "%08" PRIx32 " <-- [%08" PRIx64 "] (%" PRIu64 -+ ") int32:%" PRId32 " uint32:%" PRIu32, -+ static_cast(value), addr, icount_, -+ static_cast(value), static_cast(value)); -+ break; -+ case 8: -+ SNPrintF(trace_buf_, -+ "%08" PRIx64 " <-- [%08" PRIx64 "] (%" PRIu64 -+ ") int64:%" PRId64 " uint64:%" PRIu64, -+ static_cast(value), addr, icount_, -+ static_cast(value), static_cast(value)); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+template -+void Simulator::TraceMemWr(int64_t addr, T value) { -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (sizeof(T)) { -+ case 1: -+ SNPrintF(trace_buf_, -+ " %02" PRIx8 " --> [%08" PRIx64 "] (%" PRIu64 ")", -+ static_cast(value), addr, icount_); -+ break; -+ case 2: -+ SNPrintF(trace_buf_, -+ " %04" PRIx16 " --> [%08" PRIx64 "] (%" PRIu64 ")", -+ static_cast(value), addr, icount_); -+ break; -+ case 4: -+ SNPrintF(trace_buf_, -+ "%08" PRIx32 " --> [%08" PRIx64 "] (%" PRIu64 ")", -+ static_cast(value), addr, icount_); -+ break; -+ case 8: -+ SNPrintF(trace_buf_, -+ "%16" PRIx64 " --> [%08" PRIx64 "] (%" PRIu64 ")", -+ static_cast(value), addr, icount_); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+// TODO(plind): sign-extend and zero-extend not implmented properly -+// on all the ReadXX functions, I don't think re-interpret cast does it. -+int32_t Simulator::ReadW(int64_t addr, Instruction* instr, TraceType t) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ /* if ((addr & 0x3) == 0)*/ { -+ local_monitor_.NotifyLoad(); -+ int32_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr), t); -+ return *ptr; -+ } -+ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, -+ // reinterpret_cast(instr)); -+ // DieOrDebug(); -+ // return 0; -+} -+ -+uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ // if ((addr & 0x3) == 0) { -+ local_monitor_.NotifyLoad(); -+ uint32_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr), WORD); -+ return *ptr; -+ // } -+ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, -+ // reinterpret_cast(instr)); -+ // DieOrDebug(); -+ // return 0; -+} -+ -+void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ /*if ((addr & 0x3) == 0)*/ { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, WORD); -+ int* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ return; -+ } -+ // PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, -+ // reinterpret_cast(instr)); -+ // DieOrDebug(); -+} -+ -+void Simulator::WriteConditionalW(int64_t addr, int32_t value, -+ Instruction* instr, int32_t rk_reg) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ if ((addr & 0x3) == 0) { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) && -+ GlobalMonitor::Get()->NotifyStoreConditional_Locked( -+ addr, &global_monitor_thread_)) { -+ local_monitor_.NotifyStore(); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, WORD); -+ int* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ set_register(rk_reg, 1); -+ } else { -+ set_register(rk_reg, 0); -+ } -+ return; -+ } -+ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, -+ reinterpret_cast(instr)); -+ DieOrDebug(); -+} -+ -+int64_t Simulator::Read2W(int64_t addr, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ /* if ((addr & kPointerAlignmentMask) == 0)*/ { -+ local_monitor_.NotifyLoad(); -+ int64_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, *ptr); -+ return *ptr; -+ } -+ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, -+ // reinterpret_cast(instr)); -+ // DieOrDebug(); -+ // return 0; -+} -+ -+void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ "\n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ /*if ((addr & kPointerAlignmentMask) == 0)*/ { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, DWORD); -+ int64_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ return; -+ } -+ // PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, -+ // reinterpret_cast(instr)); -+ // DieOrDebug(); -+} -+ -+void Simulator::WriteConditional2W(int64_t addr, int64_t value, -+ Instruction* instr, int32_t rk_reg) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ "\n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ if ((addr & kPointerAlignmentMask) == 0) { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ if (local_monitor_.NotifyStoreConditional(addr, -+ TransactionSize::DoubleWord) && -+ GlobalMonitor::Get()->NotifyStoreConditional_Locked( -+ addr, &global_monitor_thread_)) { -+ local_monitor_.NotifyStore(); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, DWORD); -+ int64_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ set_register(rk_reg, 1); -+ } else { -+ set_register(rk_reg, 0); -+ } -+ return; -+ } -+ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, -+ reinterpret_cast(instr)); -+ DieOrDebug(); -+} -+ -+double Simulator::ReadD(int64_t addr, Instruction* instr) { -+ /*if ((addr & kDoubleAlignmentMask) == 0)*/ { -+ local_monitor_.NotifyLoad(); -+ double* ptr = reinterpret_cast(addr); -+ return *ptr; -+ } -+ // PrintF("Unaligned (double) read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR -+ // "\n", -+ // addr, reinterpret_cast(instr)); -+ // base::OS::Abort(); -+ // return 0; -+} -+ -+void Simulator::WriteD(int64_t addr, double value, Instruction* instr) { -+ /*if ((addr & kDoubleAlignmentMask) == 0)*/ { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ double* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ return; -+ } -+ // PrintF("Unaligned (double) write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR -+ // "\n", -+ // addr, reinterpret_cast(instr)); -+ // DieOrDebug(); -+} -+ -+uint16_t Simulator::ReadHU(int64_t addr, Instruction* instr) { -+ // if ((addr & 1) == 0) { -+ local_monitor_.NotifyLoad(); -+ uint16_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr)); -+ return *ptr; -+ // } -+ // PrintF("Unaligned unsigned halfword read at 0x%08" PRIx64 -+ // " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, reinterpret_cast(instr)); -+ // DieOrDebug(); -+ // return 0; -+} -+ -+int16_t Simulator::ReadH(int64_t addr, Instruction* instr) { -+ // if ((addr & 1) == 0) { -+ local_monitor_.NotifyLoad(); -+ int16_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr)); -+ return *ptr; -+ // } -+ // PrintF("Unaligned signed halfword read at 0x%08" PRIx64 -+ // " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, reinterpret_cast(instr)); -+ // DieOrDebug(); -+ // return 0; -+} -+ -+void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) { -+ // if ((addr & 1) == 0) { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, HALF); -+ uint16_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ return; -+ // } -+ // PrintF("Unaligned unsigned halfword write at 0x%08" PRIx64 -+ // " , pc=0x%08" V8PRIxPTR "\n", -+ // addr, reinterpret_cast(instr)); -+ // DieOrDebug(); -+} -+ -+void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) { -+ // if ((addr & 1) == 0) { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, HALF); -+ int16_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ return; -+ // } -+ // PrintF("Unaligned halfword write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR -+ // "\n", -+ // addr, reinterpret_cast(instr)); -+ // DieOrDebug(); -+} -+ -+uint32_t Simulator::ReadBU(int64_t addr) { -+ local_monitor_.NotifyLoad(); -+ uint8_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr)); -+ return *ptr & 0xFF; -+} -+ -+int32_t Simulator::ReadB(int64_t addr) { -+ local_monitor_.NotifyLoad(); -+ int8_t* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, static_cast(*ptr)); -+ return *ptr; -+} -+ -+void Simulator::WriteB(int64_t addr, uint8_t value) { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, BYTE); -+ uint8_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+} -+ -+void Simulator::WriteB(int64_t addr, int8_t value) { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ TraceMemWr(addr, value, BYTE); -+ int8_t* ptr = reinterpret_cast(addr); -+ *ptr = value; -+} -+ -+template -+T Simulator::ReadMem(int64_t addr, Instruction* instr) { -+ int alignment_mask = (1 << sizeof(T)) - 1; -+ if ((addr & alignment_mask) == 0) { -+ local_monitor_.NotifyLoad(); -+ T* ptr = reinterpret_cast(addr); -+ TraceMemRd(addr, *ptr); -+ return *ptr; -+ } -+ PrintF("Unaligned read of type sizeof(%ld) at 0x%08lx, pc=0x%08" V8PRIxPTR -+ "\n", -+ sizeof(T), addr, reinterpret_cast(instr)); -+ base::OS::Abort(); -+ return 0; -+} -+ -+template -+void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) { -+ int alignment_mask = (1 << sizeof(T)) - 1; -+ if ((addr & alignment_mask) == 0) { -+ local_monitor_.NotifyStore(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ T* ptr = reinterpret_cast(addr); -+ *ptr = value; -+ TraceMemWr(addr, value); -+ return; -+ } -+ PrintF("Unaligned write of type sizeof(%ld) at 0x%08lx, pc=0x%08" V8PRIxPTR -+ "\n", -+ sizeof(T), addr, reinterpret_cast(instr)); -+ base::OS::Abort(); -+} -+ -+// Returns the limit of the stack area to enable checking for stack overflows. -+uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { -+ // The simulator uses a separate JS stack. If we have exhausted the C stack, -+ // we also drop down the JS limit to reflect the exhaustion on the JS stack. -+ if (GetCurrentStackPosition() < c_limit) { -+ return reinterpret_cast(get_sp()); -+ } -+ -+ // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes -+ // to prevent overrunning the stack when pushing values. -+ return reinterpret_cast(stack_) + 1024; -+} -+ -+// Unsupported instructions use Format to print an error and stop execution. -+void Simulator::Format(Instruction* instr, const char* format) { -+ PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR " : %s\n", -+ reinterpret_cast(instr), format); -+ UNIMPLEMENTED(); -+} -+ -+// Calls into the V8 runtime are based on this very simple interface. -+// Note: To be able to return two values from some calls the code in runtime.cc -+// uses the ObjectPair which is essentially two 32-bit values stuffed into a -+// 64-bit value. With the code below we assume that all runtime calls return -+// 64 bits of result. If they don't, the v1 result register contains a bogus -+// value, which is fine because it is caller-saved. -+ -+using SimulatorRuntimeCall = ObjectPair (*)(int64_t arg0, int64_t arg1, -+ int64_t arg2, int64_t arg3, -+ int64_t arg4, int64_t arg5, -+ int64_t arg6, int64_t arg7, -+ int64_t arg8, int64_t arg9); -+ -+// These prototypes handle the four types of FP calls. -+using SimulatorRuntimeCompareCall = int64_t (*)(double darg0, double darg1); -+using SimulatorRuntimeFPFPCall = double (*)(double darg0, double darg1); -+using SimulatorRuntimeFPCall = double (*)(double darg0); -+using SimulatorRuntimeFPIntCall = double (*)(double darg0, int32_t arg0); -+ -+// This signature supports direct call in to API function native callback -+// (refer to InvocationCallback in v8.h). -+using SimulatorRuntimeDirectApiCall = void (*)(int64_t arg0); -+using SimulatorRuntimeProfilingApiCall = void (*)(int64_t arg0, void* arg1); -+ -+// This signature supports direct call to accessor getter callback. -+using SimulatorRuntimeDirectGetterCall = void (*)(int64_t arg0, int64_t arg1); -+using SimulatorRuntimeProfilingGetterCall = void (*)(int64_t arg0, int64_t arg1, -+ void* arg2); -+ -+// Software interrupt instructions are used by the simulator to call into the -+// C-based V8 runtime. They are also used for debugging with simulator. -+void Simulator::SoftwareInterrupt() { -+ int32_t opcode_hi15 = instr_.Bits(31, 17); -+ CHECK_EQ(opcode_hi15, 0x15); -+ uint32_t code = instr_.Bits(14, 0); -+ // We first check if we met a call_rt_redirected. -+ if (instr_.InstructionBits() == rtCallRedirInstr) { -+ Redirection* redirection = Redirection::FromInstruction(instr_.instr()); -+ -+ int64_t* stack_pointer = reinterpret_cast(get_register(sp)); -+ -+ int64_t arg0 = get_register(a0); -+ int64_t arg1 = get_register(a1); -+ int64_t arg2 = get_register(a2); -+ int64_t arg3 = get_register(a3); -+ int64_t arg4 = get_register(a4); -+ int64_t arg5 = get_register(a5); -+ int64_t arg6 = get_register(a6); -+ int64_t arg7 = get_register(a7); -+ int64_t arg8 = stack_pointer[0]; -+ int64_t arg9 = stack_pointer[1]; -+ STATIC_ASSERT(kMaxCParameters == 10); -+ -+ bool fp_call = -+ (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); -+ -+ { -+ // With the hard floating point calling convention, double -+ // arguments are passed in FPU registers. Fetch the arguments -+ // from there and call the builtin using soft floating point -+ // convention. -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_FP_FP_CALL: -+ case ExternalReference::BUILTIN_COMPARE_CALL: -+ arg0 = get_fpu_register(f0); -+ arg1 = get_fpu_register(f1); -+ arg2 = get_fpu_register(f2); -+ arg3 = get_fpu_register(f3); -+ break; -+ case ExternalReference::BUILTIN_FP_CALL: -+ arg0 = get_fpu_register(f0); -+ arg1 = get_fpu_register(f1); -+ break; -+ case ExternalReference::BUILTIN_FP_INT_CALL: -+ arg0 = get_fpu_register(f0); -+ arg1 = get_fpu_register(f1); -+ arg2 = get_register(a2); -+ break; -+ default: -+ break; -+ } -+ } -+ -+ // This is dodgy but it works because the C entry stubs are never moved. -+ // See comment in codegen-arm.cc and bug 1242173. -+ int64_t saved_ra = get_register(ra); -+ -+ intptr_t external = -+ reinterpret_cast(redirection->external_function()); -+ -+ // Based on CpuFeatures::IsSupported(FPU), La64 will use either hardware -+ // FPU, or gcc soft-float routines. Hardware FPU is simulated in this -+ // simulator. Soft-float has additional abstraction of ExternalReference, -+ // to support serialization. -+ if (fp_call) { -+ double dval0, dval1; // one or two double parameters -+ int32_t ival; // zero or one integer parameters -+ int64_t iresult = 0; // integer return value -+ double dresult = 0; // double return value -+ GetFpArgs(&dval0, &dval1, &ival); -+ SimulatorRuntimeCall generic_target = -+ reinterpret_cast(external); -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_FP_FP_CALL: -+ case ExternalReference::BUILTIN_COMPARE_CALL: -+ PrintF("Call to host function at %p with args %f, %f", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0, dval1); -+ break; -+ case ExternalReference::BUILTIN_FP_CALL: -+ PrintF("Call to host function at %p with arg %f", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0); -+ break; -+ case ExternalReference::BUILTIN_FP_INT_CALL: -+ PrintF("Call to host function at %p with args %f, %d", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0, ival); -+ break; -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ } -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_COMPARE_CALL: { -+ SimulatorRuntimeCompareCall target = -+ reinterpret_cast(external); -+ iresult = target(dval0, dval1); -+ set_register(v0, static_cast(iresult)); -+ // set_register(v1, static_cast(iresult >> 32)); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_FP_CALL: { -+ SimulatorRuntimeFPFPCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0, dval1); -+ SetFpResult(dresult); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_CALL: { -+ SimulatorRuntimeFPCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0); -+ SetFpResult(dresult); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_INT_CALL: { -+ SimulatorRuntimeFPIntCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0, ival); -+ SetFpResult(dresult); -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_COMPARE_CALL: -+ PrintF("Returned %08x\n", static_cast(iresult)); -+ break; -+ case ExternalReference::BUILTIN_FP_FP_CALL: -+ case ExternalReference::BUILTIN_FP_CALL: -+ case ExternalReference::BUILTIN_FP_INT_CALL: -+ PrintF("Returned %f\n", dresult); -+ break; -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ } -+ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " \n", -+ reinterpret_cast(external), arg0); -+ } -+ SimulatorRuntimeDirectApiCall target = -+ reinterpret_cast(external); -+ target(arg0); -+ } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " \n", -+ reinterpret_cast(external), arg0, arg1); -+ } -+ SimulatorRuntimeProfilingApiCall target = -+ reinterpret_cast(external); -+ target(arg0, Redirection::ReverseRedirection(arg1)); -+ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " \n", -+ reinterpret_cast(external), arg0, arg1); -+ } -+ SimulatorRuntimeDirectGetterCall target = -+ reinterpret_cast(external); -+ target(arg0, arg1); -+ } else if (redirection->type() == -+ ExternalReference::PROFILING_GETTER_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " %08" PRIx64 " \n", -+ reinterpret_cast(external), arg0, arg1, arg2); -+ } -+ SimulatorRuntimeProfilingGetterCall target = -+ reinterpret_cast(external); -+ target(arg0, arg1, Redirection::ReverseRedirection(arg2)); -+ } else { -+ DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || -+ redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); -+ SimulatorRuntimeCall target = -+ reinterpret_cast(external); -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF( -+ "Call to host function at %p " -+ "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 -+ " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 -+ " , %08" PRIx64 " , %08" PRIx64 " \n", -+ reinterpret_cast(FUNCTION_ADDR(target)), arg0, arg1, arg2, -+ arg3, arg4, arg5, arg6, arg7, arg8, arg9); -+ } -+ ObjectPair result = -+ target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); -+ set_register(v0, (int64_t)(result.x)); -+ set_register(v1, (int64_t)(result.y)); -+ } -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(v1), -+ get_register(v0)); -+ } -+ set_register(ra, saved_ra); -+ set_pc(get_register(ra)); -+ -+ } else if (code <= kMaxStopCode) { -+ if (IsWatchpoint(code)) { -+ PrintWatchpoint(code); -+ } else { -+ IncreaseStopCounter(code); -+ HandleStop(code, instr_.instr()); -+ } -+ } else { -+ // All remaining break_ codes, and all traps are handled here. -+ La64Debugger dbg(this); -+ dbg.Debug(); -+ } -+} -+ -+// Stop helper functions. -+bool Simulator::IsWatchpoint(uint64_t code) { -+ return (code <= kMaxWatchpointCode); -+} -+ -+void Simulator::PrintWatchpoint(uint64_t code) { -+ La64Debugger dbg(this); -+ ++break_count_; -+ PrintF("\n---- break %" PRId64 " marker: %3d (instr count: %8" PRId64 -+ " ) ----------" -+ "----------------------------------", -+ code, break_count_, icount_); -+ dbg.PrintAllRegs(); // Print registers and continue running. -+} -+ -+void Simulator::HandleStop(uint64_t code, Instruction* instr) { -+ // Stop if it is enabled, otherwise go on jumping over the stop -+ // and the message address. -+ if (IsEnabledStop(code)) { -+ La64Debugger dbg(this); -+ dbg.Stop(instr); -+ } -+} -+ -+bool Simulator::IsStopInstruction(Instruction* instr) { -+ int32_t opcode_hi15 = instr->Bits(31, 17); -+ uint32_t code = static_cast(instr->Bits(14, 0)); -+ return (opcode_hi15 == 0x15) && code > kMaxWatchpointCode && -+ code <= kMaxStopCode; -+} -+ -+bool Simulator::IsEnabledStop(uint64_t code) { -+ DCHECK_LE(code, kMaxStopCode); -+ DCHECK_GT(code, kMaxWatchpointCode); -+ return !(watched_stops_[code].count & kStopDisabledBit); -+} -+ -+void Simulator::EnableStop(uint64_t code) { -+ if (!IsEnabledStop(code)) { -+ watched_stops_[code].count &= ~kStopDisabledBit; -+ } -+} -+ -+void Simulator::DisableStop(uint64_t code) { -+ if (IsEnabledStop(code)) { -+ watched_stops_[code].count |= kStopDisabledBit; -+ } -+} -+ -+void Simulator::IncreaseStopCounter(uint64_t code) { -+ DCHECK_LE(code, kMaxStopCode); -+ if ((watched_stops_[code].count & ~(1 << 31)) == 0x7FFFFFFF) { -+ PrintF("Stop counter for code %" PRId64 -+ " has overflowed.\n" -+ "Enabling this code and reseting the counter to 0.\n", -+ code); -+ watched_stops_[code].count = 0; -+ EnableStop(code); -+ } else { -+ watched_stops_[code].count++; -+ } -+} -+ -+// Print a stop status. -+void Simulator::PrintStopInfo(uint64_t code) { -+ if (code <= kMaxWatchpointCode) { -+ PrintF("That is a watchpoint, not a stop.\n"); -+ return; -+ } else if (code > kMaxStopCode) { -+ PrintF("Code too large, only %u stops can be used\n", kMaxStopCode + 1); -+ return; -+ } -+ const char* state = IsEnabledStop(code) ? "Enabled" : "Disabled"; -+ int32_t count = watched_stops_[code].count & ~kStopDisabledBit; -+ // Don't print the state of unused breakpoints. -+ if (count != 0) { -+ if (watched_stops_[code].desc) { -+ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i, \t%s\n", -+ code, code, state, count, watched_stops_[code].desc); -+ } else { -+ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i\n", code, -+ code, state, count); -+ } -+ } -+} -+ -+void Simulator::SignalException(Exception e) { -+ FATAL("Error: Exception %i raised.", static_cast(e)); -+} -+ -+template -+static T FPAbs(T a); -+ -+template <> -+double FPAbs(double a) { -+ return fabs(a); -+} -+ -+template <> -+float FPAbs(float a) { -+ return fabsf(a); -+} -+ -+template -+static bool FPUProcessNaNsAndZeros(T a, T b, MaxMinKind kind, T* result) { -+ if (std::isnan(a) && std::isnan(b)) { -+ *result = a; -+ } else if (std::isnan(a)) { -+ *result = b; -+ } else if (std::isnan(b)) { -+ *result = a; -+ } else if (b == a) { -+ // Handle -0.0 == 0.0 case. -+ // std::signbit() returns int 0 or 1 so subtracting MaxMinKind::kMax -+ // negates the result. -+ *result = std::signbit(b) - static_cast(kind) ? b : a; -+ } else { -+ return false; -+ } -+ return true; -+} -+ -+template -+static T FPUMin(T a, T b) { -+ T result; -+ if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { -+ return result; -+ } else { -+ return b < a ? b : a; -+ } -+} -+ -+template -+static T FPUMax(T a, T b) { -+ T result; -+ if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMax, &result)) { -+ return result; -+ } else { -+ return b > a ? b : a; -+ } -+} -+ -+template -+static T FPUMinA(T a, T b) { -+ T result; -+ if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { -+ if (FPAbs(a) < FPAbs(b)) { -+ result = a; -+ } else if (FPAbs(b) < FPAbs(a)) { -+ result = b; -+ } else { -+ result = a < b ? a : b; -+ } -+ } -+ return result; -+} -+ -+template -+static T FPUMaxA(T a, T b) { -+ T result; -+ if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { -+ if (FPAbs(a) > FPAbs(b)) { -+ result = a; -+ } else if (FPAbs(b) > FPAbs(a)) { -+ result = b; -+ } else { -+ result = a > b ? a : b; -+ } -+ } -+ return result; -+} -+ -+enum class KeepSign : bool { no = false, yes }; -+ -+template ::value, -+ int>::type = 0> -+T FPUCanonalizeNaNArg(T result, T arg, KeepSign keepSign = KeepSign::no) { -+ DCHECK(std::isnan(arg)); -+ T qNaN = std::numeric_limits::quiet_NaN(); -+ if (keepSign == KeepSign::yes) { -+ return std::copysign(qNaN, result); -+ } -+ return qNaN; -+} -+ -+template -+T FPUCanonalizeNaNArgs(T result, KeepSign keepSign, T first) { -+ if (std::isnan(first)) { -+ return FPUCanonalizeNaNArg(result, first, keepSign); -+ } -+ return result; -+} -+ -+template -+T FPUCanonalizeNaNArgs(T result, KeepSign keepSign, T first, Args... args) { -+ if (std::isnan(first)) { -+ return FPUCanonalizeNaNArg(result, first, keepSign); -+ } -+ return FPUCanonalizeNaNArgs(result, keepSign, args...); -+} -+ -+template -+T FPUCanonalizeOperation(Func f, T first, Args... args) { -+ return FPUCanonalizeOperation(f, KeepSign::no, first, args...); -+} -+ -+template -+T FPUCanonalizeOperation(Func f, KeepSign keepSign, T first, Args... args) { -+ T result = f(first, args...); -+ if (std::isnan(result)) { -+ result = FPUCanonalizeNaNArgs(result, keepSign, first, args...); -+ } -+ return result; -+} -+ -+// Handle execution based on instruction types. -+void Simulator::DecodeTypeOp6() { -+ int64_t alu_out; -+ // Next pc. -+ int64_t next_pc = bad_ra; -+ -+ // Branch instructions common part. -+ auto BranchAndLinkHelper = [this, &next_pc]() { -+ int64_t current_pc = get_pc(); -+ set_register(ra, current_pc + kInstrSize); -+ int32_t offs26_low16 = -+ static_cast(instr_.Bits(25, 10) << 16) >> 16; -+ int32_t offs26_high10 = static_cast(instr_.Bits(9, 0) << 22) >> 6; -+ int32_t offs26 = offs26_low16 | offs26_high10; -+ next_pc = current_pc + (offs26 << 2); -+ printf_instr("Offs26: %08x\n", offs26); -+ set_pc(next_pc); -+ }; -+ -+ auto BranchOff16Helper = [this, &next_pc](bool do_branch) { -+ int64_t current_pc = get_pc(); -+ int32_t offs16 = static_cast(instr_.Bits(25, 10) << 16) >> 16; -+ printf_instr("Offs16: %08x\n", offs16); -+ int32_t offs = do_branch ? (offs16 << 2) : kInstrSize; -+ next_pc = current_pc + offs; -+ set_pc(next_pc); -+ }; -+ -+ auto BranchOff21Helper = [this, &next_pc](bool do_branch) { -+ int64_t current_pc = get_pc(); -+ int32_t offs21_low16 = -+ static_cast(instr_.Bits(25, 10) << 16) >> 16; -+ int32_t offs21_high5 = static_cast(instr_.Bits(4, 0) << 27) >> 11; -+ int32_t offs = offs21_low16 | offs21_high5; -+ printf_instr("Offs21: %08x\n", offs); -+ offs = do_branch ? (offs << 2) : kInstrSize; -+ next_pc = current_pc + offs; -+ set_pc(next_pc); -+ }; -+ -+ auto BranchOff26Helper = [this, &next_pc]() { -+ int64_t current_pc = get_pc(); -+ int32_t offs26_low16 = -+ static_cast(instr_.Bits(25, 10) << 16) >> 16; -+ int32_t offs26_high10 = static_cast(instr_.Bits(9, 0) << 22) >> 6; -+ int32_t offs26 = offs26_low16 | offs26_high10; -+ next_pc = current_pc + (offs26 << 2); -+ printf_instr("Offs26: %08x\n", offs26); -+ set_pc(next_pc); -+ }; -+ -+ auto JumpOff16Helper = [this, &next_pc]() { -+ int32_t offs16 = static_cast(instr_.Bits(25, 10) << 16) >> 16; -+ printf_instr("JIRL\t %s: %016lx, %s: %016lx, offs16: %x\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), offs16); -+ set_register(rd_reg(), get_pc() + kInstrSize); -+ next_pc = rj() + (offs16 << 2); -+ set_pc(next_pc); -+ }; -+ -+ switch (instr_.Bits(31, 26) << 26) { -+ case ADDU16I_D: { -+ printf_instr("ADDU16I_D\t %s: %016lx, %s: %016lx, si16: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si16()); -+ int32_t si16_upper = static_cast(si16()) << 16; -+ alu_out = static_cast(si16_upper) + rj(); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BEQZ: -+ printf_instr("BEQZ\t %s: %016lx, ", Registers::Name(rj_reg()), rj()); -+ BranchOff21Helper(rj() == 0); -+ break; -+ case BNEZ: -+ printf_instr("BNEZ\t %s: %016lx, ", Registers::Name(rj_reg()), rj()); -+ BranchOff21Helper(rj() != 0); -+ break; -+ case BCZ: { -+ if (instr_.Bits(9, 8) == 0b00) { -+ // BCEQZ -+ printf_instr("BCEQZ\t fcc%d: %s, ", cj_reg(), cj() ? "True" : "False"); -+ BranchOff21Helper(cj() == false); -+ } else if (instr_.Bits(9, 8) == 0b01) { -+ // BCNEZ -+ printf_instr("BCNEZ\t fcc%d: %s, ", cj_reg(), cj() ? "True" : "False"); -+ BranchOff21Helper(cj() == true); -+ } else { -+ UNREACHABLE(); -+ } -+ break; -+ } -+ case JIRL: -+ JumpOff16Helper(); -+ break; -+ case B: -+ printf_instr("B\t "); -+ BranchOff26Helper(); -+ break; -+ case BL: -+ printf_instr("BL\t "); -+ BranchAndLinkHelper(); -+ break; -+ case BEQ: -+ printf_instr("BEQ\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj() == rd()); -+ break; -+ case BNE: -+ printf_instr("BNE\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj() != rd()); -+ break; -+ case BLT: -+ printf_instr("BLT\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj() < rd()); -+ break; -+ case BGE: -+ printf_instr("BGE\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj() >= rd()); -+ break; -+ case BLTU: -+ printf_instr("BLTU\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj_u() < rd_u()); -+ break; -+ case BGEU: -+ printf_instr("BGEU\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), -+ rj(), Registers::Name(rd_reg()), rd()); -+ BranchOff16Helper(rj_u() >= rd_u()); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp7() { -+ int64_t alu_out; -+ -+ switch (instr_.Bits(31, 25) << 25) { -+ case LU12I_W: { -+ printf_instr("LU12I_W\t %s: %016lx, si20: %d\n", -+ Registers::Name(rd_reg()), rd(), si20()); -+ int32_t si20_upper = static_cast(si20() << 12); -+ SetResult(rd_reg(), static_cast(si20_upper)); -+ break; -+ } -+ case LU32I_D: { -+ printf_instr("LU32I_D\t %s: %016lx, si20: %d\n", -+ Registers::Name(rd_reg()), rd(), si20()); -+ int32_t si20_signExtend = static_cast(si20() << 12) >> 12; -+ int64_t lower_32bit_mask = 0xFFFFFFFF; -+ alu_out = (static_cast(si20_signExtend) << 32) | -+ (rd() & lower_32bit_mask); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case PCADDI: { -+ printf_instr("PCADDI\t %s: %016lx, si20: %d\n", Registers::Name(rd_reg()), -+ rd(), si20()); -+ int32_t si20_signExtend = static_cast(si20() << 12) >> 10; -+ int64_t current_pc = get_pc(); -+ alu_out = static_cast(si20_signExtend) + current_pc; -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case PCALAU12I: { -+ printf_instr("PCALAU12I\t %s: %016lx, si20: %d\n", -+ Registers::Name(rd_reg()), rd(), si20()); -+ int32_t si20_signExtend = static_cast(si20() << 12); -+ int64_t current_pc = get_pc(); -+ int64_t clear_lower12bit_mask = 0xFFFFFFFFFFFFF000; -+ alu_out = static_cast(si20_signExtend) + current_pc; -+ SetResult(rd_reg(), alu_out & clear_lower12bit_mask); -+ break; -+ } -+ case PCADDU12I: { -+ printf_instr("PCADDU12I\t %s: %016lx, si20: %d\n", -+ Registers::Name(rd_reg()), rd(), si20()); -+ int32_t si20_signExtend = static_cast(si20() << 12); -+ int64_t current_pc = get_pc(); -+ alu_out = static_cast(si20_signExtend) + current_pc; -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case PCADDU18I: { -+ printf_instr("PCADDU18I\t %s: %016lx, si20: %d\n", -+ Registers::Name(rd_reg()), rd(), si20()); -+ int64_t si20_signExtend = (static_cast(si20()) << 44) >> 26; -+ int64_t current_pc = get_pc(); -+ alu_out = si20_signExtend + current_pc; -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp8() { -+ int64_t addr = 0x0; -+ int64_t si14_se = (static_cast(si14()) << 50) >> 48; -+ -+ switch (instr_.Bits(31, 24) << 24) { -+ case LDPTR_W: -+ printf_instr("LDPTR_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ set_register(rd_reg(), ReadW(rj() + si14_se, instr_.instr())); -+ break; -+ case STPTR_W: -+ printf_instr("STPTR_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ WriteW(rj() + si14_se, static_cast(rd()), instr_.instr()); -+ break; -+ case LDPTR_D: -+ printf_instr("LDPTR_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ set_register(rd_reg(), Read2W(rj() + si14_se, instr_.instr())); -+ break; -+ case STPTR_D: -+ printf_instr("STPTR_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ Write2W(rj() + si14_se, rd(), instr_.instr()); -+ break; -+ case LL_W: { -+ printf_instr("LL_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ addr = si14_se + rj(); -+ set_register(rd_reg(), ReadW(addr, instr_.instr())); -+ local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, -+ &global_monitor_thread_); -+ break; -+ } -+ case SC_W: { -+ printf_instr("SC_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ addr = si14_se + rj(); -+ WriteConditionalW(addr, static_cast(rd()), instr_.instr(), -+ rd_reg()); -+ break; -+ } -+ case LL_D: { -+ printf_instr("LL_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ addr = si14_se + rj(); -+ set_register(rd_reg(), Read2W(addr, instr_.instr())); -+ local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, -+ &global_monitor_thread_); -+ break; -+ } -+ case SC_D: { -+ printf_instr("SC_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si14_se); -+ addr = si14_se + rj(); -+ WriteConditional2W(addr, rd(), instr_.instr(), rd_reg()); -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp10() { -+ int64_t alu_out = 0x0; -+ int64_t si12_se = (static_cast(si12()) << 52) >> 52; -+ uint64_t si12_ze = (static_cast(ui12()) << 52) >> 52; -+ -+ switch (instr_.Bits(31, 22) << 22) { -+ case BSTR_W: { -+ CHECK_EQ(instr_.Bit(21), 1); -+ uint8_t lsbw_ = lsbw(); -+ uint8_t msbw_ = msbw(); -+ CHECK_LE(lsbw_, msbw_); -+ uint8_t size = msbw_ - lsbw_ + 1; -+ uint64_t mask = (1ULL << size) - 1; -+ if (instr_.Bit(15) == 0) { -+ // BSTRINS_W -+ printf_instr( -+ "BSTRINS_W\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), -+ msbw_, lsbw_); -+ alu_out = static_cast((rd_u() & ~(mask << lsbw_)) | -+ ((rj_u() & mask) << lsbw_)); -+ } else { -+ // BSTRPICK_W -+ printf_instr( -+ "BSTRPICK_W\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), -+ msbw_, lsbw_); -+ alu_out = static_cast((rj_u() & (mask << lsbw_)) >> lsbw_); -+ } -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BSTRINS_D: { -+ uint8_t lsbd_ = lsbd(); -+ uint8_t msbd_ = msbd(); -+ CHECK_LE(lsbd_, msbd_); -+ printf_instr( -+ "BSTRINS_D\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), -+ msbd_, lsbd_); -+ uint8_t size = msbd_ - lsbd_ + 1; -+ if (size < 64) { -+ uint64_t mask = (1ULL << size) - 1; -+ alu_out = (rd_u() & ~(mask << lsbd_)) | ((rj_u() & mask) << lsbd_); -+ SetResult(rd_reg(), alu_out); -+ } else if (size == 64) { -+ SetResult(rd_reg(), rj()); -+ } -+ break; -+ } -+ case BSTRPICK_D: { -+ uint8_t lsbd_ = lsbd(); -+ uint8_t msbd_ = msbd(); -+ CHECK_LE(lsbd_, msbd_); -+ printf_instr( -+ "BSTRPICK_D\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), -+ msbd_, lsbd_); -+ uint8_t size = msbd_ - lsbd_ + 1; -+ if (size < 64) { -+ uint64_t mask = (1ULL << size) - 1; -+ alu_out = (rj_u() & (mask << lsbd_)) >> lsbd_; -+ SetResult(rd_reg(), alu_out); -+ } else if (size == 64) { -+ SetResult(rd_reg(), rj()); -+ } -+ break; -+ } -+ case SLTI: -+ printf_instr("SLTI\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_se); -+ SetResult(rd_reg(), rj() < si12_se ? 1 : 0); -+ break; -+ case SLTUI: -+ printf_instr("SLTUI\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_se); -+ SetResult(rd_reg(), rj_u() < static_cast(si12_se) ? 1 : 0); -+ break; -+ case ADDI_W: { -+ printf_instr("ADDI_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_se); -+ int32_t alu32_out = -+ static_cast(rj()) + static_cast(si12_se); -+ SetResult(rd_reg(), alu32_out); -+ break; -+ } -+ case ADDI_D: -+ printf_instr("ADDI_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_se); -+ SetResult(rd_reg(), rj() + si12_se); -+ break; -+ case LU52I_D: { -+ printf_instr("LU52I_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_se); -+ int64_t si12_se = static_cast(si12()) << 52; -+ uint64_t mask = (1ULL << 52) - 1; -+ alu_out = si12_se + (rj() & mask); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case ANDI: -+ printf_instr("ANDI\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ SetResult(rd_reg(), rj() & si12_ze); -+ break; -+ case ORI: -+ printf_instr("ORI\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ SetResult(rd_reg(), rj_u() | si12_ze); -+ break; -+ case XORI: -+ printf_instr("XORI\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ SetResult(rd_reg(), rj_u() ^ si12_ze); -+ break; -+ case LD_B: -+ printf_instr("LD_B\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadB(rj() + si12_se)); -+ break; -+ case LD_H: -+ printf_instr("LD_H\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadH(rj() + si12_se, instr_.instr())); -+ break; -+ case LD_W: -+ printf_instr("LD_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadW(rj() + si12_se, instr_.instr())); -+ break; -+ case LD_D: -+ printf_instr("LD_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), Read2W(rj() + si12_se, instr_.instr())); -+ break; -+ case ST_B: -+ printf_instr("ST_B\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ WriteB(rj() + si12_se, static_cast(rd())); -+ break; -+ case ST_H: -+ printf_instr("ST_H\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ WriteH(rj() + si12_se, static_cast(rd()), instr_.instr()); -+ break; -+ case ST_W: -+ printf_instr("ST_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ WriteW(rj() + si12_se, static_cast(rd()), instr_.instr()); -+ break; -+ case ST_D: -+ printf_instr("ST_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ Write2W(rj() + si12_se, rd(), instr_.instr()); -+ break; -+ case LD_BU: -+ printf_instr("LD_BU\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadBU(rj() + si12_se)); -+ break; -+ case LD_HU: -+ printf_instr("LD_HU\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadHU(rj() + si12_se, instr_.instr())); -+ break; -+ case LD_WU: -+ printf_instr("LD_WU\t %s: %016lx, %s: %016lx, si12: %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), si12_ze); -+ set_register(rd_reg(), ReadWU(rj() + si12_se, instr_.instr())); -+ break; -+ case FLD_S: { -+ printf_instr("FLD_S\t %s: %016f, %s: %016lx, si12: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ Registers::Name(rj_reg()), rj(), si12_ze); -+ set_fpu_register(fd_reg(), kFPUInvalidResult); // Trash upper 32 bits. -+ set_fpu_register_word( -+ fd_reg(), ReadW(rj() + si12_se, instr_.instr(), FLOAT_DOUBLE)); -+ break; -+ } -+ case FST_S: { -+ printf_instr("FST_S\t %s: %016f, %s: %016lx, si12: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ Registers::Name(rj_reg()), rj(), si12_ze); -+ int32_t alu_out_32 = static_cast(get_fpu_register(fd_reg())); -+ WriteW(rj() + si12_se, alu_out_32, instr_.instr()); -+ break; -+ } -+ case FLD_D: { -+ printf_instr("FLD_D\t %s: %016f, %s: %016lx, si12: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj(), si12_ze); -+ set_fpu_register_double(fd_reg(), ReadD(rj() + si12_se, instr_.instr())); -+ TraceMemRd(rj() + si12_se, get_fpu_register(fd_reg()), DOUBLE); -+ break; -+ } -+ case FST_D: { -+ printf_instr("FST_D\t %s: %016f, %s: %016lx, si12: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj(), si12_ze); -+ WriteD(rj() + si12_se, get_fpu_register_double(fd_reg()), instr_.instr()); -+ TraceMemWr(rj() + si12_se, get_fpu_register(fd_reg()), DWORD); -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp12() { -+ switch (instr_.Bits(31, 20) << 20) { -+ case FMADD_S: -+ printf_instr("FMADD_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fk_reg()), fk_float(), -+ FPURegisters::Name(fa_reg()), fa_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), std::fma(fj_float(), fk_float(), fa_float())); -+ break; -+ case FMADD_D: -+ printf_instr("FMADD_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fk_reg()), fk_double(), -+ FPURegisters::Name(fa_reg()), fa_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), -+ std::fma(fj_double(), fk_double(), fa_double())); -+ break; -+ case FMSUB_S: -+ printf_instr("FMSUB_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fk_reg()), fk_float(), -+ FPURegisters::Name(fa_reg()), fa_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), -+ std::fma(fj_float(), fk_float(), -fa_float())); -+ break; -+ case FMSUB_D: -+ printf_instr("FMSUB_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fk_reg()), fk_double(), -+ FPURegisters::Name(fa_reg()), fa_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), -+ std::fma(fj_double(), fk_double(), -fa_double())); -+ break; -+ case FNMADD_S: -+ printf_instr("FNMADD_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fk_reg()), fk_float(), -+ FPURegisters::Name(fa_reg()), fa_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), -+ std::fma(-fj_float(), fk_float(), -fa_float())); -+ break; -+ case FNMADD_D: -+ printf_instr("FNMADD_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fk_reg()), fk_double(), -+ FPURegisters::Name(fa_reg()), fa_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), -+ std::fma(-fj_double(), fk_double(), -fa_double())); -+ break; -+ case FNMSUB_S: -+ printf_instr("FNMSUB_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fk_reg()), fk_float(), -+ FPURegisters::Name(fa_reg()), fa_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), -+ std::fma(-fj_float(), fk_float(), fa_float())); -+ break; -+ case FNMSUB_D: -+ printf_instr("FNMSUB_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fk_reg()), fk_double(), -+ FPURegisters::Name(fa_reg()), fa_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), -+ std::fma(-fj_double(), fk_double(), fa_double())); -+ break; -+ case FCMP_COND_S: { -+ CHECK_EQ(instr_.Bits(4, 3), 0); -+ float fj = fj_float(); -+ float fk = fk_float(); -+ switch (cond()) { -+ case CAF: { -+ printf_instr("FCMP_CAF_S fcc%d\n", cd_reg()); -+ set_cf_register(cd_reg(), false); -+ break; -+ } -+ case CUN: { -+ printf_instr("FCMP_CUN_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CEQ: { -+ printf_instr("FCMP_CEQ_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj == fk); -+ break; -+ } -+ case CUEQ: { -+ printf_instr("FCMP_CUEQ_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj == fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CLT: { -+ printf_instr("FCMP_CLT_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj < fk); -+ break; -+ } -+ case CULT: { -+ printf_instr("FCMP_CULT_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj < fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CLE: { -+ printf_instr("FCMP_CLE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj <= fk); -+ break; -+ } -+ case CULE: { -+ printf_instr("FCMP_CULE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj <= fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CNE: { -+ printf_instr("FCMP_CNE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), (fj < fk) || (fj > fk)); -+ break; -+ } -+ case COR: { -+ printf_instr("FCMP_COR_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), !std::isnan(fj) && !std::isnan(fk)); -+ break; -+ } -+ case CUNE: { -+ printf_instr("FCMP_CUNE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj != fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case SAF: -+ case SUN: -+ case SEQ: -+ case SUEQ: -+ case SLT: -+ case SULT: -+ case SLE: -+ case SULE: -+ case SNE: -+ case SOR: -+ case SUNE: -+ UNIMPLEMENTED(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ break; -+ } -+ case FCMP_COND_D: { -+ CHECK_EQ(instr_.Bits(4, 3), 0); -+ double fj = fj_double(); -+ double fk = fk_double(); -+ switch (cond()) { -+ case CAF: { -+ printf_instr("FCMP_CAF_D fcc%d\n", cd_reg()); -+ set_cf_register(cd_reg(), false); -+ break; -+ } -+ case CUN: { -+ printf_instr("FCMP_CUN_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CEQ: { -+ printf_instr("FCMP_CEQ_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj == fk); -+ break; -+ } -+ case CUEQ: { -+ printf_instr("FCMP_CUEQ_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj == fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CLT: { -+ printf_instr("FCMP_CLT_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj < fk); -+ break; -+ } -+ case CULT: { -+ printf_instr("FCMP_CULT_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj < fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CLE: { -+ printf_instr("FCMP_CLE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), fj <= fk); -+ break; -+ } -+ case CULE: { -+ printf_instr("FCMP_CULE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj <= fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case CNE: { -+ printf_instr("FCMP_CNE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), (fj < fk) || (fj > fk)); -+ break; -+ } -+ case COR: { -+ printf_instr("FCMP_COR_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), !std::isnan(fj) && !std::isnan(fk)); -+ break; -+ } -+ case CUNE: { -+ printf_instr("FCMP_CUNE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), -+ FPURegisters::Name(fj_reg()), fj, -+ FPURegisters::Name(fk_reg()), fk); -+ set_cf_register(cd_reg(), -+ (fj != fk) || std::isnan(fj) || std::isnan(fk)); -+ break; -+ } -+ case SAF: -+ case SUN: -+ case SEQ: -+ case SUEQ: -+ case SLT: -+ case SULT: -+ case SLE: -+ case SULE: -+ case SNE: -+ case SOR: -+ case SUNE: -+ UNIMPLEMENTED(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ break; -+ } -+ case FSEL: { -+ CHECK_EQ(instr_.Bits(19, 18), 0); -+ printf_instr("FSEL fcc%d, %s: %016f, %s: %016f, %s: %016f\n", ca_reg(), -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ if (ca() == 0) { -+ SetFPUDoubleResult(fd_reg(), fj_double()); -+ } else { -+ SetFPUDoubleResult(fd_reg(), fk_double()); -+ } -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp14() { -+ int64_t alu_out = 0x0; -+ int32_t alu32_out = 0x0; -+ -+ switch (instr_.Bits(31, 18) << 18) { -+ case ALSL: { -+ uint8_t sa = sa2() + 1; -+ alu32_out = -+ (static_cast(rj()) << sa) + static_cast(rk()); -+ if (instr_.Bit(17) == 0) { -+ // ALSL_W -+ printf_instr("ALSL_W\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk(), sa2()); -+ SetResult(rd_reg(), alu32_out); -+ } else { -+ // ALSL_WU -+ printf_instr("ALSL_WU\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk(), sa2()); -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ } -+ break; -+ } -+ case BYTEPICK_W: { -+ CHECK_EQ(instr_.Bit(17), 0); -+ printf_instr("BYTEPICK_W\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk(), sa2()); -+ uint8_t sa = sa2() * 8; -+ if (sa == 0) { -+ alu32_out = static_cast(rk()); -+ } else { -+ int32_t mask = (1 << 31) >> (sa - 1); -+ int32_t rk_hi = (static_cast(rk()) & (~mask)) << sa; -+ int32_t rj_lo = (static_cast(rj()) & mask) >> (32 - sa); -+ alu32_out = rk_hi | rj_lo; -+ } -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ break; -+ } -+ case BYTEPICK_D: { -+ printf_instr("BYTEPICK_D\t %s: %016lx, %s: %016lx, %s: %016lx, sa3: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk(), sa3()); -+ uint8_t sa = sa3() * 8; -+ if (sa == 0) { -+ alu_out = rk(); -+ } else { -+ int64_t mask = (1ULL << 63) >> (sa - 1); -+ int64_t rk_hi = (rk() & (~mask)) << sa; -+ int64_t rj_lo = (rj() & mask) >> (64 - sa); -+ alu_out = rk_hi | rj_lo; -+ } -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case ALSL_D: { -+ printf_instr("ALSL_D\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk(), sa2()); -+ CHECK_EQ(instr_.Bit(17), 0); -+ uint8_t sa = sa2() + 1; -+ alu_out = (rj() << sa) + rk(); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case SLLI: { -+ DCHECK_EQ(instr_.Bit(17), 0); -+ if (instr_.Bits(17, 15) == 0b001) { -+ // SLLI_W -+ printf_instr("SLLI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui5()); -+ alu32_out = static_cast(rj()) << ui5(); -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ } else if ((instr_.Bits(17, 16) == 0b01)) { -+ // SLLI_D -+ printf_instr("SLLI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui6()); -+ SetResult(rd_reg(), rj() << ui6()); -+ } -+ break; -+ } -+ case SRLI: { -+ DCHECK_EQ(instr_.Bit(17), 0); -+ if (instr_.Bits(17, 15) == 0b001) { -+ // SRLI_W -+ printf_instr("SRLI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui5()); -+ alu32_out = static_cast(rj()) >> ui5(); -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ } else if (instr_.Bits(17, 16) == 0b01) { -+ // SRLI_D -+ printf_instr("SRLI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui6()); -+ SetResult(rd_reg(), rj_u() >> ui6()); -+ } -+ break; -+ } -+ case SRAI: { -+ DCHECK_EQ(instr_.Bit(17), 0); -+ if (instr_.Bits(17, 15) == 0b001) { -+ // SRAI_W -+ printf_instr("SRAI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui5()); -+ alu32_out = static_cast(rj()) >> ui5(); -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ } else if (instr_.Bits(17, 16) == 0b01) { -+ // SRAI_D -+ printf_instr("SRAI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui6()); -+ SetResult(rd_reg(), rj() >> ui6()); -+ } -+ break; -+ } -+ case ROTRI: { -+ DCHECK_EQ(instr_.Bit(17), 0); -+ if (instr_.Bits(17, 15) == 0b001) { -+ // ROTRI_W -+ printf_instr("ROTRI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui5()); -+ alu32_out = static_cast( -+ base::bits::RotateRight32(static_cast(rj_u()), -+ static_cast(ui5()))); -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ } else if (instr_.Bits(17, 16) == 0b01) { -+ // ROTRI_D -+ printf_instr("ROTRI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), ui6()); -+ alu_out = -+ static_cast(base::bits::RotateRight64(rj_u(), ui6())); -+ SetResult(rd_reg(), alu_out); -+ printf_instr("ROTRI, %s, %s, %d\n", Registers::Name(rd_reg()), -+ Registers::Name(rj_reg()), ui6()); -+ } -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp17() { -+ int64_t alu_out; -+ -+ switch (instr_.Bits(31, 15) << 15) { -+ case ADD_W: { -+ printf_instr("ADD_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int32_t alu32_out = static_cast(rj() + rk()); -+ // Sign-extend result of 32bit operation into 64bit register. -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ break; -+ } -+ case ADD_D: -+ printf_instr("ADD_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() + rk()); -+ break; -+ case SUB_W: { -+ printf_instr("SUB_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int32_t alu32_out = static_cast(rj() - rk()); -+ // Sign-extend result of 32bit operation into 64bit register. -+ SetResult(rd_reg(), static_cast(alu32_out)); -+ break; -+ } -+ case SUB_D: -+ printf_instr("SUB_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() - rk()); -+ break; -+ case SLT: -+ printf_instr("SLT\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() < rk() ? 1 : 0); -+ break; -+ case SLTU: -+ printf_instr("SLTU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj_u() < rk_u() ? 1 : 0); -+ break; -+ case MASKEQZ: -+ printf_instr("MASKEQZ\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rk() == 0 ? rj() : 0); -+ break; -+ case MASKNEZ: -+ printf_instr("MASKNEZ\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rk() != 0 ? rj() : 0); -+ break; -+ case NOR: -+ printf_instr("NOR\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), ~(rj() | rk())); -+ break; -+ case AND: -+ printf_instr("AND\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() & rk()); -+ break; -+ case OR: -+ printf_instr("OR\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() | rk()); -+ break; -+ case XOR: -+ printf_instr("XOR\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() ^ rk()); -+ break; -+ case ORN: -+ printf_instr("ORN\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() | (~rk())); -+ break; -+ case ANDN: -+ printf_instr("ANDN\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() & (~rk())); -+ break; -+ case SLL_W: -+ printf_instr("SLL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), (int32_t)rj() << (rk_u() % 32)); -+ break; -+ case SRL_W: { -+ printf_instr("SRL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ alu_out = static_cast((uint32_t)rj_u() >> (rk_u() % 32)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case SRA_W: -+ printf_instr("SRA_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), (int32_t)rj() >> (rk_u() % 32)); -+ break; -+ case SLL_D: -+ printf_instr("SLL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() << (rk_u() % 64)); -+ break; -+ case SRL_D: { -+ printf_instr("SRL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ alu_out = static_cast(rj_u() >> (rk_u() % 64)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case SRA_D: -+ printf_instr("SRA_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() >> (rk_u() % 64)); -+ break; -+ case ROTR_W: { -+ printf_instr("ROTR_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ alu_out = static_cast( -+ base::bits::RotateRight32(static_cast(rj_u()), -+ static_cast(rk_u() % 32))); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case ROTR_D: { -+ printf_instr("ROTR_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ alu_out = static_cast( -+ base::bits::RotateRight64((rj_u()), (rk_u() % 64))); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case MUL_W: { -+ printf_instr("MUL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ alu_out = static_cast(rj()) * static_cast(rk()); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case MULH_W: { -+ printf_instr("MULH_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int32_t rj_lo = static_cast(rj()); -+ int32_t rk_lo = static_cast(rk()); -+ alu_out = static_cast(rj_lo) * static_cast(rk_lo); -+ SetResult(rd_reg(), alu_out >> 32); -+ break; -+ } -+ case MULH_WU: { -+ printf_instr("MULH_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ uint32_t rj_lo = static_cast(rj_u()); -+ uint32_t rk_lo = static_cast(rk_u()); -+ alu_out = static_cast(rj_lo) * static_cast(rk_lo); -+ SetResult(rd_reg(), alu_out >> 32); -+ break; -+ } -+ case MUL_D: -+ printf_instr("MUL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), rj() * rk()); -+ break; -+ case MULH_D: -+ printf_instr("MULH_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), MultiplyHighSigned(rj(), rk())); -+ break; -+ case MULH_DU: -+ printf_instr("MULH_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ SetResult(rd_reg(), MultiplyHighUnsigned(rj_u(), rk_u())); -+ break; -+ case MULW_D_W: { -+ printf_instr("MULW_D_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int64_t rj_i32 = static_cast(rj()); -+ int64_t rk_i32 = static_cast(rk()); -+ SetResult(rd_reg(), rj_i32 * rk_i32); -+ break; -+ } -+ case MULW_D_WU: { -+ printf_instr("MULW_D_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ uint64_t rj_u32 = static_cast(rj_u()); -+ uint64_t rk_u32 = static_cast(rk_u()); -+ SetResult(rd_reg(), rj_u32 * rk_u32); -+ break; -+ } -+ case DIV_W: { -+ printf_instr("DIV_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int32_t rj_i32 = static_cast(rj()); -+ int32_t rk_i32 = static_cast(rk()); -+ if (rj_i32 == INT_MIN && rk_i32 == -1) { -+ SetResult(rd_reg(), INT_MIN); -+ } else if (rk_i32 != 0) { -+ SetResult(rd_reg(), rj_i32 / rk_i32); -+ } -+ break; -+ } -+ case MOD_W: { -+ printf_instr("MOD_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ int32_t rj_i32 = static_cast(rj()); -+ int32_t rk_i32 = static_cast(rk()); -+ if (rj_i32 == INT_MIN && rk_i32 == -1) { -+ SetResult(rd_reg(), 0); -+ } else if (rk_i32 != 0) { -+ SetResult(rd_reg(), rj_i32 % rk_i32); -+ } -+ break; -+ } -+ case DIV_WU: { -+ printf_instr("DIV_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ uint32_t rj_u32 = static_cast(rj()); -+ uint32_t rk_u32 = static_cast(rk()); -+ if (rk_u32 != 0) { -+ SetResult(rd_reg(), static_cast(rj_u32 / rk_u32)); -+ } -+ break; -+ } -+ case MOD_WU: { -+ printf_instr("MOD_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ uint32_t rj_u32 = static_cast(rj()); -+ uint32_t rk_u32 = static_cast(rk()); -+ if (rk_u32 != 0) { -+ SetResult(rd_reg(), static_cast(rj_u32 % rk_u32)); -+ } -+ break; -+ } -+ case DIV_D: { -+ printf_instr("DIV_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ if (rj() == LONG_MIN && rk() == -1) { -+ SetResult(rd_reg(), LONG_MIN); -+ } else if (rk() != 0) { -+ SetResult(rd_reg(), rj() / rk()); -+ } -+ break; -+ } -+ case MOD_D: { -+ printf_instr("MOD_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ if (rj() == LONG_MIN && rk() == -1) { -+ SetResult(rd_reg(), 0); -+ } else if (rk() != 0) { -+ SetResult(rd_reg(), rj() % rk()); -+ } -+ break; -+ } -+ case DIV_DU: { -+ printf_instr("DIV_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ if (rk_u() != 0) { -+ SetResult(rd_reg(), static_cast(rj_u() / rk_u())); -+ } -+ break; -+ } -+ case MOD_DU: { -+ printf_instr("MOD_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ if (rk_u() != 0) { -+ SetResult(rd_reg(), static_cast(rj_u() % rk_u())); -+ } -+ break; -+ } -+ case BREAK: -+ printf_instr("BREAK\t code: %x\n", instr_.Bits(14, 0)); -+ SoftwareInterrupt(); -+ break; -+ case FADD_S: { -+ printf_instr("FADD_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult( -+ fd_reg(), -+ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs + rhs; }, -+ fj_float(), fk_float())); -+ break; -+ } -+ case FADD_D: { -+ printf_instr("FADD_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), -+ FPUCanonalizeOperation( -+ [](double lhs, double rhs) { return lhs + rhs; }, -+ fj_double(), fk_double())); -+ break; -+ } -+ case FSUB_S: { -+ printf_instr("FSUB_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult( -+ fd_reg(), -+ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs - rhs; }, -+ fj_float(), fk_float())); -+ break; -+ } -+ case FSUB_D: { -+ printf_instr("FSUB_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), -+ FPUCanonalizeOperation( -+ [](double lhs, double rhs) { return lhs - rhs; }, -+ fj_double(), fk_double())); -+ break; -+ } -+ case FMUL_S: { -+ printf_instr("FMUL_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult( -+ fd_reg(), -+ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs * rhs; }, -+ fj_float(), fk_float())); -+ break; -+ } -+ case FMUL_D: { -+ printf_instr("FMUL_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), -+ FPUCanonalizeOperation( -+ [](double lhs, double rhs) { return lhs * rhs; }, -+ fj_double(), fk_double())); -+ break; -+ } -+ case FDIV_S: { -+ printf_instr("FDIV_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult( -+ fd_reg(), -+ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs / rhs; }, -+ fj_float(), fk_float())); -+ break; -+ } -+ case FDIV_D: { -+ printf_instr("FDIV_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), -+ FPUCanonalizeOperation( -+ [](double lhs, double rhs) { return lhs / rhs; }, -+ fj_double(), fk_double())); -+ break; -+ } -+ case FMAX_S: -+ printf_instr("FMAX_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult(fd_reg(), FPUMax(fk_float(), fj_float())); -+ break; -+ case FMAX_D: -+ printf_instr("FMAX_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), FPUMax(fk_double(), fj_double())); -+ break; -+ case FMIN_S: -+ printf_instr("FMIN_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult(fd_reg(), FPUMin(fk_float(), fj_float())); -+ break; -+ case FMIN_D: -+ printf_instr("FMIN_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), FPUMin(fk_double(), fj_double())); -+ break; -+ case FMAXA_S: -+ printf_instr("FMAXA_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult(fd_reg(), FPUMaxA(fk_float(), fj_float())); -+ break; -+ case FMAXA_D: -+ printf_instr("FMAXA_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), FPUMaxA(fk_double(), fj_double())); -+ break; -+ case FMINA_S: -+ printf_instr("FMINA_S\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float(), -+ FPURegisters::Name(fk_reg()), fk_float()); -+ SetFPUFloatResult(fd_reg(), FPUMinA(fk_float(), fj_float())); -+ break; -+ case FMINA_D: -+ printf_instr("FMINA_D\t %s: %016f, %s, %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double(), -+ FPURegisters::Name(fk_reg()), fk_double()); -+ SetFPUDoubleResult(fd_reg(), FPUMinA(fk_double(), fj_double())); -+ break; -+ case LDX_B: -+ printf_instr("LDX_B\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadB(rj() + rk())); -+ break; -+ case LDX_H: -+ printf_instr("LDX_H\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadH(rj() + rk(), instr_.instr())); -+ break; -+ case LDX_W: -+ printf_instr("LDX_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadW(rj() + rk(), instr_.instr())); -+ break; -+ case LDX_D: -+ printf_instr("LDX_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), Read2W(rj() + rk(), instr_.instr())); -+ break; -+ case STX_B: -+ printf_instr("STX_B\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ WriteB(rj() + rk(), static_cast(rd())); -+ break; -+ case STX_H: -+ printf_instr("STX_H\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ WriteH(rj() + rk(), static_cast(rd()), instr_.instr()); -+ break; -+ case STX_W: -+ printf_instr("STX_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ WriteW(rj() + rk(), static_cast(rd()), instr_.instr()); -+ break; -+ case STX_D: -+ printf_instr("STX_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ Write2W(rj() + rk(), rd(), instr_.instr()); -+ break; -+ case LDX_BU: -+ printf_instr("LDX_BU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadBU(rj() + rk())); -+ break; -+ case LDX_HU: -+ printf_instr("LDX_HU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadHU(rj() + rk(), instr_.instr())); -+ break; -+ case LDX_WU: -+ printf_instr("LDX_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj(), Registers::Name(rk_reg()), rk()); -+ set_register(rd_reg(), ReadWU(rj() + rk(), instr_.instr())); -+ break; -+ case FLDX_S: -+ printf_instr("FLDX_S\t %s: %016f, %s: %016lx, %s: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), -+ rk()); -+ set_fpu_register(fd_reg(), kFPUInvalidResult); // Trash upper 32 bits. -+ set_fpu_register_word(fd_reg(), -+ ReadW(rj() + rk(), instr_.instr(), FLOAT_DOUBLE)); -+ break; -+ case FLDX_D: -+ printf_instr("FLDX_D\t %s: %016f, %s: %016lx, %s: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), -+ rk()); -+ set_fpu_register_double(fd_reg(), ReadD(rj() + rk(), instr_.instr())); -+ break; -+ case FSTX_S: -+ printf_instr("FSTX_S\t %s: %016f, %s: %016lx, %s: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), -+ rk()); -+ WriteW(rj() + rk(), static_cast(get_fpu_register(fd_reg())), -+ instr_.instr()); -+ break; -+ case FSTX_D: -+ printf_instr("FSTX_D\t %s: %016f, %s: %016lx, %s: %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), -+ rk()); -+ WriteD(rj() + rk(), get_fpu_register_double(fd_reg()), instr_.instr()); -+ break; -+ case AMSWAP_W: -+ printf("Sim UNIMPLEMENTED: AMSWAP_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMSWAP_D: -+ printf("Sim UNIMPLEMENTED: AMSWAP_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMADD_W: -+ printf("Sim UNIMPLEMENTED: AMADD_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMADD_D: -+ printf("Sim UNIMPLEMENTED: AMADD_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMAND_W: -+ printf("Sim UNIMPLEMENTED: AMAND_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMAND_D: -+ printf("Sim UNIMPLEMENTED: AMAND_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMOR_W: -+ printf("Sim UNIMPLEMENTED: AMOR_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMOR_D: -+ printf("Sim UNIMPLEMENTED: AMOR_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMXOR_W: -+ printf("Sim UNIMPLEMENTED: AMXOR_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMXOR_D: -+ printf("Sim UNIMPLEMENTED: AMXOR_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_W: -+ printf("Sim UNIMPLEMENTED: AMMAX_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_D: -+ printf("Sim UNIMPLEMENTED: AMMAX_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_W: -+ printf("Sim UNIMPLEMENTED: AMMIN_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_D: -+ printf("Sim UNIMPLEMENTED: AMMIN_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_WU: -+ printf("Sim UNIMPLEMENTED: AMMAX_WU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_DU: -+ printf("Sim UNIMPLEMENTED: AMMAX_DU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_WU: -+ printf("Sim UNIMPLEMENTED: AMMIN_WU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_DU: -+ printf("Sim UNIMPLEMENTED: AMMIN_DU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMSWAP_DB_W: { -+ printf_instr("AMSWAP_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int32_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), ReadW(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditionalW(rj(), static_cast(rk()), instr_.instr(), -+ rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMSWAP_DB_D: { -+ printf_instr("AMSWAP_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int64_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), Read2W(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditional2W(rj(), rk(), instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMADD_DB_W: { -+ printf_instr("AMADD_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int32_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), ReadW(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditionalW(rj(), -+ static_cast(static_cast(rk()) + -+ static_cast(rd())), -+ instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMADD_DB_D: { -+ printf_instr("AMADD_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int64_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), Read2W(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditional2W(rj(), rk() + rd(), instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMAND_DB_W: { -+ printf_instr("AMAND_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int32_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), ReadW(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditionalW(rj(), -+ static_cast(static_cast(rk()) & -+ static_cast(rd())), -+ instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMAND_DB_D: { -+ printf_instr("AMAND_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int64_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), Read2W(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditional2W(rj(), rk() & rd(), instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMOR_DB_W: { -+ printf_instr("AMOR_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int32_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), ReadW(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditionalW(rj(), -+ static_cast(static_cast(rk()) | -+ static_cast(rd())), -+ instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMOR_DB_D: { -+ printf_instr("AMOR_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int64_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), Read2W(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditional2W(rj(), rk() | rd(), instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMXOR_DB_W: { -+ printf_instr("AMXOR_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int32_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), ReadW(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditionalW(rj(), -+ static_cast(static_cast(rk()) ^ -+ static_cast(rd())), -+ instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMXOR_DB_D: { -+ printf_instr("AMXOR_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), -+ rk(), Registers::Name(rj_reg()), rj()); -+ int64_t rdvalue; -+ do { -+ { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ set_register(rd_reg(), Read2W(rj(), instr_.instr())); -+ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked( -+ rj(), &global_monitor_thread_); -+ } -+ rdvalue = get_register(rd_reg()); -+ WriteConditional2W(rj(), rk() ^ rd(), instr_.instr(), rd_reg()); -+ } while (!get_register(rd_reg())); -+ set_register(rd_reg(), rdvalue); -+ } break; -+ case AMMAX_DB_W: -+ printf("Sim UNIMPLEMENTED: AMMAX_DB_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_DB_D: -+ printf("Sim UNIMPLEMENTED: AMMAX_DB_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_DB_W: -+ printf("Sim UNIMPLEMENTED: AMMIN_DB_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_DB_D: -+ printf("Sim UNIMPLEMENTED: AMMIN_DB_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_DB_WU: -+ printf("Sim UNIMPLEMENTED: AMMAX_DB_WU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMAX_DB_DU: -+ printf("Sim UNIMPLEMENTED: AMMAX_DB_DU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_DB_WU: -+ printf("Sim UNIMPLEMENTED: AMMIN_DB_WU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case AMMIN_DB_DU: -+ printf("Sim UNIMPLEMENTED: AMMIN_DB_DU\n"); -+ UNIMPLEMENTED(); -+ break; -+ case DBAR: -+ printf_instr("DBAR\n"); -+ break; -+ case IBAR: -+ printf("Sim UNIMPLEMENTED: IBAR\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FSCALEB_S: -+ printf("Sim UNIMPLEMENTED: FSCALEB_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FSCALEB_D: -+ printf("Sim UNIMPLEMENTED: FSCALEB_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FCOPYSIGN_S: -+ printf("Sim UNIMPLEMENTED: FCOPYSIGN_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FCOPYSIGN_D: -+ printf("Sim UNIMPLEMENTED: FCOPYSIGN_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void Simulator::DecodeTypeOp22() { -+ int64_t alu_out; -+ -+ switch (instr_.Bits(31, 10) << 10) { -+ case CLZ_W: { -+ printf_instr("CLZ_W\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ alu_out = base::bits::CountLeadingZeros32(static_cast(rj_u())); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case CTZ_W: { -+ printf_instr("CTZ_W\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ alu_out = base::bits::CountTrailingZeros32(static_cast(rj_u())); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case CLZ_D: { -+ printf_instr("CLZ_D\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ alu_out = base::bits::CountLeadingZeros64(static_cast(rj_u())); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case CTZ_D: { -+ printf_instr("CTZ_D\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ alu_out = base::bits::CountTrailingZeros64(static_cast(rj_u())); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVB_2H: { -+ printf_instr("REVB_2H\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint32_t input = static_cast(rj()); -+ uint64_t output = 0; -+ -+ uint32_t mask = 0xFF000000; -+ for (int i = 0; i < 4; i++) { -+ uint32_t tmp = mask & input; -+ if (i % 2 == 0) { -+ tmp = tmp >> 8; -+ } else { -+ tmp = tmp << 8; -+ } -+ output = output | tmp; -+ mask = mask >> 8; -+ } -+ -+ alu_out = static_cast(static_cast(output)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVB_4H: { -+ printf_instr("REVB_4H\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ -+ uint64_t mask = 0xFF00000000000000; -+ for (int i = 0; i < 8; i++) { -+ uint64_t tmp = mask & input; -+ if (i % 2 == 0) { -+ tmp = tmp >> 8; -+ } else { -+ tmp = tmp << 8; -+ } -+ output = output | tmp; -+ mask = mask >> 8; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVB_2W: { -+ printf_instr("REVB_2W\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ -+ uint64_t mask = 0xFF000000FF000000; -+ for (int i = 0; i < 4; i++) { -+ uint64_t tmp = mask & input; -+ if (i <= 1) { -+ tmp = tmp >> (24 - i * 16); -+ } else { -+ tmp = tmp << (i * 16 - 24); -+ } -+ output = output | tmp; -+ mask = mask >> 8; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVB_D: { -+ printf_instr("REVB_D\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ -+ uint64_t mask = 0xFF00000000000000; -+ for (int i = 0; i < 8; i++) { -+ uint64_t tmp = mask & input; -+ if (i <= 3) { -+ tmp = tmp >> (56 - i * 16); -+ } else { -+ tmp = tmp << (i * 16 - 56); -+ } -+ output = output | tmp; -+ mask = mask >> 8; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVH_2W: { -+ printf_instr("REVH_2W\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ -+ uint64_t mask = 0xFFFF000000000000; -+ for (int i = 0; i < 4; i++) { -+ uint64_t tmp = mask & input; -+ if (i % 2 == 0) { -+ tmp = tmp >> 16; -+ } else { -+ tmp = tmp << 16; -+ } -+ output = output | tmp; -+ mask = mask >> 16; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case REVH_D: { -+ printf_instr("REVH_D\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ -+ uint64_t mask = 0xFFFF000000000000; -+ for (int i = 0; i < 4; i++) { -+ uint64_t tmp = mask & input; -+ if (i <= 1) { -+ tmp = tmp >> (48 - i * 32); -+ } else { -+ tmp = tmp << (i * 32 - 48); -+ } -+ output = output | tmp; -+ mask = mask >> 16; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BITREV_4B: { -+ printf_instr("BITREV_4B\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint32_t input = static_cast(rj()); -+ uint32_t output = 0; -+ uint8_t i_byte, o_byte; -+ -+ // Reverse the bit in byte for each individual byte -+ for (int i = 0; i < 4; i++) { -+ output = output >> 8; -+ i_byte = input & 0xFF; -+ -+ // Fast way to reverse bits in byte -+ // Devised by Sean Anderson, July 13, 2001 -+ o_byte = static_cast(((i_byte * 0x0802LU & 0x22110LU) | -+ (i_byte * 0x8020LU & 0x88440LU)) * -+ 0x10101LU >> -+ 16); -+ -+ output = output | (static_cast(o_byte << 24)); -+ input = input >> 8; -+ } -+ -+ alu_out = static_cast(static_cast(output)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BITREV_8B: { -+ printf_instr("BITREV_8B\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint64_t input = rj_u(); -+ uint64_t output = 0; -+ uint8_t i_byte, o_byte; -+ -+ // Reverse the bit in byte for each individual byte -+ for (int i = 0; i < 8; i++) { -+ output = output >> 8; -+ i_byte = input & 0xFF; -+ -+ // Fast way to reverse bits in byte -+ // Devised by Sean Anderson, July 13, 2001 -+ o_byte = static_cast(((i_byte * 0x0802LU & 0x22110LU) | -+ (i_byte * 0x8020LU & 0x88440LU)) * -+ 0x10101LU >> -+ 16); -+ -+ output = output | (static_cast(o_byte) << 56); -+ input = input >> 8; -+ } -+ -+ alu_out = static_cast(output); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BITREV_W: { -+ printf_instr("BITREV_W\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint32_t input = static_cast(rj()); -+ uint32_t output = 0; -+ output = base::bits::ReverseBits(input); -+ alu_out = static_cast(static_cast(output)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case BITREV_D: { -+ printf_instr("BITREV_D\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ alu_out = static_cast(base::bits::ReverseBits(rj_u())); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case EXT_W_B: { -+ printf_instr("EXT_W_B\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint8_t input = static_cast(rj()); -+ alu_out = static_cast(static_cast(input)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case EXT_W_H: { -+ printf_instr("EXT_W_H\t %s: %016lx, %s, %016lx\n", -+ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), -+ rj()); -+ uint16_t input = static_cast(rj()); -+ alu_out = static_cast(static_cast(input)); -+ SetResult(rd_reg(), alu_out); -+ break; -+ } -+ case FABS_S: -+ printf_instr("FABS_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), std::abs(fj_float())); -+ break; -+ case FABS_D: -+ printf_instr("FABS_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), std::abs(fj_double())); -+ break; -+ case FNEG_S: -+ printf_instr("FNEG_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), -fj_float()); -+ break; -+ case FNEG_D: -+ printf_instr("FNEG_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUDoubleResult(fd_reg(), -fj_double()); -+ break; -+ case FSQRT_S: { -+ printf_instr("FSQRT_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ if (fj_float() >= 0) { -+ SetFPUFloatResult(fd_reg(), std::sqrt(fj_float())); -+ } else { -+ SetFPUFloatResult(fd_reg(), std::sqrt(-1)); // qnan -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ } -+ break; -+ } -+ case FSQRT_D: { -+ printf_instr("FSQRT_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ if (fj_double() >= 0) { -+ SetFPUDoubleResult(fd_reg(), std::sqrt(fj_double())); -+ } else { -+ SetFPUDoubleResult(fd_reg(), std::sqrt(-1)); // qnan -+ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); -+ } -+ break; -+ } -+ case FMOV_S: -+ printf_instr("FMOV_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUFloatResult(fd_reg(), fj_float()); -+ break; -+ case FMOV_D: -+ printf_instr("FMOV_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_float(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUDoubleResult(fd_reg(), fj_double()); -+ break; -+ case MOVGR2FR_W: { -+ printf_instr("MOVGR2FR_W\t %s: %016f, %s, %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj()); -+ set_fpu_register_word(fd_reg(), static_cast(rj())); -+ TraceRegWr(get_fpu_register(fd_reg()), FLOAT_DOUBLE); -+ break; -+ } -+ case MOVGR2FR_D: -+ printf_instr("MOVGR2FR_D\t %s: %016f, %s, %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj()); -+ SetFPUResult2(fd_reg(), rj()); -+ break; -+ case MOVGR2FRH_W: { -+ printf_instr("MOVGR2FRH_W\t %s: %016f, %s, %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ Registers::Name(rj_reg()), rj()); -+ set_fpu_register_hi_word(fd_reg(), static_cast(rj())); -+ TraceRegWr(get_fpu_register(fd_reg()), DOUBLE); -+ break; -+ } -+ case MOVFR2GR_S: { -+ printf_instr("MOVFR2GR_S\t %s: %016lx, %s, %016f\n", -+ Registers::Name(rd_reg()), rd(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ set_register(rd_reg(), -+ static_cast(get_fpu_register_word(fj_reg()))); -+ TraceRegWr(get_register(rd_reg()), WORD_DWORD); -+ break; -+ } -+ case MOVFR2GR_D: -+ printf_instr("MOVFR2GR_D\t %s: %016lx, %s, %016f\n", -+ Registers::Name(rd_reg()), rd(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetResult(rd_reg(), get_fpu_register(fj_reg())); -+ break; -+ case MOVFRH2GR_S: -+ printf_instr("MOVFRH2GR_S\t %s: %016lx, %s, %016f\n", -+ Registers::Name(rd_reg()), rd(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetResult(rd_reg(), get_fpu_register_hi_word(fj_reg())); -+ break; -+ case MOVGR2FCSR: { -+ printf_instr("MOVGR2FCSR\t fcsr: %016x, %s, %016lx\n", FCSR_, -+ Registers::Name(rj_reg()), rj()); -+ // fcsr could be 0-3 -+ CHECK_LT(rd_reg(), 4); -+ FCSR_ = static_cast(rj()); -+ TraceRegWr(FCSR_); -+ break; -+ } -+ case MOVFCSR2GR: { -+ printf_instr("MOVFCSR2GR\t %s, %016lx, FCSR: %016x\n", -+ Registers::Name(rd_reg()), rd(), FCSR_); -+ // fcsr could be 0-3 -+ CHECK_LT(rj_reg(), 4); -+ SetResult(rd_reg(), FCSR_); -+ break; -+ } -+ case FCVT_S_D: -+ printf_instr("FCVT_S_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ SetFPUFloatResult(fd_reg(), static_cast(fj_double())); -+ break; -+ case FCVT_D_S: -+ printf_instr("FCVT_D_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ SetFPUDoubleResult(fd_reg(), static_cast(fj_float())); -+ break; -+ case FTINTRM_W_S: { -+ printf_instr("FTINTRM_W_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::floor(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRM_W_D: { -+ printf_instr("FTINTRM_W_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::floor(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRM_L_S: { -+ printf_instr("FTINTRM_L_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::floor(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRM_L_D: { -+ printf_instr("FTINTRM_L_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::floor(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRP_W_S: { -+ printf_instr("FTINTRP_W_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::ceil(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRP_W_D: { -+ printf_instr("FTINTRP_W_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::ceil(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRP_L_S: { -+ printf_instr("FTINTRP_L_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::ceil(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRP_L_D: { -+ printf_instr("FTINTRP_L_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::ceil(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRZ_W_S: { -+ printf_instr("FTINTRZ_W_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::trunc(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRZ_W_D: { -+ printf_instr("FTINTRZ_W_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::trunc(fj); -+ int32_t result = static_cast(rounded); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRZ_L_S: { -+ printf_instr("FTINTRZ_L_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::trunc(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRZ_L_D: { -+ printf_instr("FTINTRZ_L_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::trunc(fj); -+ int64_t result = static_cast(rounded); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRNE_W_S: { -+ printf_instr("FTINTRNE_W_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::floor(fj + 0.5); -+ int32_t result = static_cast(rounded); -+ if ((result & 1) != 0 && result - fj == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ result--; -+ } -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRNE_W_D: { -+ printf_instr("FTINTRNE_W_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::floor(fj + 0.5); -+ int32_t result = static_cast(rounded); -+ if ((result & 1) != 0 && result - fj == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ result--; -+ } -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRNE_L_S: { -+ printf_instr("FTINTRNE_L_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded = std::floor(fj + 0.5); -+ int64_t result = static_cast(rounded); -+ if ((result & 1) != 0 && result - fj == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ result--; -+ } -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINTRNE_L_D: { -+ printf_instr("FTINTRNE_L_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded = std::floor(fj + 0.5); -+ int64_t result = static_cast(rounded); -+ if ((result & 1) != 0 && result - fj == 0.5) { -+ // If the number is halfway between two integers, -+ // round to the even one. -+ result--; -+ } -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINT_W_S: { -+ printf_instr("FTINT_W_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded; -+ int32_t result; -+ round_according_to_fcsr(fj, &rounded, &result); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINT_W_D: { -+ printf_instr("FTINT_W_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded; -+ int32_t result; -+ round_according_to_fcsr(fj, &rounded, &result); -+ SetFPUWordResult(fd_reg(), result); -+ if (set_fcsr_round_error(fj, rounded)) { -+ set_fpu_register_word_invalid_result(fj, rounded); -+ } -+ break; -+ } -+ case FTINT_L_S: { -+ printf_instr("FTINT_L_S\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float rounded; -+ int64_t result; -+ round64_according_to_fcsr(fj, &rounded, &result); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FTINT_L_D: { -+ printf_instr("FTINT_L_D\t %s: %016f, %s, %016f\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double rounded; -+ int64_t result; -+ round64_according_to_fcsr(fj, &rounded, &result); -+ SetFPUResult(fd_reg(), result); -+ if (set_fcsr_round64_error(fj, rounded)) { -+ set_fpu_register_invalid_result64(fj, rounded); -+ } -+ break; -+ } -+ case FFINT_S_W: { -+ alu_out = get_fpu_register_signed_word(fj_reg()); -+ printf_instr("FFINT_S_W\t %s: %016f, %s, %016x\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), (int)alu_out); -+ SetFPUFloatResult(fd_reg(), static_cast(alu_out)); -+ break; -+ } -+ case FFINT_S_L: { -+ alu_out = get_fpu_register(fj_reg()); -+ printf_instr("FFINT_S_L\t %s: %016f, %s, %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), alu_out); -+ SetFPUFloatResult(fd_reg(), static_cast(alu_out)); -+ break; -+ } -+ case FFINT_D_W: { -+ alu_out = get_fpu_register_signed_word(fj_reg()); -+ printf_instr("FFINT_D_W\t %s: %016f, %s, %016x\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), (int)alu_out); -+ SetFPUDoubleResult(fd_reg(), static_cast(alu_out)); -+ break; -+ } -+ case FFINT_D_L: { -+ alu_out = get_fpu_register(fj_reg()); -+ printf_instr("FFINT_D_L\t %s: %016f, %s, %016lx\n", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), alu_out); -+ SetFPUDoubleResult(fd_reg(), static_cast(alu_out)); -+ break; -+ } -+ case FRINT_S: { -+ printf_instr("FRINT_S\t %s: %016f, %s, %016f mode : ", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_float()); -+ float fj = fj_float(); -+ float result, temp_result; -+ double temp; -+ float upper = std::ceil(fj); -+ float lower = std::floor(fj); -+ switch (get_fcsr_rounding_mode()) { -+ case kRoundToNearest: -+ printf_instr(" kRoundToNearest\n"); -+ if (upper - fj < fj - lower) { -+ result = upper; -+ } else if (upper - fj > fj - lower) { -+ result = lower; -+ } else { -+ temp_result = upper / 2; -+ float reminder = std::modf(temp_result, &temp); -+ if (reminder == 0) { -+ result = upper; -+ } else { -+ result = lower; -+ } -+ } -+ break; -+ case kRoundToZero: -+ printf_instr(" kRoundToZero\n"); -+ result = (fj > 0 ? lower : upper); -+ break; -+ case kRoundToPlusInf: -+ printf_instr(" kRoundToPlusInf\n"); -+ result = upper; -+ break; -+ case kRoundToMinusInf: -+ printf_instr(" kRoundToMinusInf\n"); -+ result = lower; -+ break; -+ } -+ SetFPUFloatResult(fd_reg(), result); -+ if (result != fj) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ break; -+ } -+ case FRINT_D: { -+ printf_instr("FRINT_D\t %s: %016f, %s, %016f mode : ", -+ FPURegisters::Name(fd_reg()), fd_double(), -+ FPURegisters::Name(fj_reg()), fj_double()); -+ double fj = fj_double(); -+ double result, temp, temp_result; -+ double upper = std::ceil(fj); -+ double lower = std::floor(fj); -+ switch (get_fcsr_rounding_mode()) { -+ case kRoundToNearest: -+ printf_instr(" kRoundToNearest\n"); -+ if (upper - fj < fj - lower) { -+ result = upper; -+ } else if (upper - fj > fj - lower) { -+ result = lower; -+ } else { -+ temp_result = upper / 2; -+ double reminder = std::modf(temp_result, &temp); -+ if (reminder == 0) { -+ result = upper; -+ } else { -+ result = lower; -+ } -+ } -+ break; -+ case kRoundToZero: -+ printf_instr(" kRoundToZero\n"); -+ result = (fj > 0 ? lower : upper); -+ break; -+ case kRoundToPlusInf: -+ printf_instr(" kRoundToPlusInf\n"); -+ result = upper; -+ break; -+ case kRoundToMinusInf: -+ printf_instr(" kRoundToMinusInf\n"); -+ result = lower; -+ break; -+ } -+ SetFPUDoubleResult(fd_reg(), result); -+ if (result != fj) { -+ set_fcsr_bit(kFCSRInexactFlagBit, true); -+ } -+ break; -+ } -+ case MOVFR2CF: -+ printf("Sim UNIMPLEMENTED: MOVFR2CF\n"); -+ UNIMPLEMENTED(); -+ break; -+ case MOVCF2FR: -+ printf("Sim UNIMPLEMENTED: MOVCF2FR\n"); -+ UNIMPLEMENTED(); -+ break; -+ case MOVGR2CF: -+ printf_instr("MOVGR2CF\t FCC%d, %s: %016lx\n", cd_reg(), -+ Registers::Name(rj_reg()), rj()); -+ set_cf_register(cd_reg(), rj() & 1); -+ break; -+ case MOVCF2GR: -+ printf_instr("MOVCF2GR\t %s: %016lx, FCC%d\n", Registers::Name(rd_reg()), -+ rd(), cj_reg()); -+ SetResult(rd_reg(), cj()); -+ break; -+ case FRECIP_S: -+ printf("Sim UNIMPLEMENTED: FRECIP_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FRECIP_D: -+ printf("Sim UNIMPLEMENTED: FRECIP_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FRSQRT_S: -+ printf("Sim UNIMPLEMENTED: FRSQRT_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FRSQRT_D: -+ printf("Sim UNIMPLEMENTED: FRSQRT_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FCLASS_S: -+ printf("Sim UNIMPLEMENTED: FCLASS_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FCLASS_D: -+ printf("Sim UNIMPLEMENTED: FCLASS_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FLOGB_S: -+ printf("Sim UNIMPLEMENTED: FLOGB_S\n"); -+ UNIMPLEMENTED(); -+ break; -+ case FLOGB_D: -+ printf("Sim UNIMPLEMENTED: FLOGB_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case CLO_W: -+ printf("Sim UNIMPLEMENTED: CLO_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case CTO_W: -+ printf("Sim UNIMPLEMENTED: CTO_W\n"); -+ UNIMPLEMENTED(); -+ break; -+ case CLO_D: -+ printf("Sim UNIMPLEMENTED: CLO_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ case CTO_D: -+ printf("Sim UNIMPLEMENTED: CTO_D\n"); -+ UNIMPLEMENTED(); -+ break; -+ // Unimplemented opcodes raised an error in the configuration step before, -+ // so we can use the default here to set the destination register in common -+ // cases. -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+// Executes the current instruction. -+void Simulator::InstructionDecode(Instruction* instr) { -+ if (v8::internal::FLAG_check_icache) { -+ CheckICache(i_cache(), instr); -+ } -+ pc_modified_ = false; -+ -+ v8::internal::EmbeddedVector buffer; -+ -+ if (::v8::internal::FLAG_trace_sim) { -+ SNPrintF(trace_buf_, " "); -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ dasm.InstructionDecode(buffer, reinterpret_cast(instr)); -+ } -+ -+ static int instr_count = 0; -+ USE(instr_count); -+ instr_ = instr; -+ printf_instr("\nInstr%3d: %08x, PC: %016lx\t", instr_count++, -+ instr_.Bits(31, 0), get_pc()); -+ switch (instr_.InstructionType()) { -+ case Instruction::kOp6Type: -+ DecodeTypeOp6(); -+ break; -+ case Instruction::kOp7Type: -+ DecodeTypeOp7(); -+ break; -+ case Instruction::kOp8Type: -+ DecodeTypeOp8(); -+ break; -+ case Instruction::kOp10Type: -+ DecodeTypeOp10(); -+ break; -+ case Instruction::kOp12Type: -+ DecodeTypeOp12(); -+ break; -+ case Instruction::kOp14Type: -+ DecodeTypeOp14(); -+ break; -+ case Instruction::kOp17Type: -+ DecodeTypeOp17(); -+ break; -+ case Instruction::kOp22Type: -+ DecodeTypeOp22(); -+ break; -+ default: { -+ printf("instr_: %x\n", instr_.Bits(31, 0)); -+ UNREACHABLE(); -+ } -+ } -+ -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF(" 0x%08" PRIxPTR " %-44s %s\n", -+ reinterpret_cast(instr), buffer.begin(), -+ trace_buf_.begin()); -+ } -+ -+ if (!pc_modified_) { -+ set_register(pc, reinterpret_cast(instr) + kInstrSize); -+ } -+} -+ -+void Simulator::Execute() { -+ // Get the PC to simulate. Cannot use the accessor here as we need the -+ // raw PC value and not the one used as input to arithmetic instructions. -+ int64_t program_counter = get_pc(); -+ if (::v8::internal::FLAG_stop_sim_at == 0) { -+ // Fast version of the dispatch loop without checking whether the simulator -+ // should be stopping at a particular executed instruction. -+ while (program_counter != end_sim_pc) { -+ Instruction* instr = reinterpret_cast(program_counter); -+ icount_++; -+ InstructionDecode(instr); -+ program_counter = get_pc(); -+ } -+ } else { -+ // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when -+ // we reach the particular instruction count. -+ while (program_counter != end_sim_pc) { -+ Instruction* instr = reinterpret_cast(program_counter); -+ icount_++; -+ if (icount_ == static_cast(::v8::internal::FLAG_stop_sim_at)) { -+ La64Debugger dbg(this); -+ dbg.Debug(); -+ } else { -+ InstructionDecode(instr); -+ } -+ program_counter = get_pc(); -+ } -+ } -+} -+ -+void Simulator::CallInternal(Address entry) { -+ // Adjust JS-based stack limit to C-based stack limit. -+ isolate_->stack_guard()->AdjustStackLimitForSimulator(); -+ -+ // Prepare to execute the code at entry. -+ set_register(pc, static_cast(entry)); -+ // Put down marker for end of simulation. The simulator will stop simulation -+ // when the PC reaches this value. By saving the "end simulation" value into -+ // the LR the simulation stops when returning to this call point. -+ set_register(ra, end_sim_pc); -+ -+ // Remember the values of callee-saved registers. -+ int64_t s0_val = get_register(s0); -+ int64_t s1_val = get_register(s1); -+ int64_t s2_val = get_register(s2); -+ int64_t s3_val = get_register(s3); -+ int64_t s4_val = get_register(s4); -+ int64_t s5_val = get_register(s5); -+ int64_t s6_val = get_register(s6); -+ int64_t s7_val = get_register(s7); -+ int64_t s8_val = get_register(s8); -+ int64_t gp_val = get_register(gp); -+ int64_t sp_val = get_register(sp); -+ int64_t tp_val = get_register(tp); -+ int64_t fp_val = get_register(fp); -+ -+ // Set up the callee-saved registers with a known value. To be able to check -+ // that they are preserved properly across JS execution. -+ int64_t callee_saved_value = icount_; -+ set_register(s0, callee_saved_value); -+ set_register(s1, callee_saved_value); -+ set_register(s2, callee_saved_value); -+ set_register(s3, callee_saved_value); -+ set_register(s4, callee_saved_value); -+ set_register(s5, callee_saved_value); -+ set_register(s6, callee_saved_value); -+ set_register(s7, callee_saved_value); -+ set_register(s8, callee_saved_value); -+ set_register(gp, callee_saved_value); -+ set_register(tp, callee_saved_value); -+ set_register(fp, callee_saved_value); -+ -+ // Start the simulation. -+ Execute(); -+ -+ // Check that the callee-saved registers have been preserved. -+ CHECK_EQ(callee_saved_value, get_register(s0)); -+ CHECK_EQ(callee_saved_value, get_register(s1)); -+ CHECK_EQ(callee_saved_value, get_register(s2)); -+ CHECK_EQ(callee_saved_value, get_register(s3)); -+ CHECK_EQ(callee_saved_value, get_register(s4)); -+ CHECK_EQ(callee_saved_value, get_register(s5)); -+ CHECK_EQ(callee_saved_value, get_register(s6)); -+ CHECK_EQ(callee_saved_value, get_register(s7)); -+ CHECK_EQ(callee_saved_value, get_register(s8)); -+ CHECK_EQ(callee_saved_value, get_register(gp)); -+ CHECK_EQ(callee_saved_value, get_register(tp)); -+ CHECK_EQ(callee_saved_value, get_register(fp)); -+ -+ // Restore callee-saved registers with the original value. -+ set_register(s0, s0_val); -+ set_register(s1, s1_val); -+ set_register(s2, s2_val); -+ set_register(s3, s3_val); -+ set_register(s4, s4_val); -+ set_register(s5, s5_val); -+ set_register(s6, s6_val); -+ set_register(s7, s7_val); -+ set_register(s8, s8_val); -+ set_register(gp, gp_val); -+ set_register(sp, sp_val); -+ set_register(tp, tp_val); -+ set_register(fp, fp_val); -+} -+ -+intptr_t Simulator::CallImpl(Address entry, int argument_count, -+ const intptr_t* arguments) { -+ constexpr int kRegisterPassedArguments = 8; -+ // Set up arguments. -+ -+ int reg_arg_count = std::min(kRegisterPassedArguments, argument_count); -+ if (reg_arg_count > 0) set_register(a0, arguments[0]); -+ if (reg_arg_count > 1) set_register(a1, arguments[1]); -+ if (reg_arg_count > 2) set_register(a2, arguments[2]); -+ if (reg_arg_count > 3) set_register(a3, arguments[3]); -+ if (reg_arg_count > 4) set_register(a4, arguments[4]); -+ if (reg_arg_count > 5) set_register(a5, arguments[5]); -+ if (reg_arg_count > 6) set_register(a6, arguments[6]); -+ if (reg_arg_count > 7) set_register(a7, arguments[7]); -+ -+ // Remaining arguments passed on stack. -+ int64_t original_stack = get_register(sp); -+ // Compute position of stack on entry to generated code. -+ int stack_args_count = argument_count - reg_arg_count; -+ int stack_args_size = stack_args_count * sizeof(*arguments) + kCArgsSlotsSize; -+ int64_t entry_stack = original_stack - stack_args_size; -+ -+ if (base::OS::ActivationFrameAlignment() != 0) { -+ entry_stack &= -base::OS::ActivationFrameAlignment(); -+ } -+ // Store remaining arguments on stack, from low to high memory. -+ intptr_t* stack_argument = reinterpret_cast(entry_stack); -+ memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count, -+ stack_args_count * sizeof(*arguments)); -+ set_register(sp, entry_stack); -+ -+ CallInternal(entry); -+ -+ // Pop stack passed arguments. -+ CHECK_EQ(entry_stack, get_register(sp)); -+ set_register(sp, original_stack); -+ -+ return get_register(v0); -+} -+ -+double Simulator::CallFP(Address entry, double d0, double d1) { -+ const FPURegister fparg2 = f1; -+ set_fpu_register_double(f0, d0); -+ set_fpu_register_double(fparg2, d1); -+ CallInternal(entry); -+ return get_fpu_register_double(f0); -+} -+ -+uintptr_t Simulator::PushAddress(uintptr_t address) { -+ int64_t new_sp = get_register(sp) - sizeof(uintptr_t); -+ uintptr_t* stack_slot = reinterpret_cast(new_sp); -+ *stack_slot = address; -+ set_register(sp, new_sp); -+ return new_sp; -+} -+ -+uintptr_t Simulator::PopAddress() { -+ int64_t current_sp = get_register(sp); -+ uintptr_t* stack_slot = reinterpret_cast(current_sp); -+ uintptr_t address = *stack_slot; -+ set_register(sp, current_sp + sizeof(uintptr_t)); -+ return address; -+} -+ -+Simulator::LocalMonitor::LocalMonitor() -+ : access_state_(MonitorAccess::Open), -+ tagged_addr_(0), -+ size_(TransactionSize::None) {} -+ -+void Simulator::LocalMonitor::Clear() { -+ access_state_ = MonitorAccess::Open; -+ tagged_addr_ = 0; -+ size_ = TransactionSize::None; -+} -+ -+void Simulator::LocalMonitor::NotifyLoad() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non linked load could clear the local monitor. As a result, it's -+ // most strict to unconditionally clear the local monitor on load. -+ Clear(); -+ } -+} -+ -+void Simulator::LocalMonitor::NotifyLoadLinked(uintptr_t addr, -+ TransactionSize size) { -+ access_state_ = MonitorAccess::RMW; -+ tagged_addr_ = addr; -+ size_ = size; -+} -+ -+void Simulator::LocalMonitor::NotifyStore() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non exclusive store could clear the local monitor. As a result, it's -+ // most strict to unconditionally clear the local monitor on store. -+ Clear(); -+ } -+} -+ -+bool Simulator::LocalMonitor::NotifyStoreConditional(uintptr_t addr, -+ TransactionSize size) { -+ if (access_state_ == MonitorAccess::RMW) { -+ if (addr == tagged_addr_ && size_ == size) { -+ Clear(); -+ return true; -+ } else { -+ return false; -+ } -+ } else { -+ DCHECK(access_state_ == MonitorAccess::Open); -+ return false; -+ } -+} -+ -+Simulator::GlobalMonitor::LinkedAddress::LinkedAddress() -+ : access_state_(MonitorAccess::Open), -+ tagged_addr_(0), -+ next_(nullptr), -+ prev_(nullptr), -+ failure_counter_(0) {} -+ -+void Simulator::GlobalMonitor::LinkedAddress::Clear_Locked() { -+ access_state_ = MonitorAccess::Open; -+ tagged_addr_ = 0; -+} -+ -+void Simulator::GlobalMonitor::LinkedAddress::NotifyLoadLinked_Locked( -+ uintptr_t addr) { -+ access_state_ = MonitorAccess::RMW; -+ tagged_addr_ = addr; -+} -+ -+void Simulator::GlobalMonitor::LinkedAddress::NotifyStore_Locked() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non exclusive store could clear the global monitor. As a result, it's -+ // most strict to unconditionally clear global monitors on store. -+ Clear_Locked(); -+ } -+} -+ -+bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked( -+ uintptr_t addr, bool is_requesting_thread) { -+ if (access_state_ == MonitorAccess::RMW) { -+ if (is_requesting_thread) { -+ if (addr == tagged_addr_) { -+ Clear_Locked(); -+ // Introduce occasional sc/scd failures. This is to simulate the -+ // behavior of hardware, which can randomly fail due to background -+ // cache evictions. -+ if (failure_counter_++ >= kMaxFailureCounter) { -+ failure_counter_ = 0; -+ return false; -+ } else { -+ return true; -+ } -+ } -+ } else if ((addr & kExclusiveTaggedAddrMask) == -+ (tagged_addr_ & kExclusiveTaggedAddrMask)) { -+ // Check the masked addresses when responding to a successful lock by -+ // another thread so the implementation is more conservative (i.e. the -+ // granularity of locking is as large as possible.) -+ Clear_Locked(); -+ return false; -+ } -+ } -+ return false; -+} -+ -+void Simulator::GlobalMonitor::NotifyLoadLinked_Locked( -+ uintptr_t addr, LinkedAddress* linked_address) { -+ linked_address->NotifyLoadLinked_Locked(addr); -+ PrependProcessor_Locked(linked_address); -+} -+ -+void Simulator::GlobalMonitor::NotifyStore_Locked( -+ LinkedAddress* linked_address) { -+ // Notify each thread of the store operation. -+ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { -+ iter->NotifyStore_Locked(); -+ } -+} -+ -+bool Simulator::GlobalMonitor::NotifyStoreConditional_Locked( -+ uintptr_t addr, LinkedAddress* linked_address) { -+ DCHECK(IsProcessorInLinkedList_Locked(linked_address)); -+ if (linked_address->NotifyStoreConditional_Locked(addr, true)) { -+ // Notify the other processors that this StoreConditional succeeded. -+ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { -+ if (iter != linked_address) { -+ iter->NotifyStoreConditional_Locked(addr, false); -+ } -+ } -+ return true; -+ } else { -+ return false; -+ } -+} -+ -+bool Simulator::GlobalMonitor::IsProcessorInLinkedList_Locked( -+ LinkedAddress* linked_address) const { -+ return head_ == linked_address || linked_address->next_ || -+ linked_address->prev_; -+} -+ -+void Simulator::GlobalMonitor::PrependProcessor_Locked( -+ LinkedAddress* linked_address) { -+ if (IsProcessorInLinkedList_Locked(linked_address)) { -+ return; -+ } -+ -+ if (head_) { -+ head_->prev_ = linked_address; -+ } -+ linked_address->prev_ = nullptr; -+ linked_address->next_ = head_; -+ head_ = linked_address; -+} -+ -+void Simulator::GlobalMonitor::RemoveLinkedAddress( -+ LinkedAddress* linked_address) { -+ base::MutexGuard lock_guard(&mutex); -+ if (!IsProcessorInLinkedList_Locked(linked_address)) { -+ return; -+ } -+ -+ if (linked_address->prev_) { -+ linked_address->prev_->next_ = linked_address->next_; -+ } else { -+ head_ = linked_address->next_; -+ } -+ if (linked_address->next_) { -+ linked_address->next_->prev_ = linked_address->prev_; -+ } -+ linked_address->prev_ = nullptr; -+ linked_address->next_ = nullptr; -+} -+ -+#undef SScanF -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // USE_SIMULATOR -diff --git a/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.h b/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.h -new file mode 100644 -index 000000000..f66684e4d ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.h -@@ -0,0 +1,646 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Declares a Simulator for loongisa instructions if we are not generating a -+// native loongisa binary. This Simulator allows us to run and debug loongisa -+// code generation on regular desktop machines. V8 calls into generated code via -+// the GeneratedCode wrapper, which will start execution in the Simulator or -+// forwards to the real entry on a loongisa HW platform. -+ -+#ifndef V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ -+#define V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ -+ -+// globals.h defines USE_SIMULATOR. -+#include "src/common/globals.h" -+ -+template -+int Compare(const T& a, const T& b) { -+ if (a == b) -+ return 0; -+ else if (a < b) -+ return -1; -+ else -+ return 1; -+} -+ -+// Returns the negative absolute value of its argument. -+template ::value>::type> -+T Nabs(T a) { -+ return a < 0 ? a : -a; -+} -+ -+#if defined(USE_SIMULATOR) -+// Running with a simulator. -+ -+#include "src/base/hashmap.h" -+#include "src/codegen/assembler.h" -+#include "src/codegen/loongarch64/constants-loongarch64.h" -+#include "src/execution/simulator-base.h" -+#include "src/utils/allocation.h" -+ -+namespace v8 { -+namespace internal { -+ -+// ----------------------------------------------------------------------------- -+// Utility functions -+ -+class CachePage { -+ public: -+ static const int LINE_VALID = 0; -+ static const int LINE_INVALID = 1; -+ -+ static const int kPageShift = 12; -+ static const int kPageSize = 1 << kPageShift; -+ static const int kPageMask = kPageSize - 1; -+ static const int kLineShift = 2; // The cache line is only 4 bytes right now. -+ static const int kLineLength = 1 << kLineShift; -+ static const int kLineMask = kLineLength - 1; -+ -+ CachePage() { memset(&validity_map_, LINE_INVALID, sizeof(validity_map_)); } -+ -+ char* ValidityByte(int offset) { -+ return &validity_map_[offset >> kLineShift]; -+ } -+ -+ char* CachedData(int offset) { return &data_[offset]; } -+ -+ private: -+ char data_[kPageSize]; // The cached data. -+ static const int kValidityMapSize = kPageSize >> kLineShift; -+ char validity_map_[kValidityMapSize]; // One byte per line. -+}; -+ -+class SimInstructionBase : public InstructionBase { -+ public: -+ Type InstructionType() const { return type_; } -+ inline Instruction* instr() const { return instr_; } -+ inline int32_t operand() const { return operand_; } -+ -+ protected: -+ SimInstructionBase() : operand_(-1), instr_(nullptr), type_(kUnsupported) {} -+ explicit SimInstructionBase(Instruction* instr) {} -+ -+ int32_t operand_; -+ Instruction* instr_; -+ Type type_; -+ -+ private: -+ DISALLOW_ASSIGN(SimInstructionBase); -+}; -+ -+class SimInstruction : public InstructionGetters { -+ public: -+ SimInstruction() {} -+ -+ explicit SimInstruction(Instruction* instr) { *this = instr; } -+ -+ SimInstruction& operator=(Instruction* instr) { -+ operand_ = *reinterpret_cast(instr); -+ instr_ = instr; -+ type_ = InstructionBase::InstructionType(); -+ DCHECK(reinterpret_cast(&operand_) == this); -+ return *this; -+ } -+}; -+ -+class Simulator : public SimulatorBase { -+ public: -+ friend class La64Debugger; -+ -+ // Registers are declared in order. -+ enum Register { -+ no_reg = -1, -+ zero_reg = 0, -+ ra, -+ gp, -+ sp, -+ a0, -+ a1, -+ a2, -+ a3, -+ a4, -+ a5, -+ a6, -+ a7, -+ t0, -+ t1, -+ t2, -+ t3, -+ t4, -+ t5, -+ t6, -+ t7, -+ t8, -+ tp, -+ fp, -+ s0, -+ s1, -+ s2, -+ s3, -+ s4, -+ s5, -+ s6, -+ s7, -+ s8, -+ pc, // pc must be the last register. -+ kNumSimuRegisters, -+ // aliases -+ v0 = a0, -+ v1 = a1 -+ }; -+ -+ // Condition flag registers. -+ enum CFRegister { -+ fcc0, -+ fcc1, -+ fcc2, -+ fcc3, -+ fcc4, -+ fcc5, -+ fcc6, -+ fcc7, -+ kNumCFRegisters -+ }; -+ -+ // Floating point registers. -+ enum FPURegister { -+ f0, -+ f1, -+ f2, -+ f3, -+ f4, -+ f5, -+ f6, -+ f7, -+ f8, -+ f9, -+ f10, -+ f11, -+ f12, -+ f13, -+ f14, -+ f15, -+ f16, -+ f17, -+ f18, -+ f19, -+ f20, -+ f21, -+ f22, -+ f23, -+ f24, -+ f25, -+ f26, -+ f27, -+ f28, -+ f29, -+ f30, -+ f31, -+ kNumFPURegisters -+ }; -+ -+ explicit Simulator(Isolate* isolate); -+ ~Simulator(); -+ -+ // The currently executing Simulator instance. Potentially there can be one -+ // for each native thread. -+ V8_EXPORT_PRIVATE static Simulator* current(v8::internal::Isolate* isolate); -+ -+ // Accessors for register state. Reading the pc value adheres to the LA64 -+ // architecture specification and is off by a 8 from the currently executing -+ // instruction. -+ void set_register(int reg, int64_t value); -+ void set_register_word(int reg, int32_t value); -+ void set_dw_register(int dreg, const int* dbl); -+ int64_t get_register(int reg) const; -+ double get_double_from_register_pair(int reg); -+ // Same for FPURegisters. -+ void set_fpu_register(int fpureg, int64_t value); -+ void set_fpu_register_word(int fpureg, int32_t value); -+ void set_fpu_register_hi_word(int fpureg, int32_t value); -+ void set_fpu_register_float(int fpureg, float value); -+ void set_fpu_register_double(int fpureg, double value); -+ void set_fpu_register_invalid_result64(float original, float rounded); -+ void set_fpu_register_invalid_result(float original, float rounded); -+ void set_fpu_register_word_invalid_result(float original, float rounded); -+ void set_fpu_register_invalid_result64(double original, double rounded); -+ void set_fpu_register_invalid_result(double original, double rounded); -+ void set_fpu_register_word_invalid_result(double original, double rounded); -+ int64_t get_fpu_register(int fpureg) const; -+ int32_t get_fpu_register_word(int fpureg) const; -+ int32_t get_fpu_register_signed_word(int fpureg) const; -+ int32_t get_fpu_register_hi_word(int fpureg) const; -+ float get_fpu_register_float(int fpureg) const; -+ double get_fpu_register_double(int fpureg) const; -+ void set_cf_register(int cfreg, bool value); -+ bool get_cf_register(int cfreg) const; -+ void set_fcsr_rounding_mode(FPURoundingMode mode); -+ unsigned int get_fcsr_rounding_mode(); -+ void set_fcsr_bit(uint32_t cc, bool value); -+ bool test_fcsr_bit(uint32_t cc); -+ bool set_fcsr_round_error(double original, double rounded); -+ bool set_fcsr_round64_error(double original, double rounded); -+ bool set_fcsr_round_error(float original, float rounded); -+ bool set_fcsr_round64_error(float original, float rounded); -+ void round_according_to_fcsr(double toRound, double* rounded, -+ int32_t* rounded_int); -+ void round64_according_to_fcsr(double toRound, double* rounded, -+ int64_t* rounded_int); -+ void round_according_to_fcsr(float toRound, float* rounded, -+ int32_t* rounded_int); -+ void round64_according_to_fcsr(float toRound, float* rounded, -+ int64_t* rounded_int); -+ // Special case of set_register and get_register to access the raw PC value. -+ void set_pc(int64_t value); -+ int64_t get_pc() const; -+ -+ Address get_sp() const { return static_cast
(get_register(sp)); } -+ -+ // Accessor to the internal simulator stack area. -+ uintptr_t StackLimit(uintptr_t c_limit) const; -+ -+ // Executes LA64 instructions until the PC reaches end_sim_pc. -+ void Execute(); -+ -+ template -+ Return Call(Address entry, Args... args) { -+ return VariadicCall(this, &Simulator::CallImpl, entry, args...); -+ } -+ -+ // Alternative: call a 2-argument double function. -+ double CallFP(Address entry, double d0, double d1); -+ -+ // Push an address onto the JS stack. -+ uintptr_t PushAddress(uintptr_t address); -+ -+ // Pop an address from the JS stack. -+ uintptr_t PopAddress(); -+ -+ // Debugger input. -+ void set_last_debugger_input(char* input); -+ char* last_debugger_input() { return last_debugger_input_; } -+ -+ // Redirection support. -+ static void SetRedirectInstruction(Instruction* instruction); -+ -+ // ICache checking. -+ static bool ICacheMatch(void* one, void* two); -+ static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, -+ size_t size); -+ -+ // Returns true if pc register contains one of the 'special_values' defined -+ // below (bad_ra, end_sim_pc). -+ bool has_bad_pc() const; -+ -+ private: -+ enum special_values { -+ // Known bad pc value to ensure that the simulator does not execute -+ // without being properly setup. -+ bad_ra = -1, -+ // A pc value used to signal the simulator to stop execution. Generally -+ // the ra is set to this value on transition from native C code to -+ // simulated execution, so that the simulator can "return" to the native -+ // C code. -+ end_sim_pc = -2, -+ // Unpredictable value. -+ Unpredictable = 0xbadbeaf -+ }; -+ -+ V8_EXPORT_PRIVATE intptr_t CallImpl(Address entry, int argument_count, -+ const intptr_t* arguments); -+ -+ // Unsupported instructions use Format to print an error and stop execution. -+ void Format(Instruction* instr, const char* format); -+ -+ // Helpers for data value tracing. -+ enum TraceType { -+ BYTE, -+ HALF, -+ WORD, -+ DWORD, -+ FLOAT, -+ DOUBLE, -+ FLOAT_DOUBLE, -+ WORD_DWORD -+ }; -+ -+ // Read and write memory. -+ inline uint32_t ReadBU(int64_t addr); -+ inline int32_t ReadB(int64_t addr); -+ inline void WriteB(int64_t addr, uint8_t value); -+ inline void WriteB(int64_t addr, int8_t value); -+ -+ inline uint16_t ReadHU(int64_t addr, Instruction* instr); -+ inline int16_t ReadH(int64_t addr, Instruction* instr); -+ // Note: Overloaded on the sign of the value. -+ inline void WriteH(int64_t addr, uint16_t value, Instruction* instr); -+ inline void WriteH(int64_t addr, int16_t value, Instruction* instr); -+ -+ inline uint32_t ReadWU(int64_t addr, Instruction* instr); -+ inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD); -+ inline void WriteW(int64_t addr, int32_t value, Instruction* instr); -+ void WriteConditionalW(int64_t addr, int32_t value, Instruction* instr, -+ int32_t rt_reg); -+ inline int64_t Read2W(int64_t addr, Instruction* instr); -+ inline void Write2W(int64_t addr, int64_t value, Instruction* instr); -+ inline void WriteConditional2W(int64_t addr, int64_t value, -+ Instruction* instr, int32_t rt_reg); -+ -+ inline double ReadD(int64_t addr, Instruction* instr); -+ inline void WriteD(int64_t addr, double value, Instruction* instr); -+ -+ template -+ T ReadMem(int64_t addr, Instruction* instr); -+ template -+ void WriteMem(int64_t addr, T value, Instruction* instr); -+ -+ // Helper for debugging memory access. -+ inline void DieOrDebug(); -+ -+ void TraceRegWr(int64_t value, TraceType t = DWORD); -+ void TraceMemWr(int64_t addr, int64_t value, TraceType t); -+ void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD); -+ template -+ void TraceMemRd(int64_t addr, T value); -+ template -+ void TraceMemWr(int64_t addr, T value); -+ -+ SimInstruction instr_; -+ -+ // Executing is handled based on the instruction type. -+ void DecodeTypeOp6(); -+ void DecodeTypeOp7(); -+ void DecodeTypeOp8(); -+ void DecodeTypeOp10(); -+ void DecodeTypeOp12(); -+ void DecodeTypeOp14(); -+ void DecodeTypeOp17(); -+ void DecodeTypeOp22(); -+ -+ inline int32_t rj_reg() const { return instr_.RjValue(); } -+ inline int64_t rj() const { return get_register(rj_reg()); } -+ inline uint64_t rj_u() const { -+ return static_cast(get_register(rj_reg())); -+ } -+ inline int32_t rk_reg() const { return instr_.RkValue(); } -+ inline int64_t rk() const { return get_register(rk_reg()); } -+ inline uint64_t rk_u() const { -+ return static_cast(get_register(rk_reg())); -+ } -+ inline int32_t rd_reg() const { return instr_.RdValue(); } -+ inline int64_t rd() const { return get_register(rd_reg()); } -+ inline uint64_t rd_u() const { -+ return static_cast(get_register(rd_reg())); -+ } -+ inline int32_t fa_reg() const { return instr_.FaValue(); } -+ inline float fa_float() const { return get_fpu_register_float(fa_reg()); } -+ inline double fa_double() const { return get_fpu_register_double(fa_reg()); } -+ inline int32_t fj_reg() const { return instr_.FjValue(); } -+ inline float fj_float() const { return get_fpu_register_float(fj_reg()); } -+ inline double fj_double() const { return get_fpu_register_double(fj_reg()); } -+ inline int32_t fk_reg() const { return instr_.FkValue(); } -+ inline float fk_float() const { return get_fpu_register_float(fk_reg()); } -+ inline double fk_double() const { return get_fpu_register_double(fk_reg()); } -+ inline int32_t fd_reg() const { return instr_.FdValue(); } -+ inline float fd_float() const { return get_fpu_register_float(fd_reg()); } -+ inline double fd_double() const { return get_fpu_register_double(fd_reg()); } -+ inline int32_t cj_reg() const { return instr_.CjValue(); } -+ inline bool cj() const { return get_cf_register(cj_reg()); } -+ inline int32_t cd_reg() const { return instr_.CdValue(); } -+ inline bool cd() const { return get_cf_register(cd_reg()); } -+ inline int32_t ca_reg() const { return instr_.CaValue(); } -+ inline bool ca() const { return get_cf_register(ca_reg()); } -+ inline uint32_t sa2() const { return instr_.Sa2Value(); } -+ inline uint32_t sa3() const { return instr_.Sa3Value(); } -+ inline uint32_t ui5() const { return instr_.Ui5Value(); } -+ inline uint32_t ui6() const { return instr_.Ui6Value(); } -+ inline uint32_t lsbw() const { return instr_.LsbwValue(); } -+ inline uint32_t msbw() const { return instr_.MsbwValue(); } -+ inline uint32_t lsbd() const { return instr_.LsbdValue(); } -+ inline uint32_t msbd() const { return instr_.MsbdValue(); } -+ inline uint32_t cond() const { return instr_.CondValue(); } -+ inline int32_t si12() const { return (instr_.Si12Value() << 20) >> 20; } -+ inline uint32_t ui12() const { return instr_.Ui12Value(); } -+ inline int32_t si14() const { return (instr_.Si14Value() << 18) >> 18; } -+ inline int32_t si16() const { return (instr_.Si16Value() << 16) >> 16; } -+ inline int32_t si20() const { return (instr_.Si20Value() << 12) >> 12; } -+ -+ inline void SetResult(const int32_t rd_reg, const int64_t alu_out) { -+ set_register(rd_reg, alu_out); -+ TraceRegWr(alu_out); -+ } -+ -+ inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { -+ set_fpu_register_word(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg), WORD); -+ } -+ -+ inline void SetFPUWordResult2(int32_t fd_reg, int32_t alu_out) { -+ set_fpu_register_word(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg)); -+ } -+ -+ inline void SetFPUResult(int32_t fd_reg, int64_t alu_out) { -+ set_fpu_register(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg)); -+ } -+ -+ inline void SetFPUResult2(int32_t fd_reg, int64_t alu_out) { -+ set_fpu_register(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg), DOUBLE); -+ } -+ -+ inline void SetFPUFloatResult(int32_t fd_reg, float alu_out) { -+ set_fpu_register_float(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg), FLOAT); -+ } -+ -+ inline void SetFPUDoubleResult(int32_t fd_reg, double alu_out) { -+ set_fpu_register_double(fd_reg, alu_out); -+ TraceRegWr(get_fpu_register(fd_reg), DOUBLE); -+ } -+ -+ // Used for breakpoints. -+ void SoftwareInterrupt(); -+ -+ // Stop helper functions. -+ bool IsWatchpoint(uint64_t code); -+ void PrintWatchpoint(uint64_t code); -+ void HandleStop(uint64_t code, Instruction* instr); -+ bool IsStopInstruction(Instruction* instr); -+ bool IsEnabledStop(uint64_t code); -+ void EnableStop(uint64_t code); -+ void DisableStop(uint64_t code); -+ void IncreaseStopCounter(uint64_t code); -+ void PrintStopInfo(uint64_t code); -+ -+ // Executes one instruction. -+ void InstructionDecode(Instruction* instr); -+ // Execute one instruction placed in a branch delay slot. -+ -+ // ICache. -+ static void CheckICache(base::CustomMatcherHashMap* i_cache, -+ Instruction* instr); -+ static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, -+ size_t size); -+ static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, -+ void* page); -+ -+ enum Exception { -+ none, -+ kIntegerOverflow, -+ kIntegerUnderflow, -+ kDivideByZero, -+ kNumExceptions -+ }; -+ -+ // Exceptions. -+ void SignalException(Exception e); -+ -+ // Handle arguments and return value for runtime FP functions. -+ void GetFpArgs(double* x, double* y, int32_t* z); -+ void SetFpResult(const double& result); -+ -+ void CallInternal(Address entry); -+ -+ // Architecture state. -+ // Registers. -+ int64_t registers_[kNumSimuRegisters]; -+ // Floating point Registers. -+ int64_t FPUregisters_[kNumFPURegisters]; -+ // Condition flags Registers. -+ bool CFregisters_[kNumCFRegisters]; -+ // FPU control register. -+ uint32_t FCSR_; -+ -+ // Simulator support. -+ // Allocate 1MB for stack. -+ size_t stack_size_; -+ char* stack_; -+ bool pc_modified_; -+ int64_t icount_; -+ int break_count_; -+ EmbeddedVector trace_buf_; -+ -+ // Debugger input. -+ char* last_debugger_input_; -+ -+ v8::internal::Isolate* isolate_; -+ -+ // Registered breakpoints. -+ Instruction* break_pc_; -+ Instr break_instr_; -+ -+ // Stop is disabled if bit 31 is set. -+ static const uint32_t kStopDisabledBit = 1 << 31; -+ -+ // A stop is enabled, meaning the simulator will stop when meeting the -+ // instruction, if bit 31 of watched_stops_[code].count is unset. -+ // The value watched_stops_[code].count & ~(1 << 31) indicates how many times -+ // the breakpoint was hit or gone through. -+ struct StopCountAndDesc { -+ uint32_t count; -+ char* desc; -+ }; -+ StopCountAndDesc watched_stops_[kMaxStopCode + 1]; -+ -+ // Synchronization primitives. -+ enum class MonitorAccess { -+ Open, -+ RMW, -+ }; -+ -+ enum class TransactionSize { -+ None = 0, -+ Word = 4, -+ DoubleWord = 8, -+ }; -+ -+ // The least-significant bits of the address are ignored. The number of bits -+ // is implementation-defined, between 3 and minimum page size. -+ static const uintptr_t kExclusiveTaggedAddrMask = ~((1 << 3) - 1); -+ -+ class LocalMonitor { -+ public: -+ LocalMonitor(); -+ -+ // These functions manage the state machine for the local monitor, but do -+ // not actually perform loads and stores. NotifyStoreConditional only -+ // returns true if the store conditional is allowed; the global monitor will -+ // still have to be checked to see whether the memory should be updated. -+ void NotifyLoad(); -+ void NotifyLoadLinked(uintptr_t addr, TransactionSize size); -+ void NotifyStore(); -+ bool NotifyStoreConditional(uintptr_t addr, TransactionSize size); -+ -+ private: -+ void Clear(); -+ -+ MonitorAccess access_state_; -+ uintptr_t tagged_addr_; -+ TransactionSize size_; -+ }; -+ -+ class GlobalMonitor { -+ public: -+ class LinkedAddress { -+ public: -+ LinkedAddress(); -+ -+ private: -+ friend class GlobalMonitor; -+ // These functions manage the state machine for the global monitor, but do -+ // not actually perform loads and stores. -+ void Clear_Locked(); -+ void NotifyLoadLinked_Locked(uintptr_t addr); -+ void NotifyStore_Locked(); -+ bool NotifyStoreConditional_Locked(uintptr_t addr, -+ bool is_requesting_thread); -+ -+ MonitorAccess access_state_; -+ uintptr_t tagged_addr_; -+ LinkedAddress* next_; -+ LinkedAddress* prev_; -+ // A scd can fail due to background cache evictions. Rather than -+ // simulating this, we'll just occasionally introduce cases where an -+ // store conditional fails. This will happen once after every -+ // kMaxFailureCounter exclusive stores. -+ static const int kMaxFailureCounter = 5; -+ int failure_counter_; -+ }; -+ -+ // Exposed so it can be accessed by Simulator::{Read,Write}Ex*. -+ base::Mutex mutex; -+ -+ void NotifyLoadLinked_Locked(uintptr_t addr, LinkedAddress* linked_address); -+ void NotifyStore_Locked(LinkedAddress* linked_address); -+ bool NotifyStoreConditional_Locked(uintptr_t addr, -+ LinkedAddress* linked_address); -+ -+ // Called when the simulator is destroyed. -+ void RemoveLinkedAddress(LinkedAddress* linked_address); -+ -+ static GlobalMonitor* Get(); -+ -+ private: -+ // Private constructor. Call {GlobalMonitor::Get()} to get the singleton. -+ GlobalMonitor() = default; -+ friend class base::LeakyObject; -+ -+ bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const; -+ void PrependProcessor_Locked(LinkedAddress* linked_address); -+ -+ LinkedAddress* head_ = nullptr; -+ }; -+ -+ LocalMonitor local_monitor_; -+ GlobalMonitor::LinkedAddress global_monitor_thread_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // defined(USE_SIMULATOR) -+#endif // V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/execution/simulator-base.h b/src/3rdparty/chromium/v8/src/execution/simulator-base.h -index f3e333297..c16b28434 100644 ---- a/src/3rdparty/chromium/v8/src/execution/simulator-base.h -+++ b/src/3rdparty/chromium/v8/src/execution/simulator-base.h -@@ -89,7 +89,7 @@ class SimulatorBase { - static typename std::enable_if::value, intptr_t>::type - ConvertArg(T arg) { - static_assert(sizeof(T) <= sizeof(intptr_t), "type bigger than ptrsize"); --#if V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - // The MIPS64 calling convention is to sign extend all values, even unsigned - // ones. - using signed_t = typename std::make_signed::type; -diff --git a/src/3rdparty/chromium/v8/src/execution/simulator.h b/src/3rdparty/chromium/v8/src/execution/simulator.h -index 74763474c..fda820172 100644 ---- a/src/3rdparty/chromium/v8/src/execution/simulator.h -+++ b/src/3rdparty/chromium/v8/src/execution/simulator.h -@@ -24,6 +24,8 @@ - #include "src/execution/mips/simulator-mips.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/execution/mips64/simulator-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/execution/loongarch64/simulator-loongarch64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/execution/s390/simulator-s390.h" - #else -diff --git a/src/3rdparty/chromium/v8/src/flags/flag-definitions.h b/src/3rdparty/chromium/v8/src/flags/flag-definitions.h -index ab689283e..2a760a4d9 100644 ---- a/src/3rdparty/chromium/v8/src/flags/flag-definitions.h -+++ b/src/3rdparty/chromium/v8/src/flags/flag-definitions.h -@@ -1372,7 +1372,7 @@ DEFINE_BOOL(check_icache, false, - "Check icache flushes in ARM and MIPS simulator") - DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions") - #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) || \ -- defined(V8_TARGET_ARCH_PPC64) -+ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_LOONGARCH64) - DEFINE_INT(sim_stack_alignment, 16, - "Stack alignment in bytes in simulator. This must be a power of two " - "and it must be at least 16. 16 is default.") -diff --git a/src/3rdparty/chromium/v8/src/heap/base/asm/loongarch64/push_registers_asm.cc b/src/3rdparty/chromium/v8/src/heap/base/asm/loongarch64/push_registers_asm.cc -new file mode 100644 -index 000000000..c9e6f5d2c ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/heap/base/asm/loongarch64/push_registers_asm.cc -@@ -0,0 +1,48 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Push all callee-saved registers to get them on the stack for conservative -+// stack scanning. -+// -+// See asm/x64/push_registers_clang.cc for why the function is not generated -+// using clang. -+// -+// Do not depend on V8_TARGET_OS_* defines as some embedders may override the -+// GN toolchain (e.g. ChromeOS) and not provide them. -+asm(".text \n" -+ ".global PushAllRegistersAndIterateStack \n" -+ ".type PushAllRegistersAndIterateStack, %function \n" -+ ".hidden PushAllRegistersAndIterateStack \n" -+ "PushAllRegistersAndIterateStack: \n" -+ // Push all callee-saved registers and save return address. -+ " addi.d $sp, $sp, -96 \n" -+ " st.d $ra, $sp, 88 \n" -+ " st.d $s8, $sp, 80 \n" -+ " st.d $sp, $sp, 72 \n" -+ " st.d $fp, $sp, 64 \n" -+ " st.d $s7, $sp, 56 \n" -+ " st.d $s6, $sp, 48 \n" -+ " st.d $s5, $sp, 40 \n" -+ " st.d $s4, $sp, 32 \n" -+ " st.d $s3, $sp, 24 \n" -+ " st.d $s2, $sp, 16 \n" -+ " st.d $s1, $sp, 8 \n" -+ " st.d $s0, $sp, 0 \n" -+ // Maintain frame pointer. -+ " addi.d $s8, $sp, 0 \n" -+ // Pass 1st parameter (a0) unchanged (Stack*). -+ // Pass 2nd parameter (a1) unchanged (StackVisitor*). -+ // Save 3rd parameter (a2; IterateStackCallback). -+ " addi.d $a3, $a2, 0 \n" -+ // Call the callback. -+ // Pass 3rd parameter as sp (stack pointer). -+ " addi.d $a2, $sp, 0 \n" -+ " jirl $ra, $a3, 0 \n" -+ // Load return address. -+ " ld.d $ra, $sp, 88 \n" -+ // Restore frame pointer. -+ " ld.d $s8, $sp, 80 \n" -+ // Discard all callee-saved registers. -+ " addi.d $sp, $sp, 96 \n" -+ " jirl $zero, $ra, 0 \n"); -diff --git a/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc b/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc -index e6fd97ddf..4a1765325 100644 ---- a/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc -+++ b/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc -@@ -1348,7 +1348,7 @@ void InterpreterAssembler::TraceBytecodeDispatch(TNode target_bytecode) { - - // static - bool InterpreterAssembler::TargetSupportsUnalignedAccess() { --#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - return false; - #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390 || \ - V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC || \ -diff --git a/src/3rdparty/chromium/v8/src/libsampler/sampler.cc b/src/3rdparty/chromium/v8/src/libsampler/sampler.cc -index 9631d2f47..8392dbeef 100644 ---- a/src/3rdparty/chromium/v8/src/libsampler/sampler.cc -+++ b/src/3rdparty/chromium/v8/src/libsampler/sampler.cc -@@ -415,6 +415,10 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) { - state->pc = reinterpret_cast(mcontext.pc); - state->sp = reinterpret_cast(mcontext.gregs[29]); - state->fp = reinterpret_cast(mcontext.gregs[30]); -+#elif V8_HOST_ARCH_LOONGARCH64 -+ state->pc = reinterpret_cast(mcontext.__pc); -+ state->sp = reinterpret_cast(mcontext.__gregs[3]); -+ state->fp = reinterpret_cast(mcontext.__gregs[22]); - #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 - #if V8_LIBC_GLIBC - state->pc = reinterpret_cast(ucontext->uc_mcontext.regs->nip); -diff --git a/src/3rdparty/chromium/v8/src/logging/log.cc b/src/3rdparty/chromium/v8/src/logging/log.cc -index efd7c2b5f..2801e519a 100644 ---- a/src/3rdparty/chromium/v8/src/logging/log.cc -+++ b/src/3rdparty/chromium/v8/src/logging/log.cc -@@ -590,6 +590,8 @@ void LowLevelLogger::LogCodeInfo() { - const char arch[] = "ppc64"; - #elif V8_TARGET_ARCH_MIPS - const char arch[] = "mips"; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ const char arch[] = "la64"; - #elif V8_TARGET_ARCH_ARM64 - const char arch[] = "arm64"; - #elif V8_TARGET_ARCH_S390 -diff --git a/src/3rdparty/chromium/v8/src/objects/backing-store.cc b/src/3rdparty/chromium/v8/src/objects/backing-store.cc -index c67fff0fa..7c4d0fbfd 100644 ---- a/src/3rdparty/chromium/v8/src/objects/backing-store.cc -+++ b/src/3rdparty/chromium/v8/src/objects/backing-store.cc -@@ -29,7 +29,7 @@ constexpr bool kUseGuardRegions = true; - constexpr bool kUseGuardRegions = false; - #endif - --#if V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - // MIPS64 has a user space of 2^40 bytes on most processors, - // address space limits needs to be smaller. - constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB -diff --git a/src/3rdparty/chromium/v8/src/objects/code.cc b/src/3rdparty/chromium/v8/src/objects/code.cc -index c79690471..0f32770c1 100644 ---- a/src/3rdparty/chromium/v8/src/objects/code.cc -+++ b/src/3rdparty/chromium/v8/src/objects/code.cc -@@ -234,7 +234,7 @@ bool Code::IsIsolateIndependent(Isolate* isolate) { - RelocInfo::ModeMask(RelocInfo::WASM_STUB_CALL))); - - #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ -- defined(V8_TARGET_ARCH_MIPS64) -+ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) - return RelocIterator(*this, kModeMask).done(); - #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ - defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ -diff --git a/src/3rdparty/chromium/v8/src/objects/code.h b/src/3rdparty/chromium/v8/src/objects/code.h -index d71a0b113..2dfed5bd8 100644 ---- a/src/3rdparty/chromium/v8/src/objects/code.h -+++ b/src/3rdparty/chromium/v8/src/objects/code.h -@@ -447,6 +447,8 @@ class Code : public HeapObject { - static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; - #elif V8_TARGET_ARCH_MIPS64 - static constexpr int kHeaderPaddingSize = 28; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ static constexpr int kHeaderPaddingSize = 28; - #elif V8_TARGET_ARCH_X64 - static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; - #elif V8_TARGET_ARCH_ARM -diff --git a/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc b/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc -index 45fc91185..5c9d2164a 100644 ---- a/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc -+++ b/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc -@@ -105,7 +105,7 @@ bool SimulatorHelper::FillRegisters(Isolate* isolate, - state->sp = reinterpret_cast(simulator->sp()); - state->fp = reinterpret_cast(simulator->fp()); - state->lr = reinterpret_cast(simulator->lr()); --#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - if (!simulator->has_bad_pc()) { - state->pc = reinterpret_cast(simulator->get_pc()); - } -diff --git a/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc b/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc -new file mode 100644 -index 000000000..cd8e2bd7e ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc -@@ -0,0 +1,1270 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_LOONGARCH64 -+ -+#include "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h" -+ -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/logging/log.h" -+#include "src/objects/objects-inl.h" -+#include "src/regexp/regexp-macro-assembler.h" -+#include "src/regexp/regexp-stack.h" -+#include "src/snapshot/embedded/embedded-data.h" -+#include "src/strings/unicode.h" -+ -+namespace v8 { -+namespace internal { -+ -+/* clang-format off -+ * -+ * This assembler uses the following register assignment convention -+ * - t3 : Temporarily stores the index of capture start after a matching pass -+ * for a global regexp. -+ * - a5 : Pointer to current Code object including heap object tag. -+ * - a6 : Current position in input, as negative offset from end of string. -+ * Please notice that this is the byte offset, not the character offset! -+ * - a7 : Currently loaded character. Must be loaded using -+ * LoadCurrentCharacter before using any of the dispatch methods. -+ * - t0 : Points to tip of backtrack stack -+ * - t1 : Unused. -+ * - t2 : End of input (points to byte after last character in input). -+ * - fp : Frame pointer. Used to access arguments, local variables and -+ * RegExp registers. -+ * - sp : Points to tip of C stack. -+ * -+ * The remaining registers are free for computations. -+ * Each call to a public method should retain this convention. -+ * -+ * TODO(plind): O32 documented here with intent of having single 32/64 codebase -+ * in the future. -+ * -+ * The O32 stack will have the following structure: -+ * -+ * - fp[72] Isolate* isolate (address of the current isolate) -+ * - fp[68] direct_call (if 1, direct call from JavaScript code, -+ * if 0, call through the runtime system). -+ * - fp[64] stack_area_base (High end of the memory area to use as -+ * backtracking stack). -+ * - fp[60] capture array size (may fit multiple sets of matches) -+ * - fp[44..59] MIPS O32 four argument slots -+ * - fp[40] int* capture_array (int[num_saved_registers_], for output). -+ * --- sp when called --- -+ * - fp[36] return address (lr). -+ * - fp[32] old frame pointer (r11). -+ * - fp[0..31] backup of registers s0..s7. -+ * --- frame pointer ---- -+ * - fp[-4] end of input (address of end of string). -+ * - fp[-8] start of input (address of first character in string). -+ * - fp[-12] start index (character index of start). -+ * - fp[-16] void* input_string (location of a handle containing the string). -+ * - fp[-20] success counter (only for global regexps to count matches). -+ * - fp[-24] Offset of location before start of input (effectively character -+ * string start - 1). Used to initialize capture registers to a -+ * non-position. -+ * - fp[-28] At start (if 1, we are starting at the start of the -+ * string, otherwise 0) -+ * - fp[-32] register 0 (Only positions must be stored in the first -+ * - register 1 num_saved_registers_ registers) -+ * - ... -+ * - register num_registers-1 -+ * --- sp --- -+ * -+ * -+ * The N64 stack will have the following structure: -+ * -+ * - fp[80] Isolate* isolate (address of the current isolate) kIsolate -+ * kStackFrameHeader -+ * --- sp when called --- -+ * - fp[72] ra Return from RegExp code (ra). kReturnAddress -+ * - fp[64] s9, old-fp Old fp, callee saved(s9). -+ * - fp[0..63] s0..s7 Callee-saved registers s0..s7. -+ * --- frame pointer ---- -+ * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall -+ * - fp[-16] stack_base (Top of backtracking stack). kStackHighEnd -+ * - fp[-24] capture array size (may fit multiple sets of matches) kNumOutputRegisters -+ * - fp[-32] int* capture_array (int[num_saved_registers_], for output). kRegisterOutput -+ * - fp[-40] end of input (address of end of string). kInputEnd -+ * - fp[-48] start of input (address of first character in string). kInputStart -+ * - fp[-56] start index (character index of start). kStartIndex -+ * - fp[-64] void* input_string (location of a handle containing the string). kInputString -+ * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures -+ * - fp[-80] Offset of location before start of input (effectively character kStringStartMinusOne -+ * position -1). Used to initialize capture registers to a -+ * non-position. -+ * --------- The following output registers are 32-bit values. --------- -+ * - fp[-88] register 0 (Only positions must be stored in the first kRegisterZero -+ * - register 1 num_saved_registers_ registers) -+ * - ... -+ * - register num_registers-1 -+ * --- sp --- -+ * -+ * The first num_saved_registers_ registers are initialized to point to -+ * "character -1" in the string (i.e., char_size() bytes before the first -+ * character of the string). The remaining registers start out as garbage. -+ * -+ * The data up to the return address must be placed there by the calling -+ * code and the remaining arguments are passed in registers, e.g. by calling the -+ * code entry as cast to a function with the signature: -+ * int (*match)(String input_string, -+ * int start_index, -+ * Address start, -+ * Address end, -+ * int* capture_output_array, -+ * int num_capture_registers, -+ * byte* stack_area_base, -+ * bool direct_call = false, -+ * Isolate* isolate); -+ * The call is performed by NativeRegExpMacroAssembler::Execute() -+ * (in regexp-macro-assembler.cc) via the GeneratedCode wrapper. -+ * -+ * clang-format on -+ */ -+ -+#define __ ACCESS_MASM(masm_) -+ -+const int RegExpMacroAssemblerLA64::kRegExpCodeSize; -+ -+RegExpMacroAssemblerLA64::RegExpMacroAssemblerLA64(Isolate* isolate, Zone* zone, -+ Mode mode, -+ int registers_to_save) -+ : NativeRegExpMacroAssembler(isolate, zone), -+ masm_(new MacroAssembler(isolate, CodeObjectRequired::kYes, -+ NewAssemblerBuffer(kRegExpCodeSize))), -+ mode_(mode), -+ num_registers_(registers_to_save), -+ num_saved_registers_(registers_to_save), -+ entry_label_(), -+ start_label_(), -+ success_label_(), -+ backtrack_label_(), -+ exit_label_(), -+ internal_failure_label_() { -+ masm_->set_root_array_available(false); -+ -+ DCHECK_EQ(0, registers_to_save % 2); -+ __ jmp(&entry_label_); // We'll write the entry code later. -+ // If the code gets too big or corrupted, an internal exception will be -+ // raised, and we will exit right away. -+ __ bind(&internal_failure_label_); -+ __ li(a0, Operand(FAILURE)); -+ __ Ret(); -+ __ bind(&start_label_); // And then continue from here. -+} -+ -+RegExpMacroAssemblerLA64::~RegExpMacroAssemblerLA64() { -+ delete masm_; -+ // Unuse labels in case we throw away the assembler without calling GetCode. -+ entry_label_.Unuse(); -+ start_label_.Unuse(); -+ success_label_.Unuse(); -+ backtrack_label_.Unuse(); -+ exit_label_.Unuse(); -+ check_preempt_label_.Unuse(); -+ stack_overflow_label_.Unuse(); -+ internal_failure_label_.Unuse(); -+} -+ -+int RegExpMacroAssemblerLA64::stack_limit_slack() { -+ return RegExpStack::kStackLimitSlack; -+} -+ -+void RegExpMacroAssemblerLA64::AdvanceCurrentPosition(int by) { -+ if (by != 0) { -+ __ Add_d(current_input_offset(), current_input_offset(), -+ Operand(by * char_size())); -+ } -+} -+ -+void RegExpMacroAssemblerLA64::AdvanceRegister(int reg, int by) { -+ DCHECK_LE(0, reg); -+ DCHECK_GT(num_registers_, reg); -+ if (by != 0) { -+ __ Ld_d(a0, register_location(reg)); -+ __ Add_d(a0, a0, Operand(by)); -+ __ St_d(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerLA64::Backtrack() { -+ CheckPreemption(); -+ if (has_backtrack_limit()) { -+ Label next; -+ __ Ld_d(a0, MemOperand(frame_pointer(), kBacktrackCount)); -+ __ Add_d(a0, a0, Operand(1)); -+ __ St_d(a0, MemOperand(frame_pointer(), kBacktrackCount)); -+ __ Branch(&next, ne, a0, Operand(backtrack_limit())); -+ -+ // Exceeded limits are treated as a failed match. -+ Fail(); -+ -+ __ bind(&next); -+ } -+ // Pop Code offset from backtrack stack, add Code and jump to location. -+ Pop(a0); -+ __ Add_d(a0, a0, code_pointer()); -+ __ Jump(a0); -+} -+ -+void RegExpMacroAssemblerLA64::Bind(Label* label) { __ bind(label); } -+ -+void RegExpMacroAssemblerLA64::CheckCharacter(uint32_t c, Label* on_equal) { -+ BranchOrBacktrack(on_equal, eq, current_character(), Operand(c)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckCharacterGT(uc16 limit, Label* on_greater) { -+ BranchOrBacktrack(on_greater, gt, current_character(), Operand(limit)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckAtStart(int cp_offset, Label* on_at_start) { -+ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add_d(a0, current_input_offset(), -+ Operand(-char_size() + cp_offset * char_size())); -+ BranchOrBacktrack(on_at_start, eq, a0, Operand(a1)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotAtStart(int cp_offset, -+ Label* on_not_at_start) { -+ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add_d(a0, current_input_offset(), -+ Operand(-char_size() + cp_offset * char_size())); -+ BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckCharacterLT(uc16 limit, Label* on_less) { -+ BranchOrBacktrack(on_less, lt, current_character(), Operand(limit)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckGreedyLoop(Label* on_equal) { -+ Label backtrack_non_equal; -+ __ Ld_w(a0, MemOperand(backtrack_stackpointer(), 0)); -+ __ Branch(&backtrack_non_equal, ne, current_input_offset(), Operand(a0)); -+ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), -+ Operand(kIntSize)); -+ __ bind(&backtrack_non_equal); -+ BranchOrBacktrack(on_equal, eq, current_input_offset(), Operand(a0)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotBackReferenceIgnoreCase( -+ int start_reg, bool read_backward, bool unicode, Label* on_no_match) { -+ Label fallthrough; -+ __ Ld_d(a0, register_location(start_reg)); // Index of start of capture. -+ __ Ld_d(a1, register_location(start_reg + 1)); // Index of end of capture. -+ __ Sub_d(a1, a1, a0); // Length of capture. -+ -+ // At this point, the capture registers are either both set or both cleared. -+ // If the capture length is zero, then the capture is either empty or cleared. -+ // Fall through in both cases. -+ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); -+ -+ if (read_backward) { -+ __ Ld_d(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add_d(t1, t1, a1); -+ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); -+ } else { -+ __ Add_d(t1, a1, current_input_offset()); -+ // Check that there are enough characters left in the input. -+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); -+ } -+ -+ if (mode_ == LATIN1) { -+ Label success; -+ Label fail; -+ Label loop_check; -+ -+ // a0 - offset of start of capture. -+ // a1 - length of capture. -+ __ Add_d(a0, a0, Operand(end_of_input_address())); -+ __ Add_d(a2, end_of_input_address(), Operand(current_input_offset())); -+ if (read_backward) { -+ __ Sub_d(a2, a2, Operand(a1)); -+ } -+ __ Add_d(a1, a0, Operand(a1)); -+ -+ // a0 - Address of start of capture. -+ // a1 - Address of end of capture. -+ // a2 - Address of current input position. -+ -+ Label loop; -+ __ bind(&loop); -+ __ Ld_bu(a3, MemOperand(a0, 0)); -+ __ addi_d(a0, a0, char_size()); -+ __ Ld_bu(a4, MemOperand(a2, 0)); -+ __ addi_d(a2, a2, char_size()); -+ -+ __ Branch(&loop_check, eq, a4, Operand(a3)); -+ -+ // Mismatch, try case-insensitive match (converting letters to lower-case). -+ __ Or(a3, a3, Operand(0x20)); // Convert capture character to lower-case. -+ __ Or(a4, a4, Operand(0x20)); // Also convert input character. -+ __ Branch(&fail, ne, a4, Operand(a3)); -+ __ Sub_d(a3, a3, Operand('a')); -+ __ Branch(&loop_check, ls, a3, Operand('z' - 'a')); -+ // Latin-1: Check for values in range [224,254] but not 247. -+ __ Sub_d(a3, a3, Operand(224 - 'a')); -+ // Weren't Latin-1 letters. -+ __ Branch(&fail, hi, a3, Operand(254 - 224)); -+ // Check for 247. -+ __ Branch(&fail, eq, a3, Operand(247 - 224)); -+ -+ __ bind(&loop_check); -+ __ Branch(&loop, lt, a0, Operand(a1)); -+ __ jmp(&success); -+ -+ __ bind(&fail); -+ GoTo(on_no_match); -+ -+ __ bind(&success); -+ // Compute new value of character position after the matched part. -+ __ Sub_d(current_input_offset(), a2, end_of_input_address()); -+ if (read_backward) { -+ __ Ld_d(t1, register_location(start_reg)); // Index of start of capture. -+ __ Ld_d(a2, -+ register_location(start_reg + 1)); // Index of end of capture. -+ __ Add_d(current_input_offset(), current_input_offset(), Operand(t1)); -+ __ Sub_d(current_input_offset(), current_input_offset(), Operand(a2)); -+ } -+ } else { -+ DCHECK(mode_ == UC16); -+ // Put regexp engine registers on stack. -+ RegList regexp_registers_to_retain = current_input_offset().bit() | -+ current_character().bit() | -+ backtrack_stackpointer().bit(); -+ __ MultiPush(regexp_registers_to_retain); -+ -+ int argument_count = 4; -+ __ PrepareCallCFunction(argument_count, a2); -+ -+ // a0 - offset of start of capture. -+ // a1 - length of capture. -+ -+ // Put arguments into arguments registers. -+ // Parameters are -+ // a0: Address byte_offset1 - Address captured substring's start. -+ // a1: Address byte_offset2 - Address of current character position. -+ // a2: size_t byte_length - length of capture in bytes(!). -+ // a3: Isolate* isolate. -+ -+ // Address of start of capture. -+ __ Add_d(a0, a0, Operand(end_of_input_address())); -+ // Length of capture. -+ __ mov(a2, a1); -+ // Save length in callee-save register for use on return. -+ __ mov(s3, a1); -+ // Address of current input position. -+ __ Add_d(a1, current_input_offset(), Operand(end_of_input_address())); -+ if (read_backward) { -+ __ Sub_d(a1, a1, Operand(s3)); -+ } -+ // Isolate. -+ __ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate()))); -+ -+ { -+ AllowExternalCallThatCantCauseGC scope(masm_); -+ ExternalReference function = -+ unicode ? ExternalReference::re_case_insensitive_compare_unicode( -+ isolate()) -+ : ExternalReference::re_case_insensitive_compare_non_unicode( -+ isolate()); -+ __ CallCFunction(function, argument_count); -+ } -+ -+ // Restore regexp engine registers. -+ __ MultiPop(regexp_registers_to_retain); -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ -+ // Check if function returned non-zero for success or zero for failure. -+ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); -+ // On success, increment position by length of capture. -+ if (read_backward) { -+ __ Sub_d(current_input_offset(), current_input_offset(), Operand(s3)); -+ } else { -+ __ Add_d(current_input_offset(), current_input_offset(), Operand(s3)); -+ } -+ } -+ -+ __ bind(&fallthrough); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotBackReference(int start_reg, -+ bool read_backward, -+ Label* on_no_match) { -+ Label fallthrough; -+ -+ // Find length of back-referenced capture. -+ __ Ld_d(a0, register_location(start_reg)); -+ __ Ld_d(a1, register_location(start_reg + 1)); -+ __ Sub_d(a1, a1, a0); // Length to check. -+ -+ // At this point, the capture registers are either both set or both cleared. -+ // If the capture length is zero, then the capture is either empty or cleared. -+ // Fall through in both cases. -+ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); -+ -+ if (read_backward) { -+ __ Ld_d(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add_d(t1, t1, a1); -+ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); -+ } else { -+ __ Add_d(t1, a1, current_input_offset()); -+ // Check that there are enough characters left in the input. -+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); -+ } -+ -+ // Compute pointers to match string and capture string. -+ __ Add_d(a0, a0, Operand(end_of_input_address())); -+ __ Add_d(a2, end_of_input_address(), Operand(current_input_offset())); -+ if (read_backward) { -+ __ Sub_d(a2, a2, Operand(a1)); -+ } -+ __ Add_d(a1, a1, Operand(a0)); -+ -+ Label loop; -+ __ bind(&loop); -+ if (mode_ == LATIN1) { -+ __ Ld_bu(a3, MemOperand(a0, 0)); -+ __ addi_d(a0, a0, char_size()); -+ __ Ld_bu(a4, MemOperand(a2, 0)); -+ __ addi_d(a2, a2, char_size()); -+ } else { -+ DCHECK(mode_ == UC16); -+ __ Ld_hu(a3, MemOperand(a0, 0)); -+ __ addi_d(a0, a0, char_size()); -+ __ Ld_hu(a4, MemOperand(a2, 0)); -+ __ addi_d(a2, a2, char_size()); -+ } -+ BranchOrBacktrack(on_no_match, ne, a3, Operand(a4)); -+ __ Branch(&loop, lt, a0, Operand(a1)); -+ -+ // Move current character position to position after match. -+ __ Sub_d(current_input_offset(), a2, end_of_input_address()); -+ if (read_backward) { -+ __ Ld_d(t1, register_location(start_reg)); // Index of start of capture. -+ __ Ld_d(a2, register_location(start_reg + 1)); // Index of end of capture. -+ __ Add_d(current_input_offset(), current_input_offset(), Operand(t1)); -+ __ Sub_d(current_input_offset(), current_input_offset(), Operand(a2)); -+ } -+ __ bind(&fallthrough); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotCharacter(uint32_t c, -+ Label* on_not_equal) { -+ BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckCharacterAfterAnd(uint32_t c, uint32_t mask, -+ Label* on_equal) { -+ __ And(a0, current_character(), Operand(mask)); -+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); -+ BranchOrBacktrack(on_equal, eq, a0, rhs); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotCharacterAfterAnd(uint32_t c, -+ uint32_t mask, -+ Label* on_not_equal) { -+ __ And(a0, current_character(), Operand(mask)); -+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); -+ BranchOrBacktrack(on_not_equal, ne, a0, rhs); -+} -+ -+void RegExpMacroAssemblerLA64::CheckNotCharacterAfterMinusAnd( -+ uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { -+ DCHECK_GT(String::kMaxUtf16CodeUnit, minus); -+ __ Sub_d(a0, current_character(), Operand(minus)); -+ __ And(a0, a0, Operand(mask)); -+ BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckCharacterInRange(uc16 from, uc16 to, -+ Label* on_in_range) { -+ __ Sub_d(a0, current_character(), Operand(from)); -+ // Unsigned lower-or-same condition. -+ BranchOrBacktrack(on_in_range, ls, a0, Operand(to - from)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckCharacterNotInRange( -+ uc16 from, uc16 to, Label* on_not_in_range) { -+ __ Sub_d(a0, current_character(), Operand(from)); -+ // Unsigned higher condition. -+ BranchOrBacktrack(on_not_in_range, hi, a0, Operand(to - from)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckBitInTable(Handle table, -+ Label* on_bit_set) { -+ __ li(a0, Operand(table)); -+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { -+ __ And(a1, current_character(), Operand(kTableSize - 1)); -+ __ Add_d(a0, a0, a1); -+ } else { -+ __ Add_d(a0, a0, current_character()); -+ } -+ -+ __ Ld_bu(a0, FieldMemOperand(a0, ByteArray::kHeaderSize)); -+ BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg)); -+} -+ -+bool RegExpMacroAssemblerLA64::CheckSpecialCharacterClass(uc16 type, -+ Label* on_no_match) { -+ // Range checks (c in min..max) are generally implemented by an unsigned -+ // (c - min) <= (max - min) check. -+ switch (type) { -+ case 's': -+ // Match space-characters. -+ if (mode_ == LATIN1) { -+ // One byte space characters are '\t'..'\r', ' ' and \u00a0. -+ Label success; -+ __ Branch(&success, eq, current_character(), Operand(' ')); -+ // Check range 0x09..0x0D. -+ __ Sub_d(a0, current_character(), Operand('\t')); -+ __ Branch(&success, ls, a0, Operand('\r' - '\t')); -+ // \u00a0 (NBSP). -+ BranchOrBacktrack(on_no_match, ne, a0, Operand(0x00A0 - '\t')); -+ __ bind(&success); -+ return true; -+ } -+ return false; -+ case 'S': -+ // The emitted code for generic character classes is good enough. -+ return false; -+ case 'd': -+ // Match Latin1 digits ('0'..'9'). -+ __ Sub_d(a0, current_character(), Operand('0')); -+ BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0')); -+ return true; -+ case 'D': -+ // Match non Latin1-digits. -+ __ Sub_d(a0, current_character(), Operand('0')); -+ BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0')); -+ return true; -+ case '.': { -+ // Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). -+ __ Xor(a0, current_character(), Operand(0x01)); -+ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. -+ __ Sub_d(a0, a0, Operand(0x0B)); -+ BranchOrBacktrack(on_no_match, ls, a0, Operand(0x0C - 0x0B)); -+ if (mode_ == UC16) { -+ // Compare original value to 0x2028 and 0x2029, using the already -+ // computed (current_char ^ 0x01 - 0x0B). I.e., check for -+ // 0x201D (0x2028 - 0x0B) or 0x201E. -+ __ Sub_d(a0, a0, Operand(0x2028 - 0x0B)); -+ BranchOrBacktrack(on_no_match, ls, a0, Operand(1)); -+ } -+ return true; -+ } -+ case 'n': { -+ // Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). -+ __ Xor(a0, current_character(), Operand(0x01)); -+ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. -+ __ Sub_d(a0, a0, Operand(0x0B)); -+ if (mode_ == LATIN1) { -+ BranchOrBacktrack(on_no_match, hi, a0, Operand(0x0C - 0x0B)); -+ } else { -+ Label done; -+ BranchOrBacktrack(&done, ls, a0, Operand(0x0C - 0x0B)); -+ // Compare original value to 0x2028 and 0x2029, using the already -+ // computed (current_char ^ 0x01 - 0x0B). I.e., check for -+ // 0x201D (0x2028 - 0x0B) or 0x201E. -+ __ Sub_d(a0, a0, Operand(0x2028 - 0x0B)); -+ BranchOrBacktrack(on_no_match, hi, a0, Operand(1)); -+ __ bind(&done); -+ } -+ return true; -+ } -+ case 'w': { -+ if (mode_ != LATIN1) { -+ // Table is 256 entries, so all Latin1 characters can be tested. -+ BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z')); -+ } -+ ExternalReference map = -+ ExternalReference::re_word_character_map(isolate()); -+ __ li(a0, Operand(map)); -+ __ Add_d(a0, a0, current_character()); -+ __ Ld_bu(a0, MemOperand(a0, 0)); -+ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); -+ return true; -+ } -+ case 'W': { -+ Label done; -+ if (mode_ != LATIN1) { -+ // Table is 256 entries, so all Latin1 characters can be tested. -+ __ Branch(&done, hi, current_character(), Operand('z')); -+ } -+ ExternalReference map = -+ ExternalReference::re_word_character_map(isolate()); -+ __ li(a0, Operand(map)); -+ __ Add_d(a0, a0, current_character()); -+ __ Ld_bu(a0, MemOperand(a0, 0)); -+ BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); -+ if (mode_ != LATIN1) { -+ __ bind(&done); -+ } -+ return true; -+ } -+ case '*': -+ // Match any character. -+ return true; -+ // No custom implementation (yet): s(UC16), S(UC16). -+ default: -+ return false; -+ } -+} -+ -+void RegExpMacroAssemblerLA64::Fail() { -+ __ li(a0, Operand(FAILURE)); -+ __ jmp(&exit_label_); -+} -+ -+Handle RegExpMacroAssemblerLA64::GetCode(Handle source) { -+ Label return_v0; -+ if (0 /* todo masm_->has_exception()*/) { -+ // If the code gets corrupted due to long regular expressions and lack of -+ // space on trampolines, an internal exception flag is set. If this case -+ // is detected, we will jump into exit sequence right away. -+ //__ bind_to(&entry_label_, internal_failure_label_.pos()); -+ } else { -+ // Finalize code - write the entry point code now we know how many -+ // registers we need. -+ -+ // Entry code: -+ __ bind(&entry_label_); -+ -+ // Tell the system that we have a stack frame. Because the type is MANUAL, -+ // no is generated. -+ FrameScope scope(masm_, StackFrame::MANUAL); -+ -+ // Actually emit code to start a new stack frame. -+ // Push arguments -+ // Save callee-save registers. -+ // Start new stack frame. -+ // Store link register in existing stack-cell. -+ // Order here should correspond to order of offset constants in header file. -+ // TODO(plind): we save s0..s7, but ONLY use s3 here - use the regs -+ // or dont save. -+ RegList registers_to_retain = s0.bit() | s1.bit() | s2.bit() | s3.bit() | -+ s4.bit() | s5.bit() | s6.bit() | s7.bit(); -+ RegList argument_registers = a0.bit() | a1.bit() | a2.bit() | a3.bit(); -+ -+ argument_registers |= a4.bit() | a5.bit() | a6.bit() | a7.bit(); -+ -+ __ MultiPush(ra.bit(), fp.bit(), argument_registers | registers_to_retain); -+ // Set frame pointer in space for it if this is not a direct call -+ // from generated code. -+ // TODO(plind): this 8 is the # of argument regs, should have definition. -+ __ Add_d(frame_pointer(), sp, Operand(8 * kPointerSize)); -+ STATIC_ASSERT(kSuccessfulCaptures == kInputString - kSystemPointerSize); -+ __ mov(a0, zero_reg); -+ __ push(a0); // Make room for success counter and initialize it to 0. -+ STATIC_ASSERT(kStringStartMinusOne == -+ kSuccessfulCaptures - kSystemPointerSize); -+ __ push(a0); // Make room for "string start - 1" constant. -+ STATIC_ASSERT(kBacktrackCount == kStringStartMinusOne - kSystemPointerSize); -+ __ push(a0); // The backtrack counter -+ -+ // Check if we have space on the stack for registers. -+ Label stack_limit_hit; -+ Label stack_ok; -+ -+ ExternalReference stack_limit = -+ ExternalReference::address_of_jslimit(masm_->isolate()); -+ __ li(a0, Operand(stack_limit)); -+ __ Ld_d(a0, MemOperand(a0, 0)); -+ __ Sub_d(a0, sp, a0); -+ // Handle it if the stack pointer is already below the stack limit. -+ __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg)); -+ // Check if there is room for the variable number of registers above -+ // the stack limit. -+ __ Branch(&stack_ok, hs, a0, Operand(num_registers_ * kPointerSize)); -+ // Exit with OutOfMemory exception. There is not enough space on the stack -+ // for our working registers. -+ __ li(a0, Operand(EXCEPTION)); -+ __ jmp(&return_v0); -+ -+ __ bind(&stack_limit_hit); -+ CallCheckStackGuardState(a0); -+ // If returned value is non-zero, we exit with the returned value as result. -+ __ Branch(&return_v0, ne, a0, Operand(zero_reg)); -+ -+ __ bind(&stack_ok); -+ // Allocate space on stack for registers. -+ __ Sub_d(sp, sp, Operand(num_registers_ * kPointerSize)); -+ // Load string end. -+ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ // Load input start. -+ __ Ld_d(a0, MemOperand(frame_pointer(), kInputStart)); -+ // Find negative length (offset of start relative to end). -+ __ Sub_d(current_input_offset(), a0, end_of_input_address()); -+ // Set a0 to address of char before start of the input string -+ // (effectively string position -1). -+ __ Ld_d(a1, MemOperand(frame_pointer(), kStartIndex)); -+ __ Sub_d(a0, current_input_offset(), Operand(char_size())); -+ __ slli_d(t1, a1, (mode_ == UC16) ? 1 : 0); -+ __ Sub_d(a0, a0, t1); -+ // Store this value in a local variable, for use when clearing -+ // position registers. -+ __ St_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ -+ // Initialize code pointer register -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ -+ Label load_char_start_regexp, start_regexp; -+ // Load newline if index is at start, previous character otherwise. -+ __ Branch(&load_char_start_regexp, ne, a1, Operand(zero_reg)); -+ __ li(current_character(), Operand('\n')); -+ __ jmp(&start_regexp); -+ -+ // Global regexp restarts matching here. -+ __ bind(&load_char_start_regexp); -+ // Load previous char as initial value of current character register. -+ LoadCurrentCharacterUnchecked(-1, 1); -+ __ bind(&start_regexp); -+ -+ // Initialize on-stack registers. -+ if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. -+ // Fill saved registers with initial value = start offset - 1. -+ if (num_saved_registers_ > 8) { -+ // Address of register 0. -+ __ Add_d(a1, frame_pointer(), Operand(kRegisterZero)); -+ __ li(a2, Operand(num_saved_registers_)); -+ Label init_loop; -+ __ bind(&init_loop); -+ __ St_d(a0, MemOperand(a1, 0)); -+ __ Add_d(a1, a1, Operand(-kPointerSize)); -+ __ Sub_d(a2, a2, Operand(1)); -+ __ Branch(&init_loop, ne, a2, Operand(zero_reg)); -+ } else { -+ for (int i = 0; i < num_saved_registers_; i++) { -+ __ St_d(a0, register_location(i)); -+ } -+ } -+ } -+ -+ // Initialize backtrack stack pointer. -+ __ Ld_d(backtrack_stackpointer(), -+ MemOperand(frame_pointer(), kStackHighEnd)); -+ -+ __ jmp(&start_label_); -+ -+ // Exit code: -+ if (success_label_.is_linked()) { -+ // Save captures when successful. -+ __ bind(&success_label_); -+ if (num_saved_registers_ > 0) { -+ // Copy captures to output. -+ __ Ld_d(a1, MemOperand(frame_pointer(), kInputStart)); -+ __ Ld_d(a0, MemOperand(frame_pointer(), kRegisterOutput)); -+ __ Ld_d(a2, MemOperand(frame_pointer(), kStartIndex)); -+ __ Sub_d(a1, end_of_input_address(), a1); -+ // a1 is length of input in bytes. -+ if (mode_ == UC16) { -+ __ srli_d(a1, a1, 1); -+ } -+ // a1 is length of input in characters. -+ __ Add_d(a1, a1, Operand(a2)); -+ // a1 is length of string in characters. -+ -+ DCHECK_EQ(0, num_saved_registers_ % 2); -+ // Always an even number of capture registers. This allows us to -+ // unroll the loop once to add an operation between a load of a register -+ // and the following use of that register. -+ for (int i = 0; i < num_saved_registers_; i += 2) { -+ __ Ld_d(a2, register_location(i)); -+ __ Ld_d(a3, register_location(i + 1)); -+ if (i == 0 && global_with_zero_length_check()) { -+ // Keep capture start in a4 for the zero-length check later. -+ __ mov(t3, a2); -+ } -+ if (mode_ == UC16) { -+ __ srai_d(a2, a2, 1); -+ __ Add_d(a2, a2, a1); -+ __ srai_d(a3, a3, 1); -+ __ Add_d(a3, a3, a1); -+ } else { -+ __ Add_d(a2, a1, Operand(a2)); -+ __ Add_d(a3, a1, Operand(a3)); -+ } -+ // V8 expects the output to be an int32_t array. -+ __ St_w(a2, MemOperand(a0, 0)); -+ __ Add_d(a0, a0, kIntSize); -+ __ St_w(a3, MemOperand(a0, 0)); -+ __ Add_d(a0, a0, kIntSize); -+ } -+ } -+ -+ if (global()) { -+ // Restart matching if the regular expression is flagged as global. -+ __ Ld_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ __ Ld_d(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); -+ __ Ld_d(a2, MemOperand(frame_pointer(), kRegisterOutput)); -+ // Increment success counter. -+ __ Add_d(a0, a0, 1); -+ __ St_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ // Capture results have been stored, so the number of remaining global -+ // output registers is reduced by the number of stored captures. -+ __ Sub_d(a1, a1, num_saved_registers_); -+ // Check whether we have enough room for another set of capture results. -+ //__ mov(v0, a0); -+ __ Branch(&return_v0, lt, a1, Operand(num_saved_registers_)); -+ -+ __ St_d(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); -+ // Advance the location for output. -+ __ Add_d(a2, a2, num_saved_registers_ * kIntSize); -+ __ St_d(a2, MemOperand(frame_pointer(), kRegisterOutput)); -+ -+ // Prepare a0 to initialize registers with its value in the next run. -+ __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ -+ if (global_with_zero_length_check()) { -+ // Special case for zero-length matches. -+ // t3: capture start index -+ // Not a zero-length match, restart. -+ __ Branch(&load_char_start_regexp, ne, current_input_offset(), -+ Operand(t3)); -+ // Offset from the end is zero if we already reached the end. -+ __ Branch(&exit_label_, eq, current_input_offset(), -+ Operand(zero_reg)); -+ // Advance current position after a zero-length match. -+ Label advance; -+ __ bind(&advance); -+ __ Add_d(current_input_offset(), current_input_offset(), -+ Operand((mode_ == UC16) ? 2 : 1)); -+ if (global_unicode()) CheckNotInSurrogatePair(0, &advance); -+ } -+ -+ __ Branch(&load_char_start_regexp); -+ } else { -+ __ li(a0, Operand(SUCCESS)); -+ } -+ } -+ // Exit and return v0. -+ __ bind(&exit_label_); -+ if (global()) { -+ __ Ld_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ } -+ -+ __ bind(&return_v0); -+ // Skip sp past regexp registers and local variables.. -+ __ mov(sp, frame_pointer()); -+ // Restore registers s0..s7 and return (restoring ra to pc). -+ __ MultiPop(ra.bit(), fp.bit(), registers_to_retain); -+ __ Ret(); -+ -+ // Backtrack code (branch target for conditional backtracks). -+ if (backtrack_label_.is_linked()) { -+ __ bind(&backtrack_label_); -+ Backtrack(); -+ } -+ -+ Label exit_with_exception; -+ -+ // Preempt-code. -+ if (check_preempt_label_.is_linked()) { -+ SafeCallTarget(&check_preempt_label_); -+ // Put regexp engine registers on stack. -+ RegList regexp_registers_to_retain = current_input_offset().bit() | -+ current_character().bit() | -+ backtrack_stackpointer().bit(); -+ __ MultiPush(regexp_registers_to_retain); -+ CallCheckStackGuardState(a0); -+ __ MultiPop(regexp_registers_to_retain); -+ // If returning non-zero, we should end execution with the given -+ // result as return value. -+ __ Branch(&return_v0, ne, a0, Operand(zero_reg)); -+ -+ // String might have moved: Reload end of string from frame. -+ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ SafeReturn(); -+ } -+ -+ // Backtrack stack overflow code. -+ if (stack_overflow_label_.is_linked()) { -+ SafeCallTarget(&stack_overflow_label_); -+ // Reached if the backtrack-stack limit has been hit. -+ // Put regexp engine registers on stack first. -+ RegList regexp_registers = -+ current_input_offset().bit() | current_character().bit(); -+ __ MultiPush(regexp_registers); -+ -+ // Call GrowStack(backtrack_stackpointer(), &stack_base) -+ static const int num_arguments = 3; -+ __ PrepareCallCFunction(num_arguments, a0); -+ __ mov(a0, backtrack_stackpointer()); -+ __ Add_d(a1, frame_pointer(), Operand(kStackHighEnd)); -+ __ li(a2, Operand(ExternalReference::isolate_address(masm_->isolate()))); -+ ExternalReference grow_stack = -+ ExternalReference::re_grow_stack(masm_->isolate()); -+ __ CallCFunction(grow_stack, num_arguments); -+ // Restore regexp registers. -+ __ MultiPop(regexp_registers); -+ // If return nullptr, we have failed to grow the stack, and -+ // must exit with a stack-overflow exception. -+ __ Branch(&exit_with_exception, eq, a0, Operand(zero_reg)); -+ // Otherwise use return value as new stack pointer. -+ __ mov(backtrack_stackpointer(), a0); -+ // Restore saved registers and continue. -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ SafeReturn(); -+ } -+ -+ if (exit_with_exception.is_linked()) { -+ // If any of the code above needed to exit with an exception. -+ __ bind(&exit_with_exception); -+ // Exit with Result EXCEPTION(-1) to signal thrown exception. -+ __ li(a0, Operand(EXCEPTION)); -+ __ jmp(&return_v0); -+ } -+ } -+ -+ CodeDesc code_desc; -+ masm_->GetCode(isolate(), &code_desc); -+ Handle code = -+ Factory::CodeBuilder(isolate(), code_desc, CodeKind::REGEXP) -+ .set_self_reference(masm_->CodeObject()) -+ .Build(); -+ LOG(masm_->isolate(), -+ RegExpCodeCreateEvent(Handle::cast(code), source)); -+ return Handle::cast(code); -+} -+ -+void RegExpMacroAssemblerLA64::GoTo(Label* to) { -+ if (to == nullptr) { -+ Backtrack(); -+ return; -+ } -+ __ jmp(to); -+ return; -+} -+ -+void RegExpMacroAssemblerLA64::IfRegisterGE(int reg, int comparand, -+ Label* if_ge) { -+ __ Ld_d(a0, register_location(reg)); -+ BranchOrBacktrack(if_ge, ge, a0, Operand(comparand)); -+} -+ -+void RegExpMacroAssemblerLA64::IfRegisterLT(int reg, int comparand, -+ Label* if_lt) { -+ __ Ld_d(a0, register_location(reg)); -+ BranchOrBacktrack(if_lt, lt, a0, Operand(comparand)); -+} -+ -+void RegExpMacroAssemblerLA64::IfRegisterEqPos(int reg, Label* if_eq) { -+ __ Ld_d(a0, register_location(reg)); -+ BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset())); -+} -+ -+RegExpMacroAssembler::IrregexpImplementation -+RegExpMacroAssemblerLA64::Implementation() { -+ return kLA64Implementation; -+} -+ -+void RegExpMacroAssemblerLA64::PopCurrentPosition() { -+ Pop(current_input_offset()); -+} -+ -+void RegExpMacroAssemblerLA64::PopRegister(int register_index) { -+ Pop(a0); -+ __ St_d(a0, register_location(register_index)); -+} -+ -+void RegExpMacroAssemblerLA64::PushBacktrack(Label* label) { -+ if (label->is_bound()) { -+ int target = label->pos(); -+ __ li(a0, Operand(target + Code::kHeaderSize - kHeapObjectTag)); -+ } else { -+ // TODO: Optimize like arm64 without ld_wu? -+ Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); -+ Label after_constant; -+ __ Branch(&after_constant); -+ int offset = masm_->pc_offset(); -+ int cp_offset = offset + Code::kHeaderSize - kHeapObjectTag; -+ //__ emit(0); -+ __ nop(); -+ masm_->label_at_put(label, offset); -+ __ bind(&after_constant); -+ if (is_int12(cp_offset)) { -+ __ Ld_wu(a0, MemOperand(code_pointer(), cp_offset)); -+ } else { -+ __ Add_d(a0, code_pointer(), cp_offset); -+ __ Ld_wu(a0, MemOperand(a0, 0)); -+ } -+ } -+ Push(a0); -+ CheckStackLimit(); -+} -+ -+void RegExpMacroAssemblerLA64::PushCurrentPosition() { -+ Push(current_input_offset()); -+} -+ -+void RegExpMacroAssemblerLA64::PushRegister(int register_index, -+ StackCheckFlag check_stack_limit) { -+ __ Ld_d(a0, register_location(register_index)); -+ Push(a0); -+ if (check_stack_limit) CheckStackLimit(); -+} -+ -+void RegExpMacroAssemblerLA64::ReadCurrentPositionFromRegister(int reg) { -+ __ Ld_d(current_input_offset(), register_location(reg)); -+} -+ -+void RegExpMacroAssemblerLA64::ReadStackPointerFromRegister(int reg) { -+ __ Ld_d(backtrack_stackpointer(), register_location(reg)); -+ __ Ld_d(a0, MemOperand(frame_pointer(), kStackHighEnd)); -+ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0)); -+} -+ -+void RegExpMacroAssemblerLA64::SetCurrentPositionFromEnd(int by) { -+ Label after_position; -+ __ Branch(&after_position, ge, current_input_offset(), -+ Operand(-by * char_size())); -+ __ li(current_input_offset(), -by * char_size()); -+ // On RegExp code entry (where this operation is used), the character before -+ // the current position is expected to be already loaded. -+ // We have advanced the position, so it's safe to read backwards. -+ LoadCurrentCharacterUnchecked(-1, 1); -+ __ bind(&after_position); -+} -+ -+void RegExpMacroAssemblerLA64::SetRegister(int register_index, int to) { -+ DCHECK(register_index >= num_saved_registers_); // Reserved for positions! -+ __ li(a0, Operand(to)); -+ __ St_d(a0, register_location(register_index)); -+} -+ -+bool RegExpMacroAssemblerLA64::Succeed() { -+ __ jmp(&success_label_); -+ return global(); -+} -+ -+void RegExpMacroAssemblerLA64::WriteCurrentPositionToRegister(int reg, -+ int cp_offset) { -+ if (cp_offset == 0) { -+ __ St_d(current_input_offset(), register_location(reg)); -+ } else { -+ __ Add_d(a0, current_input_offset(), Operand(cp_offset * char_size())); -+ __ St_d(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerLA64::ClearRegisters(int reg_from, int reg_to) { -+ DCHECK(reg_from <= reg_to); -+ __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ for (int reg = reg_from; reg <= reg_to; reg++) { -+ __ St_d(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerLA64::WriteStackPointerToRegister(int reg) { -+ __ Ld_d(a1, MemOperand(frame_pointer(), kStackHighEnd)); -+ __ Sub_d(a0, backtrack_stackpointer(), a1); -+ __ St_d(a0, register_location(reg)); -+} -+ -+bool RegExpMacroAssemblerLA64::CanReadUnaligned() { return false; } -+ -+// Private methods: -+ -+void RegExpMacroAssemblerLA64::CallCheckStackGuardState(Register scratch) { -+ DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); -+ DCHECK(!masm_->options().isolate_independent_code); -+ -+ int stack_alignment = base::OS::ActivationFrameAlignment(); -+ -+ // Align the stack pointer and save the original sp value on the stack. -+ __ mov(scratch, sp); -+ __ Sub_d(sp, sp, Operand(kPointerSize)); -+ DCHECK(base::bits::IsPowerOfTwo(stack_alignment)); -+ __ And(sp, sp, Operand(-stack_alignment)); -+ __ St_d(scratch, MemOperand(sp, 0)); -+ -+ __ mov(a2, frame_pointer()); -+ // Code of self. -+ __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ -+ // We need to make room for the return address on the stack. -+ DCHECK(IsAligned(stack_alignment, kPointerSize)); -+ __ Sub_d(sp, sp, Operand(stack_alignment)); -+ -+ // The stack pointer now points to cell where the return address will be -+ // written. Arguments are in registers, meaning we treat the return address as -+ // argument 5. Since DirectCEntry will handle allocating space for the C -+ // argument slots, we don't need to care about that here. This is how the -+ // stack will look (sp meaning the value of sp at this moment): -+ // [sp + 3] - empty slot if needed for alignment. -+ // [sp + 2] - saved sp. -+ // [sp + 1] - second word reserved for return value. -+ // [sp + 0] - first word reserved for return value. -+ -+ // a0 will point to the return address, placed by DirectCEntry. -+ __ mov(a0, sp); -+ -+ ExternalReference stack_guard_check = -+ ExternalReference::re_check_stack_guard_state(masm_->isolate()); -+ __ li(t7, Operand(stack_guard_check)); -+ -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ CHECK(Builtins::IsIsolateIndependent(Builtins::kDirectCEntry)); -+ Address entry = d.InstructionStartOfBuiltin(Builtins::kDirectCEntry); -+ __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ __ Call(kScratchReg); -+ -+ // DirectCEntry allocated space for the C argument slots so we have to -+ // drop them with the return address from the stack with loading saved sp. -+ // At this point stack must look: -+ // [sp + 7] - empty slot if needed for alignment. -+ // [sp + 6] - saved sp. -+ // [sp + 5] - second word reserved for return value. -+ // [sp + 4] - first word reserved for return value. -+ // [sp + 3] - C argument slot. -+ // [sp + 2] - C argument slot. -+ // [sp + 1] - C argument slot. -+ // [sp + 0] - C argument slot. -+ __ Ld_d(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize)); -+ -+ __ li(code_pointer(), Operand(masm_->CodeObject())); -+} -+ -+// Helper function for reading a value out of a stack frame. -+template -+static T& frame_entry(Address re_frame, int frame_offset) { -+ return reinterpret_cast(Memory(re_frame + frame_offset)); -+} -+ -+template -+static T* frame_entry_address(Address re_frame, int frame_offset) { -+ return reinterpret_cast(re_frame + frame_offset); -+} -+ -+int64_t RegExpMacroAssemblerLA64::CheckStackGuardState(Address* return_address, -+ Address raw_code, -+ Address re_frame) { -+ Code re_code = Code::cast(Object(raw_code)); -+ return NativeRegExpMacroAssembler::CheckStackGuardState( -+ frame_entry(re_frame, kIsolate), -+ static_cast(frame_entry(re_frame, kStartIndex)), -+ static_cast( -+ frame_entry(re_frame, kDirectCall)), -+ return_address, re_code, -+ frame_entry_address
(re_frame, kInputString), -+ frame_entry_address(re_frame, kInputStart), -+ frame_entry_address(re_frame, kInputEnd)); -+} -+ -+MemOperand RegExpMacroAssemblerLA64::register_location(int register_index) { -+ DCHECK(register_index < (1 << 30)); -+ if (num_registers_ <= register_index) { -+ num_registers_ = register_index + 1; -+ } -+ return MemOperand(frame_pointer(), -+ kRegisterZero - register_index * kPointerSize); -+} -+ -+void RegExpMacroAssemblerLA64::CheckPosition(int cp_offset, -+ Label* on_outside_input) { -+ if (cp_offset >= 0) { -+ BranchOrBacktrack(on_outside_input, ge, current_input_offset(), -+ Operand(-cp_offset * char_size())); -+ } else { -+ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add_d(a0, current_input_offset(), Operand(cp_offset * char_size())); -+ BranchOrBacktrack(on_outside_input, le, a0, Operand(a1)); -+ } -+} -+ -+void RegExpMacroAssemblerLA64::BranchOrBacktrack(Label* to, Condition condition, -+ Register rs, -+ const Operand& rt) { -+ if (condition == al) { // Unconditional. -+ if (to == nullptr) { -+ Backtrack(); -+ return; -+ } -+ __ jmp(to); -+ return; -+ } -+ if (to == nullptr) { -+ __ Branch(&backtrack_label_, condition, rs, rt); -+ return; -+ } -+ __ Branch(to, condition, rs, rt); -+} -+ -+void RegExpMacroAssemblerLA64::SafeCall(Label* to, Condition cond, Register rs, -+ const Operand& rt) { -+ __ Branch(to, cond, rs, rt, true); -+} -+ -+void RegExpMacroAssemblerLA64::SafeReturn() { -+ __ pop(ra); -+ __ Add_d(t1, ra, Operand(masm_->CodeObject())); -+ __ Jump(t1); -+} -+ -+void RegExpMacroAssemblerLA64::SafeCallTarget(Label* name) { -+ __ bind(name); -+ __ Sub_d(ra, ra, Operand(masm_->CodeObject())); -+ __ push(ra); -+} -+ -+void RegExpMacroAssemblerLA64::Push(Register source) { -+ DCHECK(source != backtrack_stackpointer()); -+ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), -+ Operand(-kIntSize)); -+ __ St_w(source, MemOperand(backtrack_stackpointer(), 0)); -+} -+ -+void RegExpMacroAssemblerLA64::Pop(Register target) { -+ DCHECK(target != backtrack_stackpointer()); -+ __ Ld_w(target, MemOperand(backtrack_stackpointer(), 0)); -+ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), kIntSize); -+} -+ -+void RegExpMacroAssemblerLA64::CheckPreemption() { -+ // Check for preemption. -+ ExternalReference stack_limit = -+ ExternalReference::address_of_jslimit(masm_->isolate()); -+ __ li(a0, Operand(stack_limit)); -+ __ Ld_d(a0, MemOperand(a0, 0)); -+ SafeCall(&check_preempt_label_, ls, sp, Operand(a0)); -+} -+ -+void RegExpMacroAssemblerLA64::CheckStackLimit() { -+ ExternalReference stack_limit = -+ ExternalReference::address_of_regexp_stack_limit_address( -+ masm_->isolate()); -+ -+ __ li(a0, Operand(stack_limit)); -+ __ Ld_d(a0, MemOperand(a0, 0)); -+ SafeCall(&stack_overflow_label_, ls, backtrack_stackpointer(), Operand(a0)); -+} -+ -+void RegExpMacroAssemblerLA64::LoadCurrentCharacterUnchecked(int cp_offset, -+ int characters) { -+ Register offset = current_input_offset(); -+ if (cp_offset != 0) { -+ // t3 is not being used to store the capture start index at this point. -+ __ Add_d(t3, current_input_offset(), Operand(cp_offset * char_size())); -+ offset = t3; -+ } -+ // We assume that we cannot do unaligned loads on LA64, so this function -+ // must only be used to load a single character at a time. -+ DCHECK_EQ(1, characters); -+ __ Add_d(t1, end_of_input_address(), Operand(offset)); -+ if (mode_ == LATIN1) { -+ __ Ld_bu(current_character(), MemOperand(t1, 0)); -+ } else { -+ DCHECK(mode_ == UC16); -+ __ Ld_hu(current_character(), MemOperand(t1, 0)); -+ } -+} -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_LA64 -diff --git a/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h b/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h -new file mode 100644 -index 000000000..7985cf674 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h -@@ -0,0 +1,211 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ -+#define V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ -+ -+#include "src/codegen/loongarch64/assembler-loongarch64.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/regexp/regexp-macro-assembler.h" -+ -+namespace v8 { -+namespace internal { -+ -+class V8_EXPORT_PRIVATE RegExpMacroAssemblerLA64 -+ : public NativeRegExpMacroAssembler { -+ public: -+ RegExpMacroAssemblerLA64(Isolate* isolate, Zone* zone, Mode mode, -+ int registers_to_save); -+ virtual ~RegExpMacroAssemblerLA64(); -+ virtual int stack_limit_slack(); -+ virtual void AdvanceCurrentPosition(int by); -+ virtual void AdvanceRegister(int reg, int by); -+ virtual void Backtrack(); -+ virtual void Bind(Label* label); -+ virtual void CheckAtStart(int cp_offset, Label* on_at_start); -+ virtual void CheckCharacter(uint32_t c, Label* on_equal); -+ virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, -+ Label* on_equal); -+ virtual void CheckCharacterGT(uc16 limit, Label* on_greater); -+ virtual void CheckCharacterLT(uc16 limit, Label* on_less); -+ // A "greedy loop" is a loop that is both greedy and with a simple -+ // body. It has a particularly simple implementation. -+ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); -+ virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start); -+ virtual void CheckNotBackReference(int start_reg, bool read_backward, -+ Label* on_no_match); -+ virtual void CheckNotBackReferenceIgnoreCase(int start_reg, -+ bool read_backward, bool unicode, -+ Label* on_no_match); -+ virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); -+ virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, -+ Label* on_not_equal); -+ virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask, -+ Label* on_not_equal); -+ virtual void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range); -+ virtual void CheckCharacterNotInRange(uc16 from, uc16 to, -+ Label* on_not_in_range); -+ virtual void CheckBitInTable(Handle table, Label* on_bit_set); -+ -+ // Checks whether the given offset from the current position is before -+ // the end of the string. -+ virtual void CheckPosition(int cp_offset, Label* on_outside_input); -+ virtual bool CheckSpecialCharacterClass(uc16 type, Label* on_no_match); -+ virtual void Fail(); -+ virtual Handle GetCode(Handle source); -+ virtual void GoTo(Label* label); -+ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); -+ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); -+ virtual void IfRegisterEqPos(int reg, Label* if_eq); -+ virtual IrregexpImplementation Implementation(); -+ virtual void LoadCurrentCharacterUnchecked(int cp_offset, -+ int character_count); -+ virtual void PopCurrentPosition(); -+ virtual void PopRegister(int register_index); -+ virtual void PushBacktrack(Label* label); -+ virtual void PushCurrentPosition(); -+ virtual void PushRegister(int register_index, -+ StackCheckFlag check_stack_limit); -+ virtual void ReadCurrentPositionFromRegister(int reg); -+ virtual void ReadStackPointerFromRegister(int reg); -+ virtual void SetCurrentPositionFromEnd(int by); -+ virtual void SetRegister(int register_index, int to); -+ virtual bool Succeed(); -+ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); -+ virtual void ClearRegisters(int reg_from, int reg_to); -+ virtual void WriteStackPointerToRegister(int reg); -+ virtual bool CanReadUnaligned(); -+ -+ // Called from RegExp if the stack-guard is triggered. -+ // If the code object is relocated, the return address is fixed before -+ // returning. -+ // {raw_code} is an Address because this is called via ExternalReference. -+ static int64_t CheckStackGuardState(Address* return_address, Address raw_code, -+ Address re_frame); -+ -+ void print_regexp_frame_constants(); -+ -+ private: -+ // Offsets from frame_pointer() of function parameters and stored registers. -+ static const int kFramePointer = 0; -+ -+ // Above the frame pointer - Stored registers and stack passed parameters. -+ // Registers s0 to s7, fp, and ra. -+ static const int kStoredRegisters = kFramePointer; -+ // Return address (stored from link register, read into pc on return). -+ -+ // TODO(plind): This 9 - is 8 s-regs (s0..s7) plus fp. -+ -+ static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize; -+ // Stack frame header. -+ static const int kStackFrameHeader = kReturnAddress; -+ // Stack parameters placed by caller. -+ static const int kIsolate = kStackFrameHeader + kPointerSize; -+ -+ // Below the frame pointer. -+ // Register parameters stored by setup code. -+ static const int kDirectCall = kFramePointer - kPointerSize; -+ static const int kStackHighEnd = kDirectCall - kPointerSize; -+ static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; -+ static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; -+ static const int kInputEnd = kRegisterOutput - kPointerSize; -+ static const int kInputStart = kInputEnd - kPointerSize; -+ static const int kStartIndex = kInputStart - kPointerSize; -+ static const int kInputString = kStartIndex - kPointerSize; -+ // When adding local variables remember to push space for them in -+ // the frame in GetCode. -+ static const int kSuccessfulCaptures = kInputString - kPointerSize; -+ static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize; -+ static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize; -+ // First register address. Following registers are below it on the stack. -+ static const int kRegisterZero = kBacktrackCount - kSystemPointerSize; -+ -+ // Initial size of code buffer. -+ static const int kRegExpCodeSize = 1024; -+ -+ // Check whether preemption has been requested. -+ void CheckPreemption(); -+ -+ // Check whether we are exceeding the stack limit on the backtrack stack. -+ void CheckStackLimit(); -+ -+ // Generate a call to CheckStackGuardState. -+ void CallCheckStackGuardState(Register scratch); -+ -+ // The ebp-relative location of a regexp register. -+ MemOperand register_location(int register_index); -+ -+ // Register holding the current input position as negative offset from -+ // the end of the string. -+ inline Register current_input_offset() { return a6; } -+ -+ // The register containing the current character after LoadCurrentCharacter. -+ inline Register current_character() { return a7; } -+ -+ // Register holding address of the end of the input string. -+ inline Register end_of_input_address() { return t2; } -+ -+ // Register holding the frame address. Local variables, parameters and -+ // regexp registers are addressed relative to this. -+ inline Register frame_pointer() { return fp; } -+ -+ // The register containing the backtrack stack top. Provides a meaningful -+ // name to the register. -+ inline Register backtrack_stackpointer() { return t0; } -+ -+ // Register holding pointer to the current code object. -+ inline Register code_pointer() { return a5; } -+ -+ // Byte size of chars in the string to match (decided by the Mode argument). -+ inline int char_size() { return static_cast(mode_); } -+ -+ // Equivalent to a conditional branch to the label, unless the label -+ // is nullptr, in which case it is a conditional Backtrack. -+ void BranchOrBacktrack(Label* to, Condition condition, Register rs, -+ const Operand& rt); -+ -+ // Call and return internally in the generated code in a way that -+ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) -+ inline void SafeCall(Label* to, Condition cond, Register rs, -+ const Operand& rt); -+ inline void SafeReturn(); -+ inline void SafeCallTarget(Label* name); -+ -+ // Pushes the value of a register on the backtrack stack. Decrements the -+ // stack pointer by a word size and stores the register's value there. -+ inline void Push(Register source); -+ -+ // Pops a value from the backtrack stack. Reads the word at the stack pointer -+ // and increments it by a word size. -+ inline void Pop(Register target); -+ -+ Isolate* isolate() const { return masm_->isolate(); } -+ -+ MacroAssembler* masm_; -+ -+ // Which mode to generate code for (Latin1 or UC16). -+ Mode mode_; -+ -+ // One greater than maximal register index actually used. -+ int num_registers_; -+ -+ // Number of registers to output at the end (the saved registers -+ // are always 0..num_saved_registers_-1). -+ int num_saved_registers_; -+ -+ // Labels used internally. -+ Label entry_label_; -+ Label start_label_; -+ Label success_label_; -+ Label backtrack_label_; -+ Label exit_label_; -+ Label check_preempt_label_; -+ Label stack_overflow_label_; -+ Label internal_failure_label_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h -index 8ec12a0ae..878792213 100644 ---- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h -@@ -21,6 +21,8 @@ - #include "src/regexp/mips/regexp-macro-assembler-mips.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/regexp/s390/regexp-macro-assembler-s390.h" - #else -diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc -index d1feec4c3..9fc84c446 100644 ---- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc -@@ -15,7 +15,7 @@ RegExpMacroAssemblerTracer::RegExpMacroAssemblerTracer( - : RegExpMacroAssembler(isolate, assembler->zone()), assembler_(assembler) { - IrregexpImplementation type = assembler->Implementation(); - DCHECK_LT(type, 9); -- const char* impl_names[] = {"IA32", "ARM", "ARM64", "MIPS", "S390", -+ const char* impl_names[] = {"IA32", "ARM", "ARM64", "MIPS", "LA64", "S390", - "PPC", "X64", "X87", "Bytecode"}; - PrintF("RegExpMacroAssembler%s();\n", impl_names[type]); - } -diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h -index 52465610c..13091e809 100644 ---- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h -@@ -44,6 +44,7 @@ class RegExpMacroAssembler { - kARMImplementation, - kARM64Implementation, - kMIPSImplementation, -+ kLA64Implementation, - kS390Implementation, - kPPCImplementation, - kX64Implementation, -diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp.cc b/src/3rdparty/chromium/v8/src/regexp/regexp.cc -index 569acdab4..2e7bd9a32 100644 ---- a/src/3rdparty/chromium/v8/src/regexp/regexp.cc -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp.cc -@@ -815,6 +815,9 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, - #elif V8_TARGET_ARCH_MIPS64 - macro_assembler.reset(new RegExpMacroAssemblerMIPS(isolate, zone, mode, - output_register_count)); -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ macro_assembler.reset(new RegExpMacroAssemblerLA64(isolate, zone, mode, -+ output_register_count)); - #else - #error "Unsupported architecture" - #endif -diff --git a/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc b/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc -index 2b17ad52b..26fd5da40 100644 ---- a/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc -+++ b/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc -@@ -19,7 +19,8 @@ namespace internal { - - // Other platforms have CSA support, see builtins-sharedarraybuffer-gen.h. - #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ -- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ -+ V8_TARGET_ARCH_LOONGARCH64 - - namespace { - -diff --git a/src/3rdparty/chromium/v8/src/snapshot/deserializer.h b/src/3rdparty/chromium/v8/src/snapshot/deserializer.h -index ae410bacd..ed9ed6982 100644 ---- a/src/3rdparty/chromium/v8/src/snapshot/deserializer.h -+++ b/src/3rdparty/chromium/v8/src/snapshot/deserializer.h -@@ -30,6 +30,7 @@ class Object; - // Used for platforms with embedded constant pools to trigger deserialization - // of objects found in code. - #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ -+ defined(V8_TARGET_ARCH_LOONGARCH64) || \ - defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ - defined(V8_TARGET_ARCH_PPC64) || V8_EMBEDDED_CONSTANT_POOL - #define V8_CODE_EMBEDS_OBJECT_POINTER 1 -diff --git a/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc b/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc -index 070aaf51b..88db4a501 100644 ---- a/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc -+++ b/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc -@@ -151,7 +151,8 @@ int PlatformEmbeddedFileWriterGeneric::IndentedDataDirective( - - DataDirective PlatformEmbeddedFileWriterGeneric::ByteChunkDataDirective() - const { --#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) -+#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ -+ defined(V8_TARGET_ARCH_LOONGARCH64) - // MIPS uses a fixed 4 byte instruction set, using .long - // to prevent any unnecessary padding. - return kLong; -diff --git a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h -index 781fb87db..a1bbf1760 100644 ---- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h -@@ -46,6 +46,14 @@ constexpr RegList kLiftoffAssemblerGpCacheRegs = - constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( - f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26); - -+#elif V8_TARGET_ARCH_LOONGARCH64 -+/*todo*/ -+constexpr RegList kLiftoffAssemblerGpCacheRegs = -+ Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); -+ -+constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( -+ f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26); -+ - #elif V8_TARGET_ARCH_ARM - - // r7: cp, r10: root, r11: fp, r12: ip, r13: sp, r14: lr, r15: pc. -@@ -90,7 +98,7 @@ constexpr Condition kUnsignedLessEqual = below_equal; - constexpr Condition kUnsignedGreaterThan = above; - constexpr Condition kUnsignedGreaterEqual = above_equal; - --#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 - - constexpr Condition kEqual = eq; - constexpr Condition kUnequal = ne; -diff --git a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h -index e2bd99841..4c45162eb 100644 ---- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h -@@ -1351,6 +1351,8 @@ class LiftoffStackSlots { - #include "src/wasm/baseline/mips/liftoff-assembler-mips.h" - #elif V8_TARGET_ARCH_MIPS64 - #include "src/wasm/baseline/mips64/liftoff-assembler-mips64.h" -+#elif V8_TARGET_ARCH_LOONGARCH64 -+#include "src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/wasm/baseline/s390/liftoff-assembler-s390.h" - #else -diff --git a/src/3rdparty/chromium/v8/src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h b/src/3rdparty/chromium/v8/src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h -new file mode 100644 -index 000000000..4916ed227 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h -@@ -0,0 +1,2080 @@ -+// Copyright 2017 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ -+#define V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ -+ -+#include "src/wasm/baseline/liftoff-assembler.h" -+ -+namespace v8 { -+namespace internal { -+namespace wasm { -+ -+namespace liftoff { -+ -+// Liftoff Frames. -+// -+// slot Frame -+// +--------------------+--------------------------- -+// n+4 | optional padding slot to keep the stack 16 byte aligned. -+// n+3 | parameter n | -+// ... | ... | -+// 4 | parameter 1 | or parameter 2 -+// 3 | parameter 0 | or parameter 1 -+// 2 | (result address) | or parameter 0 -+// -----+--------------------+--------------------------- -+// 1 | return addr (ra) | -+// 0 | previous frame (fp)| -+// -----+--------------------+ <-- frame ptr (fp) -+// -1 | 0xa: WASM | -+// -2 | instance | -+// -----+--------------------+--------------------------- -+// -3 | slot 0 | ^ -+// -4 | slot 1 | | -+// | | Frame slots -+// | | | -+// | | v -+// | optional padding slot to keep the stack 16 byte aligned. -+// -----+--------------------+ <-- stack ptr (sp) -+// -+ -+// fp-8 holds the stack marker, fp-16 is the instance parameter. -+constexpr int kInstanceOffset = 16; -+ -+inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); } -+ -+inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } -+ -+inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr, -+ Register offset, uint32_t offset_imm) { -+ if (is_uint31(offset_imm)) { -+ if (offset == no_reg) return MemOperand(addr, offset_imm); -+ assm->add_d(kScratchReg, addr, offset); -+ return MemOperand(kScratchReg, offset_imm); -+ } -+ // Offset immediate does not fit in 31 bits. -+ assm->li(kScratchReg, Operand(offset_imm)); -+ assm->add_d(kScratchReg, kScratchReg, addr); -+ if (offset != no_reg) { -+ assm->add_d(kScratchReg, kScratchReg, offset); -+ } -+ return MemOperand(kScratchReg, 0); -+} -+ -+inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, -+ ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->Ld_w(dst.gp(), src); -+ break; -+ case ValueType::kI64: -+ assm->Ld_d(dst.gp(), src); -+ break; -+ case ValueType::kF32: -+ assm->Fld_s(dst.fp(), src); -+ break; -+ case ValueType::kF64: -+ assm->Fld_d(dst.fp(), src); -+ break; -+ case ValueType::kS128: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+inline void Store(LiftoffAssembler* assm, Register base, int32_t offset, -+ LiftoffRegister src, ValueType type) { -+ MemOperand dst(base, offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->St_w(src.gp(), dst); -+ break; -+ case ValueType::kI64: -+ assm->St_d(src.gp(), dst); -+ break; -+ case ValueType::kF32: -+ assm->Fst_s(src.fp(), dst); -+ break; -+ case ValueType::kF64: -+ assm->Fst_d(src.fp(), dst); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->addi_d(sp, sp, -kSystemPointerSize); -+ assm->St_w(reg.gp(), MemOperand(sp, 0)); -+ break; -+ case ValueType::kI64: -+ assm->push(reg.gp()); -+ break; -+ case ValueType::kF32: -+ assm->addi_d(sp, sp, -kSystemPointerSize); -+ assm->Fst_s(reg.fp(), MemOperand(sp, 0)); -+ break; -+ case ValueType::kF64: -+ assm->addi_d(sp, sp, -kSystemPointerSize); -+ assm->Fst_d(reg.fp(), MemOperand(sp, 0)); -+ break; -+ case ValueType::kS128: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+} // namespace liftoff -+ -+int LiftoffAssembler::PrepareStackFrame() { -+ int offset = pc_offset(); -+ // When constant that represents size of stack frame can't be represented -+ // as 16bit we need three instructions to add it to sp, so we reserve space -+ // for this case. -+ addi_d(sp, sp, 0); -+ nop(); -+ nop(); -+ return offset; -+} -+ -+void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params, -+ int stack_param_delta) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ -+ // Push the return address and frame pointer to complete the stack frame. -+ Ld_d(scratch, MemOperand(fp, 8)); -+ Push(scratch); -+ Ld_d(scratch, MemOperand(fp, 0)); -+ Push(scratch); -+ -+ // Shift the whole frame upwards. -+ int slot_count = num_callee_stack_params + 2; -+ for (int i = slot_count - 1; i >= 0; --i) { -+ Ld_d(scratch, MemOperand(sp, i * 8)); -+ St_d(scratch, MemOperand(fp, (i - stack_param_delta) * 8)); -+ } -+ -+ // Set the new stack and frame pointer. -+ addi_d(sp, fp, -stack_param_delta * 8); -+ Pop(ra, fp); -+} -+ -+void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) { -+ // We can't run out of space, just pass anything big enough to not cause the -+ // assembler to try to grow the buffer. -+ constexpr int kAvailableSpace = 256; -+ TurboAssembler patching_assembler( -+ nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, -+ ExternalAssemblerBuffer(buffer_start_ + offset, kAvailableSpace)); -+ // If bytes can be represented as 16bit, daddiu will be generated and two -+ // nops will stay untouched. Otherwise, lui-ori sequence will load it to -+ // register and, as third instruction, daddu will be generated. -+ patching_assembler.Add_d(sp, sp, Operand(-frame_size)); -+} -+ -+void LiftoffAssembler::FinishCode() {} -+ -+void LiftoffAssembler::AbortCompilation() {} -+ -+// static -+constexpr int LiftoffAssembler::StaticStackFrameSize() { -+ return liftoff::kInstanceOffset; -+} -+ -+int LiftoffAssembler::SlotSizeForType(ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kS128: -+ return type.element_size_bytes(); -+ default: -+ return kStackSlotSize; -+ } -+} -+ -+bool LiftoffAssembler::NeedsAlignment(ValueType type) { -+ return type.kind() == ValueType::kS128 || type.is_reference_type(); -+} -+ -+void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value, -+ RelocInfo::Mode rmode) { -+ switch (value.type().kind()) { -+ case ValueType::kI32: -+ TurboAssembler::li(reg.gp(), Operand(value.to_i32(), rmode)); -+ break; -+ case ValueType::kI64: -+ TurboAssembler::li(reg.gp(), Operand(value.to_i64(), rmode)); -+ break; -+ case ValueType::kF32: -+ TurboAssembler::Move(reg.fp(), value.to_f32_boxed().get_bits()); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::Move(reg.fp(), value.to_f64_boxed().get_bits()); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, -+ int size) { -+ DCHECK_LE(offset, kMaxInt); -+ Ld_d(dst, liftoff::GetInstanceOperand()); -+ DCHECK(size == 4 || size == 8); -+ if (size == 4) { -+ Ld_w(dst, MemOperand(dst, offset)); -+ } else { -+ Ld_d(dst, MemOperand(dst, offset)); -+ } -+} -+ -+void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, -+ uint32_t offset) { -+ LoadFromInstance(dst, offset, kTaggedSize); -+} -+ -+void LiftoffAssembler::SpillInstance(Register instance) { -+ St_d(instance, liftoff::GetInstanceOperand()); -+} -+ -+void LiftoffAssembler::FillInstanceInto(Register dst) { -+ Ld_d(dst, liftoff::GetInstanceOperand()); -+} -+ -+void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, -+ Register offset_reg, -+ int32_t offset_imm, -+ LiftoffRegList pinned) { -+ DCHECK_GE(offset_imm, 0); -+ STATIC_ASSERT(kTaggedSize == kInt64Size); -+ Load(LiftoffRegister(dst), src_addr, offset_reg, -+ static_cast(offset_imm), LoadType::kI64Load, pinned); -+} -+ -+void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, int32_t offset_imm, -+ LiftoffRegister src, -+ LiftoffRegList pinned) { -+ bailout(kRefTypes, "GlobalSet"); -+} -+ -+void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, LiftoffRegList pinned, -+ uint32_t* protected_load_pc, bool is_load_mem) { -+ MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm); -+ -+ if (protected_load_pc) *protected_load_pc = pc_offset(); -+ switch (type.value()) { -+ case LoadType::kI32Load8U: -+ case LoadType::kI64Load8U: -+ Ld_bu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load8S: -+ case LoadType::kI64Load8S: -+ Ld_b(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load16U: -+ case LoadType::kI64Load16U: -+ TurboAssembler::Ld_hu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load16S: -+ case LoadType::kI64Load16S: -+ TurboAssembler::Ld_h(dst.gp(), src_op); -+ break; -+ case LoadType::kI64Load32U: -+ TurboAssembler::Ld_wu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load: -+ case LoadType::kI64Load32S: -+ TurboAssembler::Ld_w(dst.gp(), src_op); -+ break; -+ case LoadType::kI64Load: -+ TurboAssembler::Ld_d(dst.gp(), src_op); -+ break; -+ case LoadType::kF32Load: -+ TurboAssembler::Fld_s(dst.fp(), src_op); -+ break; -+ case LoadType::kF64Load: -+ TurboAssembler::Fld_d(dst.fp(), src_op); -+ break; -+ case LoadType::kS128Load: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister src, -+ StoreType type, LiftoffRegList pinned, -+ uint32_t* protected_store_pc, bool is_store_mem) { -+ MemOperand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm); -+ -+ if (protected_store_pc) *protected_store_pc = pc_offset(); -+ switch (type.value()) { -+ case StoreType::kI32Store8: -+ case StoreType::kI64Store8: -+ St_b(src.gp(), dst_op); -+ break; -+ case StoreType::kI32Store16: -+ case StoreType::kI64Store16: -+ TurboAssembler::St_h(src.gp(), dst_op); -+ break; -+ case StoreType::kI32Store: -+ case StoreType::kI64Store32: -+ TurboAssembler::St_w(src.gp(), dst_op); -+ break; -+ case StoreType::kI64Store: -+ TurboAssembler::St_d(src.gp(), dst_op); -+ break; -+ case StoreType::kF32Store: -+ TurboAssembler::Fst_s(src.fp(), dst_op); -+ break; -+ case StoreType::kF64Store: -+ TurboAssembler::Fst_d(src.fp(), dst_op); -+ break; -+ case StoreType::kS128Store: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, LiftoffRegList pinned) { -+ bailout(kAtomics, "AtomicLoad"); -+} -+ -+void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister src, -+ StoreType type, LiftoffRegList pinned) { -+ bailout(kAtomics, "AtomicStore"); -+} -+ -+void LiftoffAssembler::AtomicAdd(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicAdd"); -+} -+ -+void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicSub"); -+} -+ -+void LiftoffAssembler::AtomicAnd(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicAnd"); -+} -+ -+void LiftoffAssembler::AtomicOr(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicOr"); -+} -+ -+void LiftoffAssembler::AtomicXor(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicXor"); -+} -+ -+void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, -+ LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicExchange"); -+} -+ -+void LiftoffAssembler::AtomicCompareExchange( -+ Register dst_addr, Register offset_reg, uint32_t offset_imm, -+ LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result, -+ StoreType type) { -+ bailout(kAtomics, "AtomicCompareExchange"); -+} -+ -+void LiftoffAssembler::AtomicFence() { dbar(0); } -+ -+void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, -+ uint32_t caller_slot_idx, -+ ValueType type) { -+ MemOperand src(fp, kSystemPointerSize * (caller_slot_idx + 1)); -+ liftoff::Load(this, dst, src, type); -+} -+ -+void LiftoffAssembler::StoreCallerFrameSlot(LiftoffRegister src, -+ uint32_t caller_slot_idx, -+ ValueType type) { -+ int32_t offset = kSystemPointerSize * (caller_slot_idx + 1); -+ liftoff::Store(this, fp, offset, src, type); -+} -+ -+void LiftoffAssembler::LoadReturnStackSlot(LiftoffRegister dst, int offset, -+ ValueType type) { -+ liftoff::Load(this, dst, MemOperand(sp, offset), type); -+} -+ -+void LiftoffAssembler::MoveStackValue(uint32_t dst_offset, uint32_t src_offset, -+ ValueType type) { -+ DCHECK_NE(dst_offset, src_offset); -+ LiftoffRegister reg = GetUnusedRegister(reg_class_for(type), {}); -+ Fill(reg, src_offset, type); -+ Spill(dst_offset, reg, type); -+} -+ -+void LiftoffAssembler::Move(Register dst, Register src, ValueType type) { -+ DCHECK_NE(dst, src); -+ // TODO(ksreten): Handle different sizes here. -+ TurboAssembler::Move(dst, src); -+} -+ -+void LiftoffAssembler::Move(DoubleRegister dst, DoubleRegister src, -+ ValueType type) { -+ DCHECK_NE(dst, src); -+ if (type != kWasmS128) { -+ TurboAssembler::Move(dst, src); -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Spill(int offset, LiftoffRegister reg, ValueType type) { -+ RecordUsedSpillOffset(offset); -+ MemOperand dst = liftoff::GetStackSlot(offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ St_w(reg.gp(), dst); -+ break; -+ case ValueType::kI64: -+ case ValueType::kRef: -+ case ValueType::kOptRef: -+ St_d(reg.gp(), dst); -+ break; -+ case ValueType::kF32: -+ Fst_s(reg.fp(), dst); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::Fst_d(reg.fp(), dst); -+ break; -+ case ValueType::kS128: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Spill(int offset, WasmValue value) { -+ RecordUsedSpillOffset(offset); -+ MemOperand dst = liftoff::GetStackSlot(offset); -+ switch (value.type().kind()) { -+ case ValueType::kI32: { -+ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); -+ TurboAssembler::li(tmp.gp(), Operand(value.to_i32())); -+ St_w(tmp.gp(), dst); -+ break; -+ } -+ case ValueType::kI64: -+ case ValueType::kRef: -+ case ValueType::kOptRef: { -+ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); -+ TurboAssembler::li(tmp.gp(), value.to_i64()); -+ St_d(tmp.gp(), dst); -+ break; -+ } -+ default: -+ // kWasmF32 and kWasmF64 are unreachable, since those -+ // constants are not tracked. -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Fill(LiftoffRegister reg, int offset, ValueType type) { -+ MemOperand src = liftoff::GetStackSlot(offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ Ld_w(reg.gp(), src); -+ break; -+ case ValueType::kI64: -+ case ValueType::kRef: -+ case ValueType::kOptRef: -+ Ld_d(reg.gp(), src); -+ break; -+ case ValueType::kF32: -+ Fld_s(reg.fp(), src); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::Fld_d(reg.fp(), src); -+ break; -+ case ValueType::kS128: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::FillI64Half(Register, int offset, RegPairHalf) { -+ UNREACHABLE(); -+} -+ -+void LiftoffAssembler::FillStackSlotsWithZero(int start, int size) { -+ DCHECK_LT(0, size); -+ RecordUsedSpillOffset(start + size); -+ -+ if (size <= 12 * kStackSlotSize) { -+ // Special straight-line code for up to 12 slots. Generates one -+ // instruction per slot (<= 12 instructions total). -+ uint32_t remainder = size; -+ for (; remainder >= kStackSlotSize; remainder -= kStackSlotSize) { -+ St_d(zero_reg, liftoff::GetStackSlot(start + remainder)); -+ } -+ DCHECK(remainder == 4 || remainder == 0); -+ if (remainder) { -+ St_w(zero_reg, liftoff::GetStackSlot(start + remainder)); -+ } -+ } else { -+ // General case for bigger counts (12 instructions). -+ // Use a0 for start address (inclusive), a1 for end address (exclusive). -+ Push(a1, a0); -+ Add_d(a0, fp, Operand(-start - size)); -+ Add_d(a1, fp, Operand(-start)); -+ -+ Label loop; -+ bind(&loop); -+ St_d(zero_reg, MemOperand(a0, 0)); -+ addi_d(a0, a0, kSystemPointerSize); -+ BranchShort(&loop, ne, a0, Operand(a1)); -+ -+ Pop(a1, a0); -+ } -+} -+ -+void LiftoffAssembler::emit_i64_clz(LiftoffRegister dst, LiftoffRegister src) { -+ TurboAssembler::Clz_d(dst.gp(), src.gp()); -+} -+ -+void LiftoffAssembler::emit_i64_ctz(LiftoffRegister dst, LiftoffRegister src) { -+ TurboAssembler::Ctz_d(dst.gp(), src.gp()); -+} -+ -+bool LiftoffAssembler::emit_i64_popcnt(LiftoffRegister dst, -+ LiftoffRegister src) { -+ TurboAssembler::Popcnt_d(dst.gp(), src.gp()); -+ return true; -+} -+ -+void LiftoffAssembler::emit_i32_mul(Register dst, Register lhs, Register rhs) { -+ TurboAssembler::Mul_w(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero, -+ Label* trap_div_unrepresentable) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ -+ // Check if lhs == kMinInt and rhs == -1, since this case is unrepresentable. -+ TurboAssembler::li(kScratchReg, 1); -+ TurboAssembler::li(kScratchReg2, 1); -+ TurboAssembler::LoadZeroOnCondition(kScratchReg, lhs, Operand(kMinInt), eq); -+ TurboAssembler::LoadZeroOnCondition(kScratchReg2, rhs, Operand(-1), eq); -+ add_d(kScratchReg, kScratchReg, kScratchReg2); -+ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, -+ Operand(zero_reg)); -+ -+ TurboAssembler::Div_w(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Div_wu(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Mod_w(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_remu(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Mod_wu(dst, lhs, rhs); -+} -+ -+#define I32_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name(Register dst, Register lhs, \ -+ Register rhs) { \ -+ instruction(dst, lhs, rhs); \ -+ } -+ -+// clang-format off -+I32_BINOP(add, add_w) -+I32_BINOP(sub, sub_w) -+I32_BINOP(and, and_) -+I32_BINOP(or, or_) -+I32_BINOP(xor, xor_) -+// clang-format on -+ -+#undef I32_BINOP -+ -+#define I32_BINOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register lhs, \ -+ int32_t imm) { \ -+ instruction(dst, lhs, imm); \ -+ } -+ -+// clang-format off -+I32_BINOP_I(add, Add_w) -+I32_BINOP_I(and, And) -+I32_BINOP_I(or, Or) -+I32_BINOP_I(xor, Xor) -+// clang-format on -+ -+#undef I32_BINOP_I -+ -+void LiftoffAssembler::emit_i32_clz(Register dst, Register src) { -+ TurboAssembler::Clz_w(dst, src); -+} -+ -+void LiftoffAssembler::emit_i32_ctz(Register dst, Register src) { -+ TurboAssembler::Ctz_w(dst, src); -+} -+ -+bool LiftoffAssembler::emit_i32_popcnt(Register dst, Register src) { -+ TurboAssembler::Popcnt_w(dst, src); -+ return true; -+} -+ -+#define I32_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name(Register dst, Register src, \ -+ Register amount) { \ -+ instruction(dst, src, amount); \ -+ } -+#define I32_SHIFTOP_I(name, instruction, instruction1) \ -+ I32_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register src, \ -+ int amount) { \ -+ instruction1(dst, src, amount & 0x1f); \ -+ } -+ -+I32_SHIFTOP_I(shl, sll_w, slli_w) -+I32_SHIFTOP_I(sar, sra_w, srai_w) -+I32_SHIFTOP_I(shr, srl_w, srli_w) -+ -+#undef I32_SHIFTOP -+#undef I32_SHIFTOP_I -+ -+void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ TurboAssembler::Mul_d(dst.gp(), lhs.gp(), rhs.gp()); -+} -+ -+bool LiftoffAssembler::emit_i64_divs(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero, -+ Label* trap_div_unrepresentable) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ -+ // Check if lhs == MinInt64 and rhs == -1, since this case is unrepresentable. -+ TurboAssembler::li(kScratchReg, 1); -+ TurboAssembler::li(kScratchReg2, 1); -+ TurboAssembler::LoadZeroOnCondition( -+ kScratchReg, lhs.gp(), Operand(std::numeric_limits::min()), eq); -+ TurboAssembler::LoadZeroOnCondition(kScratchReg2, rhs.gp(), Operand(-1), eq); -+ add_d(kScratchReg, kScratchReg, kScratchReg2); -+ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, -+ Operand(zero_reg)); -+ -+ TurboAssembler::Div_d(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_divu(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Div_du(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_rems(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Mod_d(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_remu(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Mod_du(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+#define I64_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name( \ -+ LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ -+ instruction(dst.gp(), lhs.gp(), rhs.gp()); \ -+ } -+ -+// clang-format off -+I64_BINOP(add, Add_d) -+I64_BINOP(sub, Sub_d) -+I64_BINOP(and, and_) -+I64_BINOP(or, or_) -+I64_BINOP(xor, xor_) -+// clang-format on -+ -+#undef I64_BINOP -+ -+#define I64_BINOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name##i( \ -+ LiftoffRegister dst, LiftoffRegister lhs, int32_t imm) { \ -+ instruction(dst.gp(), lhs.gp(), imm); \ -+ } -+ -+// clang-format off -+I64_BINOP_I(add, addi_d) -+I64_BINOP_I(and, And) -+I64_BINOP_I(or, Or) -+I64_BINOP_I(xor, Xor) -+// clang-format on -+ -+#undef I64_BINOP_I -+ -+#define I64_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name( \ -+ LiftoffRegister dst, LiftoffRegister src, Register amount) { \ -+ instruction(dst.gp(), src.gp(), amount); \ -+ } -+#define I64_SHIFTOP_I(name, instruction, instructioni) \ -+ I64_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name##i(LiftoffRegister dst, \ -+ LiftoffRegister src, int amount) { \ -+ instructioni(dst.gp(), src.gp(), amount & 63); \ -+ } -+ -+I64_SHIFTOP_I(shl, sll_d, slli_d) -+I64_SHIFTOP_I(sar, sra_d, srai_d) -+I64_SHIFTOP_I(shr, srl_d, srli_d) -+ -+#undef I64_SHIFTOP -+#undef I64_SHIFTOP_I -+ -+void LiftoffAssembler::emit_u32_to_intptr(Register dst, Register src) { -+ bstrpick_d(dst, src, 31, 0); -+} -+ -+void LiftoffAssembler::emit_f32_neg(DoubleRegister dst, DoubleRegister src) { -+ TurboAssembler::Neg_s(dst, src); -+} -+ -+void LiftoffAssembler::emit_f64_neg(DoubleRegister dst, DoubleRegister src) { -+ TurboAssembler::Neg_d(dst, src); -+} -+ -+void LiftoffAssembler::emit_f32_min(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label ool, done; -+ TurboAssembler::Float32Min(dst, lhs, rhs, &ool); -+ Branch(&done); -+ -+ bind(&ool); -+ TurboAssembler::Float32MinOutOfLine(dst, lhs, rhs); -+ bind(&done); -+} -+ -+void LiftoffAssembler::emit_f32_max(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label ool, done; -+ TurboAssembler::Float32Max(dst, lhs, rhs, &ool); -+ Branch(&done); -+ -+ bind(&ool); -+ TurboAssembler::Float32MaxOutOfLine(dst, lhs, rhs); -+ bind(&done); -+} -+ -+void LiftoffAssembler::emit_f32_copysign(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ bailout(kComplexOperation, "f32_copysign"); -+} -+ -+void LiftoffAssembler::emit_f64_min(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label ool, done; -+ TurboAssembler::Float64Min(dst, lhs, rhs, &ool); -+ Branch(&done); -+ -+ bind(&ool); -+ TurboAssembler::Float64MinOutOfLine(dst, lhs, rhs); -+ bind(&done); -+} -+ -+void LiftoffAssembler::emit_f64_max(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label ool, done; -+ TurboAssembler::Float64Max(dst, lhs, rhs, &ool); -+ Branch(&done); -+ -+ bind(&ool); -+ TurboAssembler::Float64MaxOutOfLine(dst, lhs, rhs); -+ bind(&done); -+} -+ -+void LiftoffAssembler::emit_f64_copysign(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ bailout(kComplexOperation, "f64_copysign"); -+} -+ -+#define FP_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister lhs, \ -+ DoubleRegister rhs) { \ -+ instruction(dst, lhs, rhs); \ -+ } -+#define FP_UNOP(name, instruction) \ -+ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ -+ instruction(dst, src); \ -+ } -+#define FP_UNOP_RETURN_TRUE(name, instruction) \ -+ bool LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ -+ instruction(dst, src); \ -+ return true; \ -+ } -+ -+FP_BINOP(f32_add, fadd_s) -+FP_BINOP(f32_sub, fsub_s) -+FP_BINOP(f32_mul, fmul_s) -+FP_BINOP(f32_div, fdiv_s) -+FP_UNOP(f32_abs, fabs_s) -+FP_UNOP_RETURN_TRUE(f32_ceil, Ceil_s) -+FP_UNOP_RETURN_TRUE(f32_floor, Floor_s) -+FP_UNOP_RETURN_TRUE(f32_trunc, Trunc_s) -+FP_UNOP_RETURN_TRUE(f32_nearest_int, Round_s) -+FP_UNOP(f32_sqrt, fsqrt_s) -+FP_BINOP(f64_add, fadd_d) -+FP_BINOP(f64_sub, fsub_d) -+FP_BINOP(f64_mul, fmul_d) -+FP_BINOP(f64_div, fdiv_d) -+FP_UNOP(f64_abs, fabs_d) -+FP_UNOP_RETURN_TRUE(f64_ceil, Ceil_d) -+FP_UNOP_RETURN_TRUE(f64_floor, Floor_d) -+FP_UNOP_RETURN_TRUE(f64_trunc, Trunc_d) -+FP_UNOP_RETURN_TRUE(f64_nearest_int, Round_d) -+FP_UNOP(f64_sqrt, fsqrt_d) -+ -+#undef FP_BINOP -+#undef FP_UNOP -+#undef FP_UNOP_RETURN_TRUE -+ -+bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, -+ LiftoffRegister dst, -+ LiftoffRegister src, Label* trap) { -+ switch (opcode) { -+ case kExprI32ConvertI64: -+ TurboAssembler::bstrpick_w(dst.gp(), src.gp(), 31, 0); -+ return true; -+ case kExprI32SConvertF32: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); -+ ftintrz_w_s(kScratchDoubleReg, rounded.fp()); -+ movfr2gr_s(dst.gp(), kScratchDoubleReg); -+ // Avoid INT32_MAX as an overflow indicator and use INT32_MIN instead, -+ // because INT32_MIN allows easier out-of-bounds detection. -+ TurboAssembler::Add_w(kScratchReg, dst.gp(), 1); -+ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); -+ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); -+ -+ // Checking if trap. -+ movgr2fr_w(kScratchDoubleReg, dst.gp()); -+ ffint_s_w(converted_back.fp(), kScratchDoubleReg); -+ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI32UConvertF32: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); -+ TurboAssembler::Ftintrz_uw_s(dst.gp(), rounded.fp(), kScratchDoubleReg); -+ // Avoid UINT32_MAX as an overflow indicator and use 0 instead, -+ // because 0 allows easier out-of-bounds detection. -+ TurboAssembler::Add_w(kScratchReg, dst.gp(), 1); -+ TurboAssembler::Movz(dst.gp(), zero_reg, kScratchReg); -+ -+ // Checking if trap. -+ TurboAssembler::Ffint_d_uw(converted_back.fp(), dst.gp()); -+ fcvt_s_d(converted_back.fp(), converted_back.fp()); -+ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI32SConvertF64: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); -+ ftintrz_w_d(kScratchDoubleReg, rounded.fp()); -+ movfr2gr_s(dst.gp(), kScratchDoubleReg); -+ -+ // Checking if trap. -+ ffint_d_w(converted_back.fp(), kScratchDoubleReg); -+ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI32UConvertF64: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); -+ TurboAssembler::Ftintrz_uw_d(dst.gp(), rounded.fp(), kScratchDoubleReg); -+ -+ // Checking if trap. -+ TurboAssembler::Ffint_d_uw(converted_back.fp(), dst.gp()); -+ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI32ReinterpretF32: -+ TurboAssembler::FmoveLow(dst.gp(), src.fp()); -+ return true; -+ case kExprI64SConvertI32: -+ slli_w(dst.gp(), src.gp(), 0); -+ return true; -+ case kExprI64UConvertI32: -+ TurboAssembler::bstrpick_d(dst.gp(), src.gp(), 31, 0); -+ return true; -+ case kExprI64SConvertF32: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); -+ ftintrz_l_s(kScratchDoubleReg, rounded.fp()); -+ movfr2gr_d(dst.gp(), kScratchDoubleReg); -+ // Avoid INT64_MAX as an overflow indicator and use INT64_MIN instead, -+ // because INT64_MIN allows easier out-of-bounds detection. -+ TurboAssembler::Add_d(kScratchReg, dst.gp(), 1); -+ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); -+ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); -+ -+ // Checking if trap. -+ movgr2fr_d(kScratchDoubleReg, dst.gp()); -+ ffint_s_l(converted_back.fp(), kScratchDoubleReg); -+ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI64UConvertF32: { -+ // Real conversion. -+ TurboAssembler::Ftintrz_ul_s(dst.gp(), src.fp(), kScratchDoubleReg, -+ kScratchReg); -+ -+ // Checking if trap. -+ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); -+ return true; -+ } -+ case kExprI64SConvertF64: { -+ LiftoffRegister rounded = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); -+ LiftoffRegister converted_back = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); -+ -+ // Real conversion. -+ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); -+ ftintrz_l_d(kScratchDoubleReg, rounded.fp()); -+ movfr2gr_d(dst.gp(), kScratchDoubleReg); -+ // Avoid INT64_MAX as an overflow indicator and use INT64_MIN instead, -+ // because INT64_MIN allows easier out-of-bounds detection. -+ TurboAssembler::Add_d(kScratchReg, dst.gp(), 1); -+ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); -+ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); -+ -+ // Checking if trap. -+ movgr2fr_d(kScratchDoubleReg, dst.gp()); -+ ffint_d_l(converted_back.fp(), kScratchDoubleReg); -+ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); -+ TurboAssembler::BranchFalseF(trap); -+ return true; -+ } -+ case kExprI64UConvertF64: { -+ // Real conversion. -+ TurboAssembler::Ftintrz_ul_d(dst.gp(), src.fp(), kScratchDoubleReg, -+ kScratchReg); -+ -+ // Checking if trap. -+ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); -+ return true; -+ } -+ case kExprI64ReinterpretF64: -+ movfr2gr_d(dst.gp(), src.fp()); -+ return true; -+ case kExprF32SConvertI32: { -+ LiftoffRegister scratch = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst)); -+ movgr2fr_w(scratch.fp(), src.gp()); -+ ffint_s_w(dst.fp(), scratch.fp()); -+ return true; -+ } -+ case kExprF32UConvertI32: -+ TurboAssembler::Ffint_s_uw(dst.fp(), src.gp()); -+ return true; -+ case kExprF32ConvertF64: -+ fcvt_s_d(dst.fp(), src.fp()); -+ return true; -+ case kExprF32ReinterpretI32: -+ TurboAssembler::FmoveLow(dst.fp(), src.gp()); -+ return true; -+ case kExprF64SConvertI32: { -+ LiftoffRegister scratch = -+ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst)); -+ movgr2fr_w(scratch.fp(), src.gp()); -+ ffint_d_w(dst.fp(), scratch.fp()); -+ return true; -+ } -+ case kExprF64UConvertI32: -+ TurboAssembler::Ffint_d_uw(dst.fp(), src.gp()); -+ return true; -+ case kExprF64ConvertF32: -+ fcvt_d_s(dst.fp(), src.fp()); -+ return true; -+ case kExprF64ReinterpretI64: -+ movgr2fr_d(dst.fp(), src.gp()); -+ return true; -+ case kExprI32SConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF32"); -+ return true; -+ case kExprI32UConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF32"); -+ return true; -+ case kExprI32SConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF64"); -+ return true; -+ case kExprI32UConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF64"); -+ return true; -+ case kExprI64SConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF32"); -+ return true; -+ case kExprI64UConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF32"); -+ return true; -+ case kExprI64SConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF64"); -+ return true; -+ case kExprI64UConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF64"); -+ return true; -+ default: -+ return false; -+ } -+} -+ -+void LiftoffAssembler::emit_i32_signextend_i8(Register dst, Register src) { -+ bailout(kComplexOperation, "i32_signextend_i8"); -+} -+ -+void LiftoffAssembler::emit_i32_signextend_i16(Register dst, Register src) { -+ bailout(kComplexOperation, "i32_signextend_i16"); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i8(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kComplexOperation, "i64_signextend_i8"); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i16(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kComplexOperation, "i64_signextend_i16"); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i32(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kComplexOperation, "i64_signextend_i32"); -+} -+ -+void LiftoffAssembler::emit_jump(Label* label) { -+ TurboAssembler::Branch(label); -+} -+ -+void LiftoffAssembler::emit_jump(Register target) { -+ TurboAssembler::Jump(target); -+} -+ -+void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, -+ ValueType type, Register lhs, -+ Register rhs) { -+ if (rhs != no_reg) { -+ TurboAssembler::Branch(label, cond, lhs, Operand(rhs)); -+ } else { -+ TurboAssembler::Branch(label, cond, lhs, Operand(zero_reg)); -+ } -+} -+ -+void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { -+ sltui(dst, src, 1); -+} -+ -+void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, -+ Register lhs, Register rhs) { -+ Register tmp = dst; -+ if (dst == lhs || dst == rhs) { -+ tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp(); -+ } -+ // Write 1 as result. -+ TurboAssembler::li(tmp, 1); -+ -+ // If negative condition is true, write 0 as result. -+ Condition neg_cond = NegateCondition(cond); -+ TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond); -+ -+ // If tmp != dst, result will be moved. -+ TurboAssembler::Move(dst, tmp); -+} -+ -+void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { -+ sltui(dst, src.gp(), 1); -+} -+ -+void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ Register tmp = dst; -+ if (dst == lhs.gp() || dst == rhs.gp()) { -+ tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp(); -+ } -+ // Write 1 as result. -+ TurboAssembler::li(tmp, 1); -+ -+ // If negative condition is true, write 0 as result. -+ Condition neg_cond = NegateCondition(cond); -+ TurboAssembler::LoadZeroOnCondition(tmp, lhs.gp(), Operand(rhs.gp()), -+ neg_cond); -+ -+ // If tmp != dst, result will be moved. -+ TurboAssembler::Move(dst, tmp); -+} -+ -+namespace liftoff { -+ -+inline FPUCondition ConditionToConditionCmpFPU(Condition condition, -+ bool* predicate) { -+ switch (condition) { -+ case kEqual: -+ *predicate = true; -+ return CEQ; -+ case kUnequal: -+ *predicate = false; -+ return CEQ; -+ case kUnsignedLessThan: -+ *predicate = true; -+ return CLT; -+ case kUnsignedGreaterEqual: -+ *predicate = false; -+ return CLT; -+ case kUnsignedLessEqual: -+ *predicate = true; -+ return CLE; -+ case kUnsignedGreaterThan: -+ *predicate = false; -+ return CLE; -+ default: -+ *predicate = true; -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+inline void EmitAnyTrue(LiftoffAssembler* assm, LiftoffRegister dst, -+ LiftoffRegister src) {} -+} // namespace liftoff -+ -+void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, -+ DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label not_nan, cont; -+ TurboAssembler::CompareIsNanF32(lhs, rhs); -+ TurboAssembler::BranchFalseF(¬_nan); -+ // If one of the operands is NaN, return 1 for f32.ne, else 0. -+ if (cond == ne) { -+ TurboAssembler::li(dst, 1); -+ } else { -+ TurboAssembler::Move(dst, zero_reg); -+ } -+ TurboAssembler::Branch(&cont); -+ -+ bind(¬_nan); -+ -+ TurboAssembler::li(dst, 1); -+ bool predicate; -+ FPUCondition fcond = liftoff::ConditionToConditionCmpFPU(cond, &predicate); -+ TurboAssembler::CompareF32(lhs, rhs, fcond); -+ if (predicate) { -+ TurboAssembler::LoadZeroIfNotFPUCondition(dst); -+ } else { -+ TurboAssembler::LoadZeroIfFPUCondition(dst); -+ } -+ -+ bind(&cont); -+} -+ -+void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, -+ DoubleRegister lhs, -+ DoubleRegister rhs) { -+ Label not_nan, cont; -+ TurboAssembler::CompareIsNanF64(lhs, rhs); -+ TurboAssembler::BranchFalseF(¬_nan); -+ // If one of the operands is NaN, return 1 for f64.ne, else 0. -+ if (cond == ne) { -+ TurboAssembler::li(dst, 1); -+ } else { -+ TurboAssembler::Move(dst, zero_reg); -+ } -+ TurboAssembler::Branch(&cont); -+ -+ bind(¬_nan); -+ -+ TurboAssembler::li(dst, 1); -+ bool predicate; -+ FPUCondition fcond = liftoff::ConditionToConditionCmpFPU(cond, &predicate); -+ TurboAssembler::CompareF64(lhs, rhs, fcond); -+ if (predicate) { -+ TurboAssembler::LoadZeroIfNotFPUCondition(dst); -+ } else { -+ TurboAssembler::LoadZeroIfFPUCondition(dst); -+ } -+ -+ bind(&cont); -+} -+ -+bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition, -+ LiftoffRegister true_value, -+ LiftoffRegister false_value, -+ ValueType type) { -+ return false; -+} -+ -+void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, -+ LoadTransformationKind transform, -+ uint32_t* protected_load_pc) {} -+ -+void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ const uint8_t shuffle[16], -+ bool is_swizzle) {} -+ -+void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i64x2_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_lt(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_le(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_lt(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_s128_const(LiftoffRegister dst, -+ const uint8_t imms[16]) { -+ bailout(kSimd, "emit_s128_const"); -+} -+ -+void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) { -+} -+ -+void LiftoffAssembler::emit_s128_and(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_s128_or(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_s128_xor(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_s128_and_not(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_s128_select(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ LiftoffRegister mask) {} -+ -+void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_add_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_add_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_sub_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_sub_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_add_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_add_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_sub_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_sub_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i64x2_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_abs(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_sqrt(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f32x4_ceil(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f32x4_floor(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f32x4_trunc(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f32x4_nearest_int(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_div(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_min(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_max(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_pmin(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f32x4_pmax(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_abs(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f64x2_sqrt(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f64x2_ceil(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f64x2_floor(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f64x2_trunc(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+bool LiftoffAssembler::emit_f64x2_nearest_int(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_div(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_min(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_max(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_pmin(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_f64x2_pmax(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_f32x4(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_f32x4(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_sconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_f32x4_uconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_sconvert_i16x8(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_uconvert_i16x8(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i8x16_low(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i8x16_high(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i8x16_low(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i8x16_high(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_i16x8_low(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_i16x8_high(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_i16x8_low(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_i16x8_high(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_rounding_average_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i16x8_rounding_average_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) {} -+ -+void LiftoffAssembler::emit_i8x16_abs(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i16x8_abs(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst, -+ LiftoffRegister src) {} -+ -+void LiftoffAssembler::emit_i8x16_extract_lane_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i8x16_extract_lane_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i16x8_extract_lane_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i16x8_extract_lane_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i32x4_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i64x2_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_f32x4_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_f64x2_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) {} -+ -+void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) { -+ TurboAssembler::Ld_d(limit_address, MemOperand(limit_address, 0)); -+ TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address)); -+} -+ -+void LiftoffAssembler::CallTrapCallbackForTesting() { -+ PrepareCallCFunction(0, GetUnusedRegister(kGpReg, {}).gp()); -+ CallCFunction(ExternalReference::wasm_call_trap_callback_for_testing(), 0); -+} -+ -+void LiftoffAssembler::AssertUnreachable(AbortReason reason) { -+ if (emit_debug_code()) Abort(reason); -+} -+ -+void LiftoffAssembler::PushRegisters(LiftoffRegList regs) { -+ LiftoffRegList gp_regs = regs & kGpCacheRegList; -+ unsigned num_gp_regs = gp_regs.GetNumRegsSet(); -+ if (num_gp_regs) { -+ unsigned offset = num_gp_regs * kSystemPointerSize; -+ addi_d(sp, sp, -offset); -+ while (!gp_regs.is_empty()) { -+ LiftoffRegister reg = gp_regs.GetFirstRegSet(); -+ offset -= kSystemPointerSize; -+ St_d(reg.gp(), MemOperand(sp, offset)); -+ gp_regs.clear(reg); -+ } -+ DCHECK_EQ(offset, 0); -+ } -+ LiftoffRegList fp_regs = regs & kFpCacheRegList; -+ unsigned num_fp_regs = fp_regs.GetNumRegsSet(); -+ if (num_fp_regs) { -+ unsigned slot_size = /*IsEnabled(MIPS_SIMD) ? 16 :*/ 8; -+ addi_d(sp, sp, -(num_fp_regs * slot_size)); -+ unsigned offset = 0; -+ while (!fp_regs.is_empty()) { -+ LiftoffRegister reg = fp_regs.GetFirstRegSet(); -+ if (0 /*IsEnabled(MIPS_SIMD)*/) { -+ // TurboAssembler::st_d(reg.fp().toW(), MemOperand(sp, offset)); -+ } else { -+ TurboAssembler::Fst_d(reg.fp(), MemOperand(sp, offset)); -+ } -+ fp_regs.clear(reg); -+ offset += slot_size; -+ } -+ DCHECK_EQ(offset, num_fp_regs * slot_size); -+ } -+} -+ -+void LiftoffAssembler::PopRegisters(LiftoffRegList regs) { -+ LiftoffRegList fp_regs = regs & kFpCacheRegList; -+ unsigned fp_offset = 0; -+ while (!fp_regs.is_empty()) { -+ LiftoffRegister reg = fp_regs.GetFirstRegSet(); -+ if (0 /*IsEnabled(MIPS_SIMD)*/) { -+ // TurboAssembler::ld_d(reg.fp().toW(), MemOperand(sp, fp_offset)); -+ } else { -+ TurboAssembler::Fld_d(reg.fp(), MemOperand(sp, fp_offset)); -+ } -+ fp_regs.clear(reg); -+ fp_offset += (/*IsEnabled(MIPS_SIMD) ? 16 :*/ 8); -+ } -+ if (fp_offset) addi_d(sp, sp, fp_offset); -+ LiftoffRegList gp_regs = regs & kGpCacheRegList; -+ unsigned gp_offset = 0; -+ while (!gp_regs.is_empty()) { -+ LiftoffRegister reg = gp_regs.GetLastRegSet(); -+ Ld_d(reg.gp(), MemOperand(sp, gp_offset)); -+ gp_regs.clear(reg); -+ gp_offset += kSystemPointerSize; -+ } -+ addi_d(sp, sp, gp_offset); -+} -+ -+void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) { -+ DCHECK_LT(num_stack_slots, -+ (1 << 16) / kSystemPointerSize); // 16 bit immediate -+ TurboAssembler::DropAndRet(static_cast(num_stack_slots)); -+} -+ -+void LiftoffAssembler::CallC(const wasm::FunctionSig* sig, -+ const LiftoffRegister* args, -+ const LiftoffRegister* rets, -+ ValueType out_argument_type, int stack_bytes, -+ ExternalReference ext_ref) { -+ addi_d(sp, sp, -stack_bytes); -+ -+ int arg_bytes = 0; -+ for (ValueType param_type : sig->parameters()) { -+ liftoff::Store(this, sp, arg_bytes, *args++, param_type); -+ arg_bytes += param_type.element_size_bytes(); -+ } -+ DCHECK_LE(arg_bytes, stack_bytes); -+ -+ // Pass a pointer to the buffer with the arguments to the C function. -+ // On mips, the first argument is passed in {a0}. -+ constexpr Register kFirstArgReg = a0; -+ mov(kFirstArgReg, sp); -+ -+ // Now call the C function. -+ constexpr int kNumCCallArgs = 1; -+ PrepareCallCFunction(kNumCCallArgs, kScratchReg); -+ CallCFunction(ext_ref, kNumCCallArgs); -+ -+ // Move return value to the right register. -+ const LiftoffRegister* next_result_reg = rets; -+ if (sig->return_count() > 0) { -+ DCHECK_EQ(1, sig->return_count()); -+ constexpr Register kReturnReg = a0; -+ if (kReturnReg != next_result_reg->gp()) { -+ Move(*next_result_reg, LiftoffRegister(kReturnReg), sig->GetReturn(0)); -+ } -+ ++next_result_reg; -+ } -+ -+ // Load potential output value from the buffer on the stack. -+ if (out_argument_type != kWasmStmt) { -+ liftoff::Load(this, *next_result_reg, MemOperand(sp, 0), out_argument_type); -+ } -+ -+ addi_d(sp, sp, stack_bytes); -+} -+ -+void LiftoffAssembler::CallNativeWasmCode(Address addr) { -+ Call(addr, RelocInfo::WASM_CALL); -+} -+ -+void LiftoffAssembler::TailCallNativeWasmCode(Address addr) { -+ Jump(addr, RelocInfo::WASM_CALL); -+} -+ -+void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig, -+ compiler::CallDescriptor* call_descriptor, -+ Register target) { -+ if (target == no_reg) { -+ pop(kScratchReg); -+ Call(kScratchReg); -+ } else { -+ Call(target); -+ } -+} -+ -+void LiftoffAssembler::TailCallIndirect(Register target) { -+ if (target == no_reg) { -+ Pop(kScratchReg); -+ Jump(kScratchReg); -+ } else { -+ Jump(target); -+ } -+} -+ -+void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) { -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched at relocation. -+ Call(static_cast
(sid), RelocInfo::WASM_STUB_CALL); -+} -+ -+void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) { -+ addi_d(sp, sp, -size); -+ TurboAssembler::Move(addr, sp); -+} -+ -+void LiftoffAssembler::DeallocateStackSlot(uint32_t size) { -+ addi_d(sp, sp, size); -+} -+ -+void LiftoffStackSlots::Construct() { -+ for (auto& slot : slots_) { -+ const LiftoffAssembler::VarState& src = slot.src_; -+ switch (src.loc()) { -+ case LiftoffAssembler::VarState::kStack: -+ if (src.type() != kWasmS128) { -+ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); -+ asm_->push(kScratchReg); -+ } else { -+ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_ - 8)); -+ asm_->push(kScratchReg); -+ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); -+ asm_->push(kScratchReg); -+ } -+ break; -+ case LiftoffAssembler::VarState::kRegister: -+ liftoff::push(asm_, src.reg(), src.type()); -+ break; -+ case LiftoffAssembler::VarState::kIntConst: { -+ asm_->li(kScratchReg, Operand(src.i32_const())); -+ asm_->push(kScratchReg); -+ break; -+ } -+ } -+ } -+} -+ -+} // namespace wasm -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ -diff --git a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc -index 90cdad467..7167f1924 100644 ---- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc -+++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc -@@ -268,6 +268,37 @@ void JumpTableAssembler::NopBytes(int bytes) { - } - } - -+#elif V8_TARGET_ARCH_LOONGARCH64 -+void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, -+ Address lazy_compile_target) { -+ DCHECK(is_int32(func_index)); -+ int start = pc_offset(); -+ li(kWasmCompileLazyFuncIndexRegister, (int32_t)func_index); // max. 2 instr -+ // Jump produces max. 3 instructions for 32-bit platform -+ // and max. 4 instructions for 64-bit platform. -+ Jump(lazy_compile_target, RelocInfo::NONE); -+ int nop_bytes = start + kLazyCompileTableSlotSize - pc_offset(); -+ DCHECK_EQ(nop_bytes % kInstrSize, 0); -+ for (int i = 0; i < nop_bytes; i += kInstrSize) nop(); -+} -+bool JumpTableAssembler::EmitJumpSlot(Address target) { -+ PatchAndJump(target); -+ return true; -+} -+void JumpTableAssembler::EmitFarJumpSlot(Address target) { -+ JumpToInstructionStream(target); -+} -+void JumpTableAssembler::PatchFarJumpSlot(Address slot, Address target) { -+ UNREACHABLE(); -+} -+void JumpTableAssembler::NopBytes(int bytes) { -+ DCHECK_LE(0, bytes); -+ DCHECK_EQ(0, bytes % kInstrSize); -+ for (; bytes > 0; bytes -= kInstrSize) { -+ nop(); -+ } -+} -+ - #elif V8_TARGET_ARCH_PPC64 - void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, - Address lazy_compile_target) { -diff --git a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h -index 253f0bc01..00549b758 100644 ---- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h -+++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h -@@ -215,6 +215,12 @@ class V8_EXPORT_PRIVATE JumpTableAssembler : public MacroAssembler { - static constexpr int kJumpTableSlotSize = 8 * kInstrSize; - static constexpr int kFarJumpTableSlotSize = 6 * kInstrSize; - static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; -+#elif V8_TARGET_ARCH_LOONGARCH64 -+ // TODO -+ static constexpr int kJumpTableLineSize = 8 * kInstrSize; -+ static constexpr int kJumpTableSlotSize = 8 * kInstrSize; -+ static constexpr int kFarJumpTableSlotSize = 4 * kInstrSize; -+ static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; - #else - #error Unknown architecture. - #endif -diff --git a/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h b/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h -index 7e56ea6ea..e1898d858 100644 ---- a/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h -+++ b/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h -@@ -75,6 +75,15 @@ constexpr Register kGpReturnRegisters[] = {v0, v1}; - constexpr DoubleRegister kFpParamRegisters[] = {f2, f4, f6, f8, f10, f12, f14}; - constexpr DoubleRegister kFpReturnRegisters[] = {f2, f4}; - -+#elif V8_TARGET_ARCH_LOONGARCH64 -+// =========================================================================== -+// == LOONGARCH64 TODO ============================================================= -+// =========================================================================== -+constexpr Register kGpParamRegisters[] = {a0, a2, a3, a4, a5, a6, a7}; -+constexpr Register kGpReturnRegisters[] = {a0, a1}; -+constexpr DoubleRegister kFpParamRegisters[] = {f2, f4, f6, f8, f10, f12, f14}; -+constexpr DoubleRegister kFpReturnRegisters[] = {f2, f4}; -+ - #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 - // =========================================================================== - // == ppc & ppc64 ============================================================ -diff --git a/src/3rdparty/gn/tools/gn/args.cc b/src/3rdparty/gn/tools/gn/args.cc -index d3491a422..57c1df998 100644 ---- a/src/3rdparty/gn/tools/gn/args.cc -+++ b/src/3rdparty/gn/tools/gn/args.cc -@@ -329,6 +329,7 @@ void Args::SetSystemVarsLocked(Scope* dest) const { - static const char kMips64[] = "mips64el"; - static const char kS390X[] = "s390x"; - static const char kPPC64[] = "ppc64"; -+ static const char kLoongarch64[] = "loongarch64"; - const char* arch = nullptr; - - // Set the host CPU architecture based on the underlying OS, not -@@ -353,6 +354,8 @@ void Args::SetSystemVarsLocked(Scope* dest) const { - // This allows us to use the same toolchain as ppc64 BE - // and specific flags are included using the host_byteorder logic. - arch = kPPC64; -+ else if (os_arch == "loongarch64") -+ arch = kLoongarch64; - else - CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; - -diff --git a/src/3rdparty/gn/util/build_config.h b/src/3rdparty/gn/util/build_config.h -index addd7cfb0..4d8b53aff 100644 ---- a/src/3rdparty/gn/util/build_config.h -+++ b/src/3rdparty/gn/util/build_config.h -@@ -172,6 +172,15 @@ - #define ARCH_CPU_32_BITS 1 - #define ARCH_CPU_BIG_ENDIAN 1 - #endif -+#elif defined(__loongarch__) -+#if defined(__loongarch_lp64) -+#define ARCH_CPU_LOONGARCH_FAMILY 1 -+#define ARCH_CPU_LOONGARCH64 1 -+#define ARCH_CPU_64_BITS 1 -+#define ARCH_CPU_LITTLE_ENDIAN 1 -+#else -+#error Only lp64 been supported on loongarch architecture! -+#endif - #else - #error Please add support for your architecture in build_config.h - #endif -diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri -index 3a5743c9d..2bc7d189e 100644 ---- a/src/buildtools/config/support.pri -+++ b/src/buildtools/config/support.pri -@@ -110,7 +110,7 @@ defineTest(qtwebengine_checkForPlatform) { - defineTest(qtwebengine_checkForArch) { - module = $$1 - !qtConfig(webengine-arch-support) { -- qtwebengine_skipBuild("$${module} can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.") -+ qtwebengine_skipBuild("$${module} can only be built for x86, x86-64, ARM, Aarch64, Loongarch64, and MIPSel architectures.") - return(false) - } - return(true) --- -2.45.2 - diff --git a/debian/patches/add-riscv64-support.patch b/debian/patches/add-riscv64-support.patch deleted file mode 100644 index 4aa355ae6d..0000000000 --- a/debian/patches/add-riscv64-support.patch +++ /dev/null @@ -1,44231 +0,0 @@ -Description: Add riscv64 support for qtwebengine-opensource-src - Partly taken from an earlier revision of openSUSE RISC-V's Chromium (https://build.opensuse.org/package/show/openSUSE:Factory:RISCV/chromium), - with patches for vendored ffmpeg and linking to libatomic. -Author: Eric Long ---- a/src/3rdparty/chromium/v8/BUILD.gn -+++ b/src/3rdparty/chromium/v8/BUILD.gn -@@ -714,7 +714,7 @@ - - # Mips64el/mipsel simulators. - if (target_is_simulator && -- (v8_current_cpu == "mipsel" || v8_current_cpu == "mips64el")) { -+ (v8_current_cpu == "mipsel" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64")) { - defines += [ "_MIPS_TARGET_SIMULATOR" ] - } - -@@ -817,6 +817,21 @@ - } - } - -+ # Under simulator build, compiler will not provide __riscv_xlen. Define here -+ if (v8_current_cpu == "riscv") { -+ defines += [ "V8_TARGET_ARCH_RISCV" ] -+ defines += [ "__riscv_xlen=32" ] -+ } -+ -+ if (v8_current_cpu == "riscv64") { -+ defines += [ "V8_TARGET_ARCH_RISCV64" ] -+ defines += [ "__riscv_xlen=64" ] -+ #FIXME: Temporarily use MIPS macro for the building. -+ defines += [ -+ "CAN_USE_FPU_INSTRUCTIONS", -+ ] -+ } -+ - if (v8_current_cpu == "x86") { - defines += [ "V8_TARGET_ARCH_IA32" ] - if (is_win) { -@@ -905,7 +920,7 @@ - } - - if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || -- v8_current_cpu == "mips64el") { -+ v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { - cflags += [ "-Wshorten-64-to-32" ] - } - } -@@ -1888,6 +1903,16 @@ - ### gcmole(arch:s390) ### - "src/builtins/s390/builtins-s390.cc", - ] -+ } else if (v8_current_cpu == "riscv64") { -+ sources += [ -+ ### gcmole(arch:riscv64) ### -+ "src/builtins/riscv64/builtins-riscv64.cc", -+ ] -+ } else if (v8_current_cpu == "riscv") { -+ sources += [ -+ ### gcmole(arch:riscv) ### -+ "src/builtins/riscv/builtins-riscv.cc", -+ ] - } - - if (!v8_enable_i18n_support) { -@@ -3762,6 +3787,60 @@ - "src/regexp/s390/regexp-macro-assembler-s390.h", - "src/wasm/baseline/s390/liftoff-assembler-s390.h", - ] -+ } else if (v8_current_cpu == "riscv64") { -+ sources += [ ### gcmole(arch:riscv64) ### -+ "src/codegen/riscv64/assembler-riscv64-inl.h", -+ "src/codegen/riscv64/assembler-riscv64.cc", -+ "src/codegen/riscv64/assembler-riscv64.h", -+ "src/codegen/riscv64/constants-riscv64.cc", -+ "src/codegen/riscv64/constants-riscv64.h", -+ "src/codegen/riscv64/cpu-riscv64.cc", -+ "src/codegen/riscv64/interface-descriptors-riscv64.cc", -+ "src/codegen/riscv64/macro-assembler-riscv64.cc", -+ "src/codegen/riscv64/macro-assembler-riscv64.h", -+ "src/codegen/riscv64/register-riscv64.h", -+ "src/compiler/backend/riscv64/code-generator-riscv64.cc", -+ "src/compiler/backend/riscv64/instruction-codes-riscv64.h", -+ "src/compiler/backend/riscv64/instruction-scheduler-riscv64.cc", -+ "src/compiler/backend/riscv64/instruction-selector-riscv64.cc", -+ "src/debug/riscv64/debug-riscv64.cc", -+ "src/deoptimizer/riscv64/deoptimizer-riscv64.cc", -+ "src/diagnostics/riscv64/disasm-riscv64.cc", -+ "src/execution/riscv64/frame-constants-riscv64.cc", -+ "src/execution/riscv64/frame-constants-riscv64.h", -+ "src/execution/riscv64/simulator-riscv64.cc", -+ "src/execution/riscv64/simulator-riscv64.h", -+ "src/regexp/riscv64/regexp-macro-assembler-riscv64.cc", -+ "src/regexp/riscv64/regexp-macro-assembler-riscv64.h", -+ "src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h", -+ ] -+ } else if (v8_current_cpu == "riscv") { -+ sources += [ ### gcmole(arch:riscv) ### -+ "src/codegen/riscv/assembler-riscv-inl.h", -+ "src/codegen/riscv/assembler-riscv.cc", -+ "src/codegen/riscv/assembler-riscv.h", -+ "src/codegen/riscv/constants-riscv.cc", -+ "src/codegen/riscv/constants-riscv.h", -+ "src/codegen/riscv/cpu-riscv.cc", -+ "src/codegen/riscv/interface-descriptors-riscv.cc", -+ "src/codegen/riscv/macro-assembler-riscv.cc", -+ "src/codegen/riscv/macro-assembler-riscv.h", -+ "src/codegen/riscv/register-riscv.h", -+ "src/compiler/backend/riscv/code-generator-riscv.cc", -+ "src/compiler/backend/riscv/instruction-codes-riscv.h", -+ "src/compiler/backend/riscv/instruction-scheduler-riscv.cc", -+ "src/compiler/backend/riscv/instruction-selector-riscv.cc", -+ "src/debug/riscv/debug-riscv.cc", -+ "src/deoptimizer/riscv/deoptimizer-riscv.cc", -+ "src/diagnostics/riscv/disasm-riscv.cc", -+ "src/execution/riscv/frame-constants-riscv.cc", -+ "src/execution/riscv/frame-constants-riscv.h", -+ "src/execution/riscv/simulator-riscv.cc", -+ "src/execution/riscv/simulator-riscv.h", -+ "src/regexp/riscv/regexp-macro-assembler-riscv.cc", -+ "src/regexp/riscv/regexp-macro-assembler-riscv.h", -+ "src/wasm/baseline/riscv/liftoff-assembler-riscv.h", -+ ] - } - - configs = [ -@@ -3862,7 +3941,8 @@ - if (v8_current_cpu == "mips" || v8_current_cpu == "mipsel" || - v8_current_cpu == "mips64" || v8_current_cpu == "mips64el" || - v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || -- v8_current_cpu == "s390" || v8_current_cpu == "s390x") { -+ v8_current_cpu == "s390" || v8_current_cpu == "s390x" || -+ v8_current_cpu == "riscv64" || v8_current_cpu == "riscv") { - libs += [ "atomic" ] - } - -@@ -4197,7 +4277,7 @@ - } - - if (is_ubsan && (v8_current_cpu == "x86" || v8_current_cpu == "arm" || -- v8_current_cpu == "mips")) { -+ v8_current_cpu == "mips" || v8_current_cpu == "riscv")) { - # Special UBSan 32-bit requirement. - sources += [ "src/base/ubsan.cc" ] - } -@@ -4328,6 +4408,8 @@ - sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ] - } else if (current_cpu == "mips64el") { - sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ] -+ } else if (current_cpu == "riscv64") { -+ sources += [ "src/heap/base/asm/riscv64/push_registers_asm.cc" ] - } - } else if (is_win) { - if (current_cpu == "x64") { ---- a/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni -+++ b/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni -@@ -79,7 +79,8 @@ - - if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { - _cpus = v8_current_cpu -- } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { -+ } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" -+ || v8_current_cpu == "riscv64") { - if (is_win && v8_current_cpu == "arm64") { - # set _cpus to blank for Windows ARM64 so host_toolchain could be - # selected as snapshot toolchain later. ---- a/src/3rdparty/chromium/v8/infra/mb/mb_config.pyl -+++ b/src/3rdparty/chromium/v8/infra/mb/mb_config.pyl -@@ -33,6 +33,12 @@ - 'ppc64.debug.sim': 'default_debug_ppc64_sim', - 'ppc64.optdebug.sim': 'default_optdebug_ppc64_sim', - 'ppc64.release.sim': 'default_release_ppc64_sim', -+ 'riscv64.debug': 'default_debug_riscv64', -+ 'riscv64.optdebug': 'default_optdebug_riscv64', -+ 'riscv64.release': 'default_release_riscv64', -+ 'riscv64.debug.sim': 'default_debug_riscv64_sim', -+ 'riscv64.optdebug.sim': 'default_optdebug_riscv64_sim', -+ 'riscv64.release.sim': 'default_release_riscv64_sim', - 's390x.debug': 'default_debug_s390x', - 's390x.optdebug': 'default_optdebug_s390x', - 's390x.release': 'default_release_s390x', -@@ -175,6 +181,8 @@ - # IBM. - 'V8 Linux - ppc64 - sim': 'release_simulate_ppc64', - 'V8 Linux - s390x - sim': 'release_simulate_s390x', -+ # RISC-V -+ 'V8 Linux - riscv64 - sim': 'release_simulate_riscv64', - }, - 'client.v8.branches': { - 'V8 Linux - previous branch': 'release_x86', -@@ -207,6 +215,9 @@ - 'V8 s390x - sim - previous branch': 'release_simulate_s390x', - 'V8 s390x - sim - beta branch': 'release_simulate_s390x', - 'V8 s390x - sim - stable branch': 'release_simulate_s390x', -+ 'V8 riscv64 - sim - previous branch': 'release_simulate_riscv64', -+ 'V8 riscv64 - sim - beta branch': 'release_simulate_riscv64', -+ 'V8 riscv64 - sim - stable branch': 'release_simulate_riscv64', - }, - 'tryserver.v8': { - 'v8_android_arm_compile_rel': 'release_android_arm', -@@ -323,6 +334,18 @@ - 'debug', 'simulate_mips64el', 'v8_enable_slow_dchecks'], - 'default_release_mips64el': [ - 'release', 'simulate_mips64el'], -+ 'default_debug_riscv64': [ -+ 'debug', 'riscv64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], -+ 'default_optdebug_riscv64': [ -+ 'debug', 'riscv64', 'gcc', 'v8_enable_slow_dchecks'], -+ 'default_release_riscv64': [ -+ 'release', 'riscv64', 'gcc'], -+ 'default_debug_riscv64_sim': [ -+ 'debug', 'simulate_riscv64', 'v8_enable_slow_dchecks', 'v8_full_debug'], -+ 'default_optdebug_riscv64_sim': [ -+ 'debug', 'simulate_riscv64', 'v8_enable_slow_dchecks'], -+ 'default_release_riscv64_sim': [ -+ 'release', 'simulate_riscv64'], - 'default_debug_ppc64': [ - 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], - 'default_optdebug_ppc64': [ -@@ -410,6 +433,8 @@ - 'release_bot', 'simulate_mips64el'], - 'release_simulate_ppc64': [ - 'release_bot', 'simulate_ppc64'], -+ 'release_simulate_riscv64': [ -+ 'release_bot', 'simulate_riscv64'], - 'release_simulate_s390x': [ - 'release_bot', 'simulate_s390x'], - -@@ -812,6 +837,10 @@ - 'gn_args': 'target_cpu="x64" v8_target_cpu="ppc64"', - }, - -+ 'simulate_riscv64': { -+ 'gn_args': 'target_cpu="x64" v8_target_cpu="riscv64"', -+ }, -+ - 'simulate_s390x': { - 'gn_args': 'target_cpu="x64" v8_target_cpu="s390x"', - }, -@@ -918,6 +947,10 @@ - 'gn_args': 'target_cpu="ppc64" use_custom_libcxx=false', - }, - -+ 'riscv64': { -+ 'gn_args': 'target_cpu="riscv64" use_custom_libcxx=false', -+ }, -+ - 'x64': { - 'gn_args': 'target_cpu="x64"', - }, ---- a/src/3rdparty/chromium/v8/src/base/build_config.h -+++ b/src/3rdparty/chromium/v8/src/base/build_config.h -@@ -46,6 +46,16 @@ - #else - #define V8_HOST_ARCH_32_BIT 1 - #endif -+#elif defined(__riscv) || defined(__riscv__) -+#if __riscv_xlen == 64 -+#define V8_HOST_ARCH_RISCV64 1 -+#define V8_HOST_ARCH_64_BIT 1 -+#elif __riscv_xlen == 32 -+#define V8_HOST_ARCH_RISCV 1 -+#define V8_HOST_ARCH_32_BIT 1 -+#else -+#error "Cannot detect Riscv's bitwidth" -+#endif - #else - #error "Host architecture was not detected as supported by v8" - #endif -@@ -77,7 +87,8 @@ - // environment as presented by the compiler. - #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ - !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ -- !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 -+ !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ -+ !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV - #if defined(_M_X64) || defined(__x86_64__) - #define V8_TARGET_ARCH_X64 1 - #elif defined(_M_IX86) || defined(__i386__) -@@ -94,6 +105,12 @@ - #define V8_TARGET_ARCH_PPC64 1 - #elif defined(_ARCH_PPC) - #define V8_TARGET_ARCH_PPC 1 -+#elif defined(__riscv) || defined(__riscv__) -+#if __riscv_xlen == 64 -+#define V8_TARGET_ARCH_RISCV64 1 -+#elif __riscv_xlen == 32 -+#define V8_TARGET_ARCH_RISCV 1 -+#endif - #else - #error Target architecture was not detected as supported by v8 - #endif -@@ -128,6 +145,10 @@ - #else - #define V8_TARGET_ARCH_32_BIT 1 - #endif -+#elif V8_TARGET_ARCH_RISCV64 -+#define V8_TARGET_ARCH_64_BIT 1 -+#elif V8_TARGET_ARCH_RISCV -+#define V8_TARGET_ARCH_32_BIT 1 - #else - #error Unknown target architecture pointer size - #endif -@@ -156,6 +177,13 @@ - #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) - #error Target architecture mips64 is only supported on mips64 and x64 host - #endif -+#if (V8_TARGET_ARCH_RISCV64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV64)) -+#error Target architecture riscv64 is only supported on riscv64 and x64 host -+#endif -+#if (V8_TARGET_ARCH_RISCV && \ -+ !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV || V8_HOST_ARCH_RISCV64)) -+#error Target architecture riscv (32) is only supported on riscv(32), riscv64, and x64 host -+#endif - - // Determine architecture endianness. - #if V8_TARGET_ARCH_IA32 -@@ -190,6 +218,8 @@ - #else - #define V8_TARGET_BIG_ENDIAN 1 - #endif -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+#define V8_TARGET_LITTLE_ENDIAN 1 - #else - #error Unknown target architecture endianness - #endif ---- a/src/3rdparty/chromium/v8/src/base/compiler-specific.h -+++ b/src/3rdparty/chromium/v8/src/base/compiler-specific.h -@@ -96,9 +96,10 @@ - // do not support adding noexcept to default members. - // Disabled on MSVC because constructors of standard containers are not noexcept - // there. --#if ((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \ -- !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ -- !defined(V8_TARGET_ARCH_PPC) && !defined(V8_TARGET_ARCH_PPC64)) || \ -+#if ((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \ -+ !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ -+ !defined(V8_TARGET_ARCH_PPC) && !defined(V8_TARGET_ARCH_PPC64) && \ -+ !defined(V8_TARGET_ARCH_RISCV64) && !defined(V8_TARGET_ARCH_RISCV)) || \ - (defined(__clang__) && __cplusplus > 201300L)) - #define V8_NOEXCEPT noexcept - #else ---- a/src/3rdparty/chromium/v8/src/base/macros.h -+++ b/src/3rdparty/chromium/v8/src/base/macros.h -@@ -12,6 +12,8 @@ - #include "src/base/compiler-specific.h" - #include "src/base/logging.h" - -+#define DEBUG_PRINTF(...) if (FLAG_debug_riscv) { printf(__VA_ARGS__); } -+ - // No-op macro which is used to work around MSVC's funky VA_ARGS support. - #define EXPAND(x) x - ---- a/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc -+++ b/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc -@@ -324,6 +324,12 @@ - // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance - // to fulfill request. - raw_addr &= uint64_t{0xFFFFFF0000}; -+#elif V8_TARGET_ARCH_RISCV64 -+ // FIXME(RISCV): We need more information from the kernel to correctly mask -+ // this address for RISC-V. -+ raw_addr &= uint64_t{0xFFFFFF0000}; -+#elif V8_TARGET_ARCH_RISCV -+ #error RISCV archiecture not supported - #else - raw_addr &= 0x3FFFF000; - -@@ -512,6 +518,8 @@ - #elif V8_HOST_ARCH_S390 - // Software breakpoint instruction is 0x0001 - asm volatile(".word 0x0001"); -+#elif V8_HOST_ARCH_RISCV64 || V8_HOST_ARCH_RISCV -+ asm("ebreak"); - #else - #error Unsupported host architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/builtins/builtins-sharedarraybuffer-gen.cc -+++ b/src/3rdparty/chromium/v8/src/builtins/builtins-sharedarraybuffer-gen.cc -@@ -379,7 +379,9 @@ - // 2. Let i be ? ValidateAtomicAccess(typedArray, index). - TNode index_word = ValidateAtomicAccess(array, index, context); - --#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ -+ V8_TARGET_ARCH_RISCV -+ // FIXME(RISCV): Review this special case once atomics are added - USE(array_buffer); - TNode index_number = ChangeUintPtrToTagged(index_word); - Return(CallRuntime(Runtime::kAtomicsExchange, context, array, index_number, -@@ -481,7 +483,8 @@ - // This shouldn't happen, we've already validated the type. - BIND(&other); - Unreachable(); --#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || -+ // V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - - BIND(&detached); - { -@@ -510,7 +513,9 @@ - TNode index_word = ValidateAtomicAccess(array, index, context); - - #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ -- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ -+ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ // FIXME(RISCV): Review this special case once atomics are added - USE(array_buffer); - TNode index_number = ChangeUintPtrToTagged(index_word); - Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array, -@@ -632,6 +637,7 @@ - Unreachable(); - #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 - // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - - BIND(&detached); - { -@@ -679,7 +685,9 @@ - TNode index_word = ValidateAtomicAccess(array, index, context); - - #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ -- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ -+ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ // FIXME(RISCV): Review this special case once atomics are added - USE(array_buffer); - TNode index_number = ChangeUintPtrToTagged(index_word); - Return(CallRuntime(runtime_function, context, array, index_number, value)); -@@ -783,6 +791,7 @@ - Unreachable(); - #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 - // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - - BIND(&detached); - ThrowTypeError(context, MessageTemplate::kDetachedOperation, method_name); ---- a/src/3rdparty/chromium/v8/src/builtins/builtins.cc -+++ b/src/3rdparty/chromium/v8/src/builtins/builtins.cc -@@ -490,14 +490,17 @@ - case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit: - return true; - default: --#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ -+ V8_TARGET_ARCH_RISCV -+ // FIXME(RISCV): Is this correct for RISC-V? - // TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE - // caused MIPS platform to crash, and we need some time to handle it. Now - // disable this change temporarily on MIPS platform. - return true; - #else - return false; --#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || -+ // V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - } - } - ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/builtins/riscv64/builtins-riscv64.cc -@@ -0,0 +1,3197 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/api/api-arguments.h" -+#include "src/codegen/code-factory.h" -+#include "src/debug/debug.h" -+#include "src/deoptimizer/deoptimizer.h" -+#include "src/execution/frame-constants.h" -+#include "src/execution/frames.h" -+#include "src/logging/counters.h" -+// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. -+#include "src/codegen/macro-assembler-inl.h" -+#include "src/codegen/register-configuration.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/heap/heap-inl.h" -+#include "src/objects/cell.h" -+#include "src/objects/foreign.h" -+#include "src/objects/heap-number.h" -+#include "src/objects/js-generator.h" -+#include "src/objects/objects-inl.h" -+#include "src/objects/smi.h" -+#include "src/runtime/runtime.h" -+#include "src/wasm/wasm-linkage.h" -+#include "src/wasm/wasm-objects.h" -+ -+namespace v8 { -+namespace internal { -+ -+#define __ ACCESS_MASM(masm) -+ -+void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { -+ __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), -+ RelocInfo::CODE_TARGET); -+} -+ -+static void GenerateTailCallToReturnedCode(MacroAssembler* masm, -+ Runtime::FunctionId function_id) { -+ // ----------- S t a t e ------------- -+ // -- a1 : target function (preserved for callee) -+ // -- a3 : new target (preserved for callee) -+ // ----------------------------------- -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ // Push a copy of the function onto the stack. -+ // Push a copy of the target function and the new target. -+ __ Push(a1, a3, a1); -+ -+ __ CallRuntime(function_id, 1); -+ // Restore target function and new target. -+ __ Pop(a1, a3); -+ } -+ -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Add64(a2, a0, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+} -+ -+namespace { -+ -+enum StackLimitKind { kInterruptStackLimit, kRealStackLimit }; -+ -+void LoadStackLimit(MacroAssembler* masm, Register destination, -+ StackLimitKind kind) { -+ DCHECK(masm->root_array_available()); -+ Isolate* isolate = masm->isolate(); -+ ExternalReference limit = -+ kind == StackLimitKind::kRealStackLimit -+ ? ExternalReference::address_of_real_jslimit(isolate) -+ : ExternalReference::address_of_jslimit(isolate); -+ DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); -+ -+ intptr_t offset = -+ TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); -+ CHECK(is_int32(offset)); -+ __ Ld(destination, MemOperand(kRootRegister, static_cast(offset))); -+} -+ -+void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : number of arguments -+ // -- a1 : constructor function -+ // -- a3 : new target -+ // -- cp : context -+ // -- ra : return address -+ // -- sp[...]: constructor arguments -+ // ----------------------------------- -+ -+ // Enter a construct frame. -+ { -+ FrameScope scope(masm, StackFrame::CONSTRUCT); -+ -+ // Preserve the incoming parameters on the stack. -+ __ SmiTag(a0); -+ __ Push(cp, a0); -+ __ SmiUntag(a0); -+ -+ // The receiver for the builtin/api call. -+ __ PushRoot(RootIndex::kTheHoleValue); -+ -+ // Set up pointer to last argument. -+ __ Add64(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); -+ -+ // Copy arguments and receiver to the expression stack. -+ Label loop, entry; -+ __ Move(t4, a0); -+ // ----------- S t a t e ------------- -+ // -- a0: number of arguments (untagged) -+ // -- a3: new target -+ // -- t2: pointer to last argument -+ // -- t4: counter -+ // -- sp[0*kPointerSize]: the hole (receiver) -+ // -- sp[1*kPointerSize]: number of arguments (tagged) -+ // -- sp[2*kPointerSize]: context -+ // ----------------------------------- -+ __ Branch(&entry); -+ __ bind(&loop); -+ __ CalcScaledAddress(t0, t2, t4, kPointerSizeLog2); -+ __ Ld(t1, MemOperand(t0)); -+ __ push(t1); -+ __ bind(&entry); -+ __ Add64(t4, t4, Operand(-1)); -+ __ Branch(&loop, greater_equal, t4, Operand(zero_reg)); -+ -+ // Call the function. -+ // a0: number of arguments (untagged) -+ // a1: constructor function -+ // a3: new target -+ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); -+ -+ // Restore context from the frame. -+ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ // Restore smi-tagged arguments count from the frame. -+ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ // Leave construct frame. -+ } -+ -+ // Remove caller arguments from the stack and return. -+ __ SmiScale(a4, a1, kPointerSizeLog2); -+ __ Add64(sp, sp, a4); -+ __ Add64(sp, sp, kPointerSize); -+ __ Ret(); -+} -+ -+static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, -+ Register scratch1, Register scratch2, -+ Label* stack_overflow) { -+ // Check the stack for overflow. We are not trying to catch -+ // interruptions (e.g. debug break and preemption) here, so the "real stack -+ // limit" is checked. -+ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); -+ // Make scratch1 the space we have left. The stack might already be overflowed -+ // here which will cause scratch1 to become negative. -+ __ Sub64(scratch1, sp, scratch1); -+ // Check if the arguments will overflow the stack. -+ __ Sll64(scratch2, num_args, kPointerSizeLog2); -+ // Signed comparison. -+ __ Branch(stack_overflow, le, scratch1, Operand(scratch2)); -+} -+ -+} // namespace -+ -+// The construct stub for ES5 constructor functions and ES6 class constructors. -+void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0: number of arguments (untagged) -+ // -- a1: constructor function -+ // -- a3: new target -+ // -- cp: context -+ // -- ra: return address -+ // -- sp[...]: constructor arguments -+ // ----------------------------------- -+ -+ // Enter a construct frame. -+ { -+ FrameScope scope(masm, StackFrame::CONSTRUCT); -+ Label post_instantiation_deopt_entry, not_create_implicit_receiver; -+ -+ // Preserve the incoming parameters on the stack. -+ __ SmiTag(a0); -+ __ Push(cp, a0, a1); -+ __ PushRoot(RootIndex::kTheHoleValue); -+ __ Push(a3); -+ -+ // ----------- S t a t e ------------- -+ // -- sp[0*kPointerSize]: new target -+ // -- sp[1*kPointerSize]: padding -+ // -- a1 and sp[2*kPointerSize]: constructor function -+ // -- sp[3*kPointerSize]: number of arguments (tagged) -+ // -- sp[4*kPointerSize]: context -+ // ----------------------------------- -+ -+ __ Ld(t2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lwu(t2, FieldMemOperand(t2, SharedFunctionInfo::kFlagsOffset)); -+ __ DecodeField(t2); -+ __ JumpIfIsInRange(t2, kDefaultDerivedConstructor, kDerivedConstructor, -+ ¬_create_implicit_receiver); -+ -+ // If not derived class constructor: Allocate the new receiver object. -+ __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1, -+ t2, t4); -+ __ Call(BUILTIN_CODE(masm->isolate(), FastNewObject), -+ RelocInfo::CODE_TARGET); -+ __ Branch(&post_instantiation_deopt_entry); -+ -+ // Else: use TheHoleValue as receiver for constructor call -+ __ bind(¬_create_implicit_receiver); -+ __ LoadRoot(a0, RootIndex::kTheHoleValue); -+ -+ // ----------- S t a t e ------------- -+ // -- a0: receiver -+ // -- Slot 4 / sp[0*kPointerSize]: new target -+ // -- Slot 3 / sp[1*kPointerSize]: padding -+ // -- Slot 2 / sp[2*kPointerSize]: constructor function -+ // -- Slot 1 / sp[3*kPointerSize]: number of arguments (tagged) -+ // -- Slot 0 / sp[4*kPointerSize]: context -+ // ----------------------------------- -+ // Deoptimizer enters here. -+ masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( -+ masm->pc_offset()); -+ __ bind(&post_instantiation_deopt_entry); -+ -+ // Restore new target. -+ __ Pop(a3); -+ // Push the allocated receiver to the stack. We need two copies -+ // because we may have to return the original one and the calling -+ // conventions dictate that the called function pops the receiver. -+ __ Push(a0, a0); -+ -+ // ----------- S t a t e ------------- -+ // -- r3: new target -+ // -- sp[0*kPointerSize]: implicit receiver -+ // -- sp[1*kPointerSize]: implicit receiver -+ // -- sp[2*kPointerSize]: padding -+ // -- sp[3*kPointerSize]: constructor function -+ // -- sp[4*kPointerSize]: number of arguments (tagged) -+ // -- sp[5*kPointerSize]: context -+ // ----------------------------------- -+ -+ // Restore constructor function and argument count. -+ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kConstructorOffset)); -+ __ Ld(a0, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ __ SmiUntag(a0); -+ -+ // Set up pointer to last argument. -+ __ Add64(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); -+ -+ Label enough_stack_space, stack_overflow; -+ Generate_StackOverflowCheck(masm, a0, t0, t1, &stack_overflow); -+ __ Branch(&enough_stack_space); -+ -+ __ bind(&stack_overflow); -+ // Restore the context from the frame. -+ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ -+ __ bind(&enough_stack_space); -+ -+ // Copy arguments and receiver to the expression stack. -+ Label loop, entry; -+ __ Move(t4, a0); -+ // ----------- S t a t e ------------- -+ // -- a0: number of arguments (untagged) -+ // -- a3: new target -+ // -- t2: pointer to last argument -+ // -- t4: counter -+ // -- sp[0*kPointerSize]: implicit receiver -+ // -- sp[1*kPointerSize]: implicit receiver -+ // -- sp[2*kPointerSize]: padding -+ // -- a1 and sp[3*kPointerSize]: constructor function -+ // -- sp[4*kPointerSize]: number of arguments (tagged) -+ // -- sp[5*kPointerSize]: context -+ // ----------------------------------- -+ __ Branch(&entry); -+ __ bind(&loop); -+ __ CalcScaledAddress(t0, t2, t4, kPointerSizeLog2); -+ __ Ld(t1, MemOperand(t0)); -+ __ push(t1); -+ __ bind(&entry); -+ __ Add64(t4, t4, Operand(-1)); -+ __ Branch(&loop, greater_equal, t4, Operand(zero_reg)); -+ -+ // Call the function. -+ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); -+ -+ // ----------- S t a t e ------------- -+ // -- a0: constructor result -+ // -- sp[0*kPointerSize]: implicit receiver -+ // -- sp[1*kPointerSize]: padding -+ // -- sp[2*kPointerSize]: constructor function -+ // -- sp[3*kPointerSize]: number of arguments -+ // -- sp[4*kPointerSize]: context -+ // ----------------------------------- -+ -+ // Store offset of return address for deoptimizer. -+ masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( -+ masm->pc_offset()); -+ -+ // Restore the context from the frame. -+ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); -+ -+ // If the result is an object (in the ECMA sense), we should get rid -+ // of the receiver and use the result; see ECMA-262 section 13.2.2-7 -+ // on page 74. -+ Label use_receiver, do_throw, leave_frame; -+ -+ // If the result is undefined, we jump out to using the implicit receiver. -+ __ JumpIfRoot(a0, RootIndex::kUndefinedValue, &use_receiver); -+ -+ // Otherwise we do a smi check and fall through to check if the return value -+ // is a valid receiver. -+ -+ // If the result is a smi, it is *not* an object in the ECMA sense. -+ __ JumpIfSmi(a0, &use_receiver); -+ -+ // If the type of the result (stored in its map) is less than -+ // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. -+ __ GetObjectType(a0, t2, t2); -+ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); -+ __ Branch(&leave_frame, greater_equal, t2, Operand(FIRST_JS_RECEIVER_TYPE)); -+ __ Branch(&use_receiver); -+ -+ __ bind(&do_throw); -+ __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); -+ -+ // Throw away the result of the constructor invocation and use the -+ // on-stack receiver as the result. -+ __ bind(&use_receiver); -+ __ Ld(a0, MemOperand(sp, 0 * kPointerSize)); -+ __ JumpIfRoot(a0, RootIndex::kTheHoleValue, &do_throw); -+ -+ __ bind(&leave_frame); -+ // Restore smi-tagged arguments count from the frame. -+ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); -+ // Leave construct frame. -+ } -+ // Remove caller arguments from the stack and return. -+ __ SmiScale(a4, a1, kPointerSizeLog2); -+ __ Add64(sp, sp, a4); -+ __ Add64(sp, sp, kPointerSize); -+ __ Ret(); -+} -+ -+void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { -+ Generate_JSBuiltinsConstructStubHelper(masm); -+} -+ -+static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, -+ Register sfi_data, -+ Register scratch1) { -+ Label done; -+ -+ __ GetObjectType(sfi_data, scratch1, scratch1); -+ __ Branch(&done, ne, scratch1, Operand(INTERPRETER_DATA_TYPE)); -+ __ Ld(sfi_data, -+ FieldMemOperand(sfi_data, InterpreterData::kBytecodeArrayOffset)); -+ -+ __ bind(&done); -+} -+ -+// static -+void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the value to pass to the generator -+ // -- a1 : the JSGeneratorObject to resume -+ // -- ra : return address -+ // ----------------------------------- -+ __ AssertGeneratorObject(a1); -+ -+ // Store input value into generator object. -+ __ Sd(a0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); -+ __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, a0, a3, -+ kRAHasNotBeenSaved, kDontSaveFPRegs); -+ -+ // Load suspended function and context. -+ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Ld(cp, FieldMemOperand(a4, JSFunction::kContextOffset)); -+ -+ // Flood function if we are stepping. -+ Label prepare_step_in_if_stepping, prepare_step_in_suspended_generator; -+ Label stepping_prepared; -+ ExternalReference debug_hook = -+ ExternalReference::debug_hook_on_function_call_address(masm->isolate()); -+ __ li(a5, debug_hook); -+ __ Lb(a5, MemOperand(a5)); -+ __ Branch(&prepare_step_in_if_stepping, ne, a5, Operand(zero_reg)); -+ -+ // Flood function if we need to continue stepping in the suspended generator. -+ ExternalReference debug_suspended_generator = -+ ExternalReference::debug_suspended_generator_address(masm->isolate()); -+ __ li(a5, debug_suspended_generator); -+ __ Ld(a5, MemOperand(a5)); -+ __ Branch(&prepare_step_in_suspended_generator, eq, a1, Operand(a5)); -+ __ bind(&stepping_prepared); -+ -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ Label stack_overflow; -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&stack_overflow, Uless, sp, Operand(kScratchReg)); -+ -+ // Push receiver. -+ __ Ld(a5, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); -+ __ Push(a5); -+ -+ // ----------- S t a t e ------------- -+ // -- a1 : the JSGeneratorObject to resume -+ // -- a4 : generator function -+ // -- cp : generator context -+ // -- ra : return address -+ // -- sp[0] : generator receiver -+ // ----------------------------------- -+ -+ // Push holes for arguments to generator function. Since the parser forced -+ // context allocation for any variables in generators, the actual argument -+ // values have already been copied into the context and these dummy values -+ // will never be used. -+ __ Ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lhu(a3, -+ FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ Ld(t1, -+ FieldMemOperand(a1, JSGeneratorObject::kParametersAndRegistersOffset)); -+ { -+ Label done_loop, loop; -+ __ Move(t2, zero_reg); -+ __ bind(&loop); -+ __ Sub64(a3, a3, Operand(1)); -+ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); -+ __ CalcScaledAddress(kScratchReg, t1, t2, kPointerSizeLog2); -+ __ Ld(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); -+ __ Push(kScratchReg); -+ __ Add64(t2, t2, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Underlying function needs to have bytecode available. -+ if (FLAG_debug_code) { -+ __ Ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); -+ GetSharedFunctionInfoBytecode(masm, a3, a0); -+ __ GetObjectType(a3, a3, a3); -+ __ Assert(eq, AbortReason::kMissingBytecodeArray, a3, -+ Operand(BYTECODE_ARRAY_TYPE)); -+ } -+ -+ // Resume (Ignition/TurboFan) generator object. -+ { -+ __ Ld(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lhu(a0, FieldMemOperand( -+ a0, SharedFunctionInfo::kFormalParameterCountOffset)); -+ // We abuse new.target both to indicate that this is a resume call and to -+ // pass in the generator object. In ordinary calls, new.target is always -+ // undefined because generator functions are non-constructable. -+ __ Move(a3, a1); -+ __ Move(a1, a4); -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ } -+ -+ __ bind(&prepare_step_in_if_stepping); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1, a4); -+ // Push hole as receiver since we do not use it for stepping. -+ __ PushRoot(RootIndex::kTheHoleValue); -+ __ CallRuntime(Runtime::kDebugOnFunctionCall); -+ __ Pop(a1); -+ } -+ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Branch(&stepping_prepared); -+ -+ __ bind(&prepare_step_in_suspended_generator); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kDebugPrepareStepInSuspendedGenerator); -+ __ Pop(a1); -+ } -+ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); -+ __ Branch(&stepping_prepared); -+ -+ __ bind(&stack_overflow); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ __ break_(0xCC); // This should be unreachable. -+ } -+} -+ -+void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowConstructedNonConstructable); -+} -+ -+// Clobbers scratch1 and scratch2; preserves all other registers. -+static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, -+ Register scratch1, Register scratch2) { -+ // Check the stack for overflow. We are not trying to catch -+ // interruptions (e.g. debug break and preemption) here, so the "real stack -+ // limit" is checked. -+ Label okay; -+ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); -+ // Make a2 the space we have left. The stack might already be overflowed -+ // here which will cause r2 to become negative. -+ __ Sub64(scratch1, sp, scratch1); -+ // Check if the arguments will overflow the stack. -+ __ Sll64(scratch2, argc, kPointerSizeLog2); -+ __ Branch(&okay, gt, scratch1, Operand(scratch2)); // Signed comparison. -+ -+ // Out of stack space. -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ -+ __ bind(&okay); -+} -+ -+namespace { -+ -+// Called with the native C calling convention. The corresponding function -+// signature is either: -+// -+// using JSEntryFunction = GeneratedCode; -+// or -+// using JSEntryFunction = GeneratedCode; -+void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, -+ Builtins::Name entry_trampoline) { -+ Label invoke, handler_entry, exit; -+ -+ { -+ NoRootArrayScope no_root_array(masm); -+ -+ // TODO(plind): unify the ABI description here. -+ // Registers: -+ // either -+ // a0: root register value -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a0: root register value -+ // a1: microtask_queue -+ -+ // Save callee saved registers on the stack. -+ __ MultiPush(kCalleeSaved | ra.bit()); -+ -+ // Save callee-saved FPU registers. -+ __ MultiPushFPU(kCalleeSavedFPU); -+ // Set up the reserved register for 0.0. -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0); -+ -+ // Initialize the root register. -+ // C calling convention. The first argument is passed in a0. -+ __ Move(kRootRegister, a0); -+ } -+ -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ -+ // We build an EntryFrame. -+ __ li(s1, Operand(-1)); // Push a bad frame pointer to fail if it is used. -+ __ li(s2, Operand(StackFrame::TypeToMarker(type))); -+ __ li(s3, Operand(StackFrame::TypeToMarker(type))); -+ ExternalReference c_entry_fp = ExternalReference::Create( -+ IsolateAddressId::kCEntryFPAddress, masm->isolate()); -+ __ li(s4, c_entry_fp); -+ __ Ld(s4, MemOperand(s4)); -+ __ Push(s1, s2, s3, s4); -+ // Set up frame pointer for the frame to be pushed. -+ __ Add64(fp, sp, -EntryFrameConstants::kCallerFPOffset); -+ // Registers: -+ // either -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a1: microtask_queue -+ // -+ // Stack: -+ // caller fp | -+ // function slot | entry frame -+ // context slot | -+ // bad fp (0xFF...F) | -+ // callee saved registers + ra -+ // [ O32: 4 args slots] -+ // args -+ -+ // If this is the outermost JS call, set js_entry_sp value. -+ Label non_outermost_js; -+ ExternalReference js_entry_sp = ExternalReference::Create( -+ IsolateAddressId::kJSEntrySPAddress, masm->isolate()); -+ __ li(s1, js_entry_sp); -+ __ Ld(s2, MemOperand(s1)); -+ __ Branch(&non_outermost_js, ne, s2, Operand(zero_reg)); -+ __ Sd(fp, MemOperand(s1)); -+ __ li(s3, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); -+ Label cont; -+ __ Branch(&cont); -+ __ bind(&non_outermost_js); -+ __ li(s3, Operand(StackFrame::INNER_JSENTRY_FRAME)); -+ __ bind(&cont); -+ __ push(s3); -+ -+ // Jump to a faked try block that does the invoke, with a faked catch -+ // block that sets the pending exception. -+ __ Branch(&invoke); -+ __ bind(&handler_entry); -+ -+ // Store the current pc as the handler offset. It's used later to create the -+ // handler table. -+ masm->isolate()->builtins()->SetJSEntryHandlerOffset(handler_entry.pos()); -+ -+ // Caught exception: Store result (exception) in the pending exception -+ // field in the JSEnv and return a failure sentinel. Coming in here the -+ // fp will be invalid because the PushStackHandler below sets it to 0 to -+ // signal the existence of the JSEntry frame. -+ __ li(s1, ExternalReference::Create( -+ IsolateAddressId::kPendingExceptionAddress, masm->isolate())); -+ __ Sd(a0, MemOperand(s1)); // We come back from 'invoke'. result is in a0. -+ __ LoadRoot(a0, RootIndex::kException); -+ __ Branch(&exit); -+ -+ // Invoke: Link this frame into the handler chain. -+ __ bind(&invoke); -+ __ PushStackHandler(); -+ // If an exception not caught by another handler occurs, this handler -+ // returns control to the code after the bal(&invoke) above, which -+ // restores all kCalleeSaved registers (including cp and fp) to their -+ // saved values before returning a failure to C. -+ // -+ // Registers: -+ // either -+ // a0: root register value -+ // a1: entry address -+ // a2: function -+ // a3: receiver -+ // a4: argc -+ // a5: argv -+ // or -+ // a0: root register value -+ // a1: microtask_queue -+ // -+ // Stack: -+ // handler frame -+ // entry frame -+ // callee saved registers + ra -+ // [ O32: 4 args slots] -+ // args -+ // -+ // Invoke the function by calling through JS entry trampoline builtin and -+ // pop the faked function when we return. -+ -+ Handle trampoline_code = -+ masm->isolate()->builtins()->builtin_handle(entry_trampoline); -+ __ Call(trampoline_code, RelocInfo::CODE_TARGET); -+ -+ // Unlink this frame from the handler chain. -+ __ PopStackHandler(); -+ -+ __ bind(&exit); // a0 holds result -+ // Check if the current stack frame is marked as the outermost JS frame. -+ Label non_outermost_js_2; -+ __ pop(a5); -+ __ Branch(&non_outermost_js_2, ne, a5, -+ Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); -+ __ li(a5, js_entry_sp); -+ __ Sd(zero_reg, MemOperand(a5)); -+ __ bind(&non_outermost_js_2); -+ -+ // Restore the top frame descriptors from the stack. -+ __ pop(a5); -+ __ li(a4, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, -+ masm->isolate())); -+ __ Sd(a5, MemOperand(a4)); -+ -+ // Reset the stack to the callee saved registers. -+ __ Add64(sp, sp, -EntryFrameConstants::kCallerFPOffset); -+ -+ // Restore callee-saved fpu registers. -+ __ MultiPopFPU(kCalleeSavedFPU); -+ -+ // Restore callee saved registers from the stack. -+ __ MultiPop(kCalleeSaved | ra.bit()); -+ // Return. -+ __ Jump(ra); -+} -+ -+} // namespace -+ -+void Builtins::Generate_JSEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::ENTRY, -+ Builtins::kJSEntryTrampoline); -+} -+ -+void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::CONSTRUCT_ENTRY, -+ Builtins::kJSConstructEntryTrampoline); -+} -+ -+void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { -+ Generate_JSEntryVariant(masm, StackFrame::ENTRY, -+ Builtins::kRunMicrotasksTrampoline); -+} -+ -+static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, -+ bool is_construct) { -+ // ----------- S t a t e ------------- -+ // -- a1: new.target -+ // -- a2: function -+ // -- a3: receiver_pointer -+ // -- a4: argc -+ // -- a5: argv -+ // ----------------------------------- -+ -+ // Enter an internal frame. -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ -+ // Setup the context (we need to use the caller context from the isolate). -+ ExternalReference context_address = ExternalReference::Create( -+ IsolateAddressId::kContextAddress, masm->isolate()); -+ __ li(cp, context_address); -+ __ Ld(cp, MemOperand(cp)); -+ -+ // Push the function and the receiver onto the stack. -+ __ Push(a2, a3); -+ -+ // Check if we have enough stack space to push all arguments. -+ // Clobbers a0 and a3. -+ Generate_CheckStackOverflow(masm, a4, a0, a3); -+ -+ // Setup new.target, function and argc. -+ __ Move(a3, a1); -+ __ Move(a1, a2); -+ __ Move(a0, a4); -+ -+ // a0: argc -+ // a1: function -+ // a3: new.target -+ // a5: argv -+ -+ // Copy arguments to the stack in a loop. -+ // a3: argc -+ // a5: argv, i.e. points to first arg -+ Label loop, entry; -+ __ CalcScaledAddress(s1, a5, a4, kPointerSizeLog2); -+ __ Branch(&entry); -+ // s1 points past last arg. -+ __ bind(&loop); -+ __ Ld(s2, MemOperand(a5)); // Read next parameter. -+ __ Add64(a5, a5, kPointerSize); -+ __ Ld(s2, MemOperand(s2)); // Dereference handle. -+ __ push(s2); // Push parameter. -+ __ bind(&entry); -+ __ Branch(&loop, ne, a5, Operand(s1)); -+ -+ // a0: argc -+ // a1: function -+ // a3: new.target -+ -+ // Initialize all JavaScript callee-saved registers, since they will be seen -+ // by the garbage collector as part of handlers. -+ __ LoadRoot(a4, RootIndex::kUndefinedValue); -+ __ Move(a5, a4); -+ __ Move(s1, a4); -+ __ Move(s2, a4); -+ __ Move(s3, a4); -+ __ Move(s4, a4); -+ __ Move(s5, a4); -+ // s6 holds the root address. Do not clobber. -+ // s7 is cp. Do not init. -+ -+ // Invoke the code. -+ Handle builtin = is_construct -+ ? BUILTIN_CODE(masm->isolate(), Construct) -+ : masm->isolate()->builtins()->Call(); -+ __ Call(builtin, RelocInfo::CODE_TARGET); -+ -+ // Leave internal frame. -+ } -+ __ Jump(ra); -+} -+ -+void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { -+ Generate_JSEntryTrampolineHelper(masm, false); -+} -+ -+void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { -+ Generate_JSEntryTrampolineHelper(masm, true); -+} -+ -+void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) { -+ // a1: microtask_queue -+ __ Move(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1); -+ __ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET); -+} -+ -+static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm, -+ Register optimized_code, -+ Register closure, -+ Register scratch1, -+ Register scratch2) { -+ // Store code entry in the closure. -+ __ Sd(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset)); -+ __ Move(scratch1, optimized_code); // Write barrier clobbers scratch1 below. -+ __ RecordWriteField(closure, JSFunction::kCodeOffset, scratch1, scratch2, -+ kRAHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, -+ OMIT_SMI_CHECK); -+} -+ -+static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { -+ Register args_count = scratch; -+ -+ // Get the arguments + receiver count. -+ __ Ld(args_count, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Lw(t0, FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); -+ -+ // Leave the frame (also dropping the register file). -+ __ LeaveFrame(StackFrame::INTERPRETED); -+ -+ // Drop receiver + arguments. -+ __ Add64(sp, sp, args_count); -+} -+ -+// Tail-call |function_id| if |smi_entry| == |marker| -+static void TailCallRuntimeIfMarkerEquals(MacroAssembler* masm, -+ Register smi_entry, -+ OptimizationMarker marker, -+ Runtime::FunctionId function_id) { -+ Label no_match; -+ __ Branch(&no_match, ne, smi_entry, Operand(Smi::FromEnum(marker))); -+ GenerateTailCallToReturnedCode(masm, function_id); -+ __ bind(&no_match); -+} -+ -+static void TailCallOptimizedCodeSlot(MacroAssembler* masm, -+ Register optimized_code_entry, -+ Register scratch1, Register scratch2) { -+ // ----------- S t a t e ------------- -+ // -- a3 : new target (preserved for callee if needed, and caller) -+ // -- a1 : target function (preserved for callee if needed, and caller) -+ // ----------------------------------- -+ DCHECK(!AreAliased(optimized_code_entry, a1, a3, scratch1, scratch2)); -+ -+ Register closure = a1; -+ -+ // Check if the optimized code is marked for deopt. If it is, call the -+ // runtime to clear it. -+ Label found_deoptimized_code; -+ __ Ld(a5, -+ FieldMemOperand(optimized_code_entry, Code::kCodeDataContainerOffset)); -+ __ Lw(a5, FieldMemOperand(a5, CodeDataContainer::kKindSpecificFlagsOffset)); -+ __ And(a5, a5, Operand(1 << Code::kMarkedForDeoptimizationBit)); -+ __ Branch(&found_deoptimized_code, ne, a5, Operand(zero_reg)); -+ -+ // Optimized code is good, get it into the closure and link the closure into -+ // the optimized functions list, then tail call the optimized code. -+ // The feedback vector is no longer used, so re-use it as a scratch -+ // register. -+ ReplaceClosureCodeWithOptimizedCode(masm, optimized_code_entry, closure, -+ scratch1, scratch2); -+ -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Add64(a2, optimized_code_entry, -+ Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ -+ // Optimized code slot contains deoptimized code, evict it and re-enter the -+ // closure's code. -+ __ bind(&found_deoptimized_code); -+ GenerateTailCallToReturnedCode(masm, Runtime::kEvictOptimizedCodeSlot); -+} -+ -+static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, -+ Register optimization_marker) { -+ // ----------- S t a t e ------------- -+ // -- a3 : new target (preserved for callee if needed, and caller) -+ // -- a1 : target function (preserved for callee if needed, and caller) -+ // -- feedback vector (preserved for caller if needed) -+ // -- optimization_marker : a Smi containing a non-zero optimization marker. -+ // ----------------------------------- -+ DCHECK(!AreAliased(feedback_vector, a1, a3, optimization_marker)); -+ -+ // TODO(v8:8394): The logging of first execution will break if -+ // feedback vectors are not allocated. We need to find a different way of -+ // logging these events if required. -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kLogFirstExecution, -+ Runtime::kFunctionFirstExecution); -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kCompileOptimized, -+ Runtime::kCompileOptimized_NotConcurrent); -+ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, -+ OptimizationMarker::kCompileOptimizedConcurrent, -+ Runtime::kCompileOptimized_Concurrent); -+ -+ // Otherwise, the marker is InOptimizationQueue, so fall through hoping -+ // that an interrupt will eventually update the slot with optimized code. -+ if (FLAG_debug_code) { -+ __ Assert(eq, AbortReason::kExpectedOptimizationSentinel, -+ optimization_marker, -+ Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); -+ } -+} -+ -+// Advance the current bytecode offset. This simulates what all bytecode -+// handlers do upon completion of the underlying operation. Will bail out to a -+// label if the bytecode (without prefix) is a return bytecode. Will not advance -+// the bytecode offset if the current bytecode is a JumpLoop, instead just -+// re-executing the JumpLoop to jump to the correct bytecode. -+static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, -+ Register bytecode_array, -+ Register bytecode_offset, -+ Register bytecode, Register scratch1, -+ Register scratch2, Register scratch3, -+ Label* if_return) { -+ Register bytecode_size_table = scratch1; -+ -+ // The bytecode offset value will be increased by one in wide and extra wide -+ // cases. In the case of having a wide or extra wide JumpLoop bytecode, we -+ // will restore the original bytecode. In order to simplify the code, we have -+ // a backup of it. -+ Register original_bytecode_offset = scratch3; -+ DCHECK(!AreAliased(bytecode_array, bytecode_offset, bytecode, -+ bytecode_size_table, original_bytecode_offset)); -+ __ Move(original_bytecode_offset, bytecode_offset); -+ __ li(bytecode_size_table, ExternalReference::bytecode_size_table_address()); -+ -+ // Check if the bytecode is a Wide or ExtraWide prefix bytecode. -+ Label process_bytecode, extra_wide; -+ STATIC_ASSERT(0 == static_cast(interpreter::Bytecode::kWide)); -+ STATIC_ASSERT(1 == static_cast(interpreter::Bytecode::kExtraWide)); -+ STATIC_ASSERT(2 == static_cast(interpreter::Bytecode::kDebugBreakWide)); -+ STATIC_ASSERT(3 == -+ static_cast(interpreter::Bytecode::kDebugBreakExtraWide)); -+ __ Branch(&process_bytecode, Ugreater, bytecode, Operand(3)); -+ __ And(scratch2, bytecode, Operand(1)); -+ __ Branch(&extra_wide, ne, scratch2, Operand(zero_reg)); -+ -+ // Load the next bytecode and update table to the wide scaled table. -+ __ Add64(bytecode_offset, bytecode_offset, Operand(1)); -+ __ Add64(scratch2, bytecode_array, bytecode_offset); -+ __ Lbu(bytecode, MemOperand(scratch2)); -+ __ Add64(bytecode_size_table, bytecode_size_table, -+ Operand(kIntSize * interpreter::Bytecodes::kBytecodeCount)); -+ __ Branch(&process_bytecode); -+ -+ __ bind(&extra_wide); -+ // Load the next bytecode and update table to the extra wide scaled table. -+ __ Add64(bytecode_offset, bytecode_offset, Operand(1)); -+ __ Add64(scratch2, bytecode_array, bytecode_offset); -+ __ Lbu(bytecode, MemOperand(scratch2)); -+ __ Add64(bytecode_size_table, bytecode_size_table, -+ Operand(2 * kIntSize * interpreter::Bytecodes::kBytecodeCount)); -+ -+ __ bind(&process_bytecode); -+ -+// Bailout to the return label if this is a return bytecode. -+#define JUMP_IF_EQUAL(NAME) \ -+ __ Branch(if_return, eq, bytecode, \ -+ Operand(static_cast(interpreter::Bytecode::k##NAME))); -+ RETURN_BYTECODE_LIST(JUMP_IF_EQUAL) -+#undef JUMP_IF_EQUAL -+ -+ // If this is a JumpLoop, re-execute it to perform the jump to the beginning -+ // of the loop. -+ Label end, not_jump_loop; -+ __ Branch(¬_jump_loop, ne, bytecode, -+ Operand(static_cast(interpreter::Bytecode::kJumpLoop))); -+ // We need to restore the original bytecode_offset since we might have -+ // increased it to skip the wide / extra-wide prefix bytecode. -+ __ Move(bytecode_offset, original_bytecode_offset); -+ __ Branch(&end); -+ -+ __ bind(¬_jump_loop); -+ // Otherwise, load the size of the current bytecode and advance the offset. -+ __ CalcScaledAddress(scratch2, bytecode_size_table, bytecode, 2); -+ __ Lw(scratch2, MemOperand(scratch2)); -+ __ Add64(bytecode_offset, bytecode_offset, scratch2); -+ -+ __ bind(&end); -+} -+ -+// Generate code for entering a JS function with the interpreter. -+// On entry to the function the receiver and arguments have been pushed on the -+// stack left to right. The actual argument count matches the formal parameter -+// count expected by the function. -+// -+// The live registers are: -+// o a1: the JS function object being called. -+// o a3: the incoming new target or generator object -+// o cp: our context -+// o fp: the caller's frame pointer -+// o sp: stack pointer -+// o ra: return address -+// -+// The function builds an interpreter frame. See InterpreterFrameConstants in -+// frames.h for its layout. -+void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { -+ Register closure = a1; -+ Register feedback_vector = a2; -+ -+ // Get the bytecode array from the function object and load it into -+ // kInterpreterBytecodeArrayRegister. -+ __ Ld(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld(kInterpreterBytecodeArrayRegister, -+ FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset)); -+ GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, a4); -+ -+ // The bytecode array could have been flushed from the shared function info, -+ // if so, call into CompileLazy. -+ Label compile_lazy; -+ __ GetObjectType(kInterpreterBytecodeArrayRegister, a0, a0); -+ __ Branch(&compile_lazy, ne, a0, Operand(BYTECODE_ARRAY_TYPE)); -+ -+ // Load the feedback vector from the closure. -+ __ Ld(feedback_vector, -+ FieldMemOperand(closure, JSFunction::kFeedbackCellOffset)); -+ __ Ld(feedback_vector, FieldMemOperand(feedback_vector, Cell::kValueOffset)); -+ -+ Label push_stack_frame; -+ // Check if feedback vector is valid. If valid, check for optimized code -+ // and update invocation count. Otherwise, setup the stack frame. -+ __ Ld(a4, FieldMemOperand(feedback_vector, HeapObject::kMapOffset)); -+ __ Lhu(a4, FieldMemOperand(a4, Map::kInstanceTypeOffset)); -+ __ Branch(&push_stack_frame, ne, a4, Operand(FEEDBACK_VECTOR_TYPE)); -+ -+ // Read off the optimized code slot in the feedback vector, and if there -+ // is optimized code or an optimization marker, call that instead. -+ Register optimized_code_entry = a4; -+ __ Ld(optimized_code_entry, -+ FieldMemOperand(feedback_vector, -+ FeedbackVector::kOptimizedCodeWeakOrSmiOffset)); -+ -+ // Check if the optimized code slot is not empty. -+ Label optimized_code_slot_not_empty; -+ -+ __ Branch(&optimized_code_slot_not_empty, ne, optimized_code_entry, -+ Operand(Smi::FromEnum(OptimizationMarker::kNone))); -+ -+ Label not_optimized; -+ __ bind(¬_optimized); -+ -+ // Increment invocation count for the function. -+ __ Lw(a4, FieldMemOperand(feedback_vector, -+ FeedbackVector::kInvocationCountOffset)); -+ __ Add32(a4, a4, Operand(1)); -+ __ Sw(a4, FieldMemOperand(feedback_vector, -+ FeedbackVector::kInvocationCountOffset)); -+ -+ // Open a frame scope to indicate that there is a frame on the stack. The -+ // MANUAL indicates that the scope shouldn't actually generate code to set up -+ // the frame (that is done below). -+ __ bind(&push_stack_frame); -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ PushStandardFrame(closure); -+ -+ // Reset code age and the OSR arming. The OSR field and BytecodeAgeOffset are -+ // 8-bit fields next to each other, so we could just optimize by writing a -+ // 16-bit. These static asserts guard our assumption is valid. -+ STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset == -+ BytecodeArray::kOsrNestingLevelOffset + kCharSize); -+ STATIC_ASSERT(BytecodeArray::kNoAgeBytecodeAge == 0); -+ __ Sh(zero_reg, FieldMemOperand(kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kOsrNestingLevelOffset)); -+ -+ // Load initial bytecode offset. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ -+ // Push bytecode array and Smi tagged bytecode array offset. -+ __ SmiTag(a4, kInterpreterBytecodeOffsetRegister); -+ __ Push(kInterpreterBytecodeArrayRegister, a4); -+ -+ // Allocate the local and temporary register file on the stack. -+ Label stack_overflow; -+ { -+ // Load frame size (word) from the BytecodeArray object. -+ __ Lw(a4, FieldMemOperand(kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kFrameSizeOffset)); -+ -+ // Do a stack check to ensure we don't go over the limit. -+ __ Sub64(a5, sp, Operand(a4)); -+ LoadStackLimit(masm, a2, StackLimitKind::kRealStackLimit); -+ __ Branch(&stack_overflow, Uless, a5, Operand(a2)); -+ -+ // If ok, push undefined as the initial value for all register file entries. -+ Label loop_header; -+ Label loop_check; -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ Branch(&loop_check); -+ __ bind(&loop_header); -+ // TODO(rmcilroy): Consider doing more than one push per loop iteration. -+ __ push(a5); -+ // Continue loop if not done. -+ __ bind(&loop_check); -+ __ Sub64(a4, a4, Operand(kPointerSize)); -+ __ Branch(&loop_header, ge, a4, Operand(zero_reg)); -+ } -+ -+ // If the bytecode array has a valid incoming new target or generator object -+ // register, initialize it with incoming value which was passed in r3. -+ Label no_incoming_new_target_or_generator_register; -+ __ Lw(a5, FieldMemOperand( -+ kInterpreterBytecodeArrayRegister, -+ BytecodeArray::kIncomingNewTargetOrGeneratorRegisterOffset)); -+ __ Branch(&no_incoming_new_target_or_generator_register, eq, a5, -+ Operand(zero_reg)); -+ __ CalcScaledAddress(a5, fp, a5, kPointerSizeLog2); -+ __ Sd(a3, MemOperand(a5)); -+ __ bind(&no_incoming_new_target_or_generator_register); -+ -+ // Perform interrupt stack check. -+ // TODO(solanes): Merge with the real stack limit check above. -+ Label stack_check_interrupt, after_stack_check_interrupt; -+ LoadStackLimit(masm, a5, StackLimitKind::kInterruptStackLimit); -+ __ Branch(&stack_check_interrupt, Uless, sp, Operand(a5)); -+ __ bind(&after_stack_check_interrupt); -+ -+ // Load accumulator as undefined. -+ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); -+ -+ // Load the dispatch table into a register and dispatch to the bytecode -+ // handler at the current bytecode offset. -+ Label do_dispatch; -+ __ bind(&do_dispatch); -+ __ li(kInterpreterDispatchTableRegister, -+ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); -+ __ Add64(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Lbu(a7, MemOperand(a1)); -+ __ CalcScaledAddress(kScratchReg, kInterpreterDispatchTableRegister, a7, -+ kPointerSizeLog2); -+ __ Ld(kJavaScriptCallCodeStartRegister, MemOperand(kScratchReg)); -+ __ Call(kJavaScriptCallCodeStartRegister); -+ masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); -+ -+ // Any returns to the entry trampoline are either due to the return bytecode -+ // or the interpreter tail calling a builtin and then a dispatch. -+ -+ // Get bytecode array and bytecode offset from the stack frame. -+ __ Ld(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Ld(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister); -+ -+ // Either return, or advance to the next bytecode and dispatch. -+ Label do_return; -+ __ Add64(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Lbu(a1, MemOperand(a1)); -+ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister, a1, a2, a3, -+ a4, &do_return); -+ __ Branch(&do_dispatch); -+ -+ __ bind(&do_return); -+ // The return value is in a0. -+ LeaveInterpreterFrame(masm, t0); -+ __ Jump(ra); -+ -+ __ bind(&stack_check_interrupt); -+ // Modify the bytecode offset in the stack to be kFunctionEntryBytecodeOffset -+ // for the call to the StackGuard. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(Smi::FromInt(BytecodeArray::kHeaderSize - kHeapObjectTag + -+ kFunctionEntryBytecodeOffset))); -+ __ Sd(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ CallRuntime(Runtime::kStackGuard); -+ -+ // After the call, restore the bytecode array, bytecode offset and accumulator -+ // registers again. Also, restore the bytecode offset in the stack to its -+ // previous value. -+ __ Ld(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); -+ -+ __ SmiTag(a5, kInterpreterBytecodeOffsetRegister); -+ __ Sd(a5, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ __ Branch(&after_stack_check_interrupt); -+ -+ __ bind(&optimized_code_slot_not_empty); -+ Label maybe_has_optimized_code; -+ // Check if optimized code marker is actually a weak reference to the -+ // optimized code as opposed to an optimization marker. -+ __ JumpIfNotSmi(optimized_code_entry, &maybe_has_optimized_code); -+ MaybeOptimizeCode(masm, feedback_vector, optimized_code_entry); -+ // Fall through if there's no runnable optimized code. -+ __ Branch(¬_optimized); -+ -+ __ bind(&maybe_has_optimized_code); -+ // Load code entry from the weak reference, if it was cleared, resume -+ // execution of unoptimized code. -+ __ LoadWeakValue(optimized_code_entry, optimized_code_entry, ¬_optimized); -+ TailCallOptimizedCodeSlot(masm, optimized_code_entry, t4, a5); -+ -+ __ bind(&compile_lazy); -+ GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); -+ // Unreachable code. -+ __ break_(0xCC); -+ -+ __ bind(&stack_overflow); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+} -+ -+static void Generate_InterpreterPushArgs(MacroAssembler* masm, -+ Register num_args, Register index, -+ Register scratch, Register scratch2) { -+ // Find the address of the last argument. -+ __ Move(scratch2, num_args); -+ __ Sll64(scratch2, scratch2, kPointerSizeLog2); -+ __ Sub64(scratch2, index, Operand(scratch2)); -+ -+ // Push the arguments. -+ Label loop_header, loop_check; -+ __ Branch(&loop_check); -+ __ bind(&loop_header); -+ __ Ld(scratch, MemOperand(index)); -+ __ Add64(index, index, Operand(-kPointerSize)); -+ __ push(scratch); -+ __ bind(&loop_check); -+ __ Branch(&loop_header, Ugreater, index, Operand(scratch2)); -+} -+ -+// static -+void Builtins::Generate_InterpreterPushArgsThenCallImpl( -+ MacroAssembler* masm, ConvertReceiverMode receiver_mode, -+ InterpreterPushArgsMode mode) { -+ DCHECK(mode != InterpreterPushArgsMode::kArrayFunction); -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a2 : the address of the first argument to be pushed. Subsequent -+ // arguments should be consecutive above this, in the same order as -+ // they are to be pushed onto the stack. -+ // -- a1 : the target to call (can be any Object). -+ // ----------------------------------- -+ Label stack_overflow; -+ -+ __ Add64(a3, a0, Operand(1)); // Add one for receiver. -+ -+ // Push "undefined" as the receiver arg if we need to. -+ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ Sub64(a3, a3, Operand(1)); // Subtract one for receiver. -+ } -+ -+ Generate_StackOverflowCheck(masm, a3, a4, t0, &stack_overflow); -+ -+ // This function modifies a2, t0 and a4. -+ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Pop(a2); // Pass the spread in a register -+ __ Sub64(a0, a0, Operand(1)); // Subtract one for spread -+ } -+ -+ // Call the target. -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithSpread), -+ RelocInfo::CODE_TARGET); -+ } else { -+ __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny), -+ RelocInfo::CODE_TARGET); -+ } -+ -+ __ bind(&stack_overflow); -+ { -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ } -+} -+ -+// static -+void Builtins::Generate_InterpreterPushArgsThenConstructImpl( -+ MacroAssembler* masm, InterpreterPushArgsMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argument count (not including receiver) -+ // -- a3 : new target -+ // -- a1 : constructor to call -+ // -- a2 : allocation site feedback if available, undefined otherwise. -+ // -- a4 : address of the first argument -+ // ----------------------------------- -+ Label stack_overflow; -+ -+ // Push a slot for the receiver. -+ __ push(zero_reg); -+ -+ Generate_StackOverflowCheck(masm, a0, a5, t0, &stack_overflow); -+ -+ // This function modifies t0, a4 and a5. -+ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); -+ -+ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ __ Pop(a2); // Pass the spread in a register -+ __ Sub64(a0, a0, Operand(1)); // Subtract one for spread -+ } else { -+ __ AssertUndefinedOrAllocationSite(a2, t0); -+ } -+ -+ if (mode == InterpreterPushArgsMode::kArrayFunction) { -+ __ AssertFunction(a1); -+ -+ // Tail call to the function-specific construct stub (still in the caller -+ // context at this point). -+ __ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl), -+ RelocInfo::CODE_TARGET); -+ } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { -+ // Call the constructor with a0, a1, and a3 unmodified. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithSpread), -+ RelocInfo::CODE_TARGET); -+ } else { -+ DCHECK_EQ(InterpreterPushArgsMode::kOther, mode); -+ // Call the constructor with a0, a1, and a3 unmodified. -+ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); -+ } -+ -+ __ bind(&stack_overflow); -+ { -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ // Unreachable code. -+ __ break_(0xCC); -+ } -+} -+ -+static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { -+ // Set the return address to the correct point in the interpreter entry -+ // trampoline. -+ Label builtin_trampoline, trampoline_loaded; -+ Smi interpreter_entry_return_pc_offset( -+ masm->isolate()->heap()->interpreter_entry_return_pc_offset()); -+ DCHECK_NE(interpreter_entry_return_pc_offset, Smi::zero()); -+ -+ // If the SFI function_data is an InterpreterData, the function will have a -+ // custom copy of the interpreter entry trampoline for profiling. If so, -+ // get the custom trampoline, otherwise grab the entry address of the global -+ // trampoline. -+ __ Ld(t0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ Ld(t0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); -+ __ Ld(t0, FieldMemOperand(t0, SharedFunctionInfo::kFunctionDataOffset)); -+ __ GetObjectType(t0, kInterpreterDispatchTableRegister, -+ kInterpreterDispatchTableRegister); -+ __ Branch(&builtin_trampoline, ne, kInterpreterDispatchTableRegister, -+ Operand(INTERPRETER_DATA_TYPE)); -+ -+ __ Ld(t0, FieldMemOperand(t0, InterpreterData::kInterpreterTrampolineOffset)); -+ __ Add64(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Branch(&trampoline_loaded); -+ -+ __ bind(&builtin_trampoline); -+ __ li(t0, ExternalReference:: -+ address_of_interpreter_entry_trampoline_instruction_start( -+ masm->isolate())); -+ __ Ld(t0, MemOperand(t0)); -+ -+ __ bind(&trampoline_loaded); -+ __ Add64(ra, t0, Operand(interpreter_entry_return_pc_offset.value())); -+ -+ // Initialize the dispatch table register. -+ __ li(kInterpreterDispatchTableRegister, -+ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); -+ -+ // Get the bytecode array pointer from the frame. -+ __ Ld(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ -+ if (FLAG_debug_code) { -+ // Check function data field is actually a BytecodeArray object. -+ __ SmiTst(kInterpreterBytecodeArrayRegister, kScratchReg); -+ __ Assert(ne, -+ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, -+ kScratchReg, Operand(zero_reg)); -+ __ GetObjectType(kInterpreterBytecodeArrayRegister, a1, a1); -+ __ Assert(eq, -+ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, -+ a1, Operand(BYTECODE_ARRAY_TYPE)); -+ } -+ -+ // Get the target bytecode offset from the frame. -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ if (FLAG_debug_code) { -+ Label okay; -+ __ Branch(&okay, ge, kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ // Unreachable code. -+ __ break_(0xCC); -+ __ bind(&okay); -+ } -+ -+ // Dispatch to the target bytecode. -+ __ Add64(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Lbu(a7, MemOperand(a1)); -+ __ CalcScaledAddress(a1, kInterpreterDispatchTableRegister, a7, -+ kPointerSizeLog2); -+ __ Ld(kJavaScriptCallCodeStartRegister, MemOperand(a1)); -+ __ Jump(kJavaScriptCallCodeStartRegister); -+} -+ -+void Builtins::Generate_InterpreterEnterBytecodeAdvance(MacroAssembler* masm) { -+ // Advance the current bytecode offset stored within the given interpreter -+ // stack frame. This simulates what all bytecode handlers do upon completion -+ // of the underlying operation. -+ __ Ld(kInterpreterBytecodeArrayRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); -+ __ Ld(kInterpreterBytecodeOffsetRegister, -+ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ __ SmiUntag(kInterpreterBytecodeOffsetRegister); -+ -+ Label enter_bytecode, function_entry_bytecode; -+ __ Branch(&function_entry_bytecode, eq, kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag + -+ kFunctionEntryBytecodeOffset)); -+ -+ // Load the current bytecode. -+ __ Add64(a1, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister); -+ __ Lbu(a1, MemOperand(a1)); -+ -+ // Advance to the next bytecode. -+ Label if_return; -+ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, -+ kInterpreterBytecodeOffsetRegister, a1, a2, a3, -+ a4, &if_return); -+ -+ __ bind(&enter_bytecode); -+ // Convert new bytecode offset to a Smi and save in the stackframe. -+ __ SmiTag(a2, kInterpreterBytecodeOffsetRegister); -+ __ Sd(a2, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); -+ -+ Generate_InterpreterEnterBytecode(masm); -+ -+ __ bind(&function_entry_bytecode); -+ // If the code deoptimizes during the implicit function entry stack interrupt -+ // check, it will have a bailout ID of kFunctionEntryBytecodeOffset, which is -+ // not a valid bytecode offset. Detect this case and advance to the first -+ // actual bytecode. -+ __ li(kInterpreterBytecodeOffsetRegister, -+ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); -+ __ Branch(&enter_bytecode); -+ -+ // We should never take the if_return path. -+ __ bind(&if_return); -+ __ Abort(AbortReason::kInvalidBytecodeAdvance); -+} -+ -+void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { -+ Generate_InterpreterEnterBytecode(masm); -+} -+ -+namespace { -+void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, -+ bool java_script_builtin, -+ bool with_result) { -+ const RegisterConfiguration* config(RegisterConfiguration::Default()); -+ int allocatable_register_count = config->num_allocatable_general_registers(); -+ if (with_result) { -+ // Overwrite the hole inserted by the deoptimizer with the return value from -+ // the LAZY deopt point. -+ __ Sd(a0, -+ MemOperand( -+ sp, config->num_allocatable_general_registers() * kPointerSize + -+ BuiltinContinuationFrameConstants::kFixedFrameSize)); -+ } -+ for (int i = allocatable_register_count - 1; i >= 0; --i) { -+ int code = config->GetAllocatableGeneralCode(i); -+ __ Pop(Register::from_code(code)); -+ if (java_script_builtin && code == kJavaScriptCallArgCountRegister.code()) { -+ __ SmiUntag(Register::from_code(code)); -+ } -+ } -+ __ Ld(fp, MemOperand( -+ sp, BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); -+ // Load builtin index (stored as a Smi) and use it to get the builtin start -+ // address from the builtins table. -+ __ Pop(t0); -+ __ Add64(sp, sp, -+ Operand(BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); -+ __ Pop(ra); -+ __ LoadEntryFromBuiltinIndex(t0); -+ __ Jump(t0); -+} -+} // namespace -+ -+void Builtins::Generate_ContinueToCodeStubBuiltin(MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, false, false); -+} -+ -+void Builtins::Generate_ContinueToCodeStubBuiltinWithResult( -+ MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, false, true); -+} -+ -+void Builtins::Generate_ContinueToJavaScriptBuiltin(MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, true, false); -+} -+ -+void Builtins::Generate_ContinueToJavaScriptBuiltinWithResult( -+ MacroAssembler* masm) { -+ Generate_ContinueToBuiltinHelper(masm, true, true); -+} -+ -+void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kNotifyDeoptimized); -+ } -+ -+ DCHECK_EQ(kInterpreterAccumulatorRegister.code(), a0.code()); -+ __ Ld(a0, MemOperand(sp, 0 * kPointerSize)); -+ __ Add64(sp, sp, Operand(1 * kPointerSize)); // Remove state. -+ __ Ret(); -+} -+ -+void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kCompileForOnStackReplacement); -+ } -+ -+ // If the code object is null, just return to the caller. -+ __ Ret(eq, a0, Operand(Smi::zero())); -+ -+ // Drop the handler frame that is be sitting on top of the actual -+ // JavaScript frame. This is the case then OSR is triggered from bytecode. -+ __ LeaveFrame(StackFrame::STUB); -+ -+ // Load deoptimization data from the code object. -+ // = [#deoptimization_data_offset] -+ __ Ld(a1, MemOperand(a0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); -+ -+ // Load the OSR entrypoint offset from the deoptimization data. -+ // = [#header_size + #osr_pc_offset] -+ __ SmiUntag(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( -+ DeoptimizationData::kOsrPcOffsetIndex) - -+ kHeapObjectTag)); -+ -+ // Compute the target address = code_obj + header_size + osr_offset -+ // = + #header_size + -+ __ Add64(a0, a0, a1); -+ __ Add64(ra, a0, Code::kHeaderSize - kHeapObjectTag); -+ // And "return" to the OSR entry point of the function. -+ __ Ret(); -+} -+ -+// static -+void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : argArray -+ // -- sp[4] : thisArg -+ // -- sp[8] : receiver -+ // ----------------------------------- -+ -+ Register argc = a0; -+ Register arg_array = a2; -+ Register receiver = a1; -+ Register this_arg = a5; -+ Register undefined_value = a3; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load receiver into a1, argArray into a2 (if present), remove all -+ // arguments from the stack (including the receiver), and push thisArg (if -+ // present) instead. -+ { -+ // Claim (2 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ -+ __ Sub64(sp, sp, Operand(2 * kPointerSize)); -+ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); -+ __ Pop(this_arg, arg_array); // Overwrite argc -+ -+ Label done0, done1; -+ __ Branch(&done0, ne, argc, Operand(zero_reg)); -+ __ Move(arg_array, undefined_value); // if argc == 0 -+ __ Move(this_arg, undefined_value); // if argc == 0 -+ __ bind(&done0); // else (i.e., argc > 0) -+ -+ __ Branch(&done1, ne, argc, Operand(1)); -+ __ Move(arg_array, undefined_value); // if argc == 1 -+ __ bind(&done1); // else (i.e., argc > 1) -+ -+ __ Ld(receiver, MemOperand(sp)); -+ __ Sd(this_arg, MemOperand(sp)); -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argArray -+ // -- a1 : receiver -+ // -- a3 : undefined root value -+ // -- sp[0] : thisArg -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for callable receiver here, -+ // since that's the first thing the Call/CallWithArrayLike builtins -+ // will do. -+ -+ // 3. Tail call with no arguments if argArray is null or undefined. -+ Label no_arguments; -+ __ JumpIfRoot(arg_array, RootIndex::kNullValue, &no_arguments); -+ __ Branch(&no_arguments, eq, arg_array, Operand(undefined_value)); -+ -+ // 4a. Apply the receiver to the given argArray. -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), -+ RelocInfo::CODE_TARGET); -+ -+ // 4b. The argArray is either null or undefined, so we tail call without any -+ // arguments to the receiver. -+ __ bind(&no_arguments); -+ { -+ __ Move(a0, zero_reg); -+ DCHECK(receiver == a1); -+ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); -+ } -+} -+ -+// static -+void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { -+ // 1. Make sure we have at least one argument. -+ // a0: actual number of arguments -+ { -+ Label done; -+ __ Branch(&done, ne, a0, Operand(zero_reg)); -+ __ PushRoot(RootIndex::kUndefinedValue); -+ __ Add64(a0, a0, Operand(1)); -+ __ bind(&done); -+ } -+ -+ // 2. Get the function to call (passed as receiver) from the stack. -+ // a0: actual number of arguments -+ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); -+ __ Ld(a1, MemOperand(kScratchReg)); -+ -+ // 3. Shift arguments and return address one slot down on the stack -+ // (overwriting the original receiver). Adjust argument count to make -+ // the original first argument the new receiver. -+ // a0: actual number of arguments -+ // a1: function -+ { -+ Label loop; -+ // Calculate the copy start address (destination). Copy end address is sp. -+ __ CalcScaledAddress(a2, sp, a0, kPointerSizeLog2); -+ -+ __ bind(&loop); -+ __ Ld(kScratchReg, MemOperand(a2, -kPointerSize)); -+ __ Sd(kScratchReg, MemOperand(a2)); -+ __ Sub64(a2, a2, Operand(kPointerSize)); -+ __ Branch(&loop, ne, a2, Operand(sp)); -+ // Adjust the actual number of arguments and remove the top element -+ // (which is a copy of the last argument). -+ __ Sub64(a0, a0, Operand(1)); -+ __ Pop(); -+ } -+ -+ // 4. Call the callable. -+ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ReflectApply(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : argumentsList (if argc ==3) -+ // -- sp[4] : thisArgument (if argc >=2) -+ // -- sp[8] : target (if argc >=1) -+ // -- sp[12] : receiver -+ // ----------------------------------- -+ -+ Register argc = a0; -+ Register arguments_list = a2; -+ Register target = a1; -+ Register this_argument = a5; -+ Register undefined_value = a3; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load target into a1 (if present), argumentsList into a2 (if present), -+ // remove all arguments from the stack (including the receiver), and push -+ // thisArgument (if present) instead. -+ { -+ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ -+ __ Sub64(sp, sp, Operand(3 * kPointerSize)); -+ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); -+ __ Pop(target, this_argument, arguments_list); -+ -+ Label done0, done1, done2; -+ __ Branch(&done0, ne, argc, Operand(zero_reg)); -+ __ Move(arguments_list, undefined_value); // if argc == 0 -+ __ Move(this_argument, undefined_value); // if argc == 0 -+ __ Move(target, undefined_value); // if argc == 0 -+ __ bind(&done0); // argc != 0 -+ -+ __ Branch(&done1, ne, argc, Operand(1)); -+ __ Move(arguments_list, undefined_value); // if argc == 1 -+ __ Move(this_argument, undefined_value); // if argc == 1 -+ __ bind(&done1); // argc > 1 -+ -+ __ Branch(&done2, ne, argc, Operand(2)); -+ __ Move(arguments_list, undefined_value); // if argc == 2 -+ __ bind(&done2); // argc > 2 -+ -+ __ Sd(this_argument, MemOperand(sp, 0)); // Overwrite receiver -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argumentsList -+ // -- a1 : target -+ // -- a3 : undefined root value -+ // -- sp[0] : thisArgument -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for callable target here, -+ // since that's the first thing the Call/CallWithArrayLike builtins -+ // will do. -+ -+ // 3. Apply the target to the given argumentsList. -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), -+ RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : argc -+ // -- sp[0] : new.target (optional) (dummy value if argc <= 2) -+ // -- sp[4] : argumentsList (dummy value if argc <= 1) -+ // -- sp[8] : target (dummy value if argc == 0) -+ // -- sp[12] : receiver -+ // ----------------------------------- -+ Register argc = a0; -+ Register arguments_list = a2; -+ Register target = a1; -+ Register new_target = a3; -+ Register undefined_value = a4; -+ -+ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); -+ -+ // 1. Load target into a1 (if present), argumentsList into a2 (if present), -+ // new.target into a3 (if present, otherwise use target), remove all -+ // arguments from the stack (including the receiver), and push thisArgument -+ // (if present) instead. -+ { -+ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a -+ // consistent state for a simple pop operation. -+ __ Sub64(sp, sp, Operand(3 * kPointerSize)); -+ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); -+ __ Pop(target, arguments_list, new_target); -+ -+ Label done0, done1, done2; -+ __ Branch(&done0, ne, argc, Operand(zero_reg)); -+ __ Move(arguments_list, undefined_value); // if argc == 0 -+ __ Move(new_target, undefined_value); // if argc == 0 -+ __ Move(target, undefined_value); // if argc == 0 -+ __ bind(&done0); -+ -+ __ Branch(&done1, ne, argc, Operand(1)); -+ __ Move(arguments_list, undefined_value); // if argc == 1 -+ __ Move(new_target, target); // if argc == 1 -+ __ bind(&done1); -+ -+ __ Branch(&done2, ne, argc, Operand(2)); -+ __ Move(new_target, target); // if argc == 2 -+ __ bind(&done2); -+ -+ __ Sd(undefined_value, MemOperand(sp, 0)); // Overwrite receiver -+ } -+ -+ // ----------- S t a t e ------------- -+ // -- a2 : argumentsList -+ // -- a1 : target -+ // -- a3 : new.target -+ // -- sp[0] : receiver (undefined) -+ // ----------------------------------- -+ -+ // 2. We don't need to check explicitly for constructor target here, -+ // since that's the first thing the Construct/ConstructWithArrayLike -+ // builtins will do. -+ -+ // 3. We don't need to check explicitly for constructor new.target here, -+ // since that's the second thing the Construct/ConstructWithArrayLike -+ // builtins will do. -+ -+ // 4. Construct the target with the given new.target and argumentsList. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithArrayLike), -+ RelocInfo::CODE_TARGET); -+} -+ -+static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { -+ __ SmiTag(a0); -+ __ li(a4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); -+ __ Push(Smi::zero()); // Padding. -+ __ Add64(fp, sp, -+ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp)); -+} -+ -+static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : result being passed through -+ // ----------------------------------- -+ // Get the number of arguments passed (as a smi), tear down the frame and -+ // then tear down the parameters. -+ __ Ld(a1, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ __ Move(sp, fp); -+ __ MultiPop(fp.bit() | ra.bit()); -+ __ SmiScale(a4, a1, kPointerSizeLog2); -+ __ Add64(sp, sp, a4); -+ // Adjust for the receiver. -+ __ Add64(sp, sp, Operand(kPointerSize)); -+} -+ -+// static -+void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, -+ Handle code) { -+ // ----------- S t a t e ------------- -+ // -- a1 : target -+ // -- a0 : number of parameters on the stack (not including the receiver) -+ // -- a2 : arguments list (a FixedArray) -+ // -- a4 : len (number of elements to push from args) -+ // -- a3 : new.target (for [[Construct]]) -+ // ----------------------------------- -+ if (masm->emit_debug_code()) { -+ // Allow a2 to be a FixedArray, or a FixedDoubleArray if a4 == 0. -+ Label ok, fail; -+ __ AssertNotSmi(a2); -+ __ GetObjectType(a2, t5, t5); -+ __ Branch(&ok, eq, t5, Operand(FIXED_ARRAY_TYPE)); -+ __ Branch(&fail, ne, t5, Operand(FIXED_DOUBLE_ARRAY_TYPE)); -+ __ Branch(&ok, eq, a4, Operand(zero_reg)); -+ // Fall through. -+ __ bind(&fail); -+ __ Abort(AbortReason::kOperandIsNotAFixedArray); -+ -+ __ bind(&ok); -+ } -+ -+ Register args = a2; -+ Register len = a4; -+ -+ // Check for stack overflow. -+ Label stack_overflow; -+ Generate_StackOverflowCheck(masm, len, kScratchReg, a5, &stack_overflow); -+ -+ // Push arguments onto the stack (thisArgument is already on the stack). -+ { -+ Label done, push, loop; -+ Register src = a6; -+ Register scratch = len; -+ __ Add64(src, args, FixedArray::kHeaderSize - kHeapObjectTag); -+ __ Add64(a0, a0, len); // The 'len' argument for Call() or Construct(). -+ __ Branch(&done, eq, len, Operand(zero_reg)); -+ __ Sll64(scratch, len, kPointerSizeLog2); -+ __ Sub64(scratch, sp, Operand(scratch)); -+ __ LoadRoot(t1, RootIndex::kTheHoleValue); -+ __ bind(&loop); -+ __ Ld(a5, MemOperand(src)); -+ __ Branch(&push, ne, a5, Operand(t1)); -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ bind(&push); -+ __ Add64(src, src, kPointerSize); -+ __ Push(a5); -+ __ Branch(&loop, ne, scratch, Operand(sp)); -+ __ bind(&done); -+ } -+ -+ // Tail-call to the actual Call or Construct builtin. -+ __ Jump(code, RelocInfo::CODE_TARGET); -+ -+ __ bind(&stack_overflow); -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+} -+ -+// static -+void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, -+ CallOrConstructMode mode, -+ Handle code) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a3 : the new.target (for [[Construct]] calls) -+ // -- a1 : the target to call (can be any Object) -+ // -- a2 : start index (to support rest parameters) -+ // ----------------------------------- -+ -+ // Check if new.target has a [[Construct]] internal method. -+ if (mode == CallOrConstructMode::kConstruct) { -+ Label new_target_constructor, new_target_not_constructor; -+ __ JumpIfSmi(a3, &new_target_not_constructor); -+ __ Ld(t1, FieldMemOperand(a3, HeapObject::kMapOffset)); -+ __ Lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t1, t1, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ __ Branch(&new_target_constructor, ne, t1, Operand(zero_reg)); -+ __ bind(&new_target_not_constructor); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ Push(a3); -+ __ CallRuntime(Runtime::kThrowNotConstructor); -+ } -+ __ bind(&new_target_constructor); -+ } -+ -+ // Check if we have an arguments adaptor frame below the function frame. -+ Label arguments_adaptor, arguments_done; -+ __ Ld(a6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ __ Ld(a7, MemOperand(a6, CommonFrameConstants::kContextOrFrameTypeOffset)); -+ __ Branch(&arguments_adaptor, eq, a7, -+ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ { -+ __ Ld(a7, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ Ld(a7, FieldMemOperand(a7, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lhu(a7, FieldMemOperand( -+ a7, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ Move(a6, fp); -+ } -+ __ Branch(&arguments_done); -+ __ bind(&arguments_adaptor); -+ { -+ // Just get the length from the ArgumentsAdaptorFrame. -+ __ SmiUntag(a7, -+ MemOperand(a6, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ } -+ __ bind(&arguments_done); -+ -+ Label stack_done, stack_overflow; -+ __ Sub32(a7, a7, a2); -+ __ Branch(&stack_done, le, a7, Operand(zero_reg)); -+ { -+ // Check for stack overflow. -+ Generate_StackOverflowCheck(masm, a7, a4, a5, &stack_overflow); -+ -+ // Forward the arguments from the caller frame. -+ { -+ Label loop; -+ __ Add64(a0, a0, a7); -+ __ bind(&loop); -+ { -+ __ CalcScaledAddress(kScratchReg, a6, a7, kPointerSizeLog2); -+ __ Ld(kScratchReg, MemOperand(kScratchReg, 1 * kPointerSize)); -+ __ push(kScratchReg); -+ __ Sub32(a7, a7, Operand(1)); -+ __ Branch(&loop, ne, a7, Operand(zero_reg)); -+ } -+ } -+ } -+ __ Branch(&stack_done); -+ __ bind(&stack_overflow); -+ __ TailCallRuntime(Runtime::kThrowStackOverflow); -+ __ bind(&stack_done); -+ -+ // Tail-call to the {code} handler. -+ __ Jump(code, RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_CallFunction(MacroAssembler* masm, -+ ConvertReceiverMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // ----------------------------------- -+ __ AssertFunction(a1); -+ -+ // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) -+ // Check that function is not a "classConstructor". -+ Label class_constructor; -+ __ Ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lwu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); -+ __ And(kScratchReg, a3, -+ Operand(SharedFunctionInfo::IsClassConstructorBit::kMask)); -+ __ Branch(&class_constructor, ne, kScratchReg, Operand(zero_reg)); -+ -+ // Enter the context of the function; ToObject has to run in the function -+ // context, and we also need to take the global proxy from the function -+ // context in case of conversion. -+ __ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ // We need to convert the receiver for non-native sloppy mode functions. -+ Label done_convert; -+ __ Lwu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); -+ __ And(kScratchReg, a3, -+ Operand(SharedFunctionInfo::IsNativeBit::kMask | -+ SharedFunctionInfo::IsStrictBit::kMask)); -+ __ Branch(&done_convert, ne, kScratchReg, Operand(zero_reg)); -+ { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // -- a2 : the shared function info. -+ // -- cp : the function context. -+ // ----------------------------------- -+ -+ if (mode == ConvertReceiverMode::kNullOrUndefined) { -+ // Patch receiver to global proxy. -+ __ LoadGlobalProxy(a3); -+ } else { -+ Label convert_to_object, convert_receiver; -+ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); -+ __ Ld(a3, MemOperand(kScratchReg)); -+ __ JumpIfSmi(a3, &convert_to_object); -+ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); -+ __ GetObjectType(a3, a4, a4); -+ __ Branch(&done_convert, Ugreater_equal, a4, -+ Operand(FIRST_JS_RECEIVER_TYPE)); -+ if (mode != ConvertReceiverMode::kNotNullOrUndefined) { -+ Label convert_global_proxy; -+ __ JumpIfRoot(a3, RootIndex::kUndefinedValue, &convert_global_proxy); -+ __ JumpIfNotRoot(a3, RootIndex::kNullValue, &convert_to_object); -+ __ bind(&convert_global_proxy); -+ { -+ // Patch receiver to global proxy. -+ __ LoadGlobalProxy(a3); -+ } -+ __ Branch(&convert_receiver); -+ } -+ __ bind(&convert_to_object); -+ { -+ // Convert receiver using ToObject. -+ // TODO(bmeurer): Inline the allocation here to avoid building the frame -+ // in the fast case? (fall back to AllocateInNewSpace?) -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ SmiTag(a0); -+ __ Push(a0, a1); -+ __ Move(a0, a3); -+ __ Push(cp); -+ __ Call(BUILTIN_CODE(masm->isolate(), ToObject), -+ RelocInfo::CODE_TARGET); -+ __ Pop(cp); -+ __ Move(a3, a0); -+ __ Pop(a0, a1); -+ __ SmiUntag(a0); -+ } -+ __ Ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ bind(&convert_receiver); -+ } -+ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); -+ __ Sd(a3, MemOperand(kScratchReg)); -+ } -+ __ bind(&done_convert); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSFunction) -+ // -- a2 : the shared function info. -+ // -- cp : the function context. -+ // ----------------------------------- -+ -+ __ Lhu(a2, -+ FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ InvokeFunctionCode(a1, no_reg, a2, a0, JUMP_FUNCTION); -+ -+ // The function is a "classConstructor", need to raise an exception. -+ __ bind(&class_constructor); -+ { -+ FrameScope frame(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowConstructorNonCallableError); -+ } -+} -+ -+// static -+void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // ----------------------------------- -+ __ AssertBoundFunction(a1); -+ -+ // Patch the receiver to [[BoundThis]]. -+ { -+ __ Ld(kScratchReg, FieldMemOperand(a1, JSBoundFunction::kBoundThisOffset)); -+ __ CalcScaledAddress(a4, sp, a0, kPointerSizeLog2); -+ __ Sd(kScratchReg, MemOperand(a4)); -+ } -+ -+ // Load [[BoundArguments]] into a2 and length of that into a4. -+ __ Ld(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) -+ // -- a4 : the number of [[BoundArguments]] -+ // ----------------------------------- -+ -+ // Reserve stack space for the [[BoundArguments]]. -+ { -+ Label done; -+ __ Sll64(a5, a4, kPointerSizeLog2); -+ __ Sub64(sp, sp, Operand(a5)); -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&done, Ugreater_equal, sp, Operand(kScratchReg)); -+ // Restore the stack pointer. -+ __ Add64(sp, sp, Operand(a5)); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ } -+ __ bind(&done); -+ } -+ -+ // Relocate arguments down the stack. -+ { -+ Label loop, done_loop; -+ __ Move(a5, zero_reg); -+ __ bind(&loop); -+ __ Branch(&done_loop, gt, a5, Operand(a0)); -+ __ CalcScaledAddress(a6, sp, a4, kPointerSizeLog2); -+ __ Ld(kScratchReg, MemOperand(a6)); -+ __ CalcScaledAddress(a6, sp, a5, kPointerSizeLog2); -+ __ Sd(kScratchReg, MemOperand(a6)); -+ __ Add64(a4, a4, Operand(1)); -+ __ Add64(a5, a5, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Copy [[BoundArguments]] to the stack (below the arguments). -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add64(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub64(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ CalcScaledAddress(a5, a2, a4, kPointerSizeLog2); -+ __ Ld(kScratchReg, MemOperand(a5)); -+ __ CalcScaledAddress(a5, sp, a0, kPointerSizeLog2); -+ __ Sd(kScratchReg, MemOperand(a5)); -+ __ Add64(a0, a0, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Call the [[BoundTargetFunction]] via the Call builtin. -+ __ Ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), Call_ReceiverIsAny), -+ RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the target to call (can be any Object). -+ // ----------------------------------- -+ -+ Label non_callable, non_smi; -+ __ JumpIfSmi(a1, &non_callable); -+ __ bind(&non_smi); -+ __ GetObjectType(a1, t1, t2); -+ __ Jump(masm->isolate()->builtins()->CallFunction(mode), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); -+ -+ // Check if target has a [[Call]] internal method. -+ __ Lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t1, t1, Operand(Map::Bits1::IsCallableBit::kMask)); -+ __ Branch(&non_callable, eq, t1, Operand(zero_reg)); -+ -+ __ Jump(BUILTIN_CODE(masm->isolate(), CallProxy), RelocInfo::CODE_TARGET, eq, -+ t2, Operand(JS_PROXY_TYPE)); -+ -+ // 2. Call to something else, which might have a [[Call]] internal method (if -+ // not we raise an exception). -+ // Overwrite the original receiver with the (original) target. -+ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); -+ __ Sd(a1, MemOperand(kScratchReg)); -+ // Let the "call_as_function_delegate" take care of the rest. -+ __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, a1); -+ __ Jump(masm->isolate()->builtins()->CallFunction( -+ ConvertReceiverMode::kNotNullOrUndefined), -+ RelocInfo::CODE_TARGET); -+ -+ // 3. Call to something that is not callable. -+ __ bind(&non_callable); -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ Push(a1); -+ __ CallRuntime(Runtime::kThrowCalledNonCallable); -+ } -+} -+ -+void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the constructor to call (checked to be a JSFunction) -+ // -- a3 : the new target (checked to be a constructor) -+ // ----------------------------------- -+ __ AssertConstructor(a1); -+ __ AssertFunction(a1); -+ -+ // Calling convention for function specific ConstructStubs require -+ // a2 to contain either an AllocationSite or undefined. -+ __ LoadRoot(a2, RootIndex::kUndefinedValue); -+ -+ Label call_generic_stub; -+ -+ // Jump to JSBuiltinsConstructStub or JSConstructStubGeneric. -+ __ Ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lwu(a4, FieldMemOperand(a4, SharedFunctionInfo::kFlagsOffset)); -+ __ And(a4, a4, Operand(SharedFunctionInfo::ConstructAsBuiltinBit::kMask)); -+ __ Branch(&call_generic_stub, eq, a4, Operand(zero_reg)); -+ -+ __ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub), -+ RelocInfo::CODE_TARGET); -+ -+ __ bind(&call_generic_stub); -+ __ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric), -+ RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a3 : the new target (checked to be a constructor) -+ // ----------------------------------- -+ __ AssertConstructor(a1); -+ __ AssertBoundFunction(a1); -+ -+ // Load [[BoundArguments]] into a2 and length of that into a4. -+ __ Ld(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the function to call (checked to be a JSBoundFunction) -+ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) -+ // -- a3 : the new target (checked to be a constructor) -+ // -- a4 : the number of [[BoundArguments]] -+ // ----------------------------------- -+ -+ // Reserve stack space for the [[BoundArguments]]. -+ { -+ Label done; -+ __ Sll64(a5, a4, kPointerSizeLog2); -+ __ Sub64(sp, sp, Operand(a5)); -+ // Check the stack for overflow. We are not trying to catch interruptions -+ // (i.e. debug break and preemption) here, so check the "real stack limit". -+ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); -+ __ Branch(&done, Ugreater_equal, sp, Operand(kScratchReg)); -+ // Restore the stack pointer. -+ __ Add64(sp, sp, Operand(a5)); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterFrame(StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ } -+ __ bind(&done); -+ } -+ -+ // Relocate arguments down the stack. -+ { -+ Label loop, done_loop; -+ __ Move(a5, zero_reg); -+ __ bind(&loop); -+ __ Branch(&done_loop, ge, a5, Operand(a0)); -+ __ CalcScaledAddress(a6, sp, a4, kPointerSizeLog2); -+ __ Ld(kScratchReg, MemOperand(a6)); -+ __ CalcScaledAddress(a6, sp, a5, kPointerSizeLog2); -+ __ Sd(kScratchReg, MemOperand(a6)); -+ __ Add64(a4, a4, Operand(1)); -+ __ Add64(a5, a5, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Copy [[BoundArguments]] to the stack (below the arguments). -+ { -+ Label loop, done_loop; -+ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); -+ __ Add64(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); -+ __ bind(&loop); -+ __ Sub64(a4, a4, Operand(1)); -+ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); -+ __ CalcScaledAddress(a5, a2, a4, kPointerSizeLog2); -+ __ Ld(kScratchReg, MemOperand(a5)); -+ __ CalcScaledAddress(a5, sp, a0, kPointerSizeLog2); -+ __ Sd(kScratchReg, MemOperand(a5)); -+ __ Add64(a0, a0, Operand(1)); -+ __ Branch(&loop); -+ __ bind(&done_loop); -+ } -+ -+ // Patch new.target to [[BoundTargetFunction]] if new.target equals target. -+ { -+ Label skip_load; -+ __ Branch(&skip_load, ne, a1, Operand(a3)); -+ __ Ld(a3, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ bind(&skip_load); -+ } -+ -+ // Construct the [[BoundTargetFunction]] via the Construct builtin. -+ __ Ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); -+} -+ -+// static -+void Builtins::Generate_Construct(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- a0 : the number of arguments (not including the receiver) -+ // -- a1 : the constructor to call (can be any Object) -+ // -- a3 : the new target (either the same as the constructor or -+ // the JSFunction on which new was invoked initially) -+ // ----------------------------------- -+ -+ // Check if target is a Smi. -+ Label non_constructor, non_proxy; -+ __ JumpIfSmi(a1, &non_constructor); -+ -+ // Check if target has a [[Construct]] internal method. -+ __ Ld(t1, FieldMemOperand(a1, HeapObject::kMapOffset)); -+ __ Lbu(t4, FieldMemOperand(t1, Map::kBitFieldOffset)); -+ __ And(t4, t4, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ __ Branch(&non_constructor, eq, t4, Operand(zero_reg)); -+ -+ // Dispatch based on instance type. -+ __ Lhu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); -+ -+ // Only dispatch to bound functions after checking whether they are -+ // constructors. -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructBoundFunction), -+ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); -+ -+ // Only dispatch to proxies after checking whether they are constructors. -+ __ Branch(&non_proxy, ne, t2, Operand(JS_PROXY_TYPE)); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy), -+ RelocInfo::CODE_TARGET); -+ -+ // Called Construct on an exotic Object with a [[Construct]] internal method. -+ __ bind(&non_proxy); -+ { -+ // Overwrite the original receiver with the (original) target. -+ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); -+ __ Sd(a1, MemOperand(kScratchReg)); -+ // Let the "call_as_constructor_delegate" take care of the rest. -+ __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); -+ __ Jump(masm->isolate()->builtins()->CallFunction(), -+ RelocInfo::CODE_TARGET); -+ } -+ -+ // Called Construct on an Object that doesn't have a [[Construct]] internal -+ // method. -+ __ bind(&non_constructor); -+ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructedNonConstructable), -+ RelocInfo::CODE_TARGET); -+} -+ -+void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { -+ // State setup as expected by MacroAssembler::InvokePrologue. -+ // ----------- S t a t e ------------- -+ // -- a0: actual arguments count -+ // -- a1: function (passed through to callee) -+ // -- a2: expected arguments count -+ // -- a3: new target (passed through to callee) -+ // ----------------------------------- -+ -+ Label invoke, dont_adapt_arguments, stack_overflow; -+ -+ Label enough, too_few; -+ __ Branch(&dont_adapt_arguments, eq, a2, -+ Operand(kDontAdaptArgumentsSentinel)); -+ // We use Uless as the number of argument should always be greater than 0. -+ __ Branch(&too_few, Uless, a0, Operand(a2)); -+ -+ { // Enough parameters: actual >= expected. -+ // a0: actual number of arguments as a smi -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ bind(&enough); -+ EnterArgumentsAdaptorFrame(masm); -+ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); -+ -+ // Calculate copy start address into a0 and copy end address into a4. -+ __ SmiScale(a0, a0, kPointerSizeLog2); -+ __ Add64(a0, fp, a0); -+ // Adjust for return address and receiver. -+ __ Add64(a0, a0, Operand(2 * kPointerSize)); -+ // Compute copy end address. -+ __ Sll64(a4, a2, kPointerSizeLog2); -+ __ Sub64(a4, a0, a4); -+ -+ // Copy the arguments (including the receiver) to the new stack frame. -+ // a0: copy start address -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ // a4: copy end address -+ -+ Label copy; -+ __ bind(©); -+ __ Ld(a5, MemOperand(a0)); -+ __ push(a5); -+ __ Add64(a0, a0, -kPointerSize); -+ __ Branch(©, ge, a0, Operand(a4)); -+ -+ __ Branch(&invoke); -+ } -+ -+ { // Too few parameters: Actual < expected. -+ __ bind(&too_few); -+ EnterArgumentsAdaptorFrame(masm); -+ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); -+ -+ // Calculate copy start address into a0 and copy end address into a7. -+ // a0: actual number of arguments as a smi -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ SmiScale(a0, a0, kPointerSizeLog2); -+ __ Add64(a0, fp, a0); -+ // Adjust for return address and receiver. -+ __ Add64(a0, a0, Operand(2 * kPointerSize)); -+ // Compute copy end address. Also adjust for return address. -+ __ Add64(a7, fp, kPointerSize); -+ -+ // Copy the arguments (including the receiver) to the new stack frame. -+ // a0: copy start address -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ // a7: copy end address -+ Label copy; -+ __ bind(©); -+ __ Ld(a4, MemOperand(a0)); // Adjusted above for return addr and receiver. -+ __ Sub64(sp, sp, kPointerSize); -+ __ Sub64(a0, a0, kPointerSize); -+ __ Sd(a4, MemOperand(sp)); -+ __ Branch(©, ne, a0, Operand(a7)); -+ -+ // Fill the remaining expected arguments with undefined. -+ // a1: function -+ // a2: expected number of arguments -+ // a3: new target (passed through to callee) -+ __ LoadRoot(a5, RootIndex::kUndefinedValue); -+ __ Sll64(a6, a2, kPointerSizeLog2); -+ __ Sub64(a4, fp, Operand(a6)); -+ // Adjust for frame. -+ __ Sub64(a4, a4, -+ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + -+ kPointerSize)); -+ -+ Label fill; -+ __ bind(&fill); -+ __ Sub64(sp, sp, kPointerSize); -+ __ Sd(a5, MemOperand(sp)); -+ __ Branch(&fill, ne, sp, Operand(a4)); -+ } -+ -+ // Call the entry point. -+ __ bind(&invoke); -+ __ Move(a0, a2); -+ // a0 : expected number of arguments -+ // a1 : function (passed through to callee) -+ // a3: new target (passed through to callee) -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Call(a2); -+ -+ // Store offset of return address for deoptimizer. -+ masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); -+ -+ // Exit frame and return. -+ LeaveArgumentsAdaptorFrame(masm); -+ __ Ret(); -+ -+ // ------------------------------------------- -+ // Don't adapt arguments. -+ // ------------------------------------------- -+ __ bind(&dont_adapt_arguments); -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); -+ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Jump(a2); -+ -+ __ bind(&stack_overflow); -+ { -+ FrameScope frame(masm, StackFrame::MANUAL); -+ __ CallRuntime(Runtime::kThrowStackOverflow); -+ __ break_(0xCC); -+ } -+} -+ -+void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { -+ // The function index was put in t0 by the jump table trampoline. -+ // Convert to Smi for the runtime call -+ __ SmiTag(kWasmCompileLazyFuncIndexRegister); -+ { -+ HardAbortScope hard_abort(masm); // Avoid calls to Abort. -+ FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); -+ -+ // Save all parameter registers (see kGpParamRegisters in wasm-linkage.cc). -+ // They might be overwritten in the runtime call below. We don't have any -+ // callee-saved registers in wasm, so no need to store anything else. -+ constexpr RegList gp_regs = Register::ListOf(a0, a2, a3, a4, a5, a6, a7); -+ constexpr RegList fp_regs = -+ DoubleRegister::ListOf(fa0, fa1, fa2, fa3, fa4, fa5, fa6); -+ static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs == -+ arraysize(wasm::kGpParamRegisters), -+ "frame size mismatch"); -+ static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs == -+ arraysize(wasm::kFpParamRegisters), -+ "frame size mismatch"); -+ __ MultiPush(gp_regs); -+ __ MultiPushFPU(fp_regs); -+ -+ // Pass instance and function index as an explicit arguments to the runtime -+ // function. -+ __ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister); -+ // Initialize the JavaScript context with 0. CEntry will use it to -+ // set the current context on the isolate. -+ __ Move(kContextRegister, Smi::zero()); -+ __ CallRuntime(Runtime::kWasmCompileLazy, 2); -+ -+ __ Move(s1, a0); // move return value to s1 since a0 will be restored to -+ // the value before the call -+ -+ // Restore registers. -+ __ MultiPopFPU(fp_regs); -+ __ MultiPop(gp_regs); -+ } -+ // Finally, jump to the entrypoint. -+ __ Jump(s1); -+} -+ -+void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) { -+ HardAbortScope hard_abort(masm); // Avoid calls to Abort. -+ { -+ FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK); -+ -+ // Save all parameter registers. They might hold live values, we restore -+ // them after the runtime call. -+ __ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs); -+ __ MultiPushFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); -+ -+ // Initialize the JavaScript context with 0. CEntry will use it to -+ // set the current context on the isolate. -+ __ Move(cp, Smi::zero()); -+ __ CallRuntime(Runtime::kWasmDebugBreak, 0); -+ -+ // Restore registers. -+ __ MultiPopFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); -+ __ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs); -+ } -+ __ Ret(); -+} -+ -+void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, -+ SaveFPRegsMode save_doubles, ArgvMode argv_mode, -+ bool builtin_exit_frame) { -+ // Called from JavaScript; parameters are on stack as if calling JS function -+ // a0: number of arguments including receiver -+ // a1: pointer to builtin function -+ // fp: frame pointer (restored after C call) -+ // sp: stack pointer (restored as callee's sp after C call) -+ // cp: current context (C callee-saved) -+ // -+ // If argv_mode == kArgvInRegister: -+ // a2: pointer to the first argument -+ -+ if (argv_mode == kArgvInRegister) { -+ // Move argv into the correct register. -+ __ Move(s1, a2); -+ } else { -+ // Compute the argv pointer in a callee-saved register. -+ __ CalcScaledAddress(s1, sp, a0, kPointerSizeLog2); -+ __ Sub64(s1, s1, kPointerSize); -+ } -+ -+ // Enter the exit frame that transitions from JavaScript to C++. -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame( -+ save_doubles == kSaveFPRegs, 0, -+ builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT); -+ -+ // s3: number of arguments including receiver (C callee-saved) -+ // s1: pointer to first argument (C callee-saved) -+ // s2: pointer to builtin function (C callee-saved) -+ -+ // Prepare arguments for C routine. -+ // a0 = argc -+ __ Move(s3, a0); -+ __ Move(s2, a1); -+ -+ // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We -+ // also need to reserve the 4 argument slots on the stack. -+ -+ __ AssertStackIsAligned(); -+ -+ // a0 = argc, a1 = argv, a2 = isolate -+ __ li(a2, ExternalReference::isolate_address(masm->isolate())); -+ __ Move(a1, s1); -+ -+ __ StoreReturnAddressAndCall(s2); -+ -+ // Result returned in a0 or a1:a0 - do not destroy these registers! -+ -+ // Check result for exception sentinel. -+ Label exception_returned; -+ __ LoadRoot(a4, RootIndex::kException); -+ __ Branch(&exception_returned, eq, a4, Operand(a0)); -+ -+ // Check that there is no pending exception, otherwise we -+ // should have returned the exception sentinel. -+ if (FLAG_debug_code) { -+ Label okay; -+ ExternalReference pending_exception_address = ExternalReference::Create( -+ IsolateAddressId::kPendingExceptionAddress, masm->isolate()); -+ __ li(a2, pending_exception_address); -+ __ Ld(a2, MemOperand(a2)); -+ __ LoadRoot(a4, RootIndex::kTheHoleValue); -+ // Cannot use check here as it attempts to generate call into runtime. -+ __ Branch(&okay, eq, a4, Operand(a2)); -+ __ stop(); -+ __ bind(&okay); -+ } -+ -+ // Exit C frame and return. -+ // a0:a1: result -+ // sp: stack pointer -+ // fp: frame pointer -+ Register argc = argv_mode == kArgvInRegister -+ // We don't want to pop arguments so set argc to no_reg. -+ ? no_reg -+ // s3: still holds argc (callee-saved). -+ : s3; -+ __ LeaveExitFrame(save_doubles == kSaveFPRegs, argc, EMIT_RETURN); -+ -+ // Handling of exception. -+ __ bind(&exception_returned); -+ -+ ExternalReference pending_handler_context_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerContextAddress, masm->isolate()); -+ ExternalReference pending_handler_entrypoint_address = -+ ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate()); -+ ExternalReference pending_handler_fp_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerFPAddress, masm->isolate()); -+ ExternalReference pending_handler_sp_address = ExternalReference::Create( -+ IsolateAddressId::kPendingHandlerSPAddress, masm->isolate()); -+ -+ // Ask the runtime for help to determine the handler. This will set a0 to -+ // contain the current pending exception, don't clobber it. -+ ExternalReference find_handler = -+ ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler); -+ { -+ FrameScope scope(masm, StackFrame::MANUAL); -+ __ PrepareCallCFunction(3, 0, a0); -+ __ Move(a0, zero_reg); -+ __ Move(a1, zero_reg); -+ __ li(a2, ExternalReference::isolate_address(masm->isolate())); -+ __ CallCFunction(find_handler, 3); -+ } -+ -+ // Retrieve the handler context, SP and FP. -+ __ li(cp, pending_handler_context_address); -+ __ Ld(cp, MemOperand(cp)); -+ __ li(sp, pending_handler_sp_address); -+ __ Ld(sp, MemOperand(sp)); -+ __ li(fp, pending_handler_fp_address); -+ __ Ld(fp, MemOperand(fp)); -+ -+ // If the handler is a JS frame, restore the context to the frame. Note that -+ // the context will be set to (cp == 0) for non-JS frames. -+ Label zero; -+ __ Branch(&zero, eq, cp, Operand(zero_reg)); -+ __ Sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); -+ __ bind(&zero); -+ -+ // Reset the masking register. This is done independent of the underlying -+ // feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work -+ // with both configurations. It is safe to always do this, because the -+ // underlying register is caller-saved and can be arbitrarily clobbered. -+ __ ResetSpeculationPoisonRegister(); -+ -+ // Compute the handler entry address and jump to it. -+ __ li(t6, pending_handler_entrypoint_address); -+ __ Ld(t6, MemOperand(t6)); -+ __ Jump(t6); -+} -+ -+void Builtins::Generate_DoubleToI(MacroAssembler* masm) { -+ Label done; -+ Register result_reg = t0; -+ -+ Register scratch = GetRegisterThatIsNotOneOf(result_reg); -+ Register scratch2 = GetRegisterThatIsNotOneOf(result_reg, scratch); -+ Register scratch3 = GetRegisterThatIsNotOneOf(result_reg, scratch, scratch2); -+ DoubleRegister double_scratch = kScratchDoubleReg; -+ -+ // Account for saved regs. -+ const int kArgumentOffset = 4 * kPointerSize; -+ -+ __ Push(result_reg); -+ __ Push(scratch, scratch2, scratch3); -+ -+ // Load double input. -+ __ LoadDouble(double_scratch, MemOperand(sp, kArgumentOffset)); -+ -+ // Try a conversion to a signed integer, if exception occurs, scratch is -+ // set to 0 -+ __ Trunc_w_d(scratch3, double_scratch, scratch); -+ -+ // If we had no exceptions then set result_reg and we are done. -+ Label error; -+ __ Branch(&error, eq, scratch, Operand(zero_reg)); -+ __ Move(result_reg, scratch3); -+ __ Branch(&done); -+ __ bind(&error); -+ -+ // Load the double value and perform a manual truncation. -+ Register input_high = scratch2; -+ Register input_low = scratch3; -+ -+ __ Lw(input_low, MemOperand(sp, kArgumentOffset + Register::kMantissaOffset)); -+ __ Lw(input_high, -+ MemOperand(sp, kArgumentOffset + Register::kExponentOffset)); -+ -+ Label normal_exponent; -+ // Extract the biased exponent in result. -+ __ ExtractBits(result_reg, input_high, HeapNumber::kExponentShift, -+ HeapNumber::kExponentBits); -+ -+ // Check for Infinity and NaNs, which should return 0. -+ __ Sub32(scratch, result_reg, HeapNumber::kExponentMask); -+ __ LoadZeroIfConditionZero( -+ result_reg, -+ scratch); // result_reg = scratch == 0 ? 0 : result_reg -+ __ Branch(&done, eq, scratch, Operand(zero_reg)); -+ -+ // Express exponent as delta to (number of mantissa bits + 31). -+ __ Sub32(result_reg, result_reg, -+ Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits + 31)); -+ -+ // If the delta is strictly positive, all bits would be shifted away, -+ // which means that we can return 0. -+ __ Branch(&normal_exponent, le, result_reg, Operand(zero_reg)); -+ __ Move(result_reg, zero_reg); -+ __ Branch(&done); -+ -+ __ bind(&normal_exponent); -+ const int kShiftBase = HeapNumber::kNonMantissaBitsInTopWord - 1; -+ // Calculate shift. -+ __ Add32(scratch, result_reg, -+ Operand(kShiftBase + HeapNumber::kMantissaBits)); -+ -+ // Save the sign. -+ Register sign = result_reg; -+ result_reg = no_reg; -+ __ And(sign, input_high, Operand(HeapNumber::kSignMask)); -+ -+ // We must specially handle shifts greater than 31. -+ Label high_shift_needed, high_shift_done; -+ __ Branch(&high_shift_needed, lt, scratch, Operand(32)); -+ __ Move(input_high, zero_reg); -+ __ Branch(&high_shift_done); -+ __ bind(&high_shift_needed); -+ -+ // Set the implicit 1 before the mantissa part in input_high. -+ __ Or(input_high, input_high, -+ Operand(1 << HeapNumber::kMantissaBitsInTopWord)); -+ // Shift the mantissa bits to the correct position. -+ // We don't need to clear non-mantissa bits as they will be shifted away. -+ // If they weren't, it would mean that the answer is in the 32bit range. -+ __ Sll32(input_high, input_high, scratch); -+ -+ __ bind(&high_shift_done); -+ -+ // Replace the shifted bits with bits from the lower mantissa word. -+ Label pos_shift, shift_done, sign_negative; -+ __ li(kScratchReg, 32); -+ __ subw(scratch, kScratchReg, scratch); -+ __ Branch(&pos_shift, ge, scratch, Operand(zero_reg)); -+ -+ // Negate scratch. -+ __ Sub32(scratch, zero_reg, scratch); -+ __ Sll32(input_low, input_low, scratch); -+ __ Branch(&shift_done); -+ -+ __ bind(&pos_shift); -+ __ srlw(input_low, input_low, scratch); -+ -+ __ bind(&shift_done); -+ __ Or(input_high, input_high, Operand(input_low)); -+ // Restore sign if necessary. -+ __ Move(scratch, sign); -+ result_reg = sign; -+ sign = no_reg; -+ __ Sub32(result_reg, zero_reg, input_high); -+ __ Branch(&sign_negative, ne, scratch, Operand(zero_reg)); -+ __ Move(result_reg, input_high); -+ __ bind(&sign_negative); -+ -+ __ bind(&done); -+ -+ __ Sd(result_reg, MemOperand(sp, kArgumentOffset)); -+ __ Pop(scratch, scratch2, scratch3); -+ __ Pop(result_reg); -+ __ Ret(); -+} -+ -+void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) { -+ // TODO(v8:10701): Implement for this platform. -+ __ Trap(); -+} -+ -+namespace { -+ -+int AddressOffset(ExternalReference ref0, ExternalReference ref1) { -+ int64_t offset = (ref0.address() - ref1.address()); -+ DCHECK(static_cast(offset) == offset); -+ return static_cast(offset); -+} -+ -+// Calls an API function. Allocates HandleScope, extracts returned value -+// from handle and propagates exceptions. Restores context. stack_space -+// - space to be unwound on exit (includes the call JS arguments space and -+// the additional space allocated for the fast call). -+void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address, -+ ExternalReference thunk_ref, int stack_space, -+ MemOperand* stack_space_operand, -+ MemOperand return_value_operand) { -+ Isolate* isolate = masm->isolate(); -+ ExternalReference next_address = -+ ExternalReference::handle_scope_next_address(isolate); -+ const int kNextOffset = 0; -+ const int kLimitOffset = AddressOffset( -+ ExternalReference::handle_scope_limit_address(isolate), next_address); -+ const int kLevelOffset = AddressOffset( -+ ExternalReference::handle_scope_level_address(isolate), next_address); -+ -+ DCHECK(function_address == a1 || function_address == a2); -+ -+ Label profiler_enabled, end_profiler_check; -+ __ li(t6, ExternalReference::is_profiling_address(isolate)); -+ __ Lb(t6, MemOperand(t6, 0)); -+ __ Branch(&profiler_enabled, ne, t6, Operand(zero_reg)); -+ __ li(t6, ExternalReference::address_of_runtime_stats_flag()); -+ __ Lw(t6, MemOperand(t6, 0)); -+ __ Branch(&profiler_enabled, ne, t6, Operand(zero_reg)); -+ { -+ // Call the api function directly. -+ __ Move(t6, function_address); -+ __ Branch(&end_profiler_check); -+ } -+ -+ __ bind(&profiler_enabled); -+ { -+ // Additional parameter is the address of the actual callback. -+ __ li(t6, thunk_ref); -+ } -+ __ bind(&end_profiler_check); -+ -+ // Allocate HandleScope in callee-save registers. -+ __ li(s5, next_address); -+ __ Ld(s3, MemOperand(s5, kNextOffset)); -+ __ Ld(s1, MemOperand(s5, kLimitOffset)); -+ __ Lw(s2, MemOperand(s5, kLevelOffset)); -+ __ Add32(s2, s2, Operand(1)); -+ __ Sw(s2, MemOperand(s5, kLevelOffset)); -+ -+ __ StoreReturnAddressAndCall(t6); -+ -+ Label promote_scheduled_exception; -+ Label delete_allocated_handles; -+ Label leave_exit_frame; -+ Label return_value_loaded; -+ -+ // Load value from ReturnValue. -+ __ Ld(a0, return_value_operand); -+ __ bind(&return_value_loaded); -+ -+ // No more valid handles (the result handle was the last one). Restore -+ // previous handle scope. -+ __ Sd(s3, MemOperand(s5, kNextOffset)); -+ if (__ emit_debug_code()) { -+ __ Lw(a1, MemOperand(s5, kLevelOffset)); -+ __ Check(eq, AbortReason::kUnexpectedLevelAfterReturnFromApiCall, a1, -+ Operand(s2)); -+ } -+ __ Sub32(s2, s2, Operand(1)); -+ __ Sw(s2, MemOperand(s5, kLevelOffset)); -+ __ Ld(kScratchReg, MemOperand(s5, kLimitOffset)); -+ __ Branch(&delete_allocated_handles, ne, s1, Operand(kScratchReg)); -+ -+ // Leave the API exit frame. -+ __ bind(&leave_exit_frame); -+ -+ if (stack_space_operand == nullptr) { -+ DCHECK_NE(stack_space, 0); -+ __ li(s3, Operand(stack_space)); -+ } else { -+ DCHECK_EQ(stack_space, 0); -+ STATIC_ASSERT(kCArgSlotCount == 0); -+ __ Ld(s3, *stack_space_operand); -+ } -+ -+ static constexpr bool kDontSaveDoubles = false; -+ static constexpr bool kRegisterContainsSlotCount = false; -+ __ LeaveExitFrame(kDontSaveDoubles, s3, NO_EMIT_RETURN, -+ kRegisterContainsSlotCount); -+ -+ // Check if the function scheduled an exception. -+ __ LoadRoot(a4, RootIndex::kTheHoleValue); -+ __ li(kScratchReg, ExternalReference::scheduled_exception_address(isolate)); -+ __ Ld(a5, MemOperand(kScratchReg)); -+ __ Branch(&promote_scheduled_exception, ne, a4, Operand(a5)); -+ -+ __ Ret(); -+ -+ // Re-throw by promoting a scheduled exception. -+ __ bind(&promote_scheduled_exception); -+ __ TailCallRuntime(Runtime::kPromoteScheduledException); -+ -+ // HandleScope limit has changed. Delete allocated extensions. -+ __ bind(&delete_allocated_handles); -+ __ Sd(s1, MemOperand(s5, kLimitOffset)); -+ __ Move(s3, a0); -+ __ PrepareCallCFunction(1, s1); -+ __ li(a0, ExternalReference::isolate_address(isolate)); -+ __ CallCFunction(ExternalReference::delete_handle_scope_extensions(), 1); -+ __ Move(a0, s3); -+ __ Branch(&leave_exit_frame); -+} -+ -+} // namespace -+ -+void Builtins::Generate_CallApiCallback(MacroAssembler* masm) { -+ // ----------- S t a t e ------------- -+ // -- cp : context -+ // -- a1 : api function address -+ // -- a2 : arguments count (not including the receiver) -+ // -- a3 : call data -+ // -- a0 : holder -+ // -- -+ // -- sp[0] : last argument -+ // -- ... -+ // -- sp[(argc - 1) * 8] : first argument -+ // -- sp[(argc + 0) * 8] : receiver -+ // ----------------------------------- -+ -+ Register api_function_address = a1; -+ Register argc = a2; -+ Register call_data = a3; -+ Register holder = a0; -+ Register scratch = t0; -+ Register base = t1; // For addressing MemOperands on the stack. -+ -+ DCHECK(!AreAliased(api_function_address, argc, call_data, holder, scratch, -+ base)); -+ -+ using FCA = FunctionCallbackArguments; -+ -+ STATIC_ASSERT(FCA::kArgsLength == 6); -+ STATIC_ASSERT(FCA::kNewTargetIndex == 5); -+ STATIC_ASSERT(FCA::kDataIndex == 4); -+ STATIC_ASSERT(FCA::kReturnValueOffset == 3); -+ STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); -+ STATIC_ASSERT(FCA::kIsolateIndex == 1); -+ STATIC_ASSERT(FCA::kHolderIndex == 0); -+ -+ // Set up FunctionCallbackInfo's implicit_args on the stack as follows: -+ // -+ // Target state: -+ // sp[0 * kPointerSize]: kHolder -+ // sp[1 * kPointerSize]: kIsolate -+ // sp[2 * kPointerSize]: undefined (kReturnValueDefaultValue) -+ // sp[3 * kPointerSize]: undefined (kReturnValue) -+ // sp[4 * kPointerSize]: kData -+ // sp[5 * kPointerSize]: undefined (kNewTarget) -+ -+ // Set up the base register for addressing through MemOperands. It will point -+ // at the receiver (located at sp + argc * kPointerSize). -+ __ CalcScaledAddress(base, sp, argc, kPointerSizeLog2); -+ -+ // Reserve space on the stack. -+ __ Sub64(sp, sp, Operand(FCA::kArgsLength * kPointerSize)); -+ -+ // kHolder. -+ __ Sd(holder, MemOperand(sp, 0 * kPointerSize)); -+ -+ // kIsolate. -+ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); -+ __ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); -+ -+ // kReturnValueDefaultValue and kReturnValue. -+ __ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ __ Sd(scratch, MemOperand(sp, 2 * kPointerSize)); -+ __ Sd(scratch, MemOperand(sp, 3 * kPointerSize)); -+ -+ // kData. -+ __ Sd(call_data, MemOperand(sp, 4 * kPointerSize)); -+ -+ // kNewTarget. -+ __ Sd(scratch, MemOperand(sp, 5 * kPointerSize)); -+ -+ // Keep a pointer to kHolder (= implicit_args) in a scratch register. -+ // We use it below to set up the FunctionCallbackInfo object. -+ __ Move(scratch, sp); -+ -+ // Allocate the v8::Arguments structure in the arguments' space since -+ // it's not controlled by GC. -+ static constexpr int kApiStackSpace = 4; -+ static constexpr bool kDontSaveDoubles = false; -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame(kDontSaveDoubles, kApiStackSpace); -+ -+ // EnterExitFrame may align the sp. -+ -+ // FunctionCallbackInfo::implicit_args_ (points at kHolder as set up above). -+ // Arguments are after the return address (pushed by EnterExitFrame()). -+ __ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); -+ -+ // FunctionCallbackInfo::values_ (points at the first varargs argument passed -+ // on the stack). -+ __ Sub64(scratch, base, Operand(1 * kPointerSize)); -+ __ Sd(scratch, MemOperand(sp, 2 * kPointerSize)); -+ -+ // FunctionCallbackInfo::length_. -+ // Stored as int field, 32-bit integers within struct on stack always left -+ // justified by n64 ABI. -+ __ Sw(argc, MemOperand(sp, 3 * kPointerSize)); -+ -+ // We also store the number of bytes to drop from the stack after returning -+ // from the API function here. -+ // Note: Unlike on other architectures, this stores the number of slots to -+ // drop, not the number of bytes. -+ __ Add64(scratch, argc, Operand(FCA::kArgsLength + 1 /* receiver */)); -+ __ Sd(scratch, MemOperand(sp, 4 * kPointerSize)); -+ -+ // v8::InvocationCallback's argument. -+ DCHECK(!AreAliased(api_function_address, scratch, a0)); -+ __ Add64(a0, sp, Operand(1 * kPointerSize)); -+ -+ ExternalReference thunk_ref = ExternalReference::invoke_function_callback(); -+ -+ // There are two stack slots above the arguments we constructed on the stack. -+ // TODO(jgruber): Document what these arguments are. -+ static constexpr int kStackSlotsAboveFCA = 2; -+ MemOperand return_value_operand( -+ fp, (kStackSlotsAboveFCA + FCA::kReturnValueOffset) * kPointerSize); -+ -+ static constexpr int kUseStackSpaceOperand = 0; -+ MemOperand stack_space_operand(sp, 4 * kPointerSize); -+ -+ AllowExternalCallThatCantCauseGC scope(masm); -+ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, -+ kUseStackSpaceOperand, &stack_space_operand, -+ return_value_operand); -+} -+ -+void Builtins::Generate_CallApiGetter(MacroAssembler* masm) { -+ // Build v8::PropertyCallbackInfo::args_ array on the stack and push property -+ // name below the exit frame to make GC aware of them. -+ STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); -+ STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); -+ STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); -+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); -+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); -+ STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); -+ STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); -+ STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); -+ -+ Register receiver = ApiGetterDescriptor::ReceiverRegister(); -+ Register holder = ApiGetterDescriptor::HolderRegister(); -+ Register callback = ApiGetterDescriptor::CallbackRegister(); -+ Register scratch = a4; -+ DCHECK(!AreAliased(receiver, holder, callback, scratch)); -+ -+ Register api_function_address = a2; -+ -+ // Here and below +1 is for name() pushed after the args_ array. -+ using PCA = PropertyCallbackArguments; -+ __ Sub64(sp, sp, (PCA::kArgsLength + 1) * kPointerSize); -+ __ Sd(receiver, MemOperand(sp, (PCA::kThisIndex + 1) * kPointerSize)); -+ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kDataOffset)); -+ __ Sd(scratch, MemOperand(sp, (PCA::kDataIndex + 1) * kPointerSize)); -+ __ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ __ Sd(scratch, MemOperand(sp, (PCA::kReturnValueOffset + 1) * kPointerSize)); -+ __ Sd(scratch, MemOperand(sp, (PCA::kReturnValueDefaultValueIndex + 1) * -+ kPointerSize)); -+ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); -+ __ Sd(scratch, MemOperand(sp, (PCA::kIsolateIndex + 1) * kPointerSize)); -+ __ Sd(holder, MemOperand(sp, (PCA::kHolderIndex + 1) * kPointerSize)); -+ // should_throw_on_error -> false -+ DCHECK_EQ(0, Smi::zero().ptr()); -+ __ Sd(zero_reg, -+ MemOperand(sp, (PCA::kShouldThrowOnErrorIndex + 1) * kPointerSize)); -+ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kNameOffset)); -+ __ Sd(scratch, MemOperand(sp, 0 * kPointerSize)); -+ -+ // v8::PropertyCallbackInfo::args_ array and name handle. -+ const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; -+ -+ // Load address of v8::PropertyAccessorInfo::args_ array and name handle. -+ __ Move(a0, sp); // a0 = Handle -+ __ Add64(a1, a0, Operand(1 * kPointerSize)); // a1 = v8::PCI::args_ -+ -+ const int kApiStackSpace = 1; -+ FrameScope frame_scope(masm, StackFrame::MANUAL); -+ __ EnterExitFrame(false, kApiStackSpace); -+ -+ // Create v8::PropertyCallbackInfo object on the stack and initialize -+ // it's args_ field. -+ __ Sd(a1, MemOperand(sp, 1 * kPointerSize)); -+ __ Add64(a1, sp, Operand(1 * kPointerSize)); -+ // a1 = v8::PropertyCallbackInfo& -+ -+ ExternalReference thunk_ref = -+ ExternalReference::invoke_accessor_getter_callback(); -+ -+ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kJsGetterOffset)); -+ __ Ld(api_function_address, -+ FieldMemOperand(scratch, Foreign::kForeignAddressOffset)); -+ -+ // +3 is to skip prolog, return address and name handle. -+ MemOperand return_value_operand( -+ fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); -+ MemOperand* const kUseStackSpaceConstant = nullptr; -+ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, -+ kStackUnwindSpace, kUseStackSpaceConstant, -+ return_value_operand); -+} -+ -+void Builtins::Generate_DirectCEntry(MacroAssembler* masm) { -+ // The sole purpose of DirectCEntry is for movable callers (e.g. any general -+ // purpose Code object) to be able to call into C functions that may trigger -+ // GC and thus move the caller. -+ // -+ // DirectCEntry places the return address on the stack (updated by the GC), -+ // making the call GC safe. The irregexp backend relies on this. -+ -+ // Make place for arguments to fit C calling convention. Callers use -+ // EnterExitFrame/LeaveExitFrame so they handle stack restoring and we don't -+ // have to do that here. Any caller must drop kCArgsSlotsSize stack space -+ // after the call. -+ __ Add64(sp, sp, -kCArgsSlotsSize); -+ -+ __ Sd(ra, MemOperand(sp, kCArgsSlotsSize)); // Store the return address. -+ __ Call(t6); // Call the C++ function. -+ __ Ld(t6, MemOperand(sp, kCArgsSlotsSize)); // Return to calling code. -+ -+ if (FLAG_debug_code && FLAG_enable_slow_asserts) { -+ // In case of an error the return address may point to a memory area -+ // filled with kZapValue by the GC. Dereference the address and check for -+ // this. -+ __ Uld(a4, MemOperand(t6)); -+ __ Assert(ne, AbortReason::kReceivedInvalidReturnAddress, a4, -+ Operand(reinterpret_cast(kZapValue))); -+ } -+ -+ __ Jump(t6); -+} -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- a/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h -@@ -23,6 +23,10 @@ - #include "src/codegen/mips64/assembler-mips64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/assembler-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/codegen/riscv64/assembler-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/codegen/riscv/assembler-riscv.h" - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h -+++ b/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h -@@ -23,6 +23,10 @@ - #include "src/codegen/mips64/assembler-mips64-inl.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/assembler-s390-inl.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/codegen/riscv64/assembler-riscv64-inl.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/codegen/riscv/assembler-riscv-inl.h" - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/constants-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/constants-arch.h -@@ -21,6 +21,10 @@ - #include "src/codegen/s390/constants-s390.h" // NOLINT - #elif V8_TARGET_ARCH_X64 - #include "src/codegen/x64/constants-x64.h" // NOLINT -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/codegen/riscv64/constants-riscv64.h" // NOLINT -+#elif V8_TARGET_ARCH_RISCV -+#include "src/codegen/riscv64/constants-riscv.h" // NOLINT - #else - #error Unsupported target architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/cpu-features.h -+++ b/src/3rdparty/chromium/v8/src/codegen/cpu-features.h -@@ -67,6 +67,12 @@ - VECTOR_ENHANCE_FACILITY_1, - VECTOR_ENHANCE_FACILITY_2, - MISC_INSTR_EXT2, -+ -+// FIXME (RISCV): add features for RISCV -+#elif V8_TARGET_ARCH_RISCV64 -+ FPU, -+ FP64FPU, -+ RISCV_SIMD, - #endif - - NUMBER_OF_CPU_FEATURES ---- a/src/3rdparty/chromium/v8/src/codegen/external-reference.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/external-reference.cc -@@ -502,6 +502,8 @@ - #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState - #elif V8_TARGET_ARCH_S390 - #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+#define re_stack_check_func RegExpMacroAssemblerRISCV::CheckStackGuardState - #else - UNREACHABLE(); - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc -@@ -397,7 +397,9 @@ - } - #endif // !V8_TARGET_ARCH_IA32 - --#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) -+// FIXME(RISCV): Review this once atomics are added -+#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ -+ !defined(V8_TARGET_ARCH_RISCV64) && !defined(V8_TARGET_ARCH_RISCV) - void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( - CallInterfaceDescriptorData* data) { - DefaultInitializePlatformSpecific(data, kParameterCount); ---- a/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h -+++ b/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h -@@ -52,6 +52,12 @@ - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/constants-s390.h" - #include "src/codegen/s390/macro-assembler-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/codegen/riscv64/macro-assembler-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/codegen/riscv/constants-riscv.h" -+#include "src/codegen/riscv/macro-assembler-riscv.h" - #else - #error Unsupported target architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/register-arch.h -+++ b/src/3rdparty/chromium/v8/src/codegen/register-arch.h -@@ -24,6 +24,10 @@ - #include "src/codegen/mips64/register-mips64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/codegen/s390/register-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/codegen/riscv64/register-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/codegen/riscv/register-riscv.h" - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc -@@ -64,6 +64,8 @@ - kMaxAllocatableDoubleRegisterCount; - #elif V8_TARGET_ARCH_S390 - kMaxAllocatableDoubleRegisterCount; -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ kMaxAllocatableDoubleRegisterCount; - #else - #error Unsupported target architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc -+++ b/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc -@@ -330,7 +330,8 @@ - return false; - #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \ - defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) || \ -- defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) -+ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) || \ -+ defined(V8_TARGET_ARCH_RISCV64) || defined(V8_TARGET_ARCH_RISCV) - return true; - #endif - } ---- a/src/3rdparty/chromium/v8/src/codegen/reloc-info.h -+++ b/src/3rdparty/chromium/v8/src/codegen/reloc-info.h -@@ -69,7 +69,7 @@ - EXTERNAL_REFERENCE, // The address of an external C++ function. - INTERNAL_REFERENCE, // An address inside the same function. - -- // Encoded internal reference, used only on MIPS, MIPS64 and PPC. -+ // Encoded internal reference, used only on RISCV64, MIPS, MIPS64 and PPC. - INTERNAL_REFERENCE_ENCODED, - - // An off-heap instruction stream target. See http://goo.gl/Z2HUiM. ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64-inl.h -@@ -0,0 +1,247 @@ -+ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#ifndef V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ -+#define V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/riscv64/assembler-riscv64.h" -+#include "src/debug/debug.h" -+#include "src/objects/objects-inl.h" -+ -+namespace v8 { -+namespace internal { -+ -+bool CpuFeatures::SupportsOptimizer() { return IsSupported(FPU); } -+ -+bool CpuFeatures::SupportsWasmSimd128() { return IsSupported(RISCV_SIMD); } -+ -+// ----------------------------------------------------------------------------- -+// Operand and MemOperand. -+ -+bool Operand::is_reg() const { return rm_.is_valid(); } -+ -+int64_t Operand::immediate() const { -+ DCHECK(!is_reg()); -+ DCHECK(!IsHeapObjectRequest()); -+ return value_.immediate; -+} -+ -+// ----------------------------------------------------------------------------- -+// RelocInfo. -+ -+void RelocInfo::apply(intptr_t delta) { -+ if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { -+ // Absolute code pointer inside code object moves with the code object. -+ Assembler::RelocateInternalReference(rmode_, pc_, delta); -+ } -+} -+ -+Address RelocInfo::target_address() { -+ DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+Address RelocInfo::target_address_address() { -+ DCHECK(HasTargetAddressAddress()); -+ // Read the address of the word containing the target_address in an -+ // instruction stream. -+ // The only architecture-independent user of this function is the serializer. -+ // The serializer uses it to find out how many raw bytes of instruction to -+ // output before the next target. -+ // For an instruction like LUI/ORI where the target bits are mixed into the -+ // instruction bits, the size of the target will be zero, indicating that the -+ // serializer should not step forward in memory after a target is resolved -+ // and written. In this case the target_address_address function should -+ // return the end of the instructions to be patched, allowing the -+ // deserializer to deserialize the instructions as raw bytes and put them in -+ // place, ready to be patched with the target. After jump optimization, -+ // that is the address of the instruction that follows J/JAL/JR/JALR -+ // instruction. -+ return pc_ + Assembler::kInstructionsFor64BitConstant * kInstrSize; -+} -+ -+Address RelocInfo::constant_pool_entry_address() { UNREACHABLE(); } -+ -+int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } -+ -+void Assembler::deserialization_set_special_target_at( -+ Address instruction_payload, Code code, Address target) { -+ set_target_address_at(instruction_payload, -+ !code.is_null() ? code.constant_pool() : kNullAddress, -+ target); -+} -+ -+int Assembler::deserialization_special_target_size( -+ Address instruction_payload) { -+ return kSpecialTargetSize; -+} -+ -+void Assembler::set_target_internal_reference_encoded_at(Address pc, -+ Address target) { -+ set_target_value_at(pc, static_cast(target)); -+} -+ -+void Assembler::deserialization_set_target_internal_reference_at( -+ Address pc, Address target, RelocInfo::Mode mode) { -+ if (RelocInfo::IsInternalReferenceEncoded(mode)) { -+ DCHECK(IsLui(instr_at(pc))); -+ set_target_internal_reference_encoded_at(pc, target); -+ } else { -+ DCHECK(RelocInfo::IsInternalReference(mode)); -+ Memory
(pc) = target; -+ } -+} -+ -+HeapObject RelocInfo::target_object() { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ return HeapObject::cast( -+ Object(Assembler::target_address_at(pc_, constant_pool_))); -+} -+ -+HeapObject RelocInfo::target_object_no_host(Isolate* isolate) { -+ return target_object(); -+} -+ -+Handle RelocInfo::target_object_handle(Assembler* origin) { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ return Handle(reinterpret_cast( -+ Assembler::target_address_at(pc_, constant_pool_))); -+} -+ -+void RelocInfo::set_target_object(Heap* heap, HeapObject target, -+ WriteBarrierMode write_barrier_mode, -+ ICacheFlushMode icache_flush_mode) { -+ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); -+ Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(), -+ icache_flush_mode); -+ if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null() && -+ !FLAG_disable_write_barriers) { -+ WriteBarrierForCode(host(), this, target); -+ } -+} -+ -+Address RelocInfo::target_external_reference() { -+ DCHECK(rmode_ == EXTERNAL_REFERENCE); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+void RelocInfo::set_target_external_reference( -+ Address target, ICacheFlushMode icache_flush_mode) { -+ DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); -+ Assembler::set_target_address_at(pc_, constant_pool_, target, -+ icache_flush_mode); -+} -+ -+Address RelocInfo::target_internal_reference() { -+ if (rmode_ == INTERNAL_REFERENCE) { -+ return Memory
(pc_); -+ } else { -+ // Encoded internal references are j/jal instructions. -+ DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); -+ DCHECK(Assembler::IsLui(Assembler::instr_at(pc_ + 0 * kInstrSize))); -+ Address address = Assembler::target_address_at(pc_); -+ return address; -+ } -+} -+ -+Address RelocInfo::target_internal_reference_address() { -+ DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); -+ return pc_; -+} -+ -+Address RelocInfo::target_runtime_entry(Assembler* origin) { -+ DCHECK(IsRuntimeEntry(rmode_)); -+ return target_address(); -+} -+ -+void RelocInfo::set_target_runtime_entry(Address target, -+ WriteBarrierMode write_barrier_mode, -+ ICacheFlushMode icache_flush_mode) { -+ DCHECK(IsRuntimeEntry(rmode_)); -+ if (target_address() != target) -+ set_target_address(target, write_barrier_mode, icache_flush_mode); -+} -+ -+Address RelocInfo::target_off_heap_target() { -+ DCHECK(IsOffHeapTarget(rmode_)); -+ return Assembler::target_address_at(pc_, constant_pool_); -+} -+ -+void RelocInfo::WipeOut() { -+ DCHECK(IsFullEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || -+ IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || -+ IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_) || -+ IsOffHeapTarget(rmode_)); -+ if (IsInternalReference(rmode_)) { -+ Memory
(pc_) = kNullAddress; -+ } else if (IsInternalReferenceEncoded(rmode_)) { -+ Assembler::set_target_internal_reference_encoded_at(pc_, kNullAddress); -+ } else { -+ Assembler::set_target_address_at(pc_, constant_pool_, kNullAddress); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Assembler. -+ -+void Assembler::CheckBuffer() { -+ if (buffer_space() <= kGap) { -+ GrowBuffer(); -+ } -+} -+ -+template -+void Assembler::EmitHelper(T x) { -+ DEBUG_PRINTF("%p: ", pc_); -+ disassembleInstr((int)x); -+ *reinterpret_cast(pc_) = x; -+ pc_ += sizeof(x); -+ CheckTrampolinePoolQuick(); -+} -+ -+void Assembler::emit(Instr x) { -+ if (!is_buffer_growth_blocked()) { -+ CheckBuffer(); -+ } -+ EmitHelper(x); -+} -+ -+EnsureSpace::EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64.cc -@@ -0,0 +1,2342 @@ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/riscv64/assembler-riscv64.h" -+ -+#include "src/base/cpu.h" -+#include "src/codegen/riscv64/assembler-riscv64-inl.h" -+#include "src/codegen/safepoint-table.h" -+#include "src/codegen/string-constants.h" -+#include "src/deoptimizer/deoptimizer.h" -+#include "src/diagnostics/disasm.h" -+#include "src/diagnostics/disassembler.h" -+#include "src/objects/heap-number-inl.h" -+ -+namespace v8 { -+namespace internal { -+// Get the CPU features enabled by the build. For cross compilation the -+// preprocessor symbols CAN_USE_FPU_INSTRUCTIONS -+// can be defined to enable FPU instructions when building the -+// snapshot. -+static unsigned CpuFeaturesImpliedByCompiler() { -+ unsigned answer = 0; -+#ifdef CAN_USE_FPU_INSTRUCTIONS -+ answer |= 1u << FPU; -+#endif // def CAN_USE_FPU_INSTRUCTIONS -+ -+ return answer; -+} -+ -+void CpuFeatures::ProbeImpl(bool cross_compile) { -+ supported_ |= CpuFeaturesImpliedByCompiler(); -+ -+ // Only use statically determined features for cross compile (snapshot). -+ if (cross_compile) return; -+ -+ // Probe for additional features at runtime. -+ base::CPU cpu; -+ if (cpu.has_fpu()) supported_ |= 1u << FPU; -+} -+ -+void CpuFeatures::PrintTarget() {} -+void CpuFeatures::PrintFeatures() {} -+ -+int ToNumber(Register reg) { -+ DCHECK(reg.is_valid()); -+ const int kNumbers[] = { -+ 0, // zero_reg -+ 1, // ra -+ 2, // sp -+ 3, // gp -+ 4, // tp -+ 5, // t0 -+ 6, // t1 -+ 7, // t2 -+ 8, // s0/fp -+ 9, // s1 -+ 10, // a0 -+ 11, // a1 -+ 12, // a2 -+ 13, // a3 -+ 14, // a4 -+ 15, // a5 -+ 16, // a6 -+ 17, // a7 -+ 18, // s2 -+ 19, // s3 -+ 20, // s4 -+ 21, // s5 -+ 22, // s6 -+ 23, // s7 -+ 24, // s8 -+ 25, // s9 -+ 26, // s10 -+ 27, // s11 -+ 28, // t3 -+ 29, // t4 -+ 30, // t5 -+ 31, // t6 -+ }; -+ return kNumbers[reg.code()]; -+} -+ -+Register ToRegister(int num) { -+ DCHECK(num >= 0 && num < kNumRegisters); -+ const Register kRegisters[] = { -+ zero_reg, ra, sp, gp, tp, t0, t1, t2, fp, s1, a0, a1, a2, a3, a4, a5, -+ a6, a7, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, t3, t4, t5, t6}; -+ return kRegisters[num]; -+} -+ -+// ----------------------------------------------------------------------------- -+// Implementation of RelocInfo. -+ -+const int RelocInfo::kApplyMask = -+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | -+ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); -+ -+bool RelocInfo::IsCodedSpecially() { -+ // The deserializer needs to know whether a pointer is specially coded. Being -+ // specially coded on RISC-V means that it is a lui/addi instruction, and that -+ // is always the case inside code objects. -+ return true; -+} -+ -+bool RelocInfo::IsInConstantPool() { return false; } -+ -+uint32_t RelocInfo::wasm_call_tag() const { -+ DCHECK(rmode_ == WASM_CALL || rmode_ == WASM_STUB_CALL); -+ return static_cast( -+ Assembler::target_address_at(pc_, constant_pool_)); -+} -+ -+// ----------------------------------------------------------------------------- -+// Implementation of Operand and MemOperand. -+// See assembler-riscv64-inl.h for inlined constructors. -+ -+Operand::Operand(Handle handle) -+ : rm_(no_reg), rmode_(RelocInfo::FULL_EMBEDDED_OBJECT) { -+ value_.immediate = static_cast(handle.address()); -+} -+ -+Operand Operand::EmbeddedNumber(double value) { -+ int32_t smi; -+ if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi)); -+ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); -+ result.is_heap_object_request_ = true; -+ result.value_.heap_object_request = HeapObjectRequest(value); -+ return result; -+} -+ -+Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) { -+ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); -+ result.is_heap_object_request_ = true; -+ result.value_.heap_object_request = HeapObjectRequest(str); -+ return result; -+} -+ -+MemOperand::MemOperand(Register rm, int32_t offset) : Operand(rm) { -+ offset_ = offset; -+} -+ -+MemOperand::MemOperand(Register rm, int32_t unit, int32_t multiplier, -+ OffsetAddend offset_addend) -+ : Operand(rm) { -+ offset_ = unit * multiplier + offset_addend; -+} -+ -+void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { -+ DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty()); -+ for (auto& request : heap_object_requests_) { -+ Handle object; -+ switch (request.kind()) { -+ case HeapObjectRequest::kHeapNumber: -+ object = isolate->factory()->NewHeapNumber( -+ request.heap_number()); -+ break; -+ case HeapObjectRequest::kStringConstant: -+ const StringConstantBase* str = request.string(); -+ CHECK_NOT_NULL(str); -+ object = str->AllocateStringConstant(isolate); -+ break; -+ } -+ Address pc = reinterpret_cast
(buffer_start_) + request.offset(); -+ set_target_value_at(pc, reinterpret_cast(object.location())); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Specific instructions, constants, and masks. -+ -+Assembler::Assembler(const AssemblerOptions& options, -+ std::unique_ptr buffer) -+ : AssemblerBase(options, std::move(buffer)), -+ scratch_register_list_(t3.bit()) { -+ reloc_info_writer.Reposition(buffer_start_ + buffer_->size(), pc_); -+ -+ last_trampoline_pool_end_ = 0; -+ no_trampoline_pool_before_ = 0; -+ trampoline_pool_blocked_nesting_ = 0; -+ // We leave space (16 * kTrampolineSlotsSize) -+ // for BlockTrampolinePoolScope buffer. -+ next_buffer_check_ = FLAG_force_long_branches -+ ? kMaxInt -+ : kMaxBranchOffset - kTrampolineSlotsSize * 16; -+ internal_trampoline_exception_ = false; -+ last_bound_pos_ = 0; -+ -+ trampoline_emitted_ = FLAG_force_long_branches; -+ unbound_labels_count_ = 0; -+ block_buffer_growth_ = false; -+} -+ -+void Assembler::GetCode(Isolate* isolate, CodeDesc* desc, -+ SafepointTableBuilder* safepoint_table_builder, -+ int handler_table_offset) { -+ int code_comments_size = WriteCodeComments(); -+ -+ DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. -+ -+ AllocateAndInstallRequestedHeapObjects(isolate); -+ -+ // Set up code descriptor. -+ // TODO(jgruber): Reconsider how these offsets and sizes are maintained up to -+ // this point to make CodeDesc initialization less fiddly. -+ -+ static constexpr int kConstantPoolSize = 0; -+ const int instruction_size = pc_offset(); -+ const int code_comments_offset = instruction_size - code_comments_size; -+ const int constant_pool_offset = code_comments_offset - kConstantPoolSize; -+ const int handler_table_offset2 = (handler_table_offset == kNoHandlerTable) -+ ? constant_pool_offset -+ : handler_table_offset; -+ const int safepoint_table_offset = -+ (safepoint_table_builder == kNoSafepointTable) -+ ? handler_table_offset2 -+ : safepoint_table_builder->GetCodeOffset(); -+ const int reloc_info_offset = -+ static_cast(reloc_info_writer.pos() - buffer_->start()); -+ CodeDesc::Initialize(desc, this, safepoint_table_offset, -+ handler_table_offset2, constant_pool_offset, -+ code_comments_offset, reloc_info_offset); -+} -+ -+void Assembler::Align(int m) { -+ DCHECK(m >= 4 && base::bits::IsPowerOfTwo(m)); -+ while ((pc_offset() & (m - 1)) != 0) { -+ nop(); -+ } -+} -+ -+void Assembler::CodeTargetAlign() { -+ // No advantage to aligning branch/call targets to more than -+ // single instruction, that I am aware of. -+ Align(4); -+} -+ -+// Labels refer to positions in the (to be) generated code. -+// There are bound, linked, and unused labels. -+// -+// Bound labels refer to known positions in the already -+// generated code. pos() is the position the label refers to. -+// -+// Linked labels refer to unknown positions in the code -+// to be generated; pos() is the position of the last -+// instruction using the label. -+ -+// The link chain is terminated by a value in the instruction of 0, -+// which is an otherwise illegal value (branch 0 is inf loop). -+ -+const int kEndOfChain = 0; -+ -+// Determines the end of the Jump chain (a subset of the label link chain). -+const int kEndOfJumpChain = 0; -+ -+bool Assembler::IsBranch(Instr instr) { -+ return (instr & kBaseOpcodeMask) == BRANCH; -+} -+ -+bool Assembler::IsJump(Instr instr) { -+ int Op = instr & kBaseOpcodeMask; -+ return Op == JAL || Op == JALR; -+} -+ -+bool Assembler::IsJal(Instr instr) { return (instr & kBaseOpcodeMask) == JAL; } -+ -+bool Assembler::IsJalr(Instr instr) { -+ return (instr & kBaseOpcodeMask) == JALR; -+} -+ -+bool Assembler::IsLui(Instr instr) { return (instr & kBaseOpcodeMask) == LUI; } -+bool Assembler::IsAuipc(Instr instr) { return (instr & kBaseOpcodeMask) == AUIPC; } -+bool Assembler::IsAddiw(Instr instr) { -+ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_ADDIW; -+} -+bool Assembler::IsAddi(Instr instr) { -+ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_ADDI; -+} -+bool Assembler::IsSlli(Instr instr) { -+ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_SLLI; -+} -+int Assembler::target_at(int pos, bool is_internal) { -+ if (is_internal) { -+ int64_t* p = reinterpret_cast(buffer_start_ + pos); -+ int64_t address = *p; -+ if (address == kEndOfJumpChain) { -+ return kEndOfChain; -+ } else { -+ int64_t instr_address = reinterpret_cast(p); -+ DCHECK(instr_address - address < INT_MAX); -+ int delta = static_cast(instr_address - address); -+ DCHECK(pos > delta); -+ return pos - delta; -+ } -+ } -+ Instr instr = instr_at(pos); -+ DEBUG_PRINTF("target_at: %p (%d)\n\t", -+ reinterpret_cast(buffer_start_ + pos), pos); -+ disassembleInstr(instr); -+ if (IsBranch(instr)) { -+ int32_t imm13 = BranchOffset(instr); -+ if (imm13 == kEndOfJumpChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or pos. -+ return kEndOfChain; -+ } else { -+ return pos + imm13; -+ } -+ } else if (IsJal(instr)) { -+ int32_t imm21 = JumpOffset(instr); -+ if (imm21 == kEndOfJumpChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or pos. -+ return kEndOfChain; -+ } else { -+ return pos + imm21; -+ } -+ } else if (IsJalr(instr)) { -+ int32_t imm12 = instr >> 20; -+ if (imm12 == kEndOfJumpChain) { -+ // EndOfChain sentinel is returned directly, not relative to pc or pos. -+ return kEndOfChain; -+ } else { -+ return pos + imm12; -+ } -+ } else if (IsLui(instr)) { -+ Address pc = reinterpret_cast
(buffer_start_ + pos); -+ pc = target_address_at(pc); -+ uint64_t instr_address = reinterpret_cast(buffer_start_ + pos); -+ uint64_t imm = reinterpret_cast(pc); -+ if(imm == kEndOfJumpChain) { -+ return kEndOfChain; -+ } else { -+ DCHECK(instr_address - imm < INT_MAX); -+ int32_t delta = static_cast(instr_address - imm); -+ DCHECK(pos > delta); -+ return pos - delta; -+ } -+ } else if (IsAuipc(instr)) { -+ Instr instr_auipc = instr; -+ Instr instr_jalr = instr_at(pos + 4); -+ DCHECK(IsJalr(instr_jalr)); -+ int32_t offset = BrachlongOffset(instr_auipc, instr_jalr); -+ if(offset == kEndOfJumpChain) -+ return kEndOfChain; -+ return offset + pos; -+ } else { -+ // Emitted label constant, not part of a branch. -+ if (instr == 0) { -+ return kEndOfChain; -+ } else { -+ int32_t imm18 = ((instr & static_cast(kImm16Mask)) << 16) >> 14; -+ return (imm18 + pos); -+ } -+ } -+} -+ -+static inline Instr SetBranchOffset(int32_t pos, int32_t target_pos, -+ Instr instr) { -+ int32_t imm = target_pos - pos; -+ DCHECK_EQ(imm & 1, 0); -+ DCHECK(is_intn(imm, Assembler::kBranchOffsetBits)); -+ -+ instr &= ~kBImm12Mask; -+ int32_t imm12 = ((imm & 0x800) >> 4) | // bit 11 -+ ((imm & 0x1e) << 7) | // bits 4-1 -+ ((imm & 0x7e0) << 20) | // bits 10-5 -+ ((imm & 0x1000) << 19); // bit 12 -+ -+ return instr | (imm12 & kBImm12Mask); -+} -+ -+static inline Instr SetJalOffset(int32_t pos, int32_t target_pos, Instr instr) { -+ int32_t imm = target_pos - pos; -+ DCHECK_EQ(imm & 1, 0); -+ DCHECK(is_intn(imm, Assembler::kJumpOffsetBits)); -+ -+ instr &= ~kImm20Mask; -+ int32_t imm20 = (imm & 0xff000) | // bits 19-12 -+ ((imm & 0x800) << 9) | // bit 11 -+ ((imm & 0x7fe) << 20) | // bits 10-1 -+ ((imm & 0x100000) << 11); // bit 20 -+ -+ return instr | (imm20 & kImm20Mask); -+} -+ -+void Assembler::target_at_put(int pos, int target_pos, bool is_internal) { -+ if (is_internal) { -+ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; -+ *reinterpret_cast(buffer_start_ + pos) = imm; -+ return; -+ } -+ DEBUG_PRINTF("target_at_put: %p (%d) to %p (%d)\n", -+ reinterpret_cast(buffer_start_ + pos), pos, -+ reinterpret_cast(buffer_start_ + target_pos), -+ target_pos); -+ Instr instr = instr_at(pos); -+ -+ if (IsBranch(instr)) { -+ instr = SetBranchOffset(pos, target_pos, instr); -+ instr_at_put(pos, instr); -+ } else if (IsJal(instr)) { -+ instr = SetJalOffset(pos, target_pos, instr); -+ instr_at_put(pos, instr); -+ } else if (IsLui(instr)) { -+ Address pc = reinterpret_cast
(buffer_start_ + pos); -+ set_target_value_at(pc, reinterpret_cast(buffer_start_ + target_pos)); -+ } else if (IsAuipc(instr)) { -+ Instr instr_auipc = instr; -+ Instr instr_jalr = instr_at(pos + 4); -+ DCHECK(IsJalr(instr_jalr)); -+ -+ int64_t offset = target_pos - pos; -+ DCHECK(is_int32(offset)); -+ -+ int32_t Hi20 = (((int32_t)offset + 0x800) >> 12); -+ int32_t Lo12 = (int32_t)offset << 20 >> 20; -+ -+ const int kImm31_12Mask = ((1 << 20) - 1) << 12; -+ const int kImm19_0Mask = ((1 << 20) - 1); -+ instr_auipc = (instr_auipc & ~kImm31_12Mask) | -+ ((Hi20 & kImm19_0Mask) << 12); -+ instr_at_put(pos, instr_auipc); -+ -+ const int kImm31_20Mask = ((1 << 12) - 1) << 20; -+ const int kImm11_0Mask = ((1 << 12) - 1); -+ instr_jalr = (instr_jalr & ~kImm31_20Mask) | -+ ((Lo12 & kImm11_0Mask) << 20); -+ instr_at_put(pos + 4, instr_jalr); -+ } else { -+ // Emitted label constant, not part of a branch. -+ // Make label relative to Code pointer of generated Code object. -+ instr_at_put(pos, target_pos + (Code::kHeaderSize - kHeapObjectTag)); -+ } -+ disassembleInstr(instr); -+} -+ -+void Assembler::print(const Label* L) { -+ if (L->is_unused()) { -+ PrintF("unused label\n"); -+ } else if (L->is_bound()) { -+ PrintF("bound label to %d\n", L->pos()); -+ } else if (L->is_linked()) { -+ Label l; -+ l.link_to(L->pos()); -+ PrintF("unbound label"); -+ while (l.is_linked()) { -+ PrintF("@ %d ", l.pos()); -+ Instr instr = instr_at(l.pos()); -+ if ((instr & ~kImm16Mask) == 0) { -+ PrintF("value\n"); -+ } else { -+ PrintF("%d\n", instr); -+ } -+ next(&l, is_internal_reference(&l)); -+ } -+ } else { -+ PrintF("label in inconsistent state (pos = %d)\n", L->pos_); -+ } -+} -+ -+void Assembler::bind_to(Label* L, int pos) { -+ DCHECK(0 <= pos && pos <= pc_offset()); // Must have valid binding position. -+ DEBUG_PRINTF("binding %d to label %p\n", pos, L); -+ int trampoline_pos = kInvalidSlotPos; -+ bool is_internal = false; -+ if (L->is_linked() && !trampoline_emitted_) { -+ unbound_labels_count_--; -+ if (!is_internal_reference(L)) { -+ next_buffer_check_ += kTrampolineSlotsSize; -+ } -+ } -+ -+ while (L->is_linked()) { -+ int fixup_pos = L->pos(); -+ int dist = pos - fixup_pos; -+ is_internal = is_internal_reference(L); -+ next(L, is_internal); // Call next before overwriting link with target -+ // at fixup_pos. -+ Instr instr = instr_at(fixup_pos); -+ DEBUG_PRINTF("\tfixup: %d to %d\n", fixup_pos, dist); -+ if (is_internal) { -+ target_at_put(fixup_pos, pos, is_internal); -+ } else { -+ if (IsBranch(instr)) { -+ if (dist > kMaxBranchOffset) { -+ if (trampoline_pos == kInvalidSlotPos) { -+ trampoline_pos = get_trampoline_entry(fixup_pos); -+ CHECK_NE(trampoline_pos, kInvalidSlotPos); -+ } -+ CHECK((trampoline_pos - fixup_pos) <= kMaxBranchOffset); -+ DEBUG_PRINTF("\t\ttrampolining: %d\n", trampoline_pos); -+ target_at_put(fixup_pos, trampoline_pos, false); -+ fixup_pos = trampoline_pos; -+ } -+ target_at_put(fixup_pos, pos, false); -+ } else if (IsJal(instr)) { -+ if (dist > kMaxJumpOffset) { -+ if (trampoline_pos == kInvalidSlotPos) { -+ trampoline_pos = get_trampoline_entry(fixup_pos); -+ CHECK_NE(trampoline_pos, kInvalidSlotPos); -+ } -+ CHECK((trampoline_pos - fixup_pos) <= kMaxJumpOffset); -+ DEBUG_PRINTF("\t\ttrampolining: %d\n", trampoline_pos); -+ target_at_put(fixup_pos, trampoline_pos, false); -+ fixup_pos = trampoline_pos; -+ } -+ target_at_put(fixup_pos, pos, false); -+ } else { -+ target_at_put(fixup_pos, pos, false); -+ } -+ } -+ } -+ L->bind_to(pos); -+ -+ // Keep track of the last bound label so we don't eliminate any instructions -+ // before a bound label. -+ if (pos > last_bound_pos_) last_bound_pos_ = pos; -+} -+ -+void Assembler::bind(Label* L) { -+ DCHECK(!L->is_bound()); // Label can only be bound once. -+ bind_to(L, pc_offset()); -+} -+ -+void Assembler::next(Label* L, bool is_internal) { -+ DCHECK(L->is_linked()); -+ int link = target_at(L->pos(), is_internal); -+ if (link == kEndOfChain) { -+ L->Unuse(); -+ } else { -+ DCHECK_GT(link, 0); -+ DEBUG_PRINTF("next: %p to %p (%d)\n", L, -+ reinterpret_cast(buffer_start_ + link), link); -+ L->link_to(link); -+ } -+} -+ -+bool Assembler::is_near(Label* L) { -+ DCHECK(L->is_bound()); -+ return is_intn((pc_offset() - L->pos()), kJumpOffsetBits); -+} -+ -+bool Assembler::is_near(Label* L, OffsetSize bits) { -+ if (L == nullptr || !L->is_bound()) return true; -+ return is_intn((pc_offset() - L->pos()), bits); -+} -+ -+bool Assembler::is_near_branch(Label* L) { -+ DCHECK(L->is_bound()); -+ return is_intn((pc_offset() - L->pos()), kBranchOffsetBits); -+} -+ -+int Assembler::BranchOffset(Instr instr) { -+ // | imm[12] | imm[10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode | -+ // 31 25 11 7 -+ int32_t imm13 = ((instr & 0xf00) >> 7) | ((instr & 0x7e000000) >> 20) | -+ ((instr & 0x80) << 4) | ((instr & 0x80000000) >> 19); -+ imm13 = imm13 << 19 >> 19; -+ return imm13; -+} -+ -+int Assembler::JumpOffset(Instr instr) { -+ int32_t imm21 = ((instr & 0x7fe00000) >> 20) | ((instr & 0x100000) >> 9) | -+ (instr & 0xff000) | ((instr & 0x80000000) >> 11); -+ imm21 = imm21 << 11 >> 11; -+ return imm21; -+} -+ -+int Assembler::BrachlongOffset(Instr auipc, Instr jalr) { -+ const int kImm19_0Mask = ((1 << 20) - 1); -+ int32_t imm_auipc = auipc & (kImm19_0Mask << 12); -+ int32_t imm_jalr = jalr >> 20; -+ int32_t offset = imm_jalr + imm_auipc; -+ return offset; -+} -+ -+// We have to use a temporary register for things that can be relocated even -+// if they can be encoded in RISC-V's 12 bits of immediate-offset instruction -+// space. There is no guarantee that the relocated location can be similarly -+// encoded. -+bool Assembler::MustUseReg(RelocInfo::Mode rmode) { -+ return !RelocInfo::IsNone(rmode); -+} -+ -+void Assembler::disassembleInstr(Instr instr) { -+ if (!FLAG_debug_riscv) return; -+ disasm::NameConverter converter; -+ disasm::Disassembler disasm(converter); -+ EmbeddedVector disasm_buffer; -+ -+ disasm.InstructionDecode(disasm_buffer, reinterpret_cast(&instr)); -+ DEBUG_PRINTF("%s\n", disasm_buffer.begin()); -+} -+ -+// ----- Top-level instruction formats match those in the ISA manual -+// (R, I, S, B, U, J). These match the formats defined in the compiler -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ Register rd, Register rs1, Register rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ Register rd, FPURegister rs1, Register rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ FPURegister rd, Register rs1, Register rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ FPURegister rd, FPURegister rs1, Register rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, -+ Register rd, FPURegister rs1, FPURegister rs2) { -+ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR4(uint8_t funct2, Opcode opcode, Register rd, -+ Register rs1, Register rs2, Register rs3, -+ RoundingMode frm) { -+ DCHECK(is_uint2(funct2) && rd.is_valid() && rs1.is_valid() && -+ rs2.is_valid() && rs3.is_valid() && is_uint3(frm)); -+ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct2 << kFunct2Shift) | (rs3.code() << kRs3Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrR4(uint8_t funct2, Opcode opcode, FPURegister rd, -+ FPURegister rs1, FPURegister rs2, FPURegister rs3, -+ RoundingMode frm) { -+ DCHECK(is_uint2(funct2) && rd.is_valid() && rs1.is_valid() && -+ rs2.is_valid() && rs3.is_valid() && is_uint3(frm)); -+ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct2 << kFunct2Shift) | (rs3.code() << kRs3Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrRAtomic(uint8_t funct5, bool aq, bool rl, -+ uint8_t funct3, Register rd, Register rs1, -+ Register rs2) { -+ DCHECK(is_uint5(funct5) && is_uint3(funct3) && rd.is_valid() && -+ rs1.is_valid() && rs2.is_valid()); -+ Instr instr = AMO | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (rl << kRlShift) | (aq << kAqShift) | (funct5 << kFunct5Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrRFrm(uint8_t funct7, Opcode opcode, Register rd, -+ Register rs1, Register rs2, RoundingMode frm) { -+ DCHECK(rd.is_valid() && rs1.is_valid() && rs2.is_valid() && is_uint3(frm)); -+ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | -+ (funct7 << kFunct7Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrI(uint8_t funct3, Opcode opcode, Register rd, -+ Register rs1, int16_t imm12) { -+ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && -+ (is_uint12(imm12) || is_int12(imm12))); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (imm12 << kImm12Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrI(uint8_t funct3, Opcode opcode, FPURegister rd, -+ Register rs1, int16_t imm12) { -+ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && -+ (is_uint12(imm12) || is_int12(imm12))); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (imm12 << kImm12Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrIShift(bool arithshift, uint8_t funct3, Opcode opcode, -+ Register rd, Register rs1, uint8_t shamt) { -+ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && -+ is_uint6(shamt)); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (shamt << kShamtShift) | -+ (arithshift << kArithShiftShift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrIShiftW(bool arithshift, uint8_t funct3, Opcode opcode, -+ Register rd, Register rs1, uint8_t shamt) { -+ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && -+ is_uint5(shamt)); -+ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | -+ (rs1.code() << kRs1Shift) | (shamt << kShamtWShift) | -+ (arithshift << kArithShiftShift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, -+ Register rs2, int16_t imm12) { -+ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && -+ is_int12(imm12)); -+ Instr instr = opcode | ((imm12 & 0x1f) << 7) | // bits 4-0 -+ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | -+ (rs2.code() << kRs2Shift) | -+ ((imm12 & 0xfe0) << 20); // bits 11-5 -+ emit(instr); -+} -+ -+void Assembler::GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, -+ FPURegister rs2, int16_t imm12) { -+ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && -+ is_int12(imm12)); -+ Instr instr = opcode | ((imm12 & 0x1f) << 7) | // bits 4-0 -+ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | -+ (rs2.code() << kRs2Shift) | -+ ((imm12 & 0xfe0) << 20); // bits 11-5 -+ emit(instr); -+} -+ -+void Assembler::GenInstrB(uint8_t funct3, Opcode opcode, Register rs1, -+ Register rs2, int16_t imm13) { -+ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && -+ is_int13(imm13) && ((imm13 & 1) == 0)); -+ Instr instr = opcode | ((imm13 & 0x800) >> 4) | // bit 11 -+ ((imm13 & 0x1e) << 7) | // bits 4-1 -+ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | -+ (rs2.code() << kRs2Shift) | -+ ((imm13 & 0x7e0) << 20) | // bits 10-5 -+ ((imm13 & 0x1000) << 19); // bit 12 -+ emit(instr); -+} -+ -+void Assembler::GenInstrU(Opcode opcode, Register rd, int32_t imm20) { -+ DCHECK(rd.is_valid() && (is_int20(imm20) || is_uint20(imm20))); -+ Instr instr = opcode | (rd.code() << kRdShift) | (imm20 << kImm20Shift); -+ emit(instr); -+} -+ -+void Assembler::GenInstrJ(Opcode opcode, Register rd, int32_t imm21) { -+ DCHECK(rd.is_valid() && is_int21(imm21) && ((imm21 & 1) == 0)); -+ Instr instr = opcode | (rd.code() << kRdShift) | -+ (imm21 & 0xff000) | // bits 19-12 -+ ((imm21 & 0x800) << 9) | // bit 11 -+ ((imm21 & 0x7fe) << 20) | // bits 10-1 -+ ((imm21 & 0x100000) << 11); // bit 20 -+ emit(instr); -+} -+ -+// ----- Instruction class templates match those in the compiler -+ -+void Assembler::GenInstrBranchCC_rri(uint8_t funct3, Register rs1, Register rs2, -+ int16_t imm13) { -+ GenInstrB(funct3, BRANCH, rs1, rs2, imm13); -+} -+ -+void Assembler::GenInstrLoad_ri(uint8_t funct3, Register rd, Register rs1, -+ int16_t imm12) { -+ GenInstrI(funct3, LOAD, rd, rs1, imm12); -+} -+ -+void Assembler::GenInstrStore_rri(uint8_t funct3, Register rs1, Register rs2, -+ int16_t imm12) { -+ GenInstrS(funct3, STORE, rs1, rs2, imm12); -+} -+ -+void Assembler::GenInstrALU_ri(uint8_t funct3, Register rd, Register rs1, -+ int16_t imm12) { -+ GenInstrI(funct3, OP_IMM, rd, rs1, imm12); -+} -+ -+void Assembler::GenInstrShift_ri(bool arithshift, uint8_t funct3, Register rd, -+ Register rs1, uint8_t shamt) { -+ DCHECK(is_uint6(shamt)); -+ GenInstrI(funct3, OP_IMM, rd, rs1, (arithshift << 10) | shamt); -+} -+ -+void Assembler::GenInstrALU_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ Register rs1, Register rs2) { -+ GenInstrR(funct7, funct3, OP, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrCSR_ir(uint8_t funct3, Register rd, -+ ControlStatusReg csr, Register rs1) { -+ GenInstrI(funct3, SYSTEM, rd, rs1, csr); -+} -+ -+void Assembler::GenInstrCSR_ii(uint8_t funct3, Register rd, -+ ControlStatusReg csr, uint8_t imm5) { -+ GenInstrI(funct3, SYSTEM, rd, ToRegister(imm5), csr); -+} -+ -+void Assembler::GenInstrShiftW_ri(bool arithshift, uint8_t funct3, Register rd, -+ Register rs1, uint8_t shamt) { -+ GenInstrIShiftW(arithshift, funct3, OP_IMM_32, rd, rs1, shamt); -+} -+ -+void Assembler::GenInstrALUW_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ Register rs1, Register rs2) { -+ GenInstrR(funct7, funct3, OP_32, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrPriv(uint8_t funct7, Register rs1, Register rs2) { -+ GenInstrR(funct7, 0b000, SYSTEM, ToRegister(0), rs1, rs2); -+} -+ -+void Assembler::GenInstrLoadFP_ri(uint8_t funct3, FPURegister rd, Register rs1, -+ int16_t imm12) { -+ GenInstrI(funct3, LOAD_FP, rd, rs1, imm12); -+} -+ -+void Assembler::GenInstrStoreFP_rri(uint8_t funct3, Register rs1, -+ FPURegister rs2, int16_t imm12) { -+ GenInstrS(funct3, STORE_FP, rs1, rs2, imm12); -+} -+ -+void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ FPURegister rs1, FPURegister rs2) { -+ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ Register rs1, Register rs2) { -+ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ FPURegister rs1, Register rs2) { -+ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ FPURegister rs1, Register rs2) { -+ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); -+} -+ -+void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ FPURegister rs1, FPURegister rs2) { -+ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); -+} -+ -+// Returns the next free trampoline entry. -+int32_t Assembler::get_trampoline_entry(int32_t pos) { -+ int32_t trampoline_entry = kInvalidSlotPos; -+ if (!internal_trampoline_exception_) { -+ if (trampoline_.start() > pos) { -+ trampoline_entry = trampoline_.take_slot(); -+ } -+ -+ if (kInvalidSlotPos == trampoline_entry) { -+ internal_trampoline_exception_ = true; -+ } -+ } -+ return trampoline_entry; -+} -+ -+uint64_t Assembler::jump_address(Label* L) { -+ int64_t target_pos; -+ DEBUG_PRINTF("jump_address: %p to %p (%d)\n", L, -+ reinterpret_cast(buffer_start_ + pc_offset()), -+ pc_offset()); -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ L->link_to(pc_offset()); -+ } else { -+ L->link_to(pc_offset()); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ DEBUG_PRINTF("\tstarted link\n"); -+ return kEndOfJumpChain; -+ } -+ } -+ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; -+ DCHECK_EQ(imm & 3, 0); -+ -+ return imm; -+} -+ -+uint64_t Assembler::branch_long_offset(Label* L) { -+ int64_t target_pos; -+ -+ DEBUG_PRINTF("branch_long_offset: %p to %p (%d)\n", L, -+ reinterpret_cast(buffer_start_ + pc_offset()), -+ pc_offset()); -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ L->link_to(pc_offset()); -+ } else { -+ L->link_to(pc_offset()); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ DEBUG_PRINTF("\tstarted link\n"); -+ return kEndOfJumpChain; -+ } -+ } -+ int64_t offset = target_pos - pc_offset(); -+ DCHECK_EQ(offset & 3, 0); -+ -+ return static_cast(offset); -+} -+ -+int32_t Assembler::branch_offset_helper(Label* L, OffsetSize bits) { -+ int32_t target_pos; -+ -+ DEBUG_PRINTF("branch_offset_helper: %p to %p (%d)\n", L, -+ reinterpret_cast(buffer_start_ + pc_offset()), -+ pc_offset()); -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ DEBUG_PRINTF("\tbound: %d", target_pos); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); -+ L->link_to(pc_offset()); -+ DEBUG_PRINTF("\tadded to link: %d\n", target_pos); -+ } else { -+ L->link_to(pc_offset()); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ DEBUG_PRINTF("\tstarted link\n"); -+ return kEndOfChain; -+ } -+ } -+ -+ int32_t offset = target_pos - pc_offset(); -+ DCHECK(is_intn(offset, bits)); -+ DCHECK_EQ(offset & 1, 0); -+ DEBUG_PRINTF("\toffset = %d\n", offset); -+ return offset; -+} -+ -+void Assembler::label_at_put(Label* L, int at_offset) { -+ int target_pos; -+ DEBUG_PRINTF("label_at_put: %p @ %p (%d)\n", L, -+ reinterpret_cast(buffer_start_ + at_offset), at_offset); -+ if (L->is_bound()) { -+ target_pos = L->pos(); -+ instr_at_put(at_offset, target_pos + (Code::kHeaderSize - kHeapObjectTag)); -+ } else { -+ if (L->is_linked()) { -+ target_pos = L->pos(); // L's link. -+ int32_t imm18 = target_pos - at_offset; -+ DCHECK_EQ(imm18 & 3, 0); -+ int32_t imm16 = imm18 >> 2; -+ DCHECK(is_int16(imm16)); -+ instr_at_put(at_offset, (imm16 & kImm16Mask)); -+ } else { -+ target_pos = kEndOfChain; -+ instr_at_put(at_offset, 0); -+ if (!trampoline_emitted_) { -+ unbound_labels_count_++; -+ next_buffer_check_ -= kTrampolineSlotsSize; -+ } -+ } -+ L->link_to(at_offset); -+ } -+} -+ -+//===----------------------------------------------------------------------===// -+// Instructions -+//===----------------------------------------------------------------------===// -+ -+void Assembler::lui(Register rd, int32_t imm20) { GenInstrU(LUI, rd, imm20); } -+ -+void Assembler::auipc(Register rd, int32_t imm20) { -+ GenInstrU(AUIPC, rd, imm20); -+} -+ -+// Jumps -+ -+void Assembler::jal(Register rd, int32_t imm21) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ GenInstrJ(JAL, rd, imm21); -+ BlockTrampolinePoolFor(1); -+} -+ -+void Assembler::jalr(Register rd, Register rs1, int16_t imm12) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ GenInstrI(0b000, JALR, rd, rs1, imm12); -+ BlockTrampolinePoolFor(1); -+} -+ -+// Branches -+ -+void Assembler::beq(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b000, rs1, rs2, imm13); -+} -+ -+void Assembler::bne(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b001, rs1, rs2, imm13); -+} -+ -+void Assembler::blt(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b100, rs1, rs2, imm13); -+} -+ -+void Assembler::bge(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b101, rs1, rs2, imm13); -+} -+ -+void Assembler::bltu(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b110, rs1, rs2, imm13); -+} -+ -+void Assembler::bgeu(Register rs1, Register rs2, int16_t imm13) { -+ GenInstrBranchCC_rri(0b111, rs1, rs2, imm13); -+} -+ -+// Loads -+ -+void Assembler::lb(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b000, rd, rs1, imm12); -+} -+ -+void Assembler::lh(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b001, rd, rs1, imm12); -+} -+ -+void Assembler::lw(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b010, rd, rs1, imm12); -+} -+ -+void Assembler::lbu(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b100, rd, rs1, imm12); -+} -+ -+void Assembler::lhu(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b101, rd, rs1, imm12); -+} -+ -+// Stores -+ -+void Assembler::sb(Register source, Register base, int16_t imm12) { -+ GenInstrStore_rri(0b000, base, source, imm12); -+} -+ -+void Assembler::sh(Register source, Register base, int16_t imm12) { -+ GenInstrStore_rri(0b001, base, source, imm12); -+} -+ -+void Assembler::sw(Register source, Register base, int16_t imm12) { -+ GenInstrStore_rri(0b010, base, source, imm12); -+} -+ -+// Arithmetic with immediate -+ -+void Assembler::addi(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b000, rd, rs1, imm12); -+} -+ -+void Assembler::slti(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b010, rd, rs1, imm12); -+} -+ -+void Assembler::sltiu(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b011, rd, rs1, imm12); -+} -+ -+void Assembler::xori(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b100, rd, rs1, imm12); -+} -+ -+void Assembler::ori(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b110, rd, rs1, imm12); -+} -+ -+void Assembler::andi(Register rd, Register rs1, int16_t imm12) { -+ GenInstrALU_ri(0b111, rd, rs1, imm12); -+} -+ -+void Assembler::slli(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShift_ri(0, 0b001, rd, rs1, shamt & 0x3f); -+} -+ -+void Assembler::srli(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShift_ri(0, 0b101, rd, rs1, shamt & 0x3f); -+} -+ -+void Assembler::srai(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShift_ri(1, 0b101, rd, rs1, shamt & 0x3f); -+} -+ -+// Arithmetic -+ -+void Assembler::add(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::sub(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0100000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::sll(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::slt(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::sltu(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::xor_(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b100, rd, rs1, rs2); -+} -+ -+void Assembler::srl(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b101, rd, rs1, rs2); -+} -+ -+void Assembler::sra(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0100000, 0b101, rd, rs1, rs2); -+} -+ -+void Assembler::or_(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b110, rd, rs1, rs2); -+} -+ -+void Assembler::and_(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000000, 0b111, rd, rs1, rs2); -+} -+ -+// Memory fences -+ -+void Assembler::fence(uint8_t pred, uint8_t succ) { -+ DCHECK(is_uint4(pred) && is_uint4(succ)); -+ uint16_t imm12 = succ | (pred << 4) | (0b0000 << 8); -+ GenInstrI(0b000, MISC_MEM, ToRegister(0), ToRegister(0), imm12); -+} -+ -+void Assembler::fence_tso() { -+ uint16_t imm12 = (0b0011) | (0b0011 << 4) | (0b1000 << 8); -+ GenInstrI(0b000, MISC_MEM, ToRegister(0), ToRegister(0), imm12); -+} -+ -+// Environment call / break -+ -+void Assembler::ecall() { -+ GenInstrI(0b000, SYSTEM, ToRegister(0), ToRegister(0), 0); -+} -+ -+void Assembler::ebreak() { -+ GenInstrI(0b000, SYSTEM, ToRegister(0), ToRegister(0), 1); -+} -+ -+// This is a de facto standard (as set by GNU binutils) 32-bit unimplemented -+// instruction (i.e., it should always trap, if your implementation has invalid -+// instruction traps). -+void Assembler::unimp() { -+ GenInstrI(0b001, SYSTEM, ToRegister(0), ToRegister(0), 0b110000000000); -+} -+ -+// CSR -+ -+void Assembler::csrrw(Register rd, ControlStatusReg csr, Register rs1) { -+ GenInstrCSR_ir(0b001, rd, csr, rs1); -+} -+ -+void Assembler::csrrs(Register rd, ControlStatusReg csr, Register rs1) { -+ GenInstrCSR_ir(0b010, rd, csr, rs1); -+} -+ -+void Assembler::csrrc(Register rd, ControlStatusReg csr, Register rs1) { -+ GenInstrCSR_ir(0b011, rd, csr, rs1); -+} -+ -+void Assembler::csrrwi(Register rd, ControlStatusReg csr, uint8_t imm5) { -+ GenInstrCSR_ii(0b101, rd, csr, imm5); -+} -+ -+void Assembler::csrrsi(Register rd, ControlStatusReg csr, uint8_t imm5) { -+ GenInstrCSR_ii(0b110, rd, csr, imm5); -+} -+ -+void Assembler::csrrci(Register rd, ControlStatusReg csr, uint8_t imm5) { -+ GenInstrCSR_ii(0b111, rd, csr, imm5); -+} -+ -+// RV64I -+ -+void Assembler::lwu(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b110, rd, rs1, imm12); -+} -+ -+void Assembler::ld(Register rd, Register rs1, int16_t imm12) { -+ GenInstrLoad_ri(0b011, rd, rs1, imm12); -+} -+ -+void Assembler::sd(Register source, Register base, int16_t imm12) { -+ GenInstrStore_rri(0b011, base, source, imm12); -+} -+ -+void Assembler::addiw(Register rd, Register rs1, int16_t imm12) { -+ GenInstrI(0b000, OP_IMM_32, rd, rs1, imm12); -+} -+ -+void Assembler::slliw(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShiftW_ri(0, 0b001, rd, rs1, shamt & 0x1f); -+} -+ -+void Assembler::srliw(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShiftW_ri(0, 0b101, rd, rs1, shamt & 0x1f); -+} -+ -+void Assembler::sraiw(Register rd, Register rs1, uint8_t shamt) { -+ GenInstrShiftW_ri(1, 0b101, rd, rs1, shamt & 0x1f); -+} -+ -+void Assembler::addw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::subw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0100000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::sllw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000000, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::srlw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000000, 0b101, rd, rs1, rs2); -+} -+ -+void Assembler::sraw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0100000, 0b101, rd, rs1, rs2); -+} -+ -+// RV32M Standard Extension -+ -+void Assembler::mul(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::mulh(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::mulhsu(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::mulhu(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::div(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b100, rd, rs1, rs2); -+} -+ -+void Assembler::divu(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b101, rd, rs1, rs2); -+} -+ -+void Assembler::rem(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b110, rd, rs1, rs2); -+} -+ -+void Assembler::remu(Register rd, Register rs1, Register rs2) { -+ GenInstrALU_rr(0b0000001, 0b111, rd, rs1, rs2); -+} -+ -+// RV64M Standard Extension (in addition to RV32M) -+ -+void Assembler::mulw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000001, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::divw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000001, 0b100, rd, rs1, rs2); -+} -+ -+void Assembler::divuw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000001, 0b101, rd, rs1, rs2); -+} -+ -+void Assembler::remw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000001, 0b110, rd, rs1, rs2); -+} -+ -+void Assembler::remuw(Register rd, Register rs1, Register rs2) { -+ GenInstrALUW_rr(0b0000001, 0b111, rd, rs1, rs2); -+} -+ -+// RV32A Standard Extension -+ -+void Assembler::lr_w(bool aq, bool rl, Register rd, Register rs1) { -+ GenInstrRAtomic(0b00010, aq, rl, 0b010, rd, rs1, zero_reg); -+} -+ -+void Assembler::sc_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00011, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amoswap_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00001, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amoadd_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00000, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amoxor_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00100, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amoand_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b01100, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amoor_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b01000, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amomin_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b10000, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amomax_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b10100, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amominu_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b11000, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::amomaxu_w(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b11100, aq, rl, 0b010, rd, rs1, rs2); -+} -+ -+// RV64A Standard Extension (in addition to RV32A) -+ -+void Assembler::lr_d(bool aq, bool rl, Register rd, Register rs1) { -+ GenInstrRAtomic(0b00010, aq, rl, 0b011, rd, rs1, zero_reg); -+} -+ -+void Assembler::sc_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00011, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amoswap_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00001, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amoadd_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00000, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amoxor_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b00100, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amoand_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b01100, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amoor_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b01000, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amomin_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b10000, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amomax_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b10100, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amominu_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b11000, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+void Assembler::amomaxu_d(bool aq, bool rl, Register rd, Register rs1, -+ Register rs2) { -+ GenInstrRAtomic(0b11100, aq, rl, 0b011, rd, rs1, rs2); -+} -+ -+// RV32F Standard Extension -+ -+void Assembler::flw(FPURegister rd, Register rs1, int16_t imm12) { -+ GenInstrLoadFP_ri(0b010, rd, rs1, imm12); -+} -+ -+void Assembler::fsw(FPURegister source, Register base, int16_t imm12) { -+ GenInstrStoreFP_rri(0b010, base, source, imm12); -+} -+ -+void Assembler::fmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b00, MADD, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b00, MSUB, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fnmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b00, NMSUB, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fnmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b00, NMADD, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0000000, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0000100, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fmul_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0001000, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fdiv_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0001100, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fsqrt_s(FPURegister rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b0101100, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fsgnj_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fsgnjn_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010000, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fsgnjx_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010000, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::fmin_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010100, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fmax_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010100, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fcvt_w_s(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_wu_s(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(1)); -+} -+ -+void Assembler::fmv_x_w(Register rd, FPURegister rs1) { -+ GenInstrALUFP_rr(0b1110000, 0b000, rd, rs1, zero_reg); -+} -+ -+void Assembler::feq_s(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010000, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::flt_s(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010000, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fle_s(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010000, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fclass_s(Register rd, FPURegister rs1) { -+ GenInstrALUFP_rr(0b1110000, 0b001, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_s_w(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_s_wu(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(1)); -+} -+ -+void Assembler::fmv_w_x(FPURegister rd, Register rs1) { -+ GenInstrALUFP_rr(0b1111000, 0b000, rd, rs1, zero_reg); -+} -+ -+// RV64F Standard Extension (in addition to RV32F) -+ -+void Assembler::fcvt_l_s(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(2)); -+} -+ -+void Assembler::fcvt_lu_s(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(3)); -+} -+ -+void Assembler::fcvt_s_l(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(2)); -+} -+ -+void Assembler::fcvt_s_lu(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(3)); -+} -+ -+// RV32D Standard Extension -+ -+void Assembler::fld(FPURegister rd, Register rs1, int16_t imm12) { -+ GenInstrLoadFP_ri(0b011, rd, rs1, imm12); -+} -+ -+void Assembler::fsd(FPURegister source, Register base, int16_t imm12) { -+ GenInstrStoreFP_rri(0b011, base, source, imm12); -+} -+ -+void Assembler::fmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b01, MADD, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b01, MSUB, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fnmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b01, NMSUB, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fnmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm) { -+ GenInstrR4(0b01, NMADD, rd, rs1, rs2, rs3, frm); -+} -+ -+void Assembler::fadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0000001, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0000101, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fmul_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0001001, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fdiv_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm) { -+ GenInstrALUFP_rr(0b0001101, frm, rd, rs1, rs2); -+} -+ -+void Assembler::fsqrt_d(FPURegister rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b0101101, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fsgnj_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010001, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fsgnjn_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010001, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fsgnjx_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010001, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::fmin_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010101, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fmax_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b0010101, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fcvt_s_d(FPURegister rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b0100000, frm, rd, rs1, ToRegister(1)); -+} -+ -+void Assembler::fcvt_d_s(FPURegister rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b0100001, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::feq_d(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010001, 0b010, rd, rs1, rs2); -+} -+ -+void Assembler::flt_d(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010001, 0b001, rd, rs1, rs2); -+} -+ -+void Assembler::fle_d(Register rd, FPURegister rs1, FPURegister rs2) { -+ GenInstrALUFP_rr(0b1010001, 0b000, rd, rs1, rs2); -+} -+ -+void Assembler::fclass_d(Register rd, FPURegister rs1) { -+ GenInstrALUFP_rr(0b1110001, 0b001, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_w_d(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_wu_d(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(1)); -+} -+ -+void Assembler::fcvt_d_w(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_d_wu(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(1)); -+} -+ -+// RV64D Standard Extension (in addition to RV32D) -+ -+void Assembler::fcvt_l_d(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(2)); -+} -+ -+void Assembler::fcvt_lu_d(Register rd, FPURegister rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(3)); -+} -+ -+void Assembler::fmv_x_d(Register rd, FPURegister rs1) { -+ GenInstrALUFP_rr(0b1110001, 0b000, rd, rs1, zero_reg); -+} -+ -+void Assembler::fcvt_d_l(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(2)); -+} -+ -+void Assembler::fcvt_d_lu(FPURegister rd, Register rs1, RoundingMode frm) { -+ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(3)); -+} -+ -+void Assembler::fmv_d_x(FPURegister rd, Register rs1) { -+ GenInstrALUFP_rr(0b1111001, 0b000, rd, rs1, zero_reg); -+} -+ -+// Privileged -+ -+void Assembler::uret() { -+ GenInstrPriv(0b0000000, ToRegister(0), ToRegister(0b00010)); -+} -+ -+void Assembler::sret() { -+ GenInstrPriv(0b0001000, ToRegister(0), ToRegister(0b00010)); -+} -+ -+void Assembler::mret() { -+ GenInstrPriv(0b0011000, ToRegister(0), ToRegister(0b00010)); -+} -+ -+void Assembler::wfi() { -+ GenInstrPriv(0b0001000, ToRegister(0), ToRegister(0b00101)); -+} -+ -+void Assembler::sfence_vma(Register rs1, Register rs2) { -+ GenInstrR(0b0001001, 0b000, SYSTEM, ToRegister(0), rs1, rs2); -+} -+ -+// Assembler Pseudo Instructions (Tables 25.2 and 25.3, RISC-V Unprivileged ISA) -+ -+void Assembler::nop() { addi(ToRegister(0), ToRegister(0), 0); } -+ -+void Assembler::RV_li(Register rd, int64_t imm) { -+ // 64-bit imm is put in the register rd. -+ // In most cases the imm is 32 bit and 2 instructions are generated. If a -+ // temporary register is available, in the worst case, 6 instructions are -+ // generated for a full 64-bit immediate. If temporay register is not -+ // available the maximum will be 8 instructions. If imm is more than 32 bits -+ // and a temp register is available, imm is divided into two 32-bit parts, -+ // low_32 and up_32. Each part is built in a separate register. low_32 is -+ // built before up_32. If low_32 is negative (upper 32 bits are 1), 0xffffffff -+ // is subtracted from up_32 before up_32 is built. This compensates for 32 -+ // bits of 1's in the lower when the two registers are added. If no temp is -+ // available, the upper 32 bit is built in rd, and the lower 32 bits are -+ // devided to 3 parts (11, 11, and 10 bits). The parts are shifted and added -+ // to the upper part built in rd. -+ if (is_int32(imm + 0x800)) { -+ // 32-bit case. Maximum of 2 instructions generated -+ int64_t high_20 = ((imm + 0x800) >> 12); -+ int64_t low_12 = imm << 52 >> 52; -+ if (high_20) { -+ lui(rd, (int32_t)high_20); -+ if (low_12) { -+ addi(rd, rd, low_12); -+ } -+ } else { -+ addi(rd, zero_reg, low_12); -+ } -+ return; -+ } else { -+ // 64-bit case: divide imm into two 32-bit parts, upper and lower -+ int64_t up_32 = imm >> 32; -+ int64_t low_32 = imm & 0xffffffffull; -+ Register temp_reg = rd; -+ // Check if a temporary register is available -+ if (up_32 == 0 || low_32 == 0) { -+ // No temp register is needed -+ } else { -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ temp_reg = temps.hasAvailable() ? temps.Acquire() : no_reg; -+ } -+ if (temp_reg != no_reg) { -+ // keep track of hardware behavior for lower part in sim_low -+ int64_t sim_low = 0; -+ // Build lower part -+ if (low_32 != 0) { -+ int64_t high_20 = ((low_32 + 0x800) >> 12); -+ int64_t low_12 = low_32 & 0xfff; -+ if (high_20) { -+ // Adjust to 20 bits for the case of overflow -+ high_20 &= 0xfffff; -+ sim_low = ((high_20 << 12) << 32) >> 32; -+ lui(rd, (int32_t)high_20); -+ if (low_12) { -+ sim_low += (low_12 << 52 >> 52) | low_12; -+ addi(rd, rd, low_12); -+ } -+ } else { -+ sim_low = low_12; -+ ori(rd, zero_reg, low_12); -+ } -+ } -+ if (sim_low & 0x100000000) { -+ // Bit 31 is 1. Either an overflow or a negative 64 bit -+ if (up_32 == 0) { -+ // Positive number, but overflow because of the add 0x800 -+ slli(rd, rd, 32); -+ srli(rd, rd, 32); -+ return; -+ } -+ // low_32 is a negative 64 bit after the build -+ up_32 = (up_32 - 0xffffffff) & 0xffffffff; -+ } -+ if (up_32 == 0) { -+ return; -+ } -+ // Build upper part in a temporary register -+ if (low_32 == 0) { -+ // Build upper part in rd -+ temp_reg = rd; -+ } -+ int64_t high_20 = (up_32 + 0x800) >> 12; -+ int64_t low_12 = up_32 & 0xfff; -+ if (high_20) { -+ // Adjust to 20 bits for the case of overflow -+ high_20 &= 0xfffff; -+ lui(temp_reg, (int32_t)high_20); -+ if (low_12) { -+ addi(temp_reg, temp_reg, low_12); -+ } -+ } else { -+ ori(temp_reg, zero_reg, low_12); -+ } -+ // Put it at the bgining of register -+ slli(temp_reg, temp_reg, 32); -+ if (low_32 != 0) { -+ add(rd, rd, temp_reg); -+ } -+ return; -+ } -+ // No temp register. Build imm in rd. -+ // Build upper 32 bits first in rd. Divide lower 32 bits parts and add -+ // parts to the upper part by doing shift and add. -+ // First build upper part in rd. -+ int64_t high_20 = (up_32 + 0x800) >> 12; -+ int64_t low_12 = up_32 & 0xfff; -+ if (high_20) { -+ // Adjust to 20 bits for the case of overflow -+ high_20 &= 0xfffff; -+ lui(rd, (int32_t)high_20); -+ if (low_12) { -+ addi(rd, rd, low_12); -+ } -+ } else { -+ ori(rd, zero_reg, low_12); -+ } -+ // upper part already in rd. Each part to be added to rd, has maximum of 11 -+ // bits, and always starts with a 1. rd is shifted by the size of the part -+ // plus the number of zeros between the parts. Each part is added after the -+ // left shift. -+ uint32_t mask = 0x80000000; -+ int32_t shift_val = 0; -+ int32_t i; -+ for (i = 0; i < 32; i++) { -+ if ((low_32 & mask) == 0) { -+ mask >>= 1; -+ shift_val++; -+ if (i == 31) { -+ // rest is zero -+ slli(rd, rd, shift_val); -+ } -+ continue; -+ } -+ // The first 1 seen -+ int32_t part; -+ if ((i + 11) < 32) { -+ // Pick 11 bits -+ part = ((uint32_t)(low_32 << i) >> i) >> (32 - (i + 11)); -+ slli(rd, rd, shift_val + 11); -+ ori(rd, rd, part); -+ i += 10; -+ mask >>= 11; -+ } else { -+ part = (uint32_t)(low_32 << i) >> i; -+ slli(rd, rd, shift_val + (32 - i)); -+ ori(rd, rd, part); -+ break; -+ } -+ shift_val = 0; -+ } -+ } -+} -+ -+int Assembler::li_count(int64_t imm) { -+ int count = 0; -+ if (is_int32(imm + 0x800)) { -+ int64_t Hi20 = ((imm + 0x800) >> 12); -+ int64_t Lo12 = imm << 52 >> 52; -+ -+ if (Hi20) count++; -+ -+ if (Lo12 || Hi20 == 0) count++; -+ return count; -+ } -+ -+ int64_t Lo12 = imm << 52 >> 52; -+ int64_t Hi52 = ((uint64_t)imm + 0x800ull) >> 12; -+ int FirstBit = 0; -+ uint64_t Val = Hi52; -+ while ((Val & 1) == 0) { -+ Val = Val >> 1; -+ FirstBit++; -+ } -+ int ShiftAmount = 12 + FirstBit; -+ Hi52 = (Hi52 >> (ShiftAmount - 12)) << ShiftAmount >> ShiftAmount; -+ -+ count += li_count(Hi52); -+ -+ count++; -+ if (Lo12) count++; -+ -+ return count; -+} -+ -+void Assembler::li_constant(Register rd, int64_t imm) { -+ DEBUG_PRINTF("li_constant(%d, %lx <%ld>)\n", ToNumber(rd), imm, imm); -+ lui(rd, (imm + (1LL << 47) + (1LL << 35) + (1LL << 23) + (1LL << 11)) >> -+ 48); // Bits 63:48 -+ addiw(rd, rd, -+ (imm + (1LL << 35) + (1LL << 23) + (1LL << 11)) << 16 >> -+ 52); // Bits 47:36 -+ slli(rd, rd, 12); -+ addi(rd, rd, (imm + (1LL << 23) + (1LL << 11)) << 28 >> 52); // Bits 35:24 -+ slli(rd, rd, 12); -+ addi(rd, rd, (imm + (1LL << 11)) << 40 >> 52); // Bits 23:12 -+ slli(rd, rd, 12); -+ addi(rd, rd, imm << 52 >> 52); // Bits 11:0 -+} -+ -+// Break / Trap instructions. -+void Assembler::break_(uint32_t code, bool break_as_stop) { -+ // We need to invalidate breaks that could be stops as well because the -+ // simulator expects a char pointer after the stop instruction. -+ // See constants-mips.h for explanation. -+ DCHECK( -+ (break_as_stop && code <= kMaxStopCode && code > kMaxWatchpointCode) || -+ (!break_as_stop && (code > kMaxStopCode || code <= kMaxWatchpointCode))); -+ -+ // since ebreak does not allow additional immediate field, we use the -+ // immediate field of lui instruction immediately following the ebreak to -+ // encode the "code" info -+ ebreak(); -+ DCHECK(is_uint20(code)); -+ lui(zero_reg, code); -+} -+ -+void Assembler::stop(uint32_t code) { -+ DCHECK_GT(code, kMaxWatchpointCode); -+ DCHECK_LE(code, kMaxStopCode); -+#if defined(V8_HOST_ARCH_RISCV64) -+ // FIXME: does RISCV expect a special value? -+ break_(0x54321); -+#else // V8_HOST_ARCH_RISCV64 -+ break_(code, true); -+#endif -+} -+ -+// Original MIPS Instructions -+ -+// ------------Memory-instructions------------- -+ -+bool Assembler::NeedAdjustBaseAndOffset(const MemOperand& src, -+ OffsetAccessType access_type, -+ int second_access_add_to_offset) { -+ bool two_accesses = static_cast(access_type); -+ DCHECK_LE(second_access_add_to_offset, 7); // Must be <= 7. -+ -+ // is_int12 must be passed a signed value, hence the static cast below. -+ if (is_int12(src.offset()) && -+ (!two_accesses || is_int12(static_cast( -+ src.offset() + second_access_add_to_offset)))) { -+ // Nothing to do: 'offset' (and, if needed, 'offset + 4', or other specified -+ // value) fits into int12. -+ return false; -+ } -+ return true; -+} -+ -+void Assembler::AdjustBaseAndOffset(MemOperand* src, Register scratch, -+ OffsetAccessType access_type, -+ int second_Access_add_to_offset) { -+ // This method is used to adjust the base register and offset pair -+ // for a load/store when the offset doesn't fit into int12. -+ -+ // Must not overwrite the register 'base' while loading 'offset'. -+ DCHECK(src->rm() != scratch); -+ -+ // FIXME(RISC-V): There may be a more optimal way to do this -+ RV_li(scratch, src->offset()); -+ add(scratch, scratch, src->rm()); -+ src->offset_ = 0; -+ src->rm_ = scratch; -+} -+ -+// FIXME (RISCV): not yet ported (or not used?) -+int Assembler::RelocateInternalReference(RelocInfo::Mode rmode, Address pc, -+ intptr_t pc_delta) { -+ if (RelocInfo::IsInternalReference(rmode)) { -+ int64_t* p = reinterpret_cast(pc); -+ if (*p == kEndOfJumpChain) { -+ return 0; // Number of instructions patched. -+ } -+ *p += pc_delta; -+ return 2; // Number of instructions patched. -+ } -+ Instr instr = instr_at(pc); -+ DCHECK(RelocInfo::IsInternalReferenceEncoded(rmode)); -+ if (IsLui(instr)) { -+ uint64_t target_address = target_address_at(pc) + pc_delta; -+ DEBUG_PRINTF("target_address 0x%lx\n", target_address); -+ set_target_value_at(pc, target_address); -+ return 8; // Number of instructions patched. -+ } else { -+ UNIMPLEMENTED(); -+ return 1; -+ } -+} -+ -+void Assembler::GrowBuffer() { -+ DEBUG_PRINTF("GrowBuffer: %p -> ", buffer_start_); -+ // Compute new buffer size. -+ int old_size = buffer_->size(); -+ int new_size = std::min(2 * old_size, old_size + 1 * MB); -+ -+ // Some internal data structures overflow for very large buffers, -+ // they must ensure that kMaximalBufferSize is not too large. -+ if (new_size > kMaximalBufferSize) { -+ V8::FatalProcessOutOfMemory(nullptr, "Assembler::GrowBuffer"); -+ } -+ -+ // Set up new buffer. -+ std::unique_ptr new_buffer = buffer_->Grow(new_size); -+ DCHECK_EQ(new_size, new_buffer->size()); -+ byte* new_start = new_buffer->start(); -+ -+ // Copy the data. -+ intptr_t pc_delta = new_start - buffer_start_; -+ intptr_t rc_delta = (new_start + new_size) - (buffer_start_ + old_size); -+ size_t reloc_size = (buffer_start_ + old_size) - reloc_info_writer.pos(); -+ MemMove(new_start, buffer_start_, pc_offset()); -+ MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(), -+ reloc_size); -+ -+ // Switch buffers. -+ buffer_ = std::move(new_buffer); -+ buffer_start_ = new_start; -+ DEBUG_PRINTF("%p\n", buffer_start_); -+ pc_ += pc_delta; -+ reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, -+ reloc_info_writer.last_pc() + pc_delta); -+ -+ // Relocate runtime entries. -+ Vector instructions{buffer_start_, (size_t)pc_offset()}; -+ Vector reloc_info{reloc_info_writer.pos(), reloc_size}; -+ for (RelocIterator it(instructions, reloc_info, 0); !it.done(); it.next()) { -+ RelocInfo::Mode rmode = it.rinfo()->rmode(); -+ if (rmode == RelocInfo::INTERNAL_REFERENCE) { -+ RelocateInternalReference(rmode, it.rinfo()->pc(), pc_delta); -+ } -+ } -+ DCHECK(!overflow()); -+} -+ -+void Assembler::db(uint8_t data) { -+ if (!is_buffer_growth_blocked()) CheckBuffer(); -+ EmitHelper(data); -+} -+ -+void Assembler::dd(uint32_t data) { -+ if (!is_buffer_growth_blocked()) CheckBuffer(); -+ EmitHelper(data); -+} -+ -+void Assembler::dq(uint64_t data) { -+ if (!is_buffer_growth_blocked()) CheckBuffer(); -+ EmitHelper(data); -+} -+ -+void Assembler::dd(Label* label) { -+ uint64_t data; -+ if (!is_buffer_growth_blocked()) CheckBuffer(); -+ if (label->is_bound()) { -+ data = reinterpret_cast(buffer_start_ + label->pos()); -+ } else { -+ data = jump_address(label); -+ internal_reference_positions_.insert(label->pos()); -+ } -+ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE); -+ EmitHelper(data); -+} -+ -+void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { -+ if (!ShouldRecordRelocInfo(rmode)) return; -+ // We do not try to reuse pool constants. -+ RelocInfo rinfo(reinterpret_cast
(pc_), rmode, data, Code()); -+ DCHECK_GE(buffer_space(), kMaxRelocSize); // Too late to grow buffer here. -+ reloc_info_writer.Write(&rinfo); -+} -+ -+void Assembler::BlockTrampolinePoolFor(int instructions) { -+ CheckTrampolinePoolQuick(instructions); -+ BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); -+} -+ -+void Assembler::CheckTrampolinePool() { -+ // Some small sequences of instructions must not be broken up by the -+ // insertion of a trampoline pool; such sequences are protected by setting -+ // either trampoline_pool_blocked_nesting_ or no_trampoline_pool_before_, -+ // which are both checked here. Also, recursive calls to CheckTrampolinePool -+ // are blocked by trampoline_pool_blocked_nesting_. -+ if ((trampoline_pool_blocked_nesting_ > 0) || -+ (pc_offset() < no_trampoline_pool_before_)) { -+ // Emission is currently blocked; make sure we try again as soon as -+ // possible. -+ if (trampoline_pool_blocked_nesting_ > 0) { -+ next_buffer_check_ = pc_offset() + kInstrSize; -+ } else { -+ next_buffer_check_ = no_trampoline_pool_before_; -+ } -+ return; -+ } -+ -+ DCHECK(!trampoline_emitted_); -+ DCHECK_GE(unbound_labels_count_, 0); -+ if (unbound_labels_count_ > 0) { -+ // First we emit jump, then we emit trampoline pool. -+ { -+ DEBUG_PRINTF("inserting trampoline pool at %p (%d)\n", -+ reinterpret_cast(buffer_start_ + pc_offset()), -+ pc_offset()); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Label after_pool; -+ j(&after_pool); -+ -+ int pool_start = pc_offset(); -+ for (int i = 0; i < unbound_labels_count_; i++) { -+ int64_t imm64; -+ imm64 = branch_long_offset(&after_pool); -+ DCHECK(is_int32(imm64)); -+ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); -+ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; -+ auipc(t5, Hi20); // Read PC + Hi20 into t5. -+ jr(t5, Lo12); // jump PC + Hi20 + Lo12 -+ } -+ // If unbound_labels_count_ is big enough, label after_pool will -+ // need a trampoline too, so we must create the trampoline before -+ // the bind operation to make sure function 'bind' can get this -+ // information. -+ trampoline_ = Trampoline(pool_start, unbound_labels_count_); -+ bind(&after_pool); -+ -+ trampoline_emitted_ = true; -+ // As we are only going to emit trampoline once, we need to prevent any -+ // further emission. -+ next_buffer_check_ = kMaxInt; -+ } -+ } else { -+ // Number of branches to unbound label at this point is zero, so we can -+ // move next buffer check to maximum. -+ next_buffer_check_ = -+ pc_offset() + kMaxBranchOffset - kTrampolineSlotsSize * 16; -+ } -+ return; -+} -+ -+Address Assembler::target_address_at(Address pc) { -+ DEBUG_PRINTF("target_address_at: pc: %lx\t", pc); -+ Instruction* instr0 = Instruction::At((unsigned char*)pc); -+ Instruction* instr1 = Instruction::At((unsigned char*)(pc + 1 * kInstrSize)); -+ Instruction* instr3 = Instruction::At((unsigned char*)(pc + 3 * kInstrSize)); -+ Instruction* instr5 = Instruction::At((unsigned char*)(pc + 5 * kInstrSize)); -+ Instruction* instr7 = Instruction::At((unsigned char*)(pc + 7 * kInstrSize)); -+ -+ // Interpret 5 instructions for address generated by li: See listing in -+ // Assembler::set_target_address_at() just below. -+ if (IsLui(*reinterpret_cast(instr0)) && -+ IsAddiw(*reinterpret_cast(instr1)) && -+ IsAddi(*reinterpret_cast(instr3)) && -+ IsAddi(*reinterpret_cast(instr5)) && -+ IsAddi(*reinterpret_cast(instr7))) { -+ // Assemble the 64 bit value. -+ int64_t addr = (int64_t)(instr0->Imm20UValue() << kImm20Shift) + -+ (int64_t)instr1->Imm12Value(); -+ addr <<= 12; -+ addr += (int64_t)instr3->Imm12Value(); -+ addr <<= 12; -+ addr += (int64_t)instr5->Imm12Value(); -+ addr <<= 12; -+ addr += (int64_t)instr7->Imm12Value(); -+ -+ DEBUG_PRINTF("addr: %lx\n", addr); -+ return static_cast
(addr); -+ } -+ // We should never get here, force a bad address if we do. -+ UNREACHABLE(); -+} -+ -+// On RISC-V, a 64-bit target address is stored in an 8-instruction sequence: -+// 0: lui(rd, (j.imm64_ + (1LL << 47) + (1LL << 35) + -+// (1LL << 23) + (1LL << 11)) >> 48); -+// 1: addiw(rd, rd, (j.imm64_ + (1LL << 35) + (1LL << 23) + (1LL << 11)) -+// << 16 >> 52); -+// 2: slli(rd, rd, 12); -+// 3: addi(rd, rd, (j.imm64_ + (1LL << 23) + (1LL << 11)) << 28 >> 52); -+// 4: slli(rd, rd, 12); -+// 5: addi(rd, rd, (j.imm64_ + (1 << 11)) << 40 >> 52); -+// 6: slli(rd, rd, 12); -+// 7: addi(rd, rd, j.imm64_ << 52 >> 52); -+// -+// Patching the address must replace all the lui & addi instructions, -+// and flush the i-cache. -+void Assembler::set_target_value_at(Address pc, uint64_t target, -+ ICacheFlushMode icache_flush_mode) { -+ // FIXME(RISC-V): Does the below statement apply to RISC-V? If so, we do not -+ // need all 8 instructions. -+ // There is an optimization where only 4 instructions are used to load address -+ // in code on MIP64 because only 48-bits of address is effectively used. -+ // It relies on fact the upper [63:48] bits are not used for virtual address -+ // translation and they have to be set according to value of bit 47 in order -+ // get canonical address. -+ Instruction* instr0 = Instruction::At((unsigned char*)pc); -+ DEBUG_PRINTF("set_target_value_at: pc: %lx\ttarget: %lx\n", pc, target); -+ int rd_code = instr0->RdValue(); -+ uint32_t* p = reinterpret_cast(pc); -+ -+#ifdef DEBUG -+ // Check we have the result from a li macro-instruction. -+ Instruction* instr1 = Instruction::At((unsigned char*)(pc + 1 * kInstrSize)); -+ Instruction* instr3 = Instruction::At((unsigned char*)(pc + 3 * kInstrSize)); -+ Instruction* instr5 = Instruction::At((unsigned char*)(pc + 5 * kInstrSize)); -+ Instruction* instr7 = Instruction::At((unsigned char*)(pc + 7 * kInstrSize)); -+ DCHECK(IsLui(*reinterpret_cast(instr0)) && -+ IsAddiw(*reinterpret_cast(instr1)) && -+ IsAddi(*reinterpret_cast(instr3)) && -+ IsAddi(*reinterpret_cast(instr5)) && -+ IsAddi(*reinterpret_cast(instr7))); -+#endif -+ -+ // Must use 8 instructions to insure patchable code (see above comment). -+ *p = LUI | (rd_code << kRdShift) | -+ ((uint32_t)( -+ (target + (1LL << 47) + (1LL << 35) + (1LL << 23) + (1LL << 11)) >> -+ 48) -+ << kImm20Shift); -+ *(p + 1) = -+ OP_IMM_32 | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | -+ ((uint32_t)((target + (1LL << 35) + (1LL << 23) + (1LL << 11)) << 16 >> -+ 52) -+ << kImm12Shift); -+ *(p + 2) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | (12 << kImm12Shift); -+ *(p + 3) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | -+ ((uint32_t)((target + (1LL << 23) + (1LL << 11)) << 28 >> 52) -+ << kImm12Shift); -+ *(p + 4) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | (12 << kImm12Shift); -+ *(p + 5) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | -+ ((uint32_t)((target + (1LL << 11)) << 40 >> 52) << kImm12Shift); -+ *(p + 6) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | (12 << kImm12Shift); -+ *(p + 7) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | -+ (rd_code << kRs1Shift) | -+ ((uint32_t)(target << 52 >> 52) << kImm12Shift); -+ -+ if (icache_flush_mode != SKIP_ICACHE_FLUSH) { -+ FlushInstructionCache(pc, 8 * kInstrSize); -+ } -+ DCHECK_EQ(target_address_at(pc), target); -+} -+ -+UseScratchRegisterScope::UseScratchRegisterScope(Assembler* assembler) -+ : available_(assembler->GetScratchRegisterList()), -+ old_available_(*available_) {} -+ -+UseScratchRegisterScope::~UseScratchRegisterScope() { -+ *available_ = old_available_; -+} -+ -+Register UseScratchRegisterScope::Acquire() { -+ DCHECK_NOT_NULL(available_); -+ DCHECK_NE(*available_, 0); -+ int index = static_cast(base::bits::CountTrailingZeros32(*available_)); -+ *available_ &= ~(1UL << index); -+ -+ return Register::from_code(index); -+} -+ -+bool UseScratchRegisterScope::hasAvailable() const { return *available_ != 0; } -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64.h -@@ -0,0 +1,1110 @@ -+// Copyright (c) 1994-2006 Sun Microsystems Inc. -+// All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, with or without -+// modification, are permitted provided that the following conditions are -+// met: -+// -+// - Redistributions of source code must retain the above copyright notice, -+// this list of conditions and the following disclaimer. -+// -+// - Redistribution in binary form must reproduce the above copyright -+// notice, this list of conditions and the following disclaimer in the -+// documentation and/or other materials provided with the distribution. -+// -+// - Neither the name of Sun Microsystems or the names of contributors may -+// be used to endorse or promote products derived from this software without -+// specific prior written permission. -+// -+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -+// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+// The original source code covered by the above license above has been -+// modified significantly by Google Inc. -+// Copyright 2012 the V8 project authors. All rights reserved. -+ -+#ifndef V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ -+#define V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ -+ -+#include -+ -+#include -+#include -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/external-reference.h" -+#include "src/codegen/label.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/codegen/riscv64/register-riscv64.h" -+#include "src/objects/contexts.h" -+#include "src/objects/smi.h" -+ -+namespace v8 { -+namespace internal { -+ -+class SafepointTableBuilder; -+ -+// ----------------------------------------------------------------------------- -+// Machine instruction Operands. -+constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize; -+constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; -+// Class Operand represents a shifter operand in data processing instructions. -+class Operand { -+ public: -+ // Immediate. -+ V8_INLINE explicit Operand(int64_t immediate, -+ RelocInfo::Mode rmode = RelocInfo::NONE) -+ : rm_(no_reg), rmode_(rmode) { -+ value_.immediate = immediate; -+ } -+ V8_INLINE explicit Operand(const ExternalReference& f) -+ : rm_(no_reg), rmode_(RelocInfo::EXTERNAL_REFERENCE) { -+ value_.immediate = static_cast(f.address()); -+ } -+ V8_INLINE explicit Operand(const char* s); -+ explicit Operand(Handle handle); -+ V8_INLINE explicit Operand(Smi value) : rm_(no_reg), rmode_(RelocInfo::NONE) { -+ value_.immediate = static_cast(value.ptr()); -+ } -+ -+ static Operand EmbeddedNumber(double number); // Smi or HeapNumber. -+ static Operand EmbeddedStringConstant(const StringConstantBase* str); -+ -+ // Register. -+ V8_INLINE explicit Operand(Register rm) : rm_(rm) {} -+ -+ // Return true if this is a register operand. -+ V8_INLINE bool is_reg() const; -+ -+ inline int64_t immediate() const; -+ -+ bool IsImmediate() const { return !rm_.is_valid(); } -+ -+ HeapObjectRequest heap_object_request() const { -+ DCHECK(IsHeapObjectRequest()); -+ return value_.heap_object_request; -+ } -+ -+ bool IsHeapObjectRequest() const { -+ DCHECK_IMPLIES(is_heap_object_request_, IsImmediate()); -+ DCHECK_IMPLIES(is_heap_object_request_, -+ rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT || -+ rmode_ == RelocInfo::CODE_TARGET); -+ return is_heap_object_request_; -+ } -+ -+ Register rm() const { return rm_; } -+ -+ RelocInfo::Mode rmode() const { return rmode_; } -+ -+ private: -+ Register rm_; -+ union Value { -+ Value() {} -+ HeapObjectRequest heap_object_request; // if is_heap_object_request_ -+ int64_t immediate; // otherwise -+ } value_; // valid if rm_ == no_reg -+ bool is_heap_object_request_ = false; -+ RelocInfo::Mode rmode_; -+ -+ friend class Assembler; -+ friend class MacroAssembler; -+}; -+ -+// On RISC-V we have only one addressing mode with base_reg + offset. -+// Class MemOperand represents a memory operand in load and store instructions. -+class V8_EXPORT_PRIVATE MemOperand : public Operand { -+ public: -+ // Immediate value attached to offset. -+ enum OffsetAddend { offset_minus_one = -1, offset_zero = 0 }; -+ -+ explicit MemOperand(Register rn, int32_t offset = 0); -+ explicit MemOperand(Register rn, int32_t unit, int32_t multiplier, -+ OffsetAddend offset_addend = offset_zero); -+ int32_t offset() const { return offset_; } -+ -+ bool OffsetIsInt12Encodable() const { return is_int12(offset_); } -+ -+ private: -+ int32_t offset_; -+ -+ friend class Assembler; -+}; -+ -+class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { -+ public: -+ // Create an assembler. Instructions and relocation information are emitted -+ // into a buffer, with the instructions starting from the beginning and the -+ // relocation information starting from the end of the buffer. See CodeDesc -+ // for a detailed comment on the layout (globals.h). -+ // -+ // If the provided buffer is nullptr, the assembler allocates and grows its -+ // own buffer. Otherwise it takes ownership of the provided buffer. -+ explicit Assembler(const AssemblerOptions&, -+ std::unique_ptr = {}); -+ -+ virtual ~Assembler() {} -+ -+ // GetCode emits any pending (non-emitted) code and fills the descriptor desc. -+ static constexpr int kNoHandlerTable = 0; -+ static constexpr SafepointTableBuilder* kNoSafepointTable = nullptr; -+ void GetCode(Isolate* isolate, CodeDesc* desc, -+ SafepointTableBuilder* safepoint_table_builder, -+ int handler_table_offset); -+ -+ // Convenience wrapper for code without safepoint or handler tables. -+ void GetCode(Isolate* isolate, CodeDesc* desc) { -+ GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable); -+ } -+ -+ // Unused on this architecture. -+ void MaybeEmitOutOfLineConstantPool() {} -+ -+ // Label operations & relative jumps (PPUM Appendix D). -+ // -+ // Takes a branch opcode (cc) and a label (L) and generates -+ // either a backward branch or a forward branch and links it -+ // to the label fixup chain. Usage: -+ // -+ // Label L; // unbound label -+ // j(cc, &L); // forward branch to unbound label -+ // bind(&L); // bind label to the current pc -+ // j(cc, &L); // backward branch to bound label -+ // bind(&L); // illegal: a label may be bound only once -+ // -+ // Note: The same Label can be used for forward and backward branches -+ // but it may be bound only once. -+ void bind(Label* L); // Binds an unbound label L to current code position. -+ -+ enum OffsetSize : int { -+ kOffset21 = 21, // RISCV jal -+ kOffset12 = 12, // RISCV imm12 -+ kOffset20 = 20, // RISCV imm20 -+ kOffset13 = 13 // RISCV branch -+ }; -+ -+ // Determines if Label is bound and near enough so that branch instruction -+ // can be used to reach it, instead of jump instruction. -+ bool is_near(Label* L); -+ bool is_near(Label* L, OffsetSize bits); -+ bool is_near_branch(Label* L); -+ -+ //Get offset from instr. -+ int BranchOffset(Instr instr); -+ int BrachlongOffset(Instr auipc, Instr jalr); -+ int JumpOffset(Instr instr); -+ -+ // Returns the branch offset to the given label from the current code -+ // position. Links the label to the current position if it is still unbound. -+ // Manages the jump elimination optimization if the second parameter is true. -+ int32_t branch_offset_helper(Label* L, OffsetSize bits); -+ inline int32_t branch_offset(Label* L) { -+ return branch_offset_helper(L, OffsetSize::kOffset13); -+ } -+ inline int32_t jump_offset(Label* L) { -+ return branch_offset_helper(L, OffsetSize::kOffset21); -+ } -+ -+ uint64_t jump_address(Label* L); -+ uint64_t branch_long_offset(Label* L); -+ -+ // Puts a labels target address at the given position. -+ // The high 8 bits are set to zero. -+ void label_at_put(Label* L, int at_offset); -+ -+ // Read/Modify the code target address in the branch/call instruction at pc. -+ // The isolate argument is unused (and may be nullptr) when skipping flushing. -+ static Address target_address_at(Address pc); -+ V8_INLINE static void set_target_address_at( -+ Address pc, Address target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { -+ set_target_value_at(pc, target, icache_flush_mode); -+ } -+ // On RISC-V there is no Constant Pool so we skip that parameter. -+ V8_INLINE static Address target_address_at(Address pc, -+ Address constant_pool) { -+ return target_address_at(pc); -+ } -+ V8_INLINE static void set_target_address_at( -+ Address pc, Address constant_pool, Address target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { -+ set_target_address_at(pc, target, icache_flush_mode); -+ } -+ -+ static void set_target_value_at( -+ Address pc, uint64_t target, -+ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); -+ -+ static void JumpLabelToJumpRegister(Address pc); -+ -+ // This sets the branch destination (which gets loaded at the call address). -+ // This is for calls and branches within generated code. The serializer -+ // has already deserialized the lui/ori instructions etc. -+ inline static void deserialization_set_special_target_at( -+ Address instruction_payload, Code code, Address target); -+ -+ // Get the size of the special target encoded at 'instruction_payload'. -+ inline static int deserialization_special_target_size( -+ Address instruction_payload); -+ -+ // This sets the internal reference at the pc. -+ inline static void deserialization_set_target_internal_reference_at( -+ Address pc, Address target, -+ RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); -+ -+ // Difference between address of current opcode and target address offset. -+ static constexpr int kBranchPCOffset = kInstrSize; -+ -+ // Difference between address of current opcode and target address offset, -+ // when we are generatinga sequence of instructions for long relative PC -+ // branches -+ static constexpr int kLongBranchPCOffset = 3 * kInstrSize; -+ -+ // Adjust ra register in branch delay slot of bal instruction so to skip -+ // instructions not needed after optimization of PIC in -+ // TurboAssembler::BranchAndLink method. -+ -+ static constexpr int kOptimizedBranchAndLinkLongReturnOffset = 4 * kInstrSize; -+ -+ // Here we are patching the address in the LUI/ADDI instruction pair. -+ // These values are used in the serialization process and must be zero for -+ // RISC-V platform, as Code, Embedded Object or External-reference pointers -+ // are split across two consecutive instructions and don't exist separately -+ // in the code, so the serializer should not step forwards in memory after -+ // a target is resolved and written. -+ static constexpr int kSpecialTargetSize = 0; -+ -+ // Number of consecutive instructions used to store 32bit/64bit constant. -+ // This constant was used in RelocInfo::target_address_address() function -+ // to tell serializer address of the instruction that follows -+ // LUI/ADDI instruction pair. -+ static constexpr int kInstructionsFor32BitConstant = 2; -+ static constexpr int kInstructionsFor64BitConstant = 8; -+ -+ // Difference between address of current opcode and value read from pc -+ // register. -+ static constexpr int kPcLoadDelta = 4; -+ -+ // Bits available for offset field in branches -+ static constexpr int kBranchOffsetBits = 13; -+ -+ // Bits available for offset field in jump -+ static constexpr int kJumpOffsetBits = 21; -+ -+ // Max offset for b instructions with 12-bit offset field (multiple of 2) -+ static constexpr int kMaxBranchOffset = (1 << (13 - 1)) - 1; -+ -+ // Max offset for jal instruction with 20-bit offset field (multiple of 2) -+ static constexpr int kMaxJumpOffset = (1 << (21 - 1)) - 1; -+ -+ static constexpr int kTrampolineSlotsSize = 2 * kInstrSize; -+ -+ RegList* GetScratchRegisterList() { return &scratch_register_list_; } -+ -+ // --------------------------------------------------------------------------- -+ // Code generation. -+ -+ // Insert the smallest number of nop instructions -+ // possible to align the pc offset to a multiple -+ // of m. m must be a power of 2 (>= 4). -+ void Align(int m); -+ // Insert the smallest number of zero bytes possible to align the pc offset -+ // to a mulitple of m. m must be a power of 2 (>= 2). -+ void DataAlign(int m); -+ // Aligns code to something that's optimal for a jump target for the platform. -+ void CodeTargetAlign(); -+ -+ // Different nop operations are used by the code generator to detect certain -+ // states of the generated code. -+ enum NopMarkerTypes { -+ NON_MARKING_NOP = 0, -+ DEBUG_BREAK_NOP, -+ // IC markers. -+ PROPERTY_ACCESS_INLINED, -+ PROPERTY_ACCESS_INLINED_CONTEXT, -+ PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, -+ // Helper values. -+ LAST_CODE_MARKER, -+ FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED, -+ }; -+ -+ // RISC-V Instructions Emited to a buffer -+ -+ void lui(Register rd, int32_t imm20); -+ void auipc(Register rd, int32_t imm20); -+ -+ // Jumps -+ void jal(Register rd, int32_t imm20); -+ void jalr(Register rd, Register rs1, int16_t imm12); -+ -+ // Branches -+ void beq(Register rs1, Register rs2, int16_t imm12); -+ inline void beq(Register rs1, Register rs2, Label* L) { -+ beq(rs1, rs2, branch_offset(L)); -+ } -+ void bne(Register rs1, Register rs2, int16_t imm12); -+ inline void bne(Register rs1, Register rs2, Label* L) { -+ bne(rs1, rs2, branch_offset(L)); -+ } -+ void blt(Register rs1, Register rs2, int16_t imm12); -+ inline void blt(Register rs1, Register rs2, Label* L) { -+ blt(rs1, rs2, branch_offset(L)); -+ } -+ void bge(Register rs1, Register rs2, int16_t imm12); -+ inline void bge(Register rs1, Register rs2, Label* L) { -+ bge(rs1, rs2, branch_offset(L)); -+ } -+ void bltu(Register rs1, Register rs2, int16_t imm12); -+ inline void bltu(Register rs1, Register rs2, Label* L) { -+ bltu(rs1, rs2, branch_offset(L)); -+ } -+ void bgeu(Register rs1, Register rs2, int16_t imm12); -+ inline void bgeu(Register rs1, Register rs2, Label* L) { -+ bgeu(rs1, rs2, branch_offset(L)); -+ } -+ -+ // Loads -+ void lb(Register rd, Register rs1, int16_t imm12); -+ void lh(Register rd, Register rs1, int16_t imm12); -+ void lw(Register rd, Register rs1, int16_t imm12); -+ void lbu(Register rd, Register rs1, int16_t imm12); -+ void lhu(Register rd, Register rs1, int16_t imm12); -+ -+ // Stores -+ void sb(Register source, Register base, int16_t imm12); -+ void sh(Register source, Register base, int16_t imm12); -+ void sw(Register source, Register base, int16_t imm12); -+ -+ // Arithmetic with immediate -+ void addi(Register rd, Register rs1, int16_t imm12); -+ void slti(Register rd, Register rs1, int16_t imm12); -+ void sltiu(Register rd, Register rs1, int16_t imm12); -+ void xori(Register rd, Register rs1, int16_t imm12); -+ void ori(Register rd, Register rs1, int16_t imm12); -+ void andi(Register rd, Register rs1, int16_t imm12); -+ void slli(Register rd, Register rs1, uint8_t shamt); -+ void srli(Register rd, Register rs1, uint8_t shamt); -+ void srai(Register rd, Register rs1, uint8_t shamt); -+ -+ // Arithmetic -+ void add(Register rd, Register rs1, Register rs2); -+ void sub(Register rd, Register rs1, Register rs2); -+ void sll(Register rd, Register rs1, Register rs2); -+ void slt(Register rd, Register rs1, Register rs2); -+ void sltu(Register rd, Register rs1, Register rs2); -+ void xor_(Register rd, Register rs1, Register rs2); -+ void srl(Register rd, Register rs1, Register rs2); -+ void sra(Register rd, Register rs1, Register rs2); -+ void or_(Register rd, Register rs1, Register rs2); -+ void and_(Register rd, Register rs1, Register rs2); -+ -+ // Memory fences -+ void fence(uint8_t pred, uint8_t succ); -+ void fence_tso(); -+ -+ // Environment call / break -+ void ecall(); -+ void ebreak(); -+ -+ // This is a de facto standard (as set by GNU binutils) 32-bit unimplemented -+ // instruction (i.e., it should always trap, if your implementation has -+ // invalid instruction traps). -+ void unimp(); -+ -+ // CSR -+ void csrrw(Register rd, ControlStatusReg csr, Register rs1); -+ void csrrs(Register rd, ControlStatusReg csr, Register rs1); -+ void csrrc(Register rd, ControlStatusReg csr, Register rs1); -+ void csrrwi(Register rd, ControlStatusReg csr, uint8_t imm5); -+ void csrrsi(Register rd, ControlStatusReg csr, uint8_t imm5); -+ void csrrci(Register rd, ControlStatusReg csr, uint8_t imm5); -+ -+ // RV64I -+ void lwu(Register rd, Register rs1, int16_t imm12); -+ void ld(Register rd, Register rs1, int16_t imm12); -+ void sd(Register source, Register base, int16_t imm12); -+ void addiw(Register rd, Register rs1, int16_t imm12); -+ void slliw(Register rd, Register rs1, uint8_t shamt); -+ void srliw(Register rd, Register rs1, uint8_t shamt); -+ void sraiw(Register rd, Register rs1, uint8_t shamt); -+ void addw(Register rd, Register rs1, Register rs2); -+ void subw(Register rd, Register rs1, Register rs2); -+ void sllw(Register rd, Register rs1, Register rs2); -+ void srlw(Register rd, Register rs1, Register rs2); -+ void sraw(Register rd, Register rs1, Register rs2); -+ -+ // RV32M Standard Extension -+ void mul(Register rd, Register rs1, Register rs2); -+ void mulh(Register rd, Register rs1, Register rs2); -+ void mulhsu(Register rd, Register rs1, Register rs2); -+ void mulhu(Register rd, Register rs1, Register rs2); -+ void div(Register rd, Register rs1, Register rs2); -+ void divu(Register rd, Register rs1, Register rs2); -+ void rem(Register rd, Register rs1, Register rs2); -+ void remu(Register rd, Register rs1, Register rs2); -+ -+ // RV64M Standard Extension (in addition to RV32M) -+ void mulw(Register rd, Register rs1, Register rs2); -+ void divw(Register rd, Register rs1, Register rs2); -+ void divuw(Register rd, Register rs1, Register rs2); -+ void remw(Register rd, Register rs1, Register rs2); -+ void remuw(Register rd, Register rs1, Register rs2); -+ -+ // RV32A Standard Extension -+ void lr_w(bool aq, bool rl, Register rd, Register rs1); -+ void sc_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoswap_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoadd_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoxor_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoand_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoor_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomin_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomax_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amominu_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomaxu_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ -+ // RV64A Standard Extension (in addition to RV32A) -+ void lr_d(bool aq, bool rl, Register rd, Register rs1); -+ void sc_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoswap_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoadd_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoxor_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoand_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amoor_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomin_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomax_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amominu_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ void amomaxu_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); -+ -+ // RV32F Standard Extension -+ void flw(FPURegister rd, Register rs1, int16_t imm12); -+ void fsw(FPURegister source, Register base, int16_t imm12); -+ void fmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fnmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fnmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fmul_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fdiv_s(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fsqrt_s(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fsgnj_s(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fsgnjn_s(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fsgnjx_s(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fmin_s(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fmax_s(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fcvt_w_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_wu_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fmv_x_w(Register rd, FPURegister rs1); -+ void feq_s(Register rd, FPURegister rs1, FPURegister rs2); -+ void flt_s(Register rd, FPURegister rs1, FPURegister rs2); -+ void fle_s(Register rd, FPURegister rs1, FPURegister rs2); -+ void fclass_s(Register rd, FPURegister rs1); -+ void fcvt_s_w(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fcvt_s_wu(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fmv_w_x(FPURegister rd, Register rs1); -+ -+ // RV64F Standard Extension (in addition to RV32F) -+ void fcvt_l_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_lu_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_s_l(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fcvt_s_lu(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ -+ // RV32D Standard Extension -+ void fld(FPURegister rd, Register rs1, int16_t imm12); -+ void fsd(FPURegister source, Register base, int16_t imm12); -+ void fmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fnmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fnmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ FPURegister rs3, RoundingMode frm = RNE); -+ void fadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fmul_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fdiv_d(FPURegister rd, FPURegister rs1, FPURegister rs2, -+ RoundingMode frm = RNE); -+ void fsqrt_d(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fsgnj_d(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fsgnjn_d(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fsgnjx_d(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fmin_d(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fmax_d(FPURegister rd, FPURegister rs1, FPURegister rs2); -+ void fcvt_s_d(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_d_s(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); -+ void feq_d(Register rd, FPURegister rs1, FPURegister rs2); -+ void flt_d(Register rd, FPURegister rs1, FPURegister rs2); -+ void fle_d(Register rd, FPURegister rs1, FPURegister rs2); -+ void fclass_d(Register rd, FPURegister rs1); -+ void fcvt_w_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_wu_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_d_w(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fcvt_d_wu(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ -+ // RV64D Standard Extension (in addition to RV32D) -+ void fcvt_l_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fcvt_lu_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); -+ void fmv_x_d(Register rd, FPURegister rs1); -+ void fcvt_d_l(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fcvt_d_lu(FPURegister rd, Register rs1, RoundingMode frm = RNE); -+ void fmv_d_x(FPURegister rd, Register rs1); -+ -+ // Privileged -+ void uret(); -+ void sret(); -+ void mret(); -+ void wfi(); -+ void sfence_vma(Register rs1, Register rs2); -+ -+ // Assembler Pseudo Instructions (Tables 25.2, 25.3, RISC-V Unprivileged ISA) -+ void nop(); -+ void RV_li(Register rd, int64_t imm); -+ // Returns the number of instructions required to load the immediate -+ static int li_count(int64_t imm); -+ // Loads an immediate, always using 8 instructions, regardless of the value, -+ // so that it can be modified later. -+ void li_constant(Register rd, int64_t imm); -+ -+ void mv(Register rd, Register rs) { addi(rd, rs, 0); } -+ void not_(Register rd, Register rs) { xori(rd, rs, -1); } -+ void neg(Register rd, Register rs) { sub(rd, zero_reg, rs); } -+ void negw(Register rd, Register rs) { subw(rd, zero_reg, rs); } -+ void sext_w(Register rd, Register rs) { addiw(rd, rs, 0); } -+ void seqz(Register rd, Register rs) { sltiu(rd, rs, 1); } -+ void snez(Register rd, Register rs) { sltu(rd, zero_reg, rs); } -+ void sltz(Register rd, Register rs) { slt(rd, rs, zero_reg); } -+ void sgtz(Register rd, Register rs) { slt(rd, zero_reg, rs); } -+ -+ void fmv_s(FPURegister rd, FPURegister rs) { fsgnj_s(rd, rs, rs); } -+ void fabs_s(FPURegister rd, FPURegister rs) { fsgnjx_s(rd, rs, rs); } -+ void fneg_s(FPURegister rd, FPURegister rs) { fsgnjn_s(rd, rs, rs); } -+ void fmv_d(FPURegister rd, FPURegister rs) { fsgnj_d(rd, rs, rs); } -+ void fabs_d(FPURegister rd, FPURegister rs) { fsgnjx_d(rd, rs, rs); } -+ void fneg_d(FPURegister rd, FPURegister rs) { fsgnjn_d(rd, rs, rs); } -+ -+ void beqz(Register rs, int16_t imm13) { beq(rs, zero_reg, imm13); } -+ inline void beqz(Register rs1, Label* L) { beqz(rs1, branch_offset(L)); } -+ void bnez(Register rs, int16_t imm13) { bne(rs, zero_reg, imm13); } -+ inline void bnez(Register rs1, Label* L) { bnez(rs1, branch_offset(L)); } -+ void blez(Register rs, int16_t imm13) { bge(zero_reg, rs, imm13); } -+ inline void blez(Register rs1, Label* L) { blez(rs1, branch_offset(L)); } -+ void bgez(Register rs, int16_t imm13) { bge(rs, zero_reg, imm13); } -+ inline void bgez(Register rs1, Label* L) { bgez(rs1, branch_offset(L)); } -+ void bltz(Register rs, int16_t imm13) { blt(rs, zero_reg, imm13); } -+ inline void bltz(Register rs1, Label* L) { bltz(rs1, branch_offset(L)); } -+ void bgtz(Register rs, int16_t imm13) { blt(zero_reg, rs, imm13); } -+ -+ inline void bgtz(Register rs1, Label* L) { bgtz(rs1, branch_offset(L)); } -+ void bgt(Register rs1, Register rs2, int16_t imm13) { blt(rs2, rs1, imm13); } -+ inline void bgt(Register rs1, Register rs2, Label* L) { -+ bgt(rs1, rs2, branch_offset(L)); -+ } -+ void ble(Register rs1, Register rs2, int16_t imm13) { bge(rs2, rs1, imm13); } -+ inline void ble(Register rs1, Register rs2, Label* L) { -+ ble(rs1, rs2, branch_offset(L)); -+ } -+ void bgtu(Register rs1, Register rs2, int16_t imm13) { -+ bltu(rs2, rs1, imm13); -+ } -+ inline void bgtu(Register rs1, Register rs2, Label* L) { -+ bgtu(rs1, rs2, branch_offset(L)); -+ } -+ void bleu(Register rs1, Register rs2, int16_t imm13) { -+ bgeu(rs2, rs1, imm13); -+ } -+ inline void bleu(Register rs1, Register rs2, Label* L) { -+ bleu(rs1, rs2, branch_offset(L)); -+ } -+ -+ // TODO: Replace uses of ToRegister with names once they are properly defined -+ void j(int32_t imm21) { jal(zero_reg, imm21); } -+ inline void j(Label* L) { j(jump_offset(L)); } -+ void jal(int32_t imm21) { jal(ToRegister(1), imm21); } -+ inline void jal(Label* L) { jal(jump_offset(L)); } -+ void jr(Register rs) { jalr(zero_reg, rs, 0); } -+ void jr(Register rs, int32_t imm12) { jalr(zero_reg, rs, imm12); } -+ void jalr(Register rs, int32_t imm12) { jalr(ToRegister(1), rs, imm12); } -+ void jalr(Register rs) { jalr(ToRegister(1), rs, 0); } -+ void ret() { jalr(zero_reg, ToRegister(1), 0); } -+ void call(int32_t offset) { -+ auipc(ToRegister(1), (offset >> 12) + ((offset & 0x800) >> 11)); -+ jalr(ToRegister(1), ToRegister(1), offset << 20 >> 20); -+ } -+ -+ // Read instructions-retired counter -+ void rdinstret(Register rd) { csrrs(rd, csr_instret, zero_reg); } -+ void rdinstreth(Register rd) { csrrs(rd, csr_instreth, zero_reg); } -+ void rdcycle(Register rd) { csrrs(rd, csr_cycle, zero_reg); } -+ void rdcycleh(Register rd) { csrrs(rd, csr_cycleh, zero_reg); } -+ void rdtime(Register rd) { csrrs(rd, csr_time, zero_reg); } -+ void rdtimeh(Register rd) { csrrs(rd, csr_timeh, zero_reg); } -+ -+ void csrr(Register rd, ControlStatusReg csr) { csrrs(rd, csr, zero_reg); } -+ void csrw(ControlStatusReg csr, Register rs) { csrrw(zero_reg, csr, rs); } -+ void csrs(ControlStatusReg csr, Register rs) { csrrs(zero_reg, csr, rs); } -+ void csrc(ControlStatusReg csr, Register rs) { csrrc(zero_reg, csr, rs); } -+ -+ void csrwi(ControlStatusReg csr, uint8_t imm) { csrrwi(zero_reg, csr, imm); } -+ void csrsi(ControlStatusReg csr, uint8_t imm) { csrrsi(zero_reg, csr, imm); } -+ void csrci(ControlStatusReg csr, uint8_t imm) { csrrci(zero_reg, csr, imm); } -+ -+ void frcsr(Register rd) { csrrs(rd, csr_fcsr, zero_reg); } -+ void fscsr(Register rd, Register rs) { csrrw(rd, csr_fcsr, rs); } -+ void fscsr(Register rs) { csrrw(zero_reg, csr_fcsr, rs); } -+ -+ void frrm(Register rd) { csrrs(rd, csr_frm, zero_reg); } -+ void fsrm(Register rd, Register rs) { csrrw(rd, csr_frm, rs); } -+ void fsrm(Register rs) { csrrw(zero_reg, csr_frm, rs); } -+ -+ void frflags(Register rd) { csrrs(rd, csr_fflags, zero_reg); } -+ void fsflags(Register rd, Register rs) { csrrw(rd, csr_fflags, rs); } -+ void fsflags(Register rs) { csrrw(zero_reg, csr_fflags, rs); } -+ -+ // Other pseudo instructions that are not part of RISCV pseudo assemly -+ void nor(Register rd, Register rs, Register rt) { -+ or_(rd, rs, rt); -+ not_(rd, rd); -+ } -+ -+ void sync() { fence(0b1111, 0b1111); } -+ void break_(uint32_t code, bool break_as_stop = false); -+ void stop(uint32_t code = kMaxStopCode); -+ -+ // Check the code size generated from label to here. -+ int SizeOfCodeGeneratedSince(Label* label) { -+ return pc_offset() - label->pos(); -+ } -+ -+ // Check the number of instructions generated from label to here. -+ int InstructionsGeneratedSince(Label* label) { -+ return SizeOfCodeGeneratedSince(label) / kInstrSize; -+ } -+ -+ // Class for scoping postponing the trampoline pool generation. -+ class BlockTrampolinePoolScope { -+ public: -+ explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) { -+ assem_->StartBlockTrampolinePool(); -+ } -+ ~BlockTrampolinePoolScope() { assem_->EndBlockTrampolinePool(); } -+ -+ private: -+ Assembler* assem_; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope); -+ }; -+ -+ // Class for postponing the assembly buffer growth. Typically used for -+ // sequences of instructions that must be emitted as a unit, before -+ // buffer growth (and relocation) can occur. -+ // This blocking scope is not nestable. -+ class BlockGrowBufferScope { -+ public: -+ explicit BlockGrowBufferScope(Assembler* assem) : assem_(assem) { -+ assem_->StartBlockGrowBuffer(); -+ } -+ ~BlockGrowBufferScope() { assem_->EndBlockGrowBuffer(); } -+ -+ private: -+ Assembler* assem_; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope); -+ }; -+ -+ // Record a deoptimization reason that can be used by a log or cpu profiler. -+ // Use --trace-deopt to enable. -+ void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, -+ int id); -+ -+ static int RelocateInternalReference(RelocInfo::Mode rmode, Address pc, -+ intptr_t pc_delta); -+ -+ // Writes a single byte or word of data in the code stream. Used for -+ // inline tables, e.g., jump-tables. -+ void db(uint8_t data); -+ void dd(uint32_t data); -+ void dq(uint64_t data); -+ void dp(uintptr_t data) { dq(data); } -+ void dd(Label* label); -+ -+ // Postpone the generation of the trampoline pool for the specified number of -+ // instructions. -+ void BlockTrampolinePoolFor(int instructions); -+ -+ // Check if there is less than kGap bytes available in the buffer. -+ // If this is the case, we need to grow the buffer before emitting -+ // an instruction or relocation information. -+ inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } -+ -+ // Get the number of bytes available in the buffer. -+ inline intptr_t available_space() const { -+ return reloc_info_writer.pos() - pc_; -+ } -+ -+ // Read/patch instructions. -+ static Instr instr_at(Address pc) { return *reinterpret_cast(pc); } -+ static void instr_at_put(Address pc, Instr instr) { -+ *reinterpret_cast(pc) = instr; -+ } -+ Instr instr_at(int pos) { -+ return *reinterpret_cast(buffer_start_ + pos); -+ } -+ void instr_at_put(int pos, Instr instr) { -+ *reinterpret_cast(buffer_start_ + pos) = instr; -+ } -+ -+ // Check if an instruction is a branch of some kind. -+ static bool IsBranch(Instr instr); -+ static bool IsJump(Instr instr); -+ static bool IsJal(Instr instr); -+ static bool IsJalr(Instr instr); -+ static bool IsLui(Instr instr); -+ static bool IsAuipc(Instr instr); -+ static bool IsAddiw(Instr instr); -+ static bool IsAddi(Instr instr); -+ static bool IsSlli(Instr instr); -+ -+ void CheckTrampolinePool(); -+ -+ inline int UnboundLabelsCount() { return unbound_labels_count_; } -+ -+ protected: -+ // Readable constants for base and offset adjustment helper, these indicate if -+ // aside from offset, another value like offset + 4 should fit into int16. -+ enum class OffsetAccessType : bool { -+ SINGLE_ACCESS = false, -+ TWO_ACCESSES = true -+ }; -+ -+ // Determine whether need to adjust base and offset of memroy load/store -+ bool NeedAdjustBaseAndOffset( -+ const MemOperand& src, OffsetAccessType = OffsetAccessType::SINGLE_ACCESS, -+ int second_Access_add_to_offset = 4); -+ -+ // Helper function for memory load/store using base register and offset. -+ void AdjustBaseAndOffset( -+ MemOperand* src, Register scratch, -+ OffsetAccessType access_type = OffsetAccessType::SINGLE_ACCESS, -+ int second_access_add_to_offset = 4); -+ -+ inline static void set_target_internal_reference_encoded_at(Address pc, -+ Address target); -+ -+ int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } -+ -+ // Decode branch instruction at pos and return branch target pos. -+ int target_at(int pos, bool is_internal); -+ -+ // Patch branch instruction at pos to branch to given branch target pos. -+ void target_at_put(int pos, int target_pos, bool is_internal); -+ -+ // Say if we need to relocate with this mode. -+ bool MustUseReg(RelocInfo::Mode rmode); -+ -+ // Record reloc info for current pc_. -+ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); -+ -+ // Block the emission of the trampoline pool before pc_offset. -+ void BlockTrampolinePoolBefore(int pc_offset) { -+ if (no_trampoline_pool_before_ < pc_offset) -+ no_trampoline_pool_before_ = pc_offset; -+ } -+ -+ void StartBlockTrampolinePool() { trampoline_pool_blocked_nesting_++; } -+ -+ void EndBlockTrampolinePool() { -+ trampoline_pool_blocked_nesting_--; -+ if (trampoline_pool_blocked_nesting_ == 0) { -+ CheckTrampolinePoolQuick(1); -+ } -+ } -+ -+ bool is_trampoline_pool_blocked() const { -+ return trampoline_pool_blocked_nesting_ > 0; -+ } -+ -+ bool has_exception() const { return internal_trampoline_exception_; } -+ -+ bool is_trampoline_emitted() const { return trampoline_emitted_; } -+ -+ // Temporarily block automatic assembly buffer growth. -+ void StartBlockGrowBuffer() { -+ DCHECK(!block_buffer_growth_); -+ block_buffer_growth_ = true; -+ } -+ -+ void EndBlockGrowBuffer() { -+ DCHECK(block_buffer_growth_); -+ block_buffer_growth_ = false; -+ } -+ -+ bool is_buffer_growth_blocked() const { return block_buffer_growth_; } -+ -+ void CheckTrampolinePoolQuick(int extra_instructions = 0) { -+ if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { -+ CheckTrampolinePool(); -+ } -+ } -+ -+ private: -+ // Avoid overflows for displacements etc. -+ static const int kMaximalBufferSize = 512 * MB; -+ -+ // Buffer size and constant pool distance are checked together at regular -+ // intervals of kBufferCheckInterval emitted bytes. -+ static constexpr int kBufferCheckInterval = 1 * KB / 2; -+ -+ // Code generation. -+ // The relocation writer's position is at least kGap bytes below the end of -+ // the generated instructions. This is so that multi-instruction sequences do -+ // not have to check for overflow. The same is true for writes of large -+ // relocation info entries. -+ static constexpr int kGap = 64; -+ STATIC_ASSERT(AssemblerBase::kMinimalBufferSize >= 2 * kGap); -+ -+ // Repeated checking whether the trampoline pool should be emitted is rather -+ // expensive. By default we only check again once a number of instructions -+ // has been generated. -+ static constexpr int kCheckConstIntervalInst = 32; -+ static constexpr int kCheckConstInterval = -+ kCheckConstIntervalInst * kInstrSize; -+ -+ int next_buffer_check_; // pc offset of next buffer check. -+ -+ // Emission of the trampoline pool may be blocked in some code sequences. -+ int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. -+ int no_trampoline_pool_before_; // Block emission before this pc offset. -+ -+ // Keep track of the last emitted pool to guarantee a maximal distance. -+ int last_trampoline_pool_end_; // pc offset of the end of the last pool. -+ -+ // Automatic growth of the assembly buffer may be blocked for some sequences. -+ bool block_buffer_growth_; // Block growth when true. -+ -+ // Relocation information generation. -+ // Each relocation is encoded as a variable size value. -+ static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; -+ RelocInfoWriter reloc_info_writer; -+ -+ // The bound position, before this we cannot do instruction elimination. -+ int last_bound_pos_; -+ -+ // Code emission. -+ inline void CheckBuffer(); -+ void GrowBuffer(); -+ inline void emit(Instr x); -+ inline void emit(uint64_t x); -+ template -+ inline void EmitHelper(T x); -+ -+ static void disassembleInstr(Instr instr); -+ -+ // Instruction generation. -+ -+ // ----- Top-level instruction formats match those in the ISA manual -+ // (R, I, S, B, U, J). These match the formats defined in LLVM's -+ // RISCVInstrFormats.td. -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, -+ Register rs1, Register rs2); -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, -+ FPURegister rs1, FPURegister rs2); -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, -+ FPURegister rs1, Register rs2); -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, -+ Register rs1, Register rs2); -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, -+ FPURegister rs1, Register rs2); -+ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, -+ FPURegister rs1, FPURegister rs2); -+ void GenInstrR4(uint8_t funct2, Opcode opcode, Register rd, Register rs1, -+ Register rs2, Register rs3, RoundingMode frm); -+ void GenInstrR4(uint8_t funct2, Opcode opcode, FPURegister rd, -+ FPURegister rs1, FPURegister rs2, FPURegister rs3, -+ RoundingMode frm); -+ void GenInstrRAtomic(uint8_t funct5, bool aq, bool rl, uint8_t funct3, -+ Register rd, Register rs1, Register rs2); -+ void GenInstrRFrm(uint8_t funct7, Opcode opcode, Register rd, Register rs1, -+ Register rs2, RoundingMode frm); -+ void GenInstrI(uint8_t funct3, Opcode opcode, Register rd, Register rs1, -+ int16_t imm12); -+ void GenInstrI(uint8_t funct3, Opcode opcode, FPURegister rd, Register rs1, -+ int16_t imm12); -+ void GenInstrIShift(bool arithshift, uint8_t funct3, Opcode opcode, -+ Register rd, Register rs1, uint8_t shamt); -+ void GenInstrIShiftW(bool arithshift, uint8_t funct3, Opcode opcode, -+ Register rd, Register rs1, uint8_t shamt); -+ void GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, Register rs2, -+ int16_t imm12); -+ void GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, FPURegister rs2, -+ int16_t imm12); -+ void GenInstrB(uint8_t funct3, Opcode opcode, Register rs1, Register rs2, -+ int16_t imm12); -+ void GenInstrU(Opcode opcode, Register rd, int32_t imm20); -+ void GenInstrJ(Opcode opcode, Register rd, int32_t imm20); -+ -+ // ----- Instruction class templates match those in LLVM's RISCVInstrInfo.td -+ void GenInstrBranchCC_rri(uint8_t funct3, Register rs1, Register rs2, -+ int16_t imm12); -+ void GenInstrLoad_ri(uint8_t funct3, Register rd, Register rs1, -+ int16_t imm12); -+ void GenInstrStore_rri(uint8_t funct3, Register rs1, Register rs2, -+ int16_t imm12); -+ void GenInstrALU_ri(uint8_t funct3, Register rd, Register rs1, int16_t imm12); -+ void GenInstrShift_ri(bool arithshift, uint8_t funct3, Register rd, -+ Register rs1, uint8_t shamt); -+ void GenInstrALU_rr(uint8_t funct7, uint8_t funct3, Register rd, Register rs1, -+ Register rs2); -+ void GenInstrCSR_ir(uint8_t funct3, Register rd, ControlStatusReg csr, -+ Register rs1); -+ void GenInstrCSR_ii(uint8_t funct3, Register rd, ControlStatusReg csr, -+ uint8_t rs1); -+ void GenInstrShiftW_ri(bool arithshift, uint8_t funct3, Register rd, -+ Register rs1, uint8_t shamt); -+ void GenInstrALUW_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ Register rs1, Register rs2); -+ void GenInstrPriv(uint8_t funct7, Register rs1, Register rs2); -+ void GenInstrLoadFP_ri(uint8_t funct3, FPURegister rd, Register rs1, -+ int16_t imm12); -+ void GenInstrStoreFP_rri(uint8_t funct3, Register rs1, FPURegister rs2, -+ int16_t imm12); -+ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ FPURegister rs1, FPURegister rs2); -+ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ Register rs1, Register rs2); -+ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, -+ FPURegister rs1, Register rs2); -+ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ FPURegister rs1, Register rs2); -+ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, -+ FPURegister rs1, FPURegister rs2); -+ -+ // Labels. -+ void print(const Label* L); -+ void bind_to(Label* L, int pos); -+ void next(Label* L, bool is_internal); -+ -+ // One trampoline consists of: -+ // - space for trampoline slots, -+ // - space for labels. -+ // -+ // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. -+ // Space for trampoline slots precedes space for labels. Each label is of one -+ // instruction size, so total amount for labels is equal to -+ // label_count * kInstrSize. -+ class Trampoline { -+ public: -+ Trampoline() { -+ start_ = 0; -+ next_slot_ = 0; -+ free_slot_count_ = 0; -+ end_ = 0; -+ } -+ Trampoline(int start, int slot_count) { -+ start_ = start; -+ next_slot_ = start; -+ free_slot_count_ = slot_count; -+ end_ = start + slot_count * kTrampolineSlotsSize; -+ } -+ int start() { return start_; } -+ int end() { return end_; } -+ int take_slot() { -+ int trampoline_slot = kInvalidSlotPos; -+ if (free_slot_count_ <= 0) { -+ // We have run out of space on trampolines. -+ // Make sure we fail in debug mode, so we become aware of each case -+ // when this happens. -+ DCHECK(0); -+ // Internal exception will be caught. -+ } else { -+ trampoline_slot = next_slot_; -+ free_slot_count_--; -+ next_slot_ += kTrampolineSlotsSize; -+ } -+ return trampoline_slot; -+ } -+ -+ private: -+ int start_; -+ int end_; -+ int next_slot_; -+ int free_slot_count_; -+ }; -+ -+ int32_t get_trampoline_entry(int32_t pos); -+ int unbound_labels_count_; -+ // After trampoline is emitted, long branches are used in generated code for -+ // the forward branches whose target offsets could be beyond reach of branch -+ // instruction. We use this information to trigger different mode of -+ // branch instruction generation, where we use jump instructions rather -+ // than regular branch instructions. -+ bool trampoline_emitted_ = false; -+ static constexpr int kInvalidSlotPos = -1; -+ -+ // Internal reference positions, required for unbounded internal reference -+ // labels. -+ std::set internal_reference_positions_; -+ bool is_internal_reference(Label* L) { -+ return internal_reference_positions_.find(L->pos()) != -+ internal_reference_positions_.end(); -+ } -+ -+ Trampoline trampoline_; -+ bool internal_trampoline_exception_; -+ -+ RegList scratch_register_list_; -+ -+ private: -+ void AllocateAndInstallRequestedHeapObjects(Isolate* isolate); -+ -+ int WriteCodeComments(); -+ -+ friend class RegExpMacroAssemblerRISCV; -+ friend class RelocInfo; -+ friend class BlockTrampolinePoolScope; -+ friend class EnsureSpace; -+}; -+ -+class EnsureSpace { -+ public: -+ explicit inline EnsureSpace(Assembler* assembler); -+}; -+ -+class V8_EXPORT_PRIVATE UseScratchRegisterScope { -+ public: -+ explicit UseScratchRegisterScope(Assembler* assembler); -+ ~UseScratchRegisterScope(); -+ -+ Register Acquire(); -+ bool hasAvailable() const; -+ -+ private: -+ RegList* available_; -+ RegList old_available_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/constants-riscv64.cc -@@ -0,0 +1,111 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/riscv64/constants-riscv64.h" -+ -+namespace v8 { -+namespace internal { -+ -+// ----------------------------------------------------------------------------- -+// Registers. -+ -+// These register names are defined in a way to match the native disassembler -+// formatting. See for example the command "objdump -d ". -+const char* Registers::names_[kNumSimuRegisters] = { -+ "zero_reg", "ra", "sp", "gp", "tp", "t0", "t1", "t2", "fp", "s1", "a0", -+ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "s2", "s3", "s4", "s5", -+ "s6", "s7", "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6", "pc"}; -+ -+// List of alias names which can be used when referring to RISC-V registers. -+const Registers::RegisterAlias Registers::aliases_[] = { -+ {0, "zero"}, -+ {33, "pc"}, -+ {8, "s0"}, -+ {8, "s0_fp"}, -+ {kInvalidRegister, nullptr}}; -+ -+const char* Registers::Name(int reg) { -+ const char* result; -+ if ((0 <= reg) && (reg < kNumSimuRegisters)) { -+ result = names_[reg]; -+ } else { -+ result = "noreg"; -+ } -+ return result; -+} -+ -+int Registers::Number(const char* name) { -+ // Look through the canonical names. -+ for (int i = 0; i < kNumSimuRegisters; i++) { -+ if (strcmp(names_[i], name) == 0) { -+ return i; -+ } -+ } -+ -+ // Look through the alias names. -+ int i = 0; -+ while (aliases_[i].reg != kInvalidRegister) { -+ if (strcmp(aliases_[i].name, name) == 0) { -+ return aliases_[i].reg; -+ } -+ i++; -+ } -+ -+ // No register with the reguested name found. -+ return kInvalidRegister; -+} -+ -+/* -+const char* FPURegisters::names_[kNumFPURegisters] = { -+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", -+ "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", -+ "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"}; -+*/ -+const char* FPURegisters::names_[kNumFPURegisters] = { -+ "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", -+ "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", -+ "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", -+ "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"}; -+ -+// List of alias names which can be used when referring to RISC-V FP registers. -+const FPURegisters::RegisterAlias FPURegisters::aliases_[] = { -+ {kInvalidRegister, nullptr}}; -+ -+const char* FPURegisters::Name(int creg) { -+ const char* result; -+ if ((0 <= creg) && (creg < kNumFPURegisters)) { -+ result = names_[creg]; -+ } else { -+ result = "nocreg"; -+ } -+ return result; -+} -+ -+int FPURegisters::Number(const char* name) { -+ // Look through the canonical names. -+ for (int i = 0; i < kNumFPURegisters; i++) { -+ if (strcmp(names_[i], name) == 0) { -+ return i; -+ } -+ } -+ -+ // Look through the alias names. -+ int i = 0; -+ while (aliases_[i].creg != kInvalidRegister) { -+ if (strcmp(aliases_[i].name, name) == 0) { -+ return aliases_[i].creg; -+ } -+ i++; -+ } -+ -+ // No Cregister with the reguested name found. -+ return kInvalidFPURegister; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/constants-riscv64.h -@@ -0,0 +1,947 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ -+#define V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ -+ -+#include "src/base/logging.h" -+#include "src/base/macros.h" -+#include "src/common/globals.h" -+ -+// UNIMPLEMENTED_ macro for RISCV. -+#ifdef DEBUG -+#define UNIMPLEMENTED_RISCV() \ -+ v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ -+ __FILE__, __LINE__, __func__) -+#else -+#define UNIMPLEMENTED_RISCV() -+#endif -+ -+#define UNSUPPORTED_RISCV() v8::internal::PrintF("Unsupported instruction.\n") -+ -+enum Endianness { kLittle, kBig }; -+ -+#if defined(V8_TARGET_LITTLE_ENDIAN) -+static const Endianness kArchEndian = kLittle; -+#elif defined(V8_TARGET_BIG_ENDIAN) -+static const Endianness kArchEndian = kBig; -+#else -+#error Unknown endianness -+#endif -+ -+#if defined(V8_TARGET_LITTLE_ENDIAN) -+const uint32_t kLeastSignificantByteInInt32Offset = 0; -+const uint32_t kLessSignificantWordInDoublewordOffset = 0; -+#elif defined(V8_TARGET_BIG_ENDIAN) -+const uint32_t kLeastSignificantByteInInt32Offset = 3; -+const uint32_t kLessSignificantWordInDoublewordOffset = 4; -+#else -+#error Unknown endianness -+#endif -+ -+#ifndef __STDC_FORMAT_MACROS -+#define __STDC_FORMAT_MACROS -+#endif -+#include -+ -+// Defines constants and accessor classes to assemble, disassemble and -+// simulate RISC-V instructions. -+// -+// See: The RISC-V Instruction Set Manual -+// Volume I: User-Level ISA -+// Try https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf. -+ -+namespace v8 { -+namespace internal { -+ -+// TODO(sigurds): Change this value once we use relative jumps. -+constexpr size_t kMaxPCRelativeCodeRangeInMB = 0; -+ -+// ----------------------------------------------------------------------------- -+// Registers and FPURegisters. -+ -+// Number of general purpose registers. -+const int kNumRegisters = 32; -+const int kInvalidRegister = -1; -+ -+// Number of registers with pc. -+const int kNumSimuRegisters = 33; -+ -+// In the simulator, the PC register is simulated as the 34th register. -+const int kPCRegister = 34; -+ -+// Number coprocessor registers. -+const int kNumFPURegisters = 32; -+const int kInvalidFPURegister = -1; -+ -+// 'pref' instruction hints -+const int32_t kPrefHintLoad = 0; -+const int32_t kPrefHintStore = 1; -+const int32_t kPrefHintLoadStreamed = 4; -+const int32_t kPrefHintStoreStreamed = 5; -+const int32_t kPrefHintLoadRetained = 6; -+const int32_t kPrefHintStoreRetained = 7; -+const int32_t kPrefHintWritebackInvalidate = 25; -+const int32_t kPrefHintPrepareForStore = 30; -+ -+// Actual value of root register is offset from the root array's start -+// to take advantage of negative displacement values. -+// TODO(sigurds): Choose best value. -+constexpr int kRootRegisterBias = 256; -+ -+// Helper functions for converting between register numbers and names. -+class Registers { -+ public: -+ // Return the name of the register. -+ static const char* Name(int reg); -+ -+ // Lookup the register number for the name provided. -+ static int Number(const char* name); -+ -+ struct RegisterAlias { -+ int reg; -+ const char* name; -+ }; -+ -+ static const int64_t kMaxValue = 0x7fffffffffffffffl; -+ static const int64_t kMinValue = 0x8000000000000000l; -+ -+ private: -+ static const char* names_[kNumSimuRegisters]; -+ static const RegisterAlias aliases_[]; -+}; -+ -+// Helper functions for converting between register numbers and names. -+class FPURegisters { -+ public: -+ // Return the name of the register. -+ static const char* Name(int reg); -+ -+ // Lookup the register number for the name provided. -+ static int Number(const char* name); -+ -+ struct RegisterAlias { -+ int creg; -+ const char* name; -+ }; -+ -+ private: -+ static const char* names_[kNumFPURegisters]; -+ static const RegisterAlias aliases_[]; -+}; -+ -+// ----------------------------------------------------------------------------- -+// Instructions encoding constants. -+ -+// On RISCV all instructions are 32 bits. -+using Instr = int32_t; -+ -+// Special Software Interrupt codes when used in the presence of the RISC-V -+// simulator. -+enum SoftwareInterruptCodes { -+ // Transition to C code. -+ call_rt_redirected = 0xfffff -+}; -+ -+// On RISC-V Simulator breakpoints can have different codes: -+// - Breaks between 0 and kMaxWatchpointCode are treated as simple watchpoints, -+// the simulator will run through them and print the registers. -+// - Breaks between kMaxWatchpointCode and kMaxStopCode are treated as stop() -+// instructions (see Assembler::stop()). -+// - Breaks larger than kMaxStopCode are simple breaks, dropping you into the -+// debugger. -+const uint32_t kMaxWatchpointCode = 31; -+const uint32_t kMaxStopCode = 127; -+STATIC_ASSERT(kMaxWatchpointCode < kMaxStopCode); -+ -+// ----- Fields offset and length. -+// RISCV constants -+const int kBaseOpcodeShift = 0; -+const int kBaseOpcodeBits = 7; -+const int kFunct7Shift = 25; -+const int kFunct7Bits = 7; -+const int kFunct5Shift = 27; -+const int kFunct5Bits = 5; -+const int kFunct3Shift = 12; -+const int kFunct3Bits = 3; -+const int kFunct2Shift = 25; -+const int kFunct2Bits = 2; -+const int kRs1Shift = 15; -+const int kRs1Bits = 5; -+const int kRs2Shift = 20; -+const int kRs2Bits = 5; -+const int kRs3Shift = 27; -+const int kRs3Bits = 5; -+const int kRdShift = 7; -+const int kRdBits = 5; -+const int kRlShift = 25; -+const int kAqShift = 26; -+const int kImm12Shift = 20; -+const int kImm12Bits = 12; -+const int kShamtShift = 20; -+const int kShamtBits = 5; -+const int kShamtWShift = 20; -+const int kShamtWBits = 6; -+const int kArithShiftShift = 30; -+const int kImm20Shift = 12; -+const int kImm20Bits = 20; -+const int kCsrShift = 20; -+const int kCsrBits = 12; -+const int kMemOrderBits = 4; -+const int kPredOrderShift = 24; -+const int kSuccOrderShift = 20; -+ -+// RISCV Instruction bit masks -+const uint32_t kBaseOpcodeMask = ((1 << kBaseOpcodeBits) - 1) << kBaseOpcodeShift; -+const uint32_t kFunct3Mask = ((1 << kFunct3Bits) - 1) << kFunct3Shift; -+const uint32_t kFunct5Mask = ((1 << kFunct5Bits) - 1) << kFunct5Shift; -+const uint32_t kFunct7Mask = ((1 << kFunct7Bits) - 1) << kFunct7Shift; -+const uint32_t kFunct2Mask = 0b11 << kFunct7Shift; -+const uint32_t kRTypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct7Mask; -+const uint32_t kRATypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct5Mask; -+const uint32_t kRFPTypeMask = kBaseOpcodeMask | kFunct7Mask; -+const uint32_t kR4TypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct2Mask; -+const uint32_t kITypeMask = kBaseOpcodeMask | kFunct3Mask; -+const uint32_t kSTypeMask = kBaseOpcodeMask | kFunct3Mask; -+const uint32_t kBTypeMask = kBaseOpcodeMask | kFunct3Mask; -+const uint32_t kUTypeMask = kBaseOpcodeMask; -+const uint32_t kJTypeMask = kBaseOpcodeMask; -+const uint32_t kRs1FieldMask = ((1 << kRs1Bits) - 1) << kRs1Shift; -+const uint32_t kRs2FieldMask = ((1 << kRs2Bits) - 1) << kRs2Shift; -+const uint32_t kRs3FieldMask = ((1 << kRs3Bits) - 1) << kRs3Shift; -+const uint32_t kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; -+const uint32_t kBImm12Mask = kFunct7Mask | kRdFieldMask; -+const uint32_t kImm20Mask = ((1 << kImm20Bits) - 1) << kImm20Shift; -+const uint32_t kImm12Mask = ((1 << kImm12Bits) - 1) << kImm12Shift; -+ -+// RISCV CSR related bit mask and shift -+const uint32_t kFcsrFlagsBits = 5; -+const uint32_t kFcsrFlagsMask = (1 << kFcsrFlagsBits) - 1; -+const uint32_t kFcsrFrmBits = 3; -+const uint32_t kFcsrFrmShift = kFcsrFlagsBits; -+const uint32_t kFcsrFrmMask = ((1 << kFcsrFrmBits) - 1) << kFcsrFrmShift; -+const uint32_t kFcsrBits = kFcsrFlagsBits + kFcsrFrmBits; -+const uint32_t kFcsrMask = kFcsrFlagsMask | kFcsrFrmMask; -+ -+// Original MIPS constants -+// FIXME (RISCV): to be cleaned up -+const uint32_t kImm16Shift = 0; -+const uint32_t kImm16Bits = 16; -+const uint32_t kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; -+// end of FIXME (RISCV): to be cleaned up -+ -+// ----- RISCV Base Opcodes -+ -+enum BaseOpcode : uint32_t { -+ -+}; -+ -+// ----- RISC-V Opcodes and Function Fields. -+enum Opcode : uint32_t { -+ LOAD = 0b0000011, // I form: LB LH LW LBU LHU -+ LOAD_FP = 0b0000111, // I form: FLW FLD FLQ -+ MISC_MEM = 0b0001111, // I special form: FENCE FENCE.I -+ OP_IMM = 0b0010011, // I form: ADDI SLTI SLTIU XORI ORI ANDI SLLI SRLI SARI -+ // Note: SLLI/SRLI/SRAI I form first, then func3 001/101 => R type -+ AUIPC = 0b0010111, // U form: AUIPC -+ OP_IMM_32 = 0b0011011, // I form: ADDIW SLLIW SRLIW SRAIW -+ // Note: SRLIW SRAIW I form first, then func3 101 special shift encoding -+ STORE = 0b0100011, // S form: SB SH SW SD -+ STORE_FP = 0b0100111, // S form: FSW FSD FSQ -+ AMO = 0b0101111, // R form: All A instructions -+ OP = 0b0110011, // R: ADD SUB SLL SLT SLTU XOR SRL SRA OR AND and 32M set -+ LUI = 0b0110111, // U form: LUI -+ OP_32 = 0b0111011, // R: ADDW SUBW SLLW SRLW SRAW MULW DIVW DIVUW REMW REMUW -+ MADD = 0b1000011, // R4 type: FMADD.S FMADD.D FMADD.Q -+ MSUB = 0b1000111, // R4 type: FMSUB.S FMSUB.D FMSUB.Q -+ NMSUB = 0b1001011, // R4 type: FNMSUB.S FNMSUB.D FNMSUB.Q -+ NMADD = 0b1001111, // R4 type: FNMADD.S FNMADD.D FNMADD.Q -+ OP_FP = 0b1010011, // R type: Q ext -+ BRANCH = 0b1100011, // B form: BEQ BNE, BLT, BGE, BLTU BGEU -+ JALR = 0b1100111, // I form: JALR -+ JAL = 0b1101111, // J form: JAL -+ SYSTEM = 0b1110011, // I form: ECALL EBREAK Zicsr ext -+ -+ // Note use RO (RiscV Opcode) prefix -+ // RV32I Base Instruction Set -+ RO_LUI = LUI, -+ RO_AUIPC = AUIPC, -+ RO_JAL = JAL, -+ RO_JALR = JALR | (0b000 << kFunct3Shift), -+ RO_BEQ = BRANCH | (0b000 << kFunct3Shift), -+ RO_BNE = BRANCH | (0b001 << kFunct3Shift), -+ RO_BLT = BRANCH | (0b100 << kFunct3Shift), -+ RO_BGE = BRANCH | (0b101 << kFunct3Shift), -+ RO_BLTU = BRANCH | (0b110 << kFunct3Shift), -+ RO_BGEU = BRANCH | (0b111 << kFunct3Shift), -+ RO_LB = LOAD | (0b000 << kFunct3Shift), -+ RO_LH = LOAD | (0b001 << kFunct3Shift), -+ RO_LW = LOAD | (0b010 << kFunct3Shift), -+ RO_LBU = LOAD | (0b100 << kFunct3Shift), -+ RO_LHU = LOAD | (0b101 << kFunct3Shift), -+ RO_SB = STORE | (0b000 << kFunct3Shift), -+ RO_SH = STORE | (0b001 << kFunct3Shift), -+ RO_SW = STORE | (0b010 << kFunct3Shift), -+ RO_ADDI = OP_IMM | (0b000 << kFunct3Shift), -+ RO_SLTI = OP_IMM | (0b010 << kFunct3Shift), -+ RO_SLTIU = OP_IMM | (0b011 << kFunct3Shift), -+ RO_XORI = OP_IMM | (0b100 << kFunct3Shift), -+ RO_ORI = OP_IMM | (0b110 << kFunct3Shift), -+ RO_ANDI = OP_IMM | (0b111 << kFunct3Shift), -+ RO_SLLI = OP_IMM | (0b001 << kFunct3Shift), -+ RO_SRLI = OP_IMM | (0b101 << kFunct3Shift), -+ // RO_SRAI = OP_IMM | (0b101 << kFunct3Shift), // Same as SRLI, use func7 -+ RO_ADD = OP | (0b000 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SUB = OP | (0b000 << kFunct3Shift) | (0b0100000 << kFunct7Shift), -+ RO_SLL = OP | (0b001 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SLT = OP | (0b010 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SLTU = OP | (0b011 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_XOR = OP | (0b100 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SRL = OP | (0b101 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SRA = OP | (0b101 << kFunct3Shift) | (0b0100000 << kFunct7Shift), -+ RO_OR = OP | (0b110 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_AND = OP | (0b111 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_FENCE = MISC_MEM | (0b000 << kFunct3Shift), -+ RO_ECALL = SYSTEM | (0b000 << kFunct3Shift), -+ // RO_EBREAK = SYSTEM | (0b000 << kFunct3Shift), // Same as ECALL, use imm12 -+ -+ // RV64I Base Instruction Set (in addition to RV32I) -+ RO_LWU = LOAD | (0b110 << kFunct3Shift), -+ RO_LD = LOAD | (0b011 << kFunct3Shift), -+ RO_SD = STORE | (0b011 << kFunct3Shift), -+ RO_ADDIW = OP_IMM_32 | (0b000 << kFunct3Shift), -+ RO_SLLIW = OP_IMM_32 | (0b001 << kFunct3Shift), -+ RO_SRLIW = OP_IMM_32 | (0b101 << kFunct3Shift), -+ // RO_SRAIW = OP_IMM_32 | (0b101 << kFunct3Shift), // Same as SRLIW, use func7 -+ RO_ADDW = OP_32 | (0b000 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SUBW = OP_32 | (0b000 << kFunct3Shift) | (0b0100000 << kFunct7Shift), -+ RO_SLLW = OP_32 | (0b001 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SRLW = OP_32 | (0b101 << kFunct3Shift) | (0b0000000 << kFunct7Shift), -+ RO_SRAW = OP_32 | (0b101 << kFunct3Shift) | (0b0100000 << kFunct7Shift), -+ -+ // RV32/RV64 Zifencei Standard Extension -+ RO_FENCE_I = MISC_MEM | (0b001 << kFunct3Shift), -+ -+ // RV32/RV64 Zicsr Standard Extension -+ RO_CSRRW = SYSTEM | (0b001 << kFunct3Shift), -+ RO_CSRRS = SYSTEM | (0b010 << kFunct3Shift), -+ RO_CSRRC = SYSTEM | (0b011 << kFunct3Shift), -+ RO_CSRRWI = SYSTEM | (0b101 << kFunct3Shift), -+ RO_CSRRSI = SYSTEM | (0b110 << kFunct3Shift), -+ RO_CSRRCI = SYSTEM | (0b111 << kFunct3Shift), -+ -+ // RV32M Standard Extension -+ RO_MUL = OP | (0b000 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_MULH = OP | (0b001 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_MULHSU = OP | (0b010 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_MULHU = OP | (0b011 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_DIV = OP | (0b100 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_DIVU = OP | (0b101 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_REM = OP | (0b110 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_REMU = OP | (0b111 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ -+ // RV64M Standard Extension (in addition to RV32M) -+ RO_MULW = OP_32 | (0b000 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_DIVW = OP_32 | (0b100 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_DIVUW = OP_32 | (0b101 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_REMW = OP_32 | (0b110 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ RO_REMUW = OP_32 | (0b111 << kFunct3Shift) | (0b0000001 << kFunct7Shift), -+ -+ // RV32A Standard Extension -+ RO_LR_W = AMO | (0b010 << kFunct3Shift) | (0b00010 << kFunct5Shift), -+ RO_SC_W = AMO | (0b010 << kFunct3Shift) | (0b00011 << kFunct5Shift), -+ RO_AMOSWAP_W = AMO | (0b010 << kFunct3Shift) | (0b00001 << kFunct5Shift), -+ RO_AMOADD_W = AMO | (0b010 << kFunct3Shift) | (0b00000 << kFunct5Shift), -+ RO_AMOXOR_W = AMO | (0b010 << kFunct3Shift) | (0b00100 << kFunct5Shift), -+ RO_AMOAND_W = AMO | (0b010 << kFunct3Shift) | (0b01100 << kFunct5Shift), -+ RO_AMOOR_W = AMO | (0b010 << kFunct3Shift) | (0b01000 << kFunct5Shift), -+ RO_AMOMIN_W = AMO | (0b010 << kFunct3Shift) | (0b10000 << kFunct5Shift), -+ RO_AMOMAX_W = AMO | (0b010 << kFunct3Shift) | (0b10100 << kFunct5Shift), -+ RO_AMOMINU_W = AMO | (0b010 << kFunct3Shift) | (0b11000 << kFunct5Shift), -+ RO_AMOMAXU_W = AMO | (0b010 << kFunct3Shift) | (0b11100 << kFunct5Shift), -+ -+ // RV64A Standard Extension (in addition to RV32A) -+ RO_LR_D = AMO | (0b011 << kFunct3Shift) | (0b00010 << kFunct5Shift), -+ RO_SC_D = AMO | (0b011 << kFunct3Shift) | (0b00011 << kFunct5Shift), -+ RO_AMOSWAP_D = AMO | (0b011 << kFunct3Shift) | (0b00001 << kFunct5Shift), -+ RO_AMOADD_D = AMO | (0b011 << kFunct3Shift) | (0b00000 << kFunct5Shift), -+ RO_AMOXOR_D = AMO | (0b011 << kFunct3Shift) | (0b00100 << kFunct5Shift), -+ RO_AMOAND_D = AMO | (0b011 << kFunct3Shift) | (0b01100 << kFunct5Shift), -+ RO_AMOOR_D = AMO | (0b011 << kFunct3Shift) | (0b01000 << kFunct5Shift), -+ RO_AMOMIN_D = AMO | (0b011 << kFunct3Shift) | (0b10000 << kFunct5Shift), -+ RO_AMOMAX_D = AMO | (0b011 << kFunct3Shift) | (0b10100 << kFunct5Shift), -+ RO_AMOMINU_D = AMO | (0b011 << kFunct3Shift) | (0b11000 << kFunct5Shift), -+ RO_AMOMAXU_D = AMO | (0b011 << kFunct3Shift) | (0b11100 << kFunct5Shift), -+ -+ // RV32F Standard Extension -+ RO_FLW = LOAD_FP | (0b010 << kFunct3Shift), -+ RO_FSW = STORE_FP | (0b010 << kFunct3Shift), -+ RO_FMADD_S = MADD | (0b00 << kFunct2Shift), -+ RO_FMSUB_S = MSUB | (0b00 << kFunct2Shift), -+ RO_FNMSUB_S = NMSUB | (0b00 << kFunct2Shift), -+ RO_FNMADD_S = NMADD | (0b00 << kFunct2Shift), -+ RO_FADD_S = OP_FP | (0b0000000 << kFunct7Shift), -+ RO_FSUB_S = OP_FP | (0b0000100 << kFunct7Shift), -+ RO_FMUL_S = OP_FP | (0b0001000 << kFunct7Shift), -+ RO_FDIV_S = OP_FP | (0b0001100 << kFunct7Shift), -+ RO_FSQRT_S = OP_FP | (0b0101100 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FSGNJ_S = OP_FP | (0b000 << kFunct3Shift) | (0b0010000 << kFunct7Shift), -+ RO_FSGNJN_S = OP_FP | (0b001 << kFunct3Shift) | (0b0010000 << kFunct7Shift), -+ RO_FSQNJX_S = OP_FP | (0b010 << kFunct3Shift) | (0b0010000 << kFunct7Shift), -+ RO_FMIN_S = OP_FP | (0b000 << kFunct3Shift) | (0b0010100 << kFunct7Shift), -+ RO_FMAX_S = OP_FP | (0b001 << kFunct3Shift) | (0b0010100 << kFunct7Shift), -+ RO_FCVT_W_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FCVT_WU_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00001 << kRs2Shift), -+ RO_FMV = OP_FP | (0b1110000 << kFunct7Shift) | (0b000 << kFunct3Shift) | -+ (0b00000 << kRs2Shift), -+ RO_FEQ_S = OP_FP | (0b010 << kFunct3Shift) | (0b1010000 << kFunct7Shift), -+ RO_FLT_S = OP_FP | (0b001 << kFunct3Shift) | (0b1010000 << kFunct7Shift), -+ RO_FLE_S = OP_FP | (0b000 << kFunct3Shift) | (0b1010000 << kFunct7Shift), -+ RO_FCLASS_S = OP_FP | (0b001 << kFunct3Shift) | (0b1110000 << kFunct7Shift), -+ RO_FCVT_S_W = OP_FP | (0b1101000 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FCVT_S_WU = OP_FP | (0b1101000 << kFunct7Shift) | (0b00001 << kRs2Shift), -+ RO_FMV_W_X = OP_FP | (0b000 << kFunct3Shift) | (0b1111000 << kFunct7Shift), -+ -+ // RV64F Standard Extension (in addition to RV32F) -+ RO_FCVT_L_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00010 << kRs2Shift), -+ RO_FCVT_LU_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00011 << kRs2Shift), -+ RO_FCVT_S_L = OP_FP | (0b1101000 << kFunct7Shift) | (0b00010 << kRs2Shift), -+ RO_FCVT_S_LU = OP_FP | (0b1101000 << kFunct7Shift) | (0b00011 << kRs2Shift), -+ -+ // RV32D Standard Extension -+ RO_FLD = LOAD_FP | (0b011 << kFunct3Shift), -+ RO_FSD = STORE_FP | (0b011 << kFunct3Shift), -+ RO_FMADD_D = MADD | (0b01 << kFunct2Shift), -+ RO_FMSUB_D = MSUB | (0b01 << kFunct2Shift), -+ RO_FNMSUB_D = NMSUB | (0b01 << kFunct2Shift), -+ RO_FNMADD_D = NMADD | (0b01 << kFunct2Shift), -+ RO_FADD_D = OP_FP | (0b0000001 << kFunct7Shift), -+ RO_FSUB_D = OP_FP | (0b0000101 << kFunct7Shift), -+ RO_FMUL_D = OP_FP | (0b0001001 << kFunct7Shift), -+ RO_FDIV_D = OP_FP | (0b0001101 << kFunct7Shift), -+ RO_FSQRT_D = OP_FP | (0b0101101 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FSGNJ_D = OP_FP | (0b000 << kFunct3Shift) | (0b0010001 << kFunct7Shift), -+ RO_FSGNJN_D = OP_FP | (0b001 << kFunct3Shift) | (0b0010001 << kFunct7Shift), -+ RO_FSQNJX_D = OP_FP | (0b010 << kFunct3Shift) | (0b0010001 << kFunct7Shift), -+ RO_FMIN_D = OP_FP | (0b000 << kFunct3Shift) | (0b0010101 << kFunct7Shift), -+ RO_FMAX_D = OP_FP | (0b001 << kFunct3Shift) | (0b0010101 << kFunct7Shift), -+ RO_FCVT_S_D = OP_FP | (0b0100000 << kFunct7Shift) | (0b00001 << kRs2Shift), -+ RO_FCVT_D_S = OP_FP | (0b0100001 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FEQ_D = OP_FP | (0b010 << kFunct3Shift) | (0b1010001 << kFunct7Shift), -+ RO_FLT_D = OP_FP | (0b001 << kFunct3Shift) | (0b1010001 << kFunct7Shift), -+ RO_FLE_D = OP_FP | (0b000 << kFunct3Shift) | (0b1010001 << kFunct7Shift), -+ RO_FCLASS_D = OP_FP | (0b001 << kFunct3Shift) | (0b1110001 << kFunct7Shift) | -+ (0b00000 << kRs2Shift), -+ RO_FCVT_W_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FCVT_WU_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00001 << kRs2Shift), -+ RO_FCVT_D_W = OP_FP | (0b1101001 << kFunct7Shift) | (0b00000 << kRs2Shift), -+ RO_FCVT_D_WU = OP_FP | (0b1101001 << kFunct7Shift) | (0b00001 << kRs2Shift), -+ -+ // RV64D Standard Extension (in addition to RV32D) -+ RO_FCVT_L_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00010 << kRs2Shift), -+ RO_FCVT_LU_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00011 << kRs2Shift), -+ RO_FMV_X_D = OP_FP | (0b000 << kFunct3Shift) | (0b1110001 << kFunct7Shift) | -+ (0b00000 << kRs2Shift), -+ RO_FCVT_D_L = OP_FP | (0b1101001 << kFunct7Shift) | (0b00010 << kRs2Shift), -+ RO_FCVT_D_LU = OP_FP | (0b1101001 << kFunct7Shift) | (0b00011 << kRs2Shift), -+ RO_FMV_D_X = OP_FP | (0b000 << kFunct3Shift) | (0b1111001 << kFunct7Shift) | -+ (0b00000 << kRs2Shift), -+}; -+ -+// ----- Emulated conditions. -+// On RISC-V we use this enum to abstract from conditional branch instructions. -+// The 'U' prefix is used to specify unsigned comparisons. -+// Opposite conditions must be paired as odd/even numbers -+// because 'NegateCondition' function flips LSB to negate condition. -+enum Condition { // Any value < 0 is considered no_condition. -+ kNoCondition = -1, -+ overflow = 0, -+ no_overflow = 1, -+ Uless = 2, -+ Ugreater_equal = 3, -+ Uless_equal = 4, -+ Ugreater = 5, -+ equal = 6, -+ not_equal = 7, // Unordered or Not Equal. -+ less = 8, -+ greater_equal = 9, -+ less_equal = 10, -+ greater = 11, -+ cc_always = 12, -+ -+ // Aliases. -+ eq = equal, -+ ne = not_equal, -+ ge = greater_equal, -+ lt = less, -+ gt = greater, -+ le = less_equal, -+ al = cc_always, -+ ult = Uless, -+ uge = Ugreater_equal, -+ ule = Uless_equal, -+ ugt = Ugreater, -+}; -+ -+// Returns the equivalent of !cc. -+// Negation of the default kNoCondition (-1) results in a non-default -+// no_condition value (-2). As long as tests for no_condition check -+// for condition < 0, this will work as expected. -+inline Condition NegateCondition(Condition cc) { -+ DCHECK(cc != cc_always); -+ return static_cast(cc ^ 1); -+} -+ -+inline Condition NegateFpuCondition(Condition cc) { -+ DCHECK(cc != cc_always); -+ switch (cc) { -+ case ult: -+ return ge; -+ case ugt: -+ return le; -+ case uge: -+ return lt; -+ case ule: -+ return gt; -+ case lt: -+ return uge; -+ case gt: -+ return ule; -+ case ge: -+ return ult; -+ case le: -+ return ugt; -+ case eq: -+ return ne; -+ case ne: -+ return eq; -+ default: -+ return cc; -+ } -+} -+ -+// ----- Coprocessor conditions. -+enum FPUCondition { -+ kNoFPUCondition = -1, -+ EQ = 0x02, // Ordered and Equal -+ NE = 0x03, // Unordered or Not Equal -+ LT = 0x04, // Ordered and Less Than -+ GE = 0x05, // Ordered and Greater Than or Equal -+ LE = 0x06, // Ordered and Less Than or Equal -+ GT = 0x07, // Ordered and Greater Than -+}; -+ -+enum CheckForInexactConversion { -+ kCheckForInexactConversion, -+ kDontCheckForInexactConversion -+}; -+ -+enum class MaxMinKind : int { kMin = 0, kMax = 1 }; -+ -+// ---------------------------------------------------------------------------- -+// RISCV flags -+ -+enum ControlStatusReg { -+ csr_fflags = 0x001, // Floating-Point Accrued Exceptions (RW) -+ csr_frm = 0x002, // Floating-Point Dynamic Rounding Mode (RW) -+ csr_fcsr = 0x003, // Floating-Point Control and Status Register (RW) -+ csr_cycle = 0xc00, // Cycle counter for RDCYCLE instruction (RO) -+ csr_time = 0xc01, // Timer for RDTIME instruction (RO) -+ csr_instret = 0xc02, // Insns-retired counter for RDINSTRET instruction (RO) -+ csr_cycleh = 0xc80, // Upper 32 bits of cycle, RV32I only (RO) -+ csr_timeh = 0xc81, // Upper 32 bits of time, RV32I only (RO) -+ csr_instreth = 0xc82 // Upper 32 bits of instret, RV32I only (RO) -+}; -+ -+enum FFlagsMask { -+ kInvalidOperation = 0b10000, // NV: Invalid -+ kDivideByZero = 0b1000, // DZ: Divide by Zero -+ kOverflow = 0b100, // OF: Overflow -+ kUnderflow = 0b10, // UF: Underflow -+ kInexact = 0b1 // NX: Inexact -+}; -+ -+enum RoundingMode { -+ RNE = 0b000, // Round to Nearest, ties to Even -+ RTZ = 0b001, // Round towards Zero -+ RDN = 0b010, // Round Down (towards -infinity) -+ RUP = 0b011, // Round Up (towards +infinity) -+ RMM = 0b100, // Round to Nearest, tiest to Max Magnitude -+ DYN = 0b111 // In instruction's rm field, selects dynamic rounding mode; -+ // In Rounding Mode register, Invalid -+}; -+ -+enum MemoryOdering { -+ PSI = 0b1000, // PI or SI -+ PSO = 0b0100, // PO or SO -+ PSR = 0b0010, // PR or SR -+ PSW = 0b0001, // PW or SW -+ PSIORW = PSI | PSO | PSR | PSW -+}; -+ -+enum FClassFlag { -+ kNegativeInfinity = 1, -+ kNegativeNormalNumber = 1 << 1, -+ kNegativeSubnormalNumber = 1 << 2, -+ kNegativeZero = 1 << 3, -+ kPositiveZero = 1 << 4, -+ kPositiveSubnormalNumber = 1 << 5, -+ kPositiveNormalNumber = 1 << 6, -+ kPositiveInfinity = 1 << 7, -+ kSignalingNaN = 1 << 8, -+ kQuietNaN = 1 << 9 -+}; -+ -+// ----------------------------------------------------------------------------- -+// Hints. -+ -+// Branch hints are not used on RISC-V. They are defined so that they can -+// appear in shared function signatures, but will be ignored in RISC-V -+// implementations. -+enum Hint { no_hint = 0 }; -+ -+inline Hint NegateHint(Hint hint) { return no_hint; } -+ -+// ----------------------------------------------------------------------------- -+// Specific instructions, constants, and masks. -+// These constants are declared in assembler-riscv64.cc, as they use named -+// registers and other constants. -+ -+// An ECALL instruction, used for redirected real time call -+const Instr rtCallRedirInstr = SYSTEM; // All other bits are 0s (i.e., ecall) -+// An EBreak instruction, used for debugging and semi-hosting -+const Instr kBreakInstr = SYSTEM | 1 << kImm12Shift; // ebreak -+ -+constexpr uint8_t kInstrSize = 4; -+constexpr uint8_t kInstrSizeLog2 = 2; -+ -+class InstructionBase { -+ public: -+ enum { -+ // On RISC-V, PC cannot actually be directly accessed. We behave as if PC -+ // was always the value of the current instruction being executed. -+ kPCReadOffset = 0 -+ }; -+ -+ // Instruction type. -+ enum Type { -+ kRType, -+ kR4Type, // Special R4 for Q extension -+ kIType, -+ kSType, -+ kBType, -+ kUType, -+ kJType, -+ kUnsupported = -1 -+ }; -+ -+ // Get the raw instruction bits. -+ inline Instr InstructionBits() const { -+ return *reinterpret_cast(this); -+ } -+ -+ // Set the raw instruction bits to value. -+ inline void SetInstructionBits(Instr value) { -+ *reinterpret_cast(this) = value; -+ } -+ -+ // Read one particular bit out of the instruction bits. -+ inline int Bit(int nr) const { return (InstructionBits() >> nr) & 1; } -+ -+ // Read a bit field out of the instruction bits. -+ inline int Bits(int hi, int lo) const { -+ return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); -+ } -+ -+ // Accessors for the different named fields used in the RISC-V encoding. -+ inline Opcode BaseOpcodeValue() const { -+ return static_cast( -+ Bits(kBaseOpcodeShift + kBaseOpcodeBits - 1, kBaseOpcodeShift)); -+ } -+ -+ // Return the fields at their original place in the instruction encoding. -+ inline Opcode BaseOpcodeFieldRaw() const { -+ return static_cast(InstructionBits() & kBaseOpcodeMask); -+ } -+ -+ // Safe to call within R-type instructions -+ inline int Funct7FieldRaw() const { return InstructionBits() & kFunct7Mask; } -+ -+ // Safe to call within R-, I-, S-, or B-type instructions -+ inline int Funct3FieldRaw() const { return InstructionBits() & kFunct3Mask; } -+ -+ // Safe to call within R-, I-, S-, or B-type instructions -+ inline int Rs1FieldRawNoAssert() const { -+ return InstructionBits() & kRs1FieldMask; -+ } -+ -+ // Safe to call within R-, S-, or B-type instructions -+ inline int Rs2FieldRawNoAssert() const { -+ return InstructionBits() & kRs2FieldMask; -+ } -+ -+ // Safe to call within R4-type instructions -+ inline int Rs3FieldRawNoAssert() const { -+ return InstructionBits() & kRs3FieldMask; -+ } -+ -+ inline int32_t ITypeBits() const { return InstructionBits() & kITypeMask; } -+ -+ // Get the encoding type of the instruction. -+ inline Type InstructionType() const; -+ -+ protected: -+ InstructionBase() {} -+}; -+ -+template -+class InstructionGetters : public T { -+ public: -+ inline int BaseOpcode() const { -+ return this->InstructionBits() & kBaseOpcodeMask; -+ } -+ -+ inline int Rs1Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType || -+ this->InstructionType() == InstructionBase::kR4Type || -+ this->InstructionType() == InstructionBase::kIType || -+ this->InstructionType() == InstructionBase::kSType || -+ this->InstructionType() == InstructionBase::kBType); -+ return this->Bits(kRs1Shift + kRs1Bits - 1, kRs1Shift); -+ } -+ -+ inline int Rs2Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType || -+ this->InstructionType() == InstructionBase::kR4Type || -+ this->InstructionType() == InstructionBase::kSType || -+ this->InstructionType() == InstructionBase::kBType); -+ return this->Bits(kRs2Shift + kRs2Bits - 1, kRs2Shift); -+ } -+ -+ inline int Rs3Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kR4Type); -+ return this->Bits(kRs3Shift + kRs3Bits - 1, kRs3Shift); -+ } -+ -+ inline int RdValue() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType || -+ this->InstructionType() == InstructionBase::kR4Type || -+ this->InstructionType() == InstructionBase::kIType || -+ this->InstructionType() == InstructionBase::kUType || -+ this->InstructionType() == InstructionBase::kJType); -+ return this->Bits(kRdShift + kRdBits - 1, kRdShift); -+ } -+ -+ inline int Funct7Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType); -+ return this->Bits(kFunct7Shift + kFunct7Bits - 1, kFunct7Shift); -+ } -+ -+ inline int Funct3Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType || -+ this->InstructionType() == InstructionBase::kIType || -+ this->InstructionType() == InstructionBase::kSType || -+ this->InstructionType() == InstructionBase::kBType); -+ return this->Bits(kFunct3Shift + kFunct3Bits - 1, kFunct3Shift); -+ } -+ -+ inline int Funct5Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kRType && -+ this->BaseOpcode() == OP_FP); -+ return this->Bits(kFunct5Shift + kFunct5Bits - 1, kFunct5Shift); -+ } -+ -+ inline int CsrValue() const { -+ DCHECK(this->InstructionType() == InstructionBase::kIType && -+ this->BaseOpcode() == SYSTEM); -+ return (this->Bits(kCsrShift + kCsrBits - 1, kCsrShift)); -+ } -+ -+ inline int RoundMode() const { -+ DCHECK((this->InstructionType() == InstructionBase::kRType || -+ this->InstructionType() == InstructionBase::kR4Type) && -+ this->BaseOpcode() == OP_FP); -+ return this->Bits(kFunct3Shift + kFunct3Bits - 1, kFunct3Shift); -+ } -+ -+ inline int MemoryOrder(bool is_pred) const { -+ DCHECK((this->InstructionType() == InstructionBase::kIType && -+ this->BaseOpcode() == MISC_MEM)); -+ if (is_pred) { -+ return this->Bits(kPredOrderShift + kMemOrderBits - 1, kPredOrderShift); -+ } else { -+ return this->Bits(kSuccOrderShift + kMemOrderBits - 1, kSuccOrderShift); -+ } -+ } -+ -+ inline int Imm12Value() const { -+ DCHECK(this->InstructionType() == InstructionBase::kIType); -+ int Value = this->Bits(kImm12Shift + kImm12Bits - 1, kImm12Shift); -+ return Value << 20 >> 20; -+ } -+ -+ inline int32_t Imm12SExtValue() const { -+ int32_t Value = this->Imm12Value() << 20 >> 20; -+ return Value; -+ } -+ -+ inline int BranchOffset() const { -+ DCHECK(this->InstructionType() == InstructionBase::kBType); -+ // | imm[12|10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode | -+ // 31 25 11 7 -+ uint32_t Bits = this->InstructionBits(); -+ int16_t imm13 = ((Bits & 0xf00) >> 7) | ((Bits & 0x7e000000) >> 20) | -+ ((Bits & 0x80) << 4) | ((Bits & 0x80000000) >> 19); -+ return imm13 << 19 >> 19; -+ } -+ -+ inline int StoreOffset() const { -+ DCHECK(this->InstructionType() == InstructionBase::kSType); -+ // | imm[11:5] | rs2 | rs1 | funct3 | imm[4:0] | opcode | -+ // 31 25 11 7 -+ uint32_t Bits = this->InstructionBits(); -+ int16_t imm12 = ((Bits & 0xf80) >> 7) | ((Bits & 0xfe000000) >> 20); -+ return imm12 << 20 >> 20; -+ } -+ -+ inline int Imm20UValue() const { -+ DCHECK(this->InstructionType() == InstructionBase::kUType); -+ // | imm[31:12] | rd | opcode | -+ // 31 12 -+ int32_t Bits = this->InstructionBits(); -+ return Bits >> 12; -+ } -+ -+ inline int Imm20JValue() const { -+ DCHECK(this->InstructionType() == InstructionBase::kJType); -+ // | imm[20|10:1|11|19:12] | rd | opcode | -+ // 31 12 -+ uint32_t Bits = this->InstructionBits(); -+ int32_t imm20 = ((Bits & 0x7fe00000) >> 20) | ((Bits & 0x100000) >> 9) | -+ (Bits & 0xff000) | ((Bits & 0x80000000) >> 11); -+ return imm20 << 11 >> 11; -+ } -+ -+ inline bool IsArithShift() const { -+ // Valid only for right shift operations -+ DCHECK((this->BaseOpcode() == OP || this->BaseOpcode() == OP_32 || -+ this->BaseOpcode() == OP_IMM || this->BaseOpcode() == OP_IMM_32) && -+ this->Funct3Value() == 0b101); -+ return this->InstructionBits() & 0x40000000; -+ } -+ -+ inline int Shamt() const { -+ // Valid only for shift instructions (SLLI, SRLI, SRAI) -+ DCHECK((this->InstructionBits() & kBaseOpcodeMask) == OP_IMM && -+ (this->Funct3Value() == 0b001 || this->Funct3Value() == 0b101)); -+ // | 0A0000 | shamt | rs1 | funct3 | rd | opcode | -+ // 31 25 20 -+ return this->Bits(kImm12Shift + 5, kImm12Shift); -+ } -+ -+ inline int Shamt32() const { -+ // Valid only for shift instructions (SLLIW, SRLIW, SRAIW) -+ DCHECK((this->InstructionBits() & kBaseOpcodeMask) == OP_IMM_32 && -+ (this->Funct3Value() == 0b001 || this->Funct3Value() == 0b101)); -+ // | 0A00000 | shamt | rs1 | funct3 | rd | opcode | -+ // 31 24 20 -+ return this->Bits(kImm12Shift + 4, kImm12Shift); -+ } -+ -+ inline bool AqValue() const { return this->Bits(kAqShift, kAqShift); } -+ -+ inline bool RlValue() const { return this->Bits(kRlShift, kRlShift); } -+ -+ // Say if the instruction is a break or a trap. -+ bool IsTrap() const; -+}; -+ -+class Instruction : public InstructionGetters { -+ public: -+ // Instructions are read of out a code stream. The only way to get a -+ // reference to an instruction is to convert a pointer. There is no way -+ // to allocate or create instances of class Instruction. -+ // Use the At(pc) function to create references to Instruction. -+ static Instruction* At(byte* pc) { -+ return reinterpret_cast(pc); -+ } -+ -+ private: -+ // We need to prevent the creation of instances of class Instruction. -+ DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); -+}; -+ -+// ----------------------------------------------------------------------------- -+// RISC-V assembly various constants. -+ -+// C/C++ argument slots size. -+const int kCArgSlotCount = 0; -+ -+// TODO(plind): below should be based on kPointerSize -+// TODO(plind): find all usages and remove the needless instructions for n64. -+const int kCArgsSlotsSize = kCArgSlotCount * kInstrSize * 2; -+ -+const int kInvalidStackOffset = -1; -+const int kBranchReturnOffset = 2 * kInstrSize; -+ -+static const int kNegOffset = 0x00008000; -+ -+InstructionBase::Type InstructionBase::InstructionType() const { -+ // RISCV routine -+ switch (InstructionBits() & kBaseOpcodeMask) { -+ case LOAD: -+ return kIType; -+ case LOAD_FP: -+ return kIType; -+ case MISC_MEM: -+ return kIType; -+ case OP_IMM: -+ return kIType; -+ case AUIPC: -+ return kUType; -+ case OP_IMM_32: -+ return kIType; -+ case STORE: -+ return kSType; -+ case STORE_FP: -+ return kSType; -+ case AMO: -+ return kRType; -+ case OP: -+ return kRType; -+ case LUI: -+ return kUType; -+ case OP_32: -+ return kRType; -+ case MADD: -+ case MSUB: -+ case NMSUB: -+ case NMADD: -+ return kR4Type; -+ case OP_FP: -+ return kRType; -+ case BRANCH: -+ return kBType; -+ case JALR: -+ return kIType; -+ case JAL: -+ return kJType; -+ case SYSTEM: -+ return kIType; -+ } -+ return kUnsupported; -+} -+ -+// ----------------------------------------------------------------------------- -+// Instructions. -+ -+template -+bool InstructionGetters

::IsTrap() const { -+ return (this->InstructionBits() == kBreakInstr); -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/cpu-riscv64.cc -@@ -0,0 +1,28 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// CPU specific code for arm independent of OS goes here. -+ -+#include -+#include -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/cpu-features.h" -+ -+namespace v8 { -+namespace internal { -+ -+void CpuFeatures::FlushICache(void* start, size_t size) { -+#if !defined(USE_SIMULATOR) -+ // FIXME(RISCV): builtin_clear_cache doesn't work yet, so use `fence.i` for now -+ // __builtin___clear_cache(start, (char *)start + size); -+ asm volatile("fence.i" ::: "memory"); -+#endif // !USE_SIMULATOR. -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc -@@ -0,0 +1,348 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/interface-descriptors.h" -+#include "src/execution/frames.h" -+ -+namespace v8 { -+namespace internal { -+ -+const Register CallInterfaceDescriptor::ContextRegister() { return cp; } -+ -+void CallInterfaceDescriptor::DefaultInitializePlatformSpecific( -+ CallInterfaceDescriptorData* data, int register_parameter_count) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ CHECK_LE(static_cast(register_parameter_count), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(register_parameter_count, -+ default_stub_registers); -+} -+ -+void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3}; -+ CHECK_EQ(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+void WasmI64AtomicWait32Descriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; -+ CHECK_EQ(static_cast(kParameterCount - kStackArgumentsCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount - kStackArgumentsCount, -+ default_stub_registers); -+} -+ -+void RecordWriteDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0}; -+ -+ data->RestrictAllocatableRegisters(default_stub_registers, -+ arraysize(default_stub_registers)); -+ -+ CHECK_LE(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0}; -+ -+ data->RestrictAllocatableRegisters(default_stub_registers, -+ arraysize(default_stub_registers)); -+ -+ CHECK_LE(static_cast(kParameterCount), -+ arraysize(default_stub_registers)); -+ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); -+} -+ -+const Register LoadDescriptor::ReceiverRegister() { return a1; } -+const Register LoadDescriptor::NameRegister() { return a2; } -+const Register LoadDescriptor::SlotRegister() { return a0; } -+ -+const Register LoadWithVectorDescriptor::VectorRegister() { return a3; } -+ -+const Register -+LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() { -+ return a4; -+} -+ -+const Register StoreDescriptor::ReceiverRegister() { return a1; } -+const Register StoreDescriptor::NameRegister() { return a2; } -+const Register StoreDescriptor::ValueRegister() { return a0; } -+const Register StoreDescriptor::SlotRegister() { return a4; } -+ -+const Register StoreWithVectorDescriptor::VectorRegister() { return a3; } -+ -+const Register StoreTransitionDescriptor::SlotRegister() { return a4; } -+const Register StoreTransitionDescriptor::VectorRegister() { return a3; } -+const Register StoreTransitionDescriptor::MapRegister() { return a5; } -+ -+const Register ApiGetterDescriptor::HolderRegister() { return a0; } -+const Register ApiGetterDescriptor::CallbackRegister() { return a3; } -+ -+const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } -+const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } -+ -+// static -+const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } -+ -+void TypeofDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a3}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallTrampolineDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: target -+ // a0: number of arguments -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a4 : arguments list length (untagged) -+ // a2 : arguments list (FixedArray) -+ Register registers[] = {a1, a0, a4, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallForwardVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: the target to call -+ // a0: number of arguments -+ // a2: start index (to support rest parameters) -+ Register registers[] = {a1, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallFunctionTemplateDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : function template info -+ // a0 : number of arguments (on the stack, not including receiver) -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallWithSpreadDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a2 : the object to spread -+ Register registers[] = {a1, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CallWithArrayLikeDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : the target to call -+ // a2 : the arguments list -+ Register registers[] = {a1, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a3 : the new target -+ // a4 : arguments list length (untagged) -+ // a2 : arguments list (FixedArray) -+ Register registers[] = {a1, a3, a0, a4, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: the target to call -+ // a3: new target -+ // a0: number of arguments -+ // a2: start index (to support rest parameters) -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructWithSpreadDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a0 : number of arguments (on the stack, not including receiver) -+ // a1 : the target to call -+ // a3 : the new target -+ // a2 : the object to spread -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1 : the target to call -+ // a3 : the new target -+ // a2 : the arguments list -+ Register registers[] = {a1, a3, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ConstructStubDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // a1: target -+ // a3: new target -+ // a0: number of arguments -+ // a2: allocation site or undefined -+ Register registers[] = {a1, a3, a0, a2}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void AbortDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void CompareDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void BinaryOpDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a1, a0}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ArgumentsAdaptorDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // JSFunction -+ a3, // the new target -+ a0, // actual number of arguments -+ a2, // expected number of arguments -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ApiCallbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // kApiFunctionAddress -+ a2, // kArgc -+ a3, // kCallData -+ a0, // kHolder -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterDispatchDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister, -+ kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // argument count (not including receiver) -+ a2, // address of first argument -+ a1 // the target callable to be call -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // argument count (not including receiver) -+ a4, // address of the first argument -+ a1, // constructor to call -+ a3, // new target -+ a2, // allocation site feedback if available, undefined otherwise -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void ResumeGeneratorDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a0, // the value to pass to the generator -+ a1 // the JSGeneratorObject to resume -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void FrameDropperTrampolineDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = { -+ a1, // loaded new FP -+ }; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void RunMicrotasksEntryDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ Register registers[] = {a0, a1}; -+ data->InitializePlatformSpecific(arraysize(registers), registers); -+} -+ -+void BinaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallTrampoline_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void CallWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void ConstructWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void ConstructWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void Compare_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 4); -+} -+ -+void UnaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( -+ CallInterfaceDescriptorData* data) { -+ // TODO(v8:8888): Implement on this platform. -+ DefaultInitializePlatformSpecific(data, 3); -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/macro-assembler-riscv64.cc -@@ -0,0 +1,4336 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include // For LONG_MIN, LONG_MAX. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/base/bits.h" -+#include "src/base/division-by-constant.h" -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/callable.h" -+#include "src/codegen/code-factory.h" -+#include "src/codegen/external-reference-table.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/register-configuration.h" -+#include "src/debug/debug.h" -+#include "src/execution/frames-inl.h" -+#include "src/heap/memory-chunk.h" -+#include "src/init/bootstrapper.h" -+#include "src/logging/counters.h" -+#include "src/objects/heap-number.h" -+#include "src/runtime/runtime.h" -+#include "src/snapshot/embedded/embedded-data.h" -+#include "src/snapshot/snapshot.h" -+#include "src/wasm/wasm-code-manager.h" -+ -+// Satisfy cpplint check, but don't include platform-specific header. It is -+// included recursively via macro-assembler.h. -+#if 0 -+#include "src/codegen/riscv64/macro-assembler-riscv64.h" -+#endif -+ -+namespace v8 { -+namespace internal { -+ -+static inline bool IsZero(const Operand& rt) { -+ if (rt.is_reg()) { -+ return rt.rm() == zero_reg; -+ } else { -+ return rt.immediate() == 0; -+ } -+} -+ -+int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, -+ Register exclusion1, -+ Register exclusion2, -+ Register exclusion3) const { -+ int bytes = 0; -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ bytes += NumRegs(list) * kPointerSize; -+ -+ if (fp_mode == kSaveFPRegs) { -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ return bytes; -+} -+ -+int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, -+ Register exclusion2, Register exclusion3) { -+ int bytes = 0; -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ MultiPush(list); -+ bytes += NumRegs(list) * kPointerSize; -+ -+ if (fp_mode == kSaveFPRegs) { -+ MultiPushFPU(kCallerSavedFPU); -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ return bytes; -+} -+ -+int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, -+ Register exclusion2, Register exclusion3) { -+ int bytes = 0; -+ if (fp_mode == kSaveFPRegs) { -+ MultiPopFPU(kCallerSavedFPU); -+ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; -+ } -+ -+ RegList exclusions = 0; -+ if (exclusion1 != no_reg) { -+ exclusions |= exclusion1.bit(); -+ if (exclusion2 != no_reg) { -+ exclusions |= exclusion2.bit(); -+ if (exclusion3 != no_reg) { -+ exclusions |= exclusion3.bit(); -+ } -+ } -+ } -+ -+ RegList list = kJSCallerSaved & ~exclusions; -+ MultiPop(list); -+ bytes += NumRegs(list) * kPointerSize; -+ -+ return bytes; -+} -+ -+void TurboAssembler::LoadRoot(Register destination, RootIndex index) { -+ Ld(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); -+} -+ -+void TurboAssembler::LoadRoot(Register destination, RootIndex index, -+ Condition cond, Register src1, -+ const Operand& src2) { -+ Label skip; -+ Branch(&skip, NegateCondition(cond), src1, src2); -+ Ld(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); -+ bind(&skip); -+} -+ -+void TurboAssembler::PushCommonFrame(Register marker_reg) { -+ if (marker_reg.is_valid()) { -+ Push(ra, fp, marker_reg); -+ Add64(fp, sp, Operand(kPointerSize)); -+ } else { -+ Push(ra, fp); -+ mv(fp, sp); -+ } -+} -+ -+void TurboAssembler::PushStandardFrame(Register function_reg) { -+ int offset = -StandardFrameConstants::kContextOffset; -+ if (function_reg.is_valid()) { -+ Push(ra, fp, cp, function_reg); -+ offset += kPointerSize; -+ } else { -+ Push(ra, fp, cp); -+ } -+ Add64(fp, sp, Operand(offset)); -+} -+ -+int MacroAssembler::SafepointRegisterStackIndex(int reg_code) { -+ // The registers are pushed starting with the highest encoding, -+ // which means that lowest encodings are closest to the stack pointer. -+ return kSafepointRegisterStackIndexMap[reg_code]; -+} -+ -+// Clobbers object, dst, value, and ra, if (ra_status == kRAHasBeenSaved) -+// The register 'object' contains a heap object pointer. The heap object -+// tag is shifted away. -+void MacroAssembler::RecordWriteField(Register object, int offset, -+ Register value, Register dst, -+ RAStatus ra_status, -+ SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action, -+ SmiCheck smi_check) { -+ DCHECK(!AreAliased(value, dst, t5, object)); -+ // First, check if a write barrier is even needed. The tests below -+ // catch stores of Smis. -+ Label done; -+ -+ // Skip barrier if writing a smi. -+ if (smi_check == INLINE_SMI_CHECK) { -+ JumpIfSmi(value, &done); -+ } -+ -+ // Although the object register is tagged, the offset is relative to the start -+ // of the object, so so offset must be a multiple of kPointerSize. -+ DCHECK(IsAligned(offset, kPointerSize)); -+ -+ Add64(dst, object, Operand(offset - kHeapObjectTag)); -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Label ok; -+ And(t5, dst, Operand(kPointerSize - 1)); -+ Branch(&ok, eq, t5, Operand(zero_reg)); -+ ebreak(); -+ bind(&ok); -+ } -+ -+ RecordWrite(object, dst, value, ra_status, save_fp, remembered_set_action, -+ OMIT_SMI_CHECK); -+ -+ bind(&done); -+ -+ // Clobber clobbered input registers when running with the debug-code flag -+ // turned on to provoke errors. -+ if (emit_debug_code()) { -+ li(value, Operand(bit_cast(kZapValue + 4))); -+ li(dst, Operand(bit_cast(kZapValue + 8))); -+ } -+} -+ -+void TurboAssembler::SaveRegisters(RegList registers) { -+ DCHECK_GT(NumRegs(registers), 0); -+ RegList regs = 0; -+ for (int i = 0; i < Register::kNumRegisters; ++i) { -+ if ((registers >> i) & 1u) { -+ regs |= Register::from_code(i).bit(); -+ } -+ } -+ MultiPush(regs); -+} -+ -+void TurboAssembler::RestoreRegisters(RegList registers) { -+ DCHECK_GT(NumRegs(registers), 0); -+ RegList regs = 0; -+ for (int i = 0; i < Register::kNumRegisters; ++i) { -+ if ((registers >> i) & 1u) { -+ regs |= Register::from_code(i).bit(); -+ } -+ } -+ MultiPop(regs); -+} -+ -+void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address, -+ SaveFPRegsMode fp_mode) { -+ EphemeronKeyBarrierDescriptor descriptor; -+ RegList registers = descriptor.allocatable_registers(); -+ -+ SaveRegisters(registers); -+ -+ Register object_parameter( -+ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kObject)); -+ Register slot_parameter(descriptor.GetRegisterParameter( -+ EphemeronKeyBarrierDescriptor::kSlotAddress)); -+ Register fp_mode_parameter( -+ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kFPMode)); -+ -+ Push(object); -+ Push(address); -+ -+ Pop(slot_parameter); -+ Pop(object_parameter); -+ -+ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); -+ Call(isolate()->builtins()->builtin_handle(Builtins::kEphemeronKeyBarrier), -+ RelocInfo::CODE_TARGET); -+ RestoreRegisters(registers); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) { -+ CallRecordWriteStub( -+ object, address, remembered_set_action, fp_mode, -+ isolate()->builtins()->builtin_handle(Builtins::kRecordWrite), -+ kNullAddress); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, -+ Address wasm_target) { -+ CallRecordWriteStub(object, address, remembered_set_action, fp_mode, -+ Handle::null(), wasm_target); -+} -+ -+void TurboAssembler::CallRecordWriteStub( -+ Register object, Register address, -+ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, -+ Handle code_target, Address wasm_target) { -+ DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress); -+ // TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode, -+ // i.e. always emit remember set and save FP registers in RecordWriteStub. If -+ // large performance regression is observed, we should use these values to -+ // avoid unnecessary work. -+ -+ RecordWriteDescriptor descriptor; -+ RegList registers = descriptor.allocatable_registers(); -+ -+ SaveRegisters(registers); -+ Register object_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kObject)); -+ Register slot_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kSlot)); -+ Register remembered_set_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kRememberedSet)); -+ Register fp_mode_parameter( -+ descriptor.GetRegisterParameter(RecordWriteDescriptor::kFPMode)); -+ -+ Push(object); -+ Push(address); -+ -+ Pop(slot_parameter); -+ Pop(object_parameter); -+ -+ Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action)); -+ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); -+ if (code_target.is_null()) { -+ Call(wasm_target, RelocInfo::WASM_STUB_CALL); -+ } else { -+ Call(code_target, RelocInfo::CODE_TARGET); -+ } -+ -+ RestoreRegisters(registers); -+} -+ -+// Clobbers object, address, value, and ra, if (ra_status == kRAHasBeenSaved) -+// The register 'object' contains a heap object pointer. The heap object -+// tag is shifted away. -+void MacroAssembler::RecordWrite(Register object, Register address, -+ Register value, RAStatus ra_status, -+ SaveFPRegsMode fp_mode, -+ RememberedSetAction remembered_set_action, -+ SmiCheck smi_check) { -+ DCHECK(!AreAliased(object, address, value, t5)); -+ DCHECK(!AreAliased(object, address, value, t6)); -+ -+ if (emit_debug_code()) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Ld(scratch, MemOperand(address)); -+ Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, -+ Operand(value)); -+ } -+ -+ if ((remembered_set_action == OMIT_REMEMBERED_SET && -+ !FLAG_incremental_marking) || -+ FLAG_disable_write_barriers) { -+ return; -+ } -+ -+ // First, check if a write barrier is even needed. The tests below -+ // catch stores of smis and stores into the young generation. -+ Label done; -+ -+ if (smi_check == INLINE_SMI_CHECK) { -+ DCHECK_EQ(0, kSmiTag); -+ JumpIfSmi(value, &done); -+ } -+ -+ CheckPageFlag(value, -+ value, // Used as scratch. -+ MemoryChunk::kPointersToHereAreInterestingMask, eq, &done); -+ CheckPageFlag(object, -+ value, // Used as scratch. -+ MemoryChunk::kPointersFromHereAreInterestingMask, eq, &done); -+ -+ // Record the actual write. -+ if (ra_status == kRAHasNotBeenSaved) { -+ push(ra); -+ } -+ CallRecordWriteStub(object, address, remembered_set_action, fp_mode); -+ if (ra_status == kRAHasNotBeenSaved) { -+ pop(ra); -+ } -+ -+ bind(&done); -+ -+ // Clobber clobbered registers when running with the debug-code flag -+ // turned on to provoke errors. -+ if (emit_debug_code()) { -+ li(address, Operand(bit_cast(kZapValue + 12))); -+ li(value, Operand(bit_cast(kZapValue + 16))); -+ } -+} -+ -+// --------------------------------------------------------------------------- -+// Instruction macros. -+ -+void TurboAssembler::Add32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ addw(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ addiw(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ addw(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Add64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ add(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ addi(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ // Register scratch = temps.Acquire(); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ add(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sub32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ subw(rd, rs, rt.rm()); -+ } else { -+ DCHECK(is_int32(rt.immediate())); -+ if (is_int12(-rt.immediate()) && !MustUseReg(rt.rmode())) { -+ addiw(rd, rs, -+ static_cast( -+ -rt.immediate())); // No subiw instr, use addiw(x, y, -imm). -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ if (-rt.immediate() >> 12 == 0 && !MustUseReg(rt.rmode())) { -+ // Use load -imm and addu when loading -imm generates one instruction. -+ RV_li(scratch, -rt.immediate()); -+ addw(rd, rs, scratch); -+ } else { -+ // li handles the relocation. -+ RV_li(scratch, rt.immediate()); -+ subw(rd, rs, scratch); -+ } -+ } -+ } -+} -+ -+void TurboAssembler::Sub64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ sub(rd, rs, rt.rm()); -+ } else if (is_int12(-rt.immediate()) && !MustUseReg(rt.rmode())) { -+ addi(rd, rs, -+ static_cast( -+ -rt.immediate())); // No subi instr, use addi(x, y, -imm). -+ } else { -+ DCHECK(rs != t3); -+ int li_count = InstrCountForLi64Bit(rt.immediate()); -+ int li_neg_count = InstrCountForLi64Bit(-rt.immediate()); -+ if (li_neg_count < li_count && !MustUseReg(rt.rmode())) { -+ // Use load -imm and add when loading -imm generates one instruction. -+ DCHECK(rt.immediate() != std::numeric_limits::min()); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ RV_li(scratch, -rt.immediate()); -+ add(rd, rs, scratch); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ RV_li(scratch, rt.immediate()); -+ sub(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Mul32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ mulw(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ mulw(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Mulh32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ mul(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ mul(rd, rs, scratch); -+ } -+ srai(rd, rd, 32); -+} -+ -+void TurboAssembler::Mulhu32(Register rd, Register rs, const Operand& rt, -+ Register rsz, Register rtz) { -+ slli(rsz, rs, 32); -+ if (rt.is_reg()) -+ slli(rtz, rt.rm(), 32); -+ else -+ RV_li(rtz, rt.immediate() << 32); -+ mulhu(rd, rsz, rtz); -+ srai(rd, rd, 32); -+} -+ -+void TurboAssembler::Mul64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ mul(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ mul(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Mulh64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ mulh(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ mulh(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Div32(Register res, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ divw(res, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ divw(res, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Mod32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ remw(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ remw(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Modu32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ remuw(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ remuw(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Div64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ div(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ div(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Divu32(Register res, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ divuw(res, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ divuw(res, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Divu64(Register res, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ divu(res, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ divu(res, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Mod64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ rem(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ rem(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::Modu64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ remu(rd, rs, rt.rm()); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ remu(rd, rs, scratch); -+ } -+} -+ -+void TurboAssembler::And(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ and_(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ andi(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ and_(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Or(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ or_(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ ori(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ or_(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Xor(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ xor_(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ xori(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ xor_(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Nor(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ or_(rd, rs, rt.rm()); -+ not_(rd, rd); -+ } else { -+ Or(rd, rs, rt); -+ not_(rd, rd); -+ } -+} -+ -+void TurboAssembler::Neg(Register rs, const Operand& rt) { -+ DCHECK(rt.is_reg()); -+ neg(rs, rt.rm()); -+} -+ -+void TurboAssembler::Seqz(Register rd, const Operand& rt) { -+ if (rt.is_reg()) { -+ seqz(rd, rt.rm()); -+ } else { -+ li(rd, rt.immediate() == 0); -+ } -+} -+ -+void TurboAssembler::Snez(Register rd, const Operand& rt) { -+ if (rt.is_reg()) { -+ snez(rd, rt.rm()); -+ } else { -+ li(rd, rt.immediate() != 0); -+ } -+} -+ -+void TurboAssembler::Seq(Register rd, Register rs, const Operand& rt) { -+ if (rs == zero_reg) { -+ Seqz(rd, rt); -+ } else if (IsZero(rt)) { -+ seqz(rd, rs); -+ } else { -+ Sub64(rd, rs, rt); -+ seqz(rd, rd); -+ } -+} -+ -+void TurboAssembler::Sne(Register rd, Register rs, const Operand& rt) { -+ if (rs == zero_reg) { -+ Snez(rd, rt); -+ } else if (IsZero(rt)) { -+ snez(rd, rs); -+ } else { -+ Sub64(rd, rs, rt); -+ snez(rd, rd); -+ } -+} -+ -+void TurboAssembler::Slt(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ slt(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ slti(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ slt(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sltu(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ sltu(rd, rs, rt.rm()); -+ } else { -+ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { -+ sltiu(rd, rs, static_cast(rt.immediate())); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ sltu(rd, rs, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::Sle(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ slt(rd, rt.rm(), rs); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ slt(rd, scratch, rs); -+ } -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sleu(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ sltu(rd, rt.rm(), rs); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ sltu(rd, scratch, rs); -+ } -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sge(Register rd, Register rs, const Operand& rt) { -+ Slt(rd, rs, rt); -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sgeu(Register rd, Register rs, const Operand& rt) { -+ Sltu(rd, rs, rt); -+ xori(rd, rd, 1); -+} -+ -+void TurboAssembler::Sgt(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ slt(rd, rt.rm(), rs); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ slt(rd, scratch, rs); -+ } -+} -+ -+void TurboAssembler::Sgtu(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) { -+ sltu(rd, rt.rm(), rs); -+ } else { -+ // li handles the relocation. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ DCHECK(rs != scratch); -+ RV_li(scratch, rt.immediate()); -+ sltu(rd, scratch, rs); -+ } -+} -+ -+void TurboAssembler::Sll32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ sllw(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ slliw(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Sra32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ sraw(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ sraiw(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Srl32(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ srlw(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ srliw(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Sra64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ sra(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ srai(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Srl64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ srl(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ srli(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Sll64(Register rd, Register rs, const Operand& rt) { -+ if (rt.is_reg()) -+ sll(rd, rs, rt.rm()); -+ else { -+ uint8_t shamt = static_cast(rt.immediate()); -+ slli(rd, rs, shamt); -+ } -+} -+ -+void TurboAssembler::Ror(Register rd, Register rs, const Operand& rt) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ if (rt.is_reg()) { -+ negw(scratch, rt.rm()); -+ sllw(scratch, rs, scratch); -+ srlw(rd, rs, rt.rm()); -+ or_(rd, scratch, rd); -+ sext_w(rd, rd); -+ } else { -+ int64_t ror_value = rt.immediate() % 32; -+ if (ror_value == 0) { -+ mv(rd, rs); -+ return; -+ } else if (ror_value < 0) { -+ ror_value += 32; -+ } -+ srliw(scratch, rs, ror_value); -+ slliw(rd, rs, 32 - ror_value); -+ or_(rd, scratch, rd); -+ sext_w(rd, rd); -+ } -+} -+ -+void TurboAssembler::Dror(Register rd, Register rs, const Operand& rt) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ DCHECK(rs != scratch); -+ if (rt.is_reg()) { -+ negw(scratch, rt.rm()); -+ sll(scratch, rs, scratch); -+ srl(rd, rs, rt.rm()); -+ or_(rd, scratch, rd); -+ } else { -+ int64_t dror_value = rt.immediate() % 64; -+ if (dror_value == 0) { -+ mv(rd, rs); -+ return; -+ } else if (dror_value < 0) { -+ dror_value += 64; -+ } -+ srli(scratch, rs, dror_value); -+ slli(rd, rs, 64 - dror_value); -+ or_(rd, scratch, rd); -+ } -+} -+ -+void TurboAssembler::CalcScaledAddress(Register rd, Register rt, Register rs, -+ uint8_t sa, Register scratch) { -+ DCHECK(sa >= 1 && sa <= 31); -+ Register tmp = rd == rt ? scratch : rd; -+ DCHECK(tmp != rt); -+ slli(tmp, rs, sa); -+ Add64(rd, rt, tmp); -+} -+ -+// ------------Pseudo-instructions------------- -+// Change endianness -+void TurboAssembler::ByteSwap(Register rd, Register rs, int operand_size) { -+ DCHECK(operand_size == 4 || operand_size == 8); -+ DCHECK(rd != t5 && rd != t6); -+ if (operand_size == 4) { -+ // Uint32_t t5 = 0x00FF00FF; -+ // x = (x << 16 | x >> 16); -+ // x = (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)); -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register x = temps.Acquire(); -+ li(t5, 0x00FF00FF); -+ slliw(x, rs, 16); -+ srliw(rd, rs, 16); -+ or_(x, rd, x); // x <- x << 16 | x >> 16 -+ and_(t6, x, t5); // t <- x & 0x00FF00FF -+ slliw(t6, t6, 8); // t <- (x & t5) << 8 -+ slliw(t5, t5, 8); // t5 <- 0xFF00FF00 -+ and_(rd, x, t5); // x & 0xFF00FF00 -+ srliw(rd, rd, 8); -+ or_(rd, rd, t6); // (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)) -+ } else { -+ // uint64_t t5 = 0x0000FFFF0000FFFFl; -+ // uint64_t t5 = 0x00FF00FF00FF00FFl; -+ // x = (x << 32 | x >> 32); -+ // x = (x & t5) << 16 | (x & (t5 << 16)) >> 16; -+ // x = (x & t5) << 8 | (x & (t5 << 8)) >> 8; -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register x = temps.Acquire(); -+ li(t5, 0x0000FFFF0000FFFFl); -+ slli(x, rs, 32); -+ srli(rd, rs, 32); -+ or_(x, rd, x); // x <- x << 32 | x >> 32 -+ and_(t6, x, t5); // t <- x & 0x0000FFFF0000FFFF -+ slli(t6, t6, 16); // t <- (x & 0x0000FFFF0000FFFF) << 16 -+ slli(t5, t5, 16); // t5 <- 0xFFFF0000FFFF0000 -+ and_(rd, x, t5); // rd <- x & 0xFFFF0000FFFF0000 -+ srli(rd, rd, 16); // rd <- x & (t5 << 16)) >> 16 -+ or_(x, rd, t6); // (x & t5) << 16 | (x & (t5 << 16)) >> 16; -+ li(t5, 0x00FF00FF00FF00FFl); -+ and_(t6, x, t5); // t <- x & 0x00FF00FF00FF00FF -+ slli(t6, t6, 8); // t <- (x & t5) << 8 -+ slli(t5, t5, 8); // t5 <- 0xFF00FF00FF00FF00 -+ and_(rd, x, t5); -+ srli(rd, rd, 8); // rd <- (x & (t5 << 8)) >> 8 -+ or_(rd, rd, t6); // (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)) -+ } -+} -+ -+template -+void TurboAssembler::LoadNBytes(Register rd, const MemOperand& rs, -+ Register scratch) { -+ DCHECK(rd != rs.rm() && rd != scratch); -+ DCHECK(NBYTES <= 8); -+ -+ // load the most significant byte -+ if (LOAD_SIGNED) { -+ lb(rd, rs.rm(), rs.offset() + (NBYTES - 1)); -+ } else { -+ lbu(rd, rs.rm(), rs.offset() + (NBYTES - 1)); -+ } -+ -+ // load remaining (nbytes-1) bytes from higher to lower -+ slli(rd, rd, 8 * (NBYTES - 1)); -+ for (int i = (NBYTES - 2); i >= 0; i--) { -+ lbu(scratch, rs.rm(), rs.offset() + i); -+ if (i) slli(scratch, scratch, i * 8); -+ or_(rd, rd, scratch); -+ } -+} -+ -+template -+void TurboAssembler::LoadNBytesOverwritingBaseReg(const MemOperand& rs, -+ Register scratch0, -+ Register scratch1) { -+ // This function loads nbytes from memory specified by rs and into rs.rm() -+ DCHECK(rs.rm() != scratch0 && rs.rm() != scratch1 && scratch0 != scratch1); -+ DCHECK(NBYTES <= 8); -+ -+ // load the most significant byte -+ if (LOAD_SIGNED) { -+ lb(scratch0, rs.rm(), rs.offset() + (NBYTES - 1)); -+ } else { -+ lbu(scratch0, rs.rm(), rs.offset() + (NBYTES - 1)); -+ } -+ -+ // load remaining (nbytes-1) bytes from higher to lower -+ slli(scratch0, scratch0, 8 * (NBYTES - 1)); -+ for (int i = (NBYTES - 2); i >= 0; i--) { -+ lbu(scratch1, rs.rm(), rs.offset() + i); -+ if (i) { -+ slli(scratch1, scratch1, i * 8); -+ or_(scratch0, scratch0, scratch1); -+ } else { -+ // write to rs.rm() when processing the last byte -+ or_(rs.rm(), scratch0, scratch1); -+ } -+ } -+} -+ -+template -+void TurboAssembler::UnalignedLoadHelper(Register rd, const MemOperand& rs) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ UseScratchRegisterScope temps(this); -+ -+ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { -+ // Adjust offset for two accesses and check if offset + 3 fits into int12. -+ MemOperand source = rs; -+ Register scratch_base = temps.Acquire(); -+ DCHECK(scratch_base != rs.rm()); -+ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, -+ NBYTES - 1); -+ -+ // Since source.rm() is scratch_base, assume rd != source.rm() -+ DCHECK(rd != source.rm()); -+ Register scratch_other = t5; -+ LoadNBytes(rd, source, scratch_other); -+ } else { -+ // no need to adjust base-and-offset -+ if (rd != rs.rm()) { -+ Register scratch = temps.Acquire(); -+ LoadNBytes(rd, rs, scratch); -+ } else { // rd == rs.rm() -+ Register scratch0 = temps.Acquire(); -+ Register scratch1 = t5; -+ LoadNBytesOverwritingBaseReg(rs, scratch0, scratch1); -+ } -+ } -+} -+ -+template -+void TurboAssembler::UnalignedFLoadHelper(FPURegister frd, const MemOperand& rs, -+ Register scratch) { -+ DCHECK(scratch != rs.rm()); -+ DCHECK(NBYTES == 4 || NBYTES == 8); -+ -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ UseScratchRegisterScope temps(this); -+ MemOperand source = rs; -+ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { -+ // Adjust offset for two accesses and check if offset + 3 fits into int12. -+ Register scratch_base = temps.Acquire(); -+ DCHECK(scratch_base != scratch && scratch_base != rs.rm()); -+ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, -+ NBYTES - 1); -+ } -+ -+ Register scratch_other = temps.hasAvailable() ? temps.Acquire() : t5; -+ DCHECK(scratch_other != scratch && scratch_other != rs.rm()); -+ LoadNBytes(scratch, source, scratch_other); -+ if (NBYTES == 4) -+ fmv_w_x(frd, scratch); -+ else -+ fmv_d_x(frd, scratch); -+} -+ -+template -+void TurboAssembler::UnalignedStoreHelper(Register rd, const MemOperand& rs, -+ Register scratch_other) { -+ DCHECK(scratch_other != rs.rm()); -+ DCHECK(NBYTES <= 8); -+ -+ UseScratchRegisterScope temps(this); -+ MemOperand source = rs; -+ // Adjust offset for two accesses and check if offset + 3 fits into int12. -+ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { -+ Register scratch_base = temps.Acquire(); -+ DCHECK(scratch_base != rd && scratch_base != rs.rm()); -+ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, -+ NBYTES - 1); -+ } -+ -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (scratch_other == no_reg) -+ scratch_other = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ DCHECK(scratch_other != rd && scratch_other != rs.rm() && -+ scratch_other != source.rm()); -+ -+ sb(rd, source.rm(), source.offset()); -+ for (size_t i = 1; i <= (NBYTES - 1); i++) { -+ srli(scratch_other, rd, i * 8); -+ sb(scratch_other, source.rm(), source.offset() + i); -+ } -+} -+ -+template -+void TurboAssembler::UnalignedFStoreHelper(FPURegister frd, -+ const MemOperand& rs, -+ Register scratch) { -+ DCHECK(scratch != rs.rm()); -+ DCHECK(NBYTES == 8 || NBYTES == 4); -+ -+ if (NBYTES == 4) { -+ fmv_x_w(scratch, frd); -+ } else { -+ fmv_x_d(scratch, frd); -+ } -+ UnalignedStoreHelper(scratch, rs); -+} -+ -+template -+void TurboAssembler::AlignedLoadHelper(Reg_T target, const MemOperand& rs, -+ Func generator) { -+ MemOperand source = rs; -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (NeedAdjustBaseAndOffset(source)) { -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ DCHECK(scratch != rs.rm()); -+ AdjustBaseAndOffset(&source, scratch); -+ } -+ generator(target, source); -+} -+ -+template -+void TurboAssembler::AlignedStoreHelper(Reg_T value, const MemOperand& rs, -+ Func generator) { -+ MemOperand source = rs; -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (NeedAdjustBaseAndOffset(source)) { -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ // make sure scratch does not overwrite value -+ if (std::is_same::value) -+ DCHECK(scratch.code() != value.code()); -+ DCHECK(scratch != rs.rm()); -+ AdjustBaseAndOffset(&source, scratch); -+ } -+ generator(value, source); -+} -+ -+void TurboAssembler::Ulw(Register rd, const MemOperand& rs) { -+ UnalignedLoadHelper<4, true>(rd, rs); -+} -+ -+void TurboAssembler::Ulwu(Register rd, const MemOperand& rs) { -+ UnalignedLoadHelper<4, false>(rd, rs); -+} -+ -+void TurboAssembler::Usw(Register rd, const MemOperand& rs) { -+ UnalignedStoreHelper<4>(rd, rs); -+} -+ -+void TurboAssembler::Ulh(Register rd, const MemOperand& rs) { -+ UnalignedLoadHelper<2, true>(rd, rs); -+} -+ -+void TurboAssembler::Ulhu(Register rd, const MemOperand& rs) { -+ UnalignedLoadHelper<2, false>(rd, rs); -+} -+ -+void TurboAssembler::Ush(Register rd, const MemOperand& rs) { -+ UnalignedStoreHelper<2>(rd, rs); -+} -+ -+void TurboAssembler::Uld(Register rd, const MemOperand& rs) { -+ UnalignedLoadHelper<8, true>(rd, rs); -+} -+ -+// Load consequent 32-bit word pair in 64-bit reg. and put first word in low -+// bits, -+// second word in high bits. -+void MacroAssembler::LoadWordPair(Register rd, const MemOperand& rs, -+ Register scratch) { -+ Lwu(rd, rs); -+ Lw(scratch, MemOperand(rs.rm(), rs.offset() + kPointerSize / 2)); -+ slli(scratch, scratch, 32); -+ Add64(rd, rd, scratch); -+} -+ -+void TurboAssembler::Usd(Register rd, const MemOperand& rs) { -+ UnalignedStoreHelper<8>(rd, rs); -+} -+ -+// Do 64-bit store as two consequent 32-bit stores to unaligned address. -+void MacroAssembler::StoreWordPair(Register rd, const MemOperand& rs, -+ Register scratch) { -+ Sw(rd, rs); -+ srai(scratch, rd, 32); -+ Sw(scratch, MemOperand(rs.rm(), rs.offset() + kPointerSize / 2)); -+} -+ -+void TurboAssembler::ULoadFloat(FPURegister fd, const MemOperand& rs, -+ Register scratch) { -+ UnalignedFLoadHelper<4>(fd, rs, scratch); -+} -+ -+void TurboAssembler::UStoreFloat(FPURegister fd, const MemOperand& rs, -+ Register scratch) { -+ UnalignedFStoreHelper<4>(fd, rs, scratch); -+} -+ -+void TurboAssembler::ULoadDouble(FPURegister fd, const MemOperand& rs, -+ Register scratch) { -+ UnalignedFLoadHelper<8>(fd, rs, scratch); -+} -+ -+void TurboAssembler::UStoreDouble(FPURegister fd, const MemOperand& rs, -+ Register scratch) { -+ UnalignedFStoreHelper<8>(fd, rs, scratch); -+} -+ -+void TurboAssembler::Lb(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lb(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Lbu(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lbu(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Sb(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register value, const MemOperand& source) { -+ this->sb(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Lh(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lh(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Lhu(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lhu(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Sh(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register value, const MemOperand& source) { -+ this->sh(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Lw(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lw(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Lwu(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->lwu(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Sw(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register value, const MemOperand& source) { -+ this->sw(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Ld(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register target, const MemOperand& source) { -+ this->ld(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::Sd(Register rd, const MemOperand& rs) { -+ auto fn = [this](Register value, const MemOperand& source) { -+ this->sd(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(rd, rs, fn); -+} -+ -+void TurboAssembler::LoadFloat(FPURegister fd, const MemOperand& src) { -+ auto fn = [this](FPURegister target, const MemOperand& source) { -+ this->flw(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(fd, src, fn); -+} -+ -+void TurboAssembler::StoreFloat(FPURegister fs, const MemOperand& src) { -+ auto fn = [this](FPURegister value, const MemOperand& source) { -+ this->fsw(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(fs, src, fn); -+} -+ -+void TurboAssembler::LoadDouble(FPURegister fd, const MemOperand& src) { -+ auto fn = [this](FPURegister target, const MemOperand& source) { -+ this->fld(target, source.rm(), source.offset()); -+ }; -+ AlignedLoadHelper(fd, src, fn); -+} -+ -+void TurboAssembler::StoreDouble(FPURegister fs, const MemOperand& src) { -+ auto fn = [this](FPURegister value, const MemOperand& source) { -+ this->fsd(value, source.rm(), source.offset()); -+ }; -+ AlignedStoreHelper(fs, src, fn); -+} -+ -+void TurboAssembler::Ll(Register rd, const MemOperand& rs) { -+ bool is_one_instruction = rs.offset() == 0; -+ if (is_one_instruction) { -+ lr_w(false, false, rd, rs.rm()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Add64(scratch, rs.rm(), rs.offset()); -+ lr_w(false, false, rd, scratch); -+ } -+} -+ -+void TurboAssembler::Lld(Register rd, const MemOperand& rs) { -+ bool is_one_instruction = rs.offset() == 0; -+ if (is_one_instruction) { -+ lr_d(false, false, rd, rs.rm()); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Add64(scratch, rs.rm(), rs.offset()); -+ lr_d(false, false, rd, scratch); -+ } -+} -+ -+void TurboAssembler::Sc(Register rd, const MemOperand& rs) { -+ bool is_one_instruction = rs.offset() == 0; -+ if (is_one_instruction) { -+ sc_w(false, false, rd, rs.rm(), rd); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Add64(scratch, rs.rm(), rs.offset()); -+ sc_w(false, false, rd, scratch, rd); -+ } -+} -+ -+void TurboAssembler::Scd(Register rd, const MemOperand& rs) { -+ bool is_one_instruction = rs.offset() == 0; -+ if (is_one_instruction) { -+ sc_d(false, false, rd, rs.rm(), rd); -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Add64(scratch, rs.rm(), rs.offset()); -+ sc_d(false, false, rd, scratch, rd); -+ } -+} -+ -+void TurboAssembler::li(Register dst, Handle value, LiFlags mode) { -+ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating -+ // non-isolate-independent code. In many cases it might be cheaper than -+ // embedding the relocatable value. -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(dst, value); -+ return; -+ } -+ li(dst, Operand(value), mode); -+} -+ -+void TurboAssembler::li(Register dst, ExternalReference value, LiFlags mode) { -+ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating -+ // non-isolate-independent code. In many cases it might be cheaper than -+ // embedding the relocatable value. -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadExternalReference(dst, value); -+ return; -+ } -+ li(dst, Operand(value), mode); -+} -+ -+void TurboAssembler::li(Register dst, const StringConstantBase* string, -+ LiFlags mode) { -+ li(dst, Operand::EmbeddedStringConstant(string), mode); -+} -+ -+static inline int InstrCountForLiLower32Bit(int64_t value) { -+ int64_t Hi20 = ((value + 0x800) >> 12); -+ int64_t Lo12 = value << 52 >> 52; -+ if (Hi20 == 0 || Lo12 == 0) { -+ return 1; -+ } -+ return 2; -+} -+ -+int TurboAssembler::InstrCountForLi64Bit(int64_t value) { -+ if (is_int32(value)) { -+ return InstrCountForLiLower32Bit(value); -+ } else { -+ return li_count(value); -+ } -+ UNREACHABLE(); -+ return INT_MAX; -+} -+ -+void TurboAssembler::li_optimized(Register rd, Operand j, LiFlags mode) { -+ DCHECK(!j.is_reg()); -+ DCHECK(!MustUseReg(j.rmode())); -+ DCHECK(mode == OPTIMIZE_SIZE); -+ RV_li(rd, j.immediate()); -+} -+ -+void TurboAssembler::li(Register rd, Operand j, LiFlags mode) { -+ DCHECK(!j.is_reg()); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (!MustUseReg(j.rmode()) && mode == OPTIMIZE_SIZE) { -+ RV_li(rd, j.immediate()); -+ } else if (MustUseReg(j.rmode())) { -+ int64_t immediate; -+ if (j.IsHeapObjectRequest()) { -+ RequestHeapObject(j.heap_object_request()); -+ immediate = 0; -+ } else { -+ immediate = j.immediate(); -+ } -+ -+ RecordRelocInfo(j.rmode(), immediate); -+ // FIXME(RISC_V): Does this case need to be constant size? -+ li_constant(rd, immediate); -+ } else if (mode == ADDRESS_LOAD) { -+ // We always need the same number of instructions as we may need to patch -+ // this code to load another value which may need all 8 instructions. -+ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); -+ li_constant(rd, j.immediate()); -+ } else { // mode == CONSTANT_SIZE - always emit the same instruction -+ // sequence. -+ li_constant(rd, j.immediate()); -+ } -+} -+ -+static RegList t_regs = Register::ListOf(t0, t1, t2, t3, t4, t5, t6); -+static RegList a_regs = Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7); -+static RegList s_regs = -+ Register::ListOf(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11); -+ -+void TurboAssembler::MultiPush(RegList regs) { -+ int16_t num_to_push = base::bits::CountPopulation(regs); -+ int16_t stack_offset = num_to_push * kPointerSize; -+ -+#define TEST_AND_PUSH_REG(reg) \ -+ if ((regs & reg.bit()) != 0) { \ -+ stack_offset -= kPointerSize; \ -+ Sd(reg, MemOperand(sp, stack_offset)); \ -+ regs &= ~reg.bit(); \ -+ } -+ -+#define T_REGS(V) V(t6) V(t5) V(t4) V(t3) V(t2) V(t1) V(t0) -+#define A_REGS(V) V(a7) V(a6) V(a5) V(a4) V(a3) V(a2) V(a1) V(a0) -+#define S_REGS(V) \ -+ V(s11) V(s10) V(s9) V(s8) V(s7) V(s6) V(s5) V(s4) V(s3) V(s2) V(s1) -+ -+ Sub64(sp, sp, Operand(stack_offset)); -+ -+ // Certain usage of MultiPush requires that registers are pushed onto the -+ // stack in a particular: ra, fp, sp, gp, .... (basically in the decreasing -+ // order of register numbers according to MIPS register numbers) -+ TEST_AND_PUSH_REG(ra); -+ TEST_AND_PUSH_REG(fp); -+ TEST_AND_PUSH_REG(sp); -+ TEST_AND_PUSH_REG(gp); -+ TEST_AND_PUSH_REG(tp); -+ if ((regs & s_regs) != 0) { -+ S_REGS(TEST_AND_PUSH_REG) -+ } -+ if ((regs & a_regs) != 0) { -+ A_REGS(TEST_AND_PUSH_REG) -+ } -+ if ((regs & t_regs) != 0) { -+ T_REGS(TEST_AND_PUSH_REG) -+ } -+ -+ DCHECK(regs == 0); -+ -+#undef TEST_AND_PUSH_REG -+#undef T_REGS -+#undef A_REGS -+#undef S_REGS -+} -+ -+void TurboAssembler::MultiPop(RegList regs) { -+ int16_t stack_offset = 0; -+ -+#define TEST_AND_POP_REG(reg) \ -+ if ((regs & reg.bit()) != 0) { \ -+ Ld(reg, MemOperand(sp, stack_offset)); \ -+ stack_offset += kPointerSize; \ -+ regs &= ~reg.bit(); \ -+ } -+ -+#define T_REGS(V) V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) -+#define A_REGS(V) V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) -+#define S_REGS(V) \ -+ V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) V(s9) V(s10) V(s11) -+ -+ // MultiPop pops from the stack in reverse order as MultiPush -+ if ((regs & t_regs) != 0) { -+ T_REGS(TEST_AND_POP_REG) -+ } -+ if ((regs & a_regs) != 0) { -+ A_REGS(TEST_AND_POP_REG) -+ } -+ if ((regs & s_regs) != 0) { -+ S_REGS(TEST_AND_POP_REG) -+ } -+ TEST_AND_POP_REG(tp); -+ TEST_AND_POP_REG(gp); -+ TEST_AND_POP_REG(sp); -+ TEST_AND_POP_REG(fp); -+ TEST_AND_POP_REG(ra); -+ -+ DCHECK(regs == 0); -+ -+ addi(sp, sp, stack_offset); -+ -+#undef TEST_AND_POP_REG -+#undef T_REGS -+#undef S_REGS -+#undef A_REGS -+} -+ -+void TurboAssembler::MultiPushFPU(RegList regs) { -+ int16_t num_to_push = base::bits::CountPopulation(regs); -+ int16_t stack_offset = num_to_push * kDoubleSize; -+ -+ Sub64(sp, sp, Operand(stack_offset)); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ if ((regs & (1 << i)) != 0) { -+ stack_offset -= kDoubleSize; -+ StoreDouble(FPURegister::from_code(i), MemOperand(sp, stack_offset)); -+ } -+ } -+} -+ -+void TurboAssembler::MultiPopFPU(RegList regs) { -+ int16_t stack_offset = 0; -+ -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ if ((regs & (1 << i)) != 0) { -+ LoadDouble(FPURegister::from_code(i), MemOperand(sp, stack_offset)); -+ stack_offset += kDoubleSize; -+ } -+ } -+ addi(sp, sp, stack_offset); -+} -+ -+void TurboAssembler::ExtractBits(Register rt, Register rs, uint16_t pos, -+ uint16_t size, bool sign_extend) { -+ DCHECK(pos < 64 && 0 < size && size <= 64 && 0 < pos + size && -+ pos + size <= 64); -+ slli(rt, rs, 64 - (pos + size)); -+ if (sign_extend) { -+ srai(rt, rt, 64 - size); -+ } else { -+ srli(rt, rt, 64 - size); -+ } -+} -+ -+void TurboAssembler::InsertBits(Register dest, Register source, Register pos, -+ int size) { -+ DCHECK(size < 64); -+ UseScratchRegisterScope temps(this); -+ Register mask = temps.Acquire(); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register source_ = temps.hasAvailable() ? temps.Acquire() : t5; -+ // Create a mask of the length=size. -+ li(mask, 1); -+ slli(mask, mask, size); -+ addi(mask, mask, -1); -+ and_(source_, mask, source); -+ sll(source_, source_, pos); -+ // Make a mask containing 0's. 0's start at "pos" with length=size. -+ sll(mask, mask, pos); -+ not_(mask, mask); -+ // cut area for insertion of source. -+ and_(dest, mask, dest); -+ // insert source -+ or_(dest, dest, source_); -+} -+ -+void TurboAssembler::Neg_s(FPURegister fd, FPURegister fs) { fneg_s(fd, fs); } -+ -+void TurboAssembler::Neg_d(FPURegister fd, FPURegister fs) { fneg_d(fd, fs); } -+ -+void TurboAssembler::Cvt_d_uw(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_d_wu(fd, rs); -+} -+ -+void TurboAssembler::Cvt_d_w(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_d_w(fd, rs); -+} -+ -+void TurboAssembler::Cvt_d_ul(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_d_lu(fd, rs); -+} -+ -+void TurboAssembler::Cvt_s_uw(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_s_wu(fd, rs); -+} -+ -+void TurboAssembler::Cvt_s_w(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_s_w(fd, rs); -+} -+ -+void TurboAssembler::Cvt_s_ul(FPURegister fd, Register rs) { -+ // Convert rs to a FP value in fd. -+ fcvt_s_lu(fd, rs); -+} -+ -+template -+void TurboAssembler::RoundFloatingPointToInteger(Register rd, FPURegister fs, -+ Register result, -+ CvtFunc fcvt_generator) { -+ // Save csr_fflags to scratch & clear exception flags -+ if (result.is_valid()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ int exception_flags = kInvalidOperation; -+ csrrci(scratch, csr_fflags, exception_flags); -+ -+ // actual conversion instruction -+ fcvt_generator(this, rd, fs); -+ -+ // check kInvalidOperation flag (out-of-range, NaN) -+ // set result to 1 if normal, otherwise set result to 0 for abnormal -+ frflags(result); -+ andi(result, result, exception_flags); -+ seqz(result, result); // result <-- 1 (normal), result <-- 0 (abnormal) -+ -+ // restore csr_fflags -+ csrw(csr_fflags, scratch); -+ } else { -+ // actual conversion instruction -+ fcvt_generator(this, rd, fs); -+ } -+} -+ -+void TurboAssembler::Trunc_uw_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_wu_d(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_w_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_d(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_uw_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_wu_s(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_w_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_s(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_ul_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_lu_d(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_l_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_l_d(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_ul_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_lu_s(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Trunc_l_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_l_s(dst, src, RTZ); -+ }); -+} -+ -+void TurboAssembler::Round_w_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_s(dst, src, RNE); -+ }); -+} -+ -+void TurboAssembler::Round_w_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_d(dst, src, RNE); -+ }); -+} -+ -+void TurboAssembler::Ceil_w_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_s(dst, src, RUP); -+ }); -+} -+ -+void TurboAssembler::Ceil_w_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_d(dst, src, RUP); -+ }); -+} -+ -+void TurboAssembler::Floor_w_s(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_s(dst, src, RDN); -+ }); -+} -+ -+void TurboAssembler::Floor_w_d(Register rd, FPURegister fs, Register result) { -+ RoundFloatingPointToInteger( -+ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { -+ tasm->fcvt_w_d(dst, src, RDN); -+ }); -+} -+ -+// According to JS ECMA specification, for floating-point round operations, if -+// the input is NaN, +/-infinity, or +/-0, the same input is returned as the -+// rounded result; this differs from behavior of RISCV fcvt instructions (which -+// round out-of-range values to the nearest max or min value), therefore special -+// handling is needed by NaN, +/-Infinity, +/-0 -+template -+void TurboAssembler::RoundHelper(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch, RoundingMode frm) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ DCHECK((std::is_same::value) || (std::is_same::value)); -+ // Need at least two FPRs, so check against dst == src == fpu_scratch -+ DCHECK(!(dst == src && dst == fpu_scratch)); -+ -+ const int kFloat32ExponentBias = 127; -+ const int kFloat32MantissaBits = 23; -+ const int kFloat32ExponentBits = 8; -+ const int kFloat64ExponentBias = 1023; -+ const int kFloat64MantissaBits = 52; -+ const int kFloat64ExponentBits = 11; -+ const int kFloatMantissaBits = -+ sizeof(F) == 4 ? kFloat32MantissaBits : kFloat64MantissaBits; -+ const int kFloatExponentBits = -+ sizeof(F) == 4 ? kFloat32ExponentBits : kFloat64ExponentBits; -+ const int kFloatExponentBias = -+ sizeof(F) == 4 ? kFloat32ExponentBias : kFloat64ExponentBias; -+ -+ Label done; -+ -+ // extract exponent value of the source floating-point to t6 -+ if (std::is_same::value) { -+ fmv_x_d(scratch, src); -+ } else { -+ fmv_x_w(scratch, src); -+ } -+ ExtractBits(t6, scratch, kFloatMantissaBits, kFloatExponentBits); -+ -+ // if src is NaN/+-Infinity/+-Zero or if the exponent is larger than # of bits -+ // in mantissa, the result is the same as src, so move src to dest (to avoid -+ // generating another branch) -+ if (dst != src) { -+ if (std::is_same::value) { -+ fmv_d(dst, src); -+ } else { -+ fmv_s(dst, src); -+ } -+ } -+ -+ // If real exponent (i.e., t6 - kFloatExponentBias) is greater than -+ // kFloat32MantissaBits, it means the floating-point value has no fractional -+ // part, thus the input is already rounded, jump to done. Note that, NaN and -+ // Infinity in floating-point representation sets maximal exponent value, so -+ // they also satisfy (t6-kFloatExponentBias >= kFloatMantissaBits), and JS -+ // round semantics specify that rounding of NaN (Infinity) returns NaN -+ // (Infinity), so NaN and Infinity are considered rounded value too. -+ Branch(&done, greater_equal, t6, -+ Operand(kFloatExponentBias + kFloatMantissaBits)); -+ -+ // Actual rounding is needed along this path -+ -+ // old_src holds the original input, needed for the case of src == dst -+ FPURegister old_src = src; -+ if (src == dst) { -+ DCHECK(fpu_scratch != dst); -+ Move(fpu_scratch, src); -+ old_src = fpu_scratch; -+ } -+ -+ // Since only input whose real exponent value is less than kMantissaBits -+ // (i.e., 23 or 52-bits) falls into this path, the value range of the input -+ // falls into that of 23- or 53-bit integers. So we round the input to integer -+ // values, then convert them back to floating-point. -+ if (std::is_same::value) { -+ fcvt_l_d(scratch, src, frm); -+ fcvt_d_l(dst, scratch, frm); -+ } else { -+ fcvt_w_s(scratch, src, frm); -+ fcvt_s_w(dst, scratch, frm); -+ } -+ -+ // A special handling is needed if the input is a very small positive/negative -+ // number that rounds to zero. JS semantics requires that the rounded result -+ // retains the sign of the input, so a very small positive (negative) -+ // floating-point number should be rounded to positive (negative) 0. -+ // Therefore, we use sign-bit injection to produce +/-0 correctly. Instead of -+ // testing for zero w/ a branch, we just insert sign-bit for everyone on this -+ // path (this is where old_src is needed) -+ if (std::is_same::value) { -+ fsgnj_d(dst, dst, old_src); -+ } else { -+ fsgnj_s(dst, dst, old_src); -+ } -+ -+ bind(&done); -+} -+ -+void TurboAssembler::Floor_d_d(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RDN); -+} -+ -+void TurboAssembler::Ceil_d_d(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RUP); -+} -+ -+void TurboAssembler::Trunc_d_d(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RTZ); -+} -+ -+void TurboAssembler::Round_d_d(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RNE); -+} -+ -+void TurboAssembler::Floor_s_s(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RDN); -+} -+ -+void TurboAssembler::Ceil_s_s(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RUP); -+} -+ -+void TurboAssembler::Trunc_s_s(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RTZ); -+} -+ -+void TurboAssembler::Round_s_s(FPURegister dst, FPURegister src, -+ FPURegister fpu_scratch) { -+ RoundHelper(dst, src, fpu_scratch, RNE); -+} -+ -+void MacroAssembler::Madd_s(FPURegister fd, FPURegister fr, FPURegister fs, -+ FPURegister ft) { -+ fmadd_s(fd, fs, ft, fr); -+} -+ -+void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, -+ FPURegister ft) { -+ fmadd_d(fd, fs, ft, fr); -+} -+ -+void MacroAssembler::Msub_s(FPURegister fd, FPURegister fr, FPURegister fs, -+ FPURegister ft) { -+ fmsub_s(fd, fs, ft, fr); -+} -+ -+void MacroAssembler::Msub_d(FPURegister fd, FPURegister fr, FPURegister fs, -+ FPURegister ft) { -+ fmsub_d(fd, fs, ft, fr); -+} -+ -+void TurboAssembler::CompareF32(Register rd, FPUCondition cc, FPURegister cmp1, -+ FPURegister cmp2) { -+ switch (cc) { -+ case EQ: -+ feq_s(rd, cmp1, cmp2); -+ break; -+ case NE: -+ feq_s(rd, cmp1, cmp2); -+ NegateBool(rd, rd); -+ break; -+ case LT: -+ flt_s(rd, cmp1, cmp2); -+ break; -+ case GE: -+ fle_s(rd, cmp2, cmp1); -+ break; -+ case LE: -+ fle_s(rd, cmp1, cmp2); -+ break; -+ case GT: -+ flt_s(rd, cmp2, cmp1); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void TurboAssembler::CompareF64(Register rd, FPUCondition cc, FPURegister cmp1, -+ FPURegister cmp2) { -+ switch (cc) { -+ case EQ: -+ feq_d(rd, cmp1, cmp2); -+ break; -+ case NE: -+ feq_d(rd, cmp1, cmp2); -+ NegateBool(rd, rd); -+ break; -+ case LT: -+ flt_d(rd, cmp1, cmp2); -+ break; -+ case GE: -+ fle_d(rd, cmp2, cmp1); -+ break; -+ case LE: -+ fle_d(rd, cmp1, cmp2); -+ break; -+ case GT: -+ flt_d(rd, cmp2, cmp1); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void TurboAssembler::CompareIsNanF32(Register rd, FPURegister cmp1, -+ FPURegister cmp2) { -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ feq_s(rd, cmp1, cmp1); // rd <- !isNan(cmp1) -+ feq_s(scratch, cmp2, cmp2); // scratch <- !isNaN(cmp2) -+ And(rd, rd, scratch); // rd <- !isNan(cmp1) && !isNan(cmp2) -+ Xor(rd, rd, 1); // rd <- isNan(cmp1) || isNan(cmp2) -+} -+ -+void TurboAssembler::CompareIsNanF64(Register rd, FPURegister cmp1, -+ FPURegister cmp2) { -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ feq_d(rd, cmp1, cmp1); // rd <- !isNan(cmp1) -+ feq_d(scratch, cmp2, cmp2); // scratch <- !isNaN(cmp2) -+ And(rd, rd, scratch); // rd <- !isNan(cmp1) && !isNan(cmp2) -+ Xor(rd, rd, 1); // rd <- isNan(cmp1) || isNan(cmp2) -+} -+ -+void TurboAssembler::BranchTrueShortF(Register rs, Label* target) { -+ Branch(target, not_equal, rs, Operand(zero_reg)); -+} -+ -+void TurboAssembler::BranchFalseShortF(Register rs, Label* target) { -+ Branch(target, equal, rs, Operand(zero_reg)); -+} -+ -+void TurboAssembler::BranchTrueF(Register rs, Label* target) { -+ bool long_branch = -+ target->is_bound() ? !is_near(target) : is_trampoline_emitted(); -+ if (long_branch) { -+ Label skip; -+ BranchFalseShortF(rs, &skip); -+ BranchLong(target); -+ bind(&skip); -+ } else { -+ BranchTrueShortF(rs, target); -+ } -+} -+ -+void TurboAssembler::BranchFalseF(Register rs, Label* target) { -+ bool long_branch = -+ target->is_bound() ? !is_near(target) : is_trampoline_emitted(); -+ if (long_branch) { -+ Label skip; -+ BranchTrueShortF(rs, &skip); -+ BranchLong(target); -+ bind(&skip); -+ } else { -+ BranchFalseShortF(rs, target); -+ } -+} -+ -+void TurboAssembler::InsertHighWordF64(FPURegister dst, Register src_high) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ -+ DCHECK(src_high != t5 && src_high != scratch); -+ -+ fmv_x_d(scratch, dst); -+ slli(t5, src_high, 32); -+ slli(scratch, scratch, 32); -+ srli(scratch, scratch, 32); -+ or_(scratch, scratch, t5); -+ fmv_d_x(dst, scratch); -+} -+ -+void TurboAssembler::InsertLowWordF64(FPURegister dst, Register src_low) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ UseScratchRegisterScope block_trampoline_pool(this); -+ -+ DCHECK(src_low != scratch && src_low != t5); -+ fmv_x_d(scratch, dst); -+ slli(t5, src_low, 32); -+ srli(t5, t5, 32); -+ srli(scratch, scratch, 32); -+ slli(scratch, scratch, 32); -+ or_(scratch, scratch, t5); -+ fmv_d_x(dst, scratch); -+} -+ -+void TurboAssembler::LoadFPRImmediate(FPURegister dst, uint32_t src) { -+ // Handle special values first. -+ if (src == bit_cast(0.0f) && has_single_zero_reg_set_) { -+ if (dst != kDoubleRegZero) fmv_s(dst, kDoubleRegZero); -+ } else if (src == bit_cast(-0.0f) && has_single_zero_reg_set_) { -+ Neg_s(dst, kDoubleRegZero); -+ } else { -+ if (dst == kDoubleRegZero) { -+ DCHECK(src == bit_cast(0.0f)); -+ fmv_w_x(dst, zero_reg); -+ has_single_zero_reg_set_ = true; -+ has_double_zero_reg_set_ = false; -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(static_cast(src))); -+ fmv_w_x(dst, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::LoadFPRImmediate(FPURegister dst, uint64_t src) { -+ // Handle special values first. -+ if (src == bit_cast(0.0) && has_double_zero_reg_set_) { -+ if (dst != kDoubleRegZero) fmv_d(dst, kDoubleRegZero); -+ } else if (src == bit_cast(-0.0) && has_double_zero_reg_set_) { -+ Neg_d(dst, kDoubleRegZero); -+ } else { -+ if (dst == kDoubleRegZero) { -+ DCHECK(src == bit_cast(0.0)); -+ fmv_d_x(dst, zero_reg); -+ has_double_zero_reg_set_ = true; -+ has_single_zero_reg_set_ = false; -+ } else { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(src)); -+ fmv_d_x(dst, scratch); -+ } -+ } -+} -+ -+void TurboAssembler::CompareI(Register rd, Register rs, const Operand& rt, -+ Condition cond) { -+ switch (cond) { -+ case eq: -+ Seq(rd, rs, rt); -+ break; -+ case ne: -+ Sne(rd, rs, rt); -+ break; -+ -+ // Signed comparison. -+ case greater: -+ Sgt(rd, rs, rt); -+ break; -+ case greater_equal: -+ Sge(rd, rs, rt); // rs >= rt -+ break; -+ case less: -+ Slt(rd, rs, rt); // rs < rt -+ break; -+ case less_equal: -+ Sle(rd, rs, rt); // rs <= rt -+ break; -+ -+ // Unsigned comparison. -+ case Ugreater: -+ Sgtu(rd, rs, rt); // rs > rt -+ break; -+ case Ugreater_equal: -+ Sgeu(rd, rs, rt); // rs >= rt -+ break; -+ case Uless: -+ Sltu(rd, rs, rt); // rs < rt -+ break; -+ case Uless_equal: -+ Sleu(rd, rs, rt); // rs <= rt -+ break; -+ case cc_always: -+ UNREACHABLE(); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+// dest <- (condition != 0 ? zero : dest) -+void TurboAssembler::LoadZeroIfConditionNotZero(Register dest, -+ Register condition) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ seqz(scratch, condition); -+ // neg + and may be more efficient than mul(dest, dest, scratch) -+ neg(scratch, scratch); // 0 is still 0, 1 becomes all 1s -+ and_(dest, dest, scratch); -+} -+ -+// dest <- (condition == 0 ? 0 : dest) -+void TurboAssembler::LoadZeroIfConditionZero(Register dest, -+ Register condition) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ snez(scratch, condition); -+ // neg + and may be more efficient than mul(dest, dest, scratch); -+ neg(scratch, scratch); // 0 is still 0, 1 becomes all 1s -+ and_(dest, dest, scratch); -+} -+ -+void TurboAssembler::Clz32(Register rd, Register xx) { -+ // 32 bit unsigned in lower word: count number of leading zeros. -+ // int n = 32; -+ // unsigned y; -+ -+ // y = x >>16; if (y != 0) { n = n -16; x = y; } -+ // y = x >> 8; if (y != 0) { n = n - 8; x = y; } -+ // y = x >> 4; if (y != 0) { n = n - 4; x = y; } -+ // y = x >> 2; if (y != 0) { n = n - 2; x = y; } -+ // y = x >> 1; if (y != 0) {rd = n - 2; return;} -+ // rd = n - x; -+ -+ Label L0, L1, L2, L3, L4; -+ DCHECK(xx != t5 && xx != t6); -+ UseScratchRegisterScope temps(this); -+ UseScratchRegisterScope block_trampoline_pool(this); -+ Register x = rd; -+ Register y = t5; -+ Register n = t6; -+ Move(x, xx); -+ li(n, Operand(32)); -+ srliw(y, x, 16); -+ Branch(&L0, eq, y, Operand(zero_reg)); -+ Move(x, y); -+ addiw(n, n, -16); -+ bind(&L0); -+ srliw(y, x, 8); -+ Branch(&L1, eq, y, Operand(zero_reg)); -+ addiw(n, n, -8); -+ Move(x, y); -+ bind(&L1); -+ srliw(y, x, 4); -+ Branch(&L2, eq, y, Operand(zero_reg)); -+ addiw(n, n, -4); -+ Move(x, y); -+ bind(&L2); -+ srliw(y, x, 2); -+ Branch(&L3, eq, y, Operand(zero_reg)); -+ addiw(n, n, -2); -+ Move(x, y); -+ bind(&L3); -+ srliw(y, x, 1); -+ subw(rd, n, x); -+ Branch(&L4, eq, y, Operand(zero_reg)); -+ addiw(rd, n, -2); -+ bind(&L4); -+} -+ -+void TurboAssembler::Clz64(Register rd, Register xx) { -+ // 64 bit: count number of leading zeros. -+ // int n = 64; -+ // unsigned y; -+ -+ // y = x >>32; if (y != 0) { n = n - 32; x = y; } -+ // y = x >>16; if (y != 0) { n = n - 16; x = y; } -+ // y = x >> 8; if (y != 0) { n = n - 8; x = y; } -+ // y = x >> 4; if (y != 0) { n = n - 4; x = y; } -+ // y = x >> 2; if (y != 0) { n = n - 2; x = y; } -+ // y = x >> 1; if (y != 0) {rd = n - 2; return;} -+ // rd = n - x; -+ -+ DCHECK(xx != t5 && xx != t6); -+ Label L0, L1, L2, L3, L4, L5; -+ UseScratchRegisterScope temps(this); -+ UseScratchRegisterScope block_trampoline_pool(this); -+ Register x = rd; -+ Register y = t5; -+ Register n = t6; -+ Move(x, xx); -+ li(n, Operand(64)); -+ srli(y, x, 32); -+ Branch(&L0, eq, y, Operand(zero_reg)); -+ addiw(n, n, -32); -+ Move(x, y); -+ bind(&L0); -+ srli(y, x, 16); -+ Branch(&L1, eq, y, Operand(zero_reg)); -+ addiw(n, n, -16); -+ Move(x, y); -+ bind(&L1); -+ srli(y, x, 8); -+ Branch(&L2, eq, y, Operand(zero_reg)); -+ addiw(n, n, -8); -+ Move(x, y); -+ bind(&L2); -+ srli(y, x, 4); -+ Branch(&L3, eq, y, Operand(zero_reg)); -+ addiw(n, n, -4); -+ Move(x, y); -+ bind(&L3); -+ srli(y, x, 2); -+ Branch(&L4, eq, y, Operand(zero_reg)); -+ addiw(n, n, -2); -+ Move(x, y); -+ bind(&L4); -+ srli(y, x, 1); -+ subw(rd, n, x); -+ Branch(&L5, eq, y, Operand(zero_reg)); -+ addiw(rd, n, -2); -+ bind(&L5); -+} -+ -+void TurboAssembler::Ctz32(Register rd, Register rs) { -+ // Convert trailing zeroes to trailing ones, and bits to their left -+ // to zeroes. -+ UseScratchRegisterScope temps(this); -+ UseScratchRegisterScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ Add64(scratch, rs, -1); -+ Xor(rd, scratch, rs); -+ And(rd, rd, scratch); -+ // Count number of leading zeroes. -+ Clz32(rd, rd); -+ // Subtract number of leading zeroes from 32 to get number of trailing -+ // ones. Remember that the trailing ones were formerly trailing zeroes. -+ li(scratch, 32); -+ Sub32(rd, scratch, rd); -+} -+ -+void TurboAssembler::Ctz64(Register rd, Register rs) { -+ // Convert trailing zeroes to trailing ones, and bits to their left -+ // to zeroes. -+ UseScratchRegisterScope temps(this); -+ UseScratchRegisterScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ Add64(scratch, rs, -1); -+ Xor(rd, scratch, rs); -+ And(rd, rd, scratch); -+ // Count number of leading zeroes. -+ Clz64(rd, rd); -+ // Subtract number of leading zeroes from 64 to get number of trailing -+ // ones. Remember that the trailing ones were formerly trailing zeroes. -+ li(scratch, 64); -+ Sub64(rd, scratch, rd); -+} -+ -+void TurboAssembler::Popcnt32(Register rd, Register rs) { -+ // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel -+ // -+ // A generalization of the best bit counting method to integers of -+ // bit-widths up to 128 (parameterized by type T) is this: -+ // -+ // v = v - ((v >> 1) & (T)~(T)0/3); // temp -+ // v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); // temp -+ // v = (v + (v >> 4)) & (T)~(T)0/255*15; // temp -+ // c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * BITS_PER_BYTE; //count -+ // -+ // There are algorithms which are faster in the cases where very few -+ // bits are set but the algorithm here attempts to minimize the total -+ // number of instructions executed even when a large number of bits -+ // are set. -+ // The number of instruction is 20. -+ // uint32_t B0 = 0x55555555; // (T)~(T)0/3 -+ // uint32_t B1 = 0x33333333; // (T)~(T)0/15*3 -+ // uint32_t B2 = 0x0F0F0F0F; // (T)~(T)0/255*15 -+ // uint32_t value = 0x01010101; // (T)~(T)0/255 -+ -+ DCHECK(rd != t5 && rd != t6 && rs != t5 && rs != t6); -+ uint32_t shift = 24; -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.Acquire(); -+ Register scratch2 = t5; -+ Register value = t6; -+ li(value, 0x01010101); // value = 0x01010101; -+ li(scratch2, 0x55555555); // B0 = 0x55555555; -+ Srl32(scratch, rs, 1); -+ And(scratch, scratch, scratch2); -+ Sub32(scratch, rs, scratch); -+ li(scratch2, 0x33333333); // B1 = 0x33333333; -+ slli(rd, scratch2, 4); -+ or_(scratch2, scratch2, rd); -+ And(rd, scratch, scratch2); -+ Srl32(scratch, scratch, 2); -+ And(scratch, scratch, scratch2); -+ Add32(scratch, rd, scratch); -+ srliw(rd, scratch, 4); -+ Add32(rd, rd, scratch); -+ li(scratch2, 0xF); -+ Mul32(scratch2, value, scratch2); // B2 = 0x0F0F0F0F; -+ And(rd, rd, scratch2); -+ Mul32(rd, rd, value); -+ Srl32(rd, rd, shift); -+} -+ -+void TurboAssembler::Popcnt64(Register rd, Register rs) { -+ // uint64_t B0 = 0x5555555555555555l; // (T)~(T)0/3 -+ // uint64_t B1 = 0x3333333333333333l; // (T)~(T)0/15*3 -+ // uint64_t B2 = 0x0F0F0F0F0F0F0F0Fl; // (T)~(T)0/255*15 -+ // uint64_t value = 0x0101010101010101l; // (T)~(T)0/255 -+ // uint64_t shift = 24; // (sizeof(T) - 1) * BITS_PER_BYTE -+ -+ DCHECK(rd != t5 && rd != t6 && rs != t5 && rs != t6); -+ uint64_t shift = 24; -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.Acquire(); -+ Register scratch2 = t5; -+ Register value = t6; -+ li(value, 0x1111111111111111l); // value = 0x1111111111111111l; -+ li(scratch2, 5); -+ Mul64(scratch2, value, scratch2); // B0 = 0x5555555555555555l; -+ Srl64(scratch, rs, 1); -+ And(scratch, scratch, scratch2); -+ Sub64(scratch, rs, scratch); -+ li(scratch2, 3); -+ Mul64(scratch2, value, scratch2); // B1 = 0x3333333333333333l; -+ And(rd, scratch, scratch2); -+ Srl64(scratch, scratch, 2); -+ And(scratch, scratch, scratch2); -+ Add64(scratch, rd, scratch); -+ Srl64(rd, scratch, 4); -+ Add64(rd, rd, scratch); -+ li(scratch2, 0xF); -+ li(value, 0x0101010101010101l); // value = 0x0101010101010101l; -+ Mul64(scratch2, value, scratch2); // B2 = 0x0F0F0F0F0F0F0F0Fl; -+ And(rd, rd, scratch2); -+ Mul64(rd, rd, value); -+ srli(rd, rd, 32 + shift); -+} -+ -+void TurboAssembler::TryInlineTruncateDoubleToI(Register result, -+ DoubleRegister double_input, -+ Label* done) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ // if scratch == 1, exception happens during truncation -+ Trunc_w_d(result, double_input, scratch); -+ // If we had no exceptions (i.e., scratch==1) we are done. -+ Branch(done, eq, scratch, Operand(1)); -+} -+ -+void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone, -+ Register result, -+ DoubleRegister double_input, -+ StubCallMode stub_mode) { -+ Label done; -+ -+ TryInlineTruncateDoubleToI(result, double_input, &done); -+ -+ // If we fell through then inline version didn't succeed - call stub -+ // instead. -+ push(ra); -+ Sub64(sp, sp, Operand(kDoubleSize)); // Put input on stack. -+ fsd(double_input, sp, 0); -+ -+ if (stub_mode == StubCallMode::kCallWasmRuntimeStub) { -+ Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL); -+ } else { -+ Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET); -+ } -+ ld(result, sp, 0); -+ -+ Add64(sp, sp, Operand(kDoubleSize)); -+ pop(ra); -+ -+ bind(&done); -+} -+ -+// BRANCH_ARGS_CHECK checks that conditional jump arguments are correct. -+#define BRANCH_ARGS_CHECK(cond, rs, rt) \ -+ DCHECK((cond == cc_always && rs == zero_reg && rt.rm() == zero_reg) || \ -+ (cond != cc_always && (rs != zero_reg || rt.rm() != zero_reg))) -+ -+void TurboAssembler::Branch(int32_t offset) { -+ DCHECK(is_int21(offset)); -+ BranchShort(offset); -+} -+ -+void TurboAssembler::Branch(int32_t offset, Condition cond, Register rs, -+ const Operand& rt) { -+ bool is_near = BranchShortCheck(offset, nullptr, cond, rs, rt); -+ DCHECK(is_near); -+ USE(is_near); -+} -+ -+void TurboAssembler::Branch(Label* L) { -+ if (L->is_bound()) { -+ if (is_near(L)) { -+ BranchShort(L); -+ } else { -+ BranchLong(L); -+ } -+ } else { -+ if (is_trampoline_emitted()) { -+ BranchLong(L); -+ } else { -+ BranchShort(L); -+ } -+ } -+} -+ -+void TurboAssembler::Branch(Label* L, Condition cond, Register rs, -+ const Operand& rt) { -+ if (L->is_bound()) { -+ if (!BranchShortCheck(0, L, cond, rs, rt)) { -+ if (cond != cc_always) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rs, rt); -+ BranchLong(L); -+ bind(&skip); -+ } else { -+ BranchLong(L); -+ } -+ } -+ } else { -+ if (is_trampoline_emitted()) { -+ if (cond != cc_always) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rs, rt); -+ BranchLong(L); -+ bind(&skip); -+ } else { -+ BranchLong(L); -+ } -+ } else { -+ BranchShort(L, cond, rs, rt); -+ } -+ } -+} -+ -+void TurboAssembler::Branch(Label* L, Condition cond, Register rs, -+ RootIndex index) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(L, cond, rs, Operand(scratch)); -+} -+ -+void TurboAssembler::BranchShortHelper(int32_t offset, Label* L) { -+ DCHECK(L == nullptr || offset == 0); -+ offset = GetOffset(offset, L, OffsetSize::kOffset21); -+ j(offset); -+} -+ -+void TurboAssembler::BranchShort(int32_t offset) { -+ DCHECK(is_int21(offset)); -+ BranchShortHelper(offset, nullptr); -+} -+ -+void TurboAssembler::BranchShort(Label* L) { BranchShortHelper(0, L); } -+ -+int32_t TurboAssembler::GetOffset(int32_t offset, Label* L, OffsetSize bits) { -+ if (L) { -+ offset = branch_offset_helper(L, bits); -+ } else { -+ DCHECK(is_intn(offset, bits)); -+ } -+ return offset; -+} -+ -+Register TurboAssembler::GetRtAsRegisterHelper(const Operand& rt, -+ Register scratch) { -+ Register r2 = no_reg; -+ if (rt.is_reg()) { -+ r2 = rt.rm(); -+ } else { -+ r2 = scratch; -+ li(r2, rt); -+ } -+ -+ return r2; -+} -+ -+bool TurboAssembler::CalculateOffset(Label* L, int32_t* offset, -+ OffsetSize bits) { -+ if (!is_near(L, bits)) return false; -+ *offset = GetOffset(*offset, L, bits); -+ return true; -+} -+ -+bool TurboAssembler::CalculateOffset(Label* L, int32_t* offset, OffsetSize bits, -+ Register* scratch, const Operand& rt) { -+ if (!is_near(L, bits)) return false; -+ *scratch = GetRtAsRegisterHelper(rt, *scratch); -+ *offset = GetOffset(*offset, L, bits); -+ return true; -+} -+ -+bool TurboAssembler::BranchShortHelper(int32_t offset, Label* L, Condition cond, -+ Register rs, const Operand& rt) { -+ DCHECK(L == nullptr || offset == 0); -+ UseScratchRegisterScope temps(this); -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; -+ -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ switch (cond) { -+ case cc_always: -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ break; -+ case eq: -+ // rs == rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ beq(rs, scratch, offset); -+ } -+ break; -+ case ne: -+ // rs != rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ break; // No code needs to be emitted -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bne(rs, scratch, offset); -+ } -+ break; -+ -+ // Signed comparison. -+ case greater: -+ // rs > rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ break; // No code needs to be emitted. -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bgt(rs, scratch, offset); -+ } -+ break; -+ case greater_equal: -+ // rs >= rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bge(rs, scratch, offset); -+ } -+ break; -+ case less: -+ // rs < rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ break; // No code needs to be emitted. -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ blt(rs, scratch, offset); -+ } -+ break; -+ case less_equal: -+ // rs <= rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ ble(rs, scratch, offset); -+ } -+ break; -+ -+ // Unsigned comparison. -+ case Ugreater: -+ // rs > rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ break; // No code needs to be emitted. -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bgtu(rs, scratch, offset); -+ } -+ break; -+ case Ugreater_equal: -+ // rs >= rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bgeu(rs, scratch, offset); -+ } -+ break; -+ case Uless: -+ // rs < rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ break; // No code needs to be emitted. -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bltu(rs, scratch, offset); -+ } -+ break; -+ case Uless_equal: -+ // rs <= rt -+ if (rt.is_reg() && rs == rt.rm()) { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; -+ j(offset); -+ } else { -+ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) -+ return false; -+ DCHECK(rs != scratch); -+ bleu(rs, scratch, offset); -+ } -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ -+ CheckTrampolinePoolQuick(1); -+ return true; -+} -+ -+bool TurboAssembler::BranchShortCheck(int32_t offset, Label* L, Condition cond, -+ Register rs, const Operand& rt) { -+ BRANCH_ARGS_CHECK(cond, rs, rt); -+ -+ if (!L) { -+ DCHECK(is_int13(offset)); -+ return BranchShortHelper(offset, nullptr, cond, rs, rt); -+ } else { -+ DCHECK_EQ(offset, 0); -+ return BranchShortHelper(0, L, cond, rs, rt); -+ } -+ return false; -+} -+ -+void TurboAssembler::BranchShort(int32_t offset, Condition cond, Register rs, -+ const Operand& rt) { -+ BranchShortCheck(offset, nullptr, cond, rs, rt); -+} -+ -+void TurboAssembler::BranchShort(Label* L, Condition cond, Register rs, -+ const Operand& rt) { -+ BranchShortCheck(0, L, cond, rs, rt); -+} -+ -+void TurboAssembler::BranchAndLink(int32_t offset) { -+ BranchAndLinkShort(offset); -+} -+ -+void TurboAssembler::BranchAndLink(int32_t offset, Condition cond, Register rs, -+ const Operand& rt) { -+ bool is_near = BranchAndLinkShortCheck(offset, nullptr, cond, rs, rt); -+ DCHECK(is_near); -+ USE(is_near); -+} -+ -+void TurboAssembler::BranchAndLink(Label* L) { -+ if (L->is_bound()) { -+ if (is_near(L)) { -+ BranchAndLinkShort(L); -+ } else { -+ BranchAndLinkLong(L); -+ } -+ } else { -+ if (is_trampoline_emitted()) { -+ BranchAndLinkLong(L); -+ } else { -+ BranchAndLinkShort(L); -+ } -+ } -+} -+ -+void TurboAssembler::BranchAndLink(Label* L, Condition cond, Register rs, -+ const Operand& rt) { -+ if (L->is_bound()) { -+ if (!BranchAndLinkShortCheck(0, L, cond, rs, rt)) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rs, rt); -+ BranchAndLinkLong(L); -+ bind(&skip); -+ } -+ } else { -+ if (is_trampoline_emitted()) { -+ Label skip; -+ Condition neg_cond = NegateCondition(cond); -+ BranchShort(&skip, neg_cond, rs, rt); -+ BranchAndLinkLong(L); -+ bind(&skip); -+ } else { -+ BranchAndLinkShortCheck(0, L, cond, rs, rt); -+ } -+ } -+} -+ -+void TurboAssembler::BranchAndLinkShortHelper(int32_t offset, Label* L) { -+ DCHECK(L == nullptr || offset == 0); -+ offset = GetOffset(offset, L, OffsetSize::kOffset21); -+ jal(offset); -+} -+ -+void TurboAssembler::BranchAndLinkShort(int32_t offset) { -+ DCHECK(is_int21(offset)); -+ BranchAndLinkShortHelper(offset, nullptr); -+} -+ -+void TurboAssembler::BranchAndLinkShort(Label* L) { -+ BranchAndLinkShortHelper(0, L); -+} -+ -+// Pre r6 we need to use a bgezal or bltzal, but they can't be used directly -+// with the slt instructions. We could use sub or add instead but we would miss -+// overflow cases, so we keep slt and add an intermediate third instruction. -+bool TurboAssembler::BranchAndLinkShortHelper(int32_t offset, Label* L, -+ Condition cond, Register rs, -+ const Operand& rt) { -+ DCHECK(L == nullptr || offset == 0); -+ if (!is_near(L, OffsetSize::kOffset21)) return false; -+ -+ Register scratch = t5; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ -+ if (cond == cc_always) { -+ offset = GetOffset(offset, L, OffsetSize::kOffset21); -+ jal(offset); -+ } else { -+ Branch(kInstrSize * 2, NegateCondition(cond), rs, -+ Operand(GetRtAsRegisterHelper(rt, scratch))); -+ offset = GetOffset(offset, L, OffsetSize::kOffset21); -+ jal(offset); -+ } -+ -+ return true; -+} -+ -+bool TurboAssembler::BranchAndLinkShortCheck(int32_t offset, Label* L, -+ Condition cond, Register rs, -+ const Operand& rt) { -+ BRANCH_ARGS_CHECK(cond, rs, rt); -+ -+ if (!L) { -+ DCHECK(is_int21(offset)); -+ return BranchAndLinkShortHelper(offset, nullptr, cond, rs, rt); -+ } else { -+ DCHECK_EQ(offset, 0); -+ return BranchAndLinkShortHelper(0, L, cond, rs, rt); -+ } -+ return false; -+} -+ -+void TurboAssembler::LoadFromConstantsTable(Register destination, -+ int constant_index) { -+ DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kBuiltinsConstantsTable)); -+ LoadRoot(destination, RootIndex::kBuiltinsConstantsTable); -+ Ld(destination, -+ FieldMemOperand(destination, -+ FixedArray::kHeaderSize + constant_index * kPointerSize)); -+} -+ -+void TurboAssembler::LoadRootRelative(Register destination, int32_t offset) { -+ Ld(destination, MemOperand(kRootRegister, offset)); -+} -+ -+void TurboAssembler::LoadRootRegisterOffset(Register destination, -+ intptr_t offset) { -+ if (offset == 0) { -+ Move(destination, kRootRegister); -+ } else { -+ Add64(destination, kRootRegister, Operand(offset)); -+ } -+} -+ -+void TurboAssembler::Jump(Register target, Condition cond, Register rs, -+ const Operand& rt) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (cond == cc_always) { -+ jr(target); -+ } else { -+ BRANCH_ARGS_CHECK(cond, rs, rt); -+ Branch(kInstrSize * 2, NegateCondition(cond), rs, rt); -+ jr(target); -+ } -+} -+ -+void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode, -+ Condition cond, Register rs, const Operand& rt) { -+ Label skip; -+ if (cond != cc_always) { -+ Branch(&skip, NegateCondition(cond), rs, rt); -+ } -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t6, Operand(target, rmode)); -+ Jump(t6, al, zero_reg, Operand(zero_reg)); -+ bind(&skip); -+ } -+} -+ -+void TurboAssembler::Jump(Address target, RelocInfo::Mode rmode, Condition cond, -+ Register rs, const Operand& rt) { -+ DCHECK(!RelocInfo::IsCodeTarget(rmode)); -+ Jump(static_cast(target), rmode, cond, rs, rt); -+} -+ -+void TurboAssembler::Jump(Handle code, RelocInfo::Mode rmode, -+ Condition cond, Register rs, const Operand& rt) { -+ DCHECK(RelocInfo::IsCodeTarget(rmode)); -+ -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(t6, code); -+ Add64(t6, t6, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Jump(t6, cond, rs, rt); -+ return; -+ } else if (options().inline_offheap_trampolines) { -+ int builtin_index = Builtins::kNoBuiltinId; -+ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && -+ Builtins::IsIsolateIndependent(builtin_index)) { -+ // Inline the trampoline. -+ RecordCommentForOffHeapTrampoline(builtin_index); -+ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ Address entry = d.InstructionStartOfBuiltin(builtin_index); -+ li(t6, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Jump(t6, cond, rs, rt); -+ return; -+ } -+ } -+ -+ Jump(static_cast(code.address()), rmode, cond, rs, rt); -+} -+ -+void TurboAssembler::Jump(const ExternalReference& reference) { -+ li(t6, reference); -+ Jump(t6); -+} -+ -+// FIXME (RISCV): the comment does not make sense, where is t6 used? -+// Note: To call gcc-compiled C code on riscv64, you must call through t6. -+void TurboAssembler::Call(Register target, Condition cond, Register rs, -+ const Operand& rt) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (cond == cc_always) { -+ jalr(ra, target, 0); -+ } else { -+ BRANCH_ARGS_CHECK(cond, rs, rt); -+ Branch(kInstrSize * 2, NegateCondition(cond), rs, rt); -+ jalr(ra, target, 0); -+ } -+} -+ -+void MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit, -+ unsigned higher_limit, -+ Label* on_in_range) { -+ if (lower_limit != 0) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Sub64(scratch, value, Operand(lower_limit)); -+ Branch(on_in_range, Uless_equal, scratch, -+ Operand(higher_limit - lower_limit)); -+ } else { -+ Branch(on_in_range, Uless_equal, value, -+ Operand(higher_limit - lower_limit)); -+ } -+} -+ -+void TurboAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond, -+ Register rs, const Operand& rt) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t6, Operand(static_cast(target), rmode), ADDRESS_LOAD); -+ Call(t6, cond, rs, rt); -+} -+ -+void TurboAssembler::Call(Handle code, RelocInfo::Mode rmode, -+ Condition cond, Register rs, const Operand& rt) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ -+ if (root_array_available_ && options().isolate_independent_code) { -+ IndirectLoadConstant(t6, code); -+ Add64(t6, t6, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Call(t6, cond, rs, rt); -+ return; -+ } else if (options().inline_offheap_trampolines) { -+ int builtin_index = Builtins::kNoBuiltinId; -+ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && -+ Builtins::IsIsolateIndependent(builtin_index)) { -+ // Inline the trampoline. -+ RecordCommentForOffHeapTrampoline(builtin_index); -+ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ Address entry = d.InstructionStartOfBuiltin(builtin_index); -+ li(t6, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Call(t6, cond, rs, rt); -+ return; -+ } -+ } -+ -+ DCHECK(RelocInfo::IsCodeTarget(rmode)); -+ DCHECK(code->IsExecutable()); -+ Call(code.address(), rmode, cond, rs, rt); -+} -+ -+void TurboAssembler::LoadEntryFromBuiltinIndex(Register builtin_index) { -+ STATIC_ASSERT(kSystemPointerSize == 8); -+ STATIC_ASSERT(kSmiTagSize == 1); -+ STATIC_ASSERT(kSmiTag == 0); -+ -+ // The builtin_index register contains the builtin index as a Smi. -+ SmiUntag(builtin_index, builtin_index); -+ CalcScaledAddress(builtin_index, kRootRegister, builtin_index, -+ kSystemPointerSizeLog2); -+ Ld(builtin_index, -+ MemOperand(builtin_index, IsolateData::builtin_entry_table_offset())); -+} -+ -+void TurboAssembler::CallBuiltinByIndex(Register builtin_index) { -+ LoadEntryFromBuiltinIndex(builtin_index); -+ Call(builtin_index); -+} -+ -+void TurboAssembler::PatchAndJump(Address target) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ auipc(scratch, 0); // Load PC into scratch -+ Ld(t6, MemOperand(scratch, kInstrSize * 4)); -+ jr(t6); -+ nop(); // For alignment -+ DCHECK_EQ(reinterpret_cast(pc_) % 8, 0); -+ *reinterpret_cast(pc_) = target; // pc_ should be align. -+ pc_ += sizeof(uint64_t); -+} -+ -+void TurboAssembler::StoreReturnAddressAndCall(Register target) { -+ // This generates the final instruction sequence for calls to C functions -+ // once an exit frame has been constructed. -+ // -+ // Note that this assumes the caller code (i.e. the Code object currently -+ // being generated) is immovable or that the callee function cannot trigger -+ // GC, since the callee function will return to it. -+ -+ // Compute the return address in lr to return to after the jump below. The -+ // pc is already at '+ 8' from the current instruction; but return is after -+ // three instructions, so add another 4 to pc to get the return address. -+ -+ Assembler::BlockTrampolinePoolScope block_trampoline_pool(this); -+ static constexpr int kNumInstructionsToJump = 5; -+ Label find_ra; -+ // Adjust the value in ra to point to the correct return location, one -+ // instruction past the real call into C code (the jalr(t6)), and push it. -+ // This is the return address of the exit frame. -+ auipc(ra, 0); // Set ra the current PC -+ bind(&find_ra); -+ addi(ra, ra, -+ (kNumInstructionsToJump + 1) * -+ kInstrSize); // Set ra to insn after the call -+ -+ // This spot was reserved in EnterExitFrame. -+ Sd(ra, MemOperand(sp)); -+ addi(sp, sp, -kCArgsSlotsSize); -+ // Stack is still aligned. -+ -+ // Call the C routine. -+ mv(t6, target); // Function pointer to t6 to conform to ABI for PIC. -+ jalr(t6); -+ // Make sure the stored 'ra' points to this position. -+ DCHECK_EQ(kNumInstructionsToJump, InstructionsGeneratedSince(&find_ra)); -+} -+ -+void TurboAssembler::Ret(Condition cond, Register rs, const Operand& rt) { -+ Jump(ra, cond, rs, rt); -+} -+ -+void TurboAssembler::BranchLong(Label* L) { -+ // Generate position independent long branch. -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ int64_t imm64; -+ imm64 = branch_long_offset(L); -+ DCHECK(is_int32(imm64)); -+ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); -+ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; -+ auipc(t5, Hi20); // Read PC + Hi20 into t5. -+ jr(t5, Lo12); // jump PC + Hi20 + Lo12 -+} -+ -+void TurboAssembler::BranchAndLinkLong(Label* L) { -+ // Generate position independent long branch and link. -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ int64_t imm64; -+ imm64 = branch_long_offset(L); -+ DCHECK(is_int32(imm64)); -+ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); -+ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; -+ auipc(t5, Hi20); // Read PC + Hi20 into t5. -+ jalr(t5, Lo12); // jump PC + Hi20 + Lo12 and read PC + 4 to ra -+} -+ -+void TurboAssembler::DropAndRet(int drop) { -+ Add64(sp, sp, drop * kPointerSize); -+ Ret(); -+} -+ -+void TurboAssembler::DropAndRet(int drop, Condition cond, Register r1, -+ const Operand& r2) { -+ // Both Drop and Ret need to be conditional. -+ Label skip; -+ if (cond != cc_always) { -+ Branch(&skip, NegateCondition(cond), r1, r2); -+ } -+ -+ Drop(drop); -+ Ret(); -+ -+ if (cond != cc_always) { -+ bind(&skip); -+ } -+} -+ -+void TurboAssembler::Drop(int count, Condition cond, Register reg, -+ const Operand& op) { -+ if (count <= 0) { -+ return; -+ } -+ -+ Label skip; -+ -+ if (cond != al) { -+ Branch(&skip, NegateCondition(cond), reg, op); -+ } -+ -+ Add64(sp, sp, Operand(count * kPointerSize)); -+ -+ if (cond != al) { -+ bind(&skip); -+ } -+} -+ -+void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) { -+ if (scratch == no_reg) { -+ Xor(reg1, reg1, Operand(reg2)); -+ Xor(reg2, reg2, Operand(reg1)); -+ Xor(reg1, reg1, Operand(reg2)); -+ } else { -+ mv(scratch, reg1); -+ mv(reg1, reg2); -+ mv(reg2, scratch); -+ } -+} -+ -+void TurboAssembler::Call(Label* target) { BranchAndLink(target); } -+ -+void TurboAssembler::LoadAddress(Register dst, Label* target) { -+ uint64_t address = jump_address(target); -+ li(dst, address, ADDRESS_LOAD); -+} -+ -+void TurboAssembler::Push(Smi smi) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(smi)); -+ push(scratch); -+} -+ -+void TurboAssembler::Push(Handle handle) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(handle)); -+ push(scratch); -+} -+ -+void MacroAssembler::MaybeDropFrames() { -+ // Check whether we need to drop frames to restart a function on the stack. -+ li(a1, ExternalReference::debug_restart_fp_address(isolate())); -+ Ld(a1, MemOperand(a1)); -+ Jump(BUILTIN_CODE(isolate(), FrameDropperTrampoline), RelocInfo::CODE_TARGET, -+ ne, a1, Operand(zero_reg)); -+} -+ -+// --------------------------------------------------------------------------- -+// Exception handling. -+ -+void MacroAssembler::PushStackHandler() { -+ // Adjust this code if not the case. -+ STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize); -+ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); -+ -+ Push(Smi::zero()); // Padding. -+ -+ // Link the current handler as the next handler. -+ li(t2, -+ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); -+ Ld(t1, MemOperand(t2)); -+ push(t1); -+ -+ // Set this new handler as the current one. -+ Sd(sp, MemOperand(t2)); -+} -+ -+void MacroAssembler::PopStackHandler() { -+ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); -+ pop(a1); -+ Add64(sp, sp, -+ Operand( -+ static_cast(StackHandlerConstants::kSize - kPointerSize))); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, -+ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); -+ Sd(a1, MemOperand(scratch)); -+} -+ -+void TurboAssembler::FPUCanonicalizeNaN(const DoubleRegister dst, -+ const DoubleRegister src) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ Label NotNaN; -+ -+ fmv_d(dst, src); -+ feq_d(scratch, src, src); -+ bne(scratch, zero_reg, &NotNaN); -+ RV_li(scratch, 0x7ff8000000000000ULL); // This is the canonical NaN -+ fmv_d_x(dst, scratch); -+ bind(&NotNaN); -+} -+ -+void TurboAssembler::MovFromFloatResult(const DoubleRegister dst) { -+ Move(dst, fa0); // Reg fa0 is FP return value. -+} -+ -+void TurboAssembler::MovFromFloatParameter(const DoubleRegister dst) { -+ Move(dst, fa0); // Reg fa0 is FP first argument value. -+} -+ -+void TurboAssembler::MovToFloatParameter(DoubleRegister src) { Move(fa0, src); } -+ -+void TurboAssembler::MovToFloatResult(DoubleRegister src) { Move(fa0, src); } -+ -+void TurboAssembler::MovToFloatParameters(DoubleRegister src1, -+ DoubleRegister src2) { -+ const DoubleRegister fparg2 = fa1; -+ if (src2 == fa0) { -+ DCHECK(src1 != fparg2); -+ Move(fparg2, src2); -+ Move(fa0, src1); -+ } else { -+ Move(fa0, src1); -+ Move(fparg2, src2); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// JavaScript invokes. -+ -+void TurboAssembler::PrepareForTailCall(Register callee_args_count, -+ Register caller_args_count, -+ Register scratch0, Register scratch1) { -+ // Calculate the end of destination area where we will put the arguments -+ // after we drop current frame. We add kPointerSize to count the receiver -+ // argument which is not included into formal parameters count. -+ Register dst_reg = scratch0; -+ CalcScaledAddress(dst_reg, fp, caller_args_count, kPointerSizeLog2); -+ Add64(dst_reg, dst_reg, -+ Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); -+ -+ Register src_reg = caller_args_count; -+ // Calculate the end of source area. +kPointerSize is for the receiver. -+ CalcScaledAddress(src_reg, sp, callee_args_count, kPointerSizeLog2); -+ Add64(src_reg, src_reg, Operand(kPointerSize)); -+ -+ if (FLAG_debug_code) { -+ Check(Uless, AbortReason::kStackAccessBelowStackPointer, src_reg, -+ Operand(dst_reg)); -+ } -+ -+ // Restore caller's frame pointer and return address now as they will be -+ // overwritten by the copying loop. -+ Ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); -+ Ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ -+ // Now copy callee arguments to the caller frame going backwards to avoid -+ // callee arguments corruption (source and destination areas could overlap). -+ -+ // Both src_reg and dst_reg are pointing to the word after the one to copy, -+ // so they must be pre-decremented in the loop. -+ Register tmp_reg = scratch1; -+ Label loop, entry; -+ Branch(&entry); -+ bind(&loop); -+ Sub64(src_reg, src_reg, Operand(kPointerSize)); -+ Sub64(dst_reg, dst_reg, Operand(kPointerSize)); -+ Ld(tmp_reg, MemOperand(src_reg)); -+ Sd(tmp_reg, MemOperand(dst_reg)); -+ bind(&entry); -+ Branch(&loop, ne, sp, Operand(src_reg)); -+ -+ // Leave current frame. -+ mv(sp, dst_reg); -+} -+ -+void MacroAssembler::InvokePrologue(Register expected_parameter_count, -+ Register actual_parameter_count, -+ Label* done, InvokeFlag flag) { -+ Label regular_invoke; -+ -+ // Check whether the expected and actual arguments count match. The -+ // registers are set up according to contract with -+ // ArgumentsAdaptorTrampoline: -+ // a0: actual arguments count -+ // a1: function (passed through to callee) -+ // a2: expected arguments count -+ -+ // The code below is made a lot easier because the calling code already sets -+ // up actual and expected registers according to the contract. -+ -+ DCHECK_EQ(actual_parameter_count, a0); -+ DCHECK_EQ(expected_parameter_count, a2); -+ -+ Branch(®ular_invoke, eq, expected_parameter_count, -+ Operand(actual_parameter_count)); -+ -+ Handle adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline); -+ if (flag == CALL_FUNCTION) { -+ Call(adaptor); -+ Branch(done); -+ } else { -+ Jump(adaptor, RelocInfo::CODE_TARGET); -+ } -+ -+ bind(®ular_invoke); -+} -+ -+void MacroAssembler::CheckDebugHook(Register fun, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count) { -+ Label skip_hook; -+ -+ li(t0, ExternalReference::debug_hook_on_function_call_address(isolate())); -+ Lb(t0, MemOperand(t0)); -+ Branch(&skip_hook, eq, t0, Operand(zero_reg)); -+ -+ { -+ // Load receiver to pass it later to DebugOnFunctionCall hook. -+ CalcScaledAddress(t0, sp, actual_parameter_count, kPointerSizeLog2); -+ Ld(t0, MemOperand(t0)); -+ FrameScope frame(this, -+ has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); -+ SmiTag(expected_parameter_count); -+ Push(expected_parameter_count); -+ -+ SmiTag(actual_parameter_count); -+ Push(actual_parameter_count); -+ -+ if (new_target.is_valid()) { -+ Push(new_target); -+ } -+ Push(fun); -+ Push(fun); -+ Push(t0); -+ CallRuntime(Runtime::kDebugOnFunctionCall); -+ Pop(fun); -+ if (new_target.is_valid()) { -+ Pop(new_target); -+ } -+ -+ Pop(actual_parameter_count); -+ SmiUntag(actual_parameter_count); -+ -+ Pop(expected_parameter_count); -+ SmiUntag(expected_parameter_count); -+ } -+ bind(&skip_hook); -+} -+ -+void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ DCHECK_EQ(function, a1); -+ DCHECK_IMPLIES(new_target.is_valid(), new_target == a3); -+ -+ // On function call, call into the debugger if necessary. -+ CheckDebugHook(function, new_target, expected_parameter_count, -+ actual_parameter_count); -+ -+ // Clear the new.target register if not given. -+ if (!new_target.is_valid()) { -+ LoadRoot(a3, RootIndex::kUndefinedValue); -+ } -+ -+ Label done; -+ InvokePrologue(expected_parameter_count, actual_parameter_count, &done, flag); -+ // We call indirectly through the code field in the function to -+ // allow recompilation to take effect without changing any of the -+ // call sites. -+ Register code = kJavaScriptCallCodeStartRegister; -+ Ld(code, FieldMemOperand(function, JSFunction::kCodeOffset)); -+ if (flag == CALL_FUNCTION) { -+ Add64(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Call(code); -+ } else { -+ DCHECK(flag == JUMP_FUNCTION); -+ Add64(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ Jump(code); -+ } -+ -+ // Continue here if InvokePrologue does handle the invocation due to -+ // mismatched parameter counts. -+ bind(&done); -+} -+ -+void MacroAssembler::InvokeFunctionWithNewTarget( -+ Register function, Register new_target, Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ -+ // Contract with called JS functions requires that function is passed in a1. -+ DCHECK_EQ(function, a1); -+ Register expected_parameter_count = a2; -+ Register temp_reg = t0; -+ Ld(temp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ // The argument count is stored as uint16_t -+ Lhu(expected_parameter_count, -+ FieldMemOperand(temp_reg, -+ SharedFunctionInfo::kFormalParameterCountOffset)); -+ -+ InvokeFunctionCode(a1, new_target, expected_parameter_count, -+ actual_parameter_count, flag); -+} -+ -+void MacroAssembler::InvokeFunction(Register function, -+ Register expected_parameter_count, -+ Register actual_parameter_count, -+ InvokeFlag flag) { -+ // You can't call a function without a valid frame. -+ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); -+ -+ // Contract with called JS functions requires that function is passed in a1. -+ DCHECK_EQ(function, a1); -+ -+ // Get the function and setup the context. -+ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); -+ -+ InvokeFunctionCode(a1, no_reg, expected_parameter_count, -+ actual_parameter_count, flag); -+} -+ -+// --------------------------------------------------------------------------- -+// Support functions. -+ -+void MacroAssembler::GetObjectType(Register object, Register map, -+ Register type_reg) { -+ LoadMap(map, object); -+ Lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); -+} -+ -+// ----------------------------------------------------------------------------- -+// Runtime calls. -+ -+void TurboAssembler::AddOverflow64(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t5; -+ if (!right.is_reg()) { -+ li(t3, Operand(right)); -+ right_reg = t3; -+ } else { -+ right_reg = right.rm(); -+ } -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ if (dst == left || dst == right_reg) { -+ add(scratch, left, right_reg); -+ xor_(overflow, scratch, left); -+ xor_(t3, scratch, right_reg); -+ and_(overflow, overflow, t3); -+ mv(dst, scratch); -+ } else { -+ add(dst, left, right_reg); -+ xor_(overflow, dst, left); -+ xor_(t3, dst, right_reg); -+ and_(overflow, overflow, t3); -+ } -+} -+ -+void TurboAssembler::SubOverflow64(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t5; -+ if (!right.is_reg()) { -+ li(t3, Operand(right)); -+ right_reg = t3; -+ } else { -+ right_reg = right.rm(); -+ } -+ -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ -+ if (dst == left || dst == right_reg) { -+ sub(scratch, left, right_reg); -+ xor_(overflow, left, scratch); -+ xor_(t3, left, right_reg); -+ and_(overflow, overflow, t3); -+ mv(dst, scratch); -+ } else { -+ sub(dst, left, right_reg); -+ xor_(overflow, left, dst); -+ xor_(t3, left, right_reg); -+ and_(overflow, overflow, t3); -+ } -+} -+ -+void TurboAssembler::MulOverflow32(Register dst, Register left, -+ const Operand& right, Register overflow) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ Register right_reg = no_reg; -+ Register scratch = t5; -+ if (!right.is_reg()) { -+ li(t3, Operand(right)); -+ right_reg = t3; -+ } else { -+ right_reg = right.rm(); -+ } -+ -+ DCHECK(left != scratch && right_reg != scratch && dst != scratch && -+ overflow != scratch); -+ DCHECK(overflow != left && overflow != right_reg); -+ sext_w(overflow, left); -+ sext_w(scratch, right_reg); -+ -+ mul(overflow, overflow, scratch); -+ sext_w(dst, overflow); -+ xor_(overflow, overflow, dst); -+} -+ -+void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, -+ SaveFPRegsMode save_doubles) { -+ // All parameters are on the stack. a0 has the return value after call. -+ -+ // If the expected number of arguments of the runtime function is -+ // constant, we check that the actual number of arguments match the -+ // expectation. -+ CHECK(f->nargs < 0 || f->nargs == num_arguments); -+ -+ // TODO(1236192): Most runtime routines don't need the number of -+ // arguments passed in because it is constant. At some point we -+ // should remove this need and make the runtime routine entry code -+ // smarter. -+ PrepareCEntryArgs(num_arguments); -+ PrepareCEntryFunction(ExternalReference::Create(f)); -+ Handle code = -+ CodeFactory::CEntry(isolate(), f->result_size, save_doubles); -+ Call(code, RelocInfo::CODE_TARGET); -+} -+ -+void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { -+ const Runtime::Function* function = Runtime::FunctionForId(fid); -+ DCHECK_EQ(1, function->result_size); -+ if (function->nargs >= 0) { -+ PrepareCEntryArgs(function->nargs); -+ } -+ JumpToExternalReference(ExternalReference::Create(fid)); -+} -+ -+void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, -+ bool builtin_exit_frame) { -+ PrepareCEntryFunction(builtin); -+ Handle code = CodeFactory::CEntry(isolate(), 1, kDontSaveFPRegs, -+ kArgvOnStack, builtin_exit_frame); -+ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg)); -+} -+ -+void MacroAssembler::JumpToInstructionStream(Address entry) { -+ li(kOffHeapTrampolineRegister, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ Jump(kOffHeapTrampolineRegister); -+} -+ -+void MacroAssembler::LoadWeakValue(Register out, Register in, -+ Label* target_if_cleared) { -+ Branch(target_if_cleared, eq, in, Operand(kClearedWeakHeapObjectLower32)); -+ -+ And(out, in, Operand(~kWeakHeapObjectMask)); -+} -+ -+void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, -+ Register scratch1, Register scratch2) { -+ DCHECK_GT(value, 0); -+ if (FLAG_native_code_counters && counter->Enabled()) { -+ // This operation has to be exactly 32-bit wide in case the external -+ // reference table redirects the counter to a uint32_t -+ // dummy_stats_counter_ field. -+ li(scratch2, ExternalReference::Create(counter)); -+ Lw(scratch1, MemOperand(scratch2)); -+ Add32(scratch1, scratch1, Operand(value)); -+ Sw(scratch1, MemOperand(scratch2)); -+ } -+} -+ -+void MacroAssembler::DecrementCounter(StatsCounter* counter, int value, -+ Register scratch1, Register scratch2) { -+ DCHECK_GT(value, 0); -+ if (FLAG_native_code_counters && counter->Enabled()) { -+ // This operation has to be exactly 32-bit wide in case the external -+ // reference table redirects the counter to a uint32_t -+ // dummy_stats_counter_ field. -+ li(scratch2, ExternalReference::Create(counter)); -+ Lw(scratch1, MemOperand(scratch2)); -+ Sub32(scratch1, scratch1, Operand(value)); -+ Sw(scratch1, MemOperand(scratch2)); -+ } -+} -+ -+// ----------------------------------------------------------------------------- -+// Debugging. -+ -+void TurboAssembler::Trap() { stop(); } -+void TurboAssembler::DebugBreak() { stop(); } -+ -+void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs, -+ Operand rt) { -+ if (emit_debug_code()) Check(cc, reason, rs, rt); -+} -+ -+void TurboAssembler::Check(Condition cc, AbortReason reason, Register rs, -+ Operand rt) { -+ Label L; -+ Branch(&L, cc, rs, rt); -+ Abort(reason); -+ // Will not return here. -+ bind(&L); -+} -+ -+void TurboAssembler::Abort(AbortReason reason) { -+ Label abort_start; -+ bind(&abort_start); -+#ifdef DEBUG -+ const char* msg = GetAbortReason(reason); -+ RecordComment("Abort message: "); -+ RecordComment(msg); -+#endif -+ -+ // Avoid emitting call to builtin if requested. -+ if (trap_on_abort()) { -+ ebreak(); -+ return; -+ } -+ -+ if (should_abort_hard()) { -+ // We don't care if we constructed a frame. Just pretend we did. -+ FrameScope assume_frame(this, StackFrame::NONE); -+ PrepareCallCFunction(0, a0); -+ li(a0, Operand(static_cast(reason))); -+ CallCFunction(ExternalReference::abort_with_reason(), 1); -+ return; -+ } -+ -+ Move(a0, Smi::FromInt(static_cast(reason))); -+ -+ // Disable stub call restrictions to always allow calls to abort. -+ if (!has_frame()) { -+ // We don't actually want to generate a pile of code for this, so just -+ // claim there is a stack frame, without generating one. -+ FrameScope scope(this, StackFrame::NONE); -+ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); -+ } else { -+ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); -+ } -+ // Will not return here. -+ if (is_trampoline_pool_blocked()) { -+ // If the calling code cares about the exact number of -+ // instructions generated, we insert padding here to keep the size -+ // of the Abort macro constant. -+ // Currently in debug mode with debug_code enabled the number of -+ // generated instructions is 10, so we use this as a maximum value. -+ static const int kExpectedAbortInstructions = 10; -+ int abort_instructions = InstructionsGeneratedSince(&abort_start); -+ DCHECK_LE(abort_instructions, kExpectedAbortInstructions); -+ while (abort_instructions++ < kExpectedAbortInstructions) { -+ nop(); -+ } -+ } -+} -+ -+void MacroAssembler::LoadMap(Register destination, Register object) { -+ Ld(destination, FieldMemOperand(object, HeapObject::kMapOffset)); -+} -+ -+void MacroAssembler::LoadNativeContextSlot(int index, Register dst) { -+ LoadMap(dst, cp); -+ Ld(dst, -+ FieldMemOperand(dst, Map::kConstructorOrBackPointerOrNativeContextOffset)); -+ Ld(dst, MemOperand(dst, Context::SlotOffset(index))); -+} -+ -+void TurboAssembler::StubPrologue(StackFrame::Type type) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(StackFrame::TypeToMarker(type))); -+ PushCommonFrame(scratch); -+} -+ -+void TurboAssembler::Prologue() { PushStandardFrame(a1); } -+ -+void TurboAssembler::EnterFrame(StackFrame::Type type) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ int stack_offset = -3 * kPointerSize; -+ const int fp_offset = 1 * kPointerSize; -+ addi(sp, sp, stack_offset); -+ stack_offset = -stack_offset - kPointerSize; -+ Sd(ra, MemOperand(sp, stack_offset)); -+ stack_offset -= kPointerSize; -+ Sd(fp, MemOperand(sp, stack_offset)); -+ stack_offset -= kPointerSize; -+ li(t6, Operand(StackFrame::TypeToMarker(type))); -+ Sd(t6, MemOperand(sp, stack_offset)); -+ // Adjust FP to point to saved FP. -+ DCHECK_EQ(stack_offset, 0); -+ Add64(fp, sp, Operand(fp_offset)); -+} -+ -+void TurboAssembler::LeaveFrame(StackFrame::Type type) { -+ addi(sp, fp, 2 * kPointerSize); -+ Ld(ra, MemOperand(fp, 1 * kPointerSize)); -+ Ld(fp, MemOperand(fp, 0 * kPointerSize)); -+} -+ -+void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, -+ StackFrame::Type frame_type) { -+ DCHECK(frame_type == StackFrame::EXIT || -+ frame_type == StackFrame::BUILTIN_EXIT); -+ -+ // Set up the frame structure on the stack. -+ STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); -+ STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); -+ STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); -+ -+ // This is how the stack will look: -+ // fp + 2 (==kCallerSPDisplacement) - old stack's end -+ // [fp + 1 (==kCallerPCOffset)] - saved old ra -+ // [fp + 0 (==kCallerFPOffset)] - saved old fp -+ // [fp - 1 StackFrame::EXIT Smi -+ // [fp - 2 (==kSPOffset)] - sp of the called function -+ // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the -+ // new stack (will contain saved ra) -+ -+ // Save registers and reserve room for saved entry sp. -+ addi(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp); -+ Sd(ra, MemOperand(sp, 3 * kPointerSize)); -+ Sd(fp, MemOperand(sp, 2 * kPointerSize)); -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ li(scratch, Operand(StackFrame::TypeToMarker(frame_type))); -+ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); -+ } -+ // Set up new frame pointer. -+ addi(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp); -+ -+ if (emit_debug_code()) { -+ Sd(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); -+ } -+ -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Save the frame pointer and the context in top. -+ li(t5, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, -+ isolate())); -+ Sd(fp, MemOperand(t5)); -+ li(t5, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ Sd(cp, MemOperand(t5)); -+ } -+ -+ const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); -+ if (save_doubles) { -+ // The stack is already aligned to 0 modulo 8 for stores with sdc1. -+ int kNumOfSavedRegisters = FPURegister::kNumRegisters; -+ int space = kNumOfSavedRegisters * kDoubleSize; -+ Sub64(sp, sp, Operand(space)); -+ for (int i = 0; i < kNumOfSavedRegisters; i++) { -+ FPURegister reg = FPURegister::from_code(i); -+ StoreDouble(reg, MemOperand(sp, i * kDoubleSize)); -+ } -+ } -+ -+ // Reserve place for the return address, stack space and an optional slot -+ // (used by DirectCEntry to hold the return value if a struct is -+ // returned) and align the frame preparing for calling the runtime function. -+ DCHECK_GE(stack_space, 0); -+ Sub64(sp, sp, Operand((stack_space + 2) * kPointerSize)); -+ if (frame_alignment > 0) { -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ And(sp, sp, Operand(-frame_alignment)); // Align stack. -+ } -+ -+ // Set the exit frame sp value to point just before the return address -+ // location. -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ addi(scratch, sp, kPointerSize); -+ Sd(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); -+} -+ -+void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count, -+ bool do_return, -+ bool argument_count_is_length) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ // Optionally restore all double registers. -+ if (save_doubles) { -+ // Remember: we only need to restore every 2nd double FPU value. -+ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; -+ Sub64(t5, fp, -+ Operand(ExitFrameConstants::kFixedFrameSizeFromFp + -+ kNumOfSavedRegisters * kDoubleSize)); -+ for (int i = 0; i < kNumOfSavedRegisters; i++) { -+ FPURegister reg = FPURegister::from_code(2 * i); -+ LoadDouble(reg, MemOperand(t5, i * kDoubleSize)); -+ } -+ } -+ -+ // Clear top frame. -+ li(t5, -+ ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate())); -+ Sd(zero_reg, MemOperand(t5)); -+ -+ // Restore current context from top and clear it in debug mode. -+ li(t5, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ Ld(cp, MemOperand(t5)); -+ -+#ifdef DEBUG -+ li(t5, -+ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); -+ Sd(a3, MemOperand(t5)); -+#endif -+ -+ // Pop the arguments, restore registers, and return. -+ mv(sp, fp); // Respect ABI stack constraint. -+ Ld(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); -+ Ld(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); -+ -+ if (argument_count.is_valid()) { -+ if (argument_count_is_length) { -+ add(sp, sp, argument_count); -+ } else { -+ CalcScaledAddress(sp, sp, argument_count, kPointerSizeLog2, t5); -+ } -+ } -+ -+ addi(sp, sp, 2 * kPointerSize); -+ -+ if (do_return) { -+ Ret(); -+ } -+} -+ -+int TurboAssembler::ActivationFrameAlignment() { -+#if V8_HOST_ARCH_RISCV64 -+ // Running on the real platform. Use the alignment as mandated by the local -+ // environment. -+ // Note: This will break if we ever start generating snapshots on one RISC-V -+ // platform for another RISC-V platform with a different alignment. -+ return base::OS::ActivationFrameAlignment(); -+#else // V8_HOST_ARCH_RISCV64 -+ // If we are using the simulator then we should always align to the expected -+ // alignment. As the simulator is used to generate snapshots we do not know -+ // if the target platform will need alignment, so this is controlled from a -+ // flag. -+ return FLAG_sim_stack_alignment; -+#endif // V8_HOST_ARCH_RISCV64 -+} -+ -+void MacroAssembler::AssertStackIsAligned() { -+ if (emit_debug_code()) { -+ const int frame_alignment = ActivationFrameAlignment(); -+ const int frame_alignment_mask = frame_alignment - 1; -+ -+ if (frame_alignment > kPointerSize) { -+ Label alignment_as_expected; -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, sp, frame_alignment_mask); -+ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); -+ } -+ // Don't use Check here, as it will call Runtime_Abort re-entering here. -+ ebreak(); -+ bind(&alignment_as_expected); -+ } -+ } -+} -+ -+void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { -+ if (SmiValuesAre32Bits()) { -+ Lw(dst, MemOperand(src.rm(), SmiWordOffset(src.offset()))); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ Lw(dst, src); -+ SmiUntag(dst); -+ } -+} -+ -+void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, -+ Register scratch) { -+ DCHECK_EQ(0, kSmiTag); -+ andi(scratch, value, kSmiTagMask); -+ Branch(smi_label, eq, scratch, Operand(zero_reg)); -+} -+ -+void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, -+ Register scratch) { -+ DCHECK_EQ(0, kSmiTag); -+ andi(scratch, value, kSmiTagMask); -+ Branch(not_smi_label, ne, scratch, Operand(zero_reg)); -+} -+ -+void MacroAssembler::AssertNotSmi(Register object) { -+ if (emit_debug_code()) { -+ STATIC_ASSERT(kSmiTag == 0); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, object, kSmiTagMask); -+ Check(ne, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertSmi(Register object) { -+ if (emit_debug_code()) { -+ STATIC_ASSERT(kSmiTag == 0); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ andi(scratch, object, kSmiTagMask); -+ Check(eq, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertConstructor(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t5); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor, t5, -+ Operand(zero_reg)); -+ -+ LoadMap(t5, object); -+ Lbu(t5, FieldMemOperand(t5, Map::kBitFieldOffset)); -+ And(t5, t5, Operand(Map::Bits1::IsConstructorBit::kMask)); -+ Check(ne, AbortReason::kOperandIsNotAConstructor, t5, Operand(zero_reg)); -+ } -+} -+ -+void MacroAssembler::AssertFunction(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t5); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t5, -+ Operand(zero_reg)); -+ GetObjectType(object, t5, t5); -+ Check(eq, AbortReason::kOperandIsNotAFunction, t5, -+ Operand(JS_FUNCTION_TYPE)); -+ } -+} -+ -+void MacroAssembler::AssertBoundFunction(Register object) { -+ if (emit_debug_code()) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t5); -+ Check(ne, AbortReason::kOperandIsASmiAndNotABoundFunction, t5, -+ Operand(zero_reg)); -+ GetObjectType(object, t5, t5); -+ Check(eq, AbortReason::kOperandIsNotABoundFunction, t5, -+ Operand(JS_BOUND_FUNCTION_TYPE)); -+ } -+} -+ -+void MacroAssembler::AssertGeneratorObject(Register object) { -+ if (!emit_debug_code()) return; -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ STATIC_ASSERT(kSmiTag == 0); -+ SmiTst(object, t5); -+ Check(ne, AbortReason::kOperandIsASmiAndNotAGeneratorObject, t5, -+ Operand(zero_reg)); -+ -+ GetObjectType(object, t5, t5); -+ -+ Label done; -+ -+ // Check if JSGeneratorObject -+ Branch(&done, eq, t5, Operand(JS_GENERATOR_OBJECT_TYPE)); -+ -+ // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) -+ Branch(&done, eq, t5, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); -+ -+ // Check if JSAsyncGeneratorObject -+ Branch(&done, eq, t5, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); -+ -+ Abort(AbortReason::kOperandIsNotAGeneratorObject); -+ -+ bind(&done); -+} -+ -+void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, -+ Register scratch) { -+ if (emit_debug_code()) { -+ Label done_checking; -+ AssertNotSmi(object); -+ LoadRoot(scratch, RootIndex::kUndefinedValue); -+ Branch(&done_checking, eq, object, Operand(scratch)); -+ GetObjectType(object, scratch, scratch); -+ Assert(eq, AbortReason::kExpectedUndefinedOrCell, scratch, -+ Operand(ALLOCATION_SITE_TYPE)); -+ bind(&done_checking); -+ } -+} -+ -+template -+void TurboAssembler::FloatMinMaxHelper(FPURegister dst, FPURegister src1, -+ FPURegister src2, MaxMinKind kind) { -+ DCHECK((std::is_same::value) || -+ (std::is_same::value)); -+ -+ if (src1 == src2 && dst != src1) { -+ if (std::is_same::value) { -+ fmv_s(dst, src1); -+ } else { -+ fmv_d(dst, src1); -+ } -+ return; -+ } -+ -+ Label done, nan; -+ -+ // For RISCV, fmin_s returns the other non-NaN operand as result if only one -+ // operand is NaN; but for JS, if any operand is NaN, result is Nan. The -+ // following handles the discrepency between handling of NaN between ISA and -+ // JS semantics -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ if (std::is_same::value) { -+ CompareIsNanF32(scratch, src1, src2); -+ } else { -+ CompareIsNanF64(scratch, src1, src2); -+ } -+ BranchTrueF(scratch, &nan); -+ -+ if (kind == MaxMinKind::kMax) { -+ if (std::is_same::value) { -+ fmax_s(dst, src1, src2); -+ } else { -+ fmax_d(dst, src1, src2); -+ } -+ } else { -+ if (std::is_same::value) { -+ fmin_s(dst, src1, src2); -+ } else { -+ fmin_d(dst, src1, src2); -+ } -+ } -+ j(&done); -+ -+ bind(&nan); -+ // if any operand is NaN, return NaN (fadd returns NaN if any operand is NaN) -+ if (std::is_same::value) { -+ fadd_s(dst, src1, src2); -+ } else { -+ fadd_d(dst, src1, src2); -+ } -+ -+ bind(&done); -+} -+ -+void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMax); -+} -+ -+void TurboAssembler::Float32Min(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMin); -+} -+ -+void TurboAssembler::Float64Max(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMax); -+} -+ -+void TurboAssembler::Float64Min(FPURegister dst, FPURegister src1, -+ FPURegister src2) { -+ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMin); -+} -+ -+static const int kRegisterPassedArguments = 8; -+ -+int TurboAssembler::CalculateStackPassedDWords(int num_gp_arguments, -+ int num_fp_arguments) { -+ int stack_passed_dwords = 0; -+ -+ // Up to eight integer arguments are passed in registers a0..a7 and -+ // up to eight floating point arguments are passed in registers fa0..fa7 -+ if (num_gp_arguments > kRegisterPassedArguments) { -+ stack_passed_dwords += num_gp_arguments - kRegisterPassedArguments; -+ } -+ if (num_fp_arguments > kRegisterPassedArguments) { -+ stack_passed_dwords += num_fp_arguments - kRegisterPassedArguments; -+ } -+ stack_passed_dwords += kCArgSlotCount; -+ return stack_passed_dwords; -+} -+ -+void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, -+ int num_double_arguments, -+ Register scratch) { -+ int frame_alignment = ActivationFrameAlignment(); -+ -+ // Up to eight simple arguments in a0..a7, fa0..fa7. -+ // Remaining arguments are pushed on the stack (arg slot calculation handled -+ // by CalculateStackPassedDWords()). -+ int stack_passed_arguments = -+ CalculateStackPassedDWords(num_reg_arguments, num_double_arguments); -+ if (frame_alignment > kPointerSize) { -+ // Make stack end at alignment and make room for stack arguments and the -+ // original value of sp. -+ mv(scratch, sp); -+ Sub64(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ And(sp, sp, Operand(-frame_alignment)); -+ Sd(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); -+ } else { -+ Sub64(sp, sp, Operand(stack_passed_arguments * kPointerSize)); -+ } -+} -+ -+void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, -+ Register scratch) { -+ PrepareCallCFunction(num_reg_arguments, 0, scratch); -+} -+ -+void TurboAssembler::CallCFunction(ExternalReference function, -+ int num_reg_arguments, -+ int num_double_arguments) { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ li(t6, function); -+ CallCFunctionHelper(t6, num_reg_arguments, num_double_arguments); -+} -+ -+void TurboAssembler::CallCFunction(Register function, int num_reg_arguments, -+ int num_double_arguments) { -+ CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); -+} -+ -+void TurboAssembler::CallCFunction(ExternalReference function, -+ int num_arguments) { -+ CallCFunction(function, num_arguments, 0); -+} -+ -+void TurboAssembler::CallCFunction(Register function, int num_arguments) { -+ CallCFunction(function, num_arguments, 0); -+} -+ -+void TurboAssembler::CallCFunctionHelper(Register function, -+ int num_reg_arguments, -+ int num_double_arguments) { -+ DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); -+ DCHECK(has_frame()); -+ // Make sure that the stack is aligned before calling a C function unless -+ // running in the simulator. The simulator has its own alignment check which -+ // provides more information. -+ // The argument stots are presumed to have been set up by -+ // PrepareCallCFunction. -+ -+#if V8_HOST_ARCH_RISCV64 -+ if (emit_debug_code()) { -+ int frame_alignment = base::OS::ActivationFrameAlignment(); -+ int frame_alignment_mask = frame_alignment - 1; -+ if (frame_alignment > kPointerSize) { -+ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); -+ Label alignment_as_expected; -+ { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ And(scratch, sp, Operand(frame_alignment_mask)); -+ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); -+ } -+ // Don't use Check here, as it will call Runtime_Abort possibly -+ // re-entering here. -+ ebreak(); -+ bind(&alignment_as_expected); -+ } -+ } -+#endif // V8_HOST_ARCH_RISCV64 -+ -+ // Just call directly. The function called cannot cause a GC, or -+ // allow preemption, so the return address in the link register -+ // stays correct. -+ { -+ BlockTrampolinePoolScope block_trampoline_pool(this); -+ if (function != t6) { -+ mv(t6, function); -+ function = t6; -+ } -+ -+ // Save the frame pointer and PC so that the stack layout remains -+ // iterable, even without an ExitFrame which normally exists between JS -+ // and C frames. -+ // 't' registers are caller-saved so this is safe as a scratch register. -+ Register pc_scratch = t1; -+ Register scratch = t2; -+ DCHECK(!AreAliased(pc_scratch, scratch, function)); -+ -+ auipc(pc_scratch, 0); -+ // FIXME(RISCV): Does this need an offset? It seems like this should be the -+ // PC of the call, but MIPS does not seem to do that. -+ -+ // See x64 code for reasoning about how to address the isolate data fields. -+ if (root_array_available()) { -+ Sd(pc_scratch, MemOperand(kRootRegister, -+ IsolateData::fast_c_call_caller_pc_offset())); -+ Sd(fp, MemOperand(kRootRegister, -+ IsolateData::fast_c_call_caller_fp_offset())); -+ } else { -+ DCHECK_NOT_NULL(isolate()); -+ li(scratch, ExternalReference::fast_c_call_caller_pc_address(isolate())); -+ Sd(pc_scratch, MemOperand(scratch)); -+ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); -+ Sd(fp, MemOperand(scratch)); -+ } -+ -+ Call(function); -+ -+ if (isolate() != nullptr) { -+ // We don't unset the PC; the FP is the source of truth. -+ Register scratch = t1; -+ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); -+ Sd(zero_reg, MemOperand(scratch)); -+ } -+ } -+ -+ int stack_passed_arguments = -+ CalculateStackPassedDWords(num_reg_arguments, num_double_arguments); -+ -+ if (base::OS::ActivationFrameAlignment() > kPointerSize) { -+ Ld(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); -+ } else { -+ Add64(sp, sp, Operand(stack_passed_arguments * kPointerSize)); -+ } -+} -+ -+#undef BRANCH_ARGS_CHECK -+ -+void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask, -+ Condition cc, Label* condition_met) { -+ And(scratch, object, Operand(~kPageAlignmentMask)); -+ Ld(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); -+ And(scratch, scratch, Operand(mask)); -+ Branch(condition_met, cc, scratch, Operand(zero_reg)); -+} -+ -+Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, -+ Register reg4, Register reg5, -+ Register reg6) { -+ RegList regs = 0; -+ if (reg1.is_valid()) regs |= reg1.bit(); -+ if (reg2.is_valid()) regs |= reg2.bit(); -+ if (reg3.is_valid()) regs |= reg3.bit(); -+ if (reg4.is_valid()) regs |= reg4.bit(); -+ if (reg5.is_valid()) regs |= reg5.bit(); -+ if (reg6.is_valid()) regs |= reg6.bit(); -+ -+ const RegisterConfiguration* config = RegisterConfiguration::Default(); -+ for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { -+ int code = config->GetAllocatableGeneralCode(i); -+ Register candidate = Register::from_code(code); -+ if (regs & candidate.bit()) continue; -+ return candidate; -+ } -+ UNREACHABLE(); -+} -+ -+void TurboAssembler::ComputeCodeStartAddress(Register dst) { -+ // This push on ra and the pop below together ensure that we restore the -+ // register ra, which is needed while computing the code start address. -+ push(ra); -+ -+ auipc(ra, 0); -+ addi(ra, ra, kInstrSize * 2); // ra = address of li -+ int pc = pc_offset(); -+ li(dst, Operand(pc)); -+ Sub64(dst, ra, dst); -+ -+ pop(ra); // Restore ra -+} -+ -+void TurboAssembler::ResetSpeculationPoisonRegister() { -+ li(kSpeculationPoisonRegister, -1); -+} -+ -+void TurboAssembler::CallForDeoptimization(Address target, int deopt_id, -+ Label* exit, DeoptimizeKind kind) { -+ USE(exit, kind); -+ NoRootArrayScope no_root_array(this); -+ -+ // Save the deopt id in kRootRegister (we don't need the roots array from -+ // now on). -+ DCHECK_LE(deopt_id, 0xFFFF); -+ li(kRootRegister, deopt_id); -+ Call(target, RelocInfo::RUNTIME_ENTRY); -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/macro-assembler-riscv64.h -@@ -0,0 +1,1181 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef INCLUDED_FROM_MACRO_ASSEMBLER_H -+#error This header must be included via macro-assembler.h -+#endif -+ -+#ifndef V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ -+#define V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ -+ -+#include "src/codegen/assembler.h" -+#include "src/codegen/riscv64/assembler-riscv64.h" -+#include "src/common/globals.h" -+ -+namespace v8 { -+namespace internal { -+ -+// Forward declarations. -+enum class AbortReason : uint8_t; -+ -+// Reserved Register Usage Summary. -+// -+// Registers t5, t6, and t3 are reserved for use by the MacroAssembler. -+// -+// The programmer should know that the MacroAssembler may clobber these three, -+// but won't touch other registers except in special cases. -+// -+// FIXME(RISCV): Cannot find info about this ABI. We chose t6 for now. -+// Per the RISC-V ABI, register t6 must be used for indirect function call -+// via 'jalr t6' or 'jr t6' instructions. This is relied upon by gcc when -+// trying to update gp register for position-independent-code. Whenever -+// RISC-V generated code calls C code, it must be via t6 register. -+ -+// Flags used for LeaveExitFrame function. -+enum LeaveExitFrameMode { EMIT_RETURN = true, NO_EMIT_RETURN = false }; -+ -+// Flags used for the li macro-assembler function. -+enum LiFlags { -+ // If the constant value can be represented in just 16 bits, then -+ // optimize the li to use a single instruction, rather than lui/ori/slli -+ // sequence. A number of other optimizations that emits less than -+ // maximum number of instructions exists. -+ OPTIMIZE_SIZE = 0, -+ // Always use 8 instructions (lui/addi/slliw sequence), even if the -+ // constant -+ // could be loaded with just one, so that this value is patchable later. -+ CONSTANT_SIZE = 1, -+ // For address loads 8 instruction are required. Used to mark -+ // constant load that will be used as address without relocation -+ // information. It ensures predictable code size, so specific sites -+ // in code are patchable. -+ ADDRESS_LOAD = 2 -+}; -+ -+enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; -+enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; -+enum RAStatus { kRAHasNotBeenSaved, kRAHasBeenSaved }; -+ -+Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg, -+ Register reg3 = no_reg, -+ Register reg4 = no_reg, -+ Register reg5 = no_reg, -+ Register reg6 = no_reg); -+ -+// ----------------------------------------------------------------------------- -+// Static helper functions. -+ -+#if defined(V8_TARGET_LITTLE_ENDIAN) -+#define SmiWordOffset(offset) (offset + kPointerSize / 2) -+#else -+#define SmiWordOffset(offset) offset -+#endif -+ -+// Generate a MemOperand for loading a field from an object. -+inline MemOperand FieldMemOperand(Register object, int offset) { -+ return MemOperand(object, offset - kHeapObjectTag); -+} -+ -+// Generate a MemOperand for storing arguments 5..N on the stack -+// when calling CallCFunction(). -+// TODO(plind): Currently ONLY used for O32. Should be fixed for -+// n64, and used in RegExp code, and other places -+// with more than 8 arguments. -+inline MemOperand CFunctionArgumentOperand(int index) { -+ DCHECK_GT(index, kCArgSlotCount); -+ // Argument 5 takes the slot just past the four Arg-slots. -+ int offset = (index - 5) * kPointerSize + kCArgsSlotsSize; -+ return MemOperand(sp, offset); -+} -+ -+class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { -+ public: -+ using TurboAssemblerBase::TurboAssemblerBase; -+ -+ // Activation support. -+ void EnterFrame(StackFrame::Type type); -+ void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) { -+ // Out-of-line constant pool not implemented on RISC-V. -+ UNREACHABLE(); -+ } -+ void LeaveFrame(StackFrame::Type type); -+ -+ // Generates function and stub prologue code. -+ void StubPrologue(StackFrame::Type type); -+ void Prologue(); -+ -+ void InitializeRootRegister() { -+ ExternalReference isolate_root = ExternalReference::isolate_root(isolate()); -+ li(kRootRegister, Operand(isolate_root)); -+ } -+ -+ // Jump unconditionally to given label. -+ void jmp(Label* L) { Branch(L); } -+ -+ // ------------------------------------------------------------------------- -+ // Debugging. -+ -+ void Trap() override; -+ void DebugBreak() override; -+ -+ // Calls Abort(msg) if the condition cc is not satisfied. -+ // Use --debug_code to enable. -+ void Assert(Condition cc, AbortReason reason, Register rs, Operand rt); -+ -+ // Like Assert(), but always enabled. -+ void Check(Condition cc, AbortReason reason, Register rs, Operand rt); -+ -+ // Print a message to stdout and abort execution. -+ void Abort(AbortReason msg); -+ -+ // Arguments macros. -+#define COND_TYPED_ARGS Condition cond, Register r1, const Operand &r2 -+#define COND_ARGS cond, r1, r2 -+ -+ // Cases when relocation is not needed. -+#define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \ -+ void Name(target_type target); \ -+ void Name(target_type target, COND_TYPED_ARGS); -+ -+#define DECLARE_BRANCH_PROTOTYPES(Name) \ -+ DECLARE_NORELOC_PROTOTYPE(Name, Label*) \ -+ DECLARE_NORELOC_PROTOTYPE(Name, int32_t) -+ -+ DECLARE_BRANCH_PROTOTYPES(Branch) -+ DECLARE_BRANCH_PROTOTYPES(BranchAndLink) -+ DECLARE_BRANCH_PROTOTYPES(BranchShort) -+ -+#undef DECLARE_BRANCH_PROTOTYPES -+#undef COND_TYPED_ARGS -+#undef COND_ARGS -+ -+ inline void NegateBool(Register rd, Register rs) { Xor(rd, rs, 1); } -+ -+ // Compare float, if any operand is NaN, result is false except for NE -+ void CompareF32(Register rd, FPUCondition cc, FPURegister cmp1, -+ FPURegister cmp2); -+ // Compare double, if any operand is NaN, result is false except for NE -+ void CompareF64(Register rd, FPUCondition cc, FPURegister cmp1, -+ FPURegister cmp2); -+ void CompareIsNanF32(Register rd, FPURegister cmp1, FPURegister cmp2); -+ void CompareIsNanF64(Register rd, FPURegister cmp1, FPURegister cmp2); -+ -+ // Floating point branches -+ void BranchTrueShortF(Register rs, Label* target); -+ void BranchFalseShortF(Register rs, Label* target); -+ -+ void BranchTrueF(Register rs, Label* target); -+ void BranchFalseF(Register rs, Label* target); -+ -+ void Branch(Label* L, Condition cond, Register rs, RootIndex index); -+ -+ static int InstrCountForLi64Bit(int64_t value); -+ inline void LiLower32BitHelper(Register rd, Operand j); -+ void li_optimized(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); -+ // Load int32 in the rd register. -+ void li(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); -+ inline void li(Register rd, int64_t j, LiFlags mode = OPTIMIZE_SIZE) { -+ li(rd, Operand(j), mode); -+ } -+ -+ void li(Register dst, Handle value, LiFlags mode = OPTIMIZE_SIZE); -+ void li(Register dst, ExternalReference value, LiFlags mode = OPTIMIZE_SIZE); -+ void li(Register dst, const StringConstantBase* string, -+ LiFlags mode = OPTIMIZE_SIZE); -+ -+ void LoadFromConstantsTable(Register destination, -+ int constant_index) override; -+ void LoadRootRegisterOffset(Register destination, intptr_t offset) override; -+ void LoadRootRelative(Register destination, int32_t offset) override; -+ -+// Jump, Call, and Ret pseudo instructions implementing inter-working. -+#define COND_ARGS \ -+ Condition cond = al, Register rs = zero_reg, \ -+ const Operand &rt = Operand(zero_reg) -+ -+ void Jump(Register target, COND_ARGS); -+ void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS); -+ void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS); -+ // Deffer from li, this method save target to the memory, and then load -+ // it to register use ld, it can be used in wasm jump table for concurrent -+ // patching. -+ void PatchAndJump(Address target); -+ void Jump(Handle code, RelocInfo::Mode rmode, COND_ARGS); -+ void Jump(const ExternalReference& reference) override; -+ void Call(Register target, COND_ARGS); -+ void Call(Address target, RelocInfo::Mode rmode, COND_ARGS); -+ void Call(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, -+ COND_ARGS); -+ void Call(Label* target); -+ void LoadAddress(Register dst, Label* target); -+ -+ // Load the builtin given by the Smi in |builtin_index| into the same -+ // register. -+ void LoadEntryFromBuiltinIndex(Register builtin_index); -+ void CallBuiltinByIndex(Register builtin_index) override; -+ -+ void LoadCodeObjectEntry(Register destination, -+ Register code_object) override { -+ // TODO(RISCV): Implement. -+ UNIMPLEMENTED(); -+ } -+ void CallCodeObject(Register code_object) override { -+ // TODO(RISCV): Implement. -+ UNIMPLEMENTED(); -+ } -+ void JumpCodeObject(Register code_object) override { -+ // TODO(RISCV): Implement. -+ UNIMPLEMENTED(); -+ } -+ -+ // Generates an instruction sequence s.t. the return address points to the -+ // instruction following the call. -+ // The return address on the stack is used by frame iteration. -+ void StoreReturnAddressAndCall(Register target); -+ -+ void CallForDeoptimization(Address target, int deopt_id, Label* exit, -+ DeoptimizeKind kind); -+ -+ void Ret(COND_ARGS); -+ -+ // Emit code to discard a non-negative number of pointer-sized elements -+ // from the stack, clobbering only the sp register. -+ void Drop(int count, Condition cond = cc_always, Register reg = no_reg, -+ const Operand& op = Operand(no_reg)); -+ -+ // Trivial case of DropAndRet that only emits 2 instructions. -+ void DropAndRet(int drop); -+ -+ void DropAndRet(int drop, Condition cond, Register reg, const Operand& op); -+ -+ void Ld(Register rd, const MemOperand& rs); -+ void Sd(Register rd, const MemOperand& rs); -+ -+ void push(Register src) { -+ Add64(sp, sp, Operand(-kPointerSize)); -+ Sd(src, MemOperand(sp, 0)); -+ } -+ void Push(Register src) { push(src); } -+ void Push(Handle handle); -+ void Push(Smi smi); -+ -+ // Push two registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2) { -+ Sub64(sp, sp, Operand(2 * kPointerSize)); -+ Sd(src1, MemOperand(sp, 1 * kPointerSize)); -+ Sd(src2, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push three registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3) { -+ Sub64(sp, sp, Operand(3 * kPointerSize)); -+ Sd(src1, MemOperand(sp, 2 * kPointerSize)); -+ Sd(src2, MemOperand(sp, 1 * kPointerSize)); -+ Sd(src3, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push four registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3, Register src4) { -+ Sub64(sp, sp, Operand(4 * kPointerSize)); -+ Sd(src1, MemOperand(sp, 3 * kPointerSize)); -+ Sd(src2, MemOperand(sp, 2 * kPointerSize)); -+ Sd(src3, MemOperand(sp, 1 * kPointerSize)); -+ Sd(src4, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ // Push five registers. Pushes leftmost register first (to highest address). -+ void Push(Register src1, Register src2, Register src3, Register src4, -+ Register src5) { -+ Sub64(sp, sp, Operand(5 * kPointerSize)); -+ Sd(src1, MemOperand(sp, 4 * kPointerSize)); -+ Sd(src2, MemOperand(sp, 3 * kPointerSize)); -+ Sd(src3, MemOperand(sp, 2 * kPointerSize)); -+ Sd(src4, MemOperand(sp, 1 * kPointerSize)); -+ Sd(src5, MemOperand(sp, 0 * kPointerSize)); -+ } -+ -+ void Push(Register src, Condition cond, Register tst1, Register tst2) { -+ // Since we don't have conditional execution we use a Branch. -+ Branch(3, cond, tst1, Operand(tst2)); -+ Sub64(sp, sp, Operand(kPointerSize)); -+ Sd(src, MemOperand(sp, 0)); -+ } -+ -+ void SaveRegisters(RegList registers); -+ void RestoreRegisters(RegList registers); -+ -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode); -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode, Address wasm_target); -+ void CallEphemeronKeyBarrier(Register object, Register address, -+ SaveFPRegsMode fp_mode); -+ -+ // Push multiple registers on the stack. -+ // Registers are saved in numerical order, with higher numbered registers -+ // saved in higher memory addresses. -+ void MultiPush(RegList regs); -+ void MultiPushFPU(RegList regs); -+ -+ // Calculate how much stack space (in bytes) are required to store caller -+ // registers excluding those specified in the arguments. -+ int RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, -+ Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg) const; -+ -+ // Push caller saved registers on the stack, and return the number of bytes -+ // stack pointer is adjusted. -+ int PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg); -+ // Restore caller saved registers from the stack, and return the number of -+ // bytes stack pointer is adjusted. -+ int PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, -+ Register exclusion2 = no_reg, -+ Register exclusion3 = no_reg); -+ -+ void pop(Register dst) { -+ Ld(dst, MemOperand(sp, 0)); -+ Add64(sp, sp, Operand(kPointerSize)); -+ } -+ void Pop(Register dst) { pop(dst); } -+ -+ // Pop two registers. Pops rightmost register first (from lower address). -+ void Pop(Register src1, Register src2) { -+ DCHECK(src1 != src2); -+ Ld(src2, MemOperand(sp, 0 * kPointerSize)); -+ Ld(src1, MemOperand(sp, 1 * kPointerSize)); -+ Add64(sp, sp, 2 * kPointerSize); -+ } -+ -+ // Pop three registers. Pops rightmost register first (from lower address). -+ void Pop(Register src1, Register src2, Register src3) { -+ Ld(src3, MemOperand(sp, 0 * kPointerSize)); -+ Ld(src2, MemOperand(sp, 1 * kPointerSize)); -+ Ld(src1, MemOperand(sp, 2 * kPointerSize)); -+ Add64(sp, sp, 3 * kPointerSize); -+ } -+ -+ void Pop(uint32_t count = 1) { Add64(sp, sp, Operand(count * kPointerSize)); } -+ -+ // Pops multiple values from the stack and load them in the -+ // registers specified in regs. Pop order is the opposite as in MultiPush. -+ void MultiPop(RegList regs); -+ void MultiPopFPU(RegList regs); -+ -+#define DEFINE_INSTRUCTION(instr) \ -+ void instr(Register rd, Register rs, const Operand& rt); \ -+ void instr(Register rd, Register rs, Register rt) { \ -+ instr(rd, rs, Operand(rt)); \ -+ } \ -+ void instr(Register rs, Register rt, int32_t j) { instr(rs, rt, Operand(j)); } -+ -+#define DEFINE_INSTRUCTION2(instr) \ -+ void instr(Register rs, const Operand& rt); \ -+ void instr(Register rs, Register rt) { instr(rs, Operand(rt)); } \ -+ void instr(Register rs, int32_t j) { instr(rs, Operand(j)); } -+ -+ DEFINE_INSTRUCTION(Add32) -+ DEFINE_INSTRUCTION(Add64) -+ DEFINE_INSTRUCTION(Div32) -+ DEFINE_INSTRUCTION(Divu32) -+ DEFINE_INSTRUCTION(Divu64) -+ DEFINE_INSTRUCTION(Mod32) -+ DEFINE_INSTRUCTION(Modu32) -+ DEFINE_INSTRUCTION(Div64) -+ DEFINE_INSTRUCTION(Sub32) -+ DEFINE_INSTRUCTION(Sub64) -+ DEFINE_INSTRUCTION(Mod64) -+ DEFINE_INSTRUCTION(Modu64) -+ DEFINE_INSTRUCTION(Mul32) -+ DEFINE_INSTRUCTION(Mulh32) -+ DEFINE_INSTRUCTION(Mul64) -+ DEFINE_INSTRUCTION(Mulh64) -+ DEFINE_INSTRUCTION2(Div32) -+ DEFINE_INSTRUCTION2(Div64) -+ DEFINE_INSTRUCTION2(Divu32) -+ DEFINE_INSTRUCTION2(Divu64) -+ -+ DEFINE_INSTRUCTION(And) -+ DEFINE_INSTRUCTION(Or) -+ DEFINE_INSTRUCTION(Xor) -+ DEFINE_INSTRUCTION(Nor) -+ DEFINE_INSTRUCTION2(Neg) -+ -+ DEFINE_INSTRUCTION(Slt) -+ DEFINE_INSTRUCTION(Sltu) -+ DEFINE_INSTRUCTION(Sle) -+ DEFINE_INSTRUCTION(Sleu) -+ DEFINE_INSTRUCTION(Sgt) -+ DEFINE_INSTRUCTION(Sgtu) -+ DEFINE_INSTRUCTION(Sge) -+ DEFINE_INSTRUCTION(Sgeu) -+ DEFINE_INSTRUCTION(Seq) -+ DEFINE_INSTRUCTION(Sne) -+ -+ DEFINE_INSTRUCTION(Sll64) -+ DEFINE_INSTRUCTION(Sra64) -+ DEFINE_INSTRUCTION(Srl64) -+ DEFINE_INSTRUCTION(Sll32) -+ DEFINE_INSTRUCTION(Sra32) -+ DEFINE_INSTRUCTION(Srl32) -+ -+ DEFINE_INSTRUCTION2(Seqz) -+ DEFINE_INSTRUCTION2(Snez) -+ -+ DEFINE_INSTRUCTION(Ror) -+ DEFINE_INSTRUCTION(Dror) -+#undef DEFINE_INSTRUCTION -+#undef DEFINE_INSTRUCTION2 -+#undef DEFINE_INSTRUCTION3 -+ -+ void SmiUntag(Register dst, const MemOperand& src); -+ void SmiUntag(Register dst, Register src) { -+ if (SmiValuesAre32Bits()) { -+ srai(dst, src, kSmiShift); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ sraiw(dst, src, kSmiShift); -+ } -+ } -+ -+ void SmiUntag(Register reg) { SmiUntag(reg, reg); } -+ -+ // Removes current frame and its arguments from the stack preserving -+ // the arguments and a return address pushed to the stack for the next call. -+ // Both |callee_args_count| and |caller_args_count| do not include -+ // receiver. |callee_args_count| is not modified. |caller_args_count| -+ // is trashed. -+ void PrepareForTailCall(Register callee_args_count, -+ Register caller_args_count, Register scratch0, -+ Register scratch1); -+ -+ int CalculateStackPassedDWords(int num_gp_arguments, int num_fp_arguments); -+ -+ // Before calling a C-function from generated code, align arguments on stack. -+ // After aligning the frame, non-register arguments must be stored on the -+ // stack, using helper: CFunctionArgumentOperand(). -+ // The argument count assumes all arguments are word sized. -+ // Some compilers/platforms require the stack to be aligned when calling -+ // C++ code. -+ // Needs a scratch register to do some arithmetic. This register will be -+ // trashed. -+ void PrepareCallCFunction(int num_reg_arguments, int num_double_registers, -+ Register scratch); -+ void PrepareCallCFunction(int num_reg_arguments, Register scratch); -+ -+ // Arguments 1-8 are placed in registers a0 through a7 respectively. -+ // Arguments 9..n are stored to stack -+ -+ // Calls a C function and cleans up the space for arguments allocated -+ // by PrepareCallCFunction. The called function is not allowed to trigger a -+ // garbage collection, since that might move the code and invalidate the -+ // return address (unless this is somehow accounted for by the called -+ // function). -+ void CallCFunction(ExternalReference function, int num_arguments); -+ void CallCFunction(Register function, int num_arguments); -+ void CallCFunction(ExternalReference function, int num_reg_arguments, -+ int num_double_arguments); -+ void CallCFunction(Register function, int num_reg_arguments, -+ int num_double_arguments); -+ void MovFromFloatResult(DoubleRegister dst); -+ void MovFromFloatParameter(DoubleRegister dst); -+ -+ // These functions abstract parameter passing for the three different ways -+ // we call C functions from generated code. -+ void MovToFloatParameter(DoubleRegister src); -+ void MovToFloatParameters(DoubleRegister src1, DoubleRegister src2); -+ void MovToFloatResult(DoubleRegister src); -+ -+ // See comments at the beginning of Builtins::Generate_CEntry. -+ inline void PrepareCEntryArgs(int num_args) { li(a0, num_args); } -+ inline void PrepareCEntryFunction(const ExternalReference& ref) { -+ li(a1, ref); -+ } -+ -+ void CheckPageFlag(Register object, Register scratch, int mask, Condition cc, -+ Label* condition_met); -+#undef COND_ARGS -+ -+ // Performs a truncating conversion of a floating point number as used by -+ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. -+ // Exits with 'result' holding the answer. -+ void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result, -+ DoubleRegister double_input, StubCallMode stub_mode); -+ -+ void CompareI(Register rd, Register rs, const Operand& rt, Condition cond); -+ -+ void LoadZeroIfConditionNotZero(Register dest, Register condition); -+ void LoadZeroIfConditionZero(Register dest, Register condition); -+ -+ void SignExtendByte(Register rd, Register rs) { -+ slli(rd, rs, 64 - 8); -+ srai(rd, rd, 64 - 8); -+ } -+ -+ void SignExtendShort(Register rd, Register rs) { -+ slli(rd, rs, 64 - 16); -+ srai(rd, rd, 64 - 16); -+ } -+ -+ void SignExtendWord(Register rd, Register rs) { sext_w(rd, rs); } -+ void ZeroExtendWord(Register rd, Register rs) { -+ slli(rd, rs, 32); -+ srli(rd, rd, 32); -+ } -+ -+ void Clz32(Register rd, Register rs); -+ void Clz64(Register rd, Register rs); -+ void Ctz32(Register rd, Register rs); -+ void Ctz64(Register rd, Register rs); -+ void Popcnt32(Register rd, Register rs); -+ void Popcnt64(Register rd, Register rs); -+ -+ // Bit field starts at bit pos and extending for size bits is extracted from -+ // rs and stored zero/sign-extended and right-justified in rt -+ void ExtractBits(Register rt, Register rs, uint16_t pos, uint16_t size, -+ bool sign_extend = false); -+ void ExtractBits(Register dest, Register source, Register pos, int size, -+ bool sign_extend = false) { -+ sra(dest, source, pos); -+ ExtractBits(dest, dest, 0, size, sign_extend); -+ } -+ -+ // Insert bits [0, size) of source to bits [pos, pos+size) of dest -+ void InsertBits(Register dest, Register source, Register pos, int size); -+ -+ void Neg_s(FPURegister fd, FPURegister fs); -+ void Neg_d(FPURegister fd, FPURegister fs); -+ -+ // Change endianness -+ void ByteSwap(Register dest, Register src, int operand_size); -+ -+ // Convert single to unsigned word. -+ void Trunc_uw_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // helper functions for unaligned load/store -+ template -+ void UnalignedLoadHelper(Register rd, const MemOperand& rs); -+ template -+ void UnalignedStoreHelper(Register rd, const MemOperand& rs, -+ Register scratch_other = no_reg); -+ -+ template -+ void UnalignedFLoadHelper(FPURegister frd, const MemOperand& rs, -+ Register scratch); -+ template -+ void UnalignedFStoreHelper(FPURegister frd, const MemOperand& rs, -+ Register scratch); -+ -+ template -+ void AlignedLoadHelper(Reg_T target, const MemOperand& rs, Func generator); -+ template -+ void AlignedStoreHelper(Reg_T value, const MemOperand& rs, Func generator); -+ -+ template -+ void LoadNBytes(Register rd, const MemOperand& rs, Register scratch); -+ template -+ void LoadNBytesOverwritingBaseReg(const MemOperand& rs, Register scratch0, -+ Register scratch1); -+ // load/store macros -+ void Ulh(Register rd, const MemOperand& rs); -+ void Ulhu(Register rd, const MemOperand& rs); -+ void Ush(Register rd, const MemOperand& rs); -+ -+ void Ulw(Register rd, const MemOperand& rs); -+ void Ulwu(Register rd, const MemOperand& rs); -+ void Usw(Register rd, const MemOperand& rs); -+ -+ void Uld(Register rd, const MemOperand& rs); -+ void Usd(Register rd, const MemOperand& rs); -+ -+ void ULoadFloat(FPURegister fd, const MemOperand& rs, Register scratch); -+ void UStoreFloat(FPURegister fd, const MemOperand& rs, Register scratch); -+ -+ void ULoadDouble(FPURegister fd, const MemOperand& rs, Register scratch); -+ void UStoreDouble(FPURegister fd, const MemOperand& rs, Register scratch); -+ -+ void Lb(Register rd, const MemOperand& rs); -+ void Lbu(Register rd, const MemOperand& rs); -+ void Sb(Register rd, const MemOperand& rs); -+ -+ void Lh(Register rd, const MemOperand& rs); -+ void Lhu(Register rd, const MemOperand& rs); -+ void Sh(Register rd, const MemOperand& rs); -+ -+ void Lw(Register rd, const MemOperand& rs); -+ void Lwu(Register rd, const MemOperand& rs); -+ void Sw(Register rd, const MemOperand& rs); -+ -+ void LoadFloat(FPURegister fd, const MemOperand& src); -+ void StoreFloat(FPURegister fs, const MemOperand& dst); -+ -+ void LoadDouble(FPURegister fd, const MemOperand& src); -+ void StoreDouble(FPURegister fs, const MemOperand& dst); -+ -+ void Ll(Register rd, const MemOperand& rs); -+ void Sc(Register rd, const MemOperand& rs); -+ -+ void Lld(Register rd, const MemOperand& rs); -+ void Scd(Register rd, const MemOperand& rs); -+ -+ void Float32Max(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float32Min(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float64Max(FPURegister dst, FPURegister src1, FPURegister src2); -+ void Float64Min(FPURegister dst, FPURegister src1, FPURegister src2); -+ template -+ void FloatMinMaxHelper(FPURegister dst, FPURegister src1, FPURegister src2, -+ MaxMinKind kind); -+ -+ bool IsDoubleZeroRegSet() { return has_double_zero_reg_set_; } -+ bool IsSingleZeroRegSet() { return has_single_zero_reg_set_; } -+ -+ inline void Move(Register dst, Smi smi) { li(dst, Operand(smi)); } -+ -+ inline void Move(Register dst, Register src) { -+ if (dst != src) { -+ mv(dst, src); -+ } -+ } -+ -+ inline void Move(FPURegister dst, FPURegister src) { -+ if (dst != src) fmv_d(dst, src); -+ } -+ -+ inline void Move(Register dst_low, Register dst_high, FPURegister src) { -+ fmv_x_d(dst_high, src); -+ fmv_x_w(dst_low, src); -+ srli(dst_high, dst_high, 32); -+ } -+ -+ inline void Move(Register dst, FPURegister src) { fmv_x_d(dst, src); } -+ -+ inline void Move(FPURegister dst, Register src) { fmv_d_x(dst, src); } -+ -+ // Extract sign-extended word from high-half of FPR to GPR -+ inline void ExtractHighWordFromF64(Register dst_high, FPURegister src) { -+ fmv_x_d(dst_high, src); -+ srai(dst_high, dst_high, 32); -+ } -+ -+ // Insert low-word from GPR (src_high) to the high-half of FPR (dst) -+ void InsertHighWordF64(FPURegister dst, Register src_high); -+ -+ // Extract sign-extended word from low-half of FPR to GPR -+ inline void ExtractLowWordFromF64(Register dst_low, FPURegister src) { -+ fmv_x_w(dst_low, src); -+ } -+ -+ // Insert low-word from GPR (src_high) to the low-half of FPR (dst) -+ void InsertLowWordF64(FPURegister dst, Register src_low); -+ -+ void LoadFPRImmediate(FPURegister dst, float imm) { -+ LoadFPRImmediate(dst, bit_cast(imm)); -+ } -+ void LoadFPRImmediate(FPURegister dst, double imm) { -+ LoadFPRImmediate(dst, bit_cast(imm)); -+ } -+ void LoadFPRImmediate(FPURegister dst, uint32_t src); -+ void LoadFPRImmediate(FPURegister dst, uint64_t src); -+ -+ // AddOverflow64 sets overflow register to a negative value if -+ // overflow occured, otherwise it is zero or positive -+ void AddOverflow64(Register dst, Register left, const Operand& right, -+ Register overflow); -+ // SubOverflow64 sets overflow register to a negative value if -+ // overflow occured, otherwise it is zero or positive -+ void SubOverflow64(Register dst, Register left, const Operand& right, -+ Register overflow); -+ // MulOverflow32 sets overflow register to zero if no overflow occured -+ void MulOverflow32(Register dst, Register left, const Operand& right, -+ Register overflow); -+ -+ // MIPS-style 32-bit unsigned mulh -+ void Mulhu32(Register dst, Register left, const Operand& right, -+ Register left_zero, Register right_zero); -+ -+ // Number of instructions needed for calculation of switch table entry address -+ static const int kSwitchTablePrologueSize = 6; -+ -+ // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a -+ // functor/function with 'Label *func(size_t index)' declaration. -+ template -+ void GenerateSwitchTable(Register index, size_t case_count, -+ Func GetLabelFunction); -+ -+ // Load an object from the root table. -+ void LoadRoot(Register destination, RootIndex index) override; -+ void LoadRoot(Register destination, RootIndex index, Condition cond, -+ Register src1, const Operand& src2); -+ -+ // If the value is a NaN, canonicalize the value else, do nothing. -+ void FPUCanonicalizeNaN(const DoubleRegister dst, const DoubleRegister src); -+ -+ // --------------------------------------------------------------------------- -+ // FPU macros. These do not handle special cases like NaN or +- inf. -+ -+ // Convert unsigned word to double. -+ void Cvt_d_uw(FPURegister fd, Register rs); -+ -+ // convert signed word to double. -+ void Cvt_d_w(FPURegister fd, Register rs); -+ -+ // Convert unsigned long to double. -+ void Cvt_d_ul(FPURegister fd, Register rs); -+ -+ // Convert unsigned word to float. -+ void Cvt_s_uw(FPURegister fd, Register rs); -+ -+ // convert signed word to float. -+ void Cvt_s_w(FPURegister fd, Register rs); -+ -+ // Convert unsigned long to float. -+ void Cvt_s_ul(FPURegister fd, Register rs); -+ -+ // Convert double to unsigned word. -+ void Trunc_uw_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert double to signed word. -+ void Trunc_w_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert single to signed word. -+ void Trunc_w_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert double to unsigned long. -+ void Trunc_ul_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert singled to signed long. -+ void Trunc_l_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert single to unsigned long. -+ void Trunc_ul_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Convert singled to signed long. -+ void Trunc_l_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Round single to signed word. -+ void Round_w_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Round double to signed word. -+ void Round_w_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Ceil single to signed word. -+ void Ceil_w_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Ceil double to signed word. -+ void Ceil_w_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Floor single to signed word. -+ void Floor_w_s(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Floor double to signed word. -+ void Floor_w_d(Register rd, FPURegister fs, Register result = no_reg); -+ -+ // Round double functions -+ void Trunc_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Round_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Floor_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Ceil_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ -+ // Round float functions -+ void Trunc_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Round_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Floor_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ void Ceil_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); -+ -+ // Jump the register contains a smi. -+ void JumpIfSmi(Register value, Label* smi_label, Register scratch = t3); -+ -+ void JumpIfEqual(Register a, int32_t b, Label* dest) { -+ Branch(dest, eq, a, Operand(b)); -+ } -+ -+ void JumpIfLessThan(Register a, int32_t b, Label* dest) { -+ Branch(dest, lt, a, Operand(b)); -+ } -+ -+ // Push a standard frame, consisting of ra, fp, context and JS function. -+ void PushStandardFrame(Register function_reg); -+ -+ // Get the actual activation frame alignment for target environment. -+ static int ActivationFrameAlignment(); -+ -+ // Calculated scaled address (rd) as rt + rs << sa -+ void CalcScaledAddress(Register rd, Register rs, Register rt, uint8_t sa, -+ Register scratch = t3); -+ -+ // Compute the start of the generated instruction stream from the current PC. -+ // This is an alternative to embedding the {CodeObject} handle as a reference. -+ void ComputeCodeStartAddress(Register dst); -+ -+ void ResetSpeculationPoisonRegister(); -+ -+ // Control-flow integrity: -+ -+ // Define a function entrypoint. This doesn't emit any code for this -+ // architecture, as control-flow integrity is not supported for it. -+ void CodeEntry() {} -+ // Define an exception handler. -+ void ExceptionHandler() {} -+ // Define an exception handler and bind a label. -+ void BindExceptionHandler(Label* label) { bind(label); } -+ -+ protected: -+ inline Register GetRtAsRegisterHelper(const Operand& rt, Register scratch); -+ inline int32_t GetOffset(int32_t offset, Label* L, OffsetSize bits); -+ -+ private: -+ bool has_double_zero_reg_set_ = false; -+ bool has_single_zero_reg_set_ = false; -+ -+ // Performs a truncating conversion of a floating point number as used by -+ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it -+ // succeeds, otherwise falls through if result is saturated. On return -+ // 'result' either holds answer, or is clobbered on fall through. -+ void TryInlineTruncateDoubleToI(Register result, DoubleRegister input, -+ Label* done); -+ -+ void CallCFunctionHelper(Register function, int num_reg_arguments, -+ int num_double_arguments); -+ -+ // TODO(RISCV) Reorder parameters so out parameters come last. -+ bool CalculateOffset(Label* L, int32_t* offset, OffsetSize bits); -+ bool CalculateOffset(Label* L, int32_t* offset, OffsetSize bits, -+ Register* scratch, const Operand& rt); -+ -+ void BranchShortHelper(int32_t offset, Label* L); -+ bool BranchShortHelper(int32_t offset, Label* L, Condition cond, Register rs, -+ const Operand& rt); -+ bool BranchShortCheck(int32_t offset, Label* L, Condition cond, Register rs, -+ const Operand& rt); -+ -+ void BranchAndLinkShortHelper(int32_t offset, Label* L); -+ void BranchAndLinkShort(int32_t offset); -+ void BranchAndLinkShort(Label* L); -+ bool BranchAndLinkShortHelper(int32_t offset, Label* L, Condition cond, -+ Register rs, const Operand& rt); -+ bool BranchAndLinkShortCheck(int32_t offset, Label* L, Condition cond, -+ Register rs, const Operand& rt); -+ void BranchLong(Label* L); -+ void BranchAndLinkLong(Label* L); -+ -+ template -+ void RoundHelper(FPURegister dst, FPURegister src, FPURegister fpu_scratch, -+ RoundingMode mode); -+ -+ template -+ void RoundFloatingPointToInteger(Register rd, FPURegister fs, Register result, -+ TruncFunc trunc); -+ -+ // Push a fixed frame, consisting of ra, fp. -+ void PushCommonFrame(Register marker_reg = no_reg); -+ -+ void CallRecordWriteStub(Register object, Register address, -+ RememberedSetAction remembered_set_action, -+ SaveFPRegsMode fp_mode, Handle code_target, -+ Address wasm_target); -+}; -+ -+// MacroAssembler implements a collection of frequently used macros. -+class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { -+ public: -+ using TurboAssembler::TurboAssembler; -+ -+ bool IsNear(Label* L, Condition cond, int rs_reg); -+ -+ // Swap two registers. If the scratch register is omitted then a slightly -+ // less efficient form using xor instead of mov is emitted. -+ void Swap(Register reg1, Register reg2, Register scratch = no_reg); -+ -+ void PushRoot(RootIndex index) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Push(scratch); -+ } -+ -+ // Compare the object in a register to a value and jump if they are equal. -+ void JumpIfRoot(Register with, RootIndex index, Label* if_equal) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(if_equal, eq, with, Operand(scratch)); -+ } -+ -+ // Compare the object in a register to a value and jump if they are not equal. -+ void JumpIfNotRoot(Register with, RootIndex index, Label* if_not_equal) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ LoadRoot(scratch, index); -+ Branch(if_not_equal, ne, with, Operand(scratch)); -+ } -+ -+ // Checks if value is in range [lower_limit, higher_limit] using a single -+ // comparison. -+ void JumpIfIsInRange(Register value, unsigned lower_limit, -+ unsigned higher_limit, Label* on_in_range); -+ -+ // --------------------------------------------------------------------------- -+ // GC Support -+ -+ // Notify the garbage collector that we wrote a pointer into an object. -+ // |object| is the object being stored into, |value| is the object being -+ // stored. value and scratch registers are clobbered by the operation. -+ // The offset is the offset from the start of the object, not the offset from -+ // the tagged HeapObject pointer. For use with FieldOperand(reg, off). -+ void RecordWriteField( -+ Register object, int offset, Register value, Register scratch, -+ RAStatus ra_status, SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, -+ SmiCheck smi_check = INLINE_SMI_CHECK); -+ -+ // For a given |object| notify the garbage collector that the slot |address| -+ // has been written. |value| is the object being stored. The value and -+ // address registers are clobbered by the operation. -+ void RecordWrite( -+ Register object, Register address, Register value, RAStatus ra_status, -+ SaveFPRegsMode save_fp, -+ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, -+ SmiCheck smi_check = INLINE_SMI_CHECK); -+ -+ // void Pref(int32_t hint, const MemOperand& rs); -+ -+ // --------------------------------------------------------------------------- -+ // Pseudo-instructions. -+ -+ void LoadWordPair(Register rd, const MemOperand& rs, Register scratch = t3); -+ void StoreWordPair(Register rd, const MemOperand& rs, Register scratch = t3); -+ -+ void Madd_s(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); -+ void Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); -+ void Msub_s(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); -+ void Msub_d(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); -+ -+ // Enter exit frame. -+ // argc - argument count to be dropped by LeaveExitFrame. -+ // save_doubles - saves FPU registers on stack, currently disabled. -+ // stack_space - extra stack space. -+ void EnterExitFrame(bool save_doubles, int stack_space = 0, -+ StackFrame::Type frame_type = StackFrame::EXIT); -+ -+ // Leave the current exit frame. -+ void LeaveExitFrame(bool save_doubles, Register arg_count, -+ bool do_return = NO_EMIT_RETURN, -+ bool argument_count_is_length = false); -+ -+ void LoadMap(Register destination, Register object); -+ -+ // Make sure the stack is aligned. Only emits code in debug mode. -+ void AssertStackIsAligned(); -+ -+ // Load the global proxy from the current context. -+ void LoadGlobalProxy(Register dst) { -+ LoadNativeContextSlot(Context::GLOBAL_PROXY_INDEX, dst); -+ } -+ -+ void LoadNativeContextSlot(int index, Register dst); -+ -+ // Load the initial map from the global function. The registers -+ // function and map can be the same, function is then overwritten. -+ void LoadGlobalFunctionInitialMap(Register function, Register map, -+ Register scratch); -+ -+ // ------------------------------------------------------------------------- -+ // JavaScript invokes. -+ -+ // Invoke the JavaScript function code by either calling or jumping. -+ void InvokeFunctionCode(Register function, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count, InvokeFlag flag); -+ -+ // On function call, call into the debugger if necessary. -+ void CheckDebugHook(Register fun, Register new_target, -+ Register expected_parameter_count, -+ Register actual_parameter_count); -+ -+ // Invoke the JavaScript function in the given register. Changes the -+ // current context to the context in the function before invoking. -+ void InvokeFunctionWithNewTarget(Register function, Register new_target, -+ Register actual_parameter_count, -+ InvokeFlag flag); -+ void InvokeFunction(Register function, Register expected_parameter_count, -+ Register actual_parameter_count, InvokeFlag flag); -+ -+ // Frame restart support. -+ void MaybeDropFrames(); -+ -+ // Exception handling. -+ -+ // Push a new stack handler and link into stack handler chain. -+ void PushStackHandler(); -+ -+ // Unlink the stack handler on top of the stack from the stack handler chain. -+ // Must preserve the result register. -+ void PopStackHandler(); -+ -+ // ------------------------------------------------------------------------- -+ // Support functions. -+ -+ void GetObjectType(Register function, Register map, Register type_reg); -+ -+ // ------------------------------------------------------------------------- -+ // Runtime calls. -+ -+ // Call a runtime routine. -+ void CallRuntime(const Runtime::Function* f, int num_arguments, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs); -+ -+ // Convenience function: Same as above, but takes the fid instead. -+ void CallRuntime(Runtime::FunctionId fid, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { -+ const Runtime::Function* function = Runtime::FunctionForId(fid); -+ CallRuntime(function, function->nargs, save_doubles); -+ } -+ -+ // Convenience function: Same as above, but takes the fid instead. -+ void CallRuntime(Runtime::FunctionId fid, int num_arguments, -+ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { -+ CallRuntime(Runtime::FunctionForId(fid), num_arguments, save_doubles); -+ } -+ -+ // Convenience function: tail call a runtime routine (jump). -+ void TailCallRuntime(Runtime::FunctionId fid); -+ -+ // Jump to the builtin routine. -+ void JumpToExternalReference(const ExternalReference& builtin, -+ bool builtin_exit_frame = false); -+ -+ // Generates a trampoline to jump to the off-heap instruction stream. -+ void JumpToInstructionStream(Address entry); -+ -+ // --------------------------------------------------------------------------- -+ // In-place weak references. -+ void LoadWeakValue(Register out, Register in, Label* target_if_cleared); -+ -+ // ------------------------------------------------------------------------- -+ // StatsCounter support. -+ -+ void IncrementCounter(StatsCounter* counter, int value, Register scratch1, -+ Register scratch2); -+ void DecrementCounter(StatsCounter* counter, int value, Register scratch1, -+ Register scratch2); -+ -+ // ------------------------------------------------------------------------- -+ // Smi utilities. -+ -+ void SmiTag(Register dst, Register src) { -+ STATIC_ASSERT(kSmiTag == 0); -+ if (SmiValuesAre32Bits()) { -+ // FIXME(RISCV): do not understand the logic here -+ slli(dst, src, 32); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ Add32(dst, src, src); -+ } -+ } -+ -+ void SmiTag(Register reg) { SmiTag(reg, reg); } -+ -+ // Left-shifted from int32 equivalent of Smi. -+ void SmiScale(Register dst, Register src, int scale) { -+ if (SmiValuesAre32Bits()) { -+ // The int portion is upper 32-bits of 64-bit word. -+ srai(dst, src, (kSmiShift - scale) & 0x3F); -+ } else { -+ DCHECK(SmiValuesAre31Bits()); -+ DCHECK_GE(scale, kSmiTagSize); -+ slliw(dst, src, scale - kSmiTagSize); -+ } -+ } -+ -+ // Test if the register contains a smi. -+ inline void SmiTst(Register value, Register scratch) { -+ And(scratch, value, Operand(kSmiTagMask)); -+ } -+ -+ // Jump if the register contains a non-smi. -+ void JumpIfNotSmi(Register value, Label* not_smi_label, -+ Register scratch = t3); -+ -+ // Abort execution if argument is a smi, enabled via --debug-code. -+ void AssertNotSmi(Register object); -+ void AssertSmi(Register object); -+ -+ // Abort execution if argument is not a Constructor, enabled via --debug-code. -+ void AssertConstructor(Register object); -+ -+ // Abort execution if argument is not a JSFunction, enabled via --debug-code. -+ void AssertFunction(Register object); -+ -+ // Abort execution if argument is not a JSBoundFunction, -+ // enabled via --debug-code. -+ void AssertBoundFunction(Register object); -+ -+ // Abort execution if argument is not a JSGeneratorObject (or subclass), -+ // enabled via --debug-code. -+ void AssertGeneratorObject(Register object); -+ -+ // Abort execution if argument is not undefined or an AllocationSite, enabled -+ // via --debug-code. -+ void AssertUndefinedOrAllocationSite(Register object, Register scratch); -+ -+ template -+ void DecodeField(Register dst, Register src) { -+ ExtractBits(dst, src, Field::kShift, Field::kSize); -+ } -+ -+ template -+ void DecodeField(Register reg) { -+ DecodeField(reg, reg); -+ } -+ -+ private: -+ // Helper functions for generating invokes. -+ void InvokePrologue(Register expected_parameter_count, -+ Register actual_parameter_count, Label* done, -+ InvokeFlag flag); -+ -+ // Compute memory operands for safepoint stack slots. -+ static int SafepointRegisterStackIndex(int reg_code); -+ -+ // Needs access to SafepointRegisterStackIndex for compiled frame -+ // traversal. -+ friend class StandardFrame; -+ -+ DISALLOW_IMPLICIT_CONSTRUCTORS(MacroAssembler); -+}; -+ -+template -+void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count, -+ Func GetLabelFunction) { -+ // Ensure that dd-ed labels following this instruction use 8 bytes aligned -+ // addresses. -+ BlockTrampolinePoolFor(static_cast(case_count) * 2 + -+ kSwitchTablePrologueSize); -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ -+ Align(8); -+ // Load the address from the jump table at index and jump to it -+ auipc(scratch, 0); // Load the current PC into scratch -+ slli(t5, index, kPointerSizeLog2); // t5 = offset of indexth entry -+ add(t5, t5, scratch); // t5 = (saved PC) + (offset of indexth entry) -+ ld(t5, t5, 6 * kInstrSize); // Add the size of these 6 instructions to the -+ // offset, then load -+ jr(t5); // Jump to the address loaded from the table -+ nop(); // For 16-byte alignment -+ for (size_t index = 0; index < case_count; ++index) { -+ dd(GetLabelFunction(index)); -+ } -+} -+ -+#define ACCESS_MASM(masm) masm-> -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/register-riscv64.h -@@ -0,0 +1,345 @@ -+// Copyright 2018 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_CODEGEN_RISCV_REGISTER_RISCV_H_ -+#define V8_CODEGEN_RISCV_REGISTER_RISCV_H_ -+ -+#include "src/codegen/register.h" -+#include "src/codegen/reglist.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+ -+namespace v8 { -+namespace internal { -+ -+// clang-format off -+#define GENERAL_REGISTERS(V) \ -+ V(zero_reg) V(ra) V(sp) V(gp) V(tp) V(t0) V(t1) V(t2) \ -+ V(fp) V(s1) V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) \ -+ V(a6) V(a7) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) V(s9) \ -+ V(s10) V(s11) V(t3) V(t4) V(t5) V(t6) -+ -+#define ALLOCATABLE_GENERAL_REGISTERS(V) \ -+ V(a0) V(a1) V(a2) V(a3) \ -+ V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(s7) V(t4) -+ -+#define DOUBLE_REGISTERS(V) \ -+ V(ft0) V(ft1) V(ft2) V(ft3) V(ft4) V(ft5) V(ft6) V(ft7) \ -+ V(fs0) V(fs1) V(fa0) V(fa1) V(fa2) V(fa3) V(fa4) V(fa5) \ -+ V(fa6) V(fa7) V(fs2) V(fs3) V(fs4) V(fs5) V(fs6) V(fs7) \ -+ V(fs8) V(fs9) V(fs10) V(fs11) V(ft8) V(ft9) V(ft10) V(ft11) -+ -+#define FLOAT_REGISTERS DOUBLE_REGISTERS -+#define SIMD128_REGISTERS(V) \ -+ V(w0) V(w1) V(w2) V(w3) V(w4) V(w5) V(w6) V(w7) \ -+ V(w8) V(w9) V(w10) V(w11) V(w12) V(w13) V(w14) V(w15) \ -+ V(w16) V(w17) V(w18) V(w19) V(w20) V(w21) V(w22) V(w23) \ -+ V(w24) V(w25) V(w26) V(w27) V(w28) V(w29) V(w30) V(w31) -+ -+#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ -+ V(ft0) V(ft1) V(ft2) V(ft3) \ -+ V(ft4) V(ft5) V(ft6) V(ft7) V(fa0) V(fa1) V(fa2) V(fa3) V(fa4) V(fa5) \ -+ V(fa6) V(fa7) -+ -+// clang-format on -+ -+// Note that the bit values must match those used in actual instruction -+// encoding. -+const int kNumRegs = 32; -+ -+const RegList kJSCallerSaved = 1 << 5 | // t0 -+ 1 << 6 | // t1 -+ 1 << 7 | // t2 -+ 1 << 10 | // a0 -+ 1 << 11 | // a1 -+ 1 << 12 | // a2 -+ 1 << 13 | // a3 -+ 1 << 14 | // a4 -+ 1 << 15 | // a5 -+ 1 << 16 | // a6 -+ 1 << 17 | // a7 -+ 1 << 29; // t4 -+ -+const int kNumJSCallerSaved = 12; -+ -+// Callee-saved registers preserved when switching from C to JavaScript. -+const RegList kCalleeSaved = 1 << 8 | // fp/s0 -+ 1 << 9 | // s1 -+ 1 << 18 | // s2 -+ 1 << 19 | // s3 -+ 1 << 20 | // s4 -+ 1 << 21 | // s5 -+ 1 << 22 | // s6 (roots in Javascript code) -+ 1 << 23 | // s7 (cp in Javascript code) -+ 1 << 24 | // s8 -+ 1 << 25 | // s9 -+ 1 << 26 | // s10 -+ 1 << 27; // s11 -+ -+const int kNumCalleeSaved = 12; -+ -+const RegList kCalleeSavedFPU = 1 << 8 | // fs0 -+ 1 << 9 | // fs1 -+ 1 << 18 | // fs2 -+ 1 << 19 | // fs3 -+ 1 << 20 | // fs4 -+ 1 << 21 | // fs5 -+ 1 << 22 | // fs6 -+ 1 << 23 | // fs7 -+ 1 << 24 | // fs8 -+ 1 << 25 | // fs9 -+ 1 << 26 | // fs10 -+ 1 << 27; // fs11 -+ -+const int kNumCalleeSavedFPU = 12; -+ -+const RegList kCallerSavedFPU = 1 << 0 | // ft0 -+ 1 << 1 | // ft1 -+ 1 << 2 | // ft2 -+ 1 << 3 | // ft3 -+ 1 << 4 | // ft4 -+ 1 << 5 | // ft5 -+ 1 << 6 | // ft6 -+ 1 << 7 | // ft7 -+ 1 << 10 | // fa0 -+ 1 << 11 | // fa1 -+ 1 << 12 | // fa2 -+ 1 << 13 | // fa3 -+ 1 << 14 | // fa4 -+ 1 << 15 | // fa5 -+ 1 << 16 | // fa6 -+ 1 << 17 | // fa7 -+ 1 << 28 | // ft8 -+ 1 << 29 | // ft9 -+ 1 << 30 | // ft10 -+ 1 << 31; // ft11 -+ -+// Number of registers for which space is reserved in safepoints. Must be a -+// multiple of 8. -+const int kNumSafepointRegisters = 32; -+ -+// Define the list of registers actually saved at safepoints. -+// Note that the number of saved registers may be smaller than the reserved -+// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. -+const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; -+const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; -+ -+const int kUndefIndex = -1; -+// Map with indexes on stack that corresponds to codes of saved registers. -+const int kSafepointRegisterStackIndexMap[kNumRegs] = {kUndefIndex, // zero_reg -+ kUndefIndex, // ra -+ kUndefIndex, // sp -+ kUndefIndex, // gp -+ kUndefIndex, // tp -+ 0, // t0 -+ 1, // t1 -+ 2, // t2 -+ 3, // s0/fp -+ 4, // s1 -+ 5, // a0 -+ 6, // a1 -+ 7, // a2 -+ 8, // a3 -+ 9, // a4 -+ 10, // a5 -+ 11, // a6 -+ 12, // a7 -+ 13, // s2 -+ 14, // s3 -+ 15, // s4 -+ 16, // s5 -+ 17, // s6 -+ 18, // s7 -+ 19, // s8 -+ 10, // s9 -+ 21, // s10 -+ 22, // s11 -+ kUndefIndex, // t3 -+ 23, // t4 -+ kUndefIndex, // t5 -+ kUndefIndex}; // t6 -+// CPU Registers. -+// -+// 1) We would prefer to use an enum, but enum values are assignment- -+// compatible with int, which has caused code-generation bugs. -+// -+// 2) We would prefer to use a class instead of a struct but we don't like -+// the register initialization to depend on the particular initialization -+// order (which appears to be different on OS X, Linux, and Windows for the -+// installed versions of C++ we tried). Using a struct permits C-style -+// "initialization". Also, the Register objects cannot be const as this -+// forces initialization stubs in MSVC, making us dependent on initialization -+// order. -+// -+// 3) By not using an enum, we are possibly preventing the compiler from -+// doing certain constant folds, which may significantly reduce the -+// code generated for some assembly instructions (because they boil down -+// to a few constants). If this is a problem, we could change the code -+// such that we use an enum in optimized mode, and the struct in debug -+// mode. This way we get the compile-time error checking in debug mode -+// and best performance in optimized code. -+ -+// ----------------------------------------------------------------------------- -+// Implementation of Register and FPURegister. -+ -+enum RegisterCode { -+#define REGISTER_CODE(R) kRegCode_##R, -+ GENERAL_REGISTERS(REGISTER_CODE) -+#undef REGISTER_CODE -+ kRegAfterLast -+}; -+ -+class Register : public RegisterBase { -+ public: -+#if defined(V8_TARGET_LITTLE_ENDIAN) -+ static constexpr int kMantissaOffset = 0; -+ static constexpr int kExponentOffset = 4; -+#elif defined(V8_TARGET_BIG_ENDIAN) -+ static constexpr int kMantissaOffset = 4; -+ static constexpr int kExponentOffset = 0; -+#else -+#error Unknown endianness -+#endif -+ -+ private: -+ friend class RegisterBase; -+ explicit constexpr Register(int code) : RegisterBase(code) {} -+}; -+ -+// s7: context register -+// s3: scratch register -+// s4: scratch register 2 -+#define DECLARE_REGISTER(R) \ -+ constexpr Register R = Register::from_code(kRegCode_##R); -+GENERAL_REGISTERS(DECLARE_REGISTER) -+#undef DECLARE_REGISTER -+ -+constexpr Register no_reg = Register::no_reg(); -+ -+int ToNumber(Register reg); -+ -+Register ToRegister(int num); -+ -+constexpr bool kPadArguments = false; -+constexpr bool kSimpleFPAliasing = true; -+constexpr bool kSimdMaskRegisters = false; -+ -+enum DoubleRegisterCode { -+#define REGISTER_CODE(R) kDoubleCode_##R, -+ DOUBLE_REGISTERS(REGISTER_CODE) -+#undef REGISTER_CODE -+ kDoubleAfterLast -+}; -+ -+// Coprocessor register. -+class FPURegister : public RegisterBase { -+ public: -+ // TODO(plind): Warning, inconsistent numbering here. kNumFPURegisters refers -+ // to number of 32-bit FPU regs, but kNumAllocatableRegisters refers to -+ // number of Double regs (64-bit regs, or FPU-reg-pairs). -+ -+ FPURegister low() const { -+ // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. -+ // Find low reg of a Double-reg pair, which is the reg itself. -+ return FPURegister::from_code(code()); -+ } -+ FPURegister high() const { -+ // TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1. -+ // Find high reg of a Doubel-reg pair, which is reg + 1. -+ return FPURegister::from_code(code() + 1); -+ } -+ -+ private: -+ friend class RegisterBase; -+ explicit constexpr FPURegister(int code) : RegisterBase(code) {} -+}; -+ -+enum MSARegisterCode { -+#define REGISTER_CODE(R) kMsaCode_##R, -+ SIMD128_REGISTERS(REGISTER_CODE) -+#undef REGISTER_CODE -+ kMsaAfterLast -+}; -+ -+// MIPS SIMD (MSA) register -+// FIXME (RISCV) -+class MSARegister : public RegisterBase { -+ friend class RegisterBase; -+ explicit constexpr MSARegister(int code) : RegisterBase(code) {} -+}; -+ -+// A few double registers are reserved: one as a scratch register and one to -+// hold 0.0. -+// fs9: 0.0 -+// fs11: scratch register. -+ -+// For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. -+using FloatRegister = FPURegister; -+ -+using DoubleRegister = FPURegister; -+ -+#define DECLARE_DOUBLE_REGISTER(R) \ -+ constexpr DoubleRegister R = DoubleRegister::from_code(kDoubleCode_##R); -+DOUBLE_REGISTERS(DECLARE_DOUBLE_REGISTER) -+#undef DECLARE_DOUBLE_REGISTER -+ -+constexpr DoubleRegister no_dreg = DoubleRegister::no_reg(); -+ -+// SIMD registers. -+using Simd128Register = MSARegister; -+ -+#define DECLARE_SIMD128_REGISTER(R) \ -+ constexpr Simd128Register R = Simd128Register::from_code(kMsaCode_##R); -+SIMD128_REGISTERS(DECLARE_SIMD128_REGISTER) -+#undef DECLARE_SIMD128_REGISTER -+ -+const Simd128Register no_msareg = Simd128Register::no_reg(); -+ -+// Register aliases. -+// cp is assumed to be a callee saved register. -+constexpr Register kRootRegister = s6; -+constexpr Register cp = s7; -+constexpr Register kScratchReg = s3; -+constexpr Register kScratchReg2 = s4; -+ -+constexpr DoubleRegister kScratchDoubleReg = fs11; -+ -+constexpr DoubleRegister kDoubleRegZero = fs9; -+ -+// Define {RegisterName} methods for the register types. -+DEFINE_REGISTER_NAMES(Register, GENERAL_REGISTERS) -+DEFINE_REGISTER_NAMES(FPURegister, DOUBLE_REGISTERS) -+DEFINE_REGISTER_NAMES(MSARegister, SIMD128_REGISTERS) -+ -+// Give alias names to registers for calling conventions. -+constexpr Register kReturnRegister0 = a0; -+constexpr Register kReturnRegister1 = a1; -+constexpr Register kReturnRegister2 = a2; -+constexpr Register kJSFunctionRegister = a1; -+constexpr Register kContextRegister = s7; -+constexpr Register kAllocateSizeRegister = a1; -+constexpr Register kSpeculationPoisonRegister = a7; -+constexpr Register kInterpreterAccumulatorRegister = a0; -+constexpr Register kInterpreterBytecodeOffsetRegister = t0; -+constexpr Register kInterpreterBytecodeArrayRegister = t1; -+constexpr Register kInterpreterDispatchTableRegister = t2; -+ -+constexpr Register kJavaScriptCallArgCountRegister = a0; -+constexpr Register kJavaScriptCallCodeStartRegister = a2; -+constexpr Register kJavaScriptCallTargetRegister = kJSFunctionRegister; -+constexpr Register kJavaScriptCallNewTargetRegister = a3; -+constexpr Register kJavaScriptCallExtraArg1Register = a2; -+ -+constexpr Register kOffHeapTrampolineRegister = t3; -+constexpr Register kRuntimeCallFunctionRegister = a1; -+constexpr Register kRuntimeCallArgCountRegister = a0; -+constexpr Register kRuntimeCallArgvRegister = a2; -+constexpr Register kWasmInstanceRegister = a0; -+constexpr Register kWasmCompileLazyFuncIndexRegister = t0; -+ -+constexpr DoubleRegister kFPReturnRegister0 = fa0; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_CODEGEN_RISCV_REGISTER_RISCV_H_ ---- a/src/3rdparty/chromium/v8/src/common/globals.h -+++ b/src/3rdparty/chromium/v8/src/common/globals.h -@@ -58,6 +58,12 @@ - #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) - #define USE_SIMULATOR 1 - #endif -+#if (V8_TARGET_ARCH_RISCV64 && !V8_HOST_ARCH_RISCV64) -+#define USE_SIMULATOR 1 -+#endif -+#if (V8_TARGET_ARCH_RISCV && !V8_HOST_ARCH_RISCV && !V8_HOST_ARCH_RISCV64) -+#define USE_SIMULATOR 1 -+#endif - #endif - - // Determine whether the architecture uses an embedded constant pool ---- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h -@@ -23,6 +23,10 @@ - #include "src/compiler/backend/ppc/instruction-codes-ppc.h" - #elif V8_TARGET_ARCH_S390 - #include "src/compiler/backend/s390/instruction-codes-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/compiler/backend/riscv64/instruction-codes-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/compiler/backend/riscv/instruction-codes-riscv.h" - #else - #define TARGET_ARCH_OPCODE_LIST(V) - #define TARGET_ADDRESSING_MODE_LIST(V) ---- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc -@@ -2624,7 +2624,8 @@ - #endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS - - #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && \ -- !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 -+ !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 && \ -+ !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV - void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); } - - void InstructionSelector::VisitWord64AtomicStore(Node* node) { -@@ -2649,7 +2650,8 @@ - UNIMPLEMENTED(); - } - #endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_PPC64 -- // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 -+ // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 && -+ // !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV - - #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM - // This is only needed on 32-bit to split the 64-bit value into two operands. ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/code-generator-riscv64.cc -@@ -0,0 +1,2759 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/callable.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/optimized-compilation-info.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/compiler/backend/code-generator-impl.h" -+#include "src/compiler/backend/code-generator.h" -+#include "src/compiler/backend/gap-resolver.h" -+#include "src/compiler/node-matchers.h" -+#include "src/compiler/osr.h" -+#include "src/heap/memory-chunk.h" -+#include "src/wasm/wasm-code-manager.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+#define __ tasm()-> -+ -+// TODO(plind): consider renaming these macros. -+#define TRACE_MSG(msg) \ -+ PrintF("code_gen: \'%s\' in function %s at line %d\n", msg, __FUNCTION__, \ -+ __LINE__) -+ -+#define TRACE_UNIMPL() \ -+ PrintF("UNIMPLEMENTED code_generator_riscv64: %s at line %d\n", \ -+ __FUNCTION__, __LINE__) -+ -+// Adds RISC-V-specific methods to convert InstructionOperands. -+class RiscvOperandConverter final : public InstructionOperandConverter { -+ public: -+ RiscvOperandConverter(CodeGenerator* gen, Instruction* instr) -+ : InstructionOperandConverter(gen, instr) {} -+ -+ FloatRegister OutputSingleRegister(size_t index = 0) { -+ return ToSingleRegister(instr_->OutputAt(index)); -+ } -+ -+ FloatRegister InputSingleRegister(size_t index) { -+ return ToSingleRegister(instr_->InputAt(index)); -+ } -+ -+ FloatRegister ToSingleRegister(InstructionOperand* op) { -+ // Single (Float) and Double register namespace is same on RISC-V, -+ // both are typedefs of FPURegister. -+ return ToDoubleRegister(op); -+ } -+ -+ Register InputOrZeroRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) { -+ DCHECK_EQ(0, InputInt32(index)); -+ return zero_reg; -+ } -+ return InputRegister(index); -+ } -+ -+ DoubleRegister InputOrZeroDoubleRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; -+ -+ return InputDoubleRegister(index); -+ } -+ -+ DoubleRegister InputOrZeroSingleRegister(size_t index) { -+ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; -+ -+ return InputSingleRegister(index); -+ } -+ -+ Operand InputImmediate(size_t index) { -+ Constant constant = ToConstant(instr_->InputAt(index)); -+ switch (constant.type()) { -+ case Constant::kInt32: -+ return Operand(constant.ToInt32()); -+ case Constant::kInt64: -+ return Operand(constant.ToInt64()); -+ case Constant::kFloat32: -+ return Operand::EmbeddedNumber(constant.ToFloat32()); -+ case Constant::kFloat64: -+ return Operand::EmbeddedNumber(constant.ToFloat64().value()); -+ case Constant::kExternalReference: -+ case Constant::kCompressedHeapObject: -+ case Constant::kHeapObject: -+ // TODO(plind): Maybe we should handle ExtRef & HeapObj here? -+ // maybe not done on arm due to const pool ?? -+ break; -+ case Constant::kDelayedStringConstant: -+ return Operand::EmbeddedStringConstant( -+ constant.ToDelayedStringConstant()); -+ case Constant::kRpoNumber: -+ UNREACHABLE(); // TODO(titzer): RPO immediates -+ break; -+ } -+ UNREACHABLE(); -+ } -+ -+ Operand InputOperand(size_t index) { -+ InstructionOperand* op = instr_->InputAt(index); -+ if (op->IsRegister()) { -+ return Operand(ToRegister(op)); -+ } -+ return InputImmediate(index); -+ } -+ -+ MemOperand MemoryOperand(size_t* first_index) { -+ const size_t index = *first_index; -+ switch (AddressingModeField::decode(instr_->opcode())) { -+ case kMode_None: -+ break; -+ case kMode_MRI: -+ *first_index += 2; -+ return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); -+ case kMode_MRR: -+ // TODO(plind): r6 address mode, to be implemented ... -+ UNREACHABLE(); -+ } -+ UNREACHABLE(); -+ } -+ -+ MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } -+ -+ MemOperand ToMemOperand(InstructionOperand* op) const { -+ DCHECK_NOT_NULL(op); -+ DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); -+ return SlotToMemOperand(AllocatedOperand::cast(op)->index()); -+ } -+ -+ MemOperand SlotToMemOperand(int slot) const { -+ FrameOffset offset = frame_access_state()->GetFrameOffset(slot); -+ return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); -+ } -+}; -+ -+static inline bool HasRegisterInput(Instruction* instr, size_t index) { -+ return instr->InputAt(index)->IsRegister(); -+} -+ -+namespace { -+ -+class OutOfLineRecordWrite final : public OutOfLineCode { -+ public: -+ OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, -+ Register value, Register scratch0, Register scratch1, -+ RecordWriteMode mode, StubCallMode stub_mode) -+ : OutOfLineCode(gen), -+ object_(object), -+ index_(index), -+ value_(value), -+ scratch0_(scratch0), -+ scratch1_(scratch1), -+ mode_(mode), -+ stub_mode_(stub_mode), -+ must_save_lr_(!gen->frame_access_state()->has_frame()), -+ zone_(gen->zone()) {} -+ -+ void Generate() final { -+ if (mode_ > RecordWriteMode::kValueIsPointer) { -+ __ JumpIfSmi(value_, exit()); -+ } -+ __ CheckPageFlag(value_, scratch0_, -+ MemoryChunk::kPointersToHereAreInterestingMask, eq, -+ exit()); -+ __ Add64(scratch1_, object_, index_); -+ RememberedSetAction const remembered_set_action = -+ mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET -+ : OMIT_REMEMBERED_SET; -+ SaveFPRegsMode const save_fp_mode = -+ frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; -+ if (must_save_lr_) { -+ // We need to save and restore ra if the frame was elided. -+ __ Push(ra); -+ } -+ if (mode_ == RecordWriteMode::kValueIsEphemeronKey) { -+ __ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode); -+ } else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) { -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched when the code -+ // is added to the native module and copied into wasm code space. -+ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, -+ save_fp_mode, wasm::WasmCode::kRecordWrite); -+ } else { -+ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, -+ save_fp_mode); -+ } -+ if (must_save_lr_) { -+ __ Pop(ra); -+ } -+ } -+ -+ private: -+ Register const object_; -+ Register const index_; -+ Register const value_; -+ Register const scratch0_; -+ Register const scratch1_; -+ RecordWriteMode const mode_; -+ StubCallMode const stub_mode_; -+ bool must_save_lr_; -+ Zone* zone_; -+}; -+ -+Condition FlagsConditionToConditionCmp(FlagsCondition condition) { -+ switch (condition) { -+ case kEqual: -+ return eq; -+ case kNotEqual: -+ return ne; -+ case kSignedLessThan: -+ return lt; -+ case kSignedGreaterThanOrEqual: -+ return ge; -+ case kSignedLessThanOrEqual: -+ return le; -+ case kSignedGreaterThan: -+ return gt; -+ case kUnsignedLessThan: -+ return Uless; -+ case kUnsignedGreaterThanOrEqual: -+ return Ugreater_equal; -+ case kUnsignedLessThanOrEqual: -+ return Uless_equal; -+ case kUnsignedGreaterThan: -+ return Ugreater; -+ case kUnorderedEqual: -+ case kUnorderedNotEqual: -+ break; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+Condition FlagsConditionToConditionTst(FlagsCondition condition) { -+ switch (condition) { -+ case kNotEqual: -+ return ne; -+ case kEqual: -+ return eq; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+Condition FlagsConditionToConditionOvf(FlagsCondition condition) { -+ switch (condition) { -+ case kOverflow: -+ return ne; -+ case kNotOverflow: -+ return eq; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+FPUCondition FlagsConditionToConditionCmpFPU(bool* predicate, -+ FlagsCondition condition) { -+ switch (condition) { -+ case kEqual: -+ *predicate = true; -+ return EQ; -+ case kNotEqual: -+ *predicate = false; -+ return EQ; -+ case kUnsignedLessThan: -+ *predicate = true; -+ return LT; -+ case kUnsignedGreaterThanOrEqual: -+ *predicate = false; -+ return LT; -+ case kUnsignedLessThanOrEqual: -+ *predicate = true; -+ return LE; -+ case kUnsignedGreaterThan: -+ *predicate = false; -+ return LE; -+ case kUnorderedEqual: -+ case kUnorderedNotEqual: -+ *predicate = true; -+ break; -+ default: -+ *predicate = true; -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, -+ InstructionCode opcode, Instruction* instr, -+ RiscvOperandConverter const& i) { -+ const MemoryAccessMode access_mode = -+ static_cast(MiscField::decode(opcode)); -+ if (access_mode == kMemoryAccessPoisoned) { -+ Register value = i.OutputRegister(); -+ codegen->tasm()->And(value, value, kSpeculationPoisonRegister); -+ } -+} -+ -+} // namespace -+ -+#define ASSEMBLE_ATOMIC_LOAD_INTEGER(asm_instr) \ -+ do { \ -+ __ asm_instr(i.OutputRegister(), i.MemoryOperand()); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ -+ do { \ -+ __ sync(); \ -+ __ asm_instr(i.InputOrZeroRegister(2), i.MemoryOperand()); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_BINOP(load_linked, store_conditional, bin_instr) \ -+ do { \ -+ Label binop; \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ __ sync(); \ -+ __ bind(&binop); \ -+ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ -+ __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \ -+ Operand(i.InputRegister(2))); \ -+ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&binop, ne, i.TempRegister(1), Operand(zero_reg)); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_BINOP_EXT(load_linked, store_conditional, sign_extend, \ -+ size, bin_instr, representation) \ -+ do { \ -+ Label binop; \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ And(i.TempRegister(3), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ And(i.TempRegister(3), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(3))); \ -+ __ Sll32(i.TempRegister(3), i.TempRegister(3), 3); \ -+ __ sync(); \ -+ __ bind(&binop); \ -+ __ load_linked(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(1), i.TempRegister(3), \ -+ size, sign_extend); \ -+ __ bin_instr(i.TempRegister(2), i.OutputRegister(0), \ -+ Operand(i.InputRegister(2))); \ -+ __ InsertBits(i.TempRegister(1), i.TempRegister(2), i.TempRegister(3), \ -+ size); \ -+ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&binop, ne, i.TempRegister(1), Operand(zero_reg)); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_linked, store_conditional) \ -+ do { \ -+ Label exchange; \ -+ __ sync(); \ -+ __ bind(&exchange); \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ -+ __ Move(i.TempRegister(1), i.InputRegister(2)); \ -+ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&exchange, ne, i.TempRegister(1), Operand(zero_reg)); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT( \ -+ load_linked, store_conditional, sign_extend, size, representation) \ -+ do { \ -+ Label exchange; \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ And(i.TempRegister(1), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ And(i.TempRegister(1), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(1))); \ -+ __ Sll32(i.TempRegister(1), i.TempRegister(1), 3); \ -+ __ sync(); \ -+ __ bind(&exchange); \ -+ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ InsertBits(i.TempRegister(2), i.InputRegister(2), i.TempRegister(1), \ -+ size); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&exchange, ne, i.TempRegister(2), Operand(zero_reg)); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_linked, \ -+ store_conditional) \ -+ do { \ -+ Label compareExchange; \ -+ Label exit; \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ __ sync(); \ -+ __ bind(&compareExchange); \ -+ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&exit, ne, i.InputRegister(2), \ -+ Operand(i.OutputRegister(0))); \ -+ __ Move(i.TempRegister(2), i.InputRegister(3)); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&compareExchange, ne, i.TempRegister(2), \ -+ Operand(zero_reg)); \ -+ __ bind(&exit); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT( \ -+ load_linked, store_conditional, sign_extend, size, representation) \ -+ do { \ -+ Label compareExchange; \ -+ Label exit; \ -+ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ -+ if (representation == 32) { \ -+ __ And(i.TempRegister(1), i.TempRegister(0), 0x3); \ -+ } else { \ -+ DCHECK_EQ(representation, 64); \ -+ __ And(i.TempRegister(1), i.TempRegister(0), 0x7); \ -+ } \ -+ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ -+ Operand(i.TempRegister(1))); \ -+ __ Sll32(i.TempRegister(1), i.TempRegister(1), 3); \ -+ __ sync(); \ -+ __ bind(&compareExchange); \ -+ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ ExtractBits(i.InputRegister(2), i.InputRegister(2), i.TempRegister(1), \ -+ size, sign_extend); \ -+ __ BranchShort(&exit, ne, i.InputRegister(2), \ -+ Operand(i.OutputRegister(0))); \ -+ __ InsertBits(i.TempRegister(2), i.InputRegister(3), i.TempRegister(1), \ -+ size); \ -+ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ -+ __ BranchShort(&compareExchange, ne, i.TempRegister(2), \ -+ Operand(zero_reg)); \ -+ __ bind(&exit); \ -+ __ sync(); \ -+ } while (0) -+ -+#define ASSEMBLE_IEEE754_BINOP(name) \ -+ do { \ -+ FrameScope scope(tasm(), StackFrame::MANUAL); \ -+ __ PrepareCallCFunction(0, 2, kScratchReg); \ -+ __ MovToFloatParameters(i.InputDoubleRegister(0), \ -+ i.InputDoubleRegister(1)); \ -+ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 2); \ -+ /* Move the result in the double result register. */ \ -+ __ MovFromFloatResult(i.OutputDoubleRegister()); \ -+ } while (0) -+ -+#define ASSEMBLE_IEEE754_UNOP(name) \ -+ do { \ -+ FrameScope scope(tasm(), StackFrame::MANUAL); \ -+ __ PrepareCallCFunction(0, 1, kScratchReg); \ -+ __ MovToFloatParameter(i.InputDoubleRegister(0)); \ -+ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 1); \ -+ /* Move the result in the double result register. */ \ -+ __ MovFromFloatResult(i.OutputDoubleRegister()); \ -+ } while (0) -+ -+#define ASSEMBLE_F64X2_ARITHMETIC_BINOP(op) \ -+ do { \ -+ __ op(i.OutputSimd128Register(), i.InputSimd128Register(0), \ -+ i.InputSimd128Register(1)); \ -+ } while (0) -+ -+void CodeGenerator::AssembleDeconstructFrame() { -+ __ Move(sp, fp); -+ __ Pop(ra, fp); -+} -+ -+void CodeGenerator::AssemblePrepareTailCall() { -+ if (frame_access_state()->has_frame()) { -+ __ Ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); -+ __ Ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); -+ } -+ frame_access_state()->SetFrameAccessToSP(); -+} -+ -+void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, -+ Register scratch1, -+ Register scratch2, -+ Register scratch3) { -+ DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); -+ Label done; -+ -+ // Check if current frame is an arguments adaptor frame. -+ __ Ld(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset)); -+ __ Branch(&done, ne, scratch3, -+ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); -+ -+ // Load arguments count from current arguments adaptor frame (note, it -+ // does not include receiver). -+ Register caller_args_count_reg = scratch1; -+ __ Ld(caller_args_count_reg, -+ MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); -+ __ SmiUntag(caller_args_count_reg); -+ -+ __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3); -+ __ bind(&done); -+} -+ -+namespace { -+ -+void AdjustStackPointerForTailCall(TurboAssembler* tasm, -+ FrameAccessState* state, -+ int new_slot_above_sp, -+ bool allow_shrinkage = true) { -+ int current_sp_offset = state->GetSPToFPSlotCount() + -+ StandardFrameConstants::kFixedSlotCountAboveFp; -+ int stack_slot_delta = new_slot_above_sp - current_sp_offset; -+ if (stack_slot_delta > 0) { -+ tasm->Sub64(sp, sp, stack_slot_delta * kSystemPointerSize); -+ state->IncreaseSPDelta(stack_slot_delta); -+ } else if (allow_shrinkage && stack_slot_delta < 0) { -+ tasm->Add64(sp, sp, -stack_slot_delta * kSystemPointerSize); -+ state->IncreaseSPDelta(stack_slot_delta); -+ } -+} -+ -+} // namespace -+ -+void CodeGenerator::AssembleTailCallBeforeGap(Instruction* instr, -+ int first_unused_stack_slot) { -+ AdjustStackPointerForTailCall(tasm(), frame_access_state(), -+ first_unused_stack_slot, false); -+} -+ -+void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr, -+ int first_unused_stack_slot) { -+ AdjustStackPointerForTailCall(tasm(), frame_access_state(), -+ first_unused_stack_slot); -+} -+ -+// Check that {kJavaScriptCallCodeStartRegister} is correct. -+void CodeGenerator::AssembleCodeStartRegisterCheck() { -+ __ ComputeCodeStartAddress(kScratchReg); -+ __ Assert(eq, AbortReason::kWrongFunctionCodeStart, -+ kJavaScriptCallCodeStartRegister, Operand(kScratchReg)); -+} -+ -+// Check if the code object is marked for deoptimization. If it is, then it -+// jumps to the CompileLazyDeoptimizedCode builtin. In order to do this we need -+// to: -+// 1. read from memory the word that contains that bit, which can be found in -+// the flags in the referenced {CodeDataContainer} object; -+// 2. test kMarkedForDeoptimizationBit in those flags; and -+// 3. if it is not zero then it jumps to the builtin. -+void CodeGenerator::BailoutIfDeoptimized() { -+ int offset = Code::kCodeDataContainerOffset - Code::kHeaderSize; -+ __ Ld(kScratchReg, MemOperand(kJavaScriptCallCodeStartRegister, offset)); -+ __ Lw(kScratchReg, -+ FieldMemOperand(kScratchReg, -+ CodeDataContainer::kKindSpecificFlagsOffset)); -+ __ And(kScratchReg, kScratchReg, -+ Operand(1 << Code::kMarkedForDeoptimizationBit)); -+ __ Jump(BUILTIN_CODE(isolate(), CompileLazyDeoptimizedCode), -+ RelocInfo::CODE_TARGET, ne, kScratchReg, Operand(zero_reg)); -+} -+ -+void CodeGenerator::GenerateSpeculationPoisonFromCodeStartRegister() { -+ // Calculate a mask which has all bits set in the normal case, but has all -+ // bits cleared if we are speculatively executing the wrong PC. -+ // difference = (current - expected) | (expected - current) -+ // poison = ~(difference >> (kBitsPerSystemPointer - 1)) -+ __ ComputeCodeStartAddress(kScratchReg); -+ __ Move(kSpeculationPoisonRegister, kScratchReg); -+ __ Sub32(kSpeculationPoisonRegister, kSpeculationPoisonRegister, -+ kJavaScriptCallCodeStartRegister); -+ __ Sub32(kJavaScriptCallCodeStartRegister, kJavaScriptCallCodeStartRegister, -+ kScratchReg); -+ __ or_(kSpeculationPoisonRegister, kSpeculationPoisonRegister, -+ kJavaScriptCallCodeStartRegister); -+ __ Sra64(kSpeculationPoisonRegister, kSpeculationPoisonRegister, -+ kBitsPerSystemPointer - 1); -+ __ Nor(kSpeculationPoisonRegister, kSpeculationPoisonRegister, -+ kSpeculationPoisonRegister); -+} -+ -+void CodeGenerator::AssembleRegisterArgumentPoisoning() { -+ __ And(kJSFunctionRegister, kJSFunctionRegister, kSpeculationPoisonRegister); -+ __ And(kContextRegister, kContextRegister, kSpeculationPoisonRegister); -+ __ And(sp, sp, kSpeculationPoisonRegister); -+} -+ -+// Assembles an instruction after register allocation, producing machine code. -+CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( -+ Instruction* instr) { -+ RiscvOperandConverter i(this, instr); -+ InstructionCode opcode = instr->opcode(); -+ ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); -+ switch (arch_opcode) { -+ case kArchCallCodeObject: { -+ if (instr->InputAt(0)->IsImmediate()) { -+ __ Call(i.InputCode(0), RelocInfo::CODE_TARGET); -+ } else { -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ Add64(reg, reg, Code::kHeaderSize - kHeapObjectTag); -+ __ Call(reg); -+ } -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchCallBuiltinPointer: { -+ DCHECK(!instr->InputAt(0)->IsImmediate()); -+ Register builtin_index = i.InputRegister(0); -+ __ CallBuiltinByIndex(builtin_index); -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchCallWasmFunction: { -+ // FIXME (RISCV): isnt this test deadcode? -+ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { -+ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, -+ i.TempRegister(0), i.TempRegister(1), -+ i.TempRegister(2)); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ Constant constant = i.ToConstant(instr->InputAt(0)); -+ Address wasm_code = static_cast

(constant.ToInt64()); -+ __ Call(wasm_code, constant.rmode()); -+ } else { -+ __ Add64(kScratchReg, i.InputRegister(0), 0); -+ __ Call(kScratchReg); -+ } -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchTailCallCodeObjectFromJSFunction: -+ case kArchTailCallCodeObject: { -+ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { -+ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, -+ i.TempRegister(0), i.TempRegister(1), -+ i.TempRegister(2)); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ __ Jump(i.InputCode(0), RelocInfo::CODE_TARGET); -+ } else { -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ Add64(reg, reg, Code::kHeaderSize - kHeapObjectTag); -+ __ Jump(reg); -+ } -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchTailCallWasm: { -+ if (instr->InputAt(0)->IsImmediate()) { -+ Constant constant = i.ToConstant(instr->InputAt(0)); -+ Address wasm_code = static_cast
(constant.ToInt64()); -+ __ Jump(wasm_code, constant.rmode()); -+ } else { -+ __ Add64(kScratchReg, i.InputRegister(0), 0); -+ __ Jump(kScratchReg); -+ } -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchTailCallAddress: { -+ CHECK(!instr->InputAt(0)->IsImmediate()); -+ Register reg = i.InputRegister(0); -+ DCHECK_IMPLIES( -+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), -+ reg == kJavaScriptCallCodeStartRegister); -+ __ Jump(reg); -+ frame_access_state()->ClearSPDelta(); -+ frame_access_state()->SetFrameAccessToDefault(); -+ break; -+ } -+ case kArchCallJSFunction: { -+ Register func = i.InputRegister(0); -+ if (FLAG_debug_code) { -+ // Check the function's context matches the context argument. -+ __ Ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); -+ __ Assert(eq, AbortReason::kWrongFunctionContext, cp, -+ Operand(kScratchReg)); -+ } -+ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); -+ __ Ld(a2, FieldMemOperand(func, JSFunction::kCodeOffset)); -+ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); -+ __ Call(a2); -+ RecordCallPosition(instr); -+ frame_access_state()->ClearSPDelta(); -+ break; -+ } -+ case kArchPrepareCallCFunction: { -+ int const num_parameters = MiscField::decode(instr->opcode()); -+ __ PrepareCallCFunction(num_parameters, kScratchReg); -+ // Frame alignment requires using FP-relative frame addressing. -+ frame_access_state()->SetFrameAccessToFP(); -+ break; -+ } -+ case kArchSaveCallerRegisters: { -+ fp_mode_ = -+ static_cast(MiscField::decode(instr->opcode())); -+ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); -+ // kReturnRegister0 should have been saved before entering the stub. -+ int bytes = __ PushCallerSaved(fp_mode_, kReturnRegister0); -+ DCHECK(IsAligned(bytes, kSystemPointerSize)); -+ DCHECK_EQ(0, frame_access_state()->sp_delta()); -+ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); -+ DCHECK(!caller_registers_saved_); -+ caller_registers_saved_ = true; -+ break; -+ } -+ case kArchRestoreCallerRegisters: { -+ DCHECK(fp_mode_ == -+ static_cast(MiscField::decode(instr->opcode()))); -+ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); -+ // Don't overwrite the returned value. -+ int bytes = __ PopCallerSaved(fp_mode_, kReturnRegister0); -+ frame_access_state()->IncreaseSPDelta(-(bytes / kSystemPointerSize)); -+ DCHECK_EQ(0, frame_access_state()->sp_delta()); -+ DCHECK(caller_registers_saved_); -+ caller_registers_saved_ = false; -+ break; -+ } -+ case kArchPrepareTailCall: -+ AssemblePrepareTailCall(); -+ break; -+ case kArchCallCFunction: { -+ int const num_parameters = MiscField::decode(instr->opcode()); -+ Label start_call; -+ bool isWasmCapiFunction = -+ linkage()->GetIncomingDescriptor()->IsWasmCapiFunction(); -+ // from start_call to return address. -+ // FIXME (RISC_V): is the same number of instructions generated from -+ // &start_call to after __CallCFunction()? This code seems quite brittle. -+ // Better to use label and PC-relative addressing to generate the return -+ // address -+ int offset = __ root_array_available() ? 64 : 72; -+#if V8_HOST_ARCH_RISCV64 -+ if (__ emit_debug_code()) { -+ offset += 16; -+ } -+#endif -+ if (isWasmCapiFunction) { -+ // Put the return address in a stack slot. -+ __ bind(&start_call); -+ __ auipc(kScratchReg, 0); -+ __ Add64(kScratchReg, kScratchReg, offset); -+ __ Sd(kScratchReg, -+ MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset)); -+ } -+ if (instr->InputAt(0)->IsImmediate()) { -+ ExternalReference ref = i.InputExternalReference(0); -+ __ CallCFunction(ref, num_parameters); -+ } else { -+ Register func = i.InputRegister(0); -+ __ CallCFunction(func, num_parameters); -+ } -+ if (isWasmCapiFunction) { -+ CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call)); -+ RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt); -+ } -+ -+ frame_access_state()->SetFrameAccessToDefault(); -+ // Ideally, we should decrement SP delta to match the change of stack -+ // pointer in CallCFunction. However, for certain architectures (e.g. -+ // ARM), there may be more strict alignment requirement, causing old SP -+ // to be saved on the stack. In those cases, we can not calculate the SP -+ // delta statically. -+ frame_access_state()->ClearSPDelta(); -+ if (caller_registers_saved_) { -+ // Need to re-sync SP delta introduced in kArchSaveCallerRegisters. -+ // Here, we assume the sequence to be: -+ // kArchSaveCallerRegisters; -+ // kArchCallCFunction; -+ // kArchRestoreCallerRegisters; -+ int bytes = -+ __ RequiredStackSizeForCallerSaved(fp_mode_, kReturnRegister0); -+ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); -+ } -+ break; -+ } -+ case kArchJmp: -+ AssembleArchJump(i.InputRpo(0)); -+ break; -+ case kArchBinarySearchSwitch: -+ AssembleArchBinarySearchSwitch(instr); -+ break; -+ case kArchTableSwitch: -+ AssembleArchTableSwitch(instr); -+ break; -+ case kArchAbortCSAAssert: -+ DCHECK(i.InputRegister(0) == a0); -+ { -+ // We don't actually want to generate a pile of code for this, so just -+ // claim there is a stack frame, without generating one. -+ FrameScope scope(tasm(), StackFrame::NONE); -+ __ Call( -+ isolate()->builtins()->builtin_handle(Builtins::kAbortCSAAssert), -+ RelocInfo::CODE_TARGET); -+ } -+ __ stop(); -+ break; -+ case kArchDebugBreak: -+ __ DebugBreak(); -+ break; -+ case kArchComment: -+ __ RecordComment(reinterpret_cast(i.InputInt64(0))); -+ break; -+ case kArchNop: -+ case kArchThrowTerminator: -+ // don't emit code for nops. -+ break; -+ case kArchDeoptimize: { -+ DeoptimizationExit* exit = -+ BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); -+ CodeGenResult result = AssembleDeoptimizerCall(exit); -+ if (result != kSuccess) return result; -+ break; -+ } -+ case kArchRet: -+ AssembleReturn(instr->InputAt(0)); -+ break; -+ case kArchStackPointerGreaterThan: -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kArchStackCheckOffset: -+ __ Move(i.OutputRegister(), Smi::FromInt(GetStackCheckOffset())); -+ break; -+ case kArchFramePointer: -+ __ Move(i.OutputRegister(), fp); -+ break; -+ case kArchParentFramePointer: -+ if (frame_access_state()->has_frame()) { -+ __ Ld(i.OutputRegister(), MemOperand(fp, 0)); -+ } else { -+ __ Move(i.OutputRegister(), fp); -+ } -+ break; -+ case kArchTruncateDoubleToI: -+ __ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(), -+ i.InputDoubleRegister(0), DetermineStubCallMode()); -+ break; -+ case kArchStoreWithWriteBarrier: { -+ RecordWriteMode mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ Register object = i.InputRegister(0); -+ Register index = i.InputRegister(1); -+ Register value = i.InputRegister(2); -+ Register scratch0 = i.TempRegister(0); -+ Register scratch1 = i.TempRegister(1); -+ auto ool = zone()->New(this, object, index, value, -+ scratch0, scratch1, mode, -+ DetermineStubCallMode()); -+ __ Add64(kScratchReg, object, index); -+ __ Sd(value, MemOperand(kScratchReg)); -+ __ CheckPageFlag(object, scratch0, -+ MemoryChunk::kPointersFromHereAreInterestingMask, ne, -+ ool->entry()); -+ __ bind(ool->exit()); -+ break; -+ } -+ case kArchStackSlot: { -+ FrameOffset offset = -+ frame_access_state()->GetFrameOffset(i.InputInt32(0)); -+ Register base_reg = offset.from_stack_pointer() ? sp : fp; -+ __ Add64(i.OutputRegister(), base_reg, Operand(offset.offset())); -+ int alignment = i.InputInt32(1); -+ DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || -+ alignment == 16); -+ if (FLAG_debug_code && alignment > 0) { -+ // Verify that the output_register is properly aligned -+ __ And(kScratchReg, i.OutputRegister(), -+ Operand(kSystemPointerSize - 1)); -+ __ Assert(eq, AbortReason::kAllocationIsNotDoubleAligned, kScratchReg, -+ Operand(zero_reg)); -+ } -+ if (alignment == 2 * kSystemPointerSize) { -+ Label done; -+ __ Add64(kScratchReg, base_reg, Operand(offset.offset())); -+ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); -+ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); -+ __ Add64(i.OutputRegister(), i.OutputRegister(), kSystemPointerSize); -+ __ bind(&done); -+ } else if (alignment > 2 * kSystemPointerSize) { -+ Label done; -+ __ Add64(kScratchReg, base_reg, Operand(offset.offset())); -+ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); -+ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); -+ __ li(kScratchReg2, alignment); -+ __ Sub64(kScratchReg2, kScratchReg2, Operand(kScratchReg)); -+ __ Add64(i.OutputRegister(), i.OutputRegister(), kScratchReg2); -+ __ bind(&done); -+ } -+ -+ break; -+ } -+ case kArchWordPoisonOnSpeculation: -+ __ And(i.OutputRegister(), i.InputRegister(0), -+ kSpeculationPoisonRegister); -+ break; -+ case kIeee754Float64Acos: -+ ASSEMBLE_IEEE754_UNOP(acos); -+ break; -+ case kIeee754Float64Acosh: -+ ASSEMBLE_IEEE754_UNOP(acosh); -+ break; -+ case kIeee754Float64Asin: -+ ASSEMBLE_IEEE754_UNOP(asin); -+ break; -+ case kIeee754Float64Asinh: -+ ASSEMBLE_IEEE754_UNOP(asinh); -+ break; -+ case kIeee754Float64Atan: -+ ASSEMBLE_IEEE754_UNOP(atan); -+ break; -+ case kIeee754Float64Atanh: -+ ASSEMBLE_IEEE754_UNOP(atanh); -+ break; -+ case kIeee754Float64Atan2: -+ ASSEMBLE_IEEE754_BINOP(atan2); -+ break; -+ case kIeee754Float64Cos: -+ ASSEMBLE_IEEE754_UNOP(cos); -+ break; -+ case kIeee754Float64Cosh: -+ ASSEMBLE_IEEE754_UNOP(cosh); -+ break; -+ case kIeee754Float64Cbrt: -+ ASSEMBLE_IEEE754_UNOP(cbrt); -+ break; -+ case kIeee754Float64Exp: -+ ASSEMBLE_IEEE754_UNOP(exp); -+ break; -+ case kIeee754Float64Expm1: -+ ASSEMBLE_IEEE754_UNOP(expm1); -+ break; -+ case kIeee754Float64Log: -+ ASSEMBLE_IEEE754_UNOP(log); -+ break; -+ case kIeee754Float64Log1p: -+ ASSEMBLE_IEEE754_UNOP(log1p); -+ break; -+ case kIeee754Float64Log2: -+ ASSEMBLE_IEEE754_UNOP(log2); -+ break; -+ case kIeee754Float64Log10: -+ ASSEMBLE_IEEE754_UNOP(log10); -+ break; -+ case kIeee754Float64Pow: -+ ASSEMBLE_IEEE754_BINOP(pow); -+ break; -+ case kIeee754Float64Sin: -+ ASSEMBLE_IEEE754_UNOP(sin); -+ break; -+ case kIeee754Float64Sinh: -+ ASSEMBLE_IEEE754_UNOP(sinh); -+ break; -+ case kIeee754Float64Tan: -+ ASSEMBLE_IEEE754_UNOP(tan); -+ break; -+ case kIeee754Float64Tanh: -+ ASSEMBLE_IEEE754_UNOP(tanh); -+ break; -+ case kRiscvAdd32: -+ __ Add32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvAdd64: -+ __ Add64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvAddOvf64: -+ __ AddOverflow64(i.OutputRegister(), i.InputRegister(0), -+ i.InputOperand(1), kScratchReg); -+ break; -+ case kRiscvSub32: -+ __ Sub32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvSub64: -+ __ Sub64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvSubOvf64: -+ __ SubOverflow64(i.OutputRegister(), i.InputRegister(0), -+ i.InputOperand(1), kScratchReg); -+ break; -+ case kRiscvMul32: -+ __ Mul32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvMulOvf32: -+ __ MulOverflow32(i.OutputRegister(), i.InputRegister(0), -+ i.InputOperand(1), kScratchReg); -+ break; -+ case kRiscvMulHigh32: -+ __ Mulh32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvMulHighU32: -+ __ Mulhu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), -+ kScratchReg, kScratchReg2); -+ break; -+ case kRiscvMulHigh64: -+ __ Mulh64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvDiv32: { -+ __ Div32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ // Set ouput to zero if divisor == 0 -+ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); -+ break; -+ } -+ case kRiscvDivU32: { -+ __ Divu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ // Set ouput to zero if divisor == 0 -+ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); -+ break; -+ } -+ case kRiscvMod32: -+ __ Mod32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvModU32: -+ __ Modu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvMul64: -+ __ Mul64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvDiv64: { -+ __ Div64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ // Set ouput to zero if divisor == 0 -+ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); -+ break; -+ } -+ case kRiscvDivU64: { -+ __ Divu64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ // Set ouput to zero if divisor == 0 -+ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); -+ break; -+ } -+ case kRiscvMod64: -+ __ Mod64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvModU64: -+ __ Modu64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvAnd: -+ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvAnd32: -+ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kRiscvOr: -+ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvOr32: -+ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kRiscvNor: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ } else { -+ DCHECK_EQ(0, i.InputOperand(1).immediate()); -+ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); -+ } -+ break; -+ case kRiscvNor32: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); -+ } else { -+ DCHECK_EQ(0, i.InputOperand(1).immediate()); -+ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); -+ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); -+ } -+ break; -+ case kRiscvXor: -+ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvXor32: -+ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); -+ break; -+ case kRiscvClz32: -+ __ Clz32(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvClz64: -+ __ Clz64(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvCtz32: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Ctz32(dst, src); -+ } break; -+ case kRiscvCtz64: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Ctz64(dst, src); -+ } break; -+ case kRiscvPopcnt32: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Popcnt32(dst, src); -+ } break; -+ case kRiscvPopcnt64: { -+ Register src = i.InputRegister(0); -+ Register dst = i.OutputRegister(); -+ __ Popcnt64(dst, src); -+ } break; -+ case kRiscvShl32: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Sll32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ Sll32(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kRiscvShr32: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Srl32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ Srl32(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kRiscvSar32: -+ if (instr->InputAt(1)->IsRegister()) { -+ __ Sra32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); -+ } else { -+ int64_t imm = i.InputOperand(1).immediate(); -+ __ Sra32(i.OutputRegister(), i.InputRegister(0), -+ static_cast(imm)); -+ } -+ break; -+ case kRiscvZeroExtendWord: { -+ __ ZeroExtendWord(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvSignExtendWord: { -+ __ SignExtendWord(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvShl64: -+ __ Sll64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvShr64: -+ __ Srl64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvSar64: -+ __ Sra64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvRor32: -+ __ Ror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvRor64: -+ __ Dror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); -+ break; -+ case kRiscvTst: -+ __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kRiscvCmp: -+ // Pseudo-instruction used for cmp/branch. No opcode emitted here. -+ break; -+ case kRiscvMov: -+ // TODO(plind): Should we combine mov/li like this, or use separate instr? -+ // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType -+ if (HasRegisterInput(instr, 0)) { -+ __ Move(i.OutputRegister(), i.InputRegister(0)); -+ } else { -+ __ li(i.OutputRegister(), i.InputOperand(0)); -+ } -+ break; -+ -+ case kRiscvCmpS: { -+ FPURegister left = i.InputOrZeroSingleRegister(0); -+ FPURegister right = i.InputOrZeroSingleRegister(1); -+ bool predicate; -+ FPUCondition cc = -+ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); -+ -+ if ((left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsSingleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); -+ } -+ // compare result set to kScratchReg -+ __ CompareF32(kScratchReg, cc, left, right); -+ } break; -+ case kRiscvAddS: -+ // TODO(plind): add special case: combine mult & add. -+ __ fadd_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvSubS: -+ __ fsub_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvMulS: -+ // TODO(plind): add special case: right op is -1.0, see arm port. -+ __ fmul_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvDivS: -+ __ fdiv_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvModS: { -+ // TODO(bmeurer): We should really get rid of this special instruction, -+ // and generate a CallAddress instruction instead. -+ FrameScope scope(tasm(), StackFrame::MANUAL); -+ __ PrepareCallCFunction(0, 2, kScratchReg); -+ __ MovToFloatParameters(i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ // TODO(balazs.kilvady): implement mod_two_floats_operation(isolate()) -+ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); -+ // Move the result in the double result register. -+ __ MovFromFloatResult(i.OutputSingleRegister()); -+ break; -+ } -+ case kRiscvAbsS: -+ __ fabs_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kRiscvNegS: -+ __ Neg_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kRiscvSqrtS: { -+ __ fsqrt_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kRiscvMaxS: -+ __ fmax_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvMinS: -+ __ fmin_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvCmpD: { -+ FPURegister left = i.InputOrZeroDoubleRegister(0); -+ FPURegister right = i.InputOrZeroDoubleRegister(1); -+ bool predicate; -+ FPUCondition cc = -+ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); -+ if ((left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsDoubleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0); -+ } -+ // compare result set to kScratchReg -+ __ CompareF64(kScratchReg, cc, left, right); -+ } break; -+ case kRiscvAddD: -+ // TODO(plind): add special case: combine mult & add. -+ __ fadd_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvSubD: -+ __ fsub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvMulD: -+ // TODO(plind): add special case: right op is -1.0, see arm port. -+ __ fmul_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvDivD: -+ __ fdiv_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvModD: { -+ // TODO(bmeurer): We should really get rid of this special instruction, -+ // and generate a CallAddress instruction instead. -+ FrameScope scope(tasm(), StackFrame::MANUAL); -+ __ PrepareCallCFunction(0, 2, kScratchReg); -+ __ MovToFloatParameters(i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); -+ // Move the result in the double result register. -+ __ MovFromFloatResult(i.OutputDoubleRegister()); -+ break; -+ } -+ case kRiscvAbsD: -+ __ fabs_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvNegD: -+ __ Neg_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvSqrtD: { -+ __ fsqrt_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ } -+ case kRiscvMaxD: -+ __ fmax_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvMinD: -+ __ fmin_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ i.InputDoubleRegister(1)); -+ break; -+ case kRiscvFloat64RoundDown: { -+ __ Floor_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat32RoundDown: { -+ __ Floor_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat64RoundTruncate: { -+ __ Trunc_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat32RoundTruncate: { -+ __ Trunc_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat64RoundUp: { -+ __ Ceil_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat32RoundUp: { -+ __ Ceil_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat64RoundTiesEven: { -+ __ Round_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat32RoundTiesEven: { -+ __ Round_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ kScratchDoubleReg); -+ break; -+ } -+ case kRiscvFloat32Max: { -+ __ Float32Max(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ i.InputSingleRegister(1)); -+ break; -+ } -+ case kRiscvFloat64Max: { -+ __ Float64Max(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ i.InputSingleRegister(1)); -+ break; -+ } -+ case kRiscvFloat32Min: { -+ __ Float32Min(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ i.InputSingleRegister(1)); -+ break; -+ } -+ case kRiscvFloat64Min: { -+ __ Float64Min(i.OutputSingleRegister(), i.InputSingleRegister(0), -+ i.InputSingleRegister(1)); -+ break; -+ } -+ case kRiscvFloat64SilenceNaN: -+ __ FPUCanonicalizeNaN(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvCvtSD: -+ __ fcvt_s_d(i.OutputSingleRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvCvtDS: -+ __ fcvt_d_s(i.OutputDoubleRegister(), i.InputSingleRegister(0)); -+ break; -+ case kRiscvCvtDW: { -+ __ fcvt_d_w(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtSW: { -+ __ fcvt_s_w(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtSUw: { -+ __ Cvt_s_uw(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtSL: { -+ __ fcvt_s_l(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtDL: { -+ __ fcvt_d_l(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtDUw: { -+ __ Cvt_d_uw(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtDUl: { -+ __ Cvt_d_ul(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvCvtSUl: { -+ __ Cvt_s_ul(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ } -+ case kRiscvFloorWD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Floor_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvCeilWD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Ceil_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvRoundWD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Round_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncWD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvFloorWS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Floor_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvCeilWS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Ceil_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvRoundWS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Round_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncWS: { -+ Label done; -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ -+ // On RISCV, if the input value exceeds INT32_MAX, the result of fcvt -+ // is INT32_MAX. Note that, since INT32_MAX means the lower 31-bits are -+ // all 1s, INT32_MAX cannot be represented precisely as a float, so an -+ // fcvt result of INT32_MAX always indicate overflow. -+ // -+ // In wasm_compiler, to detect overflow in converting a FP value, fval, to -+ // integer, V8 checks whether I2F(F2I(fval)) equals fval. However, if fval -+ // == INT32_MAX+1, the value of I2F(F2I(fval)) happens to be fval. So, -+ // INT32_MAX is not a good value to indicate overflow. Instead, we will -+ // use INT32_MIN as the converted result of an out-of-range FP value, -+ // exploiting the fact that INT32_MAX+1 is INT32_MIN. -+ // -+ // If the result of conversion overflow, the result will be set to -+ // INT32_MIN. Here we detect overflow by testing whether output + 1 < -+ // output (i.e., kScratchReg < output) -+ __ Add32(kScratchReg, i.OutputRegister(), 1); -+ __ Branch(&done, lt, i.OutputRegister(), Operand(kScratchReg)); -+ __ Move(i.OutputRegister(), kScratchReg); -+ __ bind(&done); -+ break; -+ } -+ case kRiscvTruncLS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_l_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncLD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_l_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncUwD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_uw_d(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncUwS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_uw_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ -+ // On RISCV, if the input value exceeds UINT32_MAX, the result of fcvt -+ // is UINT32_MAX. Note that, since UINT32_MAX means all 32-bits are 1s, -+ // UINT32_MAX cannot be represented precisely as float, so an fcvt result -+ // of UINT32_MAX always indicates overflow. -+ // -+ // In wasm_compiler.cc, to detect overflow in converting a FP value, fval, -+ // to integer, V8 checks whether I2F(F2I(fval)) equals fval. However, if -+ // fval == UINT32_MAX+1, the value of I2F(F2I(fval)) happens to be fval. -+ // So, UINT32_MAX is not a good value to indicate overflow. Instead, we -+ // will use 0 as the converted result of an out-of-range FP value, -+ // exploiting the fact that UINT32_MAX+1 is 0. -+ __ Add32(kScratchReg, i.OutputRegister(), 1); -+ // Set ouput to zero if result overflows (i.e., UINT32_MAX) -+ __ LoadZeroIfConditionZero(i.OutputRegister(), kScratchReg); -+ break; -+ } -+ case kRiscvTruncUlS: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_ul_s(i.OutputRegister(), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvTruncUlD: { -+ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; -+ __ Trunc_ul_d(i.OutputRegister(0), i.InputDoubleRegister(0), result); -+ break; -+ } -+ case kRiscvBitcastDL: -+ __ fmv_x_d(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvBitcastLD: -+ __ fmv_d_x(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvBitcastInt32ToFloat32: -+ __ fmv_w_x(i.OutputDoubleRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvBitcastFloat32ToInt32: -+ __ fmv_x_w(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvFloat64ExtractLowWord32: -+ __ ExtractLowWordFromF64(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvFloat64ExtractHighWord32: -+ __ ExtractHighWordFromF64(i.OutputRegister(), i.InputDoubleRegister(0)); -+ break; -+ case kRiscvFloat64InsertLowWord32: -+ __ InsertLowWordF64(i.OutputDoubleRegister(), i.InputRegister(1)); -+ break; -+ case kRiscvFloat64InsertHighWord32: -+ __ InsertHighWordF64(i.OutputDoubleRegister(), i.InputRegister(1)); -+ break; -+ // ... more basic instructions ... -+ -+ case kRiscvSignExtendByte: -+ __ SignExtendByte(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvSignExtendShort: -+ __ SignExtendShort(i.OutputRegister(), i.InputRegister(0)); -+ break; -+ case kRiscvLbu: -+ __ Lbu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvLb: -+ __ Lb(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvSb: -+ __ Sb(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvLhu: -+ __ Lhu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvUlhu: -+ __ Ulhu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvLh: -+ __ Lh(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvUlh: -+ __ Ulh(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvSh: -+ __ Sh(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvUsh: -+ __ Ush(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvLw: -+ __ Lw(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvUlw: -+ __ Ulw(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvLwu: -+ __ Lwu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvUlwu: -+ __ Ulwu(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvLd: -+ __ Ld(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvUld: -+ __ Uld(i.OutputRegister(), i.MemoryOperand()); -+ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); -+ break; -+ case kRiscvSw: -+ __ Sw(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvUsw: -+ __ Usw(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvSd: -+ __ Sd(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvUsd: -+ __ Usd(i.InputOrZeroRegister(2), i.MemoryOperand()); -+ break; -+ case kRiscvLoadFloat: { -+ __ LoadFloat(i.OutputSingleRegister(), i.MemoryOperand()); -+ break; -+ } -+ case kRiscvULoadFloat: { -+ __ ULoadFloat(i.OutputSingleRegister(), i.MemoryOperand(), kScratchReg); -+ break; -+ } -+ case kRiscvStoreFloat: { -+ size_t index = 0; -+ MemOperand operand = i.MemoryOperand(&index); -+ FPURegister ft = i.InputOrZeroSingleRegister(index); -+ if (ft == kDoubleRegZero && !__ IsSingleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); -+ } -+ __ StoreFloat(ft, operand); -+ break; -+ } -+ case kRiscvUStoreFloat: { -+ size_t index = 0; -+ MemOperand operand = i.MemoryOperand(&index); -+ FPURegister ft = i.InputOrZeroSingleRegister(index); -+ if (ft == kDoubleRegZero && !__ IsSingleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); -+ } -+ __ UStoreFloat(ft, operand, kScratchReg); -+ break; -+ } -+ case kRiscvLoadDouble: -+ __ LoadDouble(i.OutputDoubleRegister(), i.MemoryOperand()); -+ break; -+ case kRiscvULoadDouble: -+ __ ULoadDouble(i.OutputDoubleRegister(), i.MemoryOperand(), kScratchReg); -+ break; -+ case kRiscvStoreDouble: { -+ FPURegister ft = i.InputOrZeroDoubleRegister(2); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0); -+ } -+ __ StoreDouble(ft, i.MemoryOperand()); -+ break; -+ } -+ case kRiscvUStoreDouble: { -+ FPURegister ft = i.InputOrZeroDoubleRegister(2); -+ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0); -+ } -+ __ UStoreDouble(ft, i.MemoryOperand(), kScratchReg); -+ break; -+ } -+ case kRiscvSync: { -+ __ sync(); -+ break; -+ } -+ case kRiscvPush: -+ if (instr->InputAt(0)->IsFPRegister()) { -+ __ StoreDouble(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); -+ __ Sub32(sp, sp, Operand(kDoubleSize)); -+ frame_access_state()->IncreaseSPDelta(kDoubleSize / kSystemPointerSize); -+ } else { -+ __ Push(i.InputRegister(0)); -+ frame_access_state()->IncreaseSPDelta(1); -+ } -+ break; -+ case kRiscvPeek: { -+ // The incoming value is 0-based, but we need a 1-based value. -+ int reverse_slot = i.InputInt32(0) + 1; -+ int offset = -+ FrameSlotToFPOffset(frame()->GetTotalFrameSlotCount() - reverse_slot); -+ if (instr->OutputAt(0)->IsFPRegister()) { -+ LocationOperand* op = LocationOperand::cast(instr->OutputAt(0)); -+ if (op->representation() == MachineRepresentation::kFloat64) { -+ __ LoadDouble(i.OutputDoubleRegister(), MemOperand(fp, offset)); -+ } else { -+ DCHECK_EQ(op->representation(), MachineRepresentation::kFloat32); -+ __ LoadFloat( -+ i.OutputSingleRegister(0), -+ MemOperand(fp, offset + kLessSignificantWordInDoublewordOffset)); -+ } -+ } else { -+ __ Ld(i.OutputRegister(0), MemOperand(fp, offset)); -+ } -+ break; -+ } -+ case kRiscvStackClaim: { -+ __ Sub64(sp, sp, Operand(i.InputInt32(0))); -+ frame_access_state()->IncreaseSPDelta(i.InputInt32(0) / -+ kSystemPointerSize); -+ break; -+ } -+ case kRiscvStoreToStackSlot: { -+ if (instr->InputAt(0)->IsFPRegister()) { -+ if (instr->InputAt(0)->IsSimd128Register()) { -+ UNREACHABLE(); -+ } else { -+ __ StoreDouble(i.InputDoubleRegister(0), -+ MemOperand(sp, i.InputInt32(1))); -+ } -+ } else { -+ __ Sd(i.InputRegister(0), MemOperand(sp, i.InputInt32(1))); -+ } -+ break; -+ } -+ case kRiscvByteSwap64: { -+ __ ByteSwap(i.OutputRegister(0), i.InputRegister(0), 8); -+ break; -+ } -+ case kRiscvByteSwap32: { -+ __ ByteSwap(i.OutputRegister(0), i.InputRegister(0), 4); -+ break; -+ } -+ case kWord32AtomicLoadInt8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lb); -+ break; -+ case kWord32AtomicLoadUint8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lbu); -+ break; -+ case kWord32AtomicLoadInt16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lh); -+ break; -+ case kWord32AtomicLoadUint16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lhu); -+ break; -+ case kWord32AtomicLoadWord32: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lw); -+ break; -+ case kRiscvWord64AtomicLoadUint8: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lbu); -+ break; -+ case kRiscvWord64AtomicLoadUint16: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lhu); -+ break; -+ case kRiscvWord64AtomicLoadUint32: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lwu); -+ break; -+ case kRiscvWord64AtomicLoadUint64: -+ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld); -+ break; -+ case kWord32AtomicStoreWord8: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sb); -+ break; -+ case kWord32AtomicStoreWord16: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sh); -+ break; -+ case kWord32AtomicStoreWord32: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sw); -+ break; -+ case kRiscvWord64AtomicStoreWord8: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sb); -+ break; -+ case kRiscvWord64AtomicStoreWord16: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sh); -+ break; -+ case kRiscvWord64AtomicStoreWord32: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sw); -+ break; -+ case kRiscvWord64AtomicStoreWord64: -+ ASSEMBLE_ATOMIC_STORE_INTEGER(Sd); -+ break; -+ case kWord32AtomicExchangeInt8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 8, 32); -+ break; -+ case kWord32AtomicExchangeUint8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 8, 32); -+ break; -+ case kWord32AtomicExchangeInt16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 16, 32); -+ break; -+ case kWord32AtomicExchangeUint16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 16, 32); -+ break; -+ case kWord32AtomicExchangeWord32: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(Ll, Sc); -+ break; -+ case kRiscvWord64AtomicExchangeUint8: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 8, 64); -+ break; -+ case kRiscvWord64AtomicExchangeUint16: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 16, 64); -+ break; -+ case kRiscvWord64AtomicExchangeUint32: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 32, 64); -+ break; -+ case kRiscvWord64AtomicExchangeUint64: -+ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(Lld, Scd); -+ break; -+ case kWord32AtomicCompareExchangeInt8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 8, 32); -+ break; -+ case kWord32AtomicCompareExchangeUint8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 8, 32); -+ break; -+ case kWord32AtomicCompareExchangeInt16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 16, 32); -+ break; -+ case kWord32AtomicCompareExchangeUint16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 16, 32); -+ break; -+ case kWord32AtomicCompareExchangeWord32: -+ __ Sll32(i.InputRegister(2), i.InputRegister(2), 0); -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll, Sc); -+ break; -+ case kRiscvWord64AtomicCompareExchangeUint8: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 8, 64); -+ break; -+ case kRiscvWord64AtomicCompareExchangeUint16: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 16, 64); -+ break; -+ case kRiscvWord64AtomicCompareExchangeUint32: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 32, 64); -+ break; -+ case kRiscvWord64AtomicCompareExchangeUint64: -+ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Lld, Scd); -+ break; -+#define ATOMIC_BINOP_CASE(op, inst) \ -+ case kWord32Atomic##op##Int8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, true, 8, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Uint8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, false, 8, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Int16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, true, 16, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Uint16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, false, 16, inst, 32); \ -+ break; \ -+ case kWord32Atomic##op##Word32: \ -+ ASSEMBLE_ATOMIC_BINOP(Ll, Sc, inst); \ -+ break; -+ ATOMIC_BINOP_CASE(Add, Add32) -+ ATOMIC_BINOP_CASE(Sub, Sub32) -+ ATOMIC_BINOP_CASE(And, And) -+ ATOMIC_BINOP_CASE(Or, Or) -+ ATOMIC_BINOP_CASE(Xor, Xor) -+#undef ATOMIC_BINOP_CASE -+#define ATOMIC_BINOP_CASE(op, inst) \ -+ case kRiscvWord64Atomic##op##Uint8: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 8, inst, 64); \ -+ break; \ -+ case kRiscvWord64Atomic##op##Uint16: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 16, inst, 64); \ -+ break; \ -+ case kRiscvWord64Atomic##op##Uint32: \ -+ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 32, inst, 64); \ -+ break; \ -+ case kRiscvWord64Atomic##op##Uint64: \ -+ ASSEMBLE_ATOMIC_BINOP(Lld, Scd, inst); \ -+ break; -+ ATOMIC_BINOP_CASE(Add, Add64) -+ ATOMIC_BINOP_CASE(Sub, Sub64) -+ ATOMIC_BINOP_CASE(And, And) -+ ATOMIC_BINOP_CASE(Or, Or) -+ ATOMIC_BINOP_CASE(Xor, Xor) -+#undef ATOMIC_BINOP_CASE -+ case kRiscvAssertEqual: -+ __ Assert(eq, static_cast(i.InputOperand(2).immediate()), -+ i.InputRegister(0), Operand(i.InputRegister(1))); -+ break; -+ -+ default: -+ UNIMPLEMENTED(); -+ } -+ return kSuccess; -+} // NOLINT(readability/fn_size) -+ -+#define UNSUPPORTED_COND(opcode, condition) \ -+ StdoutStream{} << "Unsupported " << #opcode << " condition: \"" << condition \ -+ << "\""; \ -+ UNIMPLEMENTED(); -+ -+void AssembleBranchToLabels(CodeGenerator* gen, TurboAssembler* tasm, -+ Instruction* instr, FlagsCondition condition, -+ Label* tlabel, Label* flabel, bool fallthru) { -+#undef __ -+#define __ tasm-> -+ RiscvOperandConverter i(gen, instr); -+ -+ Condition cc = kNoCondition; -+ // RISC-V does not have condition code flags, so compare and branch are -+ // implemented differently than on the other arch's. The compare operations -+ // emit riscv64 pseudo-instructions, which are handled here by branch -+ // instructions that do the actual comparison. Essential that the input -+ // registers to compare pseudo-op are not modified before this branch op, as -+ // they are tested here. -+ -+ if (instr->arch_opcode() == kRiscvTst) { -+ cc = FlagsConditionToConditionTst(condition); -+ __ Branch(tlabel, cc, kScratchReg, Operand(zero_reg)); -+ } else if (instr->arch_opcode() == kRiscvAdd64 || -+ instr->arch_opcode() == kRiscvSub64) { -+ cc = FlagsConditionToConditionOvf(condition); -+ __ Sra64(kScratchReg, i.OutputRegister(), 32); -+ __ Sra64(kScratchReg2, i.OutputRegister(), 31); -+ __ Branch(tlabel, cc, kScratchReg2, Operand(kScratchReg)); -+ } else if (instr->arch_opcode() == kRiscvAddOvf64 || -+ instr->arch_opcode() == kRiscvSubOvf64) { -+ switch (condition) { -+ // Overflow occurs if overflow register is negative -+ case kOverflow: -+ __ Branch(tlabel, lt, kScratchReg, Operand(zero_reg)); -+ break; -+ case kNotOverflow: -+ __ Branch(tlabel, ge, kScratchReg, Operand(zero_reg)); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ break; -+ } -+ } else if (instr->arch_opcode() == kRiscvMulOvf32) { -+ // Overflow occurs if overflow register is not zero -+ switch (condition) { -+ case kOverflow: -+ __ Branch(tlabel, ne, kScratchReg, Operand(zero_reg)); -+ break; -+ case kNotOverflow: -+ __ Branch(tlabel, eq, kScratchReg, Operand(zero_reg)); -+ break; -+ default: -+ UNSUPPORTED_COND(kRiscvMulOvf32, condition); -+ break; -+ } -+ } else if (instr->arch_opcode() == kRiscvCmp) { -+ cc = FlagsConditionToConditionCmp(condition); -+ __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); -+ } else if (instr->arch_opcode() == kArchStackPointerGreaterThan) { -+ cc = FlagsConditionToConditionCmp(condition); -+ Register lhs_register = sp; -+ uint32_t offset; -+ if (gen->ShouldApplyOffsetToStackCheck(instr, &offset)) { -+ lhs_register = i.TempRegister(0); -+ __ Sub64(lhs_register, sp, offset); -+ } -+ __ Branch(tlabel, cc, lhs_register, Operand(i.InputRegister(0))); -+ } else if (instr->arch_opcode() == kRiscvCmpS || -+ instr->arch_opcode() == kRiscvCmpD) { -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ // floating-point compare result is set in kScratchReg -+ if (predicate) { -+ __ BranchTrueF(kScratchReg, tlabel); -+ } else { -+ __ BranchFalseF(kScratchReg, tlabel); -+ } -+ } else { -+ PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", -+ instr->arch_opcode()); -+ UNIMPLEMENTED(); -+ } -+ if (!fallthru) __ Branch(flabel); // no fallthru to flabel. -+#undef __ -+#define __ tasm()-> -+} -+ -+// Assembles branches after an instruction. -+void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { -+ Label* tlabel = branch->true_label; -+ Label* flabel = branch->false_label; -+ -+ AssembleBranchToLabels(this, tasm(), instr, branch->condition, tlabel, flabel, -+ branch->fallthru); -+} -+ -+void CodeGenerator::AssembleBranchPoisoning(FlagsCondition condition, -+ Instruction* instr) { -+ // TODO(jarin) Handle float comparisons (kUnordered[Not]Equal). -+ if (condition == kUnorderedEqual || condition == kUnorderedNotEqual) { -+ return; -+ } -+ -+ RiscvOperandConverter i(this, instr); -+ condition = NegateFlagsCondition(condition); -+ -+ switch (instr->arch_opcode()) { -+ case kRiscvCmp: { -+ __ CompareI(kScratchReg, i.InputRegister(0), i.InputOperand(1), -+ FlagsConditionToConditionCmp(condition)); -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, kScratchReg); -+ } -+ return; -+ case kRiscvTst: { -+ switch (condition) { -+ case kEqual: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); -+ break; -+ case kNotEqual: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ return; -+ case kRiscvAdd64: -+ case kRiscvSub64: { -+ // Check for overflow creates 1 or 0 for result. -+ __ Srl64(kScratchReg, i.OutputRegister(), 63); -+ __ Srl32(kScratchReg2, i.OutputRegister(), 31); -+ __ Xor(kScratchReg2, kScratchReg, kScratchReg2); -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg2); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kRiscvAddOvf64: -+ case kRiscvSubOvf64: { -+ // Overflow occurs if overflow register is negative -+ __ Slt(kScratchReg2, kScratchReg, zero_reg); -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg2); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kRiscvMulOvf32: { -+ // Overflow occurs if overflow register is not zero -+ switch (condition) { -+ case kOverflow: -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, -+ kScratchReg); -+ break; -+ case kNotOverflow: -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); -+ break; -+ default: -+ UNSUPPORTED_COND(instr->arch_opcode(), condition); -+ } -+ } -+ return; -+ case kRiscvCmpS: -+ case kRiscvCmpD: { -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ if (predicate) { -+ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, kScratchReg); -+ } else { -+ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); -+ } -+ } -+ return; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+#undef UNSUPPORTED_COND -+ -+void CodeGenerator::AssembleArchDeoptBranch(Instruction* instr, -+ BranchInfo* branch) { -+ AssembleArchBranch(instr, branch); -+} -+ -+void CodeGenerator::AssembleArchJump(RpoNumber target) { -+ if (!IsNextInAssemblyOrder(target)) __ Branch(GetLabel(target)); -+} -+ -+void CodeGenerator::AssembleArchTrap(Instruction* instr, -+ FlagsCondition condition) { -+ class OutOfLineTrap final : public OutOfLineCode { -+ public: -+ OutOfLineTrap(CodeGenerator* gen, Instruction* instr) -+ : OutOfLineCode(gen), instr_(instr), gen_(gen) {} -+ void Generate() final { -+ RiscvOperandConverter i(gen_, instr_); -+ TrapId trap_id = -+ static_cast(i.InputInt32(instr_->InputCount() - 1)); -+ GenerateCallToTrap(trap_id); -+ } -+ -+ private: -+ void GenerateCallToTrap(TrapId trap_id) { -+ if (trap_id == TrapId::kInvalid) { -+ // We cannot test calls to the runtime in cctest/test-run-wasm. -+ // Therefore we emit a call to C here instead of a call to the runtime. -+ // We use the context register as the scratch register, because we do -+ // not have a context here. -+ __ PrepareCallCFunction(0, 0, cp); -+ __ CallCFunction( -+ ExternalReference::wasm_call_trap_callback_for_testing(), 0); -+ __ LeaveFrame(StackFrame::WASM); -+ auto call_descriptor = gen_->linkage()->GetIncomingDescriptor(); -+ int pop_count = -+ static_cast(call_descriptor->StackParameterCount()); -+ pop_count += (pop_count & 1); // align -+ __ Drop(pop_count); -+ __ Ret(); -+ } else { -+ gen_->AssembleSourcePosition(instr_); -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched when the code -+ // is added to the native module and copied into wasm code space. -+ __ Call(static_cast
(trap_id), RelocInfo::WASM_STUB_CALL); -+ ReferenceMap* reference_map = -+ gen_->zone()->New(gen_->zone()); -+ gen_->RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); -+ if (FLAG_debug_code) { -+ __ stop(); -+ } -+ } -+ } -+ Instruction* instr_; -+ CodeGenerator* gen_; -+ }; -+ auto ool = zone()->New(this, instr); -+ Label* tlabel = ool->entry(); -+ AssembleBranchToLabels(this, tasm(), instr, condition, tlabel, nullptr, true); -+} -+ -+// Assembles boolean materializations after an instruction. -+void CodeGenerator::AssembleArchBoolean(Instruction* instr, -+ FlagsCondition condition) { -+ RiscvOperandConverter i(this, instr); -+ -+ // Materialize a full 32-bit 1 or 0 value. The result register is always the -+ // last output of the instruction. -+ DCHECK_NE(0u, instr->OutputCount()); -+ Register result = i.OutputRegister(instr->OutputCount() - 1); -+ Condition cc = kNoCondition; -+ // RISC-V does not have condition code flags, so compare and branch are -+ // implemented differently than on the other arch's. The compare operations -+ // emit riscv64 pseudo-instructions, which are checked and handled here. -+ -+ if (instr->arch_opcode() == kRiscvTst) { -+ cc = FlagsConditionToConditionTst(condition); -+ if (cc == eq) { -+ __ Sltu(result, kScratchReg, 1); -+ } else { -+ __ Sltu(result, zero_reg, kScratchReg); -+ } -+ return; -+ } else if (instr->arch_opcode() == kRiscvAdd64 || -+ instr->arch_opcode() == kRiscvSub64) { -+ cc = FlagsConditionToConditionOvf(condition); -+ // Check for overflow creates 1 or 0 for result. -+ __ Srl64(kScratchReg, i.OutputRegister(), 63); -+ __ Srl32(kScratchReg2, i.OutputRegister(), 31); -+ __ Xor(result, kScratchReg, kScratchReg2); -+ if (cc == eq) // Toggle result for not overflow. -+ __ Xor(result, result, 1); -+ return; -+ } else if (instr->arch_opcode() == kRiscvAddOvf64 || -+ instr->arch_opcode() == kRiscvSubOvf64) { -+ // Overflow occurs if overflow register is negative -+ __ Slt(result, kScratchReg, zero_reg); -+ } else if (instr->arch_opcode() == kRiscvMulOvf32) { -+ // Overflow occurs if overflow register is not zero -+ __ Sgtu(result, kScratchReg, zero_reg); -+ } else if (instr->arch_opcode() == kRiscvCmp) { -+ cc = FlagsConditionToConditionCmp(condition); -+ switch (cc) { -+ case eq: -+ case ne: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ if (instr->InputAt(1)->IsImmediate()) { -+ if (is_int12(-right.immediate())) { -+ if (right.immediate() == 0) { -+ if (cc == eq) { -+ __ Sltu(result, left, 1); -+ } else { -+ __ Sltu(result, zero_reg, left); -+ } -+ } else { -+ __ Add64(result, left, Operand(-right.immediate())); -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } else { -+ if (is_uint12(right.immediate())) { -+ __ Xor(result, left, right); -+ } else { -+ __ li(kScratchReg, right); -+ __ Xor(result, left, kScratchReg); -+ } -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } else { -+ __ Xor(result, left, right); -+ if (cc == eq) { -+ __ Sltu(result, result, 1); -+ } else { -+ __ Sltu(result, zero_reg, result); -+ } -+ } -+ } break; -+ case lt: -+ case ge: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ __ Slt(result, left, right); -+ if (cc == ge) { -+ __ Xor(result, result, 1); -+ } -+ } break; -+ case gt: -+ case le: { -+ Register left = i.InputRegister(1); -+ Operand right = i.InputOperand(0); -+ __ Slt(result, left, right); -+ if (cc == le) { -+ __ Xor(result, result, 1); -+ } -+ } break; -+ case Uless: -+ case Ugreater_equal: { -+ Register left = i.InputRegister(0); -+ Operand right = i.InputOperand(1); -+ __ Sltu(result, left, right); -+ if (cc == Ugreater_equal) { -+ __ Xor(result, result, 1); -+ } -+ } break; -+ case Ugreater: -+ case Uless_equal: { -+ Register left = i.InputRegister(1); -+ Operand right = i.InputOperand(0); -+ __ Sltu(result, left, right); -+ if (cc == Uless_equal) { -+ __ Xor(result, result, 1); -+ } -+ } break; -+ default: -+ UNREACHABLE(); -+ } -+ return; -+ } else if (instr->arch_opcode() == kRiscvCmpD || -+ instr->arch_opcode() == kRiscvCmpS) { -+ FPURegister left = i.InputOrZeroDoubleRegister(0); -+ FPURegister right = i.InputOrZeroDoubleRegister(1); -+ if ((instr->arch_opcode() == kRiscvCmpD) && -+ (left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsDoubleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0); -+ } else if ((instr->arch_opcode() == kRiscvCmpS) && -+ (left == kDoubleRegZero || right == kDoubleRegZero) && -+ !__ IsSingleZeroRegSet()) { -+ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); -+ } -+ bool predicate; -+ FlagsConditionToConditionCmpFPU(&predicate, condition); -+ // RISCV compare returns 0 or 1, do nothing when predicate; otherwise -+ // toggle kScratchReg (i.e., 0 -> 1, 1 -> 0) -+ if (predicate) { -+ __ Move(result, kScratchReg); -+ } else { -+ __ Xor(result, kScratchReg, 1); -+ } -+ return; -+ } else { -+ PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", -+ instr->arch_opcode()); -+ TRACE_UNIMPL(); -+ UNIMPLEMENTED(); -+ } -+} -+ -+void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) { -+ RiscvOperandConverter i(this, instr); -+ Register input = i.InputRegister(0); -+ std::vector> cases; -+ for (size_t index = 2; index < instr->InputCount(); index += 2) { -+ cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))}); -+ } -+ AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(), -+ cases.data() + cases.size()); -+} -+ -+void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { -+ RiscvOperandConverter i(this, instr); -+ Register input = i.InputRegister(0); -+ size_t const case_count = instr->InputCount() - 2; -+ -+ __ Branch(GetLabel(i.InputRpo(1)), Ugreater_equal, input, -+ Operand(case_count)); -+ __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { -+ return GetLabel(i.InputRpo(index + 2)); -+ }); -+} -+ -+void CodeGenerator::FinishFrame(Frame* frame) { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ if (saves_fpu != 0) { -+ int count = base::bits::CountPopulation(saves_fpu); -+ DCHECK_EQ(kNumCalleeSavedFPU, count); -+ frame->AllocateSavedCalleeRegisterSlots(count * -+ (kDoubleSize / kSystemPointerSize)); -+ } -+ -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ if (saves != 0) { -+ int count = base::bits::CountPopulation(saves); -+ DCHECK_EQ(kNumCalleeSaved, count + 1); -+ frame->AllocateSavedCalleeRegisterSlots(count); -+ } -+} -+ -+void CodeGenerator::AssembleConstructFrame() { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ if (frame_access_state()->has_frame()) { -+ if (call_descriptor->IsCFunctionCall()) { -+ if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) { -+ __ StubPrologue(StackFrame::C_WASM_ENTRY); -+ // Reserve stack space for saving the c_entry_fp later. -+ __ Sub64(sp, sp, Operand(kSystemPointerSize)); -+ } else { -+ __ Push(ra, fp); -+ __ Move(fp, sp); -+ } -+ } else if (call_descriptor->IsJSFunctionCall()) { -+ __ Prologue(); -+ } else { -+ __ StubPrologue(info()->GetOutputStackFrameType()); -+ if (call_descriptor->IsWasmFunctionCall()) { -+ __ Push(kWasmInstanceRegister); -+ } else if (call_descriptor->IsWasmImportWrapper() || -+ call_descriptor->IsWasmCapiFunction()) { -+ // Wasm import wrappers are passed a tuple in the place of the instance. -+ // Unpack the tuple into the instance and the target callable. -+ // This must be done here in the codegen because it cannot be expressed -+ // properly in the graph. -+ __ Ld(kJSFunctionRegister, -+ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset)); -+ __ Ld(kWasmInstanceRegister, -+ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); -+ __ Push(kWasmInstanceRegister); -+ if (call_descriptor->IsWasmCapiFunction()) { -+ // Reserve space for saving the PC later. -+ __ Sub64(sp, sp, Operand(kSystemPointerSize)); -+ } -+ } -+ } -+ } -+ -+ int required_slots = -+ frame()->GetTotalFrameSlotCount() - frame()->GetFixedSlotCount(); -+ -+ if (info()->is_osr()) { -+ // TurboFan OSR-compiled functions cannot be entered directly. -+ __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); -+ -+ // Unoptimized code jumps directly to this entrypoint while the unoptimized -+ // frame is still on the stack. Optimized code uses OSR values directly from -+ // the unoptimized frame. Thus, all that needs to be done is to allocate the -+ // remaining stack slots. -+ if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); -+ osr_pc_offset_ = __ pc_offset(); -+ required_slots -= osr_helper()->UnoptimizedFrameSlots(); -+ ResetSpeculationPoison(); -+ } -+ -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ -+ if (required_slots > 0) { -+ DCHECK(frame_access_state()->has_frame()); -+ if (info()->IsWasm() && required_slots > 128) { -+ // For WebAssembly functions with big frames we have to do the stack -+ // overflow check before we construct the frame. Otherwise we may not -+ // have enough space on the stack to call the runtime for the stack -+ // overflow. -+ Label done; -+ -+ // If the frame is bigger than the stack, we throw the stack overflow -+ // exception unconditionally. Thereby we can avoid the integer overflow -+ // check in the condition code. -+ if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { -+ __ Ld( -+ kScratchReg, -+ FieldMemOperand(kWasmInstanceRegister, -+ WasmInstanceObject::kRealStackLimitAddressOffset)); -+ __ Ld(kScratchReg, MemOperand(kScratchReg)); -+ __ Add64(kScratchReg, kScratchReg, -+ Operand(required_slots * kSystemPointerSize)); -+ __ Branch(&done, uge, sp, Operand(kScratchReg)); -+ } -+ -+ __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); -+ // We come from WebAssembly, there are no references for the GC. -+ ReferenceMap* reference_map = zone()->New(zone()); -+ RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); -+ if (FLAG_debug_code) { -+ __ stop(); -+ } -+ -+ __ bind(&done); -+ } -+ } -+ -+ const int returns = frame()->GetReturnSlotCount(); -+ -+ // Skip callee-saved and return slots, which are pushed below. -+ required_slots -= base::bits::CountPopulation(saves); -+ required_slots -= base::bits::CountPopulation(saves_fpu); -+ required_slots -= returns; -+ if (required_slots > 0) { -+ __ Sub64(sp, sp, Operand(required_slots * kSystemPointerSize)); -+ } -+ -+ if (saves_fpu != 0) { -+ // Save callee-saved FPU registers. -+ __ MultiPushFPU(saves_fpu); -+ DCHECK_EQ(kNumCalleeSavedFPU, base::bits::CountPopulation(saves_fpu)); -+ } -+ -+ if (saves != 0) { -+ // Save callee-saved registers. -+ __ MultiPush(saves); -+ DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1); -+ } -+ -+ if (returns != 0) { -+ // Create space for returns. -+ __ Sub64(sp, sp, Operand(returns * kSystemPointerSize)); -+ } -+} -+ -+void CodeGenerator::AssembleReturn(InstructionOperand* pop) { -+ auto call_descriptor = linkage()->GetIncomingDescriptor(); -+ -+ const int returns = frame()->GetReturnSlotCount(); -+ if (returns != 0) { -+ __ Add64(sp, sp, Operand(returns * kSystemPointerSize)); -+ } -+ -+ // Restore GP registers. -+ const RegList saves = call_descriptor->CalleeSavedRegisters(); -+ if (saves != 0) { -+ __ MultiPop(saves); -+ } -+ -+ // Restore FPU registers. -+ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); -+ if (saves_fpu != 0) { -+ __ MultiPopFPU(saves_fpu); -+ } -+ -+ RiscvOperandConverter g(this, nullptr); -+ if (call_descriptor->IsCFunctionCall()) { -+ AssembleDeconstructFrame(); -+ } else if (frame_access_state()->has_frame()) { -+ // Canonicalize JSFunction return sites for now unless they have an variable -+ // number of stack slot pops. -+ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { -+ if (return_label_.is_bound()) { -+ __ Branch(&return_label_); -+ return; -+ } else { -+ __ bind(&return_label_); -+ AssembleDeconstructFrame(); -+ } -+ } else { -+ AssembleDeconstructFrame(); -+ } -+ } -+ int pop_count = static_cast(call_descriptor->StackParameterCount()); -+ if (pop->IsImmediate()) { -+ pop_count += g.ToConstant(pop).ToInt32(); -+ } else { -+ Register pop_reg = g.ToRegister(pop); -+ __ Sll64(pop_reg, pop_reg, kSystemPointerSizeLog2); -+ __ Add64(sp, sp, pop_reg); -+ } -+ if (pop_count != 0) { -+ __ DropAndRet(pop_count); -+ } else { -+ __ Ret(); -+ } -+} -+ -+void CodeGenerator::FinishCode() {} -+ -+void CodeGenerator::PrepareForDeoptimizationExits(int deopt_count) {} -+ -+void CodeGenerator::AssembleMove(InstructionOperand* source, -+ InstructionOperand* destination) { -+ RiscvOperandConverter g(this, nullptr); -+ // Dispatch on the source and destination operand kinds. Not all -+ // combinations are possible. -+ if (source->IsRegister()) { -+ DCHECK(destination->IsRegister() || destination->IsStackSlot()); -+ Register src = g.ToRegister(source); -+ if (destination->IsRegister()) { -+ __ Move(g.ToRegister(destination), src); -+ } else { -+ __ Sd(src, g.ToMemOperand(destination)); -+ } -+ } else if (source->IsStackSlot()) { -+ DCHECK(destination->IsRegister() || destination->IsStackSlot()); -+ MemOperand src = g.ToMemOperand(source); -+ if (destination->IsRegister()) { -+ __ Ld(g.ToRegister(destination), src); -+ } else { -+ Register temp = kScratchReg; -+ __ Ld(temp, src); -+ __ Sd(temp, g.ToMemOperand(destination)); -+ } -+ } else if (source->IsConstant()) { -+ Constant src = g.ToConstant(source); -+ if (destination->IsRegister() || destination->IsStackSlot()) { -+ Register dst = -+ destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; -+ switch (src.type()) { -+ case Constant::kInt32: -+ __ li(dst, Operand(src.ToInt32())); -+ break; -+ case Constant::kFloat32: -+ __ li(dst, Operand::EmbeddedNumber(src.ToFloat32())); -+ break; -+ case Constant::kInt64: -+ if (RelocInfo::IsWasmReference(src.rmode())) { -+ __ li(dst, Operand(src.ToInt64(), src.rmode())); -+ } else { -+ __ li(dst, Operand(src.ToInt64())); -+ } -+ break; -+ case Constant::kFloat64: -+ __ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value())); -+ break; -+ case Constant::kExternalReference: -+ __ li(dst, src.ToExternalReference()); -+ break; -+ case Constant::kDelayedStringConstant: -+ __ li(dst, src.ToDelayedStringConstant()); -+ break; -+ case Constant::kHeapObject: { -+ Handle src_object = src.ToHeapObject(); -+ RootIndex index; -+ if (IsMaterializableFromRoot(src_object, &index)) { -+ __ LoadRoot(dst, index); -+ } else { -+ __ li(dst, src_object); -+ } -+ break; -+ } -+ case Constant::kCompressedHeapObject: -+ UNREACHABLE(); -+ case Constant::kRpoNumber: -+ UNREACHABLE(); // TODO(titzer): loading RPO numbers -+ break; -+ } -+ if (destination->IsStackSlot()) __ Sd(dst, g.ToMemOperand(destination)); -+ } else if (src.type() == Constant::kFloat32) { -+ if (destination->IsFPStackSlot()) { -+ MemOperand dst = g.ToMemOperand(destination); -+ if (bit_cast(src.ToFloat32()) == 0) { -+ __ Sw(zero_reg, dst); -+ } else { -+ __ li(kScratchReg, Operand(bit_cast(src.ToFloat32()))); -+ __ Sw(kScratchReg, dst); -+ } -+ } else { -+ DCHECK(destination->IsFPRegister()); -+ FloatRegister dst = g.ToSingleRegister(destination); -+ __ LoadFPRImmediate(dst, src.ToFloat32()); -+ } -+ } else { -+ DCHECK_EQ(Constant::kFloat64, src.type()); -+ DoubleRegister dst = destination->IsFPRegister() -+ ? g.ToDoubleRegister(destination) -+ : kScratchDoubleReg; -+ __ LoadFPRImmediate(dst, src.ToFloat64().value()); -+ if (destination->IsFPStackSlot()) { -+ __ StoreDouble(dst, g.ToMemOperand(destination)); -+ } -+ } -+ } else if (source->IsFPRegister()) { -+ MachineRepresentation rep = LocationOperand::cast(source)->representation(); -+ if (rep == MachineRepresentation::kSimd128) { -+ UNIMPLEMENTED(); -+ } else { -+ FPURegister src = g.ToDoubleRegister(source); -+ if (destination->IsFPRegister()) { -+ FPURegister dst = g.ToDoubleRegister(destination); -+ __ Move(dst, src); -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ if (rep == MachineRepresentation::kFloat32) { -+ __ StoreFloat(src, g.ToMemOperand(destination)); -+ } else { -+ DCHECK_EQ(rep, MachineRepresentation::kFloat64); -+ __ StoreDouble(src, g.ToMemOperand(destination)); -+ } -+ } -+ } -+ } else if (source->IsFPStackSlot()) { -+ DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); -+ MemOperand src = g.ToMemOperand(source); -+ MachineRepresentation rep = LocationOperand::cast(source)->representation(); -+ if (rep == MachineRepresentation::kSimd128) { -+ UNIMPLEMENTED(); -+ } else { -+ if (destination->IsFPRegister()) { -+ if (rep == MachineRepresentation::kFloat32) { -+ __ LoadFloat(g.ToDoubleRegister(destination), src); -+ } else { -+ DCHECK_EQ(rep, MachineRepresentation::kFloat64); -+ __ LoadDouble(g.ToDoubleRegister(destination), src); -+ } -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ FPURegister temp = kScratchDoubleReg; -+ if (rep == MachineRepresentation::kFloat32) { -+ __ LoadFloat(temp, src); -+ __ StoreFloat(temp, g.ToMemOperand(destination)); -+ } else { -+ DCHECK_EQ(rep, MachineRepresentation::kFloat64); -+ __ LoadDouble(temp, src); -+ __ StoreDouble(temp, g.ToMemOperand(destination)); -+ } -+ } -+ } -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+void CodeGenerator::AssembleSwap(InstructionOperand* source, -+ InstructionOperand* destination) { -+ RiscvOperandConverter g(this, nullptr); -+ // Dispatch on the source and destination operand kinds. Not all -+ // combinations are possible. -+ if (source->IsRegister()) { -+ // Register-register. -+ Register temp = kScratchReg; -+ Register src = g.ToRegister(source); -+ if (destination->IsRegister()) { -+ Register dst = g.ToRegister(destination); -+ __ Move(temp, src); -+ __ Move(src, dst); -+ __ Move(dst, temp); -+ } else { -+ DCHECK(destination->IsStackSlot()); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ Move(temp, src); -+ __ Ld(src, dst); -+ __ Sd(temp, dst); -+ } -+ } else if (source->IsStackSlot()) { -+ DCHECK(destination->IsStackSlot()); -+ Register temp_0 = kScratchReg; -+ Register temp_1 = kScratchReg2; -+ MemOperand src = g.ToMemOperand(source); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ Ld(temp_0, src); -+ __ Ld(temp_1, dst); -+ __ Sd(temp_0, dst); -+ __ Sd(temp_1, src); -+ } else if (source->IsFPRegister()) { -+ MachineRepresentation rep = LocationOperand::cast(source)->representation(); -+ if (rep == MachineRepresentation::kSimd128) { -+ UNIMPLEMENTED(); -+ } else { -+ FPURegister temp = kScratchDoubleReg; -+ FPURegister src = g.ToDoubleRegister(source); -+ if (destination->IsFPRegister()) { -+ FPURegister dst = g.ToDoubleRegister(destination); -+ __ Move(temp, src); -+ __ Move(src, dst); -+ __ Move(dst, temp); -+ } else { -+ DCHECK(destination->IsFPStackSlot()); -+ MemOperand dst = g.ToMemOperand(destination); -+ __ Move(temp, src); -+ __ LoadDouble(src, dst); -+ __ StoreDouble(temp, dst); -+ } -+ } -+ } else if (source->IsFPStackSlot()) { -+ DCHECK(destination->IsFPStackSlot()); -+ Register temp_0 = kScratchReg; -+ MemOperand src0 = g.ToMemOperand(source); -+ MemOperand src1(src0.rm(), src0.offset() + kIntSize); -+ MemOperand dst0 = g.ToMemOperand(destination); -+ MemOperand dst1(dst0.rm(), dst0.offset() + kIntSize); -+ MachineRepresentation rep = LocationOperand::cast(source)->representation(); -+ if (rep == MachineRepresentation::kSimd128) { -+ UNIMPLEMENTED(); -+ } else { -+ FPURegister temp_1 = kScratchDoubleReg; -+ __ LoadDouble(temp_1, dst0); // Save destination in temp_1. -+ __ Lw(temp_0, src0); // Then use temp_0 to copy source to destination. -+ __ Sw(temp_0, dst0); -+ __ Lw(temp_0, src1); -+ __ Sw(temp_0, dst1); -+ __ StoreDouble(temp_1, src0); -+ } -+ } else { -+ // No other combinations are possible. -+ UNREACHABLE(); -+ } -+} -+ -+void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { -+ // On 64-bit RISC-V we emit the jump tables inline. -+ UNREACHABLE(); -+} -+ -+#undef ASSEMBLE_ATOMIC_LOAD_INTEGER -+#undef ASSEMBLE_ATOMIC_STORE_INTEGER -+#undef ASSEMBLE_ATOMIC_BINOP -+#undef ASSEMBLE_ATOMIC_BINOP_EXT -+#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER -+#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT -+#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER -+#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT -+#undef ASSEMBLE_IEEE754_BINOP -+#undef ASSEMBLE_IEEE754_UNOP -+ -+#undef TRACE_MSG -+#undef TRACE_UNIMPL -+#undef __ -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-codes-riscv64.h -@@ -0,0 +1,432 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ -+#define V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+// RISC-V-specific opcodes that specify which assembly sequence to emit. -+// Most opcodes specify a single instruction. -+#define TARGET_ARCH_OPCODE_LIST(V) \ -+ V(RiscvAdd32) \ -+ V(RiscvAdd64) \ -+ V(RiscvAddOvf64) \ -+ V(RiscvSub32) \ -+ V(RiscvSub64) \ -+ V(RiscvSubOvf64) \ -+ V(RiscvMul32) \ -+ V(RiscvMulOvf32) \ -+ V(RiscvMulHigh32) \ -+ V(RiscvMulHigh64) \ -+ V(RiscvMulHighU32) \ -+ V(RiscvMul64) \ -+ V(RiscvDiv32) \ -+ V(RiscvDiv64) \ -+ V(RiscvDivU32) \ -+ V(RiscvDivU64) \ -+ V(RiscvMod32) \ -+ V(RiscvMod64) \ -+ V(RiscvModU32) \ -+ V(RiscvModU64) \ -+ V(RiscvAnd) \ -+ V(RiscvAnd32) \ -+ V(RiscvOr) \ -+ V(RiscvOr32) \ -+ V(RiscvNor) \ -+ V(RiscvNor32) \ -+ V(RiscvXor) \ -+ V(RiscvXor32) \ -+ V(RiscvClz32) \ -+ V(RiscvShl32) \ -+ V(RiscvShr32) \ -+ V(RiscvSar32) \ -+ V(RiscvZeroExtendWord) \ -+ V(RiscvSignExtendWord) \ -+ V(RiscvClz64) \ -+ V(RiscvCtz32) \ -+ V(RiscvCtz64) \ -+ V(RiscvPopcnt32) \ -+ V(RiscvPopcnt64) \ -+ V(RiscvShl64) \ -+ V(RiscvShr64) \ -+ V(RiscvSar64) \ -+ V(RiscvRor32) \ -+ V(RiscvRor64) \ -+ V(RiscvMov) \ -+ V(RiscvTst) \ -+ V(RiscvCmp) \ -+ V(RiscvCmpS) \ -+ V(RiscvAddS) \ -+ V(RiscvSubS) \ -+ V(RiscvMulS) \ -+ V(RiscvDivS) \ -+ V(RiscvModS) \ -+ V(RiscvAbsS) \ -+ V(RiscvNegS) \ -+ V(RiscvSqrtS) \ -+ V(RiscvMaxS) \ -+ V(RiscvMinS) \ -+ V(RiscvCmpD) \ -+ V(RiscvAddD) \ -+ V(RiscvSubD) \ -+ V(RiscvMulD) \ -+ V(RiscvDivD) \ -+ V(RiscvModD) \ -+ V(RiscvAbsD) \ -+ V(RiscvNegD) \ -+ V(RiscvSqrtD) \ -+ V(RiscvMaxD) \ -+ V(RiscvMinD) \ -+ V(RiscvFloat64RoundDown) \ -+ V(RiscvFloat64RoundTruncate) \ -+ V(RiscvFloat64RoundUp) \ -+ V(RiscvFloat64RoundTiesEven) \ -+ V(RiscvFloat32RoundDown) \ -+ V(RiscvFloat32RoundTruncate) \ -+ V(RiscvFloat32RoundUp) \ -+ V(RiscvFloat32RoundTiesEven) \ -+ V(RiscvCvtSD) \ -+ V(RiscvCvtDS) \ -+ V(RiscvTruncWD) \ -+ V(RiscvRoundWD) \ -+ V(RiscvFloorWD) \ -+ V(RiscvCeilWD) \ -+ V(RiscvTruncWS) \ -+ V(RiscvRoundWS) \ -+ V(RiscvFloorWS) \ -+ V(RiscvCeilWS) \ -+ V(RiscvTruncLS) \ -+ V(RiscvTruncLD) \ -+ V(RiscvTruncUwD) \ -+ V(RiscvTruncUwS) \ -+ V(RiscvTruncUlS) \ -+ V(RiscvTruncUlD) \ -+ V(RiscvCvtDW) \ -+ V(RiscvCvtSL) \ -+ V(RiscvCvtSW) \ -+ V(RiscvCvtSUw) \ -+ V(RiscvCvtSUl) \ -+ V(RiscvCvtDL) \ -+ V(RiscvCvtDUw) \ -+ V(RiscvCvtDUl) \ -+ V(RiscvLb) \ -+ V(RiscvLbu) \ -+ V(RiscvSb) \ -+ V(RiscvLh) \ -+ V(RiscvUlh) \ -+ V(RiscvLhu) \ -+ V(RiscvUlhu) \ -+ V(RiscvSh) \ -+ V(RiscvUsh) \ -+ V(RiscvLd) \ -+ V(RiscvUld) \ -+ V(RiscvLw) \ -+ V(RiscvUlw) \ -+ V(RiscvLwu) \ -+ V(RiscvUlwu) \ -+ V(RiscvSw) \ -+ V(RiscvUsw) \ -+ V(RiscvSd) \ -+ V(RiscvUsd) \ -+ V(RiscvLoadFloat) \ -+ V(RiscvULoadFloat) \ -+ V(RiscvStoreFloat) \ -+ V(RiscvUStoreFloat) \ -+ V(RiscvLoadDouble) \ -+ V(RiscvULoadDouble) \ -+ V(RiscvStoreDouble) \ -+ V(RiscvUStoreDouble) \ -+ V(RiscvBitcastDL) \ -+ V(RiscvBitcastLD) \ -+ V(RiscvBitcastInt32ToFloat32) \ -+ V(RiscvBitcastFloat32ToInt32) \ -+ V(RiscvFloat64ExtractLowWord32) \ -+ V(RiscvFloat64ExtractHighWord32) \ -+ V(RiscvFloat64InsertLowWord32) \ -+ V(RiscvFloat64InsertHighWord32) \ -+ V(RiscvFloat32Max) \ -+ V(RiscvFloat64Max) \ -+ V(RiscvFloat32Min) \ -+ V(RiscvFloat64Min) \ -+ V(RiscvFloat64SilenceNaN) \ -+ V(RiscvPush) \ -+ V(RiscvPeek) \ -+ V(RiscvByteSwap64) \ -+ V(RiscvByteSwap32) \ -+ V(RiscvStoreToStackSlot) \ -+ V(RiscvStackClaim) \ -+ V(RiscvSignExtendByte) \ -+ V(RiscvSignExtendShort) \ -+ V(RiscvSync) \ -+ V(RiscvAssertEqual) \ -+ V(RiscvS128Const) \ -+ V(RiscvS128Zero) \ -+ V(RiscvS128AllOnes) \ -+ V(RiscvI32x4Splat) \ -+ V(RiscvI32x4ExtractLane) \ -+ V(RiscvI32x4ReplaceLane) \ -+ V(RiscvI32x4Add) \ -+ V(RiscvI32x4AddHoriz) \ -+ V(RiscvI32x4Sub) \ -+ V(RiscvF64x2Abs) \ -+ V(RiscvF64x2Neg) \ -+ V(RiscvF32x4Splat) \ -+ V(RiscvF32x4ExtractLane) \ -+ V(RiscvF32x4ReplaceLane) \ -+ V(RiscvF32x4SConvertI32x4) \ -+ V(RiscvF32x4UConvertI32x4) \ -+ V(RiscvI32x4Mul) \ -+ V(RiscvI32x4MaxS) \ -+ V(RiscvI32x4MinS) \ -+ V(RiscvI32x4Eq) \ -+ V(RiscvI32x4Ne) \ -+ V(RiscvI32x4Shl) \ -+ V(RiscvI32x4ShrS) \ -+ V(RiscvI32x4ShrU) \ -+ V(RiscvI32x4MaxU) \ -+ V(RiscvI32x4MinU) \ -+ V(RiscvF64x2Sqrt) \ -+ V(RiscvF64x2Add) \ -+ V(RiscvF64x2Sub) \ -+ V(RiscvF64x2Mul) \ -+ V(RiscvF64x2Div) \ -+ V(RiscvF64x2Min) \ -+ V(RiscvF64x2Max) \ -+ V(RiscvF64x2Eq) \ -+ V(RiscvF64x2Ne) \ -+ V(RiscvF64x2Lt) \ -+ V(RiscvF64x2Le) \ -+ V(RiscvF64x2Splat) \ -+ V(RiscvF64x2ExtractLane) \ -+ V(RiscvF64x2ReplaceLane) \ -+ V(RiscvF64x2Pmin) \ -+ V(RiscvF64x2Pmax) \ -+ V(RiscvF64x2Ceil) \ -+ V(RiscvF64x2Floor) \ -+ V(RiscvF64x2Trunc) \ -+ V(RiscvF64x2NearestInt) \ -+ V(RiscvI64x2Splat) \ -+ V(RiscvI64x2ExtractLane) \ -+ V(RiscvI64x2ReplaceLane) \ -+ V(RiscvI64x2Add) \ -+ V(RiscvI64x2Sub) \ -+ V(RiscvI64x2Mul) \ -+ V(RiscvI64x2Neg) \ -+ V(RiscvI64x2Shl) \ -+ V(RiscvI64x2ShrS) \ -+ V(RiscvI64x2ShrU) \ -+ V(RiscvF32x4Abs) \ -+ V(RiscvF32x4Neg) \ -+ V(RiscvF32x4Sqrt) \ -+ V(RiscvF32x4RecipApprox) \ -+ V(RiscvF32x4RecipSqrtApprox) \ -+ V(RiscvF32x4Add) \ -+ V(RiscvF32x4AddHoriz) \ -+ V(RiscvF32x4Sub) \ -+ V(RiscvF32x4Mul) \ -+ V(RiscvF32x4Div) \ -+ V(RiscvF32x4Max) \ -+ V(RiscvF32x4Min) \ -+ V(RiscvF32x4Eq) \ -+ V(RiscvF32x4Ne) \ -+ V(RiscvF32x4Lt) \ -+ V(RiscvF32x4Le) \ -+ V(RiscvF32x4Pmin) \ -+ V(RiscvF32x4Pmax) \ -+ V(RiscvF32x4Ceil) \ -+ V(RiscvF32x4Floor) \ -+ V(RiscvF32x4Trunc) \ -+ V(RiscvF32x4NearestInt) \ -+ V(RiscvI32x4SConvertF32x4) \ -+ V(RiscvI32x4UConvertF32x4) \ -+ V(RiscvI32x4Neg) \ -+ V(RiscvI32x4GtS) \ -+ V(RiscvI32x4GeS) \ -+ V(RiscvI32x4GtU) \ -+ V(RiscvI32x4GeU) \ -+ V(RiscvI32x4Abs) \ -+ V(RiscvI32x4BitMask) \ -+ V(RiscvI16x8Splat) \ -+ V(RiscvI16x8ExtractLaneU) \ -+ V(RiscvI16x8ExtractLaneS) \ -+ V(RiscvI16x8ReplaceLane) \ -+ V(RiscvI16x8Neg) \ -+ V(RiscvI16x8Shl) \ -+ V(RiscvI16x8ShrS) \ -+ V(RiscvI16x8ShrU) \ -+ V(RiscvI16x8Add) \ -+ V(RiscvI16x8AddSaturateS) \ -+ V(RiscvI16x8AddHoriz) \ -+ V(RiscvI16x8Sub) \ -+ V(RiscvI16x8SubSaturateS) \ -+ V(RiscvI16x8Mul) \ -+ V(RiscvI16x8MaxS) \ -+ V(RiscvI16x8MinS) \ -+ V(RiscvI16x8Eq) \ -+ V(RiscvI16x8Ne) \ -+ V(RiscvI16x8GtS) \ -+ V(RiscvI16x8GeS) \ -+ V(RiscvI16x8AddSaturateU) \ -+ V(RiscvI16x8SubSaturateU) \ -+ V(RiscvI16x8MaxU) \ -+ V(RiscvI16x8MinU) \ -+ V(RiscvI16x8GtU) \ -+ V(RiscvI16x8GeU) \ -+ V(RiscvI16x8RoundingAverageU) \ -+ V(RiscvI16x8Abs) \ -+ V(RiscvI16x8BitMask) \ -+ V(RiscvI8x16Splat) \ -+ V(RiscvI8x16ExtractLaneU) \ -+ V(RiscvI8x16ExtractLaneS) \ -+ V(RiscvI8x16ReplaceLane) \ -+ V(RiscvI8x16Neg) \ -+ V(RiscvI8x16Shl) \ -+ V(RiscvI8x16ShrS) \ -+ V(RiscvI8x16Add) \ -+ V(RiscvI8x16AddSaturateS) \ -+ V(RiscvI8x16Sub) \ -+ V(RiscvI8x16SubSaturateS) \ -+ V(RiscvI8x16Mul) \ -+ V(RiscvI8x16MaxS) \ -+ V(RiscvI8x16MinS) \ -+ V(RiscvI8x16Eq) \ -+ V(RiscvI8x16Ne) \ -+ V(RiscvI8x16GtS) \ -+ V(RiscvI8x16GeS) \ -+ V(RiscvI8x16ShrU) \ -+ V(RiscvI8x16AddSaturateU) \ -+ V(RiscvI8x16SubSaturateU) \ -+ V(RiscvI8x16MaxU) \ -+ V(RiscvI8x16MinU) \ -+ V(RiscvI8x16GtU) \ -+ V(RiscvI8x16GeU) \ -+ V(RiscvI8x16RoundingAverageU) \ -+ V(RiscvI8x16Abs) \ -+ V(RiscvI8x16BitMask) \ -+ V(RiscvS128And) \ -+ V(RiscvS128Or) \ -+ V(RiscvS128Xor) \ -+ V(RiscvS128Not) \ -+ V(RiscvS128Select) \ -+ V(RiscvS128AndNot) \ -+ V(RiscvV32x4AnyTrue) \ -+ V(RiscvV32x4AllTrue) \ -+ V(RiscvV16x8AnyTrue) \ -+ V(RiscvV16x8AllTrue) \ -+ V(RiscvV8x16AnyTrue) \ -+ V(RiscvV8x16AllTrue) \ -+ V(RiscvS32x4InterleaveRight) \ -+ V(RiscvS32x4InterleaveLeft) \ -+ V(RiscvS32x4PackEven) \ -+ V(RiscvS32x4PackOdd) \ -+ V(RiscvS32x4InterleaveEven) \ -+ V(RiscvS32x4InterleaveOdd) \ -+ V(RiscvS32x4Shuffle) \ -+ V(RiscvS16x8InterleaveRight) \ -+ V(RiscvS16x8InterleaveLeft) \ -+ V(RiscvS16x8PackEven) \ -+ V(RiscvS16x8PackOdd) \ -+ V(RiscvS16x8InterleaveEven) \ -+ V(RiscvS16x8InterleaveOdd) \ -+ V(RiscvS16x4Reverse) \ -+ V(RiscvS16x2Reverse) \ -+ V(RiscvS8x16InterleaveRight) \ -+ V(RiscvS8x16InterleaveLeft) \ -+ V(RiscvS8x16PackEven) \ -+ V(RiscvS8x16PackOdd) \ -+ V(RiscvS8x16InterleaveEven) \ -+ V(RiscvS8x16InterleaveOdd) \ -+ V(RiscvI8x16Shuffle) \ -+ V(RiscvI8x16Swizzle) \ -+ V(RiscvS8x16Concat) \ -+ V(RiscvS8x8Reverse) \ -+ V(RiscvS8x4Reverse) \ -+ V(RiscvS8x2Reverse) \ -+ V(RiscvS8x16LoadSplat) \ -+ V(RiscvS16x8LoadSplat) \ -+ V(RiscvS32x4LoadSplat) \ -+ V(RiscvS64x2LoadSplat) \ -+ V(RiscvI16x8Load8x8S) \ -+ V(RiscvI16x8Load8x8U) \ -+ V(RiscvI32x4Load16x4S) \ -+ V(RiscvI32x4Load16x4U) \ -+ V(RiscvI64x2Load32x2S) \ -+ V(RiscvI64x2Load32x2U) \ -+ V(RiscvMsaLd) \ -+ V(RiscvMsaSt) \ -+ V(RiscvI32x4SConvertI16x8Low) \ -+ V(RiscvI32x4SConvertI16x8High) \ -+ V(RiscvI32x4UConvertI16x8Low) \ -+ V(RiscvI32x4UConvertI16x8High) \ -+ V(RiscvI16x8SConvertI8x16Low) \ -+ V(RiscvI16x8SConvertI8x16High) \ -+ V(RiscvI16x8SConvertI32x4) \ -+ V(RiscvI16x8UConvertI32x4) \ -+ V(RiscvI16x8UConvertI8x16Low) \ -+ V(RiscvI16x8UConvertI8x16High) \ -+ V(RiscvI8x16SConvertI16x8) \ -+ V(RiscvI8x16UConvertI16x8) \ -+ V(RiscvWord64AtomicLoadUint8) \ -+ V(RiscvWord64AtomicLoadUint16) \ -+ V(RiscvWord64AtomicLoadUint32) \ -+ V(RiscvWord64AtomicLoadUint64) \ -+ V(RiscvWord64AtomicStoreWord8) \ -+ V(RiscvWord64AtomicStoreWord16) \ -+ V(RiscvWord64AtomicStoreWord32) \ -+ V(RiscvWord64AtomicStoreWord64) \ -+ V(RiscvWord64AtomicAddUint8) \ -+ V(RiscvWord64AtomicAddUint16) \ -+ V(RiscvWord64AtomicAddUint32) \ -+ V(RiscvWord64AtomicAddUint64) \ -+ V(RiscvWord64AtomicSubUint8) \ -+ V(RiscvWord64AtomicSubUint16) \ -+ V(RiscvWord64AtomicSubUint32) \ -+ V(RiscvWord64AtomicSubUint64) \ -+ V(RiscvWord64AtomicAndUint8) \ -+ V(RiscvWord64AtomicAndUint16) \ -+ V(RiscvWord64AtomicAndUint32) \ -+ V(RiscvWord64AtomicAndUint64) \ -+ V(RiscvWord64AtomicOrUint8) \ -+ V(RiscvWord64AtomicOrUint16) \ -+ V(RiscvWord64AtomicOrUint32) \ -+ V(RiscvWord64AtomicOrUint64) \ -+ V(RiscvWord64AtomicXorUint8) \ -+ V(RiscvWord64AtomicXorUint16) \ -+ V(RiscvWord64AtomicXorUint32) \ -+ V(RiscvWord64AtomicXorUint64) \ -+ V(RiscvWord64AtomicExchangeUint8) \ -+ V(RiscvWord64AtomicExchangeUint16) \ -+ V(RiscvWord64AtomicExchangeUint32) \ -+ V(RiscvWord64AtomicExchangeUint64) \ -+ V(RiscvWord64AtomicCompareExchangeUint8) \ -+ V(RiscvWord64AtomicCompareExchangeUint16) \ -+ V(RiscvWord64AtomicCompareExchangeUint32) \ -+ V(RiscvWord64AtomicCompareExchangeUint64) -+ -+// Addressing modes represent the "shape" of inputs to an instruction. -+// Many instructions support multiple addressing modes. Addressing modes -+// are encoded into the InstructionCode of the instruction and tell the -+// code generator after register allocation which assembler method to call. -+// -+// We use the following local notation for addressing modes: -+// -+// R = register -+// O = register or stack slot -+// D = double register -+// I = immediate (handle, external, int32) -+// MRI = [register + immediate] -+// MRR = [register + register] -+// TODO(plind): Add the new r6 address modes. -+#define TARGET_ADDRESSING_MODE_LIST(V) \ -+ V(MRI) /* [%r0 + K] */ \ -+ V(MRR) /* [%r0 + %r1] */ -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-scheduler-riscv64.cc -@@ -0,0 +1,1571 @@ -+// Copyright 2015 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/compiler/backend/instruction-scheduler.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+bool InstructionScheduler::SchedulerSupported() { return true; } -+ -+int InstructionScheduler::GetTargetInstructionFlags( -+ const Instruction* instr) const { -+ switch (instr->arch_opcode()) { -+ case kRiscvAbsD: -+ case kRiscvAbsS: -+ case kRiscvAdd32: -+ case kRiscvAddD: -+ case kRiscvAddS: -+ case kRiscvAnd: -+ case kRiscvAnd32: -+ case kRiscvAssertEqual: -+ case kRiscvBitcastDL: -+ case kRiscvBitcastLD: -+ case kRiscvBitcastInt32ToFloat32: -+ case kRiscvBitcastFloat32ToInt32: -+ case kRiscvByteSwap32: -+ case kRiscvByteSwap64: -+ case kRiscvCeilWD: -+ case kRiscvCeilWS: -+ case kRiscvClz32: -+ case kRiscvCmp: -+ case kRiscvCmpD: -+ case kRiscvCmpS: -+ case kRiscvCtz32: -+ case kRiscvCvtDL: -+ case kRiscvCvtDS: -+ case kRiscvCvtDUl: -+ case kRiscvCvtDUw: -+ case kRiscvCvtDW: -+ case kRiscvCvtSD: -+ case kRiscvCvtSL: -+ case kRiscvCvtSUl: -+ case kRiscvCvtSUw: -+ case kRiscvCvtSW: -+ case kRiscvMulHigh64: -+ case kRiscvMulHighU32: -+ case kRiscvAdd64: -+ case kRiscvAddOvf64: -+ case kRiscvClz64: -+ case kRiscvCtz64: -+ case kRiscvDiv64: -+ case kRiscvDivU64: -+ case kRiscvZeroExtendWord: -+ case kRiscvSignExtendWord: -+ case kRiscvDiv32: -+ case kRiscvDivD: -+ case kRiscvDivS: -+ case kRiscvDivU32: -+ case kRiscvMod64: -+ case kRiscvModU64: -+ case kRiscvMul64: -+ case kRiscvPopcnt64: -+ case kRiscvRor64: -+ case kRiscvSar64: -+ case kRiscvShl64: -+ case kRiscvShr64: -+ case kRiscvSub64: -+ case kRiscvSubOvf64: -+ case kRiscvF64x2Abs: -+ case kRiscvF64x2Neg: -+ case kRiscvF64x2Sqrt: -+ case kRiscvF64x2Add: -+ case kRiscvF64x2Sub: -+ case kRiscvF64x2Mul: -+ case kRiscvF64x2Div: -+ case kRiscvF64x2Min: -+ case kRiscvF64x2Max: -+ case kRiscvF64x2Eq: -+ case kRiscvF64x2Ne: -+ case kRiscvF64x2Lt: -+ case kRiscvF64x2Le: -+ case kRiscvF64x2Pmin: -+ case kRiscvF64x2Pmax: -+ case kRiscvF64x2Ceil: -+ case kRiscvF64x2Floor: -+ case kRiscvF64x2Trunc: -+ case kRiscvF64x2NearestInt: -+ case kRiscvI64x2Splat: -+ case kRiscvI64x2ExtractLane: -+ case kRiscvI64x2ReplaceLane: -+ case kRiscvI64x2Add: -+ case kRiscvI64x2Sub: -+ case kRiscvI64x2Mul: -+ case kRiscvI64x2Neg: -+ case kRiscvI64x2Shl: -+ case kRiscvI64x2ShrS: -+ case kRiscvI64x2ShrU: -+ case kRiscvF32x4Abs: -+ case kRiscvF32x4Add: -+ case kRiscvF32x4AddHoriz: -+ case kRiscvF32x4Eq: -+ case kRiscvF32x4ExtractLane: -+ case kRiscvF32x4Lt: -+ case kRiscvF32x4Le: -+ case kRiscvF32x4Max: -+ case kRiscvF32x4Min: -+ case kRiscvF32x4Mul: -+ case kRiscvF32x4Div: -+ case kRiscvF32x4Ne: -+ case kRiscvF32x4Neg: -+ case kRiscvF32x4Sqrt: -+ case kRiscvF32x4RecipApprox: -+ case kRiscvF32x4RecipSqrtApprox: -+ case kRiscvF32x4ReplaceLane: -+ case kRiscvF32x4SConvertI32x4: -+ case kRiscvF32x4Splat: -+ case kRiscvF32x4Sub: -+ case kRiscvF32x4UConvertI32x4: -+ case kRiscvF32x4Pmin: -+ case kRiscvF32x4Pmax: -+ case kRiscvF32x4Ceil: -+ case kRiscvF32x4Floor: -+ case kRiscvF32x4Trunc: -+ case kRiscvF32x4NearestInt: -+ case kRiscvF64x2Splat: -+ case kRiscvF64x2ExtractLane: -+ case kRiscvF64x2ReplaceLane: -+ case kRiscvFloat32Max: -+ case kRiscvFloat32Min: -+ case kRiscvFloat32RoundDown: -+ case kRiscvFloat32RoundTiesEven: -+ case kRiscvFloat32RoundTruncate: -+ case kRiscvFloat32RoundUp: -+ case kRiscvFloat64ExtractLowWord32: -+ case kRiscvFloat64ExtractHighWord32: -+ case kRiscvFloat64InsertLowWord32: -+ case kRiscvFloat64InsertHighWord32: -+ case kRiscvFloat64Max: -+ case kRiscvFloat64Min: -+ case kRiscvFloat64RoundDown: -+ case kRiscvFloat64RoundTiesEven: -+ case kRiscvFloat64RoundTruncate: -+ case kRiscvFloat64RoundUp: -+ case kRiscvFloat64SilenceNaN: -+ case kRiscvFloorWD: -+ case kRiscvFloorWS: -+ case kRiscvI16x8Add: -+ case kRiscvI16x8AddHoriz: -+ case kRiscvI16x8AddSaturateS: -+ case kRiscvI16x8AddSaturateU: -+ case kRiscvI16x8Eq: -+ case kRiscvI16x8ExtractLaneU: -+ case kRiscvI16x8ExtractLaneS: -+ case kRiscvI16x8GeS: -+ case kRiscvI16x8GeU: -+ case kRiscvI16x8GtS: -+ case kRiscvI16x8GtU: -+ case kRiscvI16x8MaxS: -+ case kRiscvI16x8MaxU: -+ case kRiscvI16x8MinS: -+ case kRiscvI16x8MinU: -+ case kRiscvI16x8Mul: -+ case kRiscvI16x8Ne: -+ case kRiscvI16x8Neg: -+ case kRiscvI16x8ReplaceLane: -+ case kRiscvI8x16SConvertI16x8: -+ case kRiscvI16x8SConvertI32x4: -+ case kRiscvI16x8SConvertI8x16High: -+ case kRiscvI16x8SConvertI8x16Low: -+ case kRiscvI16x8Shl: -+ case kRiscvI16x8ShrS: -+ case kRiscvI16x8ShrU: -+ case kRiscvI16x8Splat: -+ case kRiscvI16x8Sub: -+ case kRiscvI16x8SubSaturateS: -+ case kRiscvI16x8SubSaturateU: -+ case kRiscvI8x16UConvertI16x8: -+ case kRiscvI16x8UConvertI32x4: -+ case kRiscvI16x8UConvertI8x16High: -+ case kRiscvI16x8UConvertI8x16Low: -+ case kRiscvI16x8RoundingAverageU: -+ case kRiscvI16x8Abs: -+ case kRiscvI16x8BitMask: -+ case kRiscvI32x4Add: -+ case kRiscvI32x4AddHoriz: -+ case kRiscvI32x4Eq: -+ case kRiscvI32x4ExtractLane: -+ case kRiscvI32x4GeS: -+ case kRiscvI32x4GeU: -+ case kRiscvI32x4GtS: -+ case kRiscvI32x4GtU: -+ case kRiscvI32x4MaxS: -+ case kRiscvI32x4MaxU: -+ case kRiscvI32x4MinS: -+ case kRiscvI32x4MinU: -+ case kRiscvI32x4Mul: -+ case kRiscvI32x4Ne: -+ case kRiscvI32x4Neg: -+ case kRiscvI32x4ReplaceLane: -+ case kRiscvI32x4SConvertF32x4: -+ case kRiscvI32x4SConvertI16x8High: -+ case kRiscvI32x4SConvertI16x8Low: -+ case kRiscvI32x4Shl: -+ case kRiscvI32x4ShrS: -+ case kRiscvI32x4ShrU: -+ case kRiscvI32x4Splat: -+ case kRiscvI32x4Sub: -+ case kRiscvI32x4UConvertF32x4: -+ case kRiscvI32x4UConvertI16x8High: -+ case kRiscvI32x4UConvertI16x8Low: -+ case kRiscvI32x4Abs: -+ case kRiscvI32x4BitMask: -+ case kRiscvI8x16Add: -+ case kRiscvI8x16AddSaturateS: -+ case kRiscvI8x16AddSaturateU: -+ case kRiscvI8x16Eq: -+ case kRiscvI8x16ExtractLaneU: -+ case kRiscvI8x16ExtractLaneS: -+ case kRiscvI8x16GeS: -+ case kRiscvI8x16GeU: -+ case kRiscvI8x16GtS: -+ case kRiscvI8x16GtU: -+ case kRiscvI8x16MaxS: -+ case kRiscvI8x16MaxU: -+ case kRiscvI8x16MinS: -+ case kRiscvI8x16MinU: -+ case kRiscvI8x16Mul: -+ case kRiscvI8x16Ne: -+ case kRiscvI8x16Neg: -+ case kRiscvI8x16ReplaceLane: -+ case kRiscvI8x16Shl: -+ case kRiscvI8x16ShrS: -+ case kRiscvI8x16ShrU: -+ case kRiscvI8x16Splat: -+ case kRiscvI8x16Sub: -+ case kRiscvI8x16SubSaturateS: -+ case kRiscvI8x16SubSaturateU: -+ case kRiscvI8x16RoundingAverageU: -+ case kRiscvI8x16Abs: -+ case kRiscvI8x16BitMask: -+ case kRiscvMaxD: -+ case kRiscvMaxS: -+ case kRiscvMinD: -+ case kRiscvMinS: -+ case kRiscvMod32: -+ case kRiscvModU32: -+ case kRiscvMov: -+ case kRiscvMul32: -+ case kRiscvMulD: -+ case kRiscvMulHigh32: -+ case kRiscvMulOvf32: -+ case kRiscvMulS: -+ case kRiscvNegD: -+ case kRiscvNegS: -+ case kRiscvNor: -+ case kRiscvNor32: -+ case kRiscvOr: -+ case kRiscvOr32: -+ case kRiscvPopcnt32: -+ case kRiscvRor32: -+ case kRiscvRoundWD: -+ case kRiscvRoundWS: -+ case kRiscvS128And: -+ case kRiscvS128Or: -+ case kRiscvS128Not: -+ case kRiscvS128Select: -+ case kRiscvS128AndNot: -+ case kRiscvS128Xor: -+ case kRiscvS128Const: -+ case kRiscvS128Zero: -+ case kRiscvS128AllOnes: -+ case kRiscvS16x8InterleaveEven: -+ case kRiscvS16x8InterleaveOdd: -+ case kRiscvS16x8InterleaveLeft: -+ case kRiscvS16x8InterleaveRight: -+ case kRiscvS16x8PackEven: -+ case kRiscvS16x8PackOdd: -+ case kRiscvS16x2Reverse: -+ case kRiscvS16x4Reverse: -+ case kRiscvV8x16AllTrue: -+ case kRiscvV8x16AnyTrue: -+ case kRiscvV32x4AllTrue: -+ case kRiscvV32x4AnyTrue: -+ case kRiscvV16x8AllTrue: -+ case kRiscvV16x8AnyTrue: -+ case kRiscvS32x4InterleaveEven: -+ case kRiscvS32x4InterleaveOdd: -+ case kRiscvS32x4InterleaveLeft: -+ case kRiscvS32x4InterleaveRight: -+ case kRiscvS32x4PackEven: -+ case kRiscvS32x4PackOdd: -+ case kRiscvS32x4Shuffle: -+ case kRiscvS8x16Concat: -+ case kRiscvS8x16InterleaveEven: -+ case kRiscvS8x16InterleaveOdd: -+ case kRiscvS8x16InterleaveLeft: -+ case kRiscvS8x16InterleaveRight: -+ case kRiscvS8x16PackEven: -+ case kRiscvS8x16PackOdd: -+ case kRiscvS8x2Reverse: -+ case kRiscvS8x4Reverse: -+ case kRiscvS8x8Reverse: -+ case kRiscvI8x16Shuffle: -+ case kRiscvI8x16Swizzle: -+ case kRiscvSar32: -+ case kRiscvSignExtendByte: -+ case kRiscvSignExtendShort: -+ case kRiscvShl32: -+ case kRiscvShr32: -+ case kRiscvSqrtD: -+ case kRiscvSqrtS: -+ case kRiscvSub32: -+ case kRiscvSubD: -+ case kRiscvSubS: -+ case kRiscvTruncLD: -+ case kRiscvTruncLS: -+ case kRiscvTruncUlD: -+ case kRiscvTruncUlS: -+ case kRiscvTruncUwD: -+ case kRiscvTruncUwS: -+ case kRiscvTruncWD: -+ case kRiscvTruncWS: -+ case kRiscvTst: -+ case kRiscvXor: -+ case kRiscvXor32: -+ return kNoOpcodeFlags; -+ -+ case kRiscvLb: -+ case kRiscvLbu: -+ case kRiscvLd: -+ case kRiscvLoadDouble: -+ case kRiscvLh: -+ case kRiscvLhu: -+ case kRiscvLw: -+ case kRiscvLoadFloat: -+ case kRiscvLwu: -+ case kRiscvMsaLd: -+ case kRiscvPeek: -+ case kRiscvUld: -+ case kRiscvULoadDouble: -+ case kRiscvUlh: -+ case kRiscvUlhu: -+ case kRiscvUlw: -+ case kRiscvUlwu: -+ case kRiscvULoadFloat: -+ case kRiscvS8x16LoadSplat: -+ case kRiscvS16x8LoadSplat: -+ case kRiscvS32x4LoadSplat: -+ case kRiscvS64x2LoadSplat: -+ case kRiscvI16x8Load8x8S: -+ case kRiscvI16x8Load8x8U: -+ case kRiscvI32x4Load16x4S: -+ case kRiscvI32x4Load16x4U: -+ case kRiscvI64x2Load32x2S: -+ case kRiscvI64x2Load32x2U: -+ case kRiscvWord64AtomicLoadUint8: -+ case kRiscvWord64AtomicLoadUint16: -+ case kRiscvWord64AtomicLoadUint32: -+ case kRiscvWord64AtomicLoadUint64: -+ -+ return kIsLoadOperation; -+ -+ case kRiscvModD: -+ case kRiscvModS: -+ case kRiscvMsaSt: -+ case kRiscvPush: -+ case kRiscvSb: -+ case kRiscvSd: -+ case kRiscvStoreDouble: -+ case kRiscvSh: -+ case kRiscvStackClaim: -+ case kRiscvStoreToStackSlot: -+ case kRiscvSw: -+ case kRiscvStoreFloat: -+ case kRiscvUsd: -+ case kRiscvUStoreDouble: -+ case kRiscvUsh: -+ case kRiscvUsw: -+ case kRiscvUStoreFloat: -+ case kRiscvSync: -+ case kRiscvWord64AtomicStoreWord8: -+ case kRiscvWord64AtomicStoreWord16: -+ case kRiscvWord64AtomicStoreWord32: -+ case kRiscvWord64AtomicStoreWord64: -+ case kRiscvWord64AtomicAddUint8: -+ case kRiscvWord64AtomicAddUint16: -+ case kRiscvWord64AtomicAddUint32: -+ case kRiscvWord64AtomicAddUint64: -+ case kRiscvWord64AtomicSubUint8: -+ case kRiscvWord64AtomicSubUint16: -+ case kRiscvWord64AtomicSubUint32: -+ case kRiscvWord64AtomicSubUint64: -+ case kRiscvWord64AtomicAndUint8: -+ case kRiscvWord64AtomicAndUint16: -+ case kRiscvWord64AtomicAndUint32: -+ case kRiscvWord64AtomicAndUint64: -+ case kRiscvWord64AtomicOrUint8: -+ case kRiscvWord64AtomicOrUint16: -+ case kRiscvWord64AtomicOrUint32: -+ case kRiscvWord64AtomicOrUint64: -+ case kRiscvWord64AtomicXorUint8: -+ case kRiscvWord64AtomicXorUint16: -+ case kRiscvWord64AtomicXorUint32: -+ case kRiscvWord64AtomicXorUint64: -+ case kRiscvWord64AtomicExchangeUint8: -+ case kRiscvWord64AtomicExchangeUint16: -+ case kRiscvWord64AtomicExchangeUint32: -+ case kRiscvWord64AtomicExchangeUint64: -+ case kRiscvWord64AtomicCompareExchangeUint8: -+ case kRiscvWord64AtomicCompareExchangeUint16: -+ case kRiscvWord64AtomicCompareExchangeUint32: -+ case kRiscvWord64AtomicCompareExchangeUint64: -+ return kHasSideEffect; -+ -+#define CASE(Name) case k##Name: -+ COMMON_ARCH_OPCODE_LIST(CASE) -+#undef CASE -+ // Already covered in architecture independent code. -+ UNREACHABLE(); -+ } -+ -+ UNREACHABLE(); -+} -+ -+enum Latency { -+ BRANCH = 4, // Estimated max. -+ RINT_S = 4, // Estimated. -+ RINT_D = 4, // Estimated. -+ -+ // FIXME (RISCV): remove MULT instructions (MIPS legacy) -+ MULT = 4, -+ MULTU = 4, -+ DMULT = 4, -+ -+ MUL32 = 7, -+ -+ DIV32 = 50, // Min:11 Max:50 -+ DIV64 = 50, -+ DIVU32 = 50, -+ DIVU64 = 50, -+ -+ ABS_S = 4, -+ ABS_D = 4, -+ NEG_S = 4, -+ NEG_D = 4, -+ ADD_S = 4, -+ ADD_D = 4, -+ SUB_S = 4, -+ SUB_D = 4, -+ MAX_S = 4, // Estimated. -+ MIN_S = 4, -+ MAX_D = 4, // Estimated. -+ MIN_D = 4, -+ C_cond_S = 4, -+ C_cond_D = 4, -+ MUL_S = 4, -+ -+ MADD_S = 4, -+ MSUB_S = 4, -+ NMADD_S = 4, -+ NMSUB_S = 4, -+ -+ CABS_cond_S = 4, -+ CABS_cond_D = 4, -+ -+ CVT_D_S = 4, -+ CVT_PS_PW = 4, -+ -+ CVT_S_W = 4, -+ CVT_S_L = 4, -+ CVT_D_W = 4, -+ CVT_D_L = 4, -+ -+ CVT_S_D = 4, -+ -+ CVT_W_S = 4, -+ CVT_W_D = 4, -+ CVT_L_S = 4, -+ CVT_L_D = 4, -+ -+ CEIL_W_S = 4, -+ CEIL_W_D = 4, -+ CEIL_L_S = 4, -+ CEIL_L_D = 4, -+ -+ FLOOR_W_S = 4, -+ FLOOR_W_D = 4, -+ FLOOR_L_S = 4, -+ FLOOR_L_D = 4, -+ -+ ROUND_W_S = 4, -+ ROUND_W_D = 4, -+ ROUND_L_S = 4, -+ ROUND_L_D = 4, -+ -+ TRUNC_W_S = 4, -+ TRUNC_W_D = 4, -+ TRUNC_L_S = 4, -+ TRUNC_L_D = 4, -+ -+ MOV_S = 4, -+ MOV_D = 4, -+ -+ MOVF_S = 4, -+ MOVF_D = 4, -+ -+ MOVN_S = 4, -+ MOVN_D = 4, -+ -+ MOVT_S = 4, -+ MOVT_D = 4, -+ -+ MOVZ_S = 4, -+ MOVZ_D = 4, -+ -+ MUL_D = 5, -+ MADD_D = 5, -+ MSUB_D = 5, -+ NMADD_D = 5, -+ NMSUB_D = 5, -+ -+ RECIP_S = 13, -+ RECIP_D = 26, -+ -+ RSQRT_S = 17, -+ RSQRT_D = 36, -+ -+ DIV_S = 17, -+ SQRT_S = 17, -+ -+ DIV_D = 32, -+ SQRT_D = 32, -+ -+ MOVT_FREG = 4, -+ MOVT_HIGH_FREG = 4, -+ MOVT_DREG = 4, -+ LOAD_FLOAT = 4, -+ LOAD_DOUBLE = 4, -+ -+ MOVF_FREG = 1, -+ MOVF_HIGH_FREG = 1, -+ MOVF_HIGH_DREG = 1, -+ MOVF_HIGH = 1, -+ MOVF_LOW = 1, -+ STORE_FLOAT = 1, -+ STORE_DOUBLE = 1, -+}; -+ -+int Add64Latency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int Sub64Latency(bool is_operand_register = true) { -+ return Add64Latency(is_operand_register); -+} -+ -+int AndLatency(bool is_operand_register = true) { -+ return Add64Latency(is_operand_register); -+} -+ -+int OrLatency(bool is_operand_register = true) { -+ return Add64Latency(is_operand_register); -+} -+ -+int NorLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int XorLatency(bool is_operand_register = true) { -+ return Add64Latency(is_operand_register); -+} -+ -+int Mul32Latency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::MUL32; -+ } else { -+ return Latency::MUL32 + 1; -+ } -+} -+ -+int Mul64Latency(bool is_operand_register = true) { -+ int latency = Latency::DMULT + Latency::MOVF_LOW; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Mulh32Latency(bool is_operand_register = true) { -+ int latency = Latency::MULT + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Mulhu32Latency(bool is_operand_register = true) { -+ int latency = Latency::MULTU + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Mulh64Latency(bool is_operand_register = true) { -+ int latency = Latency::DMULT + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Div32Latency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::DIV32; -+ } else { -+ return Latency::DIV32 + 1; -+ } -+} -+ -+int Divu32Latency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return Latency::DIVU32; -+ } else { -+ return Latency::DIVU32 + 1; -+ } -+} -+ -+int Div64Latency(bool is_operand_register = true) { -+ int latency = Latency::DIV64 + Latency::MOVF_LOW; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Divu64Latency(bool is_operand_register = true) { -+ int latency = Latency::DIVU64 + Latency::MOVF_LOW; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Mod32Latency(bool is_operand_register = true) { -+ int latency = Latency::DIV32 + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Modu32Latency(bool is_operand_register = true) { -+ int latency = Latency::DIVU32 + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Mod64Latency(bool is_operand_register = true) { -+ int latency = Latency::DIV64 + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int Modu64Latency(bool is_operand_register = true) { -+ int latency = Latency::DIV64 + Latency::MOVF_HIGH; -+ if (!is_operand_register) { -+ latency += 1; -+ } -+ return latency; -+} -+ -+int MovzLatency() { return 1; } -+ -+int MovnLatency() { return 1; } -+ -+int CallLatency() { -+ // Estimated. -+ return Add64Latency(false) + Latency::BRANCH + 5; -+} -+ -+int JumpLatency() { -+ // Estimated max. -+ return 1 + Add64Latency() + Latency::BRANCH + 2; -+} -+ -+int SmiUntagLatency() { return 1; } -+ -+int PrepareForTailCallLatency() { -+ // Estimated max. -+ return 2 * (Add64Latency() + 1 + Add64Latency(false)) + 2 + Latency::BRANCH + -+ Latency::BRANCH + 2 * Sub64Latency(false) + 2 + Latency::BRANCH + 1; -+} -+ -+int AssemblePopArgumentsAdoptFrameLatency() { -+ return 1 + Latency::BRANCH + 1 + SmiUntagLatency() + -+ PrepareForTailCallLatency(); -+} -+ -+int AssertLatency() { return 1; } -+ -+int PrepareCallCFunctionLatency() { -+ int frame_alignment = TurboAssembler::ActivationFrameAlignment(); -+ if (frame_alignment > kSystemPointerSize) { -+ return 1 + Sub64Latency(false) + AndLatency(false) + 1; -+ } else { -+ return Sub64Latency(false); -+ } -+} -+ -+int AdjustBaseAndOffsetLatency() { -+ return 3; // Estimated max. -+} -+ -+int AlignedMemoryLatency() { return AdjustBaseAndOffsetLatency() + 1; } -+ -+int UlhuLatency() { -+ return AdjustBaseAndOffsetLatency() + 2 * AlignedMemoryLatency() + 2; -+} -+ -+int UlwLatency() { -+ // Estimated max. -+ return AdjustBaseAndOffsetLatency() + 3; -+} -+ -+int UlwuLatency() { return UlwLatency() + 1; } -+ -+int UldLatency() { -+ // Estimated max. -+ return AdjustBaseAndOffsetLatency() + 3; -+} -+ -+int ULoadFloatLatency() { return UlwLatency() + Latency::MOVT_FREG; } -+ -+int ULoadDoubleLatency() { return UldLatency() + Latency::MOVT_DREG; } -+ -+int UshLatency() { -+ // Estimated max. -+ return AdjustBaseAndOffsetLatency() + 2 + 2 * AlignedMemoryLatency(); -+} -+ -+int UswLatency() { return AdjustBaseAndOffsetLatency() + 2; } -+ -+int UsdLatency() { return AdjustBaseAndOffsetLatency() + 2; } -+ -+int UStoreFloatLatency() { return Latency::MOVF_FREG + UswLatency(); } -+ -+int UStoreDoubleLatency() { return Latency::MOVF_HIGH_DREG + UsdLatency(); } -+ -+int LoadFloatLatency() { -+ return AdjustBaseAndOffsetLatency() + Latency::LOAD_FLOAT; -+} -+ -+int StoreFloatLatency() { -+ return AdjustBaseAndOffsetLatency() + Latency::STORE_FLOAT; -+} -+ -+int StoreDoubleLatency() { -+ return AdjustBaseAndOffsetLatency() + Latency::STORE_DOUBLE; -+} -+ -+int LoadDoubleLatency() { -+ return AdjustBaseAndOffsetLatency() + Latency::LOAD_DOUBLE; -+} -+ -+int MultiPushLatency() { -+ int latency = Sub64Latency(false); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ latency++; -+ } -+ return latency; -+} -+ -+int MultiPushFPULatency() { -+ int latency = Sub64Latency(false); -+ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { -+ latency += StoreDoubleLatency(); -+ } -+ return latency; -+} -+ -+int PushCallerSavedLatency(SaveFPRegsMode fp_mode) { -+ int latency = MultiPushLatency(); -+ if (fp_mode == kSaveFPRegs) { -+ latency += MultiPushFPULatency(); -+ } -+ return latency; -+} -+ -+int MultiPopLatency() { -+ int latency = Add64Latency(false); -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ latency++; -+ } -+ return latency; -+} -+ -+int MultiPopFPULatency() { -+ int latency = Add64Latency(false); -+ for (int16_t i = 0; i < kNumRegisters; i++) { -+ latency += LoadDoubleLatency(); -+ } -+ return latency; -+} -+ -+int PopCallerSavedLatency(SaveFPRegsMode fp_mode) { -+ int latency = MultiPopLatency(); -+ if (fp_mode == kSaveFPRegs) { -+ latency += MultiPopFPULatency(); -+ } -+ return latency; -+} -+ -+int CallCFunctionHelperLatency() { -+ // Estimated. -+ int latency = AndLatency(false) + Latency::BRANCH + 2 + CallLatency(); -+ if (base::OS::ActivationFrameAlignment() > kSystemPointerSize) { -+ latency++; -+ } else { -+ latency += Add64Latency(false); -+ } -+ return latency; -+} -+ -+int CallCFunctionLatency() { return 1 + CallCFunctionHelperLatency(); } -+ -+int AssembleArchJumpLatency() { -+ // Estimated max. -+ return Latency::BRANCH; -+} -+ -+int GenerateSwitchTableLatency() { -+ int latency = 6; -+ latency += 2; -+ return latency; -+} -+ -+int AssembleArchTableSwitchLatency() { -+ return Latency::BRANCH + GenerateSwitchTableLatency(); -+} -+ -+int DropAndRetLatency() { -+ // Estimated max. -+ return Add64Latency(false) + JumpLatency(); -+} -+ -+int AssemblerReturnLatency() { -+ // Estimated max. -+ return Add64Latency(false) + MultiPopLatency() + MultiPopFPULatency() + -+ Latency::BRANCH + Add64Latency() + 1 + DropAndRetLatency(); -+} -+ -+int TryInlineTruncateDoubleToILatency() { -+ return 2 + Latency::TRUNC_W_D + Latency::MOVF_FREG + 2 + AndLatency(false) + -+ Latency::BRANCH; -+} -+ -+int CallStubDelayedLatency() { return 1 + CallLatency(); } -+ -+int TruncateDoubleToIDelayedLatency() { -+ // TODO(riscv): This no longer reflects how TruncateDoubleToI is called. -+ return TryInlineTruncateDoubleToILatency() + 1 + Sub64Latency(false) + -+ StoreDoubleLatency() + CallStubDelayedLatency() + Add64Latency(false) + -+ 1; -+} -+ -+int CheckPageFlagLatency() { -+ return AndLatency(false) + AlignedMemoryLatency() + AndLatency(false) + -+ Latency::BRANCH; -+} -+ -+int SltuLatency(bool is_operand_register = true) { -+ if (is_operand_register) { -+ return 1; -+ } else { -+ return 2; // Estimated max. -+ } -+} -+ -+int BranchShortHelperLatency() { -+ return SltuLatency() + 2; // Estimated max. -+} -+ -+int BranchShortLatency() { return BranchShortHelperLatency(); } -+ -+int MoveLatency() { return 1; } -+ -+int MovToFloatParametersLatency() { return 2 * MoveLatency(); } -+ -+int MovFromFloatResultLatency() { return MoveLatency(); } -+ -+int AddOverflow64Latency() { -+ // Estimated max. -+ return 6; -+} -+ -+int SubOverflow64Latency() { -+ // Estimated max. -+ return 6; -+} -+ -+int MulOverflow32Latency() { -+ // Estimated max. -+ return Mul32Latency() + Mulh32Latency() + 2; -+} -+ -+// FIXME (RISCV): need update -+int Clz64Latency() { return 1; } -+ -+int Ctz32Latency() { -+ return Add64Latency(false) + XorLatency() + AndLatency() + Clz64Latency() + -+ 1 + Sub64Latency(); -+} -+ -+int Ctz64Latency() { -+ return Add64Latency(false) + XorLatency() + AndLatency() + 1 + Sub64Latency(); -+} -+ -+int Popcnt32Latency() { -+ return 2 + AndLatency() + Sub64Latency() + 1 + AndLatency() + 1 + -+ AndLatency() + Add64Latency() + 1 + Add64Latency() + 1 + AndLatency() + -+ 1 + Mul32Latency() + 1; -+} -+ -+int Popcnt64Latency() { -+ return 2 + AndLatency() + Sub64Latency() + 1 + AndLatency() + 1 + -+ AndLatency() + Add64Latency() + 1 + Add64Latency() + 1 + AndLatency() + -+ 1 + Mul64Latency() + 1; -+} -+ -+int CompareFLatency() { return Latency::C_cond_S; } -+ -+int CompareF32Latency() { return CompareFLatency(); } -+ -+int CompareF64Latency() { return CompareFLatency(); } -+ -+int CompareIsNanFLatency() { return CompareFLatency(); } -+ -+int CompareIsNanF32Latency() { return CompareIsNanFLatency(); } -+ -+int CompareIsNanF64Latency() { return CompareIsNanFLatency(); } -+ -+int NegsLatency() { -+ // Estimated. -+ return CompareIsNanF32Latency() + 2 * Latency::BRANCH + Latency::NEG_S + -+ Latency::MOVF_FREG + 1 + XorLatency() + Latency::MOVT_FREG; -+} -+ -+int NegdLatency() { -+ // Estimated. -+ return CompareIsNanF64Latency() + 2 * Latency::BRANCH + Latency::NEG_D + -+ Latency::MOVF_HIGH_DREG + 1 + XorLatency() + Latency::MOVT_DREG; -+} -+ -+int Float64RoundLatency() { -+ // For ceil_l_d, floor_l_d, round_l_d, trunc_l_d latency is 4. -+ return Latency::MOVF_HIGH_DREG + 1 + Latency::BRANCH + Latency::MOV_D + 4 + -+ Latency::MOVF_HIGH_DREG + Latency::BRANCH + Latency::CVT_D_L + 2 + -+ Latency::MOVT_HIGH_FREG; -+} -+ -+int Float32RoundLatency() { -+ // For ceil_w_s, floor_w_s, round_w_s, trunc_w_s latency is 4. -+ return Latency::MOVF_FREG + 1 + Latency::BRANCH + Latency::MOV_S + 4 + -+ Latency::MOVF_FREG + Latency::BRANCH + Latency::CVT_S_W + 2 + -+ Latency::MOVT_FREG; -+} -+ -+int Float32MaxLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF32Latency() + Latency::BRANCH; -+ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + -+ Latency::MOVF_FREG + 1 + Latency::MOV_S; -+} -+ -+int Float64MaxLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF64Latency() + Latency::BRANCH; -+ return latency + 5 * Latency::BRANCH + 2 * CompareF64Latency() + -+ Latency::MOVF_HIGH_DREG + Latency::MOV_D; -+} -+ -+int Float32MinLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF32Latency() + Latency::BRANCH; -+ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + -+ Latency::MOVF_FREG + 1 + Latency::MOV_S; -+} -+ -+int Float64MinLatency() { -+ // Estimated max. -+ int latency = CompareIsNanF64Latency() + Latency::BRANCH; -+ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + -+ Latency::MOVF_HIGH_DREG + Latency::MOV_D; -+} -+ -+int TruncLSLatency(bool load_status) { -+ int latency = Latency::TRUNC_L_S + Latency::MOVF_HIGH_DREG; -+ if (load_status) { -+ latency += SltuLatency() + 7; -+ } -+ return latency; -+} -+ -+int TruncLDLatency(bool load_status) { -+ int latency = Latency::TRUNC_L_D + Latency::MOVF_HIGH_DREG; -+ if (load_status) { -+ latency += SltuLatency() + 7; -+ } -+ return latency; -+} -+ -+int TruncUlSLatency() { -+ // Estimated max. -+ return 2 * CompareF32Latency() + CompareIsNanF32Latency() + -+ 4 * Latency::BRANCH + Latency::SUB_S + 2 * Latency::TRUNC_L_S + -+ 3 * Latency::MOVF_HIGH_DREG + OrLatency() + Latency::MOVT_FREG + -+ Latency::MOV_S + SltuLatency() + 4; -+} -+ -+int TruncUlDLatency() { -+ // Estimated max. -+ return 2 * CompareF64Latency() + CompareIsNanF64Latency() + -+ 4 * Latency::BRANCH + Latency::SUB_D + 2 * Latency::TRUNC_L_D + -+ 3 * Latency::MOVF_HIGH_DREG + OrLatency() + Latency::MOVT_DREG + -+ Latency::MOV_D + SltuLatency() + 4; -+} -+ -+int PushLatency() { return Add64Latency() + AlignedMemoryLatency(); } -+ -+int ByteSwapSignedLatency() { return 2; } -+ -+int LlLatency(int offset) { -+ bool is_one_instruction = is_int12(offset); -+ if (is_one_instruction) { -+ return 1; -+ } else { -+ return 3; -+ } -+} -+ -+int ExtractBitsLatency(bool sign_extend, int size) { -+ int latency = 2; -+ if (sign_extend) { -+ switch (size) { -+ case 8: -+ case 16: -+ case 32: -+ latency += 1; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+ return latency; -+} -+ -+int InsertBitsLatency() { return 2 + Sub64Latency(false) + 2; } -+ -+int ScLatency(int offset) { return 3; } -+ -+int Word32AtomicExchangeLatency(bool sign_extend, int size) { -+ return Add64Latency(false) + 1 + Sub64Latency() + 2 + LlLatency(0) + -+ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + -+ ScLatency(0) + BranchShortLatency() + 1; -+} -+ -+int Word32AtomicCompareExchangeLatency(bool sign_extend, int size) { -+ return 2 + Sub64Latency() + 2 + LlLatency(0) + -+ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + -+ ScLatency(0) + BranchShortLatency() + 1; -+} -+ -+int InstructionScheduler::GetInstructionLatency(const Instruction* instr) { -+ // FIXME(RISCV): Verify these latencies for RISC-V (currently using MIPS -+ // numbers) -+ switch (instr->arch_opcode()) { -+ case kArchCallCodeObject: -+ case kArchCallWasmFunction: -+ return CallLatency(); -+ case kArchTailCallCodeObjectFromJSFunction: -+ case kArchTailCallCodeObject: { -+ int latency = 0; -+ if (instr->arch_opcode() == kArchTailCallCodeObjectFromJSFunction) { -+ latency = AssemblePopArgumentsAdoptFrameLatency(); -+ } -+ return latency + JumpLatency(); -+ } -+ case kArchTailCallWasm: -+ case kArchTailCallAddress: -+ return JumpLatency(); -+ case kArchCallJSFunction: { -+ int latency = 0; -+ if (FLAG_debug_code) { -+ latency = 1 + AssertLatency(); -+ } -+ return latency + 1 + Add64Latency(false) + CallLatency(); -+ } -+ case kArchPrepareCallCFunction: -+ return PrepareCallCFunctionLatency(); -+ case kArchSaveCallerRegisters: { -+ auto fp_mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ return PushCallerSavedLatency(fp_mode); -+ } -+ case kArchRestoreCallerRegisters: { -+ auto fp_mode = -+ static_cast(MiscField::decode(instr->opcode())); -+ return PopCallerSavedLatency(fp_mode); -+ } -+ case kArchPrepareTailCall: -+ return 2; -+ case kArchCallCFunction: -+ return CallCFunctionLatency(); -+ case kArchJmp: -+ return AssembleArchJumpLatency(); -+ case kArchTableSwitch: -+ return AssembleArchTableSwitchLatency(); -+ case kArchAbortCSAAssert: -+ return CallLatency() + 1; -+ case kArchDebugBreak: -+ return 1; -+ case kArchComment: -+ case kArchNop: -+ case kArchThrowTerminator: -+ case kArchDeoptimize: -+ return 0; -+ case kArchRet: -+ return AssemblerReturnLatency(); -+ case kArchFramePointer: -+ return 1; -+ case kArchParentFramePointer: -+ // Estimated max. -+ return AlignedMemoryLatency(); -+ case kArchTruncateDoubleToI: -+ return TruncateDoubleToIDelayedLatency(); -+ case kArchStoreWithWriteBarrier: -+ return Add64Latency() + 1 + CheckPageFlagLatency(); -+ case kArchStackSlot: -+ // Estimated max. -+ return Add64Latency(false) + AndLatency(false) + AssertLatency() + -+ Add64Latency(false) + AndLatency(false) + BranchShortLatency() + -+ 1 + Sub64Latency() + Add64Latency(); -+ case kArchWordPoisonOnSpeculation: -+ return AndLatency(); -+ case kIeee754Float64Acos: -+ case kIeee754Float64Acosh: -+ case kIeee754Float64Asin: -+ case kIeee754Float64Asinh: -+ case kIeee754Float64Atan: -+ case kIeee754Float64Atanh: -+ case kIeee754Float64Atan2: -+ case kIeee754Float64Cos: -+ case kIeee754Float64Cosh: -+ case kIeee754Float64Cbrt: -+ case kIeee754Float64Exp: -+ case kIeee754Float64Expm1: -+ case kIeee754Float64Log: -+ case kIeee754Float64Log1p: -+ case kIeee754Float64Log10: -+ case kIeee754Float64Log2: -+ case kIeee754Float64Pow: -+ case kIeee754Float64Sin: -+ case kIeee754Float64Sinh: -+ case kIeee754Float64Tan: -+ case kIeee754Float64Tanh: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kRiscvAdd32: -+ case kRiscvAdd64: -+ return Add64Latency(instr->InputAt(1)->IsRegister()); -+ case kRiscvAddOvf64: -+ return AddOverflow64Latency(); -+ case kRiscvSub32: -+ case kRiscvSub64: -+ return Sub64Latency(instr->InputAt(1)->IsRegister()); -+ case kRiscvSubOvf64: -+ return SubOverflow64Latency(); -+ case kRiscvMul32: -+ return Mul32Latency(); -+ case kRiscvMulOvf32: -+ return MulOverflow32Latency(); -+ case kRiscvMulHigh32: -+ return Mulh32Latency(); -+ case kRiscvMulHighU32: -+ return Mulhu32Latency(); -+ case kRiscvMulHigh64: -+ return Mulh64Latency(); -+ case kRiscvDiv32: { -+ int latency = Div32Latency(instr->InputAt(1)->IsRegister()); -+ return latency + MovzLatency(); -+ } -+ case kRiscvDivU32: { -+ int latency = Divu32Latency(instr->InputAt(1)->IsRegister()); -+ return latency + MovzLatency(); -+ } -+ case kRiscvMod32: -+ return Mod32Latency(); -+ case kRiscvModU32: -+ return Modu32Latency(); -+ case kRiscvMul64: -+ return Mul64Latency(); -+ case kRiscvDiv64: { -+ int latency = Div64Latency(); -+ return latency + MovzLatency(); -+ } -+ case kRiscvDivU64: { -+ int latency = Divu64Latency(); -+ return latency + MovzLatency(); -+ } -+ case kRiscvMod64: -+ return Mod64Latency(); -+ case kRiscvModU64: -+ return Modu64Latency(); -+ case kRiscvAnd: -+ return AndLatency(instr->InputAt(1)->IsRegister()); -+ case kRiscvAnd32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = AndLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kRiscvOr: -+ return OrLatency(instr->InputAt(1)->IsRegister()); -+ case kRiscvOr32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = OrLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kRiscvNor: -+ return NorLatency(instr->InputAt(1)->IsRegister()); -+ case kRiscvNor32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = NorLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kRiscvXor: -+ return XorLatency(instr->InputAt(1)->IsRegister()); -+ case kRiscvXor32: { -+ bool is_operand_register = instr->InputAt(1)->IsRegister(); -+ int latency = XorLatency(is_operand_register); -+ if (is_operand_register) { -+ return latency + 2; -+ } else { -+ return latency + 1; -+ } -+ } -+ case kRiscvClz32: -+ case kRiscvClz64: -+ return Clz64Latency(); -+ case kRiscvCtz32: -+ return Ctz32Latency(); -+ case kRiscvCtz64: -+ return Ctz64Latency(); -+ case kRiscvPopcnt32: -+ return Popcnt32Latency(); -+ case kRiscvPopcnt64: -+ return Popcnt64Latency(); -+ case kRiscvShl32: -+ return 1; -+ case kRiscvShr32: -+ case kRiscvSar32: -+ case kRiscvZeroExtendWord: -+ return 2; -+ case kRiscvSignExtendWord: -+ case kRiscvShl64: -+ case kRiscvShr64: -+ case kRiscvSar64: -+ case kRiscvRor32: -+ case kRiscvRor64: -+ return 1; -+ case kRiscvTst: -+ return AndLatency(instr->InputAt(1)->IsRegister()); -+ case kRiscvMov: -+ return 1; -+ case kRiscvCmpS: -+ return MoveLatency() + CompareF32Latency(); -+ case kRiscvAddS: -+ return Latency::ADD_S; -+ case kRiscvSubS: -+ return Latency::SUB_S; -+ case kRiscvMulS: -+ return Latency::MUL_S; -+ case kRiscvDivS: -+ return Latency::DIV_S; -+ case kRiscvModS: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kRiscvAbsS: -+ return Latency::ABS_S; -+ case kRiscvNegS: -+ return NegdLatency(); -+ case kRiscvSqrtS: -+ return Latency::SQRT_S; -+ case kRiscvMaxS: -+ return Latency::MAX_S; -+ case kRiscvMinS: -+ return Latency::MIN_S; -+ case kRiscvCmpD: -+ return MoveLatency() + CompareF64Latency(); -+ case kRiscvAddD: -+ return Latency::ADD_D; -+ case kRiscvSubD: -+ return Latency::SUB_D; -+ case kRiscvMulD: -+ return Latency::MUL_D; -+ case kRiscvDivD: -+ return Latency::DIV_D; -+ case kRiscvModD: -+ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + -+ CallCFunctionLatency() + MovFromFloatResultLatency(); -+ case kRiscvAbsD: -+ return Latency::ABS_D; -+ case kRiscvNegD: -+ return NegdLatency(); -+ case kRiscvSqrtD: -+ return Latency::SQRT_D; -+ case kRiscvMaxD: -+ return Latency::MAX_D; -+ case kRiscvMinD: -+ return Latency::MIN_D; -+ case kRiscvFloat64RoundDown: -+ case kRiscvFloat64RoundTruncate: -+ case kRiscvFloat64RoundUp: -+ case kRiscvFloat64RoundTiesEven: -+ return Float64RoundLatency(); -+ case kRiscvFloat32RoundDown: -+ case kRiscvFloat32RoundTruncate: -+ case kRiscvFloat32RoundUp: -+ case kRiscvFloat32RoundTiesEven: -+ return Float32RoundLatency(); -+ case kRiscvFloat32Max: -+ return Float32MaxLatency(); -+ case kRiscvFloat64Max: -+ return Float64MaxLatency(); -+ case kRiscvFloat32Min: -+ return Float32MinLatency(); -+ case kRiscvFloat64Min: -+ return Float64MinLatency(); -+ case kRiscvFloat64SilenceNaN: -+ return Latency::SUB_D; -+ case kRiscvCvtSD: -+ return Latency::CVT_S_D; -+ case kRiscvCvtDS: -+ return Latency::CVT_D_S; -+ case kRiscvCvtDW: -+ return Latency::MOVT_FREG + Latency::CVT_D_W; -+ case kRiscvCvtSW: -+ return Latency::MOVT_FREG + Latency::CVT_S_W; -+ case kRiscvCvtSUw: -+ return 1 + Latency::MOVT_DREG + Latency::CVT_S_L; -+ case kRiscvCvtSL: -+ return Latency::MOVT_DREG + Latency::CVT_S_L; -+ case kRiscvCvtDL: -+ return Latency::MOVT_DREG + Latency::CVT_D_L; -+ case kRiscvCvtDUw: -+ return 1 + Latency::MOVT_DREG + Latency::CVT_D_L; -+ case kRiscvCvtDUl: -+ return 2 * Latency::BRANCH + 3 + 2 * Latency::MOVT_DREG + -+ 2 * Latency::CVT_D_L + Latency::ADD_D; -+ case kRiscvCvtSUl: -+ return 2 * Latency::BRANCH + 3 + 2 * Latency::MOVT_DREG + -+ 2 * Latency::CVT_S_L + Latency::ADD_S; -+ case kRiscvFloorWD: -+ return Latency::FLOOR_W_D + Latency::MOVF_FREG; -+ case kRiscvCeilWD: -+ return Latency::CEIL_W_D + Latency::MOVF_FREG; -+ case kRiscvRoundWD: -+ return Latency::ROUND_W_D + Latency::MOVF_FREG; -+ case kRiscvTruncWD: -+ return Latency::TRUNC_W_D + Latency::MOVF_FREG; -+ case kRiscvFloorWS: -+ return Latency::FLOOR_W_S + Latency::MOVF_FREG; -+ case kRiscvCeilWS: -+ return Latency::CEIL_W_S + Latency::MOVF_FREG; -+ case kRiscvRoundWS: -+ return Latency::ROUND_W_S + Latency::MOVF_FREG; -+ case kRiscvTruncWS: -+ return Latency::TRUNC_W_S + Latency::MOVF_FREG + 2 + MovnLatency(); -+ case kRiscvTruncLS: -+ return TruncLSLatency(instr->OutputCount() > 1); -+ case kRiscvTruncLD: -+ return TruncLDLatency(instr->OutputCount() > 1); -+ case kRiscvTruncUwD: -+ // Estimated max. -+ return CompareF64Latency() + 2 * Latency::BRANCH + -+ 2 * Latency::TRUNC_W_D + Latency::SUB_D + OrLatency() + -+ Latency::MOVT_FREG + Latency::MOVF_FREG + Latency::MOVT_HIGH_FREG + -+ 1; -+ case kRiscvTruncUwS: -+ // Estimated max. -+ return CompareF32Latency() + 2 * Latency::BRANCH + -+ 2 * Latency::TRUNC_W_S + Latency::SUB_S + OrLatency() + -+ Latency::MOVT_FREG + 2 * Latency::MOVF_FREG + 2 + MovzLatency(); -+ case kRiscvTruncUlS: -+ return TruncUlSLatency(); -+ case kRiscvTruncUlD: -+ return TruncUlDLatency(); -+ case kRiscvBitcastDL: -+ return Latency::MOVF_HIGH_DREG; -+ case kRiscvBitcastLD: -+ return Latency::MOVT_DREG; -+ case kRiscvFloat64ExtractLowWord32: -+ return Latency::MOVF_FREG; -+ case kRiscvFloat64InsertLowWord32: -+ return Latency::MOVF_HIGH_FREG + Latency::MOVT_FREG + -+ Latency::MOVT_HIGH_FREG; -+ case kRiscvFloat64ExtractHighWord32: -+ return Latency::MOVF_HIGH_FREG; -+ case kRiscvFloat64InsertHighWord32: -+ return Latency::MOVT_HIGH_FREG; -+ case kRiscvSignExtendByte: -+ case kRiscvSignExtendShort: -+ return 1; -+ case kRiscvLbu: -+ case kRiscvLb: -+ case kRiscvLhu: -+ case kRiscvLh: -+ case kRiscvLwu: -+ case kRiscvLw: -+ case kRiscvLd: -+ case kRiscvSb: -+ case kRiscvSh: -+ case kRiscvSw: -+ case kRiscvSd: -+ return AlignedMemoryLatency(); -+ case kRiscvLoadFloat: -+ return ULoadFloatLatency(); -+ case kRiscvLoadDouble: -+ return LoadDoubleLatency(); -+ case kRiscvStoreFloat: -+ return StoreFloatLatency(); -+ case kRiscvStoreDouble: -+ return StoreDoubleLatency(); -+ case kRiscvUlhu: -+ case kRiscvUlh: -+ return UlhuLatency(); -+ case kRiscvUlwu: -+ return UlwuLatency(); -+ case kRiscvUlw: -+ return UlwLatency(); -+ case kRiscvUld: -+ return UldLatency(); -+ case kRiscvULoadFloat: -+ return ULoadFloatLatency(); -+ case kRiscvULoadDouble: -+ return ULoadDoubleLatency(); -+ case kRiscvUsh: -+ return UshLatency(); -+ case kRiscvUsw: -+ return UswLatency(); -+ case kRiscvUsd: -+ return UsdLatency(); -+ case kRiscvUStoreFloat: -+ return UStoreFloatLatency(); -+ case kRiscvUStoreDouble: -+ return UStoreDoubleLatency(); -+ case kRiscvPush: { -+ int latency = 0; -+ if (instr->InputAt(0)->IsFPRegister()) { -+ latency = StoreDoubleLatency() + Sub64Latency(false); -+ } else { -+ latency = PushLatency(); -+ } -+ return latency; -+ } -+ case kRiscvPeek: { -+ int latency = 0; -+ if (instr->OutputAt(0)->IsFPRegister()) { -+ auto op = LocationOperand::cast(instr->OutputAt(0)); -+ switch (op->representation()) { -+ case MachineRepresentation::kFloat64: -+ latency = LoadDoubleLatency(); -+ break; -+ case MachineRepresentation::kFloat32: -+ latency = Latency::LOAD_FLOAT; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } else { -+ latency = AlignedMemoryLatency(); -+ } -+ return latency; -+ } -+ case kRiscvStackClaim: -+ return Sub64Latency(false); -+ case kRiscvStoreToStackSlot: { -+ int latency = 0; -+ if (instr->InputAt(0)->IsFPRegister()) { -+ if (instr->InputAt(0)->IsSimd128Register()) { -+ latency = 1; // Estimated value. -+ } else { -+ latency = StoreDoubleLatency(); -+ } -+ } else { -+ latency = AlignedMemoryLatency(); -+ } -+ return latency; -+ } -+ case kRiscvByteSwap64: -+ return ByteSwapSignedLatency(); -+ case kRiscvByteSwap32: -+ return ByteSwapSignedLatency(); -+ case kWord32AtomicLoadInt8: -+ case kWord32AtomicLoadUint8: -+ case kWord32AtomicLoadInt16: -+ case kWord32AtomicLoadUint16: -+ case kWord32AtomicLoadWord32: -+ return 2; -+ case kWord32AtomicStoreWord8: -+ case kWord32AtomicStoreWord16: -+ case kWord32AtomicStoreWord32: -+ return 3; -+ case kWord32AtomicExchangeInt8: -+ return Word32AtomicExchangeLatency(true, 8); -+ case kWord32AtomicExchangeUint8: -+ return Word32AtomicExchangeLatency(false, 8); -+ case kWord32AtomicExchangeInt16: -+ return Word32AtomicExchangeLatency(true, 16); -+ case kWord32AtomicExchangeUint16: -+ return Word32AtomicExchangeLatency(false, 16); -+ case kWord32AtomicExchangeWord32: -+ return 2 + LlLatency(0) + 1 + ScLatency(0) + BranchShortLatency() + 1; -+ case kWord32AtomicCompareExchangeInt8: -+ return Word32AtomicCompareExchangeLatency(true, 8); -+ case kWord32AtomicCompareExchangeUint8: -+ return Word32AtomicCompareExchangeLatency(false, 8); -+ case kWord32AtomicCompareExchangeInt16: -+ return Word32AtomicCompareExchangeLatency(true, 16); -+ case kWord32AtomicCompareExchangeUint16: -+ return Word32AtomicCompareExchangeLatency(false, 16); -+ case kWord32AtomicCompareExchangeWord32: -+ return 3 + LlLatency(0) + BranchShortLatency() + 1 + ScLatency(0) + -+ BranchShortLatency() + 1; -+ case kRiscvAssertEqual: -+ return AssertLatency(); -+ default: -+ return 1; -+ } -+} -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-selector-riscv64.cc -@@ -0,0 +1,2985 @@ -+// Copyright 2014 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/base/bits.h" -+#include "src/compiler/backend/instruction-selector-impl.h" -+#include "src/compiler/node-matchers.h" -+#include "src/compiler/node-properties.h" -+ -+namespace v8 { -+namespace internal { -+namespace compiler { -+ -+#define TRACE_UNIMPL() \ -+ PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) -+ -+#define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) -+ -+// Adds RISC-V-specific methods for generating InstructionOperands. -+class RiscvOperandGenerator final : public OperandGenerator { -+ public: -+ explicit RiscvOperandGenerator(InstructionSelector* selector) -+ : OperandGenerator(selector) {} -+ -+ InstructionOperand UseOperand(Node* node, InstructionCode opcode) { -+ if (CanBeImmediate(node, opcode)) { -+ return UseImmediate(node); -+ } -+ return UseRegister(node); -+ } -+ -+ // Use the zero register if the node has the immediate value zero, otherwise -+ // assign a register. -+ InstructionOperand UseRegisterOrImmediateZero(Node* node) { -+ if ((IsIntegerConstant(node) && (GetIntegerConstantValue(node) == 0)) || -+ (IsFloatConstant(node) && -+ (bit_cast(GetFloatConstantValue(node)) == 0))) { -+ return UseImmediate(node); -+ } -+ return UseRegister(node); -+ } -+ -+ bool IsIntegerConstant(Node* node) { -+ return (node->opcode() == IrOpcode::kInt32Constant) || -+ (node->opcode() == IrOpcode::kInt64Constant); -+ } -+ -+ int64_t GetIntegerConstantValue(Node* node) { -+ if (node->opcode() == IrOpcode::kInt32Constant) { -+ return OpParameter(node->op()); -+ } -+ DCHECK_EQ(IrOpcode::kInt64Constant, node->opcode()); -+ return OpParameter(node->op()); -+ } -+ -+ bool IsFloatConstant(Node* node) { -+ return (node->opcode() == IrOpcode::kFloat32Constant) || -+ (node->opcode() == IrOpcode::kFloat64Constant); -+ } -+ -+ double GetFloatConstantValue(Node* node) { -+ if (node->opcode() == IrOpcode::kFloat32Constant) { -+ return OpParameter(node->op()); -+ } -+ DCHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); -+ return OpParameter(node->op()); -+ } -+ -+ bool CanBeImmediate(Node* node, InstructionCode mode) { -+ return IsIntegerConstant(node) && -+ CanBeImmediate(GetIntegerConstantValue(node), mode); -+ } -+ -+ bool CanBeImmediate(int64_t value, InstructionCode opcode) { -+ switch (ArchOpcodeField::decode(opcode)) { -+ case kRiscvShl32: -+ case kRiscvSar32: -+ case kRiscvShr32: -+ return is_uint5(value); -+ case kRiscvShl64: -+ case kRiscvSar64: -+ case kRiscvShr64: -+ return is_uint6(value); -+ case kRiscvAdd32: -+ case kRiscvAnd32: -+ case kRiscvAnd: -+ case kRiscvAdd64: -+ case kRiscvOr32: -+ case kRiscvOr: -+ case kRiscvTst: -+ case kRiscvXor: -+ return is_int12(value); -+ case kRiscvLb: -+ case kRiscvLbu: -+ case kRiscvSb: -+ case kRiscvLh: -+ case kRiscvLhu: -+ case kRiscvSh: -+ case kRiscvLw: -+ case kRiscvSw: -+ case kRiscvLd: -+ case kRiscvSd: -+ case kRiscvLoadFloat: -+ case kRiscvStoreFloat: -+ case kRiscvLoadDouble: -+ case kRiscvStoreDouble: -+ return is_int32(value); -+ default: -+ return is_int12(value); -+ } -+ } -+ -+ private: -+ bool ImmediateFitsAddrMode1Instruction(int32_t imm) const { -+ TRACE_UNIMPL(); -+ return false; -+ } -+}; -+ -+static void VisitRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+static void VisitRRI(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ int32_t imm = OpParameter(node->op()); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm)); -+} -+ -+static void VisitSimdShift(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ if (g.IsIntegerConstant(node->InputAt(1))) { -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseImmediate(node->InputAt(1))); -+ } else { -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+ } -+} -+ -+static void VisitRRIR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ int32_t imm = OpParameter(node->op()); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm), -+ g.UseRegister(node->InputAt(1))); -+} -+ -+static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+} -+ -+static void VisitUniqueRRR(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseUniqueRegister(node->InputAt(0)), -+ g.UseUniqueRegister(node->InputAt(1))); -+} -+ -+void VisitRRRR(InstructionSelector* selector, ArchOpcode opcode, Node* node) { -+ RiscvOperandGenerator g(selector); -+ selector->Emit( -+ opcode, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(2))); -+} -+ -+static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode, -+ Node* node) { -+ RiscvOperandGenerator g(selector); -+ selector->Emit(opcode, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), -+ g.UseOperand(node->InputAt(1), opcode)); -+} -+ -+struct ExtendingLoadMatcher { -+ ExtendingLoadMatcher(Node* node, InstructionSelector* selector) -+ : matches_(false), selector_(selector), base_(nullptr), immediate_(0) { -+ Initialize(node); -+ } -+ -+ bool Matches() const { return matches_; } -+ -+ Node* base() const { -+ DCHECK(Matches()); -+ return base_; -+ } -+ int64_t immediate() const { -+ DCHECK(Matches()); -+ return immediate_; -+ } -+ ArchOpcode opcode() const { -+ DCHECK(Matches()); -+ return opcode_; -+ } -+ -+ private: -+ bool matches_; -+ InstructionSelector* selector_; -+ Node* base_; -+ int64_t immediate_; -+ ArchOpcode opcode_; -+ -+ void Initialize(Node* node) { -+ Int64BinopMatcher m(node); -+ // When loading a 64-bit value and shifting by 32, we should -+ // just load and sign-extend the interesting 4 bytes instead. -+ // This happens, for example, when we're loading and untagging SMIs. -+ DCHECK(m.IsWord64Sar()); -+ if (m.left().IsLoad() && m.right().Is(32) && -+ selector_->CanCover(m.node(), m.left().node())) { -+ DCHECK_EQ(selector_->GetEffectLevel(node), -+ selector_->GetEffectLevel(m.left().node())); -+ MachineRepresentation rep = -+ LoadRepresentationOf(m.left().node()->op()).representation(); -+ DCHECK_EQ(3, ElementSizeLog2Of(rep)); -+ if (rep != MachineRepresentation::kTaggedSigned && -+ rep != MachineRepresentation::kTaggedPointer && -+ rep != MachineRepresentation::kTagged && -+ rep != MachineRepresentation::kWord64) { -+ return; -+ } -+ -+ RiscvOperandGenerator g(selector_); -+ Node* load = m.left().node(); -+ Node* offset = load->InputAt(1); -+ base_ = load->InputAt(0); -+ opcode_ = kRiscvLw; -+ if (g.CanBeImmediate(offset, opcode_)) { -+#if defined(V8_TARGET_LITTLE_ENDIAN) -+ immediate_ = g.GetIntegerConstantValue(offset) + 4; -+#elif defined(V8_TARGET_BIG_ENDIAN) -+ immediate_ = g.GetIntegerConstantValue(offset); -+#endif -+ matches_ = g.CanBeImmediate(immediate_, kRiscvLw); -+ } -+ } -+ } -+}; -+ -+bool TryEmitExtendingLoad(InstructionSelector* selector, Node* node, -+ Node* output_node) { -+ ExtendingLoadMatcher m(node, selector); -+ RiscvOperandGenerator g(selector); -+ if (m.Matches()) { -+ InstructionOperand inputs[2]; -+ inputs[0] = g.UseRegister(m.base()); -+ InstructionCode opcode = -+ m.opcode() | AddressingModeField::encode(kMode_MRI); -+ DCHECK(is_int32(m.immediate())); -+ inputs[1] = g.TempImmediate(static_cast(m.immediate())); -+ InstructionOperand outputs[] = {g.DefineAsRegister(output_node)}; -+ selector->Emit(opcode, arraysize(outputs), outputs, arraysize(inputs), -+ inputs); -+ return true; -+ } -+ return false; -+} -+ -+bool TryMatchImmediate(InstructionSelector* selector, -+ InstructionCode* opcode_return, Node* node, -+ size_t* input_count_return, InstructionOperand* inputs) { -+ RiscvOperandGenerator g(selector); -+ if (g.CanBeImmediate(node, *opcode_return)) { -+ *opcode_return |= AddressingModeField::encode(kMode_MRI); -+ inputs[0] = g.UseImmediate(node); -+ *input_count_return = 1; -+ return true; -+ } -+ return false; -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, bool has_reverse_opcode, -+ InstructionCode reverse_opcode, -+ FlagsContinuation* cont) { -+ RiscvOperandGenerator g(selector); -+ Int32BinopMatcher m(node); -+ InstructionOperand inputs[2]; -+ size_t input_count = 0; -+ InstructionOperand outputs[1]; -+ size_t output_count = 0; -+ -+ if (TryMatchImmediate(selector, &opcode, m.right().node(), &input_count, -+ &inputs[1])) { -+ inputs[0] = g.UseRegister(m.left().node()); -+ input_count++; -+ } else if (has_reverse_opcode && -+ TryMatchImmediate(selector, &reverse_opcode, m.left().node(), -+ &input_count, &inputs[1])) { -+ inputs[0] = g.UseRegister(m.right().node()); -+ opcode = reverse_opcode; -+ input_count++; -+ } else { -+ inputs[input_count++] = g.UseRegister(m.left().node()); -+ inputs[input_count++] = g.UseOperand(m.right().node(), opcode); -+ } -+ -+ if (cont->IsDeoptimize()) { -+ // If we can deoptimize as a result of the binop, we need to make sure that -+ // the deopt inputs are not overwritten by the binop result. One way -+ // to achieve that is to declare the output register as same-as-first. -+ outputs[output_count++] = g.DefineSameAsFirst(node); -+ } else { -+ outputs[output_count++] = g.DefineAsRegister(node); -+ } -+ -+ DCHECK_NE(0u, input_count); -+ DCHECK_EQ(1u, output_count); -+ DCHECK_GE(arraysize(inputs), input_count); -+ DCHECK_GE(arraysize(outputs), output_count); -+ -+ selector->EmitWithContinuation(opcode, output_count, outputs, input_count, -+ inputs, cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, bool has_reverse_opcode, -+ InstructionCode reverse_opcode) { -+ FlagsContinuation cont; -+ VisitBinop(selector, node, opcode, has_reverse_opcode, reverse_opcode, &cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont) { -+ VisitBinop(selector, node, opcode, false, kArchNop, cont); -+} -+ -+static void VisitBinop(InstructionSelector* selector, Node* node, -+ InstructionCode opcode) { -+ VisitBinop(selector, node, opcode, false, kArchNop); -+} -+ -+void InstructionSelector::VisitStackSlot(Node* node) { -+ StackSlotRepresentation rep = StackSlotRepresentationOf(node->op()); -+ int alignment = rep.alignment(); -+ int slot = frame_->AllocateSpillSlot(rep.size(), alignment); -+ OperandGenerator g(this); -+ -+ Emit(kArchStackSlot, g.DefineAsRegister(node), -+ sequence()->AddImmediate(Constant(slot)), -+ sequence()->AddImmediate(Constant(alignment)), 0, nullptr); -+} -+ -+void InstructionSelector::VisitAbortCSAAssert(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), a0)); -+} -+ -+void EmitLoad(InstructionSelector* selector, Node* node, InstructionCode opcode, -+ Node* output = nullptr) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(output == nullptr ? node : output), -+ g.UseRegister(base), g.UseImmediate(index)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), -+ addr_reg, g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired load opcode, using temp addr_reg. -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(output == nullptr ? node : output), -+ addr_reg, g.TempImmediate(0)); -+ } -+} -+ -+void InstructionSelector::VisitLoadTransform(Node* node) { -+ LoadTransformParameters params = LoadTransformParametersOf(node->op()); -+ -+ InstructionCode opcode = kArchNop; -+ switch (params.transformation) { -+ case LoadTransformation::kS8x16LoadSplat: -+ opcode = kRiscvS8x16LoadSplat; -+ break; -+ case LoadTransformation::kS16x8LoadSplat: -+ opcode = kRiscvS16x8LoadSplat; -+ break; -+ case LoadTransformation::kS32x4LoadSplat: -+ opcode = kRiscvS32x4LoadSplat; -+ break; -+ case LoadTransformation::kS64x2LoadSplat: -+ opcode = kRiscvS64x2LoadSplat; -+ break; -+ case LoadTransformation::kI16x8Load8x8S: -+ opcode = kRiscvI16x8Load8x8S; -+ break; -+ case LoadTransformation::kI16x8Load8x8U: -+ opcode = kRiscvI16x8Load8x8U; -+ break; -+ case LoadTransformation::kI32x4Load16x4S: -+ opcode = kRiscvI32x4Load16x4S; -+ break; -+ case LoadTransformation::kI32x4Load16x4U: -+ opcode = kRiscvI32x4Load16x4U; -+ break; -+ case LoadTransformation::kI64x2Load32x2S: -+ opcode = kRiscvI64x2Load32x2S; -+ break; -+ case LoadTransformation::kI64x2Load32x2U: -+ opcode = kRiscvI64x2Load32x2U; -+ break; -+ default: -+ UNIMPLEMENTED(); -+ } -+ -+ EmitLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ -+ InstructionCode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kFloat32: -+ opcode = kRiscvLoadFloat; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kRiscvLoadDouble; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = load_rep.IsUnsigned() ? kRiscvLbu : kRiscvLb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kRiscvLhu : kRiscvLh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = load_rep.IsUnsigned() ? kRiscvLwu : kRiscvLw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvLd; -+ break; -+ case MachineRepresentation::kSimd128: -+ opcode = kRiscvMsaLd; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ UNREACHABLE(); -+ } -+ if (node->opcode() == IrOpcode::kPoisonedLoad) { -+ CHECK_NE(poisoning_level_, PoisoningMitigationLevel::kDontPoison); -+ opcode |= MiscField::encode(kMemoryAccessPoisoned); -+ } -+ -+ EmitLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitPoisonedLoad(Node* node) { VisitLoad(node); } -+ -+void InstructionSelector::VisitProtectedLoad(Node* node) { -+ // TODO(eholk) -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitStore(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ StoreRepresentation store_rep = StoreRepresentationOf(node->op()); -+ WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); -+ MachineRepresentation rep = store_rep.representation(); -+ -+ // TODO(riscv): I guess this could be done in a better way. -+ if (write_barrier_kind != kNoWriteBarrier && -+ V8_LIKELY(!FLAG_disable_write_barriers)) { -+ DCHECK(CanBeTaggedPointer(rep)); -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ RecordWriteMode record_write_mode = -+ WriteBarrierKindToRecordWriteMode(write_barrier_kind); -+ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; -+ size_t const temp_count = arraysize(temps); -+ InstructionCode code = kArchStoreWithWriteBarrier; -+ code |= MiscField::encode(static_cast(record_write_mode)); -+ Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); -+ } else { -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kFloat32: -+ opcode = kRiscvStoreFloat; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kRiscvStoreDouble; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = kRiscvSb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kRiscvSh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kRiscvSw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvSd; -+ break; -+ case MachineRepresentation::kSimd128: -+ opcode = kRiscvMsaSt; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ UNREACHABLE(); -+ return; -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, -+ g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired store opcode, using temp addr_reg. -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); -+ } -+ } -+} -+ -+void InstructionSelector::VisitProtectedStore(Node* node) { -+ // TODO(eholk) -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitWord32And(Node* node) { -+ VisitBinop(this, node, kRiscvAnd32, true, kRiscvAnd32); -+} -+ -+void InstructionSelector::VisitWord64And(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ if (m.left().IsWord64Shr() && CanCover(node, m.left().node()) && -+ m.right().HasValue()) { -+ uint64_t mask = m.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { -+ // The mask must be contiguous, and occupy the least-significant bits. -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); -+ -+ // Select Dext for And(Shr(x, imm), mask) where the mask is in the least -+ // significant bits. -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue()) { -+ // Any shift value can match; int64 shifts use `value % 64`. -+ uint32_t lsb = static_cast(mleft.right().Value() & 0x3F); -+ -+ // Dext cannot extract bits past the register size, however since -+ // shifting the original value would have introduced some zeros we can -+ // still use Dext with a smaller mask and the remaining bits will be -+ // zeros. -+ if (lsb + mask_width > 64) mask_width = 64 - lsb; -+ -+ if (lsb == 0 && mask_width == 64) { -+ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(mleft.left().node())); -+ return; -+ } -+ } -+ // Other cases fall through to the normal And operation. -+ } -+ } -+ VisitBinop(this, node, kRiscvAnd, true, kRiscvAnd); -+} -+ -+void InstructionSelector::VisitWord32Or(Node* node) { -+ VisitBinop(this, node, kRiscvOr32, true, kRiscvOr32); -+} -+ -+void InstructionSelector::VisitWord64Or(Node* node) { -+ VisitBinop(this, node, kRiscvOr, true, kRiscvOr); -+} -+ -+void InstructionSelector::VisitWord32Xor(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32Or() && CanCover(node, m.left().node()) && -+ m.right().Is(-1)) { -+ Int32BinopMatcher mleft(m.left().node()); -+ if (!mleft.right().HasValue()) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvNor32, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(mleft.right().node())); -+ return; -+ } -+ } -+ if (m.right().Is(-1)) { -+ // Use Nor for bit negation and eliminate constant loading for xori. -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvNor32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0)); -+ return; -+ } -+ VisitBinop(this, node, kRiscvXor32, true, kRiscvXor32); -+} -+ -+void InstructionSelector::VisitWord64Xor(Node* node) { -+ Int64BinopMatcher m(node); -+ if (m.left().IsWord64Or() && CanCover(node, m.left().node()) && -+ m.right().Is(-1)) { -+ Int64BinopMatcher mleft(m.left().node()); -+ if (!mleft.right().HasValue()) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvNor, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseRegister(mleft.right().node())); -+ return; -+ } -+ } -+ if (m.right().Is(-1)) { -+ // Use Nor for bit negation and eliminate constant loading for xori. -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(0)); -+ return; -+ } -+ VisitBinop(this, node, kRiscvXor, true, kRiscvXor); -+} -+ -+void InstructionSelector::VisitWord32Shl(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32And() && CanCover(node, m.left().node()) && -+ m.right().IsInRange(1, 31)) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher mleft(m.left().node()); -+ // Match Word32Shl(Word32And(x, mask), imm) to Shl where the mask is -+ // contiguous, and the shift immediate non-zero. -+ if (mleft.right().HasValue()) { -+ uint32_t mask = mleft.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { -+ uint32_t shift = m.right().Value(); -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); -+ DCHECK_NE(0u, shift); -+ if ((shift + mask_width) >= 32) { -+ // If the mask is contiguous and reaches or extends beyond the top -+ // bit, only the shift is needed. -+ Emit(kRiscvShl32, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ } -+ } -+ VisitRRO(this, kRiscvShl32, node); -+} -+ -+void InstructionSelector::VisitWord32Shr(Node* node) { -+ VisitRRO(this, kRiscvShr32, node); -+} -+ -+void InstructionSelector::VisitWord32Sar(Node* node) { -+ Int32BinopMatcher m(node); -+ if (m.left().IsWord32Shl() && CanCover(node, m.left().node())) { -+ Int32BinopMatcher mleft(m.left().node()); -+ if (m.right().HasValue() && mleft.right().HasValue()) { -+ RiscvOperandGenerator g(this); -+ uint32_t sar = m.right().Value(); -+ uint32_t shl = mleft.right().Value(); -+ if ((sar == shl) && (sar == 16)) { -+ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node())); -+ return; -+ } else if ((sar == shl) && (sar == 24)) { -+ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node())); -+ return; -+ } else if ((sar == shl) && (sar == 32)) { -+ Emit(kRiscvShl32, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), g.TempImmediate(0)); -+ return; -+ } -+ } -+ } -+ VisitRRO(this, kRiscvSar32, node); -+} -+ -+void InstructionSelector::VisitWord64Shl(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && -+ m.right().IsInRange(32, 63) && CanCover(node, m.left().node())) { -+ // There's no need to sign/zero-extend to 64-bit if we shift out the upper -+ // 32 bits anyway. -+ Emit(kRiscvShl64, g.DefineSameAsFirst(node), -+ g.UseRegister(m.left().node()->InputAt(0)), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ if (m.left().IsWord64And() && CanCover(node, m.left().node()) && -+ m.right().IsInRange(1, 63)) { -+ // Match Word64Shl(Word64And(x, mask), imm) to Dshl where the mask is -+ // contiguous, and the shift immediate non-zero. -+ Int64BinopMatcher mleft(m.left().node()); -+ if (mleft.right().HasValue()) { -+ uint64_t mask = mleft.right().Value(); -+ uint32_t mask_width = base::bits::CountPopulation(mask); -+ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); -+ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { -+ uint64_t shift = m.right().Value(); -+ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); -+ DCHECK_NE(0u, shift); -+ -+ if ((shift + mask_width) >= 64) { -+ // If the mask is contiguous and reaches or extends beyond the top -+ // bit, only the shift is needed. -+ Emit(kRiscvShl64, g.DefineAsRegister(node), -+ g.UseRegister(mleft.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ } -+ } -+ VisitRRO(this, kRiscvShl64, node); -+} -+ -+void InstructionSelector::VisitWord64Shr(Node* node) { -+ VisitRRO(this, kRiscvShr64, node); -+} -+ -+void InstructionSelector::VisitWord64Sar(Node* node) { -+ if (TryEmitExtendingLoad(this, node, node)) return; -+ VisitRRO(this, kRiscvSar64, node); -+} -+ -+void InstructionSelector::VisitWord32Rol(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64Rol(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord32Ror(Node* node) { -+ VisitRRO(this, kRiscvRor32, node); -+} -+ -+void InstructionSelector::VisitWord32Clz(Node* node) { -+ VisitRR(this, kRiscvClz32, node); -+} -+ -+void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); } -+ -+void InstructionSelector::VisitWord64ReverseBytes(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvByteSwap64, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord32ReverseBytes(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvByteSwap32, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSimd128ReverseBytes(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitWord32Ctz(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvCtz32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Ctz(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvCtz64, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord32Popcnt(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvPopcnt32, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Popcnt(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvPopcnt64, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitWord64Ror(Node* node) { -+ VisitRRO(this, kRiscvRor64, node); -+} -+ -+void InstructionSelector::VisitWord64Clz(Node* node) { -+ VisitRR(this, kRiscvClz64, node); -+} -+ -+void InstructionSelector::VisitInt32Add(Node* node) { -+ VisitBinop(this, node, kRiscvAdd32, true, kRiscvAdd32); -+} -+ -+void InstructionSelector::VisitInt64Add(Node* node) { -+ VisitBinop(this, node, kRiscvAdd64, true, kRiscvAdd64); -+} -+ -+void InstructionSelector::VisitInt32Sub(Node* node) { -+ VisitBinop(this, node, kRiscvSub32); -+} -+ -+void InstructionSelector::VisitInt64Sub(Node* node) { -+ VisitBinop(this, node, kRiscvSub64); -+} -+ -+void InstructionSelector::VisitInt32Mul(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ if (m.right().HasValue() && m.right().Value() > 0) { -+ uint32_t value = static_cast(m.right().Value()); -+ if (base::bits::IsPowerOfTwo(value)) { -+ Emit(kRiscvShl32 | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value + 1)) { -+ InstructionOperand temp = g.TempRegister(); -+ Emit(kRiscvShl32 | AddressingModeField::encode(kMode_None), temp, -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); -+ Emit(kRiscvSub32 | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); -+ return; -+ } -+ } -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher leftInput(left), rightInput(right); -+ if (leftInput.right().Is(32) && rightInput.right().Is(32)) { -+ // Combine untagging shifts with Dmul high. -+ Emit(kRiscvMulHigh64, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ VisitRRR(this, kRiscvMul32, node); -+} -+ -+void InstructionSelector::VisitInt32MulHigh(Node* node) { -+ VisitRRR(this, kRiscvMulHigh32, node); -+} -+ -+void InstructionSelector::VisitUint32MulHigh(Node* node) { -+ VisitRRR(this, kRiscvMulHighU32, node); -+} -+ -+void InstructionSelector::VisitInt64Mul(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ // TODO(dusmil): Add optimization for shifts larger than 32. -+ if (m.right().HasValue() && m.right().Value() > 0) { -+ uint32_t value = static_cast(m.right().Value()); -+ if (base::bits::IsPowerOfTwo(value)) { -+ Emit(kRiscvShl64 | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); -+ return; -+ } -+ if (base::bits::IsPowerOfTwo(value + 1)) { -+ InstructionOperand temp = g.TempRegister(); -+ Emit(kRiscvShl64 | AddressingModeField::encode(kMode_None), temp, -+ g.UseRegister(m.left().node()), -+ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); -+ Emit(kRiscvSub64 | AddressingModeField::encode(kMode_None), -+ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); -+ return; -+ } -+ } -+ Emit(kRiscvMul64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt32Div(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher rightInput(right), leftInput(left); -+ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { -+ // Combine both shifted operands with Ddiv. -+ Emit(kRiscvDiv64, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ Emit(kRiscvDiv32, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint32Div(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Emit(kRiscvDivU32, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt32Mod(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ if (CanCover(node, left) && CanCover(node, right)) { -+ if (left->opcode() == IrOpcode::kWord64Sar && -+ right->opcode() == IrOpcode::kWord64Sar) { -+ Int64BinopMatcher rightInput(right), leftInput(left); -+ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { -+ // Combine both shifted operands with Dmod. -+ Emit(kRiscvMod64, g.DefineSameAsFirst(node), -+ g.UseRegister(leftInput.left().node()), -+ g.UseRegister(rightInput.left().node())); -+ return; -+ } -+ } -+ } -+ Emit(kRiscvMod32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint32Mod(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int32BinopMatcher m(node); -+ Emit(kRiscvModU32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt64Div(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kRiscvDiv64, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint64Div(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kRiscvDivU64, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitInt64Mod(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kRiscvMod64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitUint64Mod(Node* node) { -+ RiscvOperandGenerator g(this); -+ Int64BinopMatcher m(node); -+ Emit(kRiscvModU64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), -+ g.UseRegister(m.right().node())); -+} -+ -+void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDS, node); -+} -+ -+void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) { -+ VisitRR(this, kRiscvCvtSW, node); -+} -+ -+void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) { -+ VisitRR(this, kRiscvCvtSUw, node); -+} -+ -+void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDW, node); -+} -+ -+void InstructionSelector::VisitChangeInt64ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDL, node); -+} -+ -+void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDUw, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat32ToInt32(Node* node) { -+ VisitRR(this, kRiscvTruncWS, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat32ToUint32(Node* node) { -+ VisitRR(this, kRiscvTruncUwS, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ // Match ChangeFloat64ToInt32(Float64Round##OP) to corresponding instruction -+ // which does rounding and conversion to integer format. -+ if (CanCover(node, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kFloat64RoundDown: -+ Emit(kRiscvFloorWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundUp: -+ Emit(kRiscvCeilWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundTiesEven: -+ Emit(kRiscvRoundWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ case IrOpcode::kFloat64RoundTruncate: -+ Emit(kRiscvTruncWD, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ default: -+ break; -+ } -+ if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) { -+ Node* next = value->InputAt(0); -+ if (CanCover(value, next)) { -+ // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP)) -+ switch (next->opcode()) { -+ case IrOpcode::kFloat32RoundDown: -+ Emit(kRiscvFloorWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundUp: -+ Emit(kRiscvCeilWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundTiesEven: -+ Emit(kRiscvRoundWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ case IrOpcode::kFloat32RoundTruncate: -+ Emit(kRiscvTruncWS, g.DefineAsRegister(node), -+ g.UseRegister(next->InputAt(0))); -+ return; -+ default: -+ Emit(kRiscvTruncWS, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ } else { -+ // Match float32 -> float64 -> int32 representation change path. -+ Emit(kRiscvTruncWS, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ } -+ } -+ VisitRR(this, kRiscvTruncWD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) { -+ VisitRR(this, kRiscvTruncLD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { -+ VisitRR(this, kRiscvTruncUwD, node); -+} -+ -+void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) { -+ VisitRR(this, kRiscvTruncUlD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToUint32(Node* node) { -+ VisitRR(this, kRiscvTruncUwD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToInt64(Node* node) { -+ VisitRR(this, kRiscvTruncLD, node); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) { -+ RiscvOperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ this->Emit(kRiscvTruncLS, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat64ToInt64(Node* node) { -+ RiscvOperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kRiscvTruncLD, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat32ToUint64(Node* node) { -+ RiscvOperandGenerator g(this); -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kRiscvTruncUlS, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) { -+ RiscvOperandGenerator g(this); -+ -+ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; -+ InstructionOperand outputs[2]; -+ size_t output_count = 0; -+ outputs[output_count++] = g.DefineAsRegister(node); -+ -+ Node* success_output = NodeProperties::FindProjection(node, 1); -+ if (success_output) { -+ outputs[output_count++] = g.DefineAsRegister(success_output); -+ } -+ -+ Emit(kRiscvTruncUlD, output_count, outputs, 1, inputs); -+} -+ -+void InstructionSelector::VisitBitcastWord32ToWord64(Node* node) { -+ UNIMPLEMENTED(); -+} -+ -+void InstructionSelector::VisitChangeInt32ToInt64(Node* node) { -+ Node* value = node->InputAt(0); -+ if (value->opcode() == IrOpcode::kLoad && CanCover(node, value)) { -+ // Generate sign-extending load. -+ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); -+ InstructionCode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ opcode = load_rep.IsUnsigned() ? kRiscvLbu : kRiscvLb; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kRiscvLhu : kRiscvLh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kRiscvLw; -+ break; -+ default: -+ UNREACHABLE(); -+ return; -+ } -+ EmitLoad(this, value, opcode, node); -+ } else { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvShl32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0)); -+ } -+} -+ -+void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ switch (value->opcode()) { -+ case IrOpcode::kLoad: { -+ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); -+ if (load_rep.IsUnsigned()) { -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ case MachineRepresentation::kWord16: -+ case MachineRepresentation::kWord32: -+ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ } -+ default: -+ break; -+ } -+ Emit(kRiscvZeroExtendWord, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ if (CanCover(node, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kWord64Sar: { -+ if (CanCover(value, value->InputAt(0)) && -+ TryEmitExtendingLoad(this, value, node)) { -+ return; -+ } else { -+ Int64BinopMatcher m(value); -+ if (m.right().IsInRange(32, 63)) { -+ // After smi untagging no need for truncate. Combine sequence. -+ Emit(kRiscvSar64, g.DefineSameAsFirst(node), -+ g.UseRegister(m.left().node()), -+ g.UseImmediate(m.right().node())); -+ return; -+ } -+ } -+ break; -+ } -+ default: -+ break; -+ } -+ } -+ -+ // Semantics of this machine IR is not clear. For example, x86 zero-extend the -+ // truncated value; arm treats it as nop thus the upper 32-bit as undefined; -+ // mips emits ext instruction which zero-extend the 32-bit value; for riscv, -+ // we do sign-extension of the truncated value -+ Emit(kRiscvSignExtendWord, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* value = node->InputAt(0); -+ // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding -+ // instruction. -+ if (CanCover(node, value) && -+ value->opcode() == IrOpcode::kChangeInt32ToFloat64) { -+ Emit(kRiscvCvtSW, g.DefineAsRegister(node), -+ g.UseRegister(value->InputAt(0))); -+ return; -+ } -+ VisitRR(this, kRiscvCvtSD, node); -+} -+ -+void InstructionSelector::VisitTruncateFloat64ToWord32(Node* node) { -+ VisitRR(this, kArchTruncateDoubleToI, node); -+} -+ -+void InstructionSelector::VisitRoundFloat64ToInt32(Node* node) { -+ VisitRR(this, kRiscvTruncWD, node); -+} -+ -+void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) { -+ VisitRR(this, kRiscvCvtSL, node); -+} -+ -+void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDL, node); -+} -+ -+void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { -+ VisitRR(this, kRiscvCvtSUl, node); -+} -+ -+void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { -+ VisitRR(this, kRiscvCvtDUl, node); -+} -+ -+void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) { -+ VisitRR(this, kRiscvBitcastFloat32ToInt32, node); -+} -+ -+void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { -+ VisitRR(this, kRiscvBitcastDL, node); -+} -+ -+void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) { -+ VisitRR(this, kRiscvBitcastInt32ToFloat32, node); -+} -+ -+void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { -+ VisitRR(this, kRiscvBitcastLD, node); -+} -+ -+void InstructionSelector::VisitFloat32Add(Node* node) { -+ VisitRRR(this, kRiscvAddS, node); -+} -+ -+void InstructionSelector::VisitFloat64Add(Node* node) { -+ VisitRRR(this, kRiscvAddD, node); -+} -+ -+void InstructionSelector::VisitFloat32Sub(Node* node) { -+ VisitRRR(this, kRiscvSubS, node); -+} -+ -+void InstructionSelector::VisitFloat64Sub(Node* node) { -+ VisitRRR(this, kRiscvSubD, node); -+} -+ -+void InstructionSelector::VisitFloat32Mul(Node* node) { -+ VisitRRR(this, kRiscvMulS, node); -+} -+ -+void InstructionSelector::VisitFloat64Mul(Node* node) { -+ VisitRRR(this, kRiscvMulD, node); -+} -+ -+void InstructionSelector::VisitFloat32Div(Node* node) { -+ VisitRRR(this, kRiscvDivS, node); -+} -+ -+void InstructionSelector::VisitFloat64Div(Node* node) { -+ VisitRRR(this, kRiscvDivD, node); -+} -+ -+void InstructionSelector::VisitFloat64Mod(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvModD, g.DefineAsFixed(node, fa0), -+ g.UseFixed(node->InputAt(0), fa0), g.UseFixed(node->InputAt(1), fa1)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::VisitFloat32Max(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvFloat32Max, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat64Max(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvFloat64Max, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat32Min(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvFloat32Min, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat64Min(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvFloat64Min, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); -+} -+ -+void InstructionSelector::VisitFloat32Abs(Node* node) { -+ VisitRR(this, kRiscvAbsS, node); -+} -+ -+void InstructionSelector::VisitFloat64Abs(Node* node) { -+ VisitRR(this, kRiscvAbsD, node); -+} -+ -+void InstructionSelector::VisitFloat32Sqrt(Node* node) { -+ VisitRR(this, kRiscvSqrtS, node); -+} -+ -+void InstructionSelector::VisitFloat64Sqrt(Node* node) { -+ VisitRR(this, kRiscvSqrtD, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundDown(Node* node) { -+ VisitRR(this, kRiscvFloat32RoundDown, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundDown(Node* node) { -+ VisitRR(this, kRiscvFloat64RoundDown, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundUp(Node* node) { -+ VisitRR(this, kRiscvFloat32RoundUp, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundUp(Node* node) { -+ VisitRR(this, kRiscvFloat64RoundUp, node); -+} -+ -+void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { -+ VisitRR(this, kRiscvFloat32RoundTruncate, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { -+ VisitRR(this, kRiscvFloat64RoundTruncate, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { -+ VisitRR(this, kRiscvFloat32RoundTiesEven, node); -+} -+ -+void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { -+ VisitRR(this, kRiscvFloat64RoundTiesEven, node); -+} -+ -+void InstructionSelector::VisitFloat32Neg(Node* node) { -+ VisitRR(this, kRiscvNegS, node); -+} -+ -+void InstructionSelector::VisitFloat64Neg(Node* node) { -+ VisitRR(this, kRiscvNegD, node); -+} -+ -+void InstructionSelector::VisitFloat64Ieee754Binop(Node* node, -+ InstructionCode opcode) { -+ RiscvOperandGenerator g(this); -+ Emit(opcode, g.DefineAsFixed(node, fa0), g.UseFixed(node->InputAt(0), fa0), -+ g.UseFixed(node->InputAt(1), fa1)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::VisitFloat64Ieee754Unop(Node* node, -+ InstructionCode opcode) { -+ RiscvOperandGenerator g(this); -+ Emit(opcode, g.DefineAsFixed(node, fa0), g.UseFixed(node->InputAt(0), fa1)) -+ ->MarkAsCall(); -+} -+ -+void InstructionSelector::EmitPrepareArguments( -+ ZoneVector* arguments, const CallDescriptor* call_descriptor, -+ Node* node) { -+ RiscvOperandGenerator g(this); -+ -+ // Prepare for C function call. -+ if (call_descriptor->IsCFunctionCall()) { -+ Emit(kArchPrepareCallCFunction | MiscField::encode(static_cast( -+ call_descriptor->ParameterCount())), -+ 0, nullptr, 0, nullptr); -+ -+ // Poke any stack arguments. -+ int slot = kCArgSlotCount; -+ for (PushParameter input : (*arguments)) { -+ Emit(kRiscvStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), -+ g.TempImmediate(slot << kSystemPointerSizeLog2)); -+ ++slot; -+ } -+ } else { -+ int push_count = static_cast(call_descriptor->StackParameterCount()); -+ if (push_count > 0) { -+ // Calculate needed space -+ int stack_size = 0; -+ for (PushParameter input : (*arguments)) { -+ if (input.node) { -+ stack_size += input.location.GetSizeInPointers(); -+ } -+ } -+ Emit(kRiscvStackClaim, g.NoOutput(), -+ g.TempImmediate(stack_size << kSystemPointerSizeLog2)); -+ } -+ for (size_t n = 0; n < arguments->size(); ++n) { -+ PushParameter input = (*arguments)[n]; -+ if (input.node) { -+ Emit(kRiscvStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), -+ g.TempImmediate(static_cast(n << kSystemPointerSizeLog2))); -+ } -+ } -+ } -+} -+ -+void InstructionSelector::EmitPrepareResults( -+ ZoneVector* results, const CallDescriptor* call_descriptor, -+ Node* node) { -+ RiscvOperandGenerator g(this); -+ -+ int reverse_slot = 0; -+ for (PushParameter output : *results) { -+ if (!output.location.IsCallerFrameSlot()) continue; -+ // Skip any alignment holes in nodes. -+ if (output.node != nullptr) { -+ DCHECK(!call_descriptor->IsCFunctionCall()); -+ if (output.location.GetType() == MachineType::Float32()) { -+ MarkAsFloat32(output.node); -+ } else if (output.location.GetType() == MachineType::Float64()) { -+ MarkAsFloat64(output.node); -+ } -+ Emit(kRiscvPeek, g.DefineAsRegister(output.node), -+ g.UseImmediate(reverse_slot)); -+ } -+ reverse_slot += output.location.GetSizeInPointers(); -+ } -+} -+ -+bool InstructionSelector::IsTailCallAddressImmediate() { return false; } -+ -+int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } -+ -+void InstructionSelector::VisitUnalignedLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ RiscvOperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kFloat32: -+ opcode = kRiscvULoadFloat; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kRiscvULoadDouble; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ UNREACHABLE(); -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsUnsigned() ? kRiscvUlhu : kRiscvUlh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = load_rep.IsUnsigned() ? kRiscvUlwu : kRiscvUlw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvUld; -+ break; -+ case MachineRepresentation::kSimd128: -+ opcode = kRiscvMsaLd; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ UNREACHABLE(); -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, -+ g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired load opcode, using temp addr_reg. -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); -+ } -+} -+ -+void InstructionSelector::VisitUnalignedStore(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kFloat32: -+ opcode = kRiscvUStoreFloat; -+ break; -+ case MachineRepresentation::kFloat64: -+ opcode = kRiscvUStoreDouble; -+ break; -+ case MachineRepresentation::kBit: // Fall through. -+ case MachineRepresentation::kWord8: -+ UNREACHABLE(); -+ case MachineRepresentation::kWord16: -+ opcode = kRiscvUsh; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kRiscvUsw; -+ break; -+ case MachineRepresentation::kTaggedSigned: // Fall through. -+ case MachineRepresentation::kTaggedPointer: // Fall through. -+ case MachineRepresentation::kTagged: // Fall through. -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvUsd; -+ break; -+ case MachineRepresentation::kSimd128: -+ opcode = kRiscvMsaSt; -+ break; -+ case MachineRepresentation::kCompressedPointer: // Fall through. -+ case MachineRepresentation::kCompressed: // Fall through. -+ case MachineRepresentation::kNone: -+ UNREACHABLE(); -+ } -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, -+ g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired store opcode, using temp addr_reg. -+ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), -+ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); -+ } -+} -+ -+namespace { -+ -+// Shared routine for multiple compare operations. -+static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, -+ InstructionOperand left, InstructionOperand right, -+ FlagsContinuation* cont) { -+ selector->EmitWithContinuation(opcode, left, right, cont); -+} -+ -+// Shared routine for multiple float32 compare operations. -+void VisitFloat32Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ RiscvOperandGenerator g(selector); -+ Float32BinopMatcher m(node); -+ InstructionOperand lhs, rhs; -+ -+ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) -+ : g.UseRegister(m.left().node()); -+ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) -+ : g.UseRegister(m.right().node()); -+ VisitCompare(selector, kRiscvCmpS, lhs, rhs, cont); -+} -+ -+// Shared routine for multiple float64 compare operations. -+void VisitFloat64Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ RiscvOperandGenerator g(selector); -+ Float64BinopMatcher m(node); -+ InstructionOperand lhs, rhs; -+ -+ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) -+ : g.UseRegister(m.left().node()); -+ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) -+ : g.UseRegister(m.right().node()); -+ VisitCompare(selector, kRiscvCmpD, lhs, rhs, cont); -+} -+ -+// Shared routine for multiple word compare operations. -+void VisitWordCompare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont, -+ bool commutative) { -+ RiscvOperandGenerator g(selector); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ -+ // Match immediates on left or right side of comparison. -+ if (g.CanBeImmediate(right, opcode)) { -+ if (opcode == kRiscvTst) { -+ VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), -+ cont); -+ } else { -+ switch (cont->condition()) { -+ case kEqual: -+ case kNotEqual: -+ if (cont->IsSet()) { -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseImmediate(right), cont); -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseRegister(right), cont); -+ } -+ break; -+ case kSignedLessThan: -+ case kSignedGreaterThanOrEqual: -+ case kUnsignedLessThan: -+ case kUnsignedGreaterThanOrEqual: -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseImmediate(right), cont); -+ break; -+ default: -+ VisitCompare(selector, opcode, g.UseRegister(left), -+ g.UseRegister(right), cont); -+ } -+ } -+ } else if (g.CanBeImmediate(left, opcode)) { -+ if (!commutative) cont->Commute(); -+ if (opcode == kRiscvTst) { -+ VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), -+ cont); -+ } else { -+ switch (cont->condition()) { -+ case kEqual: -+ case kNotEqual: -+ if (cont->IsSet()) { -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseImmediate(left), cont); -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseRegister(left), cont); -+ } -+ break; -+ case kSignedLessThan: -+ case kSignedGreaterThanOrEqual: -+ case kUnsignedLessThan: -+ case kUnsignedGreaterThanOrEqual: -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseImmediate(left), cont); -+ break; -+ default: -+ VisitCompare(selector, opcode, g.UseRegister(right), -+ g.UseRegister(left), cont); -+ } -+ } -+ } else { -+ VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), -+ cont); -+ } -+} -+ -+bool IsNodeUnsigned(Node* n) { -+ NodeMatcher m(n); -+ -+ if (m.IsLoad() || m.IsUnalignedLoad() || m.IsPoisonedLoad() || -+ m.IsProtectedLoad() || m.IsWord32AtomicLoad() || m.IsWord64AtomicLoad()) { -+ LoadRepresentation load_rep = LoadRepresentationOf(n->op()); -+ return load_rep.IsUnsigned(); -+ } else { -+ return m.IsUint32Div() || m.IsUint32LessThan() || -+ m.IsUint32LessThanOrEqual() || m.IsUint32Mod() || -+ m.IsUint32MulHigh() || m.IsChangeFloat64ToUint32() || -+ m.IsTruncateFloat64ToUint32() || m.IsTruncateFloat32ToUint32(); -+ } -+} -+ -+// Shared routine for multiple word compare operations. -+void VisitFullWord32Compare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, FlagsContinuation* cont) { -+ RiscvOperandGenerator g(selector); -+ InstructionOperand leftOp = g.TempRegister(); -+ InstructionOperand rightOp = g.TempRegister(); -+ -+ selector->Emit(kRiscvShl64, leftOp, g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(32)); -+ selector->Emit(kRiscvShl64, rightOp, g.UseRegister(node->InputAt(1)), -+ g.TempImmediate(32)); -+ -+ VisitCompare(selector, opcode, leftOp, rightOp, cont); -+} -+ -+void VisitOptimizedWord32Compare(InstructionSelector* selector, Node* node, -+ InstructionCode opcode, -+ FlagsContinuation* cont) { -+ if (FLAG_debug_code) { -+ RiscvOperandGenerator g(selector); -+ InstructionOperand leftOp = g.TempRegister(); -+ InstructionOperand rightOp = g.TempRegister(); -+ InstructionOperand optimizedResult = g.TempRegister(); -+ InstructionOperand fullResult = g.TempRegister(); -+ FlagsCondition condition = cont->condition(); -+ InstructionCode testOpcode = opcode | -+ FlagsConditionField::encode(condition) | -+ FlagsModeField::encode(kFlags_set); -+ -+ selector->Emit(testOpcode, optimizedResult, g.UseRegister(node->InputAt(0)), -+ g.UseRegister(node->InputAt(1))); -+ -+ selector->Emit(kRiscvShl64, leftOp, g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(32)); -+ selector->Emit(kRiscvShl64, rightOp, g.UseRegister(node->InputAt(1)), -+ g.TempImmediate(32)); -+ selector->Emit(testOpcode, fullResult, leftOp, rightOp); -+ -+ selector->Emit(kRiscvAssertEqual, g.NoOutput(), optimizedResult, fullResult, -+ g.TempImmediate(static_cast( -+ AbortReason::kUnsupportedNonPrimitiveCompare))); -+ } -+ -+ VisitWordCompare(selector, node, opcode, cont, false); -+} -+ -+void VisitWord32Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ // RISC-V doesn't support Word32 compare instructions. Instead it relies -+ // that the values in registers are correctly sign-extended and uses -+ // Word64 comparison instead. This behavior is correct in most cases, -+ // but doesn't work when comparing signed with unsigned operands. -+ // We could simulate full Word32 compare in all cases but this would -+ // create an unnecessary overhead since unsigned integers are rarely -+ // used in JavaScript. -+ // The solution proposed here tries to match a comparison of signed -+ // with unsigned operand, and perform full Word32Compare only -+ // in those cases. Unfortunately, the solution is not complete because -+ // it might skip cases where Word32 full compare is needed, so -+ // basically it is a hack. -+ // When call to a host function in simulator, if the function return a -+ // int32 value, the simulator do not sign-extended to int64 because in -+ // simulator we do not know the function whether return a int32 or int64. -+ // so we need do a full word32 compare in this case. -+#ifndef USE_SIMULATOR -+ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1))) { -+#else -+ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1)) || -+ node->InputAt(0)->opcode() == IrOpcode::kCall || -+ node->InputAt(1)->opcode() == IrOpcode::kCall) { -+#endif -+ VisitFullWord32Compare(selector, node, kRiscvCmp, cont); -+ } else { -+ VisitOptimizedWord32Compare(selector, node, kRiscvCmp, cont); -+ } -+} -+ -+void VisitWord64Compare(InstructionSelector* selector, Node* node, -+ FlagsContinuation* cont) { -+ VisitWordCompare(selector, node, kRiscvCmp, cont, false); -+} -+ -+void EmitWordCompareZero(InstructionSelector* selector, Node* value, -+ FlagsContinuation* cont) { -+ RiscvOperandGenerator g(selector); -+ selector->EmitWithContinuation(kRiscvCmp, g.UseRegister(value), -+ g.TempImmediate(0), cont); -+} -+ -+void VisitAtomicLoad(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), g.UseRegister(base), -+ g.UseImmediate(index)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), -+ addr_reg, g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired load opcode, using temp addr_reg. -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); -+ } -+} -+ -+void VisitAtomicStore(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ if (g.CanBeImmediate(index, opcode)) { -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.NoOutput(), g.UseRegister(base), g.UseImmediate(index), -+ g.UseRegisterOrImmediateZero(value)); -+ } else { -+ InstructionOperand addr_reg = g.TempRegister(); -+ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), -+ addr_reg, g.UseRegister(index), g.UseRegister(base)); -+ // Emit desired store opcode, using temp addr_reg. -+ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), -+ g.NoOutput(), addr_reg, g.TempImmediate(0), -+ g.UseRegisterOrImmediateZero(value)); -+ } -+} -+ -+void VisitAtomicExchange(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temp[3]; -+ temp[0] = g.TempRegister(); -+ temp[1] = g.TempRegister(); -+ temp[2] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); -+} -+ -+void VisitAtomicCompareExchange(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* old_value = node->InputAt(2); -+ Node* new_value = node->InputAt(3); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[4]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(old_value); -+ inputs[input_count++] = g.UseUniqueRegister(new_value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temp[3]; -+ temp[0] = g.TempRegister(); -+ temp[1] = g.TempRegister(); -+ temp[2] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); -+} -+ -+void VisitAtomicBinop(InstructionSelector* selector, Node* node, -+ ArchOpcode opcode) { -+ RiscvOperandGenerator g(selector); -+ Node* base = node->InputAt(0); -+ Node* index = node->InputAt(1); -+ Node* value = node->InputAt(2); -+ -+ AddressingMode addressing_mode = kMode_MRI; -+ InstructionOperand inputs[3]; -+ size_t input_count = 0; -+ inputs[input_count++] = g.UseUniqueRegister(base); -+ inputs[input_count++] = g.UseUniqueRegister(index); -+ inputs[input_count++] = g.UseUniqueRegister(value); -+ InstructionOperand outputs[1]; -+ outputs[0] = g.UseUniqueRegister(node); -+ InstructionOperand temps[4]; -+ temps[0] = g.TempRegister(); -+ temps[1] = g.TempRegister(); -+ temps[2] = g.TempRegister(); -+ temps[3] = g.TempRegister(); -+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); -+ selector->Emit(code, 1, outputs, input_count, inputs, 4, temps); -+} -+ -+} // namespace -+ -+void InstructionSelector::VisitStackPointerGreaterThan( -+ Node* node, FlagsContinuation* cont) { -+ StackCheckKind kind = StackCheckKindOf(node->op()); -+ InstructionCode opcode = -+ kArchStackPointerGreaterThan | MiscField::encode(static_cast(kind)); -+ -+ RiscvOperandGenerator g(this); -+ -+ // No outputs. -+ InstructionOperand* const outputs = nullptr; -+ const int output_count = 0; -+ -+ // Applying an offset to this stack check requires a temp register. Offsets -+ // are only applied to the first stack check. If applying an offset, we must -+ // ensure the input and temp registers do not alias, thus kUniqueRegister. -+ InstructionOperand temps[] = {g.TempRegister()}; -+ const int temp_count = (kind == StackCheckKind::kJSFunctionEntry ? 1 : 0); -+ const auto register_mode = (kind == StackCheckKind::kJSFunctionEntry) -+ ? OperandGenerator::kUniqueRegister -+ : OperandGenerator::kRegister; -+ -+ Node* const value = node->InputAt(0); -+ InstructionOperand inputs[] = {g.UseRegisterWithMode(value, register_mode)}; -+ static constexpr int input_count = arraysize(inputs); -+ -+ EmitWithContinuation(opcode, output_count, outputs, input_count, inputs, -+ temp_count, temps, cont); -+} -+ -+// Shared routine for word comparisons against zero. -+void InstructionSelector::VisitWordCompareZero(Node* user, Node* value, -+ FlagsContinuation* cont) { -+ // Try to combine with comparisons against 0 by simply inverting the branch. -+ while (CanCover(user, value)) { -+ if (value->opcode() == IrOpcode::kWord32Equal) { -+ Int32BinopMatcher m(value); -+ if (!m.right().Is(0)) break; -+ user = value; -+ value = m.left().node(); -+ } else if (value->opcode() == IrOpcode::kWord64Equal) { -+ Int64BinopMatcher m(value); -+ if (!m.right().Is(0)) break; -+ user = value; -+ value = m.left().node(); -+ } else { -+ break; -+ } -+ -+ cont->Negate(); -+ } -+ -+ if (CanCover(user, value)) { -+ switch (value->opcode()) { -+ case IrOpcode::kWord32Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kInt32LessThan: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThan); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kInt32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kUint32LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kUint32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitWord32Compare(this, value, cont); -+ case IrOpcode::kWord64Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kInt64LessThan: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThan); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kInt64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kUint64LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kUint64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitWord64Compare(this, value, cont); -+ case IrOpcode::kFloat32Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat32LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat32LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitFloat32Compare(this, value, cont); -+ case IrOpcode::kFloat64Equal: -+ cont->OverwriteAndNegateIfEqual(kEqual); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kFloat64LessThan: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kFloat64LessThanOrEqual: -+ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); -+ return VisitFloat64Compare(this, value, cont); -+ case IrOpcode::kProjection: -+ // Check if this is the overflow output projection of an -+ // WithOverflow node. -+ if (ProjectionIndexOf(value->op()) == 1u) { -+ // We cannot combine the WithOverflow with this branch -+ // unless the 0th projection (the use of the actual value of the -+ // is either nullptr, which means there's no use of the -+ // actual value, or was already defined, which means it is scheduled -+ // *AFTER* this branch). -+ Node* const node = value->InputAt(0); -+ Node* const result = NodeProperties::FindProjection(node, 0); -+ if (result == nullptr || IsDefined(result)) { -+ switch (node->opcode()) { -+ case IrOpcode::kInt32AddWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kRiscvAdd64, cont); -+ case IrOpcode::kInt32SubWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kRiscvSub64, cont); -+ case IrOpcode::kInt32MulWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kRiscvMulOvf32, cont); -+ case IrOpcode::kInt64AddWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kRiscvAddOvf64, cont); -+ case IrOpcode::kInt64SubWithOverflow: -+ cont->OverwriteAndNegateIfEqual(kOverflow); -+ return VisitBinop(this, node, kRiscvSubOvf64, cont); -+ default: -+ break; -+ } -+ } -+ } -+ break; -+ case IrOpcode::kWord32And: -+ case IrOpcode::kWord64And: -+ return VisitWordCompare(this, value, kRiscvTst, cont, true); -+ case IrOpcode::kStackPointerGreaterThan: -+ cont->OverwriteAndNegateIfEqual(kStackPointerGreaterThanCondition); -+ return VisitStackPointerGreaterThan(value, cont); -+ default: -+ break; -+ } -+ } -+ -+ // Continuation could not be combined with a compare, emit compare against 0. -+ EmitWordCompareZero(this, value, cont); -+} -+ -+void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { -+ RiscvOperandGenerator g(this); -+ InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); -+ -+ // Emit either ArchTableSwitch or ArchBinarySearchSwitch. -+ if (enable_switch_jump_table_ == kEnableSwitchJumpTable) { -+ static const size_t kMaxTableSwitchValueRange = 2 << 16; -+ size_t table_space_cost = 10 + 2 * sw.value_range(); -+ size_t table_time_cost = 3; -+ size_t lookup_space_cost = 2 + 2 * sw.case_count(); -+ size_t lookup_time_cost = sw.case_count(); -+ if (sw.case_count() > 0 && -+ table_space_cost + 3 * table_time_cost <= -+ lookup_space_cost + 3 * lookup_time_cost && -+ sw.min_value() > std::numeric_limits::min() && -+ sw.value_range() <= kMaxTableSwitchValueRange) { -+ InstructionOperand index_operand = value_operand; -+ if (sw.min_value()) { -+ index_operand = g.TempRegister(); -+ Emit(kRiscvSub32, index_operand, value_operand, -+ g.TempImmediate(sw.min_value())); -+ } -+ // Generate a table lookup. -+ return EmitTableSwitch(sw, index_operand); -+ } -+ } -+ -+ // Generate a tree of conditional jumps. -+ return EmitBinarySearchSwitch(sw, value_operand); -+} -+ -+void InstructionSelector::VisitWord32Equal(Node* const node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ Int32BinopMatcher m(node); -+ if (m.right().Is(0)) { -+ return VisitWordCompareZero(m.node(), m.left().node(), &cont); -+ } -+ -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitWord32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kRiscvAdd64, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kRiscvAdd64, &cont); -+} -+ -+void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kRiscvSub64, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kRiscvSub64, &cont); -+} -+ -+void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kRiscvMulOvf32, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kRiscvMulOvf32, &cont); -+} -+ -+void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kRiscvAddOvf64, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kRiscvAddOvf64, &cont); -+} -+ -+void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { -+ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); -+ return VisitBinop(this, node, kRiscvSubOvf64, &cont); -+ } -+ FlagsContinuation cont; -+ VisitBinop(this, node, kRiscvSubOvf64, &cont); -+} -+ -+void InstructionSelector::VisitWord64Equal(Node* const node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ Int64BinopMatcher m(node); -+ if (m.right().Is(0)) { -+ return VisitWordCompareZero(m.node(), m.left().node(), &cont); -+ } -+ -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitWord64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32Equal(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitFloat32Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64Equal(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64LessThan(Node* node) { -+ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { -+ FlagsContinuation cont = -+ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); -+ VisitFloat64Compare(this, node, &cont); -+} -+ -+void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { -+ VisitRR(this, kRiscvFloat64ExtractLowWord32, node); -+} -+ -+void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { -+ VisitRR(this, kRiscvFloat64ExtractHighWord32, node); -+} -+ -+void InstructionSelector::VisitFloat64SilenceNaN(Node* node) { -+ VisitRR(this, kRiscvFloat64SilenceNaN, node); -+} -+ -+void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ Emit(kRiscvFloat64InsertLowWord32, g.DefineSameAsFirst(node), -+ g.UseRegister(left), g.UseRegister(right)); -+} -+ -+void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Node* left = node->InputAt(0); -+ Node* right = node->InputAt(1); -+ Emit(kRiscvFloat64InsertHighWord32, g.DefineSameAsFirst(node), -+ g.UseRegister(left), g.UseRegister(right)); -+} -+ -+void InstructionSelector::VisitMemoryBarrier(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvSync, g.NoOutput()); -+} -+ -+void InstructionSelector::VisitWord32AtomicLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ opcode = -+ load_rep.IsSigned() ? kWord32AtomicLoadInt8 : kWord32AtomicLoadUint8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = load_rep.IsSigned() ? kWord32AtomicLoadInt16 -+ : kWord32AtomicLoadUint16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kWord32AtomicLoadWord32; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ VisitAtomicLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicStore(Node* node) { -+ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kWord8: -+ opcode = kWord32AtomicStoreWord8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kWord32AtomicStoreWord16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kWord32AtomicStoreWord32; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ VisitAtomicStore(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicLoad(Node* node) { -+ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (load_rep.representation()) { -+ case MachineRepresentation::kWord8: -+ opcode = kRiscvWord64AtomicLoadUint8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kRiscvWord64AtomicLoadUint16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kRiscvWord64AtomicLoadUint32; -+ break; -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvWord64AtomicLoadUint64; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ VisitAtomicLoad(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicStore(Node* node) { -+ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); -+ ArchOpcode opcode = kArchNop; -+ switch (rep) { -+ case MachineRepresentation::kWord8: -+ opcode = kRiscvWord64AtomicStoreWord8; -+ break; -+ case MachineRepresentation::kWord16: -+ opcode = kRiscvWord64AtomicStoreWord16; -+ break; -+ case MachineRepresentation::kWord32: -+ opcode = kRiscvWord64AtomicStoreWord32; -+ break; -+ case MachineRepresentation::kWord64: -+ opcode = kRiscvWord64AtomicStoreWord64; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ VisitAtomicStore(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = kWord32AtomicExchangeInt8; -+ } else if (type == MachineType::Uint8()) { -+ opcode = kWord32AtomicExchangeUint8; -+ } else if (type == MachineType::Int16()) { -+ opcode = kWord32AtomicExchangeInt16; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kWord32AtomicExchangeUint16; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = kWord32AtomicExchangeWord32; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = kRiscvWord64AtomicExchangeUint8; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kRiscvWord64AtomicExchangeUint16; -+ } else if (type == MachineType::Uint32()) { -+ opcode = kRiscvWord64AtomicExchangeUint32; -+ } else if (type == MachineType::Uint64()) { -+ opcode = kRiscvWord64AtomicExchangeUint64; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord32AtomicCompareExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = kWord32AtomicCompareExchangeInt8; -+ } else if (type == MachineType::Uint8()) { -+ opcode = kWord32AtomicCompareExchangeUint8; -+ } else if (type == MachineType::Int16()) { -+ opcode = kWord32AtomicCompareExchangeInt16; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kWord32AtomicCompareExchangeUint16; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = kWord32AtomicCompareExchangeWord32; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicCompareExchange(this, node, opcode); -+} -+ -+void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = kRiscvWord64AtomicCompareExchangeUint8; -+ } else if (type == MachineType::Uint16()) { -+ opcode = kRiscvWord64AtomicCompareExchangeUint16; -+ } else if (type == MachineType::Uint32()) { -+ opcode = kRiscvWord64AtomicCompareExchangeUint32; -+ } else if (type == MachineType::Uint64()) { -+ opcode = kRiscvWord64AtomicCompareExchangeUint64; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicCompareExchange(this, node, opcode); -+} -+void InstructionSelector::VisitWord32AtomicBinaryOperation( -+ Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op, -+ ArchOpcode uint16_op, ArchOpcode word32_op) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Int8()) { -+ opcode = int8_op; -+ } else if (type == MachineType::Uint8()) { -+ opcode = uint8_op; -+ } else if (type == MachineType::Int16()) { -+ opcode = int16_op; -+ } else if (type == MachineType::Uint16()) { -+ opcode = uint16_op; -+ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { -+ opcode = word32_op; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ -+ VisitAtomicBinop(this, node, opcode); -+} -+ -+#define VISIT_ATOMIC_BINOP(op) \ -+ void InstructionSelector::VisitWord32Atomic##op(Node* node) { \ -+ VisitWord32AtomicBinaryOperation( \ -+ node, kWord32Atomic##op##Int8, kWord32Atomic##op##Uint8, \ -+ kWord32Atomic##op##Int16, kWord32Atomic##op##Uint16, \ -+ kWord32Atomic##op##Word32); \ -+ } -+VISIT_ATOMIC_BINOP(Add) -+VISIT_ATOMIC_BINOP(Sub) -+VISIT_ATOMIC_BINOP(And) -+VISIT_ATOMIC_BINOP(Or) -+VISIT_ATOMIC_BINOP(Xor) -+#undef VISIT_ATOMIC_BINOP -+ -+void InstructionSelector::VisitWord64AtomicBinaryOperation( -+ Node* node, ArchOpcode uint8_op, ArchOpcode uint16_op, ArchOpcode uint32_op, -+ ArchOpcode uint64_op) { -+ ArchOpcode opcode = kArchNop; -+ MachineType type = AtomicOpType(node->op()); -+ if (type == MachineType::Uint8()) { -+ opcode = uint8_op; -+ } else if (type == MachineType::Uint16()) { -+ opcode = uint16_op; -+ } else if (type == MachineType::Uint32()) { -+ opcode = uint32_op; -+ } else if (type == MachineType::Uint64()) { -+ opcode = uint64_op; -+ } else { -+ UNREACHABLE(); -+ return; -+ } -+ VisitAtomicBinop(this, node, opcode); -+} -+ -+#define VISIT_ATOMIC_BINOP(op) \ -+ void InstructionSelector::VisitWord64Atomic##op(Node* node) { \ -+ VisitWord64AtomicBinaryOperation( \ -+ node, kRiscvWord64Atomic##op##Uint8, kRiscvWord64Atomic##op##Uint16, \ -+ kRiscvWord64Atomic##op##Uint32, kRiscvWord64Atomic##op##Uint64); \ -+ } -+VISIT_ATOMIC_BINOP(Add) -+VISIT_ATOMIC_BINOP(Sub) -+VISIT_ATOMIC_BINOP(And) -+VISIT_ATOMIC_BINOP(Or) -+VISIT_ATOMIC_BINOP(Xor) -+#undef VISIT_ATOMIC_BINOP -+ -+void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) { -+ UNREACHABLE(); -+} -+ -+void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { -+ UNREACHABLE(); -+} -+ -+#define SIMD_TYPE_LIST(V) \ -+ V(F32x4) \ -+ V(I32x4) \ -+ V(I16x8) \ -+ V(I8x16) -+ -+#define SIMD_UNOP_LIST(V) \ -+ V(F64x2Abs, kRiscvF64x2Abs) \ -+ V(F64x2Neg, kRiscvF64x2Neg) \ -+ V(F64x2Sqrt, kRiscvF64x2Sqrt) \ -+ V(F64x2Ceil, kRiscvF64x2Ceil) \ -+ V(F64x2Floor, kRiscvF64x2Floor) \ -+ V(F64x2Trunc, kRiscvF64x2Trunc) \ -+ V(F64x2NearestInt, kRiscvF64x2NearestInt) \ -+ V(I64x2Neg, kRiscvI64x2Neg) \ -+ V(F32x4SConvertI32x4, kRiscvF32x4SConvertI32x4) \ -+ V(F32x4UConvertI32x4, kRiscvF32x4UConvertI32x4) \ -+ V(F32x4Abs, kRiscvF32x4Abs) \ -+ V(F32x4Neg, kRiscvF32x4Neg) \ -+ V(F32x4Sqrt, kRiscvF32x4Sqrt) \ -+ V(F32x4RecipApprox, kRiscvF32x4RecipApprox) \ -+ V(F32x4RecipSqrtApprox, kRiscvF32x4RecipSqrtApprox) \ -+ V(F32x4Ceil, kRiscvF32x4Ceil) \ -+ V(F32x4Floor, kRiscvF32x4Floor) \ -+ V(F32x4Trunc, kRiscvF32x4Trunc) \ -+ V(F32x4NearestInt, kRiscvF32x4NearestInt) \ -+ V(I32x4SConvertF32x4, kRiscvI32x4SConvertF32x4) \ -+ V(I32x4UConvertF32x4, kRiscvI32x4UConvertF32x4) \ -+ V(I32x4Neg, kRiscvI32x4Neg) \ -+ V(I32x4SConvertI16x8Low, kRiscvI32x4SConvertI16x8Low) \ -+ V(I32x4SConvertI16x8High, kRiscvI32x4SConvertI16x8High) \ -+ V(I32x4UConvertI16x8Low, kRiscvI32x4UConvertI16x8Low) \ -+ V(I32x4UConvertI16x8High, kRiscvI32x4UConvertI16x8High) \ -+ V(I32x4Abs, kRiscvI32x4Abs) \ -+ V(I32x4BitMask, kRiscvI32x4BitMask) \ -+ V(I16x8Neg, kRiscvI16x8Neg) \ -+ V(I16x8SConvertI8x16Low, kRiscvI16x8SConvertI8x16Low) \ -+ V(I16x8SConvertI8x16High, kRiscvI16x8SConvertI8x16High) \ -+ V(I16x8UConvertI8x16Low, kRiscvI16x8UConvertI8x16Low) \ -+ V(I16x8UConvertI8x16High, kRiscvI16x8UConvertI8x16High) \ -+ V(I16x8Abs, kRiscvI16x8Abs) \ -+ V(I16x8BitMask, kRiscvI16x8BitMask) \ -+ V(I8x16Neg, kRiscvI8x16Neg) \ -+ V(I8x16Abs, kRiscvI8x16Abs) \ -+ V(I8x16BitMask, kRiscvI8x16BitMask) \ -+ V(S128Not, kRiscvS128Not) \ -+ V(V32x4AnyTrue, kRiscvV32x4AnyTrue) \ -+ V(V32x4AllTrue, kRiscvV32x4AllTrue) \ -+ V(V16x8AnyTrue, kRiscvV16x8AnyTrue) \ -+ V(V16x8AllTrue, kRiscvV16x8AllTrue) \ -+ V(V8x16AnyTrue, kRiscvV8x16AnyTrue) \ -+ V(V8x16AllTrue, kRiscvV8x16AllTrue) -+ -+#define SIMD_SHIFT_OP_LIST(V) \ -+ V(I64x2Shl) \ -+ V(I64x2ShrS) \ -+ V(I64x2ShrU) \ -+ V(I32x4Shl) \ -+ V(I32x4ShrS) \ -+ V(I32x4ShrU) \ -+ V(I16x8Shl) \ -+ V(I16x8ShrS) \ -+ V(I16x8ShrU) \ -+ V(I8x16Shl) \ -+ V(I8x16ShrS) \ -+ V(I8x16ShrU) -+ -+#define SIMD_BINOP_LIST(V) \ -+ V(F64x2Add, kRiscvF64x2Add) \ -+ V(F64x2Sub, kRiscvF64x2Sub) \ -+ V(F64x2Mul, kRiscvF64x2Mul) \ -+ V(F64x2Div, kRiscvF64x2Div) \ -+ V(F64x2Min, kRiscvF64x2Min) \ -+ V(F64x2Max, kRiscvF64x2Max) \ -+ V(F64x2Eq, kRiscvF64x2Eq) \ -+ V(F64x2Ne, kRiscvF64x2Ne) \ -+ V(F64x2Lt, kRiscvF64x2Lt) \ -+ V(F64x2Le, kRiscvF64x2Le) \ -+ V(I64x2Add, kRiscvI64x2Add) \ -+ V(I64x2Sub, kRiscvI64x2Sub) \ -+ V(I64x2Mul, kRiscvI64x2Mul) \ -+ V(F32x4Add, kRiscvF32x4Add) \ -+ V(F32x4AddHoriz, kRiscvF32x4AddHoriz) \ -+ V(F32x4Sub, kRiscvF32x4Sub) \ -+ V(F32x4Mul, kRiscvF32x4Mul) \ -+ V(F32x4Div, kRiscvF32x4Div) \ -+ V(F32x4Max, kRiscvF32x4Max) \ -+ V(F32x4Min, kRiscvF32x4Min) \ -+ V(F32x4Eq, kRiscvF32x4Eq) \ -+ V(F32x4Ne, kRiscvF32x4Ne) \ -+ V(F32x4Lt, kRiscvF32x4Lt) \ -+ V(F32x4Le, kRiscvF32x4Le) \ -+ V(I32x4Add, kRiscvI32x4Add) \ -+ V(I32x4AddHoriz, kRiscvI32x4AddHoriz) \ -+ V(I32x4Sub, kRiscvI32x4Sub) \ -+ V(I32x4Mul, kRiscvI32x4Mul) \ -+ V(I32x4MaxS, kRiscvI32x4MaxS) \ -+ V(I32x4MinS, kRiscvI32x4MinS) \ -+ V(I32x4MaxU, kRiscvI32x4MaxU) \ -+ V(I32x4MinU, kRiscvI32x4MinU) \ -+ V(I32x4Eq, kRiscvI32x4Eq) \ -+ V(I32x4Ne, kRiscvI32x4Ne) \ -+ V(I32x4GtS, kRiscvI32x4GtS) \ -+ V(I32x4GeS, kRiscvI32x4GeS) \ -+ V(I32x4GtU, kRiscvI32x4GtU) \ -+ V(I32x4GeU, kRiscvI32x4GeU) \ -+ V(I16x8Add, kRiscvI16x8Add) \ -+ V(I16x8AddSaturateS, kRiscvI16x8AddSaturateS) \ -+ V(I16x8AddSaturateU, kRiscvI16x8AddSaturateU) \ -+ V(I16x8AddHoriz, kRiscvI16x8AddHoriz) \ -+ V(I16x8Sub, kRiscvI16x8Sub) \ -+ V(I16x8SubSaturateS, kRiscvI16x8SubSaturateS) \ -+ V(I16x8SubSaturateU, kRiscvI16x8SubSaturateU) \ -+ V(I16x8Mul, kRiscvI16x8Mul) \ -+ V(I16x8MaxS, kRiscvI16x8MaxS) \ -+ V(I16x8MinS, kRiscvI16x8MinS) \ -+ V(I16x8MaxU, kRiscvI16x8MaxU) \ -+ V(I16x8MinU, kRiscvI16x8MinU) \ -+ V(I16x8Eq, kRiscvI16x8Eq) \ -+ V(I16x8Ne, kRiscvI16x8Ne) \ -+ V(I16x8GtS, kRiscvI16x8GtS) \ -+ V(I16x8GeS, kRiscvI16x8GeS) \ -+ V(I16x8GtU, kRiscvI16x8GtU) \ -+ V(I16x8GeU, kRiscvI16x8GeU) \ -+ V(I16x8RoundingAverageU, kRiscvI16x8RoundingAverageU) \ -+ V(I16x8SConvertI32x4, kRiscvI16x8SConvertI32x4) \ -+ V(I16x8UConvertI32x4, kRiscvI16x8UConvertI32x4) \ -+ V(I8x16Add, kRiscvI8x16Add) \ -+ V(I8x16AddSaturateS, kRiscvI8x16AddSaturateS) \ -+ V(I8x16AddSaturateU, kRiscvI8x16AddSaturateU) \ -+ V(I8x16Sub, kRiscvI8x16Sub) \ -+ V(I8x16SubSaturateS, kRiscvI8x16SubSaturateS) \ -+ V(I8x16SubSaturateU, kRiscvI8x16SubSaturateU) \ -+ V(I8x16Mul, kRiscvI8x16Mul) \ -+ V(I8x16MaxS, kRiscvI8x16MaxS) \ -+ V(I8x16MinS, kRiscvI8x16MinS) \ -+ V(I8x16MaxU, kRiscvI8x16MaxU) \ -+ V(I8x16MinU, kRiscvI8x16MinU) \ -+ V(I8x16Eq, kRiscvI8x16Eq) \ -+ V(I8x16Ne, kRiscvI8x16Ne) \ -+ V(I8x16GtS, kRiscvI8x16GtS) \ -+ V(I8x16GeS, kRiscvI8x16GeS) \ -+ V(I8x16GtU, kRiscvI8x16GtU) \ -+ V(I8x16GeU, kRiscvI8x16GeU) \ -+ V(I8x16RoundingAverageU, kRiscvI8x16RoundingAverageU) \ -+ V(I8x16SConvertI16x8, kRiscvI8x16SConvertI16x8) \ -+ V(I8x16UConvertI16x8, kRiscvI8x16UConvertI16x8) \ -+ V(S128And, kRiscvS128And) \ -+ V(S128Or, kRiscvS128Or) \ -+ V(S128Xor, kRiscvS128Xor) \ -+ V(S128AndNot, kRiscvS128AndNot) -+ -+void InstructionSelector::VisitS128Const(Node* node) { -+ RiscvOperandGenerator g(this); -+ static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t); -+ uint32_t val[kUint32Immediates]; -+ memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size); -+ // If all bytes are zeros or ones, avoid emitting code for generic constants -+ bool all_zeros = !(val[0] || val[1] || val[2] || val[3]); -+ bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX && -+ val[2] == UINT32_MAX && val[3] == UINT32_MAX; -+ InstructionOperand dst = g.DefineAsRegister(node); -+ if (all_zeros) { -+ Emit(kRiscvS128Zero, dst); -+ } else if (all_ones) { -+ Emit(kRiscvS128AllOnes, dst); -+ } else { -+ Emit(kRiscvS128Const, dst, g.UseImmediate(val[0]), g.UseImmediate(val[1]), -+ g.UseImmediate(val[2]), g.UseImmediate(val[3])); -+ } -+} -+ -+void InstructionSelector::VisitS128Zero(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvS128Zero, g.DefineAsRegister(node)); -+} -+ -+#define SIMD_VISIT_SPLAT(Type) \ -+ void InstructionSelector::Visit##Type##Splat(Node* node) { \ -+ VisitRR(this, kRiscv##Type##Splat, node); \ -+ } -+SIMD_TYPE_LIST(SIMD_VISIT_SPLAT) -+SIMD_VISIT_SPLAT(F64x2) -+#undef SIMD_VISIT_SPLAT -+ -+#define SIMD_VISIT_EXTRACT_LANE(Type, Sign) \ -+ void InstructionSelector::Visit##Type##ExtractLane##Sign(Node* node) { \ -+ VisitRRI(this, kRiscv##Type##ExtractLane##Sign, node); \ -+ } -+SIMD_VISIT_EXTRACT_LANE(F64x2, ) -+SIMD_VISIT_EXTRACT_LANE(F32x4, ) -+SIMD_VISIT_EXTRACT_LANE(I32x4, ) -+SIMD_VISIT_EXTRACT_LANE(I16x8, U) -+SIMD_VISIT_EXTRACT_LANE(I16x8, S) -+SIMD_VISIT_EXTRACT_LANE(I8x16, U) -+SIMD_VISIT_EXTRACT_LANE(I8x16, S) -+#undef SIMD_VISIT_EXTRACT_LANE -+ -+#define SIMD_VISIT_REPLACE_LANE(Type) \ -+ void InstructionSelector::Visit##Type##ReplaceLane(Node* node) { \ -+ VisitRRIR(this, kRiscv##Type##ReplaceLane, node); \ -+ } -+SIMD_TYPE_LIST(SIMD_VISIT_REPLACE_LANE) -+SIMD_VISIT_REPLACE_LANE(F64x2) -+#undef SIMD_VISIT_REPLACE_LANE -+ -+#define SIMD_VISIT_UNOP(Name, instruction) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitRR(this, instruction, node); \ -+ } -+SIMD_UNOP_LIST(SIMD_VISIT_UNOP) -+#undef SIMD_VISIT_UNOP -+ -+#define SIMD_VISIT_SHIFT_OP(Name) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitSimdShift(this, kRiscv##Name, node); \ -+ } -+SIMD_SHIFT_OP_LIST(SIMD_VISIT_SHIFT_OP) -+#undef SIMD_VISIT_SHIFT_OP -+ -+#define SIMD_VISIT_BINOP(Name, instruction) \ -+ void InstructionSelector::Visit##Name(Node* node) { \ -+ VisitRRR(this, instruction, node); \ -+ } -+SIMD_BINOP_LIST(SIMD_VISIT_BINOP) -+#undef SIMD_VISIT_BINOP -+ -+void InstructionSelector::VisitS128Select(Node* node) { -+ VisitRRRR(this, kRiscvS128Select, node); -+} -+ -+namespace { -+ -+struct ShuffleEntry { -+ uint8_t shuffle[kSimd128Size]; -+ ArchOpcode opcode; -+}; -+ -+static const ShuffleEntry arch_shuffles[] = { -+ {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}, -+ kRiscvS32x4InterleaveRight}, -+ {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}, -+ kRiscvS32x4InterleaveLeft}, -+ {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}, -+ kRiscvS32x4PackEven}, -+ {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}, -+ kRiscvS32x4PackOdd}, -+ {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}, -+ kRiscvS32x4InterleaveEven}, -+ {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}, -+ kRiscvS32x4InterleaveOdd}, -+ -+ {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}, -+ kRiscvS16x8InterleaveRight}, -+ {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}, -+ kRiscvS16x8InterleaveLeft}, -+ {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}, -+ kRiscvS16x8PackEven}, -+ {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}, -+ kRiscvS16x8PackOdd}, -+ {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}, -+ kRiscvS16x8InterleaveEven}, -+ {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}, -+ kRiscvS16x8InterleaveOdd}, -+ {{6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9}, -+ kRiscvS16x4Reverse}, -+ {{2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13}, -+ kRiscvS16x2Reverse}, -+ -+ {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}, -+ kRiscvS8x16InterleaveRight}, -+ {{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}, -+ kRiscvS8x16InterleaveLeft}, -+ {{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}, -+ kRiscvS8x16PackEven}, -+ {{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, -+ kRiscvS8x16PackOdd}, -+ {{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}, -+ kRiscvS8x16InterleaveEven}, -+ {{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}, -+ kRiscvS8x16InterleaveOdd}, -+ {{7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}, kRiscvS8x8Reverse}, -+ {{3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12}, kRiscvS8x4Reverse}, -+ {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}, -+ kRiscvS8x2Reverse}}; -+ -+bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table, -+ size_t num_entries, bool is_swizzle, -+ ArchOpcode* opcode) { -+ uint8_t mask = is_swizzle ? kSimd128Size - 1 : 2 * kSimd128Size - 1; -+ for (size_t i = 0; i < num_entries; ++i) { -+ const ShuffleEntry& entry = table[i]; -+ int j = 0; -+ for (; j < kSimd128Size; ++j) { -+ if ((entry.shuffle[j] & mask) != (shuffle[j] & mask)) { -+ break; -+ } -+ } -+ if (j == kSimd128Size) { -+ *opcode = entry.opcode; -+ return true; -+ } -+ } -+ return false; -+} -+ -+} // namespace -+ -+void InstructionSelector::VisitI8x16Shuffle(Node* node) { -+ uint8_t shuffle[kSimd128Size]; -+ bool is_swizzle; -+ CanonicalizeShuffle(node, shuffle, &is_swizzle); -+ uint8_t shuffle32x4[4]; -+ ArchOpcode opcode; -+ if (TryMatchArchShuffle(shuffle, arch_shuffles, arraysize(arch_shuffles), -+ is_swizzle, &opcode)) { -+ VisitRRR(this, opcode, node); -+ return; -+ } -+ Node* input0 = node->InputAt(0); -+ Node* input1 = node->InputAt(1); -+ uint8_t offset; -+ RiscvOperandGenerator g(this); -+ if (wasm::SimdShuffle::TryMatchConcat(shuffle, &offset)) { -+ Emit(kRiscvS8x16Concat, g.DefineSameAsFirst(node), g.UseRegister(input1), -+ g.UseRegister(input0), g.UseImmediate(offset)); -+ return; -+ } -+ if (wasm::SimdShuffle::TryMatch32x4Shuffle(shuffle, shuffle32x4)) { -+ Emit(kRiscvS32x4Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), -+ g.UseRegister(input1), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4))); -+ return; -+ } -+ Emit(kRiscvI8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), -+ g.UseRegister(input1), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)), -+ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12))); -+} -+ -+void InstructionSelector::VisitI8x16Swizzle(Node* node) { -+ RiscvOperandGenerator g(this); -+ InstructionOperand temps[] = {g.TempSimd128Register()}; -+ // We don't want input 0 or input 1 to be the same as output, since we will -+ // modify output before do the calculation. -+ Emit(kRiscvI8x16Swizzle, g.DefineAsRegister(node), -+ g.UseUniqueRegister(node->InputAt(0)), -+ g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); -+} -+ -+void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord16ToInt32(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), -+ g.UseRegister(node->InputAt(0))); -+} -+ -+void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) { -+ RiscvOperandGenerator g(this); -+ Emit(kRiscvShl32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), -+ g.TempImmediate(0)); -+} -+ -+void InstructionSelector::VisitF32x4Pmin(Node* node) { -+ VisitUniqueRRR(this, kRiscvF32x4Pmin, node); -+} -+ -+void InstructionSelector::VisitF32x4Pmax(Node* node) { -+ VisitUniqueRRR(this, kRiscvF32x4Pmax, node); -+} -+ -+void InstructionSelector::VisitF64x2Pmin(Node* node) { -+ VisitUniqueRRR(this, kRiscvF64x2Pmin, node); -+} -+ -+void InstructionSelector::VisitF64x2Pmax(Node* node) { -+ VisitUniqueRRR(this, kRiscvF64x2Pmax, node); -+} -+ -+// static -+MachineOperatorBuilder::Flags -+InstructionSelector::SupportedMachineOperatorFlags() { -+ MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; -+ return flags | MachineOperatorBuilder::kWord32ShiftIsSafe | -+ MachineOperatorBuilder::kInt32DivIsSafe | -+ MachineOperatorBuilder::kUint32DivIsSafe | -+ MachineOperatorBuilder::kFloat64RoundDown | -+ MachineOperatorBuilder::kFloat32RoundDown | -+ MachineOperatorBuilder::kFloat64RoundUp | -+ MachineOperatorBuilder::kFloat32RoundUp | -+ MachineOperatorBuilder::kFloat64RoundTruncate | -+ MachineOperatorBuilder::kFloat32RoundTruncate | -+ MachineOperatorBuilder::kFloat64RoundTiesEven | -+ MachineOperatorBuilder::kFloat32RoundTiesEven; -+} -+ -+// static -+MachineOperatorBuilder::AlignmentRequirements -+InstructionSelector::AlignmentRequirements() { -+ return MachineOperatorBuilder::AlignmentRequirements:: -+ NoUnalignedAccessSupport(); -+} -+ -+#undef SIMD_BINOP_LIST -+#undef SIMD_SHIFT_OP_LIST -+#undef SIMD_UNOP_LIST -+#undef SIMD_TYPE_LIST -+#undef TRACE_UNIMPL -+#undef TRACE -+ -+} // namespace compiler -+} // namespace internal -+} // namespace v8 ---- a/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc -+++ b/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc -@@ -131,6 +131,19 @@ - d8.bit() | d9.bit() | d10.bit() | d11.bit() | d12.bit() | d13.bit() | \ - d14.bit() | d15.bit() - -+#elif V8_TARGET_ARCH_RISCV64 -+// =========================================================================== -+// == riscv64 ================================================================= -+// =========================================================================== -+#define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 -+// fp is not part of CALLEE_SAVE_REGISTERS (similar to how MIPS64 or PPC defines -+// it) -+#define CALLEE_SAVE_REGISTERS \ -+ s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | s7.bit() | \ -+ s8.bit() | s9.bit() | s10.bit() | s11.bit() -+#define CALLEE_SAVE_FP_REGISTERS \ -+ fs0.bit() | fs1.bit() | fs2.bit() | fs3.bit() | fs4.bit() | fs5.bit() | \ -+ fs6.bit() | fs7.bit() | fs8.bit() | fs9.bit() | fs10.bit() | fs11.bit() - #else - // =========================================================================== - // == unknown ================================================================ ---- a/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc -+++ b/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc -@@ -1060,8 +1060,10 @@ - } - } - CHECK(!failed); --#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ -- defined(V8_TARGET_ARCH_MIPS64) -+ // FIXME (RISCV): does RISCV need this? -+#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ -+ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_RISCV64) || \ -+ defined(V8_TARGET_ARCH_RISCV) - // Isolate-independent builtin calls and jumps do not emit reloc infos - // on PPC. We try to avoid using PC relative code due to performance - // issue with especially older hardwares. ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/debug/riscv64/debug-riscv64.cc -@@ -0,0 +1,55 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/debug/debug.h" -+#include "src/debug/liveedit.h" -+#include "src/execution/frames-inl.h" -+ -+namespace v8 { -+namespace internal { -+ -+#define __ ACCESS_MASM(masm) -+ -+void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { -+ { -+ FrameScope scope(masm, StackFrame::INTERNAL); -+ __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); -+ } -+ __ MaybeDropFrames(); -+ -+ // Return to caller. -+ __ Ret(); -+} -+ -+void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { -+ // Frame is being dropped: -+ // - Drop to the target frame specified by a1. -+ // - Look up current function on the frame. -+ // - Leave the frame. -+ // - Restart the frame by calling the function. -+ __ mv(fp, a1); -+ __ Ld(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ -+ // Pop return address and frame. -+ __ LeaveFrame(StackFrame::INTERNAL); -+ -+ __ Ld(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); -+ __ Lhu(a0, -+ FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); -+ __ mv(a2, a0); -+ -+ __ InvokeFunction(a1, a2, a0, JUMP_FUNCTION); -+} -+ -+const bool LiveEdit::kFrameDropperSupported = true; -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/deoptimizer/riscv64/deoptimizer-riscv64.cc -@@ -0,0 +1,240 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/register-configuration.h" -+#include "src/codegen/safepoint-table.h" -+#include "src/deoptimizer/deoptimizer.h" -+ -+namespace v8 { -+namespace internal { -+ -+const bool Deoptimizer::kSupportsFixedDeoptExitSizes = false; -+const int Deoptimizer::kNonLazyDeoptExitSize = 0; -+const int Deoptimizer::kLazyDeoptExitSize = 0; -+ -+#define __ masm-> -+ -+// This code tries to be close to ia32 code so that any changes can be -+// easily ported. -+void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, -+ Isolate* isolate, -+ DeoptimizeKind deopt_kind) { -+ NoRootArrayScope no_root_array(masm); -+ -+ // Unlike on ARM we don't save all the registers, just the useful ones. -+ // For the rest, there are gaps on the stack, so the offsets remain the same. -+ const int kNumberOfRegisters = Register::kNumRegisters; -+ -+ RegList restored_regs = kJSCallerSaved | kCalleeSaved; -+ RegList saved_regs = restored_regs | sp.bit() | ra.bit(); -+ -+ const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; -+ -+ // Save all double FPU registers before messing with them. -+ __ Sub64(sp, sp, Operand(kDoubleRegsSize)); -+ const RegisterConfiguration* config = RegisterConfiguration::Default(); -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); -+ int offset = code * kDoubleSize; -+ __ StoreDouble(fpu_reg, MemOperand(sp, offset)); -+ } -+ -+ // Push saved_regs (needed to populate FrameDescription::registers_). -+ // Leave gaps for other registers. -+ __ Sub64(sp, sp, kNumberOfRegisters * kPointerSize); -+ for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { -+ if ((saved_regs & (1 << i)) != 0) { -+ __ Sd(ToRegister(i), MemOperand(sp, kPointerSize * i)); -+ } -+ } -+ -+ __ li(a2, Operand(ExternalReference::Create( -+ IsolateAddressId::kCEntryFPAddress, isolate))); -+ __ Sd(fp, MemOperand(a2)); -+ -+ const int kSavedRegistersAreaSize = -+ (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; -+ -+ // Get the bailout is passed as kRootRegister by the caller. -+ __ mv(a2, kRootRegister); -+ -+ // Get the address of the location in the code object (a3) (return -+ // address for lazy deoptimization) and compute the fp-to-sp delta in -+ // register a4. -+ __ mv(a3, ra); -+ __ Add64(a4, sp, Operand(kSavedRegistersAreaSize)); -+ -+ __ Sub64(a4, fp, a4); -+ -+ // Allocate a new deoptimizer object. -+ __ PrepareCallCFunction(6, a5); -+ // Pass six arguments, according to n64 ABI. -+ __ mv(a0, zero_reg); -+ Label context_check; -+ __ Ld(a1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); -+ __ JumpIfSmi(a1, &context_check); -+ __ Ld(a0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); -+ __ bind(&context_check); -+ __ li(a1, Operand(static_cast(deopt_kind))); -+ // a2: bailout id already loaded. -+ // a3: code address or 0 already loaded. -+ // a4: already has fp-to-sp delta. -+ __ li(a5, Operand(ExternalReference::isolate_address(isolate))); -+ -+ // Call Deoptimizer::New(). -+ { -+ AllowExternalCallThatCantCauseGC scope(masm); -+ __ CallCFunction(ExternalReference::new_deoptimizer_function(), 6); -+ } -+ -+ // Preserve "deoptimizer" object in register a0 and get the input -+ // frame descriptor pointer to a1 (deoptimizer->input_); -+ // Move deopt-obj to a0 for call to Deoptimizer::ComputeOutputFrames() below. -+ __ Ld(a1, MemOperand(a0, Deoptimizer::input_offset())); -+ -+ // Copy core registers into FrameDescription::registers_[kNumRegisters]. -+ DCHECK_EQ(Register::kNumRegisters, kNumberOfRegisters); -+ for (int i = 0; i < kNumberOfRegisters; i++) { -+ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); -+ if ((saved_regs & (1 << i)) != 0) { -+ __ Ld(a2, MemOperand(sp, i * kPointerSize)); -+ __ Sd(a2, MemOperand(a1, offset)); -+ } else if (FLAG_debug_code) { -+ __ li(a2, kDebugZapValue); -+ __ Sd(a2, MemOperand(a1, offset)); -+ } -+ } -+ -+ int double_regs_offset = FrameDescription::double_registers_offset(); -+ // Copy FPU registers to -+ // double_registers_[DoubleRegister::kNumAllocatableRegisters] -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ int dst_offset = code * kDoubleSize + double_regs_offset; -+ int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; -+ __ LoadDouble(ft0, MemOperand(sp, src_offset)); -+ __ StoreDouble(ft0, MemOperand(a1, dst_offset)); -+ } -+ -+ // Remove the saved registers from the stack. -+ __ Add64(sp, sp, Operand(kSavedRegistersAreaSize)); -+ -+ // Compute a pointer to the unwinding limit in register a2; that is -+ // the first stack slot not part of the input frame. -+ __ Ld(a2, MemOperand(a1, FrameDescription::frame_size_offset())); -+ __ Add64(a2, a2, sp); -+ -+ // Unwind the stack down to - but not including - the unwinding -+ // limit and copy the contents of the activation frame to the input -+ // frame description. -+ __ Add64(a3, a1, Operand(FrameDescription::frame_content_offset())); -+ Label pop_loop; -+ Label pop_loop_header; -+ __ BranchShort(&pop_loop_header); -+ __ bind(&pop_loop); -+ __ pop(a4); -+ __ Sd(a4, MemOperand(a3, 0)); -+ __ addi(a3, a3, sizeof(uint64_t)); -+ __ bind(&pop_loop_header); -+ __ BranchShort(&pop_loop, ne, a2, Operand(sp)); -+ // Compute the output frame in the deoptimizer. -+ __ push(a0); // Preserve deoptimizer object across call. -+ // a0: deoptimizer object; a1: scratch. -+ __ PrepareCallCFunction(1, a1); -+ // Call Deoptimizer::ComputeOutputFrames(). -+ { -+ AllowExternalCallThatCantCauseGC scope(masm); -+ __ CallCFunction(ExternalReference::compute_output_frames_function(), 1); -+ } -+ __ pop(a0); // Restore deoptimizer object (class Deoptimizer). -+ -+ __ Ld(sp, MemOperand(a0, Deoptimizer::caller_frame_top_offset())); -+ -+ // Replace the current (input) frame with the output frames. -+ Label outer_push_loop, inner_push_loop, outer_loop_header, inner_loop_header; -+ // Outer loop state: a4 = current "FrameDescription** output_", -+ // a1 = one past the last FrameDescription**. -+ __ Lw(a1, MemOperand(a0, Deoptimizer::output_count_offset())); -+ __ Ld(a4, MemOperand(a0, Deoptimizer::output_offset())); // a4 is output_. -+ __ CalcScaledAddress(a1, a4, a1, kPointerSizeLog2); -+ __ BranchShort(&outer_loop_header); -+ __ bind(&outer_push_loop); -+ // Inner loop state: a2 = current FrameDescription*, a3 = loop index. -+ __ Ld(a2, MemOperand(a4, 0)); // output_[ix] -+ __ Ld(a3, MemOperand(a2, FrameDescription::frame_size_offset())); -+ __ BranchShort(&inner_loop_header); -+ __ bind(&inner_push_loop); -+ __ Sub64(a3, a3, Operand(sizeof(uint64_t))); -+ __ Add64(a6, a2, Operand(a3)); -+ __ Ld(a7, MemOperand(a6, FrameDescription::frame_content_offset())); -+ __ push(a7); -+ __ bind(&inner_loop_header); -+ __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); -+ -+ __ Add64(a4, a4, Operand(kPointerSize)); -+ __ bind(&outer_loop_header); -+ __ BranchShort(&outer_push_loop, lt, a4, Operand(a1)); -+ -+ __ Ld(a1, MemOperand(a0, Deoptimizer::input_offset())); -+ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { -+ int code = config->GetAllocatableDoubleCode(i); -+ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); -+ int src_offset = code * kDoubleSize + double_regs_offset; -+ __ LoadDouble(fpu_reg, MemOperand(a1, src_offset)); -+ } -+ -+ // Push pc and continuation from the last output frame. -+ __ Ld(a6, MemOperand(a2, FrameDescription::pc_offset())); -+ __ push(a6); -+ __ Ld(a6, MemOperand(a2, FrameDescription::continuation_offset())); -+ __ push(a6); -+ -+ // Technically restoring 't3' should work unless zero_reg is also restored -+ // but it's safer to check for this. -+ DCHECK(!(t3.bit() & restored_regs)); -+ // Restore the registers from the last output frame. -+ __ mv(t3, a2); -+ for (int i = kNumberOfRegisters - 1; i >= 0; i--) { -+ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); -+ if ((restored_regs & (1 << i)) != 0) { -+ __ Ld(ToRegister(i), MemOperand(t3, offset)); -+ } -+ } -+ -+ __ pop(t3); // Get continuation, leave pc on stack. -+ __ pop(ra); -+ __ Jump(t3); -+ __ stop(); -+} -+ -+// Maximum size of a table entry generated below. -+// FIXME(RISCV): Is this value correct? -+const int Deoptimizer::table_entry_size_ = 2 * kInstrSize; -+ -+Float32 RegisterValues::GetFloatRegister(unsigned n) const { -+ return Float32::FromBits( -+ static_cast(double_registers_[n].get_bits())); -+} -+ -+void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { -+ SetFrameSlot(offset, value); -+} -+ -+void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { -+ SetFrameSlot(offset, value); -+} -+ -+void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { -+ // No embedded constant pool support. -+ UNREACHABLE(); -+} -+ -+void FrameDescription::SetPc(intptr_t pc) { pc_ = pc; } -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 ---- a/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h -+++ b/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h -@@ -86,6 +86,7 @@ - static const uint32_t kElfMachARM64 = 183; - static const uint32_t kElfMachS390x = 22; - static const uint32_t kElfMachPPC64 = 21; -+ static const uint32_t kElfMachRISCV = 243; - - uint32_t GetElfMach() { - #if V8_TARGET_ARCH_IA32 -@@ -104,6 +105,8 @@ - return kElfMachS390x; - #elif V8_TARGET_ARCH_PPC64 - return kElfMachPPC64; -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ return kElfMachRISCV; - #else - UNIMPLEMENTED(); - return 0; ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/diagnostics/riscv64/disasm-riscv64.cc -@@ -0,0 +1,1448 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// A Disassembler object is used to disassemble a block of code instruction by -+// instruction. The default implementation of the NameConverter object can be -+// overriden to modify register names or to do symbol lookup on addresses. -+// -+// The example below will disassemble a block of code and print it to stdout. -+// -+// NameConverter converter; -+// Disassembler d(converter); -+// for (byte* pc = begin; pc < end;) { -+// v8::internal::EmbeddedVector buffer; -+// byte* prev_pc = pc; -+// pc += d.InstructionDecode(buffer, pc); -+// printf("%p %08x %s\n", -+// prev_pc, *reinterpret_cast(prev_pc), buffer); -+// } -+// -+// The Disassembler class also has a convenience method to disassemble a block -+// of code into a FILE*, meaning that the above functionality could also be -+// achieved by just calling Disassembler::Disassemble(stdout, begin, end); -+ -+#include -+#include -+#include -+#include -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/base/platform/platform.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/diagnostics/disasm.h" -+ -+namespace v8 { -+namespace internal { -+ -+//------------------------------------------------------------------------------ -+ -+// Decoder decodes and disassembles instructions into an output buffer. -+// It uses the converter to convert register names and call destinations into -+// more informative description. -+class Decoder { -+ public: -+ Decoder(const disasm::NameConverter& converter, -+ v8::internal::Vector out_buffer) -+ : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { -+ out_buffer_[out_buffer_pos_] = '\0'; -+ } -+ -+ ~Decoder() {} -+ -+ // Writes one disassembled instruction into 'buffer' (0-terminated). -+ // Returns the length of the disassembled machine instruction in bytes. -+ int InstructionDecode(byte* instruction); -+ -+ private: -+ // Bottleneck functions to print into the out_buffer. -+ void PrintChar(const char ch); -+ void Print(const char* str); -+ -+ // Printing of common values. -+ void PrintRegister(int reg); -+ void PrintFPURegister(int freg); -+ void PrintFPUStatusRegister(int freg); -+ void PrintRs1(Instruction* instr); -+ void PrintRs2(Instruction* instr); -+ void PrintRd(Instruction* instr); -+ void PrintVs1(Instruction* instr); -+ void PrintFRs1(Instruction* instr); -+ void PrintFRs2(Instruction* instr); -+ void PrintFRs3(Instruction* instr); -+ void PrintFRd(Instruction* instr); -+ void PrintImm12(Instruction* instr); -+ void PrintImm12X(Instruction* instr); -+ void PrintImm20U(Instruction* instr); -+ void PrintImm20J(Instruction* instr); -+ void PrintShamt(Instruction* instr); -+ void PrintShamt32(Instruction* instr); -+ void PrintAcquireRelease(Instruction* instr); -+ void PrintBranchOffset(Instruction* instr); -+ void PrintStoreOffset(Instruction* instr); -+ void PrintCSRReg(Instruction* instr); -+ void PrintRoundingMode(Instruction* instr); -+ void PrintMemoryOrder(Instruction* instr, bool is_pred); -+ -+ // Each of these functions decodes one particular instruction type. -+ void DecodeRType(Instruction* instr); -+ void DecodeR4Type(Instruction* instr); -+ void DecodeRAType(Instruction* instr); -+ void DecodeRFPType(Instruction* instr); -+ void DecodeIType(Instruction* instr); -+ void DecodeSType(Instruction* instr); -+ void DecodeBType(Instruction* instr); -+ void DecodeUType(Instruction* instr); -+ void DecodeJType(Instruction* instr); -+ -+ // Printing of instruction name. -+ void PrintInstructionName(Instruction* instr); -+ -+ // Handle formatting of instructions and their options. -+ int FormatRegister(Instruction* instr, const char* option); -+ int FormatFPURegisterOrRoundMode(Instruction* instr, const char* option); -+ int FormatOption(Instruction* instr, const char* option); -+ void Format(Instruction* instr, const char* format); -+ void Unknown(Instruction* instr); -+ -+ const disasm::NameConverter& converter_; -+ v8::internal::Vector out_buffer_; -+ int out_buffer_pos_; -+ -+ DISALLOW_COPY_AND_ASSIGN(Decoder); -+}; -+ -+// Support for assertions in the Decoder formatting functions. -+#define STRING_STARTS_WITH(string, compare_string) \ -+ (strncmp(string, compare_string, strlen(compare_string)) == 0) -+ -+// Append the ch to the output buffer. -+void Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; } -+ -+// Append the str to the output buffer. -+void Decoder::Print(const char* str) { -+ char cur = *str++; -+ while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { -+ PrintChar(cur); -+ cur = *str++; -+ } -+ out_buffer_[out_buffer_pos_] = 0; -+} -+ -+// Print the register name according to the active name converter. -+void Decoder::PrintRegister(int reg) { -+ Print(converter_.NameOfCPURegister(reg)); -+} -+ -+void Decoder::PrintRs1(Instruction* instr) { -+ int reg = instr->Rs1Value(); -+ PrintRegister(reg); -+} -+ -+void Decoder::PrintRs2(Instruction* instr) { -+ int reg = instr->Rs2Value(); -+ PrintRegister(reg); -+} -+ -+void Decoder::PrintRd(Instruction* instr) { -+ int reg = instr->RdValue(); -+ PrintRegister(reg); -+} -+ -+void Decoder::PrintVs1(Instruction* instr) { -+ int val = instr->Rs1Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", val); -+} -+ -+// Print the FPUregister name according to the active name converter. -+void Decoder::PrintFPURegister(int freg) { -+ Print(converter_.NameOfXMMRegister(freg)); -+} -+ -+void Decoder::PrintFRs1(Instruction* instr) { -+ int reg = instr->Rs1Value(); -+ PrintFPURegister(reg); -+} -+ -+void Decoder::PrintFRs2(Instruction* instr) { -+ int reg = instr->Rs2Value(); -+ PrintFPURegister(reg); -+} -+ -+void Decoder::PrintFRs3(Instruction* instr) { -+ int reg = instr->Rs3Value(); -+ PrintFPURegister(reg); -+} -+ -+void Decoder::PrintFRd(Instruction* instr) { -+ int reg = instr->RdValue(); -+ PrintFPURegister(reg); -+} -+ -+void Decoder::PrintImm12X(Instruction* instr) { -+ int32_t imm = instr->Imm12Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm); -+} -+ -+void Decoder::PrintImm12(Instruction* instr) { -+ int32_t imm = instr->Imm12Value(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); -+} -+ -+void Decoder::PrintBranchOffset(Instruction* instr) { -+ int32_t imm = instr->BranchOffset(); -+ const char* target = converter_.NameOfAddress(reinterpret_cast(instr) + imm); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d -> %s", imm, target); -+} -+ -+void Decoder::PrintStoreOffset(Instruction* instr) { -+ int32_t imm = instr->StoreOffset(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); -+} -+ -+void Decoder::PrintImm20U(Instruction* instr) { -+ int32_t imm = instr->Imm20UValue(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm); -+} -+ -+void Decoder::PrintImm20J(Instruction* instr) { -+ int32_t imm = instr->Imm20JValue(); -+ const char* target = converter_.NameOfAddress(reinterpret_cast(instr) + imm); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d -> %s", imm, target); -+} -+ -+void Decoder::PrintShamt(Instruction* instr) { -+ int32_t imm = instr->Shamt(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); -+} -+ -+void Decoder::PrintShamt32(Instruction* instr) { -+ int32_t imm = instr->Shamt32(); -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); -+} -+ -+void Decoder::PrintAcquireRelease(Instruction* instr) { -+ bool aq = instr->AqValue(); -+ bool rl = instr->RlValue(); -+ if (aq || rl) { -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "."); -+ } -+ if (aq) { -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "aq"); -+ } -+ if (rl) { -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "rl"); -+ } -+} -+ -+void Decoder::PrintCSRReg(Instruction* instr) { -+ int32_t csr_reg = instr->CsrValue(); -+ std::string s; -+ switch (csr_reg) { -+ case csr_fflags: // Floating-Point Accrued Exceptions (RW) -+ s = "csr_fflags"; -+ break; -+ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) -+ s = "csr_frm"; -+ break; -+ case csr_fcsr: // Floating-Point Control and Status Register (RW) -+ s = "csr_fcsr"; -+ break; -+ case csr_cycle: -+ s = "csr_cycle"; -+ break; -+ case csr_time: -+ s = "csr_time"; -+ break; -+ case csr_instret: -+ s = "csr_instret"; -+ break; -+ case csr_cycleh: -+ s = "csr_cycleh"; -+ break; -+ case csr_timeh: -+ s = "csr_timeh"; -+ break; -+ case csr_instreth: -+ s = "csr_instreth"; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); -+} -+ -+void Decoder::PrintRoundingMode(Instruction* instr) { -+ int frm = instr->RoundMode(); -+ std::string s; -+ switch (frm) { -+ case RNE: -+ s = "RNE"; -+ break; -+ case RTZ: -+ s = "RTZ"; -+ break; -+ case RDN: -+ s = "RDN"; -+ break; -+ case RUP: -+ s = "RUP"; -+ break; -+ case RMM: -+ s = "RMM"; -+ break; -+ case DYN: -+ s = "DYN"; -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); -+} -+ -+void Decoder::PrintMemoryOrder(Instruction* instr, bool is_pred) { -+ int memOrder = instr->MemoryOrder(is_pred); -+ std::string s; -+ if ((memOrder & PSI) == PSI) { -+ s += "i"; -+ } -+ if ((memOrder & PSO) == PSO) { -+ s += "o"; -+ } -+ if ((memOrder & PSR) == PSR) { -+ s += "r"; -+ } -+ if ((memOrder & PSW) == PSW) { -+ s += "w"; -+ } -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); -+} -+ -+// Printing of instruction name. -+void Decoder::PrintInstructionName(Instruction* instr) {} -+ -+// Handle all register based formatting in this function to reduce the -+// complexity of FormatOption. -+int Decoder::FormatRegister(Instruction* instr, const char* format) { -+ DCHECK_EQ(format[0], 'r'); -+ if (format[1] == 's') { // 'rs[12]: Rs register. -+ if (format[2] == '1') { -+ int reg = instr->Rs1Value(); -+ PrintRegister(reg); -+ return 3; -+ } else if (format[2] == '2') { -+ int reg = instr->Rs2Value(); -+ PrintRegister(reg); -+ return 3; -+ } -+ UNREACHABLE(); -+ } else if (format[1] == 'd') { // 'rd: rd register. -+ int reg = instr->RdValue(); -+ PrintRegister(reg); -+ return 2; -+ } -+ UNREACHABLE(); -+} -+ -+// Handle all FPUregister based formatting in this function to reduce the -+// complexity of FormatOption. -+int Decoder::FormatFPURegisterOrRoundMode(Instruction* instr, -+ const char* format) { -+ DCHECK_EQ(format[0], 'f'); -+ if (format[1] == 's') { // 'fs[1-3]: Rs register. -+ if (format[2] == '1') { -+ int reg = instr->Rs1Value(); -+ PrintFPURegister(reg); -+ return 3; -+ } else if (format[2] == '2') { -+ int reg = instr->Rs2Value(); -+ PrintFPURegister(reg); -+ return 3; -+ } else if (format[2] == '3') { -+ int reg = instr->Rs3Value(); -+ PrintFPURegister(reg); -+ return 3; -+ } -+ UNREACHABLE(); -+ } else if (format[1] == 'd') { // 'fd: fd register. -+ int reg = instr->RdValue(); -+ PrintFPURegister(reg); -+ return 2; -+ } else if (format[1] == 'r') { // 'frm -+ DCHECK(STRING_STARTS_WITH(format, "frm")); -+ PrintRoundingMode(instr); -+ return 3; -+ } -+ UNREACHABLE(); -+} -+ -+// FormatOption takes a formatting string and interprets it based on -+// the current instructions. The format string points to the first -+// character of the option string (the option escape has already been -+// consumed by the caller.) FormatOption returns the number of -+// characters that were consumed from the formatting string. -+int Decoder::FormatOption(Instruction* instr, const char* format) { -+ switch (format[0]) { -+ case 'c': { // `csr: CSR registers -+ if (format[1] == 's') { -+ if (format[2] == 'r') { -+ PrintCSRReg(instr); -+ return 3; -+ } -+ } -+ UNREACHABLE(); -+ } -+ case 'i': { // 'imm12, 'imm12x, 'imm20U, or 'imm20J: Immediates. -+ if (format[3] == '1') { -+ if (format[4] == '2') { -+ DCHECK(STRING_STARTS_WITH(format, "imm12")); -+ if (format[5] == 'x') { -+ PrintImm12X(instr); -+ return 6; -+ } -+ PrintImm12(instr); -+ return 5; -+ } -+ } else if (format[3] == '2' && format[4] == '0') { -+ DCHECK(STRING_STARTS_WITH(format, "imm20")); -+ switch (format[5]) { -+ case 'U': -+ DCHECK(STRING_STARTS_WITH(format, "imm20U")); -+ PrintImm20U(instr); -+ break; -+ case 'J': -+ DCHECK(STRING_STARTS_WITH(format, "imm20J")); -+ PrintImm20J(instr); -+ break; -+ } -+ return 6; -+ } -+ UNREACHABLE(); -+ } -+ case 'o': { // 'offB or 'offS: Offsets. -+ if (format[3] == 'B') { -+ DCHECK(STRING_STARTS_WITH(format, "offB")); -+ PrintBranchOffset(instr); -+ return 4; -+ } else if (format[3] == 'S') { -+ DCHECK(STRING_STARTS_WITH(format, "offS")); -+ PrintStoreOffset(instr); -+ return 4; -+ } -+ UNREACHABLE(); -+ } -+ case 'r': { // 'r: registers. -+ return FormatRegister(instr, format); -+ } -+ case 'f': { // 'f: FPUregisters or `frm -+ return FormatFPURegisterOrRoundMode(instr, format); -+ } -+ case 'a': { // 'a: Atomic acquire and release. -+ PrintAcquireRelease(instr); -+ return 1; -+ } -+ case 'p': { // `pre -+ DCHECK(STRING_STARTS_WITH(format, "pre")); -+ PrintMemoryOrder(instr, true); -+ return 3; -+ } -+ case 's': { // 's32 or 's64: Shift amount. -+ if (format[1] == '3') { -+ DCHECK(STRING_STARTS_WITH(format, "s32")); -+ PrintShamt32(instr); -+ return 3; -+ } else if (format[1] == '6') { -+ DCHECK(STRING_STARTS_WITH(format, "s64")); -+ PrintShamt(instr); -+ return 3; -+ } else if (format[1] == 'u') { -+ DCHECK(STRING_STARTS_WITH(format, "suc")); -+ PrintMemoryOrder(instr, false); -+ return 3; -+ } -+ UNREACHABLE(); -+ } -+ case 'v': { // 'vs1: Raw values from register fields -+ DCHECK(STRING_STARTS_WITH(format, "vs1")); -+ PrintVs1(instr); -+ return 3; -+ } -+ } -+ UNREACHABLE(); -+} -+ -+// Format takes a formatting string for a whole instruction and prints it into -+// the output buffer. All escaped options are handed to FormatOption to be -+// parsed further. -+void Decoder::Format(Instruction* instr, const char* format) { -+ char cur = *format++; -+ while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { -+ if (cur == '\'') { // Single quote is used as the formatting escape. -+ format += FormatOption(instr, format); -+ } else { -+ out_buffer_[out_buffer_pos_++] = cur; -+ } -+ cur = *format++; -+ } -+ out_buffer_[out_buffer_pos_] = '\0'; -+} -+ -+// For currently unimplemented decodings the disassembler calls Unknown(instr) -+// which will just print "unknown" of the instruction bits. -+void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); } -+ -+// RISCV Instruction Decode Routine -+void Decoder::DecodeRType(Instruction* instr) { -+ switch (instr->InstructionBits() & kRTypeMask) { -+ case RO_ADD: -+ Format(instr, "add 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SUB: -+ if (instr->Rs1Value() == zero_reg.code()) -+ Format(instr, "neg 'rd, rs2"); -+ else -+ Format(instr, "sub 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SLL: -+ Format(instr, "sll 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SLT: -+ if (instr->Rs2Value() == zero_reg.code()) -+ Format(instr, "sltz 'rd, 'rs1"); -+ else if (instr->Rs1Value() == zero_reg.code()) -+ Format(instr, "sgtz 'rd, 'rs2"); -+ else -+ Format(instr, "slt 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SLTU: -+ if (instr->Rs1Value() == zero_reg.code()) -+ Format(instr, "snez 'rd, 'rs2"); -+ else -+ Format(instr, "sltu 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_XOR: -+ Format(instr, "xor 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SRL: -+ Format(instr, "srl 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SRA: -+ Format(instr, "sra 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_OR: -+ Format(instr, "or 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_AND: -+ Format(instr, "and 'rd, 'rs1, 'rs2"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_ADDW: -+ Format(instr, "addw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SUBW: -+ if (instr->Rs1Value() == zero_reg.code()) -+ Format(instr, "negw 'rd, 'rs2"); -+ else -+ Format(instr, "subw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SLLW: -+ Format(instr, "sllw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SRLW: -+ Format(instr, "srlw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_SRAW: -+ Format(instr, "sraw 'rd, 'rs1, 'rs2"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ // TODO: Add RISCV M extension macro -+ case RO_MUL: -+ Format(instr, "mul 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_MULH: -+ Format(instr, "mulh 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_MULHSU: -+ Format(instr, "mulhsu 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_MULHU: -+ Format(instr, "mulhu 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_DIV: -+ Format(instr, "div 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_DIVU: -+ Format(instr, "divu 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_REM: -+ Format(instr, "rem 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_REMU: -+ Format(instr, "remu 'rd, 'rs1, 'rs2"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_MULW: -+ Format(instr, "mulw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_DIVW: -+ Format(instr, "divw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_DIVUW: -+ Format(instr, "divuw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_REMW: -+ Format(instr, "remw 'rd, 'rs1, 'rs2"); -+ break; -+ case RO_REMUW: -+ Format(instr, "remuw 'rd, 'rs1, 'rs2"); -+ break; -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: End Add RISCV M extension macro -+ default: { -+ switch (instr->BaseOpcode()) { -+ case AMO: -+ DecodeRAType(instr); -+ break; -+ case OP_FP: -+ DecodeRFPType(instr); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ } -+ } -+} -+ -+void Decoder::DecodeRAType(Instruction* instr) { -+ // TODO: Add macro for RISCV A extension -+ // Special handling for A extension instructions because it uses func5 -+ // For all A extension instruction, V8 simulator is pure sequential. No -+ // Memory address lock or other synchronizaiton behaviors. -+ switch (instr->InstructionBits() & kRATypeMask) { -+ case RO_LR_W: -+ Format(instr, "lr.w'a 'rd, ('rs1)"); -+ break; -+ case RO_SC_W: -+ Format(instr, "sc.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOSWAP_W: -+ Format(instr, "amoswap.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOADD_W: -+ Format(instr, "amoadd.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOXOR_W: -+ Format(instr, "amoxor.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOAND_W: -+ Format(instr, "amoand.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOOR_W: -+ Format(instr, "amoor.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMIN_W: -+ Format(instr, "amomin.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMAX_W: -+ Format(instr, "amomax.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMINU_W: -+ Format(instr, "amominu.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMAXU_W: -+ Format(instr, "amomaxu.w'a 'rd, 'rs2, ('rs1)"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_LR_D: -+ Format(instr, "lr.d'a 'rd, ('rs1)"); -+ break; -+ case RO_SC_D: -+ Format(instr, "sc.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOSWAP_D: -+ Format(instr, "amoswap.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOADD_D: -+ Format(instr, "amoadd.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOXOR_D: -+ Format(instr, "amoxor.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOAND_D: -+ Format(instr, "amoand.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOOR_D: -+ Format(instr, "amoor.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMIN_D: -+ Format(instr, "amomin.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMAX_D: -+ Format(instr, "amoswap.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMINU_D: -+ Format(instr, "amominu.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+ case RO_AMOMAXU_D: -+ Format(instr, "amomaxu.d'a 'rd, 'rs2, ('rs1)"); -+ break; -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: End Add macro for RISCV A extension -+ default: { -+ UNSUPPORTED_RISCV(); -+ } -+ } -+} -+ -+void Decoder::DecodeRFPType(Instruction* instr) { -+ // OP_FP instructions (F/D) uses func7 first. Some further uses fun3 and rs2() -+ -+ // kRATypeMask is only for func7 -+ switch (instr->InstructionBits() & kRFPTypeMask) { -+ // TODO: Add macro for RISCV F extension -+ case RO_FADD_S: -+ Format(instr, "fadd.s 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FSUB_S: -+ Format(instr, "fsub.s 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FMUL_S: -+ Format(instr, "fmul.s 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FDIV_S: -+ Format(instr, "fdiv.s 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FSQRT_S: -+ Format(instr, "fsqrt.s 'fd, 'fs1"); -+ break; -+ case RO_FSGNJ_S: { // RO_FSGNJN_S RO_FSGNJX_S -+ switch (instr->Funct3Value()) { -+ case 0b000: // RO_FSGNJ_S -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fmv.s 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnj.s 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FSGNJN_S -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fneg.s 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnjn.s 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b010: // RO_FSGNJX_S -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fabs.s 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnjx.s 'fd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FMIN_S: { // RO_FMAX_S -+ switch (instr->Funct3Value()) { -+ case 0b000: // RO_FMIN_S -+ Format(instr, "fmin.s 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FMAX_S -+ Format(instr, "fmax.s 'fd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FCVT_W_S: { // RO_FCVT_WU_S , 64F RO_FCVT_L_S RO_FCVT_LU_S -+ switch (instr->Rs2Value()) { -+ case 0b00000: // RO_FCVT_W_S -+ Format(instr, "fcvt.w.s ['frm] 'rd, 'fs1"); -+ break; -+ case 0b00001: // RO_FCVT_WU_S -+ Format(instr, "fcvt.wu.s ['frm] 'rd, 'fs1"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: // RO_FCVT_L_S -+ Format(instr, "fcvt.l.s ['frm] 'rd, 'fs1"); -+ break; -+ case 0b00011: // RO_FCVT_LU_S -+ Format(instr, "fcvt.lu.s ['frm] 'rd, 'fs1"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FMV: { // RO_FCLASS_S -+ if (instr->Rs2Value() != 0b00000) { -+ UNSUPPORTED_RISCV(); -+ } -+ switch (instr->Funct3Value()) { -+ case 0b000: // RO_FMV_X_W -+ Format(instr, "fmv.x.w 'rd, 'fs1"); -+ break; -+ case 0b001: // RO_FCLASS_S -+ Format(instr, "fclass.s 'rd, 'fs1"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FLE_S: { // RO_FEQ_S RO_FLT_S RO_FLE_S -+ switch (instr->Funct3Value()) { -+ case 0b010: // RO_FEQ_S -+ Format(instr, "feq.s 'rd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FLT_S -+ Format(instr, "flt.s 'rd, 'fs1, 'fs2"); -+ break; -+ case 0b000: // RO_FLE_S -+ Format(instr, "fle.s 'rd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FCVT_S_W: { // RO_FCVT_S_WU , 64F RO_FCVT_S_L RO_FCVT_S_LU -+ switch (instr->Rs2Value()) { -+ case 0b00000: // RO_FCVT_S_W -+ Format(instr, "fcvt.s.w 'fd, 'rs1"); -+ break; -+ case 0b00001: // RO_FCVT_S_WU -+ Format(instr, "fcvt.s.wu 'fd, 'rs1"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: // RO_FCVT_S_L -+ Format(instr, "fcvt.s.l 'fd, 'rs1"); -+ break; -+ case 0b00011: // RO_FCVT_S_LU -+ Format(instr, "fcvt.s.lu 'fd, 'rs1"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED_RISCV(); -+ } -+ } -+ break; -+ } -+ case RO_FMV_W_X: { -+ if (instr->Funct3Value() == 0b000) { -+ Format(instr, "fmv.w.x 'fd, 'rs1"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ // TODO: Add macro for RISCV D extension -+ case RO_FADD_D: -+ Format(instr, "fadd.d 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FSUB_D: -+ Format(instr, "fsub.d 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FMUL_D: -+ Format(instr, "fmul.d 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FDIV_D: -+ Format(instr, "fdiv.d 'fd, 'fs1, 'fs2"); -+ break; -+ case RO_FSQRT_D: { -+ if (instr->Rs2Value() == 0b00000) { -+ Format(instr, "fsqrt.d 'fd, 'fs1"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FSGNJ_D: { // RO_FSGNJN_D RO_FSGNJX_D -+ switch (instr->Funct3Value()) { -+ case 0b000: // RO_FSGNJ_D -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fmv.d 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnj.d 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FSGNJN_D -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fneg.d 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnjn.d 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b010: // RO_FSGNJX_D -+ if (instr->Rs1Value() == instr->Rs2Value()) -+ Format(instr, "fabs.d 'fd, 'fs1"); -+ else -+ Format(instr, "fsgnjx.d 'fd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FMIN_D: { // RO_FMAX_D -+ switch (instr->Funct3Value()) { -+ case 0b000: // RO_FMIN_D -+ Format(instr, "fmin.d 'fd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FMAX_D -+ Format(instr, "fmax.d 'fd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case (RO_FCVT_S_D & kRFPTypeMask): { -+ if (instr->Rs2Value() == 0b00001) { -+ Format(instr, "fcvt.s.d ['frm] 'fd, 'rs1"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FCVT_D_S: { -+ if (instr->Rs2Value() == 0b00000) { -+ Format(instr, "fcvt.d.s 'fd, 'fs1"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FLE_D: { // RO_FEQ_D RO_FLT_D RO_FLE_D -+ switch (instr->Funct3Value()) { -+ case 0b010: // RO_FEQ_S -+ Format(instr, "feq.d 'rd, 'fs1, 'fs2"); -+ break; -+ case 0b001: // RO_FLT_D -+ Format(instr, "flt.d 'rd, 'fs1, 'fs2"); -+ break; -+ case 0b000: // RO_FLE_D -+ Format(instr, "fle.d 'rd, 'fs1, 'fs2"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case (RO_FCLASS_D & kRFPTypeMask): { // RO_FCLASS_D , 64D RO_FMV_X_D -+ if (instr->Rs2Value() != 0b00000) { -+ UNSUPPORTED_RISCV(); -+ break; -+ } -+ switch (instr->Funct3Value()) { -+ case 0b001: // RO_FCLASS_D -+ Format(instr, "fclass.d 'rd, 'fs1"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b000: // RO_FMV_X_D -+ Format(instr, "fmv.x.d 'rd, 'fs1"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FCVT_W_D: { // RO_FCVT_WU_D , 64F RO_FCVT_L_D RO_FCVT_LU_D -+ switch (instr->Rs2Value()) { -+ case 0b00000: // RO_FCVT_W_D -+ Format(instr, "fcvt.w.d ['frm] 'rd, 'fs1"); -+ break; -+ case 0b00001: // RO_FCVT_WU_D -+ Format(instr, "fcvt.wu.d ['frm] 'rd, 'fs1"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: // RO_FCVT_L_D -+ Format(instr, "fcvt.l.d ['frm] 'rd, 'fs1"); -+ break; -+ case 0b00011: // RO_FCVT_LU_D -+ Format(instr, "fcvt.lu.d ['frm] 'rd, 'fs1"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ case RO_FCVT_D_W: { // RO_FCVT_D_WU , 64F RO_FCVT_D_L RO_FCVT_D_LU -+ switch (instr->Rs2Value()) { -+ case 0b00000: // RO_FCVT_D_W -+ Format(instr, "fcvt.d.w 'fd, 'rs1"); -+ break; -+ case 0b00001: // RO_FCVT_D_WU -+ Format(instr, "fcvt.d.wu 'fd, 'rs1"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: // RO_FCVT_D_L -+ Format(instr, "fcvt.d.l 'fd, 'rs1"); -+ break; -+ case 0b00011: // RO_FCVT_D_LU -+ Format(instr, "fcvt.d.lu 'fd, 'rs1"); -+ break; -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_FMV_D_X: { -+ if (instr->Funct3Value() == 0b000 && instr->Rs2Value() == 0b00000) { -+ Format(instr, "fmv.d.x 'fd, 'rs1"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED_RISCV(); -+ } -+ } -+} -+ -+void Decoder::DecodeR4Type(Instruction* instr) { -+ switch (instr->InstructionBits() & kR4TypeMask) { -+ // TODO: use F Extension macro block -+ case RO_FMADD_S: -+ Format(instr, "fmadd.s 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FMSUB_S: -+ Format(instr, "fmsub.s 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FNMSUB_S: -+ Format(instr, "fnmsub.s 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FNMADD_S: -+ Format(instr, "fnmadd.s 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ // TODO: use F Extension macro block -+ case RO_FMADD_D: -+ Format(instr, "fmadd.d 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FMSUB_D: -+ Format(instr, "fmsub.d 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FNMSUB_D: -+ Format(instr, "fnmsub.d 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ case RO_FNMADD_D: -+ Format(instr, "fnmadd.d 'fd, 'fs1, 'fs2, 'fs3"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+ -+void Decoder::DecodeIType(Instruction* instr) { -+ switch (instr->InstructionBits() & kITypeMask) { -+ case RO_JALR: -+ if (instr->RdValue() == zero_reg.code() && -+ instr->Rs1Value() == ra.code() && instr->Imm12Value() == 0) -+ Format(instr, "ret"); -+ else if (instr->RdValue() == zero_reg.code() && instr->Imm12Value() == 0) -+ Format(instr, "jr 'rs1"); -+ else if (instr->RdValue() == ra.code() && instr->Imm12Value() == 0) -+ Format(instr, "jalr 'rs1"); -+ else -+ Format(instr, "jalr 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LB: -+ Format(instr, "lb 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LH: -+ Format(instr, "lh 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LW: -+ Format(instr, "lw 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LBU: -+ Format(instr, "lbu 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LHU: -+ Format(instr, "lhu 'rd, 'imm12('rs1)"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_LWU: -+ Format(instr, "lwu 'rd, 'imm12('rs1)"); -+ break; -+ case RO_LD: -+ Format(instr, "ld 'rd, 'imm12('rs1)"); -+ break; -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ case RO_ADDI: -+ if (instr->Imm12Value() == 0) { -+ if (instr->RdValue() == zero_reg.code() && -+ instr->Rs1Value() == zero_reg.code()) -+ Format(instr, "nop"); -+ else -+ Format(instr, "mv 'rd, 'rs1"); -+ } else if (instr->Rs1Value() == zero_reg.code()) { -+ Format(instr, "li 'rd, 'imm12"); -+ } else { -+ Format(instr, "addi 'rd, 'rs1, 'imm12"); -+ } -+ break; -+ case RO_SLTI: -+ Format(instr, "slti 'rd, 'rs1, 'imm12"); -+ break; -+ case RO_SLTIU: -+ if (instr->Imm12Value() == 1) -+ Format(instr, "seqz 'rd, 'rs1"); -+ else -+ Format(instr, "sltiu 'rd, 'rs1, 'imm12"); -+ break; -+ case RO_XORI: -+ if (instr->Imm12Value() == -1) -+ Format(instr, "not 'rd, 'rs1"); -+ else -+ Format(instr, "xori 'rd, 'rs1, 'imm12x"); -+ break; -+ case RO_ORI: -+ Format(instr, "ori 'rd, 'rs1, 'imm12x"); -+ break; -+ case RO_ANDI: -+ Format(instr, "andi 'rd, 'rs1, 'imm12x"); -+ break; -+ case RO_SLLI: -+ Format(instr, "slli 'rd, 'rs1, 's64"); -+ break; -+ case RO_SRLI: { // RO_SRAI -+ if (!instr->IsArithShift()) { -+ Format(instr, "srli 'rd, 'rs1, 's64"); -+ } else { -+ Format(instr, "srai 'rd, 'rs1, 's64"); -+ } -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_ADDIW: -+ if (instr->Imm12Value() == 0) -+ Format(instr, "sext.w 'rd, 'rs1"); -+ else -+ Format(instr, "addiw 'rd, 'rs1, 'imm12"); -+ break; -+ case RO_SLLIW: -+ Format(instr, "slliw 'rd, 'rs1, 's32"); -+ break; -+ case RO_SRLIW: { // RO_SRAIW -+ if (!instr->IsArithShift()) { -+ Format(instr, "srliw 'rd, 'rs1, 's32"); -+ } else { -+ Format(instr, "sraiw 'rd, 'rs1, 's32"); -+ } -+ break; -+ } -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ case RO_FENCE: -+ if (instr->MemoryOrder(true) == PSIORW && -+ instr->MemoryOrder(false) == PSIORW) -+ Format(instr, "fence"); -+ else -+ Format(instr, "fence 'pre, 'suc"); -+ break; -+ case RO_ECALL: { // RO_EBREAK -+ if (instr->Imm12Value() == 0) { // ECALL -+ Format(instr, "ecall"); -+ } else if (instr->Imm12Value() == 1) { // EBREAK -+ Format(instr, "ebreak"); -+ } else { -+ UNSUPPORTED_RISCV(); -+ } -+ break; -+ } -+ // TODO: use Zifencei Standard Extension macro block -+ case RO_FENCE_I: -+ Format(instr, "fence.i"); -+ break; -+ // TODO: use Zicsr Standard Extension macro block -+ // FIXME(RISC-V): Add special formatting for CSR registers -+ case RO_CSRRW: -+ if (instr->CsrValue() == csr_fcsr) { -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "fscsr 'rs1"); -+ else -+ Format(instr, "fscsr 'rd, 'rs1"); -+ } else if (instr->CsrValue() == csr_frm) { -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "fsrm 'rs1"); -+ else -+ Format(instr, "fsrm 'rd, 'rs1"); -+ } else if (instr->CsrValue() == csr_fflags) { -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "fsflags 'rs1"); -+ else -+ Format(instr, "fsflags 'rd, 'rs1"); -+ } else if (instr->RdValue() == zero_reg.code()) { -+ Format(instr, "csrw 'csr, 'rs1"); -+ } else { -+ Format(instr, "csrrw 'rd, 'csr, 'rs1"); -+ } -+ break; -+ case RO_CSRRS: -+ if (instr->Rs1Value() == zero_reg.code()) { -+ switch (instr->CsrValue()) { -+ case csr_instret: -+ Format(instr, "rdinstret 'rd"); -+ break; -+ case csr_instreth: -+ Format(instr, "rdinstreth 'rd"); -+ break; -+ case csr_time: -+ Format(instr, "rdtime 'rd"); -+ break; -+ case csr_timeh: -+ Format(instr, "rdtimeh 'rd"); -+ break; -+ case csr_cycle: -+ Format(instr, "rdcycle 'rd"); -+ break; -+ case csr_cycleh: -+ Format(instr, "rdcycleh 'rd"); -+ break; -+ case csr_fflags: -+ Format(instr, "frflags 'rd"); -+ break; -+ case csr_frm: -+ Format(instr, "frrm 'rd"); -+ break; -+ case csr_fcsr: -+ Format(instr, "frcsr 'rd"); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } else if (instr->Rs1Value() == zero_reg.code()) { -+ Format(instr, "csrr 'rd, 'csr"); -+ } else if (instr->RdValue() == zero_reg.code()) { -+ Format(instr, "csrs 'csr, 'rs1"); -+ } else -+ Format(instr, "csrrs 'rd, 'csr, 'rs1"); -+ break; -+ case RO_CSRRC: -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "csrc 'csr, 'rs1"); -+ else -+ Format(instr, "csrrc 'rd, 'csr, 'rs1"); -+ break; -+ case RO_CSRRWI: -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "csrwi 'csr, 'vs1"); -+ else -+ Format(instr, "csrrwi 'rd, 'csr, 'vs1"); -+ break; -+ case RO_CSRRSI: -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "csrsi 'csr, 'vs1"); -+ else -+ Format(instr, "csrrsi 'rd, 'csr, 'vs1"); -+ break; -+ case RO_CSRRCI: -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "csrci 'csr, 'vs1"); -+ else -+ Format(instr, "csrrci 'rd, 'csr, 'vs1"); -+ break; -+ // TODO: use F Extension macro block -+ case RO_FLW: -+ Format(instr, "flw 'fd, 'imm12('rs1)"); -+ break; -+ // TODO: use D Extension macro block -+ case RO_FLD: -+ Format(instr, "fld 'fd, 'imm12('rs1)"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+ -+void Decoder::DecodeSType(Instruction* instr) { -+ switch (instr->InstructionBits() & kSTypeMask) { -+ case RO_SB: -+ Format(instr, "sb 'rs2, 'offS('rs1)"); -+ break; -+ case RO_SH: -+ Format(instr, "sh 'rs2, 'offS('rs1)"); -+ break; -+ case RO_SW: -+ Format(instr, "sw 'rs2, 'offS('rs1)"); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_SD: -+ Format(instr, "sd 'rs2, 'offS('rs1)"); -+ break; -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: use F Extension macro block -+ case RO_FSW: -+ Format(instr, "fsw 'fs2, 'offS('rs1)"); -+ break; -+ // TODO: use D Extension macro block -+ case RO_FSD: -+ Format(instr, "fsd 'fs2, 'offS('rs1)"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+ -+void Decoder::DecodeBType(Instruction* instr) { -+ switch (instr->InstructionBits() & kBTypeMask) { -+ case RO_BEQ: -+ Format(instr, "beq 'rs1, 'rs2, 'offB"); -+ break; -+ case RO_BNE: -+ Format(instr, "bne 'rs1, 'rs2, 'offB"); -+ break; -+ case RO_BLT: -+ Format(instr, "blt 'rs1, 'rs2, 'offB"); -+ break; -+ case RO_BGE: -+ Format(instr, "bge 'rs1, 'rs2, 'offB"); -+ break; -+ case RO_BLTU: -+ Format(instr, "bltu 'rs1, 'rs2, 'offB"); -+ break; -+ case RO_BGEU: -+ Format(instr, "bgeu 'rs1, 'rs2, 'offB"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+void Decoder::DecodeUType(Instruction* instr) { -+ // U Type doesn't have additional mask -+ switch (instr->BaseOpcodeFieldRaw()) { -+ case RO_LUI: -+ Format(instr, "lui 'rd, 'imm20U"); -+ break; -+ case RO_AUIPC: -+ Format(instr, "auipc 'rd, 'imm20U"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+void Decoder::DecodeJType(Instruction* instr) { -+ // J Type doesn't have additional mask -+ switch (instr->BaseOpcodeValue()) { -+ case RO_JAL: -+ if (instr->RdValue() == zero_reg.code()) -+ Format(instr, "j 'imm20J"); -+ else if (instr->RdValue() == ra.code()) -+ Format(instr, "jal 'imm20J"); -+ else -+ Format(instr, "jal 'rd, 'imm20J"); -+ break; -+ default: -+ UNSUPPORTED_RISCV(); -+ } -+} -+ -+// Disassemble the instruction at *instr_ptr into the output buffer. -+// All instructions are one word long, except for the simulator -+// pseudo-instruction stop(msg). For that one special case, we return -+// size larger than one kInstrSize. -+int Decoder::InstructionDecode(byte* instr_ptr) { -+ Instruction* instr = Instruction::At(instr_ptr); -+ // Print raw instruction bytes. -+ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", -+ instr->InstructionBits()); -+ switch (instr->InstructionType()) { -+ case Instruction::kRType: -+ DecodeRType(instr); -+ break; -+ case Instruction::kR4Type: -+ DecodeR4Type(instr); -+ break; -+ case Instruction::kIType: -+ DecodeIType(instr); -+ break; -+ case Instruction::kSType: -+ DecodeSType(instr); -+ break; -+ case Instruction::kBType: -+ DecodeBType(instr); -+ break; -+ case Instruction::kUType: -+ DecodeUType(instr); -+ break; -+ case Instruction::kJType: -+ DecodeJType(instr); -+ break; -+ default: -+ Format(instr, "UNSUPPORTED"); -+ UNSUPPORTED_RISCV(); -+ } -+ return kInstrSize; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+//------------------------------------------------------------------------------ -+ -+namespace disasm { -+ -+const char* NameConverter::NameOfAddress(byte* addr) const { -+ v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast(addr)); -+ return tmp_buffer_.begin(); -+} -+ -+const char* NameConverter::NameOfConstant(byte* addr) const { -+ return NameOfAddress(addr); -+} -+ -+const char* NameConverter::NameOfCPURegister(int reg) const { -+ return v8::internal::Registers::Name(reg); -+} -+ -+const char* NameConverter::NameOfXMMRegister(int reg) const { -+ return v8::internal::FPURegisters::Name(reg); -+} -+ -+const char* NameConverter::NameOfByteCPURegister(int reg) const { -+ UNREACHABLE(); // RISC-V does not have the concept of a byte register. -+ return "nobytereg"; -+} -+ -+const char* NameConverter::NameInCode(byte* addr) const { -+ // The default name converter is called for unknown code. So we will not try -+ // to access any memory. -+ return ""; -+} -+ -+//------------------------------------------------------------------------------ -+ -+int Disassembler::InstructionDecode(v8::internal::Vector buffer, -+ byte* instruction) { -+ v8::internal::Decoder d(converter_, buffer); -+ return d.InstructionDecode(instruction); -+} -+ -+// The RISC-V assembler does not currently use constant pools. -+int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; } -+ -+void Disassembler::Disassemble(FILE* f, byte* begin, byte* end, -+ UnimplementedOpcodeAction unimplemented_action) { -+ NameConverter converter; -+ Disassembler d(converter, unimplemented_action); -+ for (byte* pc = begin; pc < end;) { -+ v8::internal::EmbeddedVector buffer; -+ buffer[0] = '\0'; -+ byte* prev_pc = pc; -+ pc += d.InstructionDecode(buffer, pc); -+ v8::internal::PrintF(f, "%p %08x %s\n", static_cast(prev_pc), -+ *reinterpret_cast(prev_pc), buffer.begin()); -+ } -+} -+ -+#undef STRING_STARTS_WITH -+ -+} // namespace disasm -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- a/src/3rdparty/chromium/v8/src/execution/frame-constants.h -+++ b/src/3rdparty/chromium/v8/src/execution/frame-constants.h -@@ -356,6 +356,10 @@ - #include "src/execution/mips64/frame-constants-mips64.h" // NOLINT - #elif V8_TARGET_ARCH_S390 - #include "src/execution/s390/frame-constants-s390.h" // NOLINT -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/execution/riscv64/frame-constants-riscv64.h" // NOLINT -+#elif V8_TARGET_ARCH_RISCV -+#include "src/execution/riscv/frame-constants-riscv.h" // NOLINT - #else - #error Unsupported target architecture. - #endif ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/riscv64/frame-constants-riscv64.cc -@@ -0,0 +1,32 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/codegen/riscv64/assembler-riscv64-inl.h" -+#include "src/execution/frame-constants.h" -+#include "src/execution/frames.h" -+ -+#include "src/execution/riscv64/frame-constants-riscv64.h" -+ -+namespace v8 { -+namespace internal { -+ -+Register JavaScriptFrame::fp_register() { return v8::internal::fp; } -+Register JavaScriptFrame::context_register() { return cp; } -+Register JavaScriptFrame::constant_pool_pointer_register() { UNREACHABLE(); } -+ -+int InterpreterFrameConstants::RegisterStackSlotCount(int register_count) { -+ return register_count; -+} -+ -+int BuiltinContinuationFrameConstants::PaddingSlotCount(int register_count) { -+ USE(register_count); -+ return 0; -+} -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/riscv64/frame-constants-riscv64.h -@@ -0,0 +1,87 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ -+#define V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ -+ -+#include "src/base/bits.h" -+#include "src/base/macros.h" -+#include "src/execution/frame-constants.h" -+#include "src/wasm/baseline/liftoff-assembler-defs.h" -+#include "src/wasm/wasm-linkage.h" -+ -+namespace v8 { -+namespace internal { -+ -+class EntryFrameConstants : public AllStatic { -+ public: -+ // This is the offset to where JSEntry pushes the current value of -+ // Isolate::c_entry_fp onto the stack. -+ static constexpr int kCallerFPOffset = -+ -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); -+}; -+ -+class WasmCompileLazyFrameConstants : public TypedFrameConstants { -+ public: -+ static constexpr int kNumberOfSavedGpParamRegs = -+ arraysize(wasm::kGpParamRegisters); -+ static constexpr int kNumberOfSavedFpParamRegs = -+ arraysize(wasm::kFpParamRegisters); -+ -+ // FP-relative. -+ // Builtins::Generate_WasmCompileLazy pushes WasmInstance to the stack after -+ // pushing SavedGPParamRegs and SavedFpParamRegs onto the stack, therefore -+ // kWasmInstanceOffset is setup as such -+ static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET( -+ kNumberOfSavedGpParamRegs + kNumberOfSavedGpParamRegs); -+ static constexpr int kFixedFrameSizeFromFp = -+ TypedFrameConstants::kFixedFrameSizeFromFp + -+ kNumberOfSavedGpParamRegs * kPointerSize + -+ kNumberOfSavedFpParamRegs * kDoubleSize; -+}; -+ -+// Frame constructed by the {WasmDebugBreak} builtin. -+// After pushing the frame type marker, the builtin pushes all Liftoff cache -+// registers (see liftoff-assembler-defs.h). -+class WasmDebugBreakFrameConstants : public TypedFrameConstants { -+ public: -+ // constexpr RegList kLiftoffAssemblerGpCacheRegs = -+ // Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); -+ static constexpr uint32_t kPushedGpRegs = wasm::kLiftoffAssemblerGpCacheRegs; -+ -+ // constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( -+ // ft0, ft1, ft2, ft3, ft4, ft5, ft6, ft7, fa0, fa1, fa2, fa3, fa4, fa5, -+ // fa6, fa7, ft8, ft9, ft10, ft11); -+ static constexpr uint32_t kPushedFpRegs = wasm::kLiftoffAssemblerFpCacheRegs; -+ -+ static constexpr int kNumPushedGpRegisters = -+ base::bits::CountPopulation(kPushedGpRegs); -+ static constexpr int kNumPushedFpRegisters = -+ base::bits::CountPopulation(kPushedFpRegs); -+ -+ static constexpr int kLastPushedGpRegisterOffset = -+ -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; -+ static constexpr int kLastPushedFpRegisterOffset = -+ kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize; -+ -+ // Offsets are fp-relative. -+ static int GetPushedGpRegisterOffset(int reg_code) { -+ DCHECK_NE(0, kPushedGpRegs & (1 << reg_code)); -+ uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1); -+ return kLastPushedGpRegisterOffset + -+ base::bits::CountPopulation(lower_regs) * kSystemPointerSize; -+ } -+ -+ static int GetPushedFpRegisterOffset(int reg_code) { -+ DCHECK_NE(0, kPushedFpRegs & (1 << reg_code)); -+ uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1); -+ return kLastPushedFpRegisterOffset + -+ base::bits::CountPopulation(lower_regs) * kDoubleSize; -+ } -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/riscv64/simulator-riscv64.cc -@@ -0,0 +1,3509 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Copyright(c) 2010 - 2017, -+// The Regents of the University of California(Regents).All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, -+// with or without modification, -+// are permitted provided that the following -+// conditions are met : 1. Redistributions of source code must retain the -+// above copyright notice, this list of conditions and the following -+// disclaimer.2. Redistributions in binary form must reproduce the above -+// copyright notice, this list of conditions and the following disclaimer in -+// the -+// documentation and / -+// or -+// other materials provided with the distribution.3. Neither the name of -+// the Regents nor the names of its contributors may be used to endorse -+// or -+// promote products derived from -+// this software without specific prior written permission. -+// -+// IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, -+// INDIRECT, SPECIAL, -+// INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, -+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -+// EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+// -+// REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, -+// INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -+// PARTICULAR PURPOSE.THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, -+// IF ANY, -+// PROVIDED HEREUNDER IS PROVIDED -+// "AS IS".REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, -+// SUPPORT, UPDATES, ENHANCEMENTS, -+// OR MODIFICATIONS. -+ -+// The original source code covered by the above license above has been -+// modified significantly by the v8 project authors. -+ -+#include "src/execution/riscv64/simulator-riscv64.h" -+ -+// Only build the simulator if not compiling for real RISCV hardware. -+#if defined(USE_SIMULATOR) -+ -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "src/base/bits.h" -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/diagnostics/disasm.h" -+#include "src/heap/combined-heap.h" -+#include "src/runtime/runtime-utils.h" -+#include "src/utils/ostreams.h" -+#include "src/utils/vector.h" -+ -+namespace v8 { -+namespace internal { -+ -+DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor, -+ Simulator::GlobalMonitor::Get) -+ -+// Util functions. -+inline bool HaveSameSign(int64_t a, int64_t b) { return ((a ^ b) >= 0); } -+ -+uint32_t get_fcsr_condition_bit(uint32_t cc) { -+ if (cc == 0) { -+ return 23; -+ } else { -+ return 24 + cc; -+ } -+} -+ -+// Generated by Assembler::break_()/stop(), ebreak code is passed as immediate -+// field of a subsequent LUI instruction; otherwise returns -1 -+static inline int32_t get_ebreak_code(Instruction* instr) { -+ DCHECK(instr->InstructionBits() == kBreakInstr); -+ byte* cur = reinterpret_cast(instr); -+ Instruction* next_instr = reinterpret_cast(cur + kInstrSize); -+ if (next_instr->BaseOpcodeFieldRaw() == RO_LUI) -+ return (next_instr->Imm20UValue()); -+ else -+ return -1; -+} -+ -+// This macro provides a platform independent use of sscanf. The reason for -+// SScanF not being implemented in a platform independent was through -+// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time -+// Library does not provide vsscanf. -+#define SScanF sscanf // NOLINT -+ -+// The RiscvDebugger class is used by the simulator while debugging simulated -+// code. -+class RiscvDebugger { -+ public: -+ explicit RiscvDebugger(Simulator* sim) : sim_(sim) {} -+ -+ void Debug(); -+ // Print all registers with a nice formatting. -+ void PrintRegs(char name_prefix, int start_index, int end_index); -+ void PrintAllRegs(); -+ void PrintAllRegsIncludingFPU(); -+ -+ static const Instr kNopInstr = 0x0; -+ -+ private: -+ Simulator* sim_; -+ -+ int64_t GetRegisterValue(int regnum); -+ int64_t GetFPURegisterValue(int regnum); -+ float GetFPURegisterValueFloat(int regnum); -+ double GetFPURegisterValueDouble(int regnum); -+ bool GetValue(const char* desc, int64_t* value); -+}; -+ -+inline void UNSUPPORTED() { -+ printf("Sim: Unsupported instruction.\n"); -+ base::OS::Abort(); -+} -+ -+int64_t RiscvDebugger::GetRegisterValue(int regnum) { -+ if (regnum == kNumSimuRegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_register(regnum); -+ } -+} -+ -+int64_t RiscvDebugger::GetFPURegisterValue(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register(regnum); -+ } -+} -+ -+float RiscvDebugger::GetFPURegisterValueFloat(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register_float(regnum); -+ } -+} -+ -+double RiscvDebugger::GetFPURegisterValueDouble(int regnum) { -+ if (regnum == kNumFPURegisters) { -+ return sim_->get_pc(); -+ } else { -+ return sim_->get_fpu_register_double(regnum); -+ } -+} -+ -+bool RiscvDebugger::GetValue(const char* desc, int64_t* value) { -+ int regnum = Registers::Number(desc); -+ int fpuregnum = FPURegisters::Number(desc); -+ -+ if (regnum != kInvalidRegister) { -+ *value = GetRegisterValue(regnum); -+ return true; -+ } else if (fpuregnum != kInvalidFPURegister) { -+ *value = GetFPURegisterValue(fpuregnum); -+ return true; -+ } else if (strncmp(desc, "0x", 2) == 0) { -+ return SScanF(desc + 2, "%" SCNx64, reinterpret_cast(value)) == -+ 1; -+ } else { -+ return SScanF(desc, "%" SCNu64, reinterpret_cast(value)) == 1; -+ } -+ return false; -+} -+ -+#define REG_INFO(name) \ -+ name, GetRegisterValue(Registers::Number(name)), \ -+ GetRegisterValue(Registers::Number(name)) -+ -+void RiscvDebugger::PrintRegs(char name_prefix, int start_index, -+ int end_index) { -+ EmbeddedVector name1, name2; -+ DCHECK(name_prefix == 'a' || name_prefix == 't' || name_prefix == 's'); -+ DCHECK(start_index >= 0 && end_index <= 99); -+ int num_registers = (end_index - start_index) + 1; -+ for (int i = 0; i < num_registers / 2; i++) { -+ SNPrintF(name1, "%c%d", name_prefix, start_index + 2 * i); -+ SNPrintF(name2, "%c%d", name_prefix, start_index + 2 * i + 1); -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 -+ " %14" PRId64 " \n", -+ REG_INFO(name1.begin()), REG_INFO(name2.begin())); -+ } -+ if (num_registers % 2 == 1) { -+ SNPrintF(name1, "%c%d", name_prefix, end_index); -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \n", REG_INFO(name1.begin())); -+ } -+} -+ -+void RiscvDebugger::PrintAllRegs() { -+ PrintF("\n"); -+ // ra, sp, gp -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 -+ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", -+ REG_INFO("ra"), REG_INFO("sp"), REG_INFO("gp")); -+ -+ // tp, fp, pc -+ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 -+ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", -+ REG_INFO("tp"), REG_INFO("fp"), REG_INFO("pc")); -+ -+ // print register a0, .., a7 -+ PrintRegs('a', 0, 7); -+ // print registers s1, ..., s11 -+ PrintRegs('s', 1, 11); -+ // print registers t0, ..., t6 -+ PrintRegs('t', 0, 6); -+} -+ -+#undef REG_INFO -+ -+void RiscvDebugger::PrintAllRegsIncludingFPU() { -+#define FPU_REG_INFO(n) \ -+ FPURegisters::Name(n), GetFPURegisterValue(n), GetFPURegisterValueDouble(n) -+ -+ PrintAllRegs(); -+ -+ PrintF("\n\n"); -+ // f0, f1, f2, ... f31. -+ DCHECK(kNumFPURegisters % 2 == 0); -+ for (int i = 0; i < kNumFPURegisters; i += 2) -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e \t%3s: 0x%016" PRIx64 " %16.4e\n", -+ FPU_REG_INFO(i), FPU_REG_INFO(i + 1)); -+#undef FPU_REG_INFO -+} -+ -+void RiscvDebugger::Debug() { -+ intptr_t last_pc = -1; -+ bool done = false; -+ -+#define COMMAND_SIZE 63 -+#define ARG_SIZE 255 -+ -+#define STR(a) #a -+#define XSTR(a) STR(a) -+ -+ char cmd[COMMAND_SIZE + 1]; -+ char arg1[ARG_SIZE + 1]; -+ char arg2[ARG_SIZE + 1]; -+ char* argv[3] = {cmd, arg1, arg2}; -+ -+ // Make sure to have a proper terminating character if reaching the limit. -+ cmd[COMMAND_SIZE] = 0; -+ arg1[ARG_SIZE] = 0; -+ arg2[ARG_SIZE] = 0; -+ -+ while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) { -+ if (last_pc != sim_->get_pc()) { -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ dasm.InstructionDecode(buffer, reinterpret_cast(sim_->get_pc())); -+ PrintF(" 0x%016" PRIx64 " %s\n", sim_->get_pc(), buffer.begin()); -+ last_pc = sim_->get_pc(); -+ } -+ char* line = ReadLine("sim> "); -+ if (line == nullptr) { -+ break; -+ } else { -+ char* last_input = sim_->last_debugger_input(); -+ if (strcmp(line, "\n") == 0 && last_input != nullptr) { -+ line = last_input; -+ } else { -+ // Ownership is transferred to sim_; -+ sim_->set_last_debugger_input(line); -+ } -+ // Use sscanf to parse the individual parts of the command line. At the -+ // moment no command expects more than two parameters. -+ int argc = SScanF( -+ line, -+ "%" XSTR(COMMAND_SIZE) "s " -+ "%" XSTR(ARG_SIZE) "s " -+ "%" XSTR(ARG_SIZE) "s", -+ cmd, arg1, arg2); -+ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { -+ Instruction* instr = reinterpret_cast(sim_->get_pc()); -+ if (!(instr->IsTrap()) || -+ instr->InstructionBits() == rtCallRedirInstr) { -+ sim_->InstructionDecode( -+ reinterpret_cast(sim_->get_pc())); -+ } else { -+ // Allow si to jump over generated breakpoints. -+ PrintF("/!\\ Jumping over generated breakpoint.\n"); -+ sim_->set_pc(sim_->get_pc() + kInstrSize); -+ } -+ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { -+ // Execute the one instruction we broke at with breakpoints disabled. -+ sim_->InstructionDecode(reinterpret_cast(sim_->get_pc())); -+ // Leave the debugger shell. -+ done = true; -+ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { -+ if (argc == 2) { -+ int64_t value; -+ double dvalue; -+ if (strcmp(arg1, "all") == 0) { -+ PrintAllRegs(); -+ } else if (strcmp(arg1, "allf") == 0) { -+ PrintAllRegsIncludingFPU(); -+ } else { -+ int regnum = Registers::Number(arg1); -+ int fpuregnum = FPURegisters::Number(arg1); -+ -+ if (regnum != kInvalidRegister) { -+ value = GetRegisterValue(regnum); -+ PrintF("%s: 0x%08" PRIx64 " %" PRId64 " \n", arg1, value, -+ value); -+ } else if (fpuregnum != kInvalidFPURegister) { -+ value = GetFPURegisterValue(fpuregnum); -+ dvalue = GetFPURegisterValueDouble(fpuregnum); -+ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", -+ FPURegisters::Name(fpuregnum), value, dvalue); -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } -+ } else { -+ if (argc == 3) { -+ if (strcmp(arg2, "single") == 0) { -+ int64_t value; -+ float fvalue; -+ int fpuregnum = FPURegisters::Number(arg1); -+ -+ if (fpuregnum != kInvalidFPURegister) { -+ value = GetFPURegisterValue(fpuregnum); -+ value &= 0xFFFFFFFFUL; -+ fvalue = GetFPURegisterValueFloat(fpuregnum); -+ PrintF("%s: 0x%08" PRIx64 " %11.4e\n", arg1, value, fvalue); -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } else { -+ PrintF("print single\n"); -+ } -+ } else { -+ PrintF("print or print single\n"); -+ } -+ } -+ } else if ((strcmp(cmd, "po") == 0) || -+ (strcmp(cmd, "printobject") == 0)) { -+ if (argc == 2) { -+ int64_t value; -+ StdoutStream os; -+ if (GetValue(arg1, &value)) { -+ Object obj(value); -+ os << arg1 << ": \n"; -+#ifdef DEBUG -+ obj.Print(os); -+ os << "\n"; -+#else -+ os << Brief(obj) << "\n"; -+#endif -+ } else { -+ os << arg1 << " unrecognized\n"; -+ } -+ } else { -+ PrintF("printobject \n"); -+ } -+ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) { -+ int64_t* cur = nullptr; -+ int64_t* end = nullptr; -+ int next_arg = 1; -+ -+ if (strcmp(cmd, "stack") == 0) { -+ cur = reinterpret_cast(sim_->get_register(Simulator::sp)); -+ } else { // Command "mem". -+ if (argc < 2) { -+ PrintF("Need to specify
to mem command\n"); -+ continue; -+ } -+ int64_t value; -+ if (!GetValue(arg1, &value)) { -+ PrintF("%s unrecognized\n", arg1); -+ continue; -+ } -+ cur = reinterpret_cast(value); -+ next_arg++; -+ } -+ -+ int64_t words; -+ if (argc == next_arg) { -+ words = 10; -+ } else { -+ if (!GetValue(argv[next_arg], &words)) { -+ words = 10; -+ } -+ } -+ end = cur + words; -+ -+ while (cur < end) { -+ PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ", -+ reinterpret_cast(cur), *cur, *cur); -+ Object obj(*cur); -+ Heap* current_heap = sim_->isolate_->heap(); -+ if (obj.IsSmi() || -+ IsValidHeapObject(current_heap, HeapObject::cast(obj))) { -+ PrintF(" ("); -+ if (obj.IsSmi()) { -+ PrintF("smi %d", Smi::ToInt(obj)); -+ } else { -+ obj.ShortPrint(); -+ } -+ PrintF(")"); -+ } -+ PrintF("\n"); -+ cur++; -+ } -+ -+ } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0) || -+ (strcmp(cmd, "di") == 0)) { -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ -+ byte* cur = nullptr; -+ byte* end = nullptr; -+ -+ if (argc == 1) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ end = cur + (10 * kInstrSize); -+ } else if (argc == 2) { -+ int regnum = Registers::Number(arg1); -+ if (regnum != kInvalidRegister || strncmp(arg1, "0x", 2) == 0) { -+ // The argument is an address or a register name. -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(value); -+ // Disassemble 10 instructions at . -+ end = cur + (10 * kInstrSize); -+ } -+ } else { -+ // The argument is the number of instructions. -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ // Disassemble instructions. -+ end = cur + (value * kInstrSize); -+ } -+ } -+ } else { -+ int64_t value1; -+ int64_t value2; -+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { -+ cur = reinterpret_cast(value1); -+ end = cur + (value2 * kInstrSize); -+ } -+ } -+ -+ while (cur < end) { -+ dasm.InstructionDecode(buffer, cur); -+ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), -+ buffer.begin()); -+ cur += kInstrSize; -+ } -+ } else if (strcmp(cmd, "gdb") == 0) { -+ PrintF("relinquishing control to gdb\n"); -+ v8::base::OS::DebugBreak(); -+ PrintF("regaining control from gdb\n"); -+ } else if (strcmp(cmd, "break") == 0 -+ || strcmp(cmd, "b") == 0 -+ || strcmp(cmd, "tbreak") == 0) { -+ bool is_tbreak = strcmp(cmd, "tbreak") == 0; -+ if (argc == 2) { -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ sim_->SetBreakpoint(reinterpret_cast(value), is_tbreak); -+ } else { -+ PrintF("%s unrecognized\n", arg1); -+ } -+ } else { -+ sim_->ListBreakpoints(); -+ PrintF("Use `break
` to set or disable a breakpoint\n"); -+ PrintF("Use `tbreak
` to set or disable a temporary breakpoint\n"); -+ } -+ } else if (strcmp(cmd, "flags") == 0) { -+ PrintF("No flags on RISC-V !\n"); -+ } else if (strcmp(cmd, "stop") == 0) { -+ int64_t value; -+ if (argc == 3) { -+ // Print information about all/the specified breakpoint(s). -+ if (strcmp(arg1, "info") == 0) { -+ if (strcmp(arg2, "all") == 0) { -+ PrintF("Stop information:\n"); -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->PrintStopInfo(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->PrintStopInfo(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } else if (strcmp(arg1, "enable") == 0) { -+ // Enable all/the specified breakpoint(s). -+ if (strcmp(arg2, "all") == 0) { -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->EnableStop(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->EnableStop(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } else if (strcmp(arg1, "disable") == 0) { -+ // Disable all/the specified breakpoint(s). -+ if (strcmp(arg2, "all") == 0) { -+ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; -+ i++) { -+ sim_->DisableStop(i); -+ } -+ } else if (GetValue(arg2, &value)) { -+ sim_->DisableStop(value); -+ } else { -+ PrintF("Unrecognized argument.\n"); -+ } -+ } -+ } else { -+ PrintF("Wrong usage. Use help command for more information.\n"); -+ } -+ } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) { -+ // Print registers and disassemble. -+ PrintAllRegs(); -+ PrintF("\n"); -+ -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ v8::internal::EmbeddedVector buffer; -+ -+ byte* cur = nullptr; -+ byte* end = nullptr; -+ -+ if (argc == 1) { -+ cur = reinterpret_cast(sim_->get_pc()); -+ end = cur + (10 * kInstrSize); -+ } else if (argc == 2) { -+ int64_t value; -+ if (GetValue(arg1, &value)) { -+ cur = reinterpret_cast(value); -+ // no length parameter passed, assume 10 instructions -+ end = cur + (10 * kInstrSize); -+ } -+ } else { -+ int64_t value1; -+ int64_t value2; -+ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { -+ cur = reinterpret_cast(value1); -+ end = cur + (value2 * kInstrSize); -+ } -+ } -+ -+ while (cur < end) { -+ dasm.InstructionDecode(buffer, cur); -+ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), -+ buffer.begin()); -+ cur += kInstrSize; -+ } -+ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { -+ PrintF("cont (alias 'c')\n"); -+ PrintF(" Continue execution\n"); -+ PrintF("stepi (alias 'si')\n"); -+ PrintF(" Step one instruction\n"); -+ PrintF("print (alias 'p')\n"); -+ PrintF(" print \n"); -+ PrintF(" Print register content\n"); -+ PrintF(" Use register name 'all' to print all GPRs\n"); -+ PrintF(" Use register name 'allf' to print all GPRs and FPRs\n"); -+ PrintF("printobject (alias 'po')\n"); -+ PrintF(" printobject \n"); -+ PrintF(" Print an object from a register\n"); -+ PrintF("stack\n"); -+ PrintF(" stack []\n"); -+ PrintF(" Dump stack content, default dump 10 words)\n"); -+ PrintF("mem\n"); -+ PrintF(" mem
[]\n"); -+ PrintF(" Dump memory content, default dump 10 words)\n"); -+ PrintF("flags\n"); -+ PrintF(" print flags\n"); -+ PrintF("disasm (alias 'di')\n"); -+ PrintF(" disasm []\n"); -+ PrintF(" disasm [
] (e.g., disasm pc) \n"); -+ PrintF(" disasm [[
] ]\n"); -+ PrintF(" Disassemble code, default is 10 instructions\n"); -+ PrintF(" from pc\n"); -+ PrintF("gdb \n"); -+ PrintF(" Return to gdb if the simulator was started with gdb\n"); -+ PrintF("break (alias 'b')\n"); -+ PrintF(" break : list all breakpoints\n"); -+ PrintF(" break
: set / enable / disable a breakpoint.\n"); -+ PrintF("tbreak\n"); -+ PrintF(" tbreak : list all breakpoints\n"); -+ PrintF(" tbreak
: set / enable / disable a temporary breakpoint.\n"); -+ PrintF(" Set a breakpoint enabled only for one stop. \n"); -+ PrintF("stop feature:\n"); -+ PrintF(" Description:\n"); -+ PrintF(" Stops are debug instructions inserted by\n"); -+ PrintF(" the Assembler::stop() function.\n"); -+ PrintF(" When hitting a stop, the Simulator will\n"); -+ PrintF(" stop and give control to the Debugger.\n"); -+ PrintF(" All stop codes are watched:\n"); -+ PrintF(" - They can be enabled / disabled: the Simulator\n"); -+ PrintF(" will / won't stop when hitting them.\n"); -+ PrintF(" - The Simulator keeps track of how many times they \n"); -+ PrintF(" are met. (See the info command.) Going over a\n"); -+ PrintF(" disabled stop still increases its counter. \n"); -+ PrintF(" Commands:\n"); -+ PrintF(" stop info all/ : print infos about number \n"); -+ PrintF(" or all stop(s).\n"); -+ PrintF(" stop enable/disable all/ : enables / disables\n"); -+ PrintF(" all or number stop(s)\n"); -+ } else { -+ PrintF("Unknown command: %s\n", cmd); -+ } -+ } -+ } -+ -+#undef COMMAND_SIZE -+#undef ARG_SIZE -+ -+#undef STR -+#undef XSTR -+} -+ -+void Simulator::SetBreakpoint(Instruction* location, bool is_tbreak) { -+ for (unsigned i = 0; i < breakpoints_.size(); i++) { -+ if (breakpoints_.at(i).location == location) { -+ if (breakpoints_.at(i).is_tbreak != is_tbreak) { -+ PrintF("Change breakpoint at %p to %s breakpoint\n", -+ reinterpret_cast(location), -+ is_tbreak ? "temporary" : "regular"); -+ breakpoints_.at(i).is_tbreak = is_tbreak; -+ return; -+ } -+ PrintF("Existing breakpoint at %p was %s\n", -+ reinterpret_cast(location), -+ breakpoints_.at(i).enabled ? "disabled" : "enabled"); -+ breakpoints_.at(i).enabled = !breakpoints_.at(i).enabled; -+ return; -+ } -+ } -+ Breakpoint new_breakpoint = {location, true, is_tbreak}; -+ breakpoints_.push_back(new_breakpoint); -+ PrintF("Set a %sbreakpoint at %p\n", -+ is_tbreak ? "temporary " : "", -+ reinterpret_cast(location)); -+} -+ -+void Simulator::ListBreakpoints() { -+ PrintF("Breakpoints:\n"); -+ for (unsigned i = 0; i < breakpoints_.size(); i++) { -+ PrintF("%p : %s %s\n", -+ reinterpret_cast(breakpoints_.at(i).location), -+ breakpoints_.at(i).enabled ? "enabled" : "disabled", -+ breakpoints_.at(i).is_tbreak ? ": temporary" : ""); -+ } -+} -+ -+void Simulator::CheckBreakpoints() { -+ bool hit_a_breakpoint = false; -+ bool is_tbreak = false; -+ Instruction* pc_ = reinterpret_cast(get_pc()); -+ for (unsigned i = 0; i < breakpoints_.size(); i++) { -+ if ((breakpoints_.at(i).location == pc_) && breakpoints_.at(i).enabled) { -+ hit_a_breakpoint = true; -+ if (breakpoints_.at(i).is_tbreak) { -+ // Disable a temporary breakpoint. -+ is_tbreak = true; -+ breakpoints_.at(i).enabled = false; -+ } -+ break; -+ } -+ } -+ if (hit_a_breakpoint) { -+ PrintF("Hit %sa breakpoint at %p.\n", -+ is_tbreak ? "and disabled " : "", -+ reinterpret_cast(pc_)); -+ RiscvDebugger dbg(this); -+ dbg.Debug(); -+ } -+} -+ -+bool Simulator::ICacheMatch(void* one, void* two) { -+ DCHECK_EQ(reinterpret_cast(one) & CachePage::kPageMask, 0); -+ DCHECK_EQ(reinterpret_cast(two) & CachePage::kPageMask, 0); -+ return one == two; -+} -+ -+static uint32_t ICacheHash(void* key) { -+ return static_cast(reinterpret_cast(key)) >> 2; -+} -+ -+static bool AllOnOnePage(uintptr_t start, size_t size) { -+ intptr_t start_page = (start & ~CachePage::kPageMask); -+ intptr_t end_page = ((start + size) & ~CachePage::kPageMask); -+ return start_page == end_page; -+} -+ -+void Simulator::set_last_debugger_input(char* input) { -+ DeleteArray(last_debugger_input_); -+ last_debugger_input_ = input; -+} -+ -+void Simulator::SetRedirectInstruction(Instruction* instruction) { -+ instruction->SetInstructionBits(rtCallRedirInstr); -+} -+ -+void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, -+ void* start_addr, size_t size) { -+ int64_t start = reinterpret_cast(start_addr); -+ int64_t intra_line = (start & CachePage::kLineMask); -+ start -= intra_line; -+ size += intra_line; -+ size = ((size - 1) | CachePage::kLineMask) + 1; -+ int offset = (start & CachePage::kPageMask); -+ while (!AllOnOnePage(start, size - 1)) { -+ int bytes_to_flush = CachePage::kPageSize - offset; -+ FlushOnePage(i_cache, start, bytes_to_flush); -+ start += bytes_to_flush; -+ size -= bytes_to_flush; -+ DCHECK_EQ((int64_t)0, start & CachePage::kPageMask); -+ offset = 0; -+ } -+ if (size != 0) { -+ FlushOnePage(i_cache, start, size); -+ } -+} -+ -+CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, -+ void* page) { -+ base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); -+ if (entry->value == nullptr) { -+ CachePage* new_page = new CachePage(); -+ entry->value = new_page; -+ } -+ return reinterpret_cast(entry->value); -+} -+ -+// Flush from start up to and not including start + size. -+void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, -+ intptr_t start, size_t size) { -+ DCHECK_LE(size, CachePage::kPageSize); -+ DCHECK(AllOnOnePage(start, size - 1)); -+ DCHECK_EQ(start & CachePage::kLineMask, 0); -+ DCHECK_EQ(size & CachePage::kLineMask, 0); -+ void* page = reinterpret_cast(start & (~CachePage::kPageMask)); -+ int offset = (start & CachePage::kPageMask); -+ CachePage* cache_page = GetCachePage(i_cache, page); -+ char* valid_bytemap = cache_page->ValidityByte(offset); -+ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); -+} -+ -+void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, -+ Instruction* instr) { -+ int64_t address = reinterpret_cast(instr); -+ void* page = reinterpret_cast(address & (~CachePage::kPageMask)); -+ void* line = reinterpret_cast(address & (~CachePage::kLineMask)); -+ int offset = (address & CachePage::kPageMask); -+ CachePage* cache_page = GetCachePage(i_cache, page); -+ char* cache_valid_byte = cache_page->ValidityByte(offset); -+ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); -+ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); -+ if (cache_hit) { -+ // Check that the data in memory matches the contents of the I-cache. -+ CHECK_EQ(0, memcmp(reinterpret_cast(instr), -+ cache_page->CachedData(offset), kInstrSize)); -+ } else { -+ // Cache miss. Load memory into the cache. -+ memcpy(cached_line, line, CachePage::kLineLength); -+ *cache_valid_byte = CachePage::LINE_VALID; -+ } -+} -+ -+Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { -+ // Set up simulator support first. Some of this information is needed to -+ // setup the architecture state. -+ stack_size_ = FLAG_sim_stack_size * KB; -+ stack_ = reinterpret_cast(malloc(stack_size_)); -+ pc_modified_ = false; -+ icount_ = 0; -+ break_count_ = 0; -+ // Reset debug helpers. -+ breakpoints_.clear(); -+ // TODO: 'next' command -+ //break_on_next_ = false; -+ -+ // Set up architecture state. -+ // All registers are initialized to zero to start with. -+ for (int i = 0; i < kNumSimuRegisters; i++) { -+ registers_[i] = 0; -+ } -+ -+ for (int i = 0; i < kNumFPURegisters; i++) { -+ FPUregisters_[i] = 0; -+ } -+ -+ FCSR_ = 0; -+ -+ // The sp is initialized to point to the bottom (high address) of the -+ // allocated stack area. To be safe in potential stack underflows we leave -+ // some buffer below. -+ registers_[sp] = reinterpret_cast(stack_) + stack_size_ - 64; -+ // The ra and pc are initialized to a known bad value that will cause an -+ // access violation if the simulator ever tries to execute it. -+ registers_[pc] = bad_ra; -+ registers_[ra] = bad_ra; -+ -+ last_debugger_input_ = nullptr; -+} -+ -+Simulator::~Simulator() { -+ GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_); -+ free(stack_); -+} -+ -+// Get the active Simulator for the current thread. -+Simulator* Simulator::current(Isolate* isolate) { -+ v8::internal::Isolate::PerIsolateThreadData* isolate_data = -+ isolate->FindOrAllocatePerThreadDataForThisThread(); -+ DCHECK_NOT_NULL(isolate_data); -+ -+ Simulator* sim = isolate_data->simulator(); -+ if (sim == nullptr) { -+ // TODO(146): delete the simulator object when a thread/isolate goes away. -+ sim = new Simulator(isolate); -+ isolate_data->set_simulator(sim); -+ } -+ return sim; -+} -+ -+// Sets the register in the architecture state. It will also deal with -+// updating Simulator internal state for special registers such as PC. -+void Simulator::set_register(int reg, int64_t value) { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ if (reg == pc) { -+ pc_modified_ = true; -+ } -+ -+ // Zero register always holds 0. -+ registers_[reg] = (reg == 0) ? 0 : value; -+} -+ -+void Simulator::set_dw_register(int reg, const int* dbl) { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ registers_[reg] = dbl[1]; -+ registers_[reg] = registers_[reg] << 32; -+ registers_[reg] += dbl[0]; -+} -+ -+void Simulator::set_fpu_register(int fpureg, int64_t value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ FPUregisters_[fpureg] = value; -+} -+ -+void Simulator::set_fpu_register_word(int fpureg, int32_t value) { -+ // Set ONLY lower 32-bits, leaving upper bits untouched. -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ int32_t* pword; -+ if (kArchEndian == kLittle) { -+ pword = reinterpret_cast(&FPUregisters_[fpureg]); -+ } else { -+ pword = reinterpret_cast(&FPUregisters_[fpureg]) + 1; -+ } -+ *pword = value; -+} -+ -+void Simulator::set_fpu_register_hi_word(int fpureg, int32_t value) { -+ // Set ONLY upper 32-bits, leaving lower bits untouched. -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ int32_t* phiword; -+ if (kArchEndian == kLittle) { -+ phiword = (reinterpret_cast(&FPUregisters_[fpureg])) + 1; -+ } else { -+ phiword = reinterpret_cast(&FPUregisters_[fpureg]); -+ } -+ *phiword = value; -+} -+ -+void Simulator::set_fpu_register_float(int fpureg, float value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ FPUregisters_[fpureg] = box_float(value); -+} -+ -+void Simulator::set_fpu_register_double(int fpureg, double value) { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ *bit_cast(&FPUregisters_[fpureg]) = value; -+} -+ -+// Get the register from the architecture state. This function does handle -+// the special case of accessing the PC register. -+int64_t Simulator::get_register(int reg) const { -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); -+ if (reg == 0) -+ return 0; -+ else -+ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); -+} -+ -+double Simulator::get_double_from_register_pair(int reg) { -+ // TODO(plind): bad ABI stuff, refactor or remove. -+ DCHECK((reg >= 0) && (reg < kNumSimuRegisters) && ((reg % 2) == 0)); -+ -+ double dm_val = 0.0; -+ // Read the bits from the unsigned integer register_[] array -+ // into the double precision floating point value and return it. -+ char buffer[sizeof(registers_[0])]; -+ memcpy(buffer, ®isters_[reg], sizeof(registers_[0])); -+ memcpy(&dm_val, buffer, sizeof(registers_[0])); -+ return (dm_val); -+} -+ -+int64_t Simulator::get_fpu_register(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return FPUregisters_[fpureg]; -+} -+ -+int32_t Simulator::get_fpu_register_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); -+} -+ -+int32_t Simulator::get_fpu_register_signed_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); -+} -+ -+int32_t Simulator::get_fpu_register_hi_word(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return static_cast((FPUregisters_[fpureg] >> 32) & 0xFFFFFFFF); -+} -+ -+float Simulator::get_fpu_register_float(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ if (!is_boxed_float(FPUregisters_[fpureg])) { -+ return std::numeric_limits::quiet_NaN(); -+ } -+ return *bit_cast(const_cast(&FPUregisters_[fpureg])); -+} -+ -+double Simulator::get_fpu_register_double(int fpureg) const { -+ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); -+ return *bit_cast(&FPUregisters_[fpureg]); -+} -+ -+// Runtime FP routines take up to two double arguments and zero -+// or one integer arguments. All are constructed here, -+// from fa0, fa1, and a0. -+void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { -+ *x = get_fpu_register_double(fa0); -+ *y = get_fpu_register_double(fa1); -+ *z = static_cast(get_register(a0)); -+} -+ -+// The return value is in fa0. -+void Simulator::SetFpResult(const double& result) { -+ set_fpu_register_double(fa0, result); -+} -+ -+// helper functions to read/write/set/clear CRC values/bits -+uint32_t Simulator::read_csr_value(uint32_t csr) { -+ switch (csr) { -+ case csr_fflags: // Floating-Point Accrued Exceptions (RW) -+ return (FCSR_ & kFcsrFlagsMask); -+ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) -+ return (FCSR_ & kFcsrFrmMask) >> kFcsrFrmShift; -+ case csr_fcsr: // Floating-Point Control and Status Register (RW) -+ return (FCSR_ & kFcsrMask); -+ default: -+ UNIMPLEMENTED(); -+ } -+} -+ -+uint32_t Simulator::get_dynamic_rounding_mode() { -+ return read_csr_value(csr_frm); -+} -+ -+void Simulator::write_csr_value(uint32_t csr, uint64_t val) { -+ uint32_t value = (uint32_t)val; -+ switch (csr) { -+ case csr_fflags: // Floating-Point Accrued Exceptions (RW) -+ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); -+ FCSR_ = (FCSR_ & (~kFcsrFlagsMask)) | value; -+ break; -+ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) -+ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); -+ FCSR_ = (FCSR_ & (~kFcsrFrmMask)) | (value << kFcsrFrmShift); -+ break; -+ case csr_fcsr: // Floating-Point Control and Status Register (RW) -+ DCHECK(value <= ((1 << kFcsrBits) - 1)); -+ FCSR_ = (FCSR_ & (~kFcsrMask)) | value; -+ break; -+ default: -+ UNIMPLEMENTED(); -+ } -+} -+ -+void Simulator::set_csr_bits(uint32_t csr, uint64_t val) { -+ uint32_t value = (uint32_t)val; -+ switch (csr) { -+ case csr_fflags: // Floating-Point Accrued Exceptions (RW) -+ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); -+ FCSR_ = FCSR_ | value; -+ break; -+ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) -+ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); -+ FCSR_ = FCSR_ | (value << kFcsrFrmShift); -+ break; -+ case csr_fcsr: // Floating-Point Control and Status Register (RW) -+ DCHECK(value <= ((1 << kFcsrBits) - 1)); -+ FCSR_ = FCSR_ | value; -+ break; -+ default: -+ UNIMPLEMENTED(); -+ } -+} -+ -+void Simulator::clear_csr_bits(uint32_t csr, uint64_t val) { -+ uint32_t value = (uint32_t)val; -+ switch (csr) { -+ case csr_fflags: // Floating-Point Accrued Exceptions (RW) -+ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); -+ FCSR_ = FCSR_ & (~value); -+ break; -+ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) -+ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); -+ FCSR_ = FCSR_ & (~(value << kFcsrFrmShift)); -+ break; -+ case csr_fcsr: // Floating-Point Control and Status Register (RW) -+ DCHECK(value <= ((1 << kFcsrBits) - 1)); -+ FCSR_ = FCSR_ & (~value); -+ break; -+ default: -+ UNIMPLEMENTED(); -+ } -+} -+ -+bool Simulator::test_fflags_bits(uint32_t mask) { -+ return (FCSR_ & kFcsrFlagsMask & mask) != 0; -+} -+ -+template -+T Simulator::FMaxMinHelper(T a, T b, MaxMinKind kind) { -+ // set invalid bit for signaling nan -+ if ((a == std::numeric_limits::signaling_NaN()) || -+ (b == std::numeric_limits::signaling_NaN())) { -+ // FIXME: NV -> kInvalidOperation -+ set_csr_bits(csr_fflags, kInvalidOperation); -+ } -+ -+ T result = 0; -+ if (std::isnan(a) && std::isnan(b)) { -+ result = a; -+ } else if (std::isnan(a)) { -+ result = b; -+ } else if (std::isnan(b)) { -+ result = a; -+ } else if (b == a) { // Handle -0.0 == 0.0 case. -+ if (kind == MaxMinKind::kMax) { -+ result = std::signbit(b) ? a : b; -+ } else { -+ result = std::signbit(b) ? b : a; -+ } -+ } else { -+ result = (kind == MaxMinKind::kMax) ? fmax(a, b) : fmin(a, b); -+ } -+ -+ return result; -+} -+ -+// Raw access to the PC register. -+void Simulator::set_pc(int64_t value) { -+ pc_modified_ = true; -+ registers_[pc] = value; -+ DCHECK(has_bad_pc() || ((value % kInstrSize) == 0)); -+} -+ -+bool Simulator::has_bad_pc() const { -+ return ((registers_[pc] == bad_ra) || (registers_[pc] == end_sim_pc)); -+} -+ -+// Raw access to the PC register without the special adjustment when reading. -+int64_t Simulator::get_pc() const { return registers_[pc]; } -+ -+// The RISC-V spec leaves it open to the implementation on how to handle -+// unaligned reads and writes. For now, we simply disallow unaligned reads but -+// at some point, we may want to implement some other behavior. -+ -+// TODO(plind): refactor this messy debug code when we do unaligned access. -+void Simulator::DieOrDebug() { -+ if ((1)) { // Flag for this was removed. -+ RiscvDebugger dbg(this); -+ dbg.Debug(); -+ } else { -+ base::OS::Abort(); -+ } -+} -+ -+void Simulator::TraceRegWr(int64_t value, TraceType t) { -+ if (::v8::internal::FLAG_trace_sim) { -+ union { -+ int64_t fmt_int64; -+ int32_t fmt_int32[2]; -+ float fmt_float[2]; -+ double fmt_double; -+ } v; -+ v.fmt_int64 = value; -+ -+ switch (t) { -+ case WORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 -+ " uint32:%" PRIu32, -+ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0]); -+ break; -+ case DWORD: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 -+ " uint64:%" PRIu64, -+ value, icount_, value, value); -+ break; -+ case FLOAT: -+ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e", -+ v.fmt_int64, icount_, v.fmt_float[0]); -+ break; -+ case DOUBLE: -+ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") dbl:%e", -+ v.fmt_int64, icount_, v.fmt_double); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+// TODO(plind): consider making icount_ printing a flag option. -+template -+void Simulator::TraceMemRd(int64_t addr, T value, int64_t reg_value) { -+ if (::v8::internal::FLAG_trace_sim) { -+ if (std::is_integral::value) { -+ switch (sizeof(T)) { -+ case 1: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int8:%" PRId8 -+ " uint8:%" PRIu8 " <-- [addr: %" PRIx64 "]", -+ reg_value, icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ case 2: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int16:%" PRId16 -+ " uint16:%" PRIu16 " <-- [addr: %" PRIx64 "]", -+ reg_value, icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ case 4: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 -+ " uint32:%" PRIu32 " <-- [addr: %" PRIx64 "]", -+ reg_value, icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ case 8: -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 -+ " uint64:%" PRIu64 " <-- [addr: %" PRIx64 "]", -+ reg_value, icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } else if (std::is_same::value) { -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") flt:%e <-- [addr: %" PRIx64 -+ "]", -+ reg_value, icount_, static_cast(value), addr); -+ } else if (std::is_same::value) { -+ SNPrintF(trace_buf_, -+ "%016" PRIx64 " (%" PRId64 ") dbl:%e <-- [addr: %" PRIx64 -+ "]", -+ reg_value, icount_, static_cast(value), addr); -+ } else { -+ UNREACHABLE(); -+ } -+ } -+} -+ -+template -+void Simulator::TraceMemWr(int64_t addr, T value) { -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (sizeof(T)) { -+ case 1: -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 ") int8:%" PRId8 -+ " uint8:%" PRIu8 " --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ case 2: -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 ") int16:%" PRId16 -+ " uint16:%" PRIu16 " --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), -+ static_cast(value), addr); -+ break; -+ case 4: -+ if (std::is_integral::value) { -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 ") int32:%" PRId32 -+ " uint32:%" PRIu32 " --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), -+ static_cast(value), addr); -+ } else { -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 -+ ") flt:%e --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), addr); -+ } -+ break; -+ case 8: -+ if (std::is_integral::value) { -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 ") int64:%" PRId64 -+ " uint64:%" PRIu64 " --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), -+ static_cast(value), addr); -+ } else { -+ SNPrintF(trace_buf_, -+ " (%" PRIu64 -+ ") dbl:%e --> [addr: %" PRIx64 "]", -+ icount_, static_cast(value), addr); -+ } -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+// RISCV Memory Read/Write functions -+ -+// FIXME (RISCV): check whether the specific board supports unaligned load/store -+// (determined by EEI). For now, we assume the board does not support unaligned -+// load/store (e.g., trapping) -+template -+T Simulator::ReadMem(int64_t addr, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ -+ // check for natural alignment -+ if ((addr & (sizeof(T) - 1)) != 0) { -+ PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, -+ reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ -+ T* ptr = reinterpret_cast(addr); -+ T value = *ptr; -+ return value; -+} -+ -+template -+void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) { -+ if (addr >= 0 && addr < 0x400) { -+ // This has to be a nullptr-dereference, drop into debugger. -+ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR -+ " \n", -+ addr, reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ -+ // check for natural alignment -+ if ((addr & (sizeof(T) - 1)) != 0) { -+ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, -+ reinterpret_cast(instr)); -+ DieOrDebug(); -+ } -+ -+ T* ptr = reinterpret_cast(addr); -+ TraceMemWr(addr, value); -+ *ptr = value; -+} -+ -+// Returns the limit of the stack area to enable checking for stack overflows. -+uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { -+ // The simulator uses a separate JS stack. If we have exhausted the C stack, -+ // we also drop down the JS limit to reflect the exhaustion on the JS stack. -+ if (GetCurrentStackPosition() < c_limit) { -+ return reinterpret_cast(get_sp()); -+ } -+ -+ // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes -+ // to prevent overrunning the stack when pushing values. -+ return reinterpret_cast(stack_) + 1024; -+} -+ -+// Unsupported instructions use Format to print an error and stop execution. -+void Simulator::Format(Instruction* instr, const char* format) { -+ PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR " : %s\n", -+ reinterpret_cast(instr), format); -+ UNIMPLEMENTED_RISCV(); -+} -+ -+// Calls into the V8 runtime are based on this very simple interface. -+// Note: To be able to return two values from some calls the code in -+// runtime.cc uses the ObjectPair which is essentially two 32-bit values -+// stuffed into a 64-bit value. With the code below we assume that all runtime -+// calls return 64 bits of result. If they don't, the a1 result register -+// contains a bogus value, which is fine because it is caller-saved. -+ -+using SimulatorRuntimeCall = ObjectPair (*)(int64_t arg0, int64_t arg1, -+ int64_t arg2, int64_t arg3, -+ int64_t arg4, int64_t arg5, -+ int64_t arg6, int64_t arg7, -+ int64_t arg8, int64_t arg9); -+ -+// These prototypes handle the four types of FP calls. -+using SimulatorRuntimeCompareCall = int64_t (*)(double darg0, double darg1); -+using SimulatorRuntimeFPFPCall = double (*)(double darg0, double darg1); -+using SimulatorRuntimeFPCall = double (*)(double darg0); -+using SimulatorRuntimeFPIntCall = double (*)(double darg0, int32_t arg0); -+ -+// This signature supports direct call in to API function native callback -+// (refer to InvocationCallback in v8.h). -+using SimulatorRuntimeDirectApiCall = void (*)(int64_t arg0); -+using SimulatorRuntimeProfilingApiCall = void (*)(int64_t arg0, void* arg1); -+ -+// This signature supports direct call to accessor getter callback. -+using SimulatorRuntimeDirectGetterCall = void (*)(int64_t arg0, int64_t arg1); -+using SimulatorRuntimeProfilingGetterCall = void (*)(int64_t arg0, int64_t arg1, -+ void* arg2); -+ -+// Software interrupt instructions are used by the simulator to call into the -+// C-based V8 runtime. They are also used for debugging with simulator. -+void Simulator::SoftwareInterrupt() { -+ // There are two instructions that could get us here, the ebreak or ecall -+ // instructions are "SYSTEM" class opcode distinuished by Imm12Value field w/ -+ // the rest of instruction fields being zero -+ int32_t func = instr_.Imm12Value(); -+ // We first check if we met a call_rt_redirected. -+ if (instr_.InstructionBits() == rtCallRedirInstr) { // ECALL -+ Redirection* redirection = Redirection::FromInstruction(instr_.instr()); -+ -+ int64_t* stack_pointer = reinterpret_cast(get_register(sp)); -+ -+ int64_t arg0 = get_register(a0); -+ int64_t arg1 = get_register(a1); -+ int64_t arg2 = get_register(a2); -+ int64_t arg3 = get_register(a3); -+ int64_t arg4 = get_register(a4); -+ int64_t arg5 = get_register(a5); -+ int64_t arg6 = get_register(a6); -+ int64_t arg7 = get_register(a7); -+ int64_t arg8 = stack_pointer[0]; -+ int64_t arg9 = stack_pointer[1]; -+ STATIC_ASSERT(kMaxCParameters == 10); -+ -+ bool fp_call = -+ (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || -+ (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); -+ -+ // This is dodgy but it works because the C entry stubs are never moved. -+ // See comment in codegen-arm.cc and bug 1242173. -+ int64_t saved_ra = get_register(ra); -+ -+ intptr_t external = -+ reinterpret_cast(redirection->external_function()); -+ -+ if (fp_call) { -+ double dval0, dval1; // one or two double parameters -+ int32_t ival; // zero or one integer parameters -+ int64_t iresult = 0; // integer return value -+ double dresult = 0; // double return value -+ GetFpArgs(&dval0, &dval1, &ival); -+ SimulatorRuntimeCall generic_target = -+ reinterpret_cast(external); -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_FP_FP_CALL: -+ case ExternalReference::BUILTIN_COMPARE_CALL: -+ PrintF("Call to host function at %p with args %f, %f", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0, dval1); -+ break; -+ case ExternalReference::BUILTIN_FP_CALL: -+ PrintF("Call to host function at %p with arg %f", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0); -+ break; -+ case ExternalReference::BUILTIN_FP_INT_CALL: -+ PrintF("Call to host function at %p with args %f, %d", -+ reinterpret_cast(FUNCTION_ADDR(generic_target)), -+ dval0, ival); -+ break; -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ } -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_COMPARE_CALL: { -+ SimulatorRuntimeCompareCall target = -+ reinterpret_cast(external); -+ iresult = target(dval0, dval1); -+ set_register(a0, static_cast(iresult)); -+ // set_register(a1, static_cast(iresult >> 32)); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_FP_CALL: { -+ SimulatorRuntimeFPFPCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0, dval1); -+ SetFpResult(dresult); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_CALL: { -+ SimulatorRuntimeFPCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0); -+ SetFpResult(dresult); -+ break; -+ } -+ case ExternalReference::BUILTIN_FP_INT_CALL: { -+ SimulatorRuntimeFPIntCall target = -+ reinterpret_cast(external); -+ dresult = target(dval0, ival); -+ SetFpResult(dresult); -+ break; -+ } -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ if (::v8::internal::FLAG_trace_sim) { -+ switch (redirection->type()) { -+ case ExternalReference::BUILTIN_COMPARE_CALL: -+ PrintF("Returned %08x\n", static_cast(iresult)); -+ break; -+ case ExternalReference::BUILTIN_FP_FP_CALL: -+ case ExternalReference::BUILTIN_FP_CALL: -+ case ExternalReference::BUILTIN_FP_INT_CALL: -+ PrintF("Returned %f\n", dresult); -+ break; -+ default: -+ UNREACHABLE(); -+ break; -+ } -+ } -+ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " \n", -+ reinterpret_cast(external), arg0); -+ } -+ SimulatorRuntimeDirectApiCall target = -+ reinterpret_cast(external); -+ target(arg0); -+ } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " \n", -+ reinterpret_cast(external), arg0, arg1); -+ } -+ SimulatorRuntimeProfilingApiCall target = -+ reinterpret_cast(external); -+ target(arg0, Redirection::ReverseRedirection(arg1)); -+ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " \n", -+ reinterpret_cast(external), arg0, arg1); -+ } -+ SimulatorRuntimeDirectGetterCall target = -+ reinterpret_cast(external); -+ target(arg0, arg1); -+ } else if (redirection->type() == -+ ExternalReference::PROFILING_GETTER_CALL) { -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 -+ " %08" PRIx64 " \n", -+ reinterpret_cast(external), arg0, arg1, arg2); -+ } -+ SimulatorRuntimeProfilingGetterCall target = -+ reinterpret_cast(external); -+ target(arg0, arg1, Redirection::ReverseRedirection(arg2)); -+ } else { -+ DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || -+ redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); -+ SimulatorRuntimeCall target = -+ reinterpret_cast(external); -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF( -+ "Call to host function at %p " -+ "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 -+ " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 -+ " , %08" PRIx64 " , %08" PRIx64 " \n", -+ reinterpret_cast(FUNCTION_ADDR(target)), arg0, arg1, arg2, -+ arg3, arg4, arg5, arg6, arg7, arg8, arg9); -+ } -+ ObjectPair result = -+ target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); -+ set_register(a0, (int64_t)(result.x)); -+ set_register(a1, (int64_t)(result.y)); -+ } -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(a1), -+ get_register(a0)); -+ } -+ set_register(ra, saved_ra); -+ set_pc(get_register(ra)); -+ -+ } else if (func == 1) { // EBREAK -+ int32_t code = get_ebreak_code(instr_.instr()); -+ set_pc(get_pc() + kInstrSize * 2); -+ if (code != -1 && static_cast(code) <= kMaxStopCode) { -+ if (IsWatchpoint(code)) { -+ PrintWatchpoint(code); -+ } else { -+ IncreaseStopCounter(code); -+ HandleStop(code); -+ } -+ } else { -+ // All remaining break_ codes, and all traps are handled here. -+ RiscvDebugger dbg(this); -+ dbg.Debug(); -+ } -+ } else { -+ UNREACHABLE(); -+ } -+} -+ -+// Stop helper functions. -+bool Simulator::IsWatchpoint(uint64_t code) { -+ return (code <= kMaxWatchpointCode); -+} -+ -+void Simulator::PrintWatchpoint(uint64_t code) { -+ RiscvDebugger dbg(this); -+ ++break_count_; -+ PrintF("\n---- watchpoint %" PRId64 " marker: %3d (instr count: %8" PRId64 -+ " ) ----------" -+ "----------------------------------", -+ code, break_count_, icount_); -+ dbg.PrintAllRegs(); // Print registers and continue running. -+} -+ -+void Simulator::HandleStop(uint64_t code) { -+ // Stop if it is enabled, otherwise go on jumping over the stop -+ // and the message address. -+ if (IsEnabledStop(code)) { -+ RiscvDebugger dbg(this); -+ PrintF("Simulator hit stop (%" PRId64 ")\n", code); -+ dbg.Debug(); -+ } -+} -+ -+bool Simulator::IsStopInstruction(Instruction* instr) { -+ if (instr->InstructionBits() != kBreakInstr) return false; -+ int32_t code = get_ebreak_code(instr); -+ return code != -1 && static_cast(code) > kMaxWatchpointCode && -+ static_cast(code) <= kMaxStopCode; -+} -+ -+bool Simulator::IsEnabledStop(uint64_t code) { -+ DCHECK_LE(code, kMaxStopCode); -+ DCHECK_GT(code, kMaxWatchpointCode); -+ return !(watched_stops_[code].count & kStopDisabledBit); -+} -+ -+void Simulator::EnableStop(uint64_t code) { -+ if (!IsEnabledStop(code)) { -+ watched_stops_[code].count &= ~kStopDisabledBit; -+ } -+} -+ -+void Simulator::DisableStop(uint64_t code) { -+ if (IsEnabledStop(code)) { -+ watched_stops_[code].count |= kStopDisabledBit; -+ } -+} -+ -+void Simulator::IncreaseStopCounter(uint64_t code) { -+ DCHECK_LE(code, kMaxStopCode); -+ if ((watched_stops_[code].count & ~(1 << 31)) == 0x7FFFFFFF) { -+ PrintF("Stop counter for code %" PRId64 -+ " has overflowed.\n" -+ "Enabling this code and reseting the counter to 0.\n", -+ code); -+ watched_stops_[code].count = 0; -+ EnableStop(code); -+ } else { -+ watched_stops_[code].count++; -+ } -+} -+ -+// Print a stop status. -+void Simulator::PrintStopInfo(uint64_t code) { -+ if (code <= kMaxWatchpointCode) { -+ PrintF("That is a watchpoint, not a stop.\n"); -+ return; -+ } else if (code > kMaxStopCode) { -+ PrintF("Code too large, only %u stops can be used\n", kMaxStopCode + 1); -+ return; -+ } -+ const char* state = IsEnabledStop(code) ? "Enabled" : "Disabled"; -+ int32_t count = watched_stops_[code].count & ~kStopDisabledBit; -+ // Don't print the state of unused breakpoints. -+ if (count != 0) { -+ if (watched_stops_[code].desc) { -+ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i, \t%s\n", -+ code, code, state, count, watched_stops_[code].desc); -+ } else { -+ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i\n", code, -+ code, state, count); -+ } -+ } -+} -+ -+void Simulator::SignalException(Exception e) { -+ FATAL("Error: Exception %i raised.", static_cast(e)); -+} -+ -+// RISCV Instruction Decode Routine -+void Simulator::DecodeRVRType() { -+ switch (instr_.InstructionBits() & kRTypeMask) { -+ case RO_ADD: { -+ set_rd(sext_xlen(rs1() + rs2())); -+ break; -+ } -+ case RO_SUB: { -+ set_rd(sext_xlen(rs1() - rs2())); -+ break; -+ } -+ case RO_SLL: { -+ set_rd(sext_xlen(rs1() << (rs2() & (xlen - 1)))); -+ break; -+ } -+ case RO_SLT: { -+ set_rd(sreg_t(rs1()) < sreg_t(rs2())); -+ break; -+ } -+ case RO_SLTU: { -+ set_rd(reg_t(rs1()) < reg_t(rs2())); -+ break; -+ } -+ case RO_XOR: { -+ set_rd(rs1() ^ rs2()); -+ break; -+ } -+ case RO_SRL: { -+ set_rd(sext_xlen(zext_xlen(rs1()) >> (rs2() & (xlen - 1)))); -+ break; -+ } -+ case RO_SRA: { -+ set_rd(sext_xlen(sext_xlen(rs1()) >> (rs2() & (xlen - 1)))); -+ break; -+ } -+ case RO_OR: { -+ set_rd(rs1() | rs2()); -+ break; -+ } -+ case RO_AND: { -+ set_rd(rs1() & rs2()); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_ADDW: { -+ set_rd(sext32(rs1() + rs2())); -+ break; -+ } -+ case RO_SUBW: { -+ set_rd(sext32(rs1() - rs2())); -+ break; -+ } -+ case RO_SLLW: { -+ set_rd(sext32(rs1() << (rs2() & 0x1F))); -+ break; -+ } -+ case RO_SRLW: { -+ set_rd(sext32(uint32_t(rs1()) >> (rs2() & 0x1F))); -+ break; -+ } -+ case RO_SRAW: { -+ set_rd(sext32(int32_t(rs1()) >> (rs2() & 0x1F))); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ // TODO: Add RISCV M extension macro -+ case RO_MUL: { -+ set_rd(rs1() * rs2()); -+ break; -+ } -+ case RO_MULH: { -+ set_rd(mulh(rs1(), rs2())); -+ break; -+ } -+ case RO_MULHSU: { -+ set_rd(mulhsu(rs1(), rs2())); -+ break; -+ } -+ case RO_MULHU: { -+ set_rd(mulhu(rs1(), rs2())); -+ break; -+ } -+ case RO_DIV: { -+ sreg_t lhs = sext_xlen(rs1()); -+ sreg_t rhs = sext_xlen(rs2()); -+ if (rhs == 0) { -+ set_rd(-1); -+ } else if (lhs == INT64_MIN && rhs == -1) { -+ set_rd(lhs); -+ } else { -+ set_rd(sext_xlen(lhs / rhs)); -+ } -+ break; -+ } -+ case RO_DIVU: { -+ reg_t lhs = zext_xlen(rs1()); -+ reg_t rhs = zext_xlen(rs2()); -+ if (rhs == 0) { -+ set_rd(UINT64_MAX); -+ } else { -+ set_rd(zext_xlen(lhs / rhs)); -+ } -+ break; -+ } -+ case RO_REM: { -+ sreg_t lhs = sext_xlen(rs1()); -+ sreg_t rhs = sext_xlen(rs2()); -+ if (rhs == 0) { -+ set_rd(lhs); -+ } else if (lhs == INT64_MIN && rhs == -1) { -+ set_rd(0); -+ } else { -+ set_rd(sext_xlen(lhs % rhs)); -+ } -+ break; -+ } -+ case RO_REMU: { -+ reg_t lhs = zext_xlen(rs1()); -+ reg_t rhs = zext_xlen(rs2()); -+ if (rhs == 0) { -+ set_rd(lhs); -+ } else { -+ set_rd(zext_xlen(lhs % rhs)); -+ } -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_MULW: { -+ set_rd(sext32(sext32(rs1()) * sext32(rs2()))); -+ break; -+ } -+ case RO_DIVW: { -+ sreg_t lhs = sext32(rs1()); -+ sreg_t rhs = sext32(rs2()); -+ if (rhs == 0) { -+ set_rd(-1); -+ } else if (lhs == INT32_MIN && rhs == -1) { -+ set_rd(lhs); -+ } else { -+ set_rd(sext32(lhs / rhs)); -+ } -+ break; -+ } -+ case RO_DIVUW: { -+ reg_t lhs = zext32(rs1()); -+ reg_t rhs = zext32(rs2()); -+ if (rhs == 0) { -+ set_rd(UINT32_MAX); -+ } else { -+ set_rd(zext32(lhs / rhs)); -+ } -+ break; -+ } -+ case RO_REMW: { -+ sreg_t lhs = sext32(rs1()); -+ sreg_t rhs = sext32(rs2()); -+ if (rhs == 0) { -+ set_rd(lhs); -+ } else if (lhs == INT32_MIN && rhs == -1) { -+ set_rd(0); -+ } else { -+ set_rd(sext32(lhs % rhs)); -+ } -+ break; -+ } -+ case RO_REMUW: { -+ reg_t lhs = zext32(rs1()); -+ reg_t rhs = zext32(rs2()); -+ if (rhs == 0) { -+ set_rd(zext32(lhs)); -+ } else { -+ set_rd(zext32(lhs % rhs)); -+ } -+ break; -+ } -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: End Add RISCV M extension macro -+ default: { -+ switch (instr_.BaseOpcode()) { -+ case AMO: -+ DecodeRVRAType(); -+ break; -+ case OP_FP: -+ DecodeRVRFPType(); -+ break; -+ default: -+ UNSUPPORTED(); -+ } -+ } -+ } -+} -+ -+float Simulator::RoundF2FHelper(float input_val, int rmode) { -+ if (rmode == DYN) rmode = get_dynamic_rounding_mode(); -+ -+ float rounded = 0; -+ switch (rmode) { -+ case RNE: { // Round to Nearest, tiest to Even -+ int curr_mode = fegetround(); -+ fesetround(FE_TONEAREST); -+ rounded = std::nearbyintf(input_val); -+ fesetround(curr_mode); -+ break; -+ } -+ case RTZ: // Round towards Zero -+ rounded = std::truncf(input_val); -+ break; -+ case RDN: // Round Down (towards -infinity) -+ rounded = floorf(input_val); -+ break; -+ case RUP: // Round Up (towards +infinity) -+ rounded = ceilf(input_val); -+ break; -+ case RMM: // Round to Nearest, tiest to Max Magnitude -+ rounded = std::roundf(input_val); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ return rounded; -+} -+ -+double Simulator::RoundF2FHelper(double input_val, int rmode) { -+ if (rmode == DYN) rmode = get_dynamic_rounding_mode(); -+ -+ double rounded = 0; -+ switch (rmode) { -+ case RNE: { // Round to Nearest, tiest to Even -+ int curr_mode = fegetround(); -+ fesetround(FE_TONEAREST); -+ rounded = std::nearbyint(input_val); -+ fesetround(curr_mode); -+ break; -+ } -+ case RTZ: // Round towards Zero -+ rounded = std::trunc(input_val); -+ break; -+ case RDN: // Round Down (towards -infinity) -+ rounded = std::floor(input_val); -+ break; -+ case RUP: // Round Up (towards +infinity) -+ rounded = std::ceil(input_val); -+ break; -+ case RMM: // Round to Nearest, tiest to Max Magnitude -+ rounded = std::round(input_val); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ return rounded; -+} -+ -+// convert rounded floating-point to integer types, handle input values that -+// are out-of-range, underflow, or NaN, and set appropriate fflags -+template -+I_TYPE Simulator::RoundF2IHelper(F_TYPE original, int rmode) { -+ DCHECK(std::is_integral::value); -+ -+ DCHECK((std::is_same::value || -+ std::is_same::value)); -+ -+ I_TYPE max_i = std::numeric_limits::max(); -+ I_TYPE min_i = std::numeric_limits::min(); -+ -+ if (!std::isfinite(original)) { -+ set_fflags(kInvalidOperation); -+ if (std::isnan(original) || -+ original == std::numeric_limits::infinity()) { -+ return max_i; -+ } else { -+ DCHECK(original == -std::numeric_limits::infinity()); -+ return min_i; -+ } -+ } -+ -+ F_TYPE rounded = RoundF2FHelper(original, rmode); -+ if (original != rounded) set_fflags(kInexact); -+ -+ if (!std::isfinite(rounded)) { -+ set_fflags(kInvalidOperation); -+ if (std::isnan(rounded) || -+ rounded == std::numeric_limits::infinity()) { -+ return max_i; -+ } else { -+ DCHECK(rounded == -std::numeric_limits::infinity()); -+ return min_i; -+ } -+ } -+ -+ // FIXME (RISCV): comparison of rounded (float) and max_i (integer) may not -+ // be precise because max_i is promoted to floating point during comparison. -+ // Rounding up may happen when converting max_i to floating-point, e.g., -+ // max is 9223372036854775807 vs. (double)max is -+ // 9223372036854775808.00000000000000 -+ -+ // Since integer max values are either all 1s (for unsigned) or all 1s -+ // except for sign-bit (for signed), they cannot be represented precisely in -+ // floating point, in order to precisely tell whether the rounded floating -+ // point is within the max range, we compare against (max_i+1) which would -+ // have a single 1 w/ many trailing zeros -+ float max_i_plus_1 = -+ std::is_same::value -+ ? 0x1p64f // uint64_t::max + 1 cannot be represented in integers, -+ // so use its float representation directly -+ : static_cast(static_cast(max_i) + 1); -+ if (rounded >= max_i_plus_1) { -+ set_fflags(kOverflow | kInvalidOperation); -+ return max_i; -+ } -+ -+ // Since min_i (either 0 for unsigned, or for signed) is represented -+ // precisely in floating-point, comparing rounded directly against min_i -+ if (rounded <= min_i) { -+ if (rounded < min_i) set_fflags(kOverflow | kInvalidOperation); -+ return min_i; -+ } -+ -+ F_TYPE underflow_fval = -+ std::is_same::value ? FLT_MIN : DBL_MIN; -+ if (rounded < underflow_fval && rounded > -underflow_fval && rounded != 0) { -+ set_fflags(kUnderflow); -+ } -+ -+ return static_cast(rounded); -+} -+ -+template -+static int64_t FclassHelper(T value) { -+ switch (std::fpclassify(value)) { -+ case FP_INFINITE: -+ return (std::signbit(value) ? kNegativeInfinity : kPositiveInfinity); -+ case FP_NAN: -+ return (isSnan(value) ? kSignalingNaN : kQuietNaN); -+ case FP_NORMAL: -+ return (std::signbit(value) ? kNegativeNormalNumber -+ : kPositiveNormalNumber); -+ case FP_SUBNORMAL: -+ return (std::signbit(value) ? kNegativeSubnormalNumber -+ : kPositiveSubnormalNumber); -+ case FP_ZERO: -+ return (std::signbit(value) ? kNegativeZero : kPositiveZero); -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+template -+bool Simulator::CompareFHelper(T input1, T input2, FPUCondition cc) { -+ DCHECK(std::is_floating_point::value); -+ bool result = false; -+ switch (cc) { -+ case LT: -+ case LE: -+ // FLT, FLE are signaling compares -+ if (std::isnan(input1) || std::isnan(input2)) { -+ set_fflags(kInvalidOperation); -+ result = false; -+ } else { -+ result = (cc == LT) ? (input1 < input2) : (input1 <= input2); -+ } -+ break; -+ -+ case EQ: -+ if (std::numeric_limits::signaling_NaN() == input1 || -+ std::numeric_limits::signaling_NaN() == input2) { -+ set_fflags(kInvalidOperation); -+ } -+ if (std::isnan(input1) || std::isnan(input2)) { -+ result = false; -+ } else { -+ result = (input1 == input2); -+ } -+ break; -+ -+ default: -+ UNREACHABLE(); -+ } -+ return result; -+} -+ -+template -+static inline bool is_invalid_fmul(T src1, T src2) { -+ return (isinf(src1) && src2 == static_cast(0.0)) || -+ (src1 == static_cast(0.0) && isinf(src2)); -+} -+ -+template -+static inline bool is_invalid_fadd(T src1, T src2) { -+ return (isinf(src1) && isinf(src2) && -+ std::signbit(src1) != std::signbit(src2)); -+} -+ -+template -+static inline bool is_invalid_fsub(T src1, T src2) { -+ return (isinf(src1) && isinf(src2) && -+ std::signbit(src1) == std::signbit(src2)); -+} -+ -+template -+static inline bool is_invalid_fdiv(T src1, T src2) { -+ return ((src1 == 0 && src2 == 0) || (isinf(src1) && isinf(src2))); -+} -+ -+template -+static inline bool is_invalid_fsqrt(T src1) { -+ return (src1 < 0); -+} -+ -+void Simulator::DecodeRVRAType() { -+ // TODO: Add macro for RISCV A extension -+ // Special handling for A extension instructions because it uses func5 -+ // For all A extension instruction, V8 simulator is pure sequential. No -+ // Memory address lock or other synchronizaiton behaviors. -+ switch (instr_.InstructionBits() & kRATypeMask) { -+ case RO_LR_W: { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ int64_t addr = rs1(); -+ auto val = ReadMem(addr, instr_.instr()); -+ set_rd(sext32(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, -+ &global_monitor_thread_); -+ break; -+ } -+ case RO_SC_W: { -+ int64_t addr = rs1(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) && -+ GlobalMonitor::Get()->NotifyStoreConditional_Locked( -+ addr, &global_monitor_thread_)) { -+ local_monitor_.NotifyStore(); -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ WriteMem(rs1(), (int32_t)rs2(), instr_.instr()); -+ set_rd(0, false); -+ } else { -+ set_rd(1, false); -+ } -+ break; -+ } -+ case RO_AMOSWAP_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return (uint32_t)rs2(); }, instr_.instr(), -+ WORD))); -+ break; -+ } -+ case RO_AMOADD_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return lhs + (uint32_t)rs2(); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOXOR_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return lhs ^ (uint32_t)rs2(); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOAND_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return lhs & (uint32_t)rs2(); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOOR_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return lhs | (uint32_t)rs2(); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOMIN_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](int32_t lhs) { return std::min(lhs, (int32_t)rs2()); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOMAX_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](int32_t lhs) { return std::max(lhs, (int32_t)rs2()); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOMINU_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return std::min(lhs, (uint32_t)rs2()); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+ case RO_AMOMAXU_W: { -+ set_rd(sext32(amo( -+ rs1(), [&](uint32_t lhs) { return std::max(lhs, (uint32_t)rs2()); }, -+ instr_.instr(), WORD))); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_LR_D: { -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ int64_t addr = rs1(); -+ auto val = ReadMem(addr, instr_.instr()); -+ set_rd(val, false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord); -+ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, -+ &global_monitor_thread_); -+ break; -+ } -+ case RO_SC_D: { -+ int64_t addr = rs1(); -+ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); -+ if (local_monitor_.NotifyStoreConditional(addr, -+ TransactionSize::DoubleWord) && -+ (GlobalMonitor::Get()->NotifyStoreConditional_Locked( -+ addr, &global_monitor_thread_))) { -+ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); -+ WriteMem(rs1(), rs2(), instr_.instr()); -+ set_rd(0, false); -+ } else { -+ set_rd(1, false); -+ } -+ break; -+ } -+ case RO_AMOSWAP_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return rs2(); }, instr_.instr(), DWORD)); -+ break; -+ } -+ case RO_AMOADD_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return lhs + rs2(); }, instr_.instr(), -+ DWORD)); -+ break; -+ } -+ case RO_AMOXOR_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return lhs ^ rs2(); }, instr_.instr(), -+ DWORD)); -+ break; -+ } -+ case RO_AMOAND_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return lhs & rs2(); }, instr_.instr(), -+ DWORD)); -+ break; -+ } -+ case RO_AMOOR_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return lhs | rs2(); }, instr_.instr(), -+ DWORD)); -+ break; -+ } -+ case RO_AMOMIN_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return std::min(lhs, rs2()); }, -+ instr_.instr(), DWORD)); -+ break; -+ } -+ case RO_AMOMAX_D: { -+ set_rd(amo( -+ rs1(), [&](int64_t lhs) { return std::max(lhs, rs2()); }, -+ instr_.instr(), DWORD)); -+ break; -+ } -+ case RO_AMOMINU_D: { -+ set_rd(amo( -+ rs1(), [&](uint64_t lhs) { return std::min(lhs, (uint64_t)rs2()); }, -+ instr_.instr(), DWORD)); -+ break; -+ } -+ case RO_AMOMAXU_D: { -+ set_rd(amo( -+ rs1(), [&](uint64_t lhs) { return std::max(lhs, (uint64_t)rs2()); }, -+ instr_.instr(), DWORD)); -+ break; -+ } -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: End Add macro for RISCV A extension -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+} -+ -+void Simulator::DecodeRVRFPType() { -+ // OP_FP instructions (F/D) uses func7 first. Some further uses fun3 and -+ // rs2() -+ -+ // kRATypeMask is only for func7 -+ switch (instr_.InstructionBits() & kRFPTypeMask) { -+ // TODO: Add macro for RISCV F extension -+ case RO_FADD_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2) { -+ if (is_invalid_fadd(frs1, frs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return frs1 + frs2; -+ } -+ }; -+ set_frd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FSUB_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2) { -+ if (is_invalid_fsub(frs1, frs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return frs1 - frs2; -+ } -+ }; -+ set_frd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FMUL_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2) { -+ if (is_invalid_fmul(frs1, frs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return frs1 * frs2; -+ } -+ }; -+ set_frd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FDIV_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2) { -+ if (is_invalid_fdiv(frs1, frs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else if (frs2 == 0.0f) { -+ this->set_fflags(kDivideByZero); -+ return (std::signbit(frs1) == std::signbit(frs2) -+ ? std::numeric_limits::infinity() -+ : -std::numeric_limits::infinity()); -+ } else { -+ return frs1 / frs2; -+ } -+ }; -+ set_frd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FSQRT_S: { -+ if (instr_.Rs2Value() == 0b00000) { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs) { -+ if (is_invalid_fsqrt(frs)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::sqrt(frs); -+ } -+ }; -+ set_frd(CanonicalizeFPUOp1(fn)); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ case RO_FSGNJ_S: { // RO_FSGNJN_S RO_FSQNJX_S -+ switch (instr_.Funct3Value()) { -+ case 0b000: { // RO_FSGNJ_S -+ set_frd(fsgnj32(frs1(), frs2(), false, false)); -+ break; -+ } -+ case 0b001: { // RO_FSGNJN_S -+ set_frd(fsgnj32(frs1(), frs2(), true, false)); -+ break; -+ } -+ case 0b010: { // RO_FSQNJX_S -+ set_frd(fsgnj32(frs1(), frs2(), false, true)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FMIN_S: { // RO_FMAX_S -+ switch (instr_.Funct3Value()) { -+ case 0b000: { // RO_FMIN_S -+ set_frd(FMaxMinHelper(frs1(), frs2(), MaxMinKind::kMin)); -+ break; -+ } -+ case 0b001: { // RO_FMAX_S -+ set_frd(FMaxMinHelper(frs1(), frs2(), MaxMinKind::kMax)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FCVT_W_S: { // RO_FCVT_WU_S , 64F RO_FCVT_L_S RO_FCVT_LU_S -+ float original_val = frs1(); -+ switch (instr_.Rs2Value()) { -+ case 0b00000: { // RO_FCVT_W_S -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+ case 0b00001: { // RO_FCVT_WU_S -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: { // RO_FCVT_L_S -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+ case 0b00011: { // RO_FCVT_LU_S -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FMV: { // RO_FCLASS_S -+ switch (instr_.Funct3Value()) { -+ case 0b000: { -+ if (instr_.Rs2Value() == 0b00000) { -+ // RO_FMV_X_W -+ set_rd(sext_xlen(get_fpu_register_word(rs1_reg()))); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ case 0b001: { // RO_FCLASS_S -+ set_rd(FclassHelper(frs1())); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ // FIXME (RISCV): implement handling of NaN (quiet and signalling) -+ case RO_FLE_S: { // RO_FEQ_S RO_FLT_S RO_FLE_S -+ switch (instr_.Funct3Value()) { -+ case 0b010: { // RO_FEQ_S -+ set_rd(CompareFHelper(frs1(), frs2(), EQ)); -+ break; -+ } -+ case 0b001: { // RO_FLT_S -+ set_rd(CompareFHelper(frs1(), frs2(), LT)); -+ break; -+ } -+ case 0b000: { // RO_FLE_S -+ set_rd(CompareFHelper(frs1(), frs2(), LE)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FCVT_S_W: { // RO_FCVT_S_WU , 64F RO_FCVT_S_L RO_FCVT_S_LU -+ switch (instr_.Rs2Value()) { -+ case 0b00000: { // RO_FCVT_S_W -+ set_frd((float)(int32_t)rs1()); -+ break; -+ } -+ case 0b00001: { // RO_FCVT_S_WU -+ set_frd((float)(uint32_t)rs1()); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: { // RO_FCVT_S_L -+ set_frd((float)(int64_t)rs1()); -+ break; -+ } -+ case 0b00011: { // RO_FCVT_S_LU -+ set_frd((float)(uint64_t)rs1()); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FMV_W_X: { -+ if (instr_.Funct3Value() == 0b000) { -+ // since FMV preserves source bit-pattern, no need to canonize -+ set_frd(bit_cast((uint32_t)rs1())); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ // TODO: Add macro for RISCV D extension -+ case RO_FADD_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2) { -+ if (is_invalid_fadd(drs1, drs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return drs1 + drs2; -+ } -+ }; -+ set_drd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FSUB_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2) { -+ if (is_invalid_fsub(drs1, drs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return drs1 - drs2; -+ } -+ }; -+ set_drd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FMUL_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2) { -+ if (is_invalid_fmul(drs1, drs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return drs1 * drs2; -+ } -+ }; -+ set_drd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FDIV_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2) { -+ if (is_invalid_fdiv(drs1, drs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else if (drs2 == 0.0) { -+ this->set_fflags(kDivideByZero); -+ return (std::signbit(drs1) == std::signbit(drs2) -+ ? std::numeric_limits::infinity() -+ : -std::numeric_limits::infinity()); -+ } else { -+ return drs1 / drs2; -+ } -+ }; -+ set_drd(CanonicalizeFPUOp2(fn)); -+ break; -+ } -+ case RO_FSQRT_D: { -+ if (instr_.Rs2Value() == 0b00000) { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs) { -+ if (is_invalid_fsqrt(drs)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::sqrt(drs); -+ } -+ }; -+ set_drd(CanonicalizeFPUOp1(fn)); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ case RO_FSGNJ_D: { // RO_FSGNJN_D RO_FSQNJX_D -+ switch (instr_.Funct3Value()) { -+ case 0b000: { // RO_FSGNJ_D -+ set_drd(fsgnj64(drs1(), drs2(), false, false)); -+ break; -+ } -+ case 0b001: { // RO_FSGNJN_D -+ set_drd(fsgnj64(drs1(), drs2(), true, false)); -+ break; -+ } -+ case 0b010: { // RO_FSQNJX_D -+ set_drd(fsgnj64(drs1(), drs2(), false, true)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FMIN_D: { // RO_FMAX_D -+ switch (instr_.Funct3Value()) { -+ case 0b000: { // RO_FMIN_D -+ set_drd(FMaxMinHelper(drs1(), drs2(), MaxMinKind::kMin)); -+ break; -+ } -+ case 0b001: { // RO_FMAX_D -+ set_drd(FMaxMinHelper(drs1(), drs2(), MaxMinKind::kMax)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case (RO_FCVT_S_D & kRFPTypeMask): { -+ if (instr_.Rs2Value() == 0b00001) { -+ auto fn = [](double drs) { return (float)drs; }; -+ set_frd(CanonicalizeDoubleToFloatOperation(fn)); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ case RO_FCVT_D_S: { -+ if (instr_.Rs2Value() == 0b00000) { -+ auto fn = [](float frs) { return (double)frs; }; -+ set_drd(CanonicalizeFloatToDoubleOperation(fn)); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ case RO_FLE_D: { // RO_FEQ_D RO_FLT_D RO_FLE_D -+ switch (instr_.Funct3Value()) { -+ case 0b010: { // RO_FEQ_S -+ set_rd(CompareFHelper(drs1(), drs2(), EQ)); -+ break; -+ } -+ case 0b001: { // RO_FLT_D -+ set_rd(CompareFHelper(drs1(), drs2(), LT)); -+ break; -+ } -+ case 0b000: { // RO_FLE_D -+ set_rd(CompareFHelper(drs1(), drs2(), LE)); -+ break; -+ } -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case (RO_FCLASS_D & kRFPTypeMask): { // RO_FCLASS_D , 64D RO_FMV_X_D -+ if (instr_.Rs2Value() != 0b00000) { -+ UNSUPPORTED(); -+ break; -+ } -+ switch (instr_.Funct3Value()) { -+ case 0b001: { // RO_FCLASS_D -+ set_rd(FclassHelper(drs1())); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b000: { // RO_FMV_X_D -+ set_rd(bit_cast(drs1())); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FCVT_W_D: { // RO_FCVT_WU_D , 64F RO_FCVT_L_D RO_FCVT_LU_D -+ double original_val = drs1(); -+ switch (instr_.Rs2Value()) { -+ case 0b00000: { // RO_FCVT_W_D -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+ case 0b00001: { // RO_FCVT_WU_D -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: { // RO_FCVT_L_D -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+ case 0b00011: { // RO_FCVT_LU_D -+ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+ case RO_FCVT_D_W: { // RO_FCVT_D_WU , 64F RO_FCVT_D_L RO_FCVT_D_LU -+ switch (instr_.Rs2Value()) { -+ case 0b00000: { // RO_FCVT_D_W -+ set_drd((int32_t)rs1()); -+ break; -+ } -+ case 0b00001: { // RO_FCVT_D_WU -+ set_drd((uint32_t)rs1()); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case 0b00010: { // RO_FCVT_D_L -+ set_drd((int64_t)rs1()); -+ break; -+ } -+ case 0b00011: { // RO_FCVT_D_LU -+ set_drd((uint64_t)rs1()); -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_FMV_D_X: { -+ if (instr_.Funct3Value() == 0b000 && instr_.Rs2Value() == 0b00000) { -+ // Since FMV preserves source bit-pattern, no need to canonize -+ set_drd(bit_cast(rs1())); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+#endif /* V8_TARGET_ARCH_64_BIT */ -+ default: { -+ UNSUPPORTED(); -+ } -+ } -+} -+ -+void Simulator::DecodeRVR4Type() { -+ switch (instr_.InstructionBits() & kR4TypeMask) { -+ // TODO: use F Extension macro block -+ case RO_FMADD_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2, float frs3) { -+ if (is_invalid_fmul(frs1, frs2) || is_invalid_fadd(frs1 * frs2, frs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::fma(frs1, frs2, frs3); -+ } -+ }; -+ set_frd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FMSUB_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2, float frs3) { -+ if (is_invalid_fmul(frs1, frs2) || is_invalid_fsub(frs1 * frs2, frs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::fma(frs1, frs2, -frs3); -+ } -+ }; -+ set_frd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FNMSUB_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2, float frs3) { -+ if (is_invalid_fmul(frs1, frs2) || is_invalid_fsub(frs3, frs1 * frs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return -std::fma(frs1, frs2, -frs3); -+ } -+ }; -+ set_frd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FNMADD_S: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](float frs1, float frs2, float frs3) { -+ if (is_invalid_fmul(frs1, frs2) || is_invalid_fadd(frs1 * frs2, frs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return -std::fma(frs1, frs2, frs3); -+ } -+ }; -+ set_frd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ // TODO: use F Extension macro block -+ case RO_FMADD_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2, double drs3) { -+ if (is_invalid_fmul(drs1, drs2) || is_invalid_fadd(drs1 * drs2, drs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::fma(drs1, drs2, drs3); -+ } -+ }; -+ set_drd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FMSUB_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2, double drs3) { -+ if (is_invalid_fmul(drs1, drs2) || is_invalid_fsub(drs1 * drs2, drs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return std::fma(drs1, drs2, -drs3); -+ } -+ }; -+ set_drd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FNMSUB_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2, double drs3) { -+ if (is_invalid_fmul(drs1, drs2) || is_invalid_fsub(drs3, drs1 * drs2)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return -std::fma(drs1, drs2, -drs3); -+ } -+ }; -+ set_drd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ case RO_FNMADD_D: { -+ // TODO: use rm value (round mode) -+ auto fn = [this](double drs1, double drs2, double drs3) { -+ if (is_invalid_fmul(drs1, drs2) || is_invalid_fadd(drs1 * drs2, drs3)) { -+ this->set_fflags(kInvalidOperation); -+ return std::numeric_limits::quiet_NaN(); -+ } else { -+ return -std::fma(drs1, drs2, drs3); -+ } -+ }; -+ set_drd(CanonicalizeFPUOp3(fn)); -+ break; -+ } -+ default: -+ UNSUPPORTED(); -+ } -+} -+ -+void Simulator::DecodeRVIType() { -+ switch (instr_.InstructionBits() & kITypeMask) { -+ case RO_JALR: { -+ set_rd(get_pc() + kInstrSize); -+ // Note: No need to shift 2 for JALR's imm12, but set lowest bit to 0. -+ int64_t next_pc = (rs1() + imm12()) & ~reg_t(1); -+ set_pc(next_pc); -+ break; -+ } -+ case RO_LB: { -+ int64_t addr = rs1() + imm12(); -+ int8_t val = ReadMem(addr, instr_.instr()); -+ set_rd(sext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+ case RO_LH: { -+ int64_t addr = rs1() + imm12(); -+ int16_t val = ReadMem(addr, instr_.instr()); -+ set_rd(sext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+ case RO_LW: { -+ int64_t addr = rs1() + imm12(); -+ int32_t val = ReadMem(addr, instr_.instr()); -+ set_rd(sext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+ case RO_LBU: { -+ int64_t addr = rs1() + imm12(); -+ uint8_t val = ReadMem(addr, instr_.instr()); -+ set_rd(zext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+ case RO_LHU: { -+ int64_t addr = rs1() + imm12(); -+ uint16_t val = ReadMem(addr, instr_.instr()); -+ set_rd(zext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_LWU: { -+ int64_t addr = rs1() + imm12(); -+ uint32_t val = ReadMem(addr, instr_.instr()); -+ set_rd(zext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+ case RO_LD: { -+ int64_t addr = rs1() + imm12(); -+ int64_t val = ReadMem(addr, instr_.instr()); -+ set_rd(sext_xlen(val), false); -+ TraceMemRd(addr, val, get_register(rd_reg())); -+ break; -+ } -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ case RO_ADDI: { -+ set_rd(sext_xlen(rs1() + imm12())); -+ break; -+ } -+ case RO_SLTI: { -+ set_rd(sreg_t(rs1()) < sreg_t(imm12())); -+ break; -+ } -+ case RO_SLTIU: { -+ set_rd(reg_t(rs1()) < reg_t(imm12())); -+ break; -+ } -+ case RO_XORI: { -+ set_rd(imm12() ^ rs1()); -+ break; -+ } -+ case RO_ORI: { -+ set_rd(imm12() | rs1()); -+ break; -+ } -+ case RO_ANDI: { -+ set_rd(imm12() & rs1()); -+ break; -+ } -+ case RO_SLLI: { -+ require(shamt() < xlen); -+ set_rd(sext_xlen(rs1() << shamt())); -+ break; -+ } -+ case RO_SRLI: { // RO_SRAI -+ if (!instr_.IsArithShift()) { -+ require(shamt() < xlen); -+ set_rd(sext_xlen(zext_xlen(rs1()) >> shamt())); -+ } else { -+ require(shamt() < xlen); -+ set_rd(sext_xlen(sext_xlen(rs1()) >> shamt())); -+ } -+ break; -+ } -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_ADDIW: { -+ set_rd(sext32(rs1() + imm12())); -+ break; -+ } -+ case RO_SLLIW: { -+ set_rd(sext32(rs1() << shamt32())); -+ break; -+ } -+ case RO_SRLIW: { // RO_SRAIW -+ if (!instr_.IsArithShift()) { -+ set_rd(sext32(uint32_t(rs1()) >> shamt32())); -+ } else { -+ set_rd(sext32(int32_t(rs1()) >> shamt32())); -+ } -+ break; -+ } -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ case RO_FENCE: { -+ // DO nothing in sumulator -+ break; -+ } -+ case RO_ECALL: { // RO_EBREAK -+ if (instr_.Imm12Value() == 0) { // ECALL -+ SoftwareInterrupt(); -+ } else if (instr_.Imm12Value() == 1) { // EBREAK -+ SoftwareInterrupt(); -+ } else { -+ UNSUPPORTED(); -+ } -+ break; -+ } -+ // TODO: use Zifencei Standard Extension macro block -+ case RO_FENCE_I: { -+ // spike: flush icache. -+ break; -+ } -+ // TODO: use Zicsr Standard Extension macro block -+ case RO_CSRRW: { -+ if (rd_reg() != zero_reg) { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ } -+ write_csr_value(csr_reg(), rs1()); -+ break; -+ } -+ case RO_CSRRS: { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ if (rs1_reg() != zero_reg) { -+ set_csr_bits(csr_reg(), rs1()); -+ } -+ break; -+ } -+ case RO_CSRRC: { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ if (rs1_reg() != zero_reg) { -+ clear_csr_bits(csr_reg(), rs1()); -+ } -+ break; -+ } -+ case RO_CSRRWI: { -+ if (rd_reg() != zero_reg) { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ } -+ write_csr_value(csr_reg(), imm5CSR()); -+ break; -+ } -+ case RO_CSRRSI: { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ if (imm5CSR() != 0) { -+ set_csr_bits(csr_reg(), imm5CSR()); -+ } -+ break; -+ } -+ case RO_CSRRCI: { -+ set_rd(zext_xlen(read_csr_value(csr_reg()))); -+ if (imm5CSR() != 0) { -+ clear_csr_bits(csr_reg(), imm5CSR()); -+ } -+ break; -+ } -+ // TODO: use F Extension macro block -+ case RO_FLW: { -+ int64_t addr = rs1() + imm12(); -+ float val = ReadMem(addr, instr_.instr()); -+ set_frd(val, false); -+ TraceMemRd(addr, val, get_fpu_register(frd_reg())); -+ break; -+ } -+ // TODO: use D Extension macro block -+ case RO_FLD: { -+ int64_t addr = rs1() + imm12(); -+ double val = ReadMem(addr, instr_.instr()); -+ set_drd(val, false); -+ TraceMemRd(addr, val, get_fpu_register(frd_reg())); -+ break; -+ } -+ default: -+ UNSUPPORTED(); -+ } -+} -+ -+void Simulator::DecodeRVSType() { -+ switch (instr_.InstructionBits() & kSTypeMask) { -+ case RO_SB: -+ WriteMem(rs1() + s_imm12(), (uint8_t)rs2(), instr_.instr()); -+ break; -+ case RO_SH: -+ WriteMem(rs1() + s_imm12(), (uint16_t)rs2(), instr_.instr()); -+ break; -+ case RO_SW: -+ WriteMem(rs1() + s_imm12(), (uint32_t)rs2(), instr_.instr()); -+ break; -+#ifdef V8_TARGET_ARCH_64_BIT -+ case RO_SD: -+ WriteMem(rs1() + s_imm12(), (uint64_t)rs2(), instr_.instr()); -+ break; -+#endif /*V8_TARGET_ARCH_64_BIT*/ -+ // TODO: use F Extension macro block -+ case RO_FSW: { -+ WriteMem(rs1() + s_imm12(), -+ (uint32_t)get_fpu_register_word(rs2_reg()), -+ instr_.instr()); -+ break; -+ } -+ // TODO: use D Extension macro block -+ case RO_FSD: { -+ WriteMem(rs1() + s_imm12(), drs2(), instr_.instr()); -+ break; -+ } -+ default: -+ UNSUPPORTED(); -+ } -+} -+ -+void Simulator::DecodeRVBType() { -+ switch (instr_.InstructionBits() & kBTypeMask) { -+ case RO_BEQ: -+ if (rs1() == rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ case RO_BNE: -+ if (rs1() != rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ case RO_BLT: -+ if (rs1() < rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ case RO_BGE: -+ if (rs1() >= rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ case RO_BLTU: -+ if ((reg_t)rs1() < (reg_t)rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ case RO_BGEU: -+ if ((reg_t)rs1() >= (reg_t)rs2()) { -+ int64_t next_pc = get_pc() + boffset(); -+ set_pc(next_pc); -+ } -+ break; -+ default: -+ UNSUPPORTED(); -+ } -+} -+void Simulator::DecodeRVUType() { -+ // U Type doesn't have additoinal mask -+ switch (instr_.BaseOpcodeFieldRaw()) { -+ case RO_LUI: -+ set_rd(u_imm()); -+ break; -+ case RO_AUIPC: -+ set_rd(sext_xlen(u_imm() + get_pc())); -+ break; -+ default: -+ UNSUPPORTED(); -+ } -+} -+void Simulator::DecodeRVJType() { -+ // J Type doesn't have additional mask -+ switch (instr_.BaseOpcodeValue()) { -+ case RO_JAL: { -+ set_rd(get_pc() + kInstrSize); -+ int64_t next_pc = get_pc() + imm20J(); -+ set_pc(next_pc); -+ break; -+ } -+ default: -+ UNSUPPORTED(); -+ } -+} -+ -+// Executes the current instruction. -+void Simulator::InstructionDecode(Instruction* instr) { -+ if (v8::internal::FLAG_check_icache) { -+ CheckICache(i_cache(), instr); -+ } -+ pc_modified_ = false; -+ -+ v8::internal::EmbeddedVector buffer; -+ -+ if (::v8::internal::FLAG_trace_sim) { -+ SNPrintF(trace_buf_, " "); -+ disasm::NameConverter converter; -+ disasm::Disassembler dasm(converter); -+ // Use a reasonably large buffer. -+ dasm.InstructionDecode(buffer, reinterpret_cast(instr)); -+ -+ // PrintF("EXECUTING 0x%08" PRIxPTR " %-44s\n", -+ // reinterpret_cast(instr), buffer.begin()); -+ } -+ -+ instr_ = instr; -+ switch (instr_.InstructionType()) { -+ case Instruction::kRType: -+ DecodeRVRType(); -+ break; -+ case Instruction::kR4Type: -+ DecodeRVR4Type(); -+ break; -+ case Instruction::kIType: -+ DecodeRVIType(); -+ break; -+ case Instruction::kSType: -+ DecodeRVSType(); -+ break; -+ case Instruction::kBType: -+ DecodeRVBType(); -+ break; -+ case Instruction::kUType: -+ DecodeRVUType(); -+ break; -+ case Instruction::kJType: -+ DecodeRVJType(); -+ break; -+ default: -+ if (::v8::internal::FLAG_trace_sim) { -+ std::cout << "Unrecognized instruction [@pc=0x" << std::hex -+ << registers_[pc] << "]: 0x" << instr->InstructionBits() -+ << std::endl; -+ } -+ UNSUPPORTED(); -+ } -+ -+ if (::v8::internal::FLAG_trace_sim) { -+ PrintF(" 0x%012" PRIxPTR " %-44s %s\n", -+ reinterpret_cast(instr), buffer.begin(), -+ trace_buf_.begin()); -+ } -+ -+ if (!pc_modified_) { -+ set_register(pc, reinterpret_cast(instr) + kInstrSize); -+ } -+} -+ -+void Simulator::Execute() { -+ // Get the PC to simulate. Cannot use the accessor here as we need the -+ // raw PC value and not the one used as input to arithmetic instructions. -+ int64_t program_counter = get_pc(); -+ while (program_counter != end_sim_pc) { -+ Instruction* instr = reinterpret_cast(program_counter); -+ icount_++; -+ if (icount_ == static_cast(::v8::internal::FLAG_stop_sim_at)) { -+ RiscvDebugger dbg(this); -+ dbg.Debug(); -+ } else { -+ InstructionDecode(instr); -+ } -+ CheckBreakpoints(); -+ program_counter = get_pc(); -+ } -+} -+ -+void Simulator::CallInternal(Address entry) { -+ // Adjust JS-based stack limit to C-based stack limit. -+ isolate_->stack_guard()->AdjustStackLimitForSimulator(); -+ -+ // Prepare to execute the code at entry. -+ set_register(pc, static_cast(entry)); -+ // Put down marker for end of simulation. The simulator will stop simulation -+ // when the PC reaches this value. By saving the "end simulation" value into -+ // the LR the simulation stops when returning to this call point. -+ set_register(ra, end_sim_pc); -+ -+ // Remember the values of callee-saved registers. -+ // The code below assumes that r9 is not used as sb (static base) in -+ // simulator code and therefore is regarded as a callee-saved register. -+ int64_t s0_val = get_register(s0); -+ int64_t s1_val = get_register(s1); -+ int64_t s2_val = get_register(s2); -+ int64_t s3_val = get_register(s3); -+ int64_t s4_val = get_register(s4); -+ int64_t s5_val = get_register(s5); -+ int64_t s6_val = get_register(s6); -+ int64_t s7_val = get_register(s7); -+ int64_t gp_val = get_register(gp); -+ int64_t sp_val = get_register(sp); -+ int64_t fp_val = get_register(fp); -+ -+ // Set up the callee-saved registers with a known value. To be able to check -+ // that they are preserved properly across JS execution. -+ int64_t callee_saved_value = icount_; -+ set_register(s0, callee_saved_value); -+ set_register(s1, callee_saved_value); -+ set_register(s2, callee_saved_value); -+ set_register(s3, callee_saved_value); -+ set_register(s4, callee_saved_value); -+ set_register(s5, callee_saved_value); -+ set_register(s6, callee_saved_value); -+ set_register(s7, callee_saved_value); -+ set_register(gp, callee_saved_value); -+ set_register(fp, callee_saved_value); -+ -+ // Start the simulation. -+ Execute(); -+ -+ // Check that the callee-saved registers have been preserved. -+ CHECK_EQ(callee_saved_value, get_register(s0)); -+ CHECK_EQ(callee_saved_value, get_register(s1)); -+ CHECK_EQ(callee_saved_value, get_register(s2)); -+ CHECK_EQ(callee_saved_value, get_register(s3)); -+ CHECK_EQ(callee_saved_value, get_register(s4)); -+ CHECK_EQ(callee_saved_value, get_register(s5)); -+ CHECK_EQ(callee_saved_value, get_register(s6)); -+ CHECK_EQ(callee_saved_value, get_register(s7)); -+ CHECK_EQ(callee_saved_value, get_register(gp)); -+ CHECK_EQ(callee_saved_value, get_register(fp)); -+ -+ // Restore callee-saved registers with the original value. -+ set_register(s0, s0_val); -+ set_register(s1, s1_val); -+ set_register(s2, s2_val); -+ set_register(s3, s3_val); -+ set_register(s4, s4_val); -+ set_register(s5, s5_val); -+ set_register(s6, s6_val); -+ set_register(s7, s7_val); -+ set_register(gp, gp_val); -+ set_register(sp, sp_val); -+ set_register(fp, fp_val); -+} -+ -+intptr_t Simulator::CallImpl(Address entry, int argument_count, -+ const intptr_t* arguments) { -+ constexpr int kRegisterPassedArguments = 8; -+ // Set up arguments. -+ -+ // First four arguments passed in registers in both ABI's. -+ int reg_arg_count = std::min(kRegisterPassedArguments, argument_count); -+ if (reg_arg_count > 0) set_register(a0, arguments[0]); -+ if (reg_arg_count > 1) set_register(a1, arguments[1]); -+ if (reg_arg_count > 2) set_register(a2, arguments[2]); -+ if (reg_arg_count > 3) set_register(a3, arguments[3]); -+ -+ // Up to eight arguments passed in registers in N64 ABI. -+ // TODO(plind): N64 ABI calls these regs a4 - a7. Clarify this. -+ if (reg_arg_count > 4) set_register(a4, arguments[4]); -+ if (reg_arg_count > 5) set_register(a5, arguments[5]); -+ if (reg_arg_count > 6) set_register(a6, arguments[6]); -+ if (reg_arg_count > 7) set_register(a7, arguments[7]); -+ -+ if (::v8::internal::FLAG_trace_sim) { -+ std::cout << "CallImpl: reg_arg_count = " << reg_arg_count << std::hex -+ << " entry-pc (JSEntry) = 0x" << entry << " a0 (Isolate) = 0x" -+ << get_register(a0) << " a1 (orig_func/new_target) = 0x" -+ << get_register(a1) << " a2 (func/target) = 0x" -+ << get_register(a2) << " a3 (receiver) = 0x" << get_register(a3) -+ << " a4 (argc) = 0x" << get_register(a4) << " a5 (argv) = 0x" -+ << get_register(a5) << std::endl; -+ } -+ -+ // Remaining arguments passed on stack. -+ int64_t original_stack = get_register(sp); -+ // Compute position of stack on entry to generated code. -+ int stack_args_count = argument_count - reg_arg_count; -+ int stack_args_size = stack_args_count * sizeof(*arguments) + kCArgsSlotsSize; -+ int64_t entry_stack = original_stack - stack_args_size; -+ -+ if (base::OS::ActivationFrameAlignment() != 0) { -+ entry_stack &= -base::OS::ActivationFrameAlignment(); -+ } -+ // Store remaining arguments on stack, from low to high memory. -+ intptr_t* stack_argument = reinterpret_cast(entry_stack); -+ memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count, -+ stack_args_count * sizeof(*arguments)); -+ set_register(sp, entry_stack); -+ -+ CallInternal(entry); -+ -+ // Pop stack passed arguments. -+ CHECK_EQ(entry_stack, get_register(sp)); -+ set_register(sp, original_stack); -+ -+ // return get_register(a0); -+ // RISCV uses a0 to return result -+ return get_register(a0); -+} -+ -+double Simulator::CallFP(Address entry, double d0, double d1) { -+ set_fpu_register_double(fa0, d0); -+ set_fpu_register_double(fa1, d1); -+ CallInternal(entry); -+ return get_fpu_register_double(fa0); -+} -+ -+uintptr_t Simulator::PushAddress(uintptr_t address) { -+ int64_t new_sp = get_register(sp) - sizeof(uintptr_t); -+ uintptr_t* stack_slot = reinterpret_cast(new_sp); -+ *stack_slot = address; -+ set_register(sp, new_sp); -+ return new_sp; -+} -+ -+uintptr_t Simulator::PopAddress() { -+ int64_t current_sp = get_register(sp); -+ uintptr_t* stack_slot = reinterpret_cast(current_sp); -+ uintptr_t address = *stack_slot; -+ set_register(sp, current_sp + sizeof(uintptr_t)); -+ return address; -+} -+ -+Simulator::LocalMonitor::LocalMonitor() -+ : access_state_(MonitorAccess::Open), -+ tagged_addr_(0), -+ size_(TransactionSize::None) {} -+ -+void Simulator::LocalMonitor::Clear() { -+ access_state_ = MonitorAccess::Open; -+ tagged_addr_ = 0; -+ size_ = TransactionSize::None; -+} -+ -+void Simulator::LocalMonitor::NotifyLoad() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non linked load could clear the local monitor. As a result, it's -+ // most strict to unconditionally clear the local monitor on load. -+ Clear(); -+ } -+} -+ -+void Simulator::LocalMonitor::NotifyLoadLinked(uintptr_t addr, -+ TransactionSize size) { -+ access_state_ = MonitorAccess::RMW; -+ tagged_addr_ = addr; -+ size_ = size; -+} -+ -+void Simulator::LocalMonitor::NotifyStore() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non exclusive store could clear the local monitor. As a result, it's -+ // most strict to unconditionally clear the local monitor on store. -+ Clear(); -+ } -+} -+ -+bool Simulator::LocalMonitor::NotifyStoreConditional(uintptr_t addr, -+ TransactionSize size) { -+ if (access_state_ == MonitorAccess::RMW) { -+ if (addr == tagged_addr_ && size_ == size) { -+ Clear(); -+ return true; -+ } else { -+ return false; -+ } -+ } else { -+ DCHECK(access_state_ == MonitorAccess::Open); -+ return false; -+ } -+} -+ -+Simulator::GlobalMonitor::LinkedAddress::LinkedAddress() -+ : access_state_(MonitorAccess::Open), -+ tagged_addr_(0), -+ next_(nullptr), -+ prev_(nullptr), -+ failure_counter_(0) {} -+ -+void Simulator::GlobalMonitor::LinkedAddress::Clear_Locked() { -+ access_state_ = MonitorAccess::Open; -+ tagged_addr_ = 0; -+} -+ -+void Simulator::GlobalMonitor::LinkedAddress::NotifyLoadLinked_Locked( -+ uintptr_t addr) { -+ access_state_ = MonitorAccess::RMW; -+ tagged_addr_ = addr; -+} -+ -+void Simulator::GlobalMonitor::LinkedAddress::NotifyStore_Locked() { -+ if (access_state_ == MonitorAccess::RMW) { -+ // A non exclusive store could clear the global monitor. As a result, it's -+ // most strict to unconditionally clear global monitors on store. -+ Clear_Locked(); -+ } -+} -+ -+bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked( -+ uintptr_t addr, bool is_requesting_thread) { -+ if (access_state_ == MonitorAccess::RMW) { -+ if (is_requesting_thread) { -+ if (addr == tagged_addr_) { -+ Clear_Locked(); -+ // Introduce occasional sc/scd failures. This is to simulate the -+ // behavior of hardware, which can randomly fail due to background -+ // cache evictions. -+ if (failure_counter_++ >= kMaxFailureCounter) { -+ failure_counter_ = 0; -+ return false; -+ } else { -+ return true; -+ } -+ } -+ } else if ((addr & kExclusiveTaggedAddrMask) == -+ (tagged_addr_ & kExclusiveTaggedAddrMask)) { -+ // Check the masked addresses when responding to a successful lock by -+ // another thread so the implementation is more conservative (i.e. the -+ // granularity of locking is as large as possible.) -+ Clear_Locked(); -+ return false; -+ } -+ } -+ return false; -+} -+ -+void Simulator::GlobalMonitor::NotifyLoadLinked_Locked( -+ uintptr_t addr, LinkedAddress* linked_address) { -+ linked_address->NotifyLoadLinked_Locked(addr); -+ PrependProcessor_Locked(linked_address); -+} -+ -+void Simulator::GlobalMonitor::NotifyStore_Locked( -+ LinkedAddress* linked_address) { -+ // Notify each thread of the store operation. -+ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { -+ iter->NotifyStore_Locked(); -+ } -+} -+ -+bool Simulator::GlobalMonitor::NotifyStoreConditional_Locked( -+ uintptr_t addr, LinkedAddress* linked_address) { -+ DCHECK(IsProcessorInLinkedList_Locked(linked_address)); -+ if (linked_address->NotifyStoreConditional_Locked(addr, true)) { -+ // Notify the other processors that this StoreConditional succeeded. -+ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { -+ if (iter != linked_address) { -+ iter->NotifyStoreConditional_Locked(addr, false); -+ } -+ } -+ return true; -+ } else { -+ return false; -+ } -+} -+ -+bool Simulator::GlobalMonitor::IsProcessorInLinkedList_Locked( -+ LinkedAddress* linked_address) const { -+ return head_ == linked_address || linked_address->next_ || -+ linked_address->prev_; -+} -+ -+void Simulator::GlobalMonitor::PrependProcessor_Locked( -+ LinkedAddress* linked_address) { -+ if (IsProcessorInLinkedList_Locked(linked_address)) { -+ return; -+ } -+ -+ if (head_) { -+ head_->prev_ = linked_address; -+ } -+ linked_address->prev_ = nullptr; -+ linked_address->next_ = head_; -+ head_ = linked_address; -+} -+ -+void Simulator::GlobalMonitor::RemoveLinkedAddress( -+ LinkedAddress* linked_address) { -+ base::MutexGuard lock_guard(&mutex); -+ if (!IsProcessorInLinkedList_Locked(linked_address)) { -+ return; -+ } -+ -+ if (linked_address->prev_) { -+ linked_address->prev_->next_ = linked_address->next_; -+ } else { -+ head_ = linked_address->next_; -+ } -+ if (linked_address->next_) { -+ linked_address->next_->prev_ = linked_address->prev_; -+ } -+ linked_address->prev_ = nullptr; -+ linked_address->next_ = nullptr; -+} -+ -+#undef SScanF -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // USE_SIMULATOR ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/execution/riscv64/simulator-riscv64.h -@@ -0,0 +1,764 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Copyright(c) 2010 - 2017, -+// The Regents of the University of California(Regents).All Rights Reserved. -+// -+// Redistribution and use in source and binary forms, -+// with or without modification, -+// are permitted provided that the following -+// conditions are met : 1. Redistributions of source code must retain the -+// above copyright notice, this list of conditions and the following -+// disclaimer.2. Redistributions in binary form must reproduce the above -+// copyright notice, this list of conditions and the following disclaimer in -+// the -+// documentation and / -+// or -+// other materials provided with the distribution.3. Neither the name of -+// the Regents nor the names of its contributors may be used to endorse -+// or -+// promote products derived from -+// this software without specific prior written permission. -+// -+// IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, -+// INDIRECT, SPECIAL, -+// INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, -+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -+// EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+// -+// REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, -+// INCLUDING, BUT NOT LIMITED TO, -+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -+// PARTICULAR PURPOSE.THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, -+// IF ANY, -+// PROVIDED HEREUNDER IS PROVIDED -+// "AS IS".REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, -+// SUPPORT, UPDATES, ENHANCEMENTS, -+// OR MODIFICATIONS. -+ -+// The original source code covered by the above license above has been -+// modified significantly by the v8 project authors. -+ -+// Declares a Simulator for RISC-V instructions if we are not generating a -+// native RISC-V binary. This Simulator allows us to run and debug RISC-V code -+// generation on regular desktop machines. V8 calls into generated code via the -+// GeneratedCode wrapper, which will start execution in the Simulator or -+// forwards to the real entry on a RISC-V HW platform. -+ -+#ifndef V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ -+#define V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ -+ -+// globals.h defines USE_SIMULATOR. -+#include "src/common/globals.h" -+ -+template -+int Compare(const T& a, const T& b) { -+ if (a == b) -+ return 0; -+ else if (a < b) -+ return -1; -+ else -+ return 1; -+} -+ -+// Returns the negative absolute value of its argument. -+template ::value>::type> -+T Nabs(T a) { -+ return a < 0 ? a : -a; -+} -+ -+#if defined(USE_SIMULATOR) -+// Running with a simulator. -+ -+#include "src/base/hashmap.h" -+#include "src/codegen/assembler.h" -+#include "src/codegen/riscv64/constants-riscv64.h" -+#include "src/execution/simulator-base.h" -+#include "src/utils/allocation.h" -+ -+namespace v8 { -+namespace internal { -+ -+// ----------------------------------------------------------------------------- -+// Utility types and functions for RISCV -+// TODO: Add Spike License here -+#ifdef V8_TARGET_ARCH_32_BIT -+using sreg_t = int32_t; -+using reg_t = uint32_t; -+#define xlen 32 -+#elif V8_TARGET_ARCH_64_BIT -+using sreg_t = int64_t; -+using reg_t = uint64_t; -+#define xlen 64 -+#else -+#error "Cannot detect Riscv's bitwidth" -+#endif -+ -+#define sext32(x) ((sreg_t)(int32_t)(x)) -+#define zext32(x) ((reg_t)(uint32_t)(x)) -+#define sext_xlen(x) (((sreg_t)(x) << (64 - xlen)) >> (64 - xlen)) -+#define zext_xlen(x) (((reg_t)(x) << (64 - xlen)) >> (64 - xlen)) -+ -+#define BIT(n) (0x1LL << n) -+#define QUIET_BIT_S(nan) (bit_cast(nan) & BIT(22)) -+#define QUIET_BIT_D(nan) (bit_cast(nan) & BIT(51)) -+static inline bool isSnan(float fp) { return !QUIET_BIT_S(fp); } -+static inline bool isSnan(double fp) { return !QUIET_BIT_D(fp); } -+#undef QUIET_BIT_S -+#undef QUIET_BIT_D -+ -+inline uint64_t mulhu(uint64_t a, uint64_t b) { -+ __uint128_t full_result = ((__uint128_t)a) * ((__uint128_t)b); -+ return full_result >> 64; -+} -+ -+inline int64_t mulh(int64_t a, int64_t b) { -+ __int128_t full_result = ((__int128_t)a) * ((__int128_t)b); -+ return full_result >> 64; -+} -+ -+inline int64_t mulhsu(int64_t a, uint64_t b) { -+ __int128_t full_result = ((__int128_t)a) * ((__uint128_t)b); -+ return full_result >> 64; -+} -+ -+// Floating point helpers -+#define F32_SIGN ((uint32_t)1 << 31) -+union u32_f32 { -+ uint32_t u; -+ float f; -+}; -+inline float fsgnj32(float rs1, float rs2, bool n, bool x) { -+ u32_f32 a = {.f = rs1}, b = {.f = rs2}; -+ u32_f32 res; -+ res.u = -+ (a.u & ~F32_SIGN) | ((((x) ? a.u : (n) ? F32_SIGN : 0) ^ b.u) & F32_SIGN); -+ return res.f; -+} -+#define F64_SIGN ((uint64_t)1 << 63) -+union u64_f64 { -+ uint64_t u; -+ double d; -+}; -+inline double fsgnj64(double rs1, double rs2, bool n, bool x) { -+ u64_f64 a = {.d = rs1}, b = {.d = rs2}; -+ u64_f64 res; -+ res.u = -+ (a.u & ~F64_SIGN) | ((((x) ? a.u : (n) ? F64_SIGN : 0) ^ b.u) & F64_SIGN); -+ return res.d; -+} -+ -+inline bool is_boxed_float(int64_t v) { -+ return (uint32_t)((v >> 32) + 1) == 0; -+} -+inline int64_t box_float(float v) { -+ return (0xFFFFFFFF00000000 | bit_cast(v)); -+} -+ -+// ----------------------------------------------------------------------------- -+// Utility functions -+ -+class CachePage { -+ public: -+ static const int LINE_VALID = 0; -+ static const int LINE_INVALID = 1; -+ -+ static const int kPageShift = 12; -+ static const int kPageSize = 1 << kPageShift; -+ static const int kPageMask = kPageSize - 1; -+ static const int kLineShift = 2; // The cache line is only 4 bytes right now. -+ static const int kLineLength = 1 << kLineShift; -+ static const int kLineMask = kLineLength - 1; -+ -+ CachePage() { memset(&validity_map_, LINE_INVALID, sizeof(validity_map_)); } -+ -+ char* ValidityByte(int offset) { -+ return &validity_map_[offset >> kLineShift]; -+ } -+ -+ char* CachedData(int offset) { return &data_[offset]; } -+ -+ private: -+ char data_[kPageSize]; // The cached data. -+ static const int kValidityMapSize = kPageSize >> kLineShift; -+ char validity_map_[kValidityMapSize]; // One byte per line. -+}; -+ -+class SimInstructionBase : public InstructionBase { -+ public: -+ Type InstructionType() const { return type_; } -+ inline Instruction* instr() const { return instr_; } -+ inline int32_t operand() const { return operand_; } -+ -+ protected: -+ SimInstructionBase() : operand_(-1), instr_(nullptr), type_(kUnsupported) {} -+ explicit SimInstructionBase(Instruction* instr) {} -+ -+ int32_t operand_; -+ Instruction* instr_; -+ Type type_; -+ -+ private: -+ DISALLOW_ASSIGN(SimInstructionBase); -+}; -+ -+class SimInstruction : public InstructionGetters { -+ public: -+ SimInstruction() {} -+ -+ explicit SimInstruction(Instruction* instr) { *this = instr; } -+ -+ SimInstruction& operator=(Instruction* instr) { -+ operand_ = *reinterpret_cast(instr); -+ instr_ = instr; -+ type_ = InstructionBase::InstructionType(); -+ DCHECK(reinterpret_cast(&operand_) == this); -+ return *this; -+ } -+}; -+ -+class Simulator : public SimulatorBase { -+ public: -+ friend class RiscvDebugger; -+ -+ // Registers are declared in order. See SMRL chapter 2. -+ enum Register { -+ no_reg = -1, -+ zero_reg = 0, -+ ra, -+ sp, -+ gp, -+ tp, -+ t0, -+ t1, -+ t2, -+ s0, -+ s1, -+ a0, -+ a1, -+ a2, -+ a3, -+ a4, -+ a5, -+ a6, -+ a7, -+ s2, -+ s3, -+ s4, -+ s5, -+ s6, -+ s7, -+ s8, -+ s9, -+ s10, -+ s11, -+ t3, -+ t4, -+ t5, -+ t6, -+ pc, // pc must be the last register. -+ kNumSimuRegisters, -+ // aliases -+ fp = s0 -+ }; -+ -+ // Coprocessor registers. -+ // Generated code will always use doubles. So we will only use even registers. -+ enum FPURegister { -+ ft0, -+ ft1, -+ ft2, -+ ft3, -+ ft4, -+ ft5, -+ ft6, -+ ft7, -+ fs0, -+ fs1, -+ fa0, -+ fa1, -+ fa2, -+ fa3, -+ fa4, -+ fa5, -+ fa6, -+ fa7, -+ fs2, -+ fs3, -+ fs4, -+ fs5, -+ fs6, -+ fs7, -+ fs8, -+ fs9, -+ fs10, -+ fs11, -+ ft8, -+ ft9, -+ ft10, -+ ft11, -+ kNumFPURegisters -+ }; -+ -+ explicit Simulator(Isolate* isolate); -+ ~Simulator(); -+ -+ // The currently executing Simulator instance. Potentially there can be one -+ // for each native thread. -+ V8_EXPORT_PRIVATE static Simulator* current(v8::internal::Isolate* isolate); -+ -+ // Accessors for register state. Reading the pc value adheres to the RISC-V -+ // architecture specification and is off by a 8 from the currently executing -+ // instruction. -+ void set_register(int reg, int64_t value); -+ void set_register_word(int reg, int32_t value); -+ void set_dw_register(int dreg, const int* dbl); -+ int64_t get_register(int reg) const; -+ double get_double_from_register_pair(int reg); -+ -+ // Same for FPURegisters. -+ void set_fpu_register(int fpureg, int64_t value); -+ void set_fpu_register_word(int fpureg, int32_t value); -+ void set_fpu_register_hi_word(int fpureg, int32_t value); -+ void set_fpu_register_float(int fpureg, float value); -+ void set_fpu_register_double(int fpureg, double value); -+ -+ int64_t get_fpu_register(int fpureg) const; -+ int32_t get_fpu_register_word(int fpureg) const; -+ int32_t get_fpu_register_signed_word(int fpureg) const; -+ int32_t get_fpu_register_hi_word(int fpureg) const; -+ float get_fpu_register_float(int fpureg) const; -+ double get_fpu_register_double(int fpureg) const; -+ -+ // RV CSR manipulation -+ uint32_t read_csr_value(uint32_t csr); -+ void write_csr_value(uint32_t csr, uint64_t value); -+ void set_csr_bits(uint32_t csr, uint64_t flags); -+ void clear_csr_bits(uint32_t csr, uint64_t flags); -+ -+ void set_fflags(uint32_t flags) { set_csr_bits(csr_fflags, flags); } -+ void clear_fflags(int32_t flags) { clear_csr_bits(csr_fflags, flags); } -+ -+ inline uint32_t get_dynamic_rounding_mode(); -+ inline bool test_fflags_bits(uint32_t mask); -+ -+ float RoundF2FHelper(float input_val, int rmode); -+ double RoundF2FHelper(double input_val, int rmode); -+ template -+ I_TYPE RoundF2IHelper(F_TYPE original, int rmode); -+ -+ template -+ T FMaxMinHelper(T a, T b, MaxMinKind kind); -+ -+ template -+ bool CompareFHelper(T input1, T input2, FPUCondition cc); -+ -+ // Special case of set_register and get_register to access the raw PC value. -+ void set_pc(int64_t value); -+ int64_t get_pc() const; -+ -+ Address get_sp() const { return static_cast
(get_register(sp)); } -+ -+ // Accessor to the internal simulator stack area. -+ uintptr_t StackLimit(uintptr_t c_limit) const; -+ -+ // Executes RISC-V instructions until the PC reaches end_sim_pc. -+ void Execute(); -+ -+ template -+ Return Call(Address entry, Args... args) { -+ return VariadicCall(this, &Simulator::CallImpl, entry, args...); -+ } -+ -+ // Alternative: call a 2-argument double function. -+ double CallFP(Address entry, double d0, double d1); -+ -+ // Push an address onto the JS stack. -+ uintptr_t PushAddress(uintptr_t address); -+ -+ // Pop an address from the JS stack. -+ uintptr_t PopAddress(); -+ -+ // Debugger input. -+ void set_last_debugger_input(char* input); -+ char* last_debugger_input() { return last_debugger_input_; } -+ -+ // Redirection support. -+ static void SetRedirectInstruction(Instruction* instruction); -+ -+ // ICache checking. -+ static bool ICacheMatch(void* one, void* two); -+ static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, -+ size_t size); -+ -+ // Returns true if pc register contains one of the 'special_values' defined -+ // below (bad_ra, end_sim_pc). -+ bool has_bad_pc() const; -+ -+ private: -+ enum special_values { -+ // Known bad pc value to ensure that the simulator does not execute -+ // without being properly setup. -+ bad_ra = -1, -+ // A pc value used to signal the simulator to stop execution. Generally -+ // the ra is set to this value on transition from native C code to -+ // simulated execution, so that the simulator can "return" to the native -+ // C code. -+ end_sim_pc = -2, -+ // Unpredictable value. -+ Unpredictable = 0xbadbeaf -+ }; -+ -+ V8_EXPORT_PRIVATE intptr_t CallImpl(Address entry, int argument_count, -+ const intptr_t* arguments); -+ -+ // Unsupported instructions use Format to print an error and stop execution. -+ void Format(Instruction* instr, const char* format); -+ -+ // Helpers for data value tracing. -+ enum TraceType { -+ BYTE, -+ HALF, -+ WORD, -+ DWORD, -+ FLOAT, -+ DOUBLE, -+ // FLOAT_DOUBLE, -+ // WORD_DWORD -+ }; -+ -+ // RISCV Memory read/write methods -+ template -+ T ReadMem(int64_t addr, Instruction* instr); -+ template -+ void WriteMem(int64_t addr, T value, Instruction* instr); -+ template -+ T amo(int64_t addr, OP f, Instruction* instr, TraceType t) { -+ auto lhs = ReadMem(addr, instr); -+ // FIXME: trace memory read for AMO -+ WriteMem(addr, (T)f(lhs), instr); -+ return lhs; -+ } -+ -+ // Helper for debugging memory access. -+ inline void DieOrDebug(); -+ -+ void TraceRegWr(int64_t value, TraceType t = DWORD); -+ void TraceMemWr(int64_t addr, int64_t value, TraceType t); -+ template -+ void TraceMemRd(int64_t addr, T value, int64_t reg_value); -+ template -+ void TraceMemWr(int64_t addr, T value); -+ -+ SimInstruction instr_; -+ -+ // RISCV utlity API to access register value -+ inline int32_t rs1_reg() const { return instr_.Rs1Value(); } -+ inline int64_t rs1() const { return get_register(rs1_reg()); } -+ inline float frs1() const { return get_fpu_register_float(rs1_reg()); } -+ inline double drs1() const { return get_fpu_register_double(rs1_reg()); } -+ inline int32_t rs2_reg() const { return instr_.Rs2Value(); } -+ inline int64_t rs2() const { return get_register(rs2_reg()); } -+ inline float frs2() const { return get_fpu_register_float(rs2_reg()); } -+ inline double drs2() const { return get_fpu_register_double(rs2_reg()); } -+ inline int32_t rs3_reg() const { return instr_.Rs3Value(); } -+ inline int64_t rs3() const { return get_register(rs3_reg()); } -+ inline float frs3() const { return get_fpu_register_float(rs3_reg()); } -+ inline double drs3() const { return get_fpu_register_double(rs3_reg()); } -+ inline int32_t rd_reg() const { return instr_.RdValue(); } -+ inline int32_t frd_reg() const { return instr_.RdValue(); } -+ inline int16_t boffset() const { return instr_.BranchOffset(); } -+ inline int16_t imm12() const { return instr_.Imm12Value(); } -+ inline int32_t imm20J() const { return instr_.Imm20JValue(); } -+ inline int32_t imm5CSR() const { return instr_.Rs1Value(); } -+ inline int16_t csr_reg() const { return instr_.CsrValue(); } -+ -+ inline void set_rd(int64_t value, bool trace = true) { -+ set_register(rd_reg(), value); -+ if (trace) TraceRegWr(get_register(rd_reg()), DWORD); -+ } -+ inline void set_frd(float value, bool trace = true) { -+ set_fpu_register_float(rd_reg(), value); -+ if (trace) TraceRegWr(get_fpu_register_word(rd_reg()), FLOAT); -+ } -+ inline void set_drd(double value, bool trace = true) { -+ set_fpu_register_double(rd_reg(), value); -+ if (trace) TraceRegWr(get_fpu_register(rd_reg()), DOUBLE); -+ } -+ inline int16_t shamt() const { return (imm12() & 0x3F); } -+ inline int16_t shamt32() const { return (imm12() & 0x1F); } -+ inline int32_t s_imm12() const { return instr_.StoreOffset(); } -+ inline int32_t u_imm() const { return instr_.Imm20UValue() << 12; } -+ inline void require(bool check) { -+ if (!check) { -+ SignalException(kIllegalInstruction); -+ } -+ } -+ -+ template -+ inline T CanonicalizeFPUOp3(Func fn) { -+ DCHECK(std::is_floating_point::value); -+ T src1 = std::is_same::value ? frs1() : drs1(); -+ T src2 = std::is_same::value ? frs2() : drs2(); -+ T src3 = std::is_same::value ? frs3() : drs3(); -+ auto alu_out = fn(src1, src2, src3); -+ // if any input or result is NaN, the result is quiet_NaN -+ if (std::isnan(alu_out) || std::isnan(src1) || std::isnan(src2) || -+ std::isnan(src3)) { -+ // signaling_nan sets kInvalidOperation bit -+ if (isSnan(alu_out) || isSnan(src1) || isSnan(src2) || isSnan(src3)) -+ set_fflags(kInvalidOperation); -+ alu_out = std::numeric_limits::quiet_NaN(); -+ } -+ return alu_out; -+ } -+ -+ template -+ inline T CanonicalizeFPUOp2(Func fn) { -+ DCHECK(std::is_floating_point::value); -+ T src1 = std::is_same::value ? frs1() : drs1(); -+ T src2 = std::is_same::value ? frs2() : drs2(); -+ auto alu_out = fn(src1, src2); -+ // if any input or result is NaN, the result is quiet_NaN -+ if (std::isnan(alu_out) || std::isnan(src1) || std::isnan(src2)) { -+ // signaling_nan sets kInvalidOperation bit -+ if (isSnan(alu_out) || isSnan(src1) || isSnan(src2)) -+ set_fflags(kInvalidOperation); -+ alu_out = std::numeric_limits::quiet_NaN(); -+ } -+ return alu_out; -+ } -+ -+ template -+ inline T CanonicalizeFPUOp1(Func fn) { -+ DCHECK(std::is_floating_point::value); -+ T src1 = std::is_same::value ? frs1() : drs1(); -+ auto alu_out = fn(src1); -+ // if any input or result is NaN, the result is quiet_NaN -+ if (std::isnan(alu_out) || std::isnan(src1)) { -+ // signaling_nan sets kInvalidOperation bit -+ if (isSnan(alu_out) || isSnan(src1)) set_fflags(kInvalidOperation); -+ alu_out = std::numeric_limits::quiet_NaN(); -+ } -+ return alu_out; -+ } -+ -+ template -+ inline float CanonicalizeDoubleToFloatOperation(Func fn) { -+ float alu_out = fn(drs1()); -+ if (std::isnan(alu_out) || std::isnan(drs1())) -+ alu_out = std::numeric_limits::quiet_NaN(); -+ return alu_out; -+ } -+ -+ template -+ inline float CanonicalizeFloatToDoubleOperation(Func fn) { -+ double alu_out = fn(frs1()); -+ if (std::isnan(alu_out) || std::isnan(frs1())) -+ alu_out = std::numeric_limits::quiet_NaN(); -+ return alu_out; -+ } -+ -+ // RISCV decoding routine -+ void DecodeRVRType(); -+ void DecodeRVR4Type(); -+ void DecodeRVRFPType(); // Special routine for R/OP_FP type -+ void DecodeRVRAType(); // Special routine for R/AMO type -+ void DecodeRVIType(); -+ void DecodeRVSType(); -+ void DecodeRVBType(); -+ void DecodeRVUType(); -+ void DecodeRVJType(); -+ -+ // Used for breakpoints and traps. -+ void SoftwareInterrupt(); -+ -+ // Debug helpers -+ -+ // Simulator breakpoints. -+ struct Breakpoint { -+ Instruction* location; -+ bool enabled; -+ bool is_tbreak; -+ }; -+ std::vector breakpoints_; -+ void SetBreakpoint(Instruction* breakpoint, bool is_tbreak); -+ void ListBreakpoints(); -+ void CheckBreakpoints(); -+ -+ // Stop helper functions. -+ bool IsWatchpoint(uint64_t code); -+ void PrintWatchpoint(uint64_t code); -+ void HandleStop(uint64_t code); -+ bool IsStopInstruction(Instruction* instr); -+ bool IsEnabledStop(uint64_t code); -+ void EnableStop(uint64_t code); -+ void DisableStop(uint64_t code); -+ void IncreaseStopCounter(uint64_t code); -+ void PrintStopInfo(uint64_t code); -+ -+ // Executes one instruction. -+ void InstructionDecode(Instruction* instr); -+ -+ // ICache. -+ static void CheckICache(base::CustomMatcherHashMap* i_cache, -+ Instruction* instr); -+ static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, -+ size_t size); -+ static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, -+ void* page); -+ -+ enum Exception { -+ none, -+ kIntegerOverflow, -+ kIntegerUnderflow, -+ kDivideByZero, -+ kNumExceptions, -+ // RISCV illegual instruction exception -+ kIllegalInstruction, -+ }; -+ -+ // Exceptions. -+ void SignalException(Exception e); -+ -+ // Handle arguments and return value for runtime FP functions. -+ void GetFpArgs(double* x, double* y, int32_t* z); -+ void SetFpResult(const double& result); -+ -+ void CallInternal(Address entry); -+ -+ // Architecture state. -+ // Registers. -+ int64_t registers_[kNumSimuRegisters]; -+ // Coprocessor Registers. -+ int64_t FPUregisters_[kNumFPURegisters]; -+ // Floating-point control and status register. -+ uint32_t FCSR_; -+ -+ // Simulator support. -+ // Allocate 1MB for stack. -+ size_t stack_size_; -+ char* stack_; -+ bool pc_modified_; -+ int64_t icount_; -+ int break_count_; -+ EmbeddedVector trace_buf_; -+ -+ // Debugger input. -+ char* last_debugger_input_; -+ -+ v8::internal::Isolate* isolate_; -+ -+ // Stop is disabled if bit 31 is set. -+ static const uint32_t kStopDisabledBit = 1 << 31; -+ -+ // A stop is enabled, meaning the simulator will stop when meeting the -+ // instruction, if bit 31 of watched_stops_[code].count is unset. -+ // The value watched_stops_[code].count & ~(1 << 31) indicates how many times -+ // the breakpoint was hit or gone through. -+ struct StopCountAndDesc { -+ uint32_t count; -+ char* desc; -+ }; -+ StopCountAndDesc watched_stops_[kMaxStopCode + 1]; -+ -+ // Synchronization primitives. -+ enum class MonitorAccess { -+ Open, -+ RMW, -+ }; -+ -+ enum class TransactionSize { -+ None = 0, -+ Word = 4, -+ DoubleWord = 8, -+ }; -+ -+ // The least-significant bits of the address are ignored. The number of bits -+ // is implementation-defined, between 3 and minimum page size. -+ static const uintptr_t kExclusiveTaggedAddrMask = ~((1 << 3) - 1); -+ -+ class LocalMonitor { -+ public: -+ LocalMonitor(); -+ -+ // These functions manage the state machine for the local monitor, but do -+ // not actually perform loads and stores. NotifyStoreConditional only -+ // returns true if the store conditional is allowed; the global monitor will -+ // still have to be checked to see whether the memory should be updated. -+ void NotifyLoad(); -+ void NotifyLoadLinked(uintptr_t addr, TransactionSize size); -+ void NotifyStore(); -+ bool NotifyStoreConditional(uintptr_t addr, TransactionSize size); -+ -+ private: -+ void Clear(); -+ -+ MonitorAccess access_state_; -+ uintptr_t tagged_addr_; -+ TransactionSize size_; -+ }; -+ -+ class GlobalMonitor { -+ public: -+ class LinkedAddress { -+ public: -+ LinkedAddress(); -+ -+ private: -+ friend class GlobalMonitor; -+ // These functions manage the state machine for the global monitor, but do -+ // not actually perform loads and stores. -+ void Clear_Locked(); -+ void NotifyLoadLinked_Locked(uintptr_t addr); -+ void NotifyStore_Locked(); -+ bool NotifyStoreConditional_Locked(uintptr_t addr, -+ bool is_requesting_thread); -+ -+ MonitorAccess access_state_; -+ uintptr_t tagged_addr_; -+ LinkedAddress* next_; -+ LinkedAddress* prev_; -+ // A scd can fail due to background cache evictions. Rather than -+ // simulating this, we'll just occasionally introduce cases where an -+ // store conditional fails. This will happen once after every -+ // kMaxFailureCounter exclusive stores. -+ static const int kMaxFailureCounter = 5; -+ int failure_counter_; -+ }; -+ -+ // Exposed so it can be accessed by Simulator::{Read,Write}Ex*. -+ base::Mutex mutex; -+ -+ void NotifyLoadLinked_Locked(uintptr_t addr, LinkedAddress* linked_address); -+ void NotifyStore_Locked(LinkedAddress* linked_address); -+ bool NotifyStoreConditional_Locked(uintptr_t addr, -+ LinkedAddress* linked_address); -+ -+ // Called when the simulator is destroyed. -+ void RemoveLinkedAddress(LinkedAddress* linked_address); -+ -+ static GlobalMonitor* Get(); -+ -+ private: -+ // Private constructor. Call {GlobalMonitor::Get()} to get the singleton. -+ GlobalMonitor() = default; -+ friend class base::LeakyObject; -+ -+ bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const; -+ void PrependProcessor_Locked(LinkedAddress* linked_address); -+ -+ LinkedAddress* head_ = nullptr; -+ }; -+ -+ LocalMonitor local_monitor_; -+ GlobalMonitor::LinkedAddress global_monitor_thread_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // defined(USE_SIMULATOR) -+#endif // V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ ---- a/src/3rdparty/chromium/v8/src/execution/simulator-base.h -+++ b/src/3rdparty/chromium/v8/src/execution/simulator-base.h -@@ -89,9 +89,10 @@ - static typename std::enable_if::value, intptr_t>::type - ConvertArg(T arg) { - static_assert(sizeof(T) <= sizeof(intptr_t), "type bigger than ptrsize"); --#if V8_TARGET_ARCH_MIPS64 -- // The MIPS64 calling convention is to sign extend all values, even unsigned -- // ones. -+#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 -+ // The MIPS64 and RISCV64 calling convention is to sign extend all values, -+ // even unsigned ones. -+ // FIXME (RISCV): what about RISCV calling contention? - using signed_t = typename std::make_signed::type; - return static_cast(static_cast(arg)); - #else -@@ -125,6 +126,7 @@ - // - V8_TARGET_ARCH_PPC: svc (Supervisor Call) - // - V8_TARGET_ARCH_PPC64: svc (Supervisor Call) - // - V8_TARGET_ARCH_S390: svc (Supervisor Call) -+// - V8_TARGET_ARCH_RISCV64: ecall (Supervisor Call) - class Redirection { - public: - Redirection(Address external_function, ExternalReference::Type type); ---- a/src/3rdparty/chromium/v8/src/execution/simulator.h -+++ b/src/3rdparty/chromium/v8/src/execution/simulator.h -@@ -26,6 +26,10 @@ - #include "src/execution/mips64/simulator-mips64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/execution/s390/simulator-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/execution/riscv64/simulator-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/execution/riscv/simulator-riscv.h" - #else - #error Unsupported target architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/flags/flag-definitions.h -+++ b/src/3rdparty/chromium/v8/src/flags/flag-definitions.h -@@ -1182,6 +1182,7 @@ - DEFINE_STRING(sim_arm64_optional_features, "none", - "enable optional features on the simulator for testing: none or " - "all") -+DEFINE_BOOL(debug_riscv, false, "enable debug prints") - - // Controlling source positions for Torque/CSA code. - DEFINE_BOOL(enable_source_at_csa_bind, false, -@@ -1372,7 +1373,7 @@ - "Check icache flushes in ARM and MIPS simulator") - DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions") - #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) || \ -- defined(V8_TARGET_ARCH_PPC64) -+ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_RISCV64) - DEFINE_INT(sim_stack_alignment, 16, - "Stack alignment in bytes in simulator. This must be a power of two " - "and it must be at least 16. 16 is default.") ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/heap/base/asm/riscv64/push_registers_asm.cc -@@ -0,0 +1,47 @@ -+// Copyright 2020 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+// Push all callee-saved registers to get them on the stack for conservative -+// stack scanning. -+// -+// See asm/x64/push_registers_clang.cc for why the function is not generated -+// using clang. -+// -+// Do not depend on V8_TARGET_OS_* defines as some embedders may override the -+// GN toolchain (e.g. ChromeOS) and not provide them. -+asm( -+ ".global PushAllRegistersAndIterateStack \n" -+ ".type PushAllRegistersAndIterateStack, %function \n" -+ ".hidden PushAllRegistersAndIterateStack \n" -+ "PushAllRegistersAndIterateStack: \n" -+ // Push all callee-saved registers and save return address. -+ " addi sp, sp, -96 \n" -+ " sd ra, 88(sp) \n" -+ " sd s8, 80(sp) \n" -+ " sd sp, 72(sp) \n" -+ " sd gp, 64(sp) \n" -+ " sd s7, 56(sp) \n" -+ " sd s6, 48(sp) \n" -+ " sd s5, 40(sp) \n" -+ " sd s4, 32(sp) \n" -+ " sd s3, 24(sp) \n" -+ " sd s2, 16(sp) \n" -+ " sd s1, 8(sp) \n" -+ " sd s0, 0(sp) \n" -+ // Maintain frame pointer. -+ " mv s8, sp \n" -+ // Pass 1st parameter (a0) unchanged (Stack*). -+ // Pass 2nd parameter (a1) unchanged (StackVisitor*). -+ // Save 3rd parameter (a2; IterateStackCallback). -+ " mv a3, a2 \n" -+ " mv a2, sp \n" -+ // Call the callback. -+ " jalr a3 \n" -+ // Load return address. -+ " ld ra, 88(sp) \n" -+ // Restore frame pointer. -+ " ld s8, 80(sp) \n" -+ " addi sp, sp, 96 \n" -+ " jr ra \n"); -+ ---- a/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc -+++ b/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc -@@ -1348,7 +1348,8 @@ - - // static - bool InterpreterAssembler::TargetSupportsUnalignedAccess() { --#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ -+ V8_TARGET_ARCH_RISCV - return false; - #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390 || \ - V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC || \ ---- a/src/3rdparty/chromium/v8/src/libsampler/sampler.cc -+++ b/src/3rdparty/chromium/v8/src/libsampler/sampler.cc -@@ -442,6 +442,12 @@ - state->sp = reinterpret_cast(ucontext->uc_mcontext.gregs[15]); - state->fp = reinterpret_cast(ucontext->uc_mcontext.gregs[11]); - state->lr = reinterpret_cast(ucontext->uc_mcontext.gregs[14]); -+#elif V8_HOST_ARCH_RISCV64 || V8_HOST_ARCH_RISCV -+ // Spec CH.25 RISC-V Assembly Programmer’s Handbook -+ state->pc = reinterpret_cast(mcontext.__gregs[REG_PC]); -+ state->sp = reinterpret_cast(mcontext.__gregs[REG_SP]); -+ state->fp = reinterpret_cast(mcontext.__gregs[REG_S0]); -+ state->lr = reinterpret_cast(mcontext.__gregs[REG_RA]); - #endif // V8_HOST_ARCH_* - #elif V8_OS_IOS - ---- a/src/3rdparty/chromium/v8/src/logging/log.cc -+++ b/src/3rdparty/chromium/v8/src/logging/log.cc -@@ -594,6 +594,14 @@ - const char arch[] = "arm64"; - #elif V8_TARGET_ARCH_S390 - const char arch[] = "s390"; -+#elif V8_TARGET_ARCH_RISCV64 -+ // FIXME (RISCV) porting: need more specific arch strings based on cpu -+ // features -+ const char arch[] = "riscv64"; -+#elif V8_TARGET_ARCH_RISCV -+ // FIXME (RISCV) porting: need more specific arch strings based on cpu -+ // features -+ const char arch[] = "riscv"; - #else - const char arch[] = "unknown"; - #endif ---- a/src/3rdparty/chromium/v8/src/objects/backing-store.cc -+++ b/src/3rdparty/chromium/v8/src/objects/backing-store.cc -@@ -29,7 +29,8 @@ - constexpr bool kUseGuardRegions = false; - #endif - --#if V8_TARGET_ARCH_MIPS64 -+#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 -+// FIXME(RISCV): Check this value - // MIPS64 has a user space of 2^40 bytes on most processors, - // address space limits needs to be smaller. - constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB -@@ -39,6 +40,10 @@ - constexpr size_t kAddressSpaceLimit = 0xC0000000; // 3 GiB - #endif - -+#if V8_TARGET_ARCH_RISCV -+#erro RISCV(32) architecture not supported -+#endif -+ - constexpr uint64_t kOneGiB = 1024 * 1024 * 1024; - constexpr uint64_t kNegativeGuardSize = 2 * kOneGiB; - ---- a/src/3rdparty/chromium/v8/src/objects/code.cc -+++ b/src/3rdparty/chromium/v8/src/objects/code.cc -@@ -234,7 +234,7 @@ - RelocInfo::ModeMask(RelocInfo::WASM_STUB_CALL))); - - #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ -- defined(V8_TARGET_ARCH_MIPS64) -+ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_RISCV64) - return RelocIterator(*this, kModeMask).done(); - #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ - defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ ---- a/src/3rdparty/chromium/v8/src/objects/code.h -+++ b/src/3rdparty/chromium/v8/src/objects/code.h -@@ -461,6 +461,10 @@ - : (COMPRESS_POINTERS_BOOL ? 16 : 28); - #elif V8_TARGET_ARCH_S390X - static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; -+#elif V8_TARGET_ARCH_RISCV64 -+ static constexpr int kHeaderPaddingSize = 28; -+#elif V8_TARGET_ARCH_RISCV -+#error riscv32 unsupported yet - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc -+++ b/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc -@@ -125,6 +125,13 @@ - state->sp = reinterpret_cast(simulator->get_register(Simulator::sp)); - state->fp = reinterpret_cast(simulator->get_register(Simulator::fp)); - state->lr = reinterpret_cast(simulator->get_register(Simulator::ra)); -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ if (!simulator->has_bad_pc()) { -+ state->pc = reinterpret_cast(simulator->get_pc()); -+ } -+ state->sp = reinterpret_cast(simulator->get_register(Simulator::sp)); -+ state->fp = reinterpret_cast(simulator->get_register(Simulator::fp)); -+ state->lr = reinterpret_cast(simulator->get_register(Simulator::ra)); - #endif - if (state->sp == 0 || state->fp == 0) { - // It possible that the simulator is interrupted while it is updating ---- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h -@@ -23,6 +23,10 @@ - #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/regexp/s390/regexp-macro-assembler-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/regexp/riscv64/regexp-macro-assembler-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/regexp/riscv/regexp-macro-assembler-riscv.h" - #else - #error Unsupported target architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h -@@ -44,6 +44,7 @@ - kARMImplementation, - kARM64Implementation, - kMIPSImplementation, -+ kRISCVImplementation, - kS390Implementation, - kPPCImplementation, - kX64Implementation, ---- a/src/3rdparty/chromium/v8/src/regexp/regexp.cc -+++ b/src/3rdparty/chromium/v8/src/regexp/regexp.cc -@@ -815,6 +815,9 @@ - #elif V8_TARGET_ARCH_MIPS64 - macro_assembler.reset(new RegExpMacroAssemblerMIPS(isolate, zone, mode, - output_register_count)); -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+ macro_assembler.reset(new RegExpMacroAssemblerRISCV(isolate, zone, mode, -+ output_register_count)); - #else - #error "Unsupported architecture" - #endif ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/regexp/riscv64/regexp-macro-assembler-riscv64.cc -@@ -0,0 +1,1260 @@ -+// Copyright 2012 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#if V8_TARGET_ARCH_RISCV64 -+ -+#include "src/regexp/riscv64/regexp-macro-assembler-riscv64.h" -+ -+#include "src/codegen/assembler-inl.h" -+#include "src/codegen/macro-assembler.h" -+#include "src/logging/log.h" -+#include "src/objects/objects-inl.h" -+#include "src/regexp/regexp-macro-assembler.h" -+#include "src/regexp/regexp-stack.h" -+#include "src/snapshot/embedded/embedded-data.h" -+#include "src/strings/unicode.h" -+ -+namespace v8 { -+namespace internal { -+ -+/* clang-format off -+ * -+ * This assembler uses the following register assignment convention -+ * - t4 : Temporarily stores the index of capture start after a matching pass -+ * for a global regexp. -+ * - a5 : Pointer to current Code object including heap object tag. -+ * - a6 : Current position in input, as negative offset from end of string. -+ * Please notice that this is the byte offset, not the character offset! -+ * - a7 : Currently loaded character. Must be loaded using -+ * LoadCurrentCharacter before using any of the dispatch methods. -+ * - t0 : Points to tip of backtrack stack -+ * - t1 : Unused. -+ * - t2 : End of input (points to byte after last character in input). -+ * - fp : Frame pointer. Used to access arguments, local variables and -+ * RegExp registers. -+ * - sp : Points to tip of C stack. -+ * -+ * The remaining registers are free for computations. -+ * Each call to a public method should retain this convention. -+ * -+ * The stack will have the following structure: -+ * FIXME(RISCV): Verify that this stack description is correct -+ * -+ * - fp[80] Isolate* isolate (address of the current isolate) kIsolate -+ * kStackFrameHeader -+ * --- sp when called --- -+ * - fp[72] ra Return from RegExp code (ra). kReturnAddress -+ * - fp[64] s9, old-fp Old fp, callee saved(s9). -+ * - fp[0..63] fp..s7 Callee-saved registers fp..s7. -+ * --- frame pointer ---- -+ * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall -+ * - fp[-16] stack_base (Top of backtracking stack). kStackHighEnd -+ * - fp[-24] capture array size (may fit multiple sets of matches) kNumOutputRegisters -+ * - fp[-32] int* capture_array (int[num_saved_registers_], for output). kRegisterOutput -+ * - fp[-40] end of input (address of end of string). kInputEnd -+ * - fp[-48] start of input (address of first character in string). kInputStart -+ * - fp[-56] start index (character index of start). kStartIndex -+ * - fp[-64] void* input_string (location of a handle containing the string). kInputString -+ * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures -+ * - fp[-80] Offset of location before start of input (effectively character kStringStartMinusOne -+ * position -1). Used to initialize capture registers to a -+ * non-position. -+ * --------- The following output registers are 32-bit values. --------- -+ * - fp[-88] register 0 (Only positions must be stored in the first kRegisterZero -+ * - register 1 num_saved_registers_ registers) -+ * - ... -+ * - register num_registers-1 -+ * --- sp --- -+ * -+ * The first num_saved_registers_ registers are initialized to point to -+ * "character -1" in the string (i.e., char_size() bytes before the first -+ * character of the string). The remaining registers start out as garbage. -+ * -+ * The data up to the return address must be placed there by the calling -+ * code and the remaining arguments are passed in registers, e.g. by calling the -+ * code entry as cast to a function with the signature: -+ * int (*match)(String input_string, -+ * int start_index, -+ * Address start, -+ * Address end, -+ * int* capture_output_array, -+ * int num_capture_registers, -+ * byte* stack_area_base, -+ * bool direct_call = false, -+ * Isolate* isolate); -+ * The call is performed by NativeRegExpMacroAssembler::Execute() -+ * (in regexp-macro-assembler.cc) via the GeneratedCode wrapper. -+ * -+ * clang-format on -+ */ -+ -+#define __ ACCESS_MASM(masm_) -+ -+const int RegExpMacroAssemblerRISCV::kRegExpCodeSize; -+ -+RegExpMacroAssemblerRISCV::RegExpMacroAssemblerRISCV(Isolate* isolate, -+ Zone* zone, Mode mode, -+ int registers_to_save) -+ : NativeRegExpMacroAssembler(isolate, zone), -+ masm_(new MacroAssembler(isolate, CodeObjectRequired::kYes, -+ NewAssemblerBuffer(kRegExpCodeSize))), -+ mode_(mode), -+ num_registers_(registers_to_save), -+ num_saved_registers_(registers_to_save), -+ entry_label_(), -+ start_label_(), -+ success_label_(), -+ backtrack_label_(), -+ exit_label_(), -+ internal_failure_label_() { -+ masm_->set_root_array_available(false); -+ -+ DCHECK_EQ(0, registers_to_save % 2); -+ __ jmp(&entry_label_); // We'll write the entry code later. -+ // If the code gets too big or corrupted, an internal exception will be -+ // raised, and we will exit right away. -+ __ bind(&internal_failure_label_); -+ __ li(a0, Operand(FAILURE)); -+ __ Ret(); -+ __ bind(&start_label_); // And then continue from here. -+} -+ -+RegExpMacroAssemblerRISCV::~RegExpMacroAssemblerRISCV() { -+ delete masm_; -+ // Unuse labels in case we throw away the assembler without calling GetCode. -+ entry_label_.Unuse(); -+ start_label_.Unuse(); -+ success_label_.Unuse(); -+ backtrack_label_.Unuse(); -+ exit_label_.Unuse(); -+ check_preempt_label_.Unuse(); -+ stack_overflow_label_.Unuse(); -+ internal_failure_label_.Unuse(); -+} -+ -+int RegExpMacroAssemblerRISCV::stack_limit_slack() { -+ return RegExpStack::kStackLimitSlack; -+} -+ -+void RegExpMacroAssemblerRISCV::AdvanceCurrentPosition(int by) { -+ if (by != 0) { -+ __ Add64(current_input_offset(), current_input_offset(), -+ Operand(by * char_size())); -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::AdvanceRegister(int reg, int by) { -+ DCHECK_LE(0, reg); -+ DCHECK_GT(num_registers_, reg); -+ if (by != 0) { -+ __ Ld(a0, register_location(reg)); -+ __ Add64(a0, a0, Operand(by)); -+ __ Sd(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::Backtrack() { -+ CheckPreemption(); -+ if (has_backtrack_limit()) { -+ Label next; -+ __ Ld(a0, MemOperand(frame_pointer(), kBacktrackCount)); -+ __ Add64(a0, a0, Operand(1)); -+ __ Sd(a0, MemOperand(frame_pointer(), kBacktrackCount)); -+ __ Branch(&next, ne, a0, Operand(backtrack_limit())); -+ -+ // Exceeded limits are treated as a failed match. -+ Fail(); -+ -+ __ bind(&next); -+ } -+ // Pop Code offset from backtrack stack, add Code and jump to location. -+ Pop(a0); -+ __ Add64(a0, a0, code_pointer()); -+ __ Jump(a0); -+} -+ -+void RegExpMacroAssemblerRISCV::Bind(Label* label) { __ bind(label); } -+ -+void RegExpMacroAssemblerRISCV::CheckCharacter(uint32_t c, Label* on_equal) { -+ BranchOrBacktrack(on_equal, eq, current_character(), Operand(c)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckCharacterGT(uc16 limit, -+ Label* on_greater) { -+ BranchOrBacktrack(on_greater, gt, current_character(), Operand(limit)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckAtStart(int cp_offset, -+ Label* on_at_start) { -+ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add64(a0, current_input_offset(), -+ Operand(-char_size() + cp_offset * char_size())); -+ BranchOrBacktrack(on_at_start, eq, a0, Operand(a1)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotAtStart(int cp_offset, -+ Label* on_not_at_start) { -+ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add64(a0, current_input_offset(), -+ Operand(-char_size() + cp_offset * char_size())); -+ BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckCharacterLT(uc16 limit, Label* on_less) { -+ BranchOrBacktrack(on_less, lt, current_character(), Operand(limit)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckGreedyLoop(Label* on_equal) { -+ Label backtrack_non_equal; -+ __ Lw(a0, MemOperand(backtrack_stackpointer(), 0)); -+ __ Branch(&backtrack_non_equal, ne, current_input_offset(), Operand(a0)); -+ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), -+ Operand(kIntSize)); -+ __ bind(&backtrack_non_equal); -+ BranchOrBacktrack(on_equal, eq, current_input_offset(), Operand(a0)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotBackReferenceIgnoreCase( -+ int start_reg, bool read_backward, bool unicode, Label* on_no_match) { -+ Label fallthrough; -+ __ Ld(a0, register_location(start_reg)); // Index of start of capture. -+ __ Ld(a1, register_location(start_reg + 1)); // Index of end of capture. -+ __ Sub64(a1, a1, a0); // Length of capture. -+ -+ // At this point, the capture registers are either both set or both cleared. -+ // If the capture length is zero, then the capture is either empty or cleared. -+ // Fall through in both cases. -+ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); -+ -+ if (read_backward) { -+ __ Ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add64(t1, t1, a1); -+ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); -+ } else { -+ __ Add64(t1, a1, current_input_offset()); -+ // Check that there are enough characters left in the input. -+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); -+ } -+ -+ if (mode_ == LATIN1) { -+ Label success; -+ Label fail; -+ Label loop_check; -+ -+ // a0 - offset of start of capture. -+ // a1 - length of capture. -+ __ Add64(a0, a0, Operand(end_of_input_address())); -+ __ Add64(a2, end_of_input_address(), Operand(current_input_offset())); -+ if (read_backward) { -+ __ Sub64(a2, a2, Operand(a1)); -+ } -+ __ Add64(a1, a0, Operand(a1)); -+ -+ // a0 - Address of start of capture. -+ // a1 - Address of end of capture. -+ // a2 - Address of current input position. -+ -+ Label loop; -+ __ bind(&loop); -+ __ Lbu(a3, MemOperand(a0, 0)); -+ __ addi(a0, a0, char_size()); -+ __ Lbu(a4, MemOperand(a2, 0)); -+ __ addi(a2, a2, char_size()); -+ -+ __ Branch(&loop_check, eq, a4, Operand(a3)); -+ -+ // Mismatch, try case-insensitive match (converting letters to lower-case). -+ __ Or(a3, a3, Operand(0x20)); // Convert capture character to lower-case. -+ __ Or(a4, a4, Operand(0x20)); // Also convert input character. -+ __ Branch(&fail, ne, a4, Operand(a3)); -+ __ Sub64(a3, a3, Operand('a')); -+ __ Branch(&loop_check, Uless_equal, a3, Operand('z' - 'a')); -+ // Latin-1: Check for values in range [224,254] but not 247. -+ __ Sub64(a3, a3, Operand(224 - 'a')); -+ // Weren't Latin-1 letters. -+ __ Branch(&fail, Ugreater, a3, Operand(254 - 224)); -+ // Check for 247. -+ __ Branch(&fail, eq, a3, Operand(247 - 224)); -+ -+ __ bind(&loop_check); -+ __ Branch(&loop, lt, a0, Operand(a1)); -+ __ jmp(&success); -+ -+ __ bind(&fail); -+ GoTo(on_no_match); -+ -+ __ bind(&success); -+ // Compute new value of character position after the matched part. -+ __ Sub64(current_input_offset(), a2, end_of_input_address()); -+ if (read_backward) { -+ __ Ld(t1, register_location(start_reg)); // Index of start of capture. -+ __ Ld(a2, register_location(start_reg + 1)); // Index of end of capture. -+ __ Add64(current_input_offset(), current_input_offset(), Operand(t1)); -+ __ Sub64(current_input_offset(), current_input_offset(), Operand(a2)); -+ } -+ } else { -+ DCHECK(mode_ == UC16); -+ // Put regexp engine registers on stack. -+ RegList regexp_registers_to_retain = current_input_offset().bit() | -+ current_character().bit() | -+ backtrack_stackpointer().bit(); -+ __ MultiPush(regexp_registers_to_retain); -+ -+ int argument_count = 4; -+ __ PrepareCallCFunction(argument_count, a2); -+ -+ // a0 - offset of start of capture. -+ // a1 - length of capture. -+ -+ // Put arguments into arguments registers. -+ // Parameters are -+ // a0: Address byte_offset1 - Address captured substring's start. -+ // a1: Address byte_offset2 - Address of current character position. -+ // a2: size_t byte_length - length of capture in bytes(!). -+ // a3: Isolate* isolate. -+ -+ // Address of start of capture. -+ __ Add64(a0, a0, Operand(end_of_input_address())); -+ // Length of capture. -+ __ mv(a2, a1); -+ // Save length in callee-save register for use on return. -+ __ mv(s3, a1); -+ // Address of current input position. -+ __ Add64(a1, current_input_offset(), Operand(end_of_input_address())); -+ if (read_backward) { -+ __ Sub64(a1, a1, Operand(s3)); -+ } -+ // Isolate. -+ __ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate()))); -+ -+ { -+ AllowExternalCallThatCantCauseGC scope(masm_); -+ ExternalReference function = -+ unicode ? ExternalReference::re_case_insensitive_compare_unicode( -+ isolate()) -+ : ExternalReference::re_case_insensitive_compare_non_unicode( -+ isolate()); -+ __ CallCFunction(function, argument_count); -+ } -+ -+ // Restore regexp engine registers. -+ __ MultiPop(regexp_registers_to_retain); -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ -+ // Check if function returned non-zero for success or zero for failure. -+ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); -+ // On success, increment position by length of capture. -+ if (read_backward) { -+ __ Sub64(current_input_offset(), current_input_offset(), Operand(s3)); -+ } else { -+ __ Add64(current_input_offset(), current_input_offset(), Operand(s3)); -+ } -+ } -+ -+ __ bind(&fallthrough); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotBackReference(int start_reg, -+ bool read_backward, -+ Label* on_no_match) { -+ Label fallthrough; -+ -+ // Find length of back-referenced capture. -+ __ Ld(a0, register_location(start_reg)); -+ __ Ld(a1, register_location(start_reg + 1)); -+ __ Sub64(a1, a1, a0); // Length to check. -+ -+ // At this point, the capture registers are either both set or both cleared. -+ // If the capture length is zero, then the capture is either empty or cleared. -+ // Fall through in both cases. -+ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); -+ -+ if (read_backward) { -+ __ Ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add64(t1, t1, a1); -+ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); -+ } else { -+ __ Add64(t1, a1, current_input_offset()); -+ // Check that there are enough characters left in the input. -+ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); -+ } -+ -+ // Compute pointers to match string and capture string. -+ __ Add64(a0, a0, Operand(end_of_input_address())); -+ __ Add64(a2, end_of_input_address(), Operand(current_input_offset())); -+ if (read_backward) { -+ __ Sub64(a2, a2, Operand(a1)); -+ } -+ __ Add64(a1, a1, Operand(a0)); -+ -+ Label loop; -+ __ bind(&loop); -+ if (mode_ == LATIN1) { -+ __ Lbu(a3, MemOperand(a0, 0)); -+ __ addi(a0, a0, char_size()); -+ __ Lbu(a4, MemOperand(a2, 0)); -+ __ addi(a2, a2, char_size()); -+ } else { -+ DCHECK(mode_ == UC16); -+ __ Lhu(a3, MemOperand(a0, 0)); -+ __ addi(a0, a0, char_size()); -+ __ Lhu(a4, MemOperand(a2, 0)); -+ __ addi(a2, a2, char_size()); -+ } -+ BranchOrBacktrack(on_no_match, ne, a3, Operand(a4)); -+ __ Branch(&loop, lt, a0, Operand(a1)); -+ -+ // Move current character position to position after match. -+ __ Sub64(current_input_offset(), a2, end_of_input_address()); -+ if (read_backward) { -+ __ Ld(t1, register_location(start_reg)); // Index of start of capture. -+ __ Ld(a2, register_location(start_reg + 1)); // Index of end of capture. -+ __ Add64(current_input_offset(), current_input_offset(), Operand(t1)); -+ __ Sub64(current_input_offset(), current_input_offset(), Operand(a2)); -+ } -+ __ bind(&fallthrough); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotCharacter(uint32_t c, -+ Label* on_not_equal) { -+ BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckCharacterAfterAnd(uint32_t c, -+ uint32_t mask, -+ Label* on_equal) { -+ __ And(a0, current_character(), Operand(mask)); -+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); -+ BranchOrBacktrack(on_equal, eq, a0, rhs); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotCharacterAfterAnd(uint32_t c, -+ uint32_t mask, -+ Label* on_not_equal) { -+ __ And(a0, current_character(), Operand(mask)); -+ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); -+ BranchOrBacktrack(on_not_equal, ne, a0, rhs); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckNotCharacterAfterMinusAnd( -+ uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { -+ DCHECK_GT(String::kMaxUtf16CodeUnit, minus); -+ __ Sub64(a0, current_character(), Operand(minus)); -+ __ And(a0, a0, Operand(mask)); -+ BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckCharacterInRange(uc16 from, uc16 to, -+ Label* on_in_range) { -+ __ Sub64(a0, current_character(), Operand(from)); -+ // Unsigned lower-or-same condition. -+ BranchOrBacktrack(on_in_range, Uless_equal, a0, Operand(to - from)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckCharacterNotInRange( -+ uc16 from, uc16 to, Label* on_not_in_range) { -+ __ Sub64(a0, current_character(), Operand(from)); -+ // Unsigned higher condition. -+ BranchOrBacktrack(on_not_in_range, Ugreater, a0, Operand(to - from)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckBitInTable(Handle table, -+ Label* on_bit_set) { -+ __ li(a0, Operand(table)); -+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { -+ __ And(a1, current_character(), Operand(kTableSize - 1)); -+ __ Add64(a0, a0, a1); -+ } else { -+ __ Add64(a0, a0, current_character()); -+ } -+ -+ __ Lbu(a0, FieldMemOperand(a0, ByteArray::kHeaderSize)); -+ BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg)); -+} -+ -+bool RegExpMacroAssemblerRISCV::CheckSpecialCharacterClass(uc16 type, -+ Label* on_no_match) { -+ // Range checks (c in min..max) are generally implemented by an unsigned -+ // (c - min) <= (max - min) check. -+ switch (type) { -+ case 's': -+ // Match space-characters. -+ if (mode_ == LATIN1) { -+ // One byte space characters are '\t'..'\r', ' ' and \u00a0. -+ Label success; -+ __ Branch(&success, eq, current_character(), Operand(' ')); -+ // Check range 0x09..0x0D. -+ __ Sub64(a0, current_character(), Operand('\t')); -+ __ Branch(&success, Uless_equal, a0, Operand('\r' - '\t')); -+ // \u00a0 (NBSP). -+ BranchOrBacktrack(on_no_match, ne, a0, Operand(0x00A0 - '\t')); -+ __ bind(&success); -+ return true; -+ } -+ return false; -+ case 'S': -+ // The emitted code for generic character classes is good enough. -+ return false; -+ case 'd': -+ // Match Latin1 digits ('0'..'9'). -+ __ Sub64(a0, current_character(), Operand('0')); -+ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand('9' - '0')); -+ return true; -+ case 'D': -+ // Match non Latin1-digits. -+ __ Sub64(a0, current_character(), Operand('0')); -+ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand('9' - '0')); -+ return true; -+ case '.': { -+ // Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). -+ __ Xor(a0, current_character(), Operand(0x01)); -+ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. -+ __ Sub64(a0, a0, Operand(0x0B)); -+ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand(0x0C - 0x0B)); -+ if (mode_ == UC16) { -+ // Compare original value to 0x2028 and 0x2029, using the already -+ // computed (current_char ^ 0x01 - 0x0B). I.e., check for -+ // 0x201D (0x2028 - 0x0B) or 0x201E. -+ __ Sub64(a0, a0, Operand(0x2028 - 0x0B)); -+ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand(1)); -+ } -+ return true; -+ } -+ case 'n': { -+ // Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). -+ __ Xor(a0, current_character(), Operand(0x01)); -+ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. -+ __ Sub64(a0, a0, Operand(0x0B)); -+ if (mode_ == LATIN1) { -+ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand(0x0C - 0x0B)); -+ } else { -+ Label done; -+ BranchOrBacktrack(&done, Uless_equal, a0, Operand(0x0C - 0x0B)); -+ // Compare original value to 0x2028 and 0x2029, using the already -+ // computed (current_char ^ 0x01 - 0x0B). I.e., check for -+ // 0x201D (0x2028 - 0x0B) or 0x201E. -+ __ Sub64(a0, a0, Operand(0x2028 - 0x0B)); -+ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand(1)); -+ __ bind(&done); -+ } -+ return true; -+ } -+ case 'w': { -+ if (mode_ != LATIN1) { -+ // Table is 256 entries, so all Latin1 characters can be tested. -+ BranchOrBacktrack(on_no_match, Ugreater, current_character(), -+ Operand('z')); -+ } -+ ExternalReference map = -+ ExternalReference::re_word_character_map(isolate()); -+ __ li(a0, Operand(map)); -+ __ Add64(a0, a0, current_character()); -+ __ Lbu(a0, MemOperand(a0, 0)); -+ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); -+ return true; -+ } -+ case 'W': { -+ Label done; -+ if (mode_ != LATIN1) { -+ // Table is 256 entries, so all Latin1 characters can be tested. -+ __ Branch(&done, Ugreater, current_character(), Operand('z')); -+ } -+ ExternalReference map = -+ ExternalReference::re_word_character_map(isolate()); -+ __ li(a0, Operand(map)); -+ __ Add64(a0, a0, current_character()); -+ __ Lbu(a0, MemOperand(a0, 0)); -+ BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); -+ if (mode_ != LATIN1) { -+ __ bind(&done); -+ } -+ return true; -+ } -+ case '*': -+ // Match any character. -+ return true; -+ // No custom implementation (yet): s(UC16), S(UC16). -+ default: -+ return false; -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::Fail() { -+ __ li(a0, Operand(FAILURE)); -+ __ jmp(&exit_label_); -+} -+ -+Handle RegExpMacroAssemblerRISCV::GetCode(Handle source) { -+ Label return_a0; -+ if (masm_->has_exception()) { -+ // If the code gets corrupted due to long regular expressions and lack of -+ // space on trampolines, an internal exception flag is set. If this case -+ // is detected, we will jump into exit sequence right away. -+ __ bind_to(&entry_label_, internal_failure_label_.pos()); -+ } else { -+ // Finalize code - write the entry point code now we know how many -+ // registers we need. -+ -+ // Entry code: -+ __ bind(&entry_label_); -+ -+ // Tell the system that we have a stack frame. Because the type is MANUAL, -+ // no is generated. -+ FrameScope scope(masm_, StackFrame::MANUAL); -+ -+ // Actually emit code to start a new stack frame. -+ // Push arguments -+ // Save callee-save registers. -+ // Start new stack frame. -+ // Store link register in existing stack-cell. -+ // Order here should correspond to order of offset constants in header file. -+ // TODO(plind): we save fp..s11, but ONLY use s3 here - use the regs -+ // or dont save. -+ // -+ // FIXME (RISCV): how about saving only s*registers that are actually used? -+ RegList registers_to_retain = -+ fp.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | -+ s6.bit() | s7.bit() | s8.bit() /*| s9.bit() | s10.bit() | s11.bit()*/; -+ DCHECK(NumRegs(registers_to_retain) == kNumCalleeRegsToRetain); -+ -+ // The remaining arguments are passed in registers, e.g.by calling the code -+ // entry as cast to a function with the signature: -+ // -+ // *int(*match)(String input_string, // a0 -+ // int start_index, // a1 -+ // Address start, // a2 -+ // Address end, // a3 -+ // int*capture_output_array, // a4 -+ // int num_capture_registers, // a5 -+ // byte* stack_area_base, // a6 -+ // bool direct_call = false, // a7 -+ // Isolate * isolate); // on the stack -+ RegList argument_registers = a0.bit() | a1.bit() | a2.bit() | a3.bit() | -+ a4.bit() | a5.bit() | a6.bit() | a7.bit(); -+ -+ // According to MultiPush implementation, registers will be pushed in the -+ // order of ra, fp, then s8, ..., s1, and finally a7,...a0 -+ __ MultiPush(ra.bit() | registers_to_retain | argument_registers); -+ -+ // Set frame pointer in space for it if this is not a direct call -+ // from generated code. -+ __ Add64(frame_pointer(), sp, -+ Operand(NumRegs(argument_registers) * kPointerSize)); -+ -+ STATIC_ASSERT(kSuccessfulCaptures == kInputString - kSystemPointerSize); -+ __ mv(a0, zero_reg); -+ __ push(a0); // Make room for success counter and initialize it to 0. -+ STATIC_ASSERT(kStringStartMinusOne == -+ kSuccessfulCaptures - kSystemPointerSize); -+ __ push(a0); // Make room for "string start - 1" constant. -+ STATIC_ASSERT(kBacktrackCount == kStringStartMinusOne - kSystemPointerSize); -+ __ push(a0); // The backtrack counter -+ -+ // Check if we have space on the stack for registers. -+ Label stack_limit_hit; -+ Label stack_ok; -+ -+ ExternalReference stack_limit = -+ ExternalReference::address_of_jslimit(masm_->isolate()); -+ __ li(a0, Operand(stack_limit)); -+ __ Ld(a0, MemOperand(a0)); -+ __ Sub64(a0, sp, a0); -+ // Handle it if the stack pointer is already below the stack limit. -+ __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg)); -+ // Check if there is room for the variable number of registers above -+ // the stack limit. -+ __ Branch(&stack_ok, Ugreater_equal, a0, -+ Operand(num_registers_ * kPointerSize)); -+ // Exit with OutOfMemory exception. There is not enough space on the stack -+ // for our working registers. -+ __ li(a0, Operand(EXCEPTION)); -+ __ jmp(&return_a0); -+ -+ __ bind(&stack_limit_hit); -+ CallCheckStackGuardState(a0); -+ // If returned value is non-zero, we exit with the returned value as result. -+ __ Branch(&return_a0, ne, a0, Operand(zero_reg)); -+ -+ __ bind(&stack_ok); -+ // Allocate space on stack for registers. -+ __ Sub64(sp, sp, Operand(num_registers_ * kPointerSize)); -+ // Load string end. -+ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ // Load input start. -+ __ Ld(a0, MemOperand(frame_pointer(), kInputStart)); -+ // Find negative length (offset of start relative to end). -+ __ Sub64(current_input_offset(), a0, end_of_input_address()); -+ // Set a0 to address of char before start of the input string -+ // (effectively string position -1). -+ __ Ld(a1, MemOperand(frame_pointer(), kStartIndex)); -+ __ Sub64(a0, current_input_offset(), Operand(char_size())); -+ __ slli(t1, a1, (mode_ == UC16) ? 1 : 0); -+ __ Sub64(a0, a0, t1); -+ // Store this value in a local variable, for use when clearing -+ // position registers. -+ __ Sd(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ -+ // Initialize code pointer register -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ -+ Label load_char_start_regexp, start_regexp; -+ // Load newline if index is at start, previous character otherwise. -+ __ Branch(&load_char_start_regexp, ne, a1, Operand(zero_reg)); -+ __ li(current_character(), Operand('\n')); -+ __ jmp(&start_regexp); -+ -+ // Global regexp restarts matching here. -+ __ bind(&load_char_start_regexp); -+ // Load previous char as initial value of current character register. -+ LoadCurrentCharacterUnchecked(-1, 1); -+ __ bind(&start_regexp); -+ -+ // Initialize on-stack registers. -+ if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. -+ // Fill saved registers with initial value = start offset - 1. -+ if (num_saved_registers_ > 8) { -+ // Address of register 0. -+ __ Add64(a1, frame_pointer(), Operand(kRegisterZero)); -+ __ li(a2, Operand(num_saved_registers_)); -+ Label init_loop; -+ __ bind(&init_loop); -+ __ Sd(a0, MemOperand(a1)); -+ __ Add64(a1, a1, Operand(-kPointerSize)); -+ __ Sub64(a2, a2, Operand(1)); -+ __ Branch(&init_loop, ne, a2, Operand(zero_reg)); -+ } else { -+ for (int i = 0; i < num_saved_registers_; i++) { -+ __ Sd(a0, register_location(i)); -+ } -+ } -+ } -+ -+ // Initialize backtrack stack pointer. -+ __ Ld(backtrack_stackpointer(), MemOperand(frame_pointer(), kStackHighEnd)); -+ -+ __ jmp(&start_label_); -+ -+ // Exit code: -+ if (success_label_.is_linked()) { -+ // Save captures when successful. -+ __ bind(&success_label_); -+ if (num_saved_registers_ > 0) { -+ // Copy captures to output. -+ __ Ld(a1, MemOperand(frame_pointer(), kInputStart)); -+ __ Ld(a0, MemOperand(frame_pointer(), kRegisterOutput)); -+ __ Ld(a2, MemOperand(frame_pointer(), kStartIndex)); -+ __ Sub64(a1, end_of_input_address(), a1); -+ // a1 is length of input in bytes. -+ if (mode_ == UC16) { -+ __ srli(a1, a1, 1); -+ } -+ // a1 is length of input in characters. -+ __ Add64(a1, a1, Operand(a2)); -+ // a1 is length of string in characters. -+ -+ DCHECK_EQ(0, num_saved_registers_ % 2); -+ // Always an even number of capture registers. This allows us to -+ // unroll the loop once to add an operation between a load of a register -+ // and the following use of that register. -+ for (int i = 0; i < num_saved_registers_; i += 2) { -+ __ Ld(a2, register_location(i)); -+ __ Ld(a3, register_location(i + 1)); -+ if (i == 0 && global_with_zero_length_check()) { -+ // Keep capture start in a4 for the zero-length check later. -+ __ mv(t4, a2); -+ } -+ if (mode_ == UC16) { -+ __ srai(a2, a2, 1); -+ __ Add64(a2, a2, a1); -+ __ srai(a3, a3, 1); -+ __ Add64(a3, a3, a1); -+ } else { -+ __ Add64(a2, a1, Operand(a2)); -+ __ Add64(a3, a1, Operand(a3)); -+ } -+ // V8 expects the output to be an int32_t array. -+ __ Sw(a2, MemOperand(a0)); -+ __ Add64(a0, a0, kIntSize); -+ __ Sw(a3, MemOperand(a0)); -+ __ Add64(a0, a0, kIntSize); -+ } -+ } -+ -+ if (global()) { -+ // Restart matching if the regular expression is flagged as global. -+ __ Ld(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ __ Ld(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); -+ __ Ld(a2, MemOperand(frame_pointer(), kRegisterOutput)); -+ // Increment success counter. -+ __ Add64(a0, a0, 1); -+ __ Sd(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ // Capture results have been stored, so the number of remaining global -+ // output registers is reduced by the number of stored captures. -+ __ Sub64(a1, a1, num_saved_registers_); -+ // Check whether we have enough room for another set of capture results. -+ __ Branch(&return_a0, lt, a1, Operand(num_saved_registers_)); -+ -+ __ Sd(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); -+ // Advance the location for output. -+ __ Add64(a2, a2, num_saved_registers_ * kIntSize); -+ __ Sd(a2, MemOperand(frame_pointer(), kRegisterOutput)); -+ -+ // Prepare a0 to initialize registers with its value in the next run. -+ __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ -+ if (global_with_zero_length_check()) { -+ // Special case for zero-length matches. -+ // t4: capture start index -+ // Not a zero-length match, restart. -+ __ Branch(&load_char_start_regexp, ne, current_input_offset(), -+ Operand(t4)); -+ // Offset from the end is zero if we already reached the end. -+ __ Branch(&exit_label_, eq, current_input_offset(), -+ Operand(zero_reg)); -+ // Advance current position after a zero-length match. -+ Label advance; -+ __ bind(&advance); -+ __ Add64(current_input_offset(), current_input_offset(), -+ Operand((mode_ == UC16) ? 2 : 1)); -+ if (global_unicode()) CheckNotInSurrogatePair(0, &advance); -+ } -+ -+ __ Branch(&load_char_start_regexp); -+ } else { -+ __ li(a0, Operand(SUCCESS)); -+ } -+ } -+ // Exit and return a0. -+ __ bind(&exit_label_); -+ if (global()) { -+ __ Ld(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); -+ } -+ -+ __ bind(&return_a0); -+ // Skip sp past regexp registers and local variables.. -+ __ mv(sp, frame_pointer()); -+ -+ // Restore registers fp..s11 and return (restoring ra to pc). -+ __ MultiPop(registers_to_retain | ra.bit()); -+ -+ __ Ret(); -+ -+ // Backtrack code (branch target for conditional backtracks). -+ if (backtrack_label_.is_linked()) { -+ __ bind(&backtrack_label_); -+ Backtrack(); -+ } -+ -+ Label exit_with_exception; -+ -+ // Preempt-code. -+ if (check_preempt_label_.is_linked()) { -+ SafeCallTarget(&check_preempt_label_); -+ // Put regexp engine registers on stack. -+ RegList regexp_registers_to_retain = current_input_offset().bit() | -+ current_character().bit() | -+ backtrack_stackpointer().bit(); -+ __ MultiPush(regexp_registers_to_retain); -+ CallCheckStackGuardState(a0); -+ __ MultiPop(regexp_registers_to_retain); -+ // If returning non-zero, we should end execution with the given -+ // result as return value. -+ __ Branch(&return_a0, ne, a0, Operand(zero_reg)); -+ -+ // String might have moved: Reload end of string from frame. -+ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ SafeReturn(); -+ } -+ -+ // Backtrack stack overflow code. -+ if (stack_overflow_label_.is_linked()) { -+ SafeCallTarget(&stack_overflow_label_); -+ // Reached if the backtrack-stack limit has been hit. -+ // Put regexp engine registers on stack first. -+ RegList regexp_registers = -+ current_input_offset().bit() | current_character().bit(); -+ __ MultiPush(regexp_registers); -+ -+ // Call GrowStack(backtrack_stackpointer(), &stack_base) -+ static const int num_arguments = 3; -+ __ PrepareCallCFunction(num_arguments, a0); -+ __ mv(a0, backtrack_stackpointer()); -+ __ Add64(a1, frame_pointer(), Operand(kStackHighEnd)); -+ __ li(a2, Operand(ExternalReference::isolate_address(masm_->isolate()))); -+ ExternalReference grow_stack = -+ ExternalReference::re_grow_stack(masm_->isolate()); -+ __ CallCFunction(grow_stack, num_arguments); -+ // Restore regexp registers. -+ __ MultiPop(regexp_registers); -+ // If return nullptr, we have failed to grow the stack, and -+ // must exit with a stack-overflow exception. -+ __ Branch(&exit_with_exception, eq, a0, Operand(zero_reg)); -+ // Otherwise use return value as new stack pointer. -+ __ mv(backtrack_stackpointer(), a0); -+ // Restore saved registers and continue. -+ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); -+ SafeReturn(); -+ } -+ -+ if (exit_with_exception.is_linked()) { -+ // If any of the code above needed to exit with an exception. -+ __ bind(&exit_with_exception); -+ // Exit with Result EXCEPTION(-1) to signal thrown exception. -+ __ li(a0, Operand(EXCEPTION)); -+ __ jmp(&return_a0); -+ } -+ } -+ -+ CodeDesc code_desc; -+ masm_->GetCode(isolate(), &code_desc); -+ Handle code = -+ Factory::CodeBuilder(isolate(), code_desc, CodeKind::REGEXP) -+ .set_self_reference(masm_->CodeObject()) -+ .Build(); -+ LOG(masm_->isolate(), -+ RegExpCodeCreateEvent(Handle::cast(code), source)); -+ return Handle::cast(code); -+} -+ -+void RegExpMacroAssemblerRISCV::GoTo(Label* to) { -+ if (to == nullptr) { -+ Backtrack(); -+ return; -+ } -+ __ jmp(to); -+ return; -+} -+ -+void RegExpMacroAssemblerRISCV::IfRegisterGE(int reg, int comparand, -+ Label* if_ge) { -+ __ Ld(a0, register_location(reg)); -+ BranchOrBacktrack(if_ge, ge, a0, Operand(comparand)); -+} -+ -+void RegExpMacroAssemblerRISCV::IfRegisterLT(int reg, int comparand, -+ Label* if_lt) { -+ __ Ld(a0, register_location(reg)); -+ BranchOrBacktrack(if_lt, lt, a0, Operand(comparand)); -+} -+ -+void RegExpMacroAssemblerRISCV::IfRegisterEqPos(int reg, Label* if_eq) { -+ __ Ld(a0, register_location(reg)); -+ BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset())); -+} -+ -+RegExpMacroAssembler::IrregexpImplementation -+RegExpMacroAssemblerRISCV::Implementation() { -+ return kRISCVImplementation; -+} -+ -+void RegExpMacroAssemblerRISCV::PopCurrentPosition() { -+ Pop(current_input_offset()); -+} -+ -+void RegExpMacroAssemblerRISCV::PopRegister(int register_index) { -+ Pop(a0); -+ __ Sd(a0, register_location(register_index)); -+} -+ -+void RegExpMacroAssemblerRISCV::PushBacktrack(Label* label) { -+ if (label->is_bound()) { -+ int target = label->pos(); -+ __ li(a0, Operand(target + Code::kHeaderSize - kHeapObjectTag)); -+ } else { -+ Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); -+ Label after_constant; -+ __ Branch(&after_constant); -+ int offset = masm_->pc_offset(); -+ int cp_offset = offset + Code::kHeaderSize - kHeapObjectTag; -+ __ emit(0); -+ masm_->label_at_put(label, offset); -+ __ bind(&after_constant); -+ if (is_int16(cp_offset)) { -+ __ Lwu(a0, MemOperand(code_pointer(), cp_offset)); -+ } else { -+ __ Add64(a0, code_pointer(), cp_offset); -+ __ Lwu(a0, MemOperand(a0, 0)); -+ } -+ } -+ Push(a0); -+ CheckStackLimit(); -+} -+ -+void RegExpMacroAssemblerRISCV::PushCurrentPosition() { -+ Push(current_input_offset()); -+} -+ -+void RegExpMacroAssemblerRISCV::PushRegister(int register_index, -+ StackCheckFlag check_stack_limit) { -+ __ Ld(a0, register_location(register_index)); -+ Push(a0); -+ if (check_stack_limit) CheckStackLimit(); -+} -+ -+void RegExpMacroAssemblerRISCV::ReadCurrentPositionFromRegister(int reg) { -+ __ Ld(current_input_offset(), register_location(reg)); -+} -+ -+void RegExpMacroAssemblerRISCV::ReadStackPointerFromRegister(int reg) { -+ __ Ld(backtrack_stackpointer(), register_location(reg)); -+ __ Ld(a0, MemOperand(frame_pointer(), kStackHighEnd)); -+ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0)); -+} -+ -+void RegExpMacroAssemblerRISCV::SetCurrentPositionFromEnd(int by) { -+ Label after_position; -+ __ Branch(&after_position, ge, current_input_offset(), -+ Operand(-by * char_size())); -+ __ li(current_input_offset(), -by * char_size()); -+ // On RegExp code entry (where this operation is used), the character before -+ // the current position is expected to be already loaded. -+ // We have advanced the position, so it's safe to read backwards. -+ LoadCurrentCharacterUnchecked(-1, 1); -+ __ bind(&after_position); -+} -+ -+void RegExpMacroAssemblerRISCV::SetRegister(int register_index, int to) { -+ DCHECK(register_index >= num_saved_registers_); // Reserved for positions! -+ __ li(a0, Operand(to)); -+ __ Sd(a0, register_location(register_index)); -+} -+ -+bool RegExpMacroAssemblerRISCV::Succeed() { -+ __ jmp(&success_label_); -+ return global(); -+} -+ -+void RegExpMacroAssemblerRISCV::WriteCurrentPositionToRegister(int reg, -+ int cp_offset) { -+ if (cp_offset == 0) { -+ __ Sd(current_input_offset(), register_location(reg)); -+ } else { -+ __ Add64(a0, current_input_offset(), Operand(cp_offset * char_size())); -+ __ Sd(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::ClearRegisters(int reg_from, int reg_to) { -+ DCHECK(reg_from <= reg_to); -+ __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ for (int reg = reg_from; reg <= reg_to; reg++) { -+ __ Sd(a0, register_location(reg)); -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::WriteStackPointerToRegister(int reg) { -+ __ Ld(a1, MemOperand(frame_pointer(), kStackHighEnd)); -+ __ Sub64(a0, backtrack_stackpointer(), a1); -+ __ Sd(a0, register_location(reg)); -+} -+ -+bool RegExpMacroAssemblerRISCV::CanReadUnaligned() { return false; } -+ -+// Private methods: -+ -+void RegExpMacroAssemblerRISCV::CallCheckStackGuardState(Register scratch) { -+ DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); -+ DCHECK(!masm_->options().isolate_independent_code); -+ -+ int stack_alignment = base::OS::ActivationFrameAlignment(); -+ -+ // Align the stack pointer and save the original sp value on the stack. -+ __ mv(scratch, sp); -+ __ Sub64(sp, sp, Operand(kPointerSize)); -+ DCHECK(base::bits::IsPowerOfTwo(stack_alignment)); -+ __ And(sp, sp, Operand(-stack_alignment)); -+ __ Sd(scratch, MemOperand(sp)); -+ -+ __ mv(a2, frame_pointer()); -+ // Code of self. -+ __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); -+ -+ // We need to make room for the return address on the stack. -+ DCHECK(IsAligned(stack_alignment, kPointerSize)); -+ __ Sub64(sp, sp, Operand(stack_alignment)); -+ -+ // The stack pointer now points to cell where the return address will be -+ // written. Arguments are in registers, meaning we treat the return address as -+ // argument 5. Since DirectCEntry will handle allocating space for the C -+ // argument slots, we don't need to care about that here. This is how the -+ // stack will look (sp meaning the value of sp at this moment): -+ // [sp + 3] - empty slot if needed for alignment. -+ // [sp + 2] - saved sp. -+ // [sp + 1] - second word reserved for return value. -+ // [sp + 0] - first word reserved for return value. -+ -+ // a0 will point to the return address, placed by DirectCEntry. -+ __ mv(a0, sp); -+ -+ ExternalReference stack_guard_check = -+ ExternalReference::re_check_stack_guard_state(masm_->isolate()); -+ __ li(t6, Operand(stack_guard_check)); -+ -+ EmbeddedData d = EmbeddedData::FromBlob(); -+ CHECK(Builtins::IsIsolateIndependent(Builtins::kDirectCEntry)); -+ Address entry = d.InstructionStartOfBuiltin(Builtins::kDirectCEntry); -+ __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); -+ __ Call(kScratchReg); -+ -+ // DirectCEntry allocated space for the C argument slots so we have to -+ // drop them with the return address from the stack with loading saved sp. -+ // At this point stack must look: -+ // [sp + 7] - empty slot if needed for alignment. -+ // [sp + 6] - saved sp. -+ // [sp + 5] - second word reserved for return value. -+ // [sp + 4] - first word reserved for return value. -+ // [sp + 3] - C argument slot. -+ // [sp + 2] - C argument slot. -+ // [sp + 1] - C argument slot. -+ // [sp + 0] - C argument slot. -+ __ Ld(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize)); -+ -+ __ li(code_pointer(), Operand(masm_->CodeObject())); -+} -+ -+// Helper function for reading a value out of a stack frame. -+template -+static T& frame_entry(Address re_frame, int frame_offset) { -+ return reinterpret_cast(Memory(re_frame + frame_offset)); -+} -+ -+template -+static T* frame_entry_address(Address re_frame, int frame_offset) { -+ return reinterpret_cast(re_frame + frame_offset); -+} -+ -+int64_t RegExpMacroAssemblerRISCV::CheckStackGuardState(Address* return_address, -+ Address raw_code, -+ Address re_frame) { -+ Code re_code = Code::cast(Object(raw_code)); -+ return NativeRegExpMacroAssembler::CheckStackGuardState( -+ frame_entry(re_frame, kIsolate), -+ static_cast(frame_entry(re_frame, kStartIndex)), -+ static_cast( -+ frame_entry(re_frame, kDirectCall)), -+ return_address, re_code, -+ frame_entry_address
(re_frame, kInputString), -+ frame_entry_address(re_frame, kInputStart), -+ frame_entry_address(re_frame, kInputEnd)); -+} -+ -+MemOperand RegExpMacroAssemblerRISCV::register_location(int register_index) { -+ DCHECK(register_index < (1 << 30)); -+ if (num_registers_ <= register_index) { -+ num_registers_ = register_index + 1; -+ } -+ return MemOperand(frame_pointer(), -+ kRegisterZero - register_index * kPointerSize); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckPosition(int cp_offset, -+ Label* on_outside_input) { -+ if (cp_offset >= 0) { -+ BranchOrBacktrack(on_outside_input, ge, current_input_offset(), -+ Operand(-cp_offset * char_size())); -+ } else { -+ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); -+ __ Add64(a0, current_input_offset(), Operand(cp_offset * char_size())); -+ BranchOrBacktrack(on_outside_input, le, a0, Operand(a1)); -+ } -+} -+ -+void RegExpMacroAssemblerRISCV::BranchOrBacktrack(Label* to, -+ Condition condition, -+ Register rs, -+ const Operand& rt) { -+ if (condition == al) { // Unconditional. -+ if (to == nullptr) { -+ Backtrack(); -+ return; -+ } -+ __ jmp(to); -+ return; -+ } -+ if (to == nullptr) { -+ __ Branch(&backtrack_label_, condition, rs, rt); -+ return; -+ } -+ __ Branch(to, condition, rs, rt); -+} -+ -+void RegExpMacroAssemblerRISCV::SafeCall(Label* to, Condition cond, Register rs, -+ const Operand& rt) { -+ __ BranchAndLink(to, cond, rs, rt); -+} -+ -+void RegExpMacroAssemblerRISCV::SafeReturn() { -+ __ pop(ra); -+ __ Add64(t1, ra, Operand(masm_->CodeObject())); -+ __ Jump(t1); -+} -+ -+void RegExpMacroAssemblerRISCV::SafeCallTarget(Label* name) { -+ __ bind(name); -+ __ Sub64(ra, ra, Operand(masm_->CodeObject())); -+ __ push(ra); -+} -+ -+void RegExpMacroAssemblerRISCV::Push(Register source) { -+ DCHECK(source != backtrack_stackpointer()); -+ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), -+ Operand(-kIntSize)); -+ __ Sw(source, MemOperand(backtrack_stackpointer())); -+} -+ -+void RegExpMacroAssemblerRISCV::Pop(Register target) { -+ DCHECK(target != backtrack_stackpointer()); -+ __ Lw(target, MemOperand(backtrack_stackpointer())); -+ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), kIntSize); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckPreemption() { -+ // Check for preemption. -+ ExternalReference stack_limit = -+ ExternalReference::address_of_jslimit(masm_->isolate()); -+ __ li(a0, Operand(stack_limit)); -+ __ Ld(a0, MemOperand(a0)); -+ SafeCall(&check_preempt_label_, Uless_equal, sp, Operand(a0)); -+} -+ -+void RegExpMacroAssemblerRISCV::CheckStackLimit() { -+ ExternalReference stack_limit = -+ ExternalReference::address_of_regexp_stack_limit_address( -+ masm_->isolate()); -+ -+ __ li(a0, Operand(stack_limit)); -+ __ Ld(a0, MemOperand(a0)); -+ SafeCall(&stack_overflow_label_, Uless_equal, backtrack_stackpointer(), -+ Operand(a0)); -+} -+ -+void RegExpMacroAssemblerRISCV::LoadCurrentCharacterUnchecked(int cp_offset, -+ int characters) { -+ Register offset = current_input_offset(); -+ if (cp_offset != 0) { -+ // t4 is not being used to store the capture start index at this point. -+ __ Add64(t4, current_input_offset(), Operand(cp_offset * char_size())); -+ offset = t4; -+ } -+ // We assume that we cannot do unaligned loads on RISC-V, so this function -+ // must only be used to load a single character at a time. -+ DCHECK_EQ(1, characters); -+ __ Add64(t1, end_of_input_address(), Operand(offset)); -+ if (mode_ == LATIN1) { -+ __ Lbu(current_character(), MemOperand(t1, 0)); -+ } else { -+ DCHECK(mode_ == UC16); -+ __ Lhu(current_character(), MemOperand(t1, 0)); -+ } -+} -+ -+#undef __ -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_TARGET_ARCH_RISCV64 ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/regexp/riscv64/regexp-macro-assembler-riscv64.h -@@ -0,0 +1,213 @@ -+// Copyright 2011 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ -+#define V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ -+ -+#include "src/codegen/macro-assembler.h" -+#include "src/codegen/riscv64/assembler-riscv64.h" -+#include "src/regexp/regexp-macro-assembler.h" -+ -+namespace v8 { -+namespace internal { -+ -+class V8_EXPORT_PRIVATE RegExpMacroAssemblerRISCV -+ : public NativeRegExpMacroAssembler { -+ public: -+ RegExpMacroAssemblerRISCV(Isolate* isolate, Zone* zone, Mode mode, -+ int registers_to_save); -+ virtual ~RegExpMacroAssemblerRISCV(); -+ virtual int stack_limit_slack(); -+ virtual void AdvanceCurrentPosition(int by); -+ virtual void AdvanceRegister(int reg, int by); -+ virtual void Backtrack(); -+ virtual void Bind(Label* label); -+ virtual void CheckAtStart(int cp_offset, Label* on_at_start); -+ virtual void CheckCharacter(uint32_t c, Label* on_equal); -+ virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, -+ Label* on_equal); -+ virtual void CheckCharacterGT(uc16 limit, Label* on_greater); -+ virtual void CheckCharacterLT(uc16 limit, Label* on_less); -+ // A "greedy loop" is a loop that is both greedy and with a simple -+ // body. It has a particularly simple implementation. -+ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); -+ virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start); -+ virtual void CheckNotBackReference(int start_reg, bool read_backward, -+ Label* on_no_match); -+ virtual void CheckNotBackReferenceIgnoreCase(int start_reg, -+ bool read_backward, bool unicode, -+ Label* on_no_match); -+ virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); -+ virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, -+ Label* on_not_equal); -+ virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask, -+ Label* on_not_equal); -+ virtual void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range); -+ virtual void CheckCharacterNotInRange(uc16 from, uc16 to, -+ Label* on_not_in_range); -+ virtual void CheckBitInTable(Handle table, Label* on_bit_set); -+ -+ // Checks whether the given offset from the current position is before -+ // the end of the string. -+ virtual void CheckPosition(int cp_offset, Label* on_outside_input); -+ virtual bool CheckSpecialCharacterClass(uc16 type, Label* on_no_match); -+ virtual void Fail(); -+ virtual Handle GetCode(Handle source); -+ virtual void GoTo(Label* label); -+ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); -+ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); -+ virtual void IfRegisterEqPos(int reg, Label* if_eq); -+ virtual IrregexpImplementation Implementation(); -+ virtual void LoadCurrentCharacterUnchecked(int cp_offset, -+ int character_count); -+ virtual void PopCurrentPosition(); -+ virtual void PopRegister(int register_index); -+ virtual void PushBacktrack(Label* label); -+ virtual void PushCurrentPosition(); -+ virtual void PushRegister(int register_index, -+ StackCheckFlag check_stack_limit); -+ virtual void ReadCurrentPositionFromRegister(int reg); -+ virtual void ReadStackPointerFromRegister(int reg); -+ virtual void SetCurrentPositionFromEnd(int by); -+ virtual void SetRegister(int register_index, int to); -+ virtual bool Succeed(); -+ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); -+ virtual void ClearRegisters(int reg_from, int reg_to); -+ virtual void WriteStackPointerToRegister(int reg); -+ virtual bool CanReadUnaligned(); -+ -+ // Called from RegExp if the stack-guard is triggered. -+ // If the code object is relocated, the return address is fixed before -+ // returning. -+ // {raw_code} is an Address because this is called via ExternalReference. -+ static int64_t CheckStackGuardState(Address* return_address, Address raw_code, -+ Address re_frame); -+ -+ void print_regexp_frame_constants(); -+ -+ private: -+ // Offsets from frame_pointer() of function parameters and stored registers. -+ static const int kFramePointer = 0; -+ -+ // Above the frame pointer - Stored registers and stack passed parameters. -+ // Registers s1 to s8, fp, and ra. -+ static const int kStoredRegisters = kFramePointer; -+ // Return address (stored from link register, read into pc on return). -+ -+ // This 9 is 8 s-regs (s1..s8) plus fp. -+ static const int kNumCalleeRegsToRetain = 9; -+ static const int kReturnAddress = -+ kStoredRegisters + kNumCalleeRegsToRetain * kPointerSize; -+ -+ // Stack frame header. -+ static const int kStackFrameHeader = kReturnAddress; -+ // Stack parameters placed by caller. -+ static const int kIsolate = kStackFrameHeader + kPointerSize; -+ -+ // Below the frame pointer. -+ // Register parameters stored by setup code. -+ static const int kDirectCall = kFramePointer - kPointerSize; -+ static const int kStackHighEnd = kDirectCall - kPointerSize; -+ static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; -+ static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; -+ static const int kInputEnd = kRegisterOutput - kPointerSize; -+ static const int kInputStart = kInputEnd - kPointerSize; -+ static const int kStartIndex = kInputStart - kPointerSize; -+ static const int kInputString = kStartIndex - kPointerSize; -+ // When adding local variables remember to push space for them in -+ // the frame in GetCode. -+ static const int kSuccessfulCaptures = kInputString - kPointerSize; -+ static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize; -+ static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize; -+ // First register address. Following registers are below it on the stack. -+ static const int kRegisterZero = kBacktrackCount - kSystemPointerSize; -+ -+ // Initial size of code buffer. -+ static const int kRegExpCodeSize = 1024; -+ -+ // Check whether preemption has been requested. -+ void CheckPreemption(); -+ -+ // Check whether we are exceeding the stack limit on the backtrack stack. -+ void CheckStackLimit(); -+ -+ // Generate a call to CheckStackGuardState. -+ void CallCheckStackGuardState(Register scratch); -+ -+ // The ebp-relative location of a regexp register. -+ MemOperand register_location(int register_index); -+ -+ // Register holding the current input position as negative offset from -+ // the end of the string. -+ inline Register current_input_offset() { return a6; } -+ -+ // The register containing the current character after LoadCurrentCharacter. -+ inline Register current_character() { return a7; } -+ -+ // Register holding address of the end of the input string. -+ inline Register end_of_input_address() { return t2; } -+ -+ // Register holding the frame address. Local variables, parameters and -+ // regexp registers are addressed relative to this. -+ inline Register frame_pointer() { return fp; } -+ -+ // The register containing the backtrack stack top. Provides a meaningful -+ // name to the register. -+ inline Register backtrack_stackpointer() { return t0; } -+ -+ // Register holding pointer to the current code object. -+ inline Register code_pointer() { return a5; } -+ -+ // Byte size of chars in the string to match (decided by the Mode argument). -+ inline int char_size() { return static_cast(mode_); } -+ -+ // Equivalent to a conditional branch to the label, unless the label -+ // is nullptr, in which case it is a conditional Backtrack. -+ void BranchOrBacktrack(Label* to, Condition condition, Register rs, -+ const Operand& rt); -+ -+ // Call and return internally in the generated code in a way that -+ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) -+ inline void SafeCall(Label* to, Condition cond, Register rs, -+ const Operand& rt); -+ inline void SafeReturn(); -+ inline void SafeCallTarget(Label* name); -+ -+ // Pushes the value of a register on the backtrack stack. Decrements the -+ // stack pointer by a word size and stores the register's value there. -+ inline void Push(Register source); -+ -+ // Pops a value from the backtrack stack. Reads the word at the stack pointer -+ // and increments it by a word size. -+ inline void Pop(Register target); -+ -+ Isolate* isolate() const { return masm_->isolate(); } -+ -+ MacroAssembler* masm_; -+ -+ // Which mode to generate code for (Latin1 or UC16). -+ Mode mode_; -+ -+ // One greater than maximal register index actually used. -+ int num_registers_; -+ -+ // Number of registers to output at the end (the saved registers -+ // are always 0..num_saved_registers_-1). -+ int num_saved_registers_; -+ -+ // Labels used internally. -+ Label entry_label_; -+ Label start_label_; -+ Label success_label_; -+ Label backtrack_label_; -+ Label exit_label_; -+ Label check_preempt_label_; -+ Label stack_overflow_label_; -+ Label internal_failure_label_; -+}; -+ -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ ---- a/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc -+++ b/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc -@@ -19,7 +19,8 @@ - - // Other platforms have CSA support, see builtins-sharedarraybuffer-gen.h. - #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ -- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ -+ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - - namespace { - -@@ -568,6 +569,6 @@ - - #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 - // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X -- -+ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV - } // namespace internal - } // namespace v8 ---- a/src/3rdparty/chromium/v8/src/snapshot/deserializer.h -+++ b/src/3rdparty/chromium/v8/src/snapshot/deserializer.h -@@ -29,9 +29,10 @@ - - // Used for platforms with embedded constant pools to trigger deserialization - // of objects found in code. --#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ -- defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ -- defined(V8_TARGET_ARCH_PPC64) || V8_EMBEDDED_CONSTANT_POOL -+#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ -+ defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ -+ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_RISCV64) || \ -+ defined(V8_TARGET_ARCH_RISCV) || V8_EMBEDDED_CONSTANT_POOL - #define V8_CODE_EMBEDS_OBJECT_POINTER 1 - #else - #define V8_CODE_EMBEDS_OBJECT_POINTER 0 ---- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h -@@ -69,6 +69,23 @@ - d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d16, d17, - d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29); - -+#elif V8_TARGET_ARCH_RISCV64 -+ -+// Any change of kLiftoffAssemblerGpCacheRegs also need to update -+// kPushedGpRegs in frame-constants-riscv64.h -+constexpr RegList kLiftoffAssemblerGpCacheRegs = -+ Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); -+ -+// Any change of kLiftoffAssemblerGpCacheRegs also need to update -+// kPushedFpRegs in frame-constants-riscv64.h -+constexpr RegList kLiftoffAssemblerFpCacheRegs = -+ DoubleRegister::ListOf(ft0, ft1, ft2, ft3, ft4, ft5, ft6, ft7, fa0, fa1, -+ fa2, fa3, fa4, fa5, fa6, fa7, ft8, ft9, ft10, ft11); -+ -+#elif V8_TARGET_ARCH_RISCV -+ -+#error RISCV (32) architecture not supported yet -+ - #else - - constexpr RegList kLiftoffAssemblerGpCacheRegs = 0xff; -@@ -116,6 +133,18 @@ - constexpr Condition kUnsignedGreaterThan = hi; - constexpr Condition kUnsignedGreaterEqual = hs; - -+#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV -+constexpr Condition kEqual = eq; -+constexpr Condition kUnequal = ne; -+constexpr Condition kSignedLessThan = lt; -+constexpr Condition kSignedLessEqual = le; -+constexpr Condition kSignedGreaterThan = gt; -+constexpr Condition kSignedGreaterEqual = ge; -+constexpr Condition kUnsignedLessThan = ult; -+constexpr Condition kUnsignedLessEqual = ule; -+constexpr Condition kUnsignedGreaterThan = ugt; -+constexpr Condition kUnsignedGreaterEqual = uge; -+ - #else - - // On unimplemented platforms, just make this compile. ---- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h -@@ -1353,6 +1353,10 @@ - #include "src/wasm/baseline/mips64/liftoff-assembler-mips64.h" - #elif V8_TARGET_ARCH_S390 - #include "src/wasm/baseline/s390/liftoff-assembler-s390.h" -+#elif V8_TARGET_ARCH_RISCV64 -+#include "src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h" -+#elif V8_TARGET_ARCH_RISCV -+#include "src/wasm/baseline/riscv/liftoff-assembler-riscv.h" - #else - #error Unsupported architecture. - #endif ---- /dev/null -+++ b/src/3rdparty/chromium/v8/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h -@@ -0,0 +1,2335 @@ -+// Copyright 2017 the V8 project authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ -+#define V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ -+ -+#include "src/wasm/baseline/liftoff-assembler.h" -+ -+namespace v8 { -+namespace internal { -+namespace wasm { -+ -+namespace liftoff { -+ -+// Liftoff Frames. -+// -+// slot Frame -+// +--------------------+--------------------------- -+// n+4 | optional padding slot to keep the stack 16 byte aligned. -+// n+3 | parameter n | -+// ... | ... | -+// 4 | parameter 1 | or parameter 2 -+// 3 | parameter 0 | or parameter 1 -+// 2 | (result address) | or parameter 0 -+// -----+--------------------+--------------------------- -+// 1 | return addr (ra) | -+// 0 | previous frame (fp)| -+// -----+--------------------+ <-- frame ptr (fp) -+// -1 | 0xa: WASM | -+// -2 | instance | -+// -----+--------------------+--------------------------- -+// -3 | slot 0 | ^ -+// -4 | slot 1 | | -+// | | Frame slots -+// | | | -+// | | v -+// | optional padding slot to keep the stack 16 byte aligned. -+// -----+--------------------+ <-- stack ptr (sp) -+// -+ -+// fp-8 holds the stack marker, fp-16 is the instance parameter. -+constexpr int kInstanceOffset = 16; -+ -+inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); } -+ -+inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } -+ -+inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, -+ ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->Lw(dst.gp(), src); -+ break; -+ case ValueType::kI64: -+ assm->Ld(dst.gp(), src); -+ break; -+ case ValueType::kF32: -+ assm->LoadFloat(dst.fp(), src); -+ break; -+ case ValueType::kF64: -+ assm->LoadDouble(dst.fp(), src); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+inline void Store(LiftoffAssembler* assm, Register base, int32_t offset, -+ LiftoffRegister src, ValueType type) { -+ MemOperand dst(base, offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->Usw(src.gp(), dst); -+ break; -+ case ValueType::kI64: -+ assm->Usd(src.gp(), dst); -+ break; -+ case ValueType::kF32: -+ assm->UStoreFloat(src.fp(), dst, t5); -+ break; -+ case ValueType::kF64: -+ assm->UStoreDouble(src.fp(), dst, t5); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kI32: -+ assm->addi(sp, sp, -kSystemPointerSize); -+ assm->Sw(reg.gp(), MemOperand(sp, 0)); -+ break; -+ case ValueType::kI64: -+ assm->push(reg.gp()); -+ break; -+ case ValueType::kF32: -+ assm->addi(sp, sp, -kSystemPointerSize); -+ assm->StoreFloat(reg.fp(), MemOperand(sp, 0)); -+ break; -+ case ValueType::kF64: -+ assm->addi(sp, sp, -kSystemPointerSize); -+ assm->StoreDouble(reg.fp(), MemOperand(sp, 0)); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+#if defined(V8_TARGET_BIG_ENDIAN) -+inline void ChangeEndiannessLoad(LiftoffAssembler* assm, LiftoffRegister dst, -+ LoadType type, LiftoffRegList pinned) { -+ bool is_float = false; -+ LiftoffRegister tmp = dst; -+ switch (type.value()) { -+ case LoadType::kI64Load8U: -+ case LoadType::kI64Load8S: -+ case LoadType::kI32Load8U: -+ case LoadType::kI32Load8S: -+ // No need to change endianness for byte size. -+ return; -+ case LoadType::kF32Load: -+ is_float = true; -+ tmp = assm->GetUnusedRegister(kGpReg, pinned); -+ assm->emit_type_conversion(kExprI32ReinterpretF32, tmp, dst); -+ V8_FALLTHROUGH; -+ case LoadType::kI64Load32U: -+ assm->TurboAssembler::ByteSwapUnsigned(tmp.gp(), tmp.gp(), 4); -+ break; -+ case LoadType::kI32Load: -+ case LoadType::kI64Load32S: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); -+ break; -+ case LoadType::kI32Load16S: -+ case LoadType::kI64Load16S: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); -+ break; -+ case LoadType::kI32Load16U: -+ case LoadType::kI64Load16U: -+ assm->TurboAssembler::ByteSwapUnsigned(tmp.gp(), tmp.gp(), 2); -+ break; -+ case LoadType::kF64Load: -+ is_float = true; -+ tmp = assm->GetUnusedRegister(kGpReg, pinned); -+ assm->emit_type_conversion(kExprI64ReinterpretF64, tmp, dst); -+ V8_FALLTHROUGH; -+ case LoadType::kI64Load: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 8); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ if (is_float) { -+ switch (type.value()) { -+ case LoadType::kF32Load: -+ assm->emit_type_conversion(kExprF32ReinterpretI32, dst, tmp); -+ break; -+ case LoadType::kF64Load: -+ assm->emit_type_conversion(kExprF64ReinterpretI64, dst, tmp); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+ -+inline void ChangeEndiannessStore(LiftoffAssembler* assm, LiftoffRegister src, -+ StoreType type, LiftoffRegList pinned) { -+ bool is_float = false; -+ LiftoffRegister tmp = src; -+ switch (type.value()) { -+ case StoreType::kI64Store8: -+ case StoreType::kI32Store8: -+ // No need to change endianness for byte size. -+ return; -+ case StoreType::kF32Store: -+ is_float = true; -+ tmp = assm->GetUnusedRegister(kGpReg, pinned); -+ assm->emit_type_conversion(kExprI32ReinterpretF32, tmp, src); -+ V8_FALLTHROUGH; -+ case StoreType::kI32Store: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); -+ break; -+ case StoreType::kI32Store16: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); -+ break; -+ case StoreType::kF64Store: -+ is_float = true; -+ tmp = assm->GetUnusedRegister(kGpReg, pinned); -+ assm->emit_type_conversion(kExprI64ReinterpretF64, tmp, src); -+ V8_FALLTHROUGH; -+ case StoreType::kI64Store: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 8); -+ break; -+ case StoreType::kI64Store32: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); -+ break; -+ case StoreType::kI64Store16: -+ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ if (is_float) { -+ switch (type.value()) { -+ case StoreType::kF32Store: -+ assm->emit_type_conversion(kExprF32ReinterpretI32, src, tmp); -+ break; -+ case StoreType::kF64Store: -+ assm->emit_type_conversion(kExprF64ReinterpretI64, src, tmp); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ } -+} -+#endif // V8_TARGET_BIG_ENDIAN -+ -+} // namespace liftoff -+ -+int LiftoffAssembler::PrepareStackFrame() { -+ int offset = pc_offset(); -+ // When constant that represents size of stack frame can't be represented -+ // as 16bit we need three instructions to add it to sp, so we reserve space -+ // for this case. -+ Add64(sp, sp, Operand(0L)); -+ nop(); -+ nop(); -+ return offset; -+} -+ -+void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params, -+ int stack_param_delta) { -+ UseScratchRegisterScope temps(this); -+ Register scratch = temps.Acquire(); -+ -+ // Push the return address and frame pointer to complete the stack frame. -+ Ld(scratch, MemOperand(fp, 8)); -+ Push(scratch); -+ Ld(scratch, MemOperand(fp, 0)); -+ Push(scratch); -+ -+ // Shift the whole frame upwards. -+ int slot_count = num_callee_stack_params + 2; -+ for (int i = slot_count - 1; i >= 0; --i) { -+ Ld(scratch, MemOperand(sp, i * 8)); -+ Sd(scratch, MemOperand(fp, (i - stack_param_delta) * 8)); -+ } -+ -+ // Set the new stack and frame pointer. -+ Add64(sp, fp, -stack_param_delta * 8); -+ Pop(ra, fp); -+} -+ -+void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) { -+ // We can't run out of space, just pass anything big enough to not cause the -+ // assembler to try to grow the buffer. -+ constexpr int kAvailableSpace = 256; -+ TurboAssembler patching_assembler( -+ nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, -+ ExternalAssemblerBuffer(buffer_start_ + offset, kAvailableSpace)); -+ // If bytes can be represented as 16bit, addi will be generated and two -+ // nops will stay untouched. Otherwise, lui-ori sequence will load it to -+ // register and, as third instruction, daddu will be generated. -+ patching_assembler.Add64(sp, sp, Operand(-frame_size)); -+} -+ -+void LiftoffAssembler::FinishCode() {} -+ -+void LiftoffAssembler::AbortCompilation() {} -+ -+// static -+constexpr int LiftoffAssembler::StaticStackFrameSize() { -+ return liftoff::kInstanceOffset; -+} -+ -+int LiftoffAssembler::SlotSizeForType(ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kS128: -+ return type.element_size_bytes(); -+ default: -+ return kStackSlotSize; -+ } -+} -+ -+bool LiftoffAssembler::NeedsAlignment(ValueType type) { -+ switch (type.kind()) { -+ case ValueType::kS128: -+ return true; -+ default: -+ // No alignment because all other types are kStackSlotSize. -+ return false; -+ } -+} -+ -+void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value, -+ RelocInfo::Mode rmode) { -+ switch (value.type().kind()) { -+ case ValueType::kI32: -+ TurboAssembler::li(reg.gp(), Operand(value.to_i32(), rmode)); -+ break; -+ case ValueType::kI64: -+ TurboAssembler::li(reg.gp(), Operand(value.to_i64(), rmode)); -+ break; -+ case ValueType::kF32: -+ TurboAssembler::LoadFPRImmediate(reg.fp(), -+ value.to_f32_boxed().get_bits()); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::LoadFPRImmediate(reg.fp(), -+ value.to_f64_boxed().get_bits()); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, -+ int size) { -+ DCHECK_LE(offset, kMaxInt); -+ Ld(dst, liftoff::GetInstanceOperand()); -+ DCHECK(size == 4 || size == 8); -+ if (size == 4) { -+ Lw(dst, MemOperand(dst, offset)); -+ } else { -+ Ld(dst, MemOperand(dst, offset)); -+ } -+} -+ -+void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, -+ uint32_t offset) { -+ LoadFromInstance(dst, offset, kTaggedSize); -+} -+ -+void LiftoffAssembler::SpillInstance(Register instance) { -+ Sd(instance, liftoff::GetInstanceOperand()); -+} -+ -+void LiftoffAssembler::FillInstanceInto(Register dst) { -+ Ld(dst, liftoff::GetInstanceOperand()); -+} -+ -+void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, -+ Register offset_reg, -+ int32_t offset_imm, -+ LiftoffRegList pinned) { -+ STATIC_ASSERT(kTaggedSize == kInt64Size); -+ Load(LiftoffRegister(dst), src_addr, offset_reg, -+ static_cast(offset_imm), LoadType::kI64Load, pinned); -+} -+ -+void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, -+ int32_t offset_imm, -+ LiftoffRegister src, -+ LiftoffRegList pinned) { -+ bailout(kRefTypes, "GlobalSet"); -+} -+ -+void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, LiftoffRegList pinned, -+ uint32_t* protected_load_pc, bool is_load_mem) { -+ Register src = no_reg; -+ if (offset_reg != no_reg) { -+ src = GetUnusedRegister(kGpReg, pinned).gp(); -+ emit_ptrsize_add(src, src_addr, offset_reg); -+ } -+ MemOperand src_op = (offset_reg != no_reg) ? MemOperand(src, offset_imm) -+ : MemOperand(src_addr, offset_imm); -+ -+ if (protected_load_pc) *protected_load_pc = pc_offset(); -+ switch (type.value()) { -+ case LoadType::kI32Load8U: -+ case LoadType::kI64Load8U: -+ Lbu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load8S: -+ case LoadType::kI64Load8S: -+ Lb(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load16U: -+ case LoadType::kI64Load16U: -+ TurboAssembler::Ulhu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load16S: -+ case LoadType::kI64Load16S: -+ TurboAssembler::Ulh(dst.gp(), src_op); -+ break; -+ case LoadType::kI64Load32U: -+ TurboAssembler::Ulwu(dst.gp(), src_op); -+ break; -+ case LoadType::kI32Load: -+ case LoadType::kI64Load32S: -+ TurboAssembler::Ulw(dst.gp(), src_op); -+ break; -+ case LoadType::kI64Load: -+ TurboAssembler::Uld(dst.gp(), src_op); -+ break; -+ case LoadType::kF32Load: -+ TurboAssembler::ULoadFloat(dst.fp(), src_op, t5); -+ break; -+ case LoadType::kF64Load: -+ TurboAssembler::ULoadDouble(dst.fp(), src_op, t5); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+#if defined(V8_TARGET_BIG_ENDIAN) -+ if (is_load_mem) { -+ pinned.set(src_op.rm()); -+ liftoff::ChangeEndiannessLoad(this, dst, type, pinned); -+ } -+#endif -+} -+ -+void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister src, -+ StoreType type, LiftoffRegList pinned, -+ uint32_t* protected_store_pc, bool is_store_mem) { -+ Register dst = no_reg; -+ MemOperand dst_op = MemOperand(dst_addr, offset_imm); -+ if (offset_reg != no_reg) { -+ if (is_store_mem) { -+ pinned.set(src); -+ } -+ dst = GetUnusedRegister(kGpReg, pinned).gp(); -+ emit_ptrsize_add(dst, dst_addr, offset_reg); -+ dst_op = MemOperand(dst, offset_imm); -+ } -+ -+#if defined(V8_TARGET_BIG_ENDIAN) -+ if (is_store_mem) { -+ pinned.set(dst_op.rm()); -+ LiftoffRegister tmp = GetUnusedRegister(src.reg_class(), pinned); -+ // Save original value. -+ Move(tmp, src, type.value_type()); -+ -+ src = tmp; -+ pinned.set(tmp); -+ liftoff::ChangeEndiannessStore(this, src, type, pinned); -+ } -+#endif -+ -+ if (protected_store_pc) *protected_store_pc = pc_offset(); -+ -+ // FIXME (RISCV): current implementation treats all stores as unaligned -+ switch (type.value()) { -+ case StoreType::kI32Store8: -+ case StoreType::kI64Store8: -+ Sb(src.gp(), dst_op); -+ break; -+ case StoreType::kI32Store16: -+ case StoreType::kI64Store16: -+ TurboAssembler::Ush(src.gp(), dst_op); -+ break; -+ case StoreType::kI32Store: -+ case StoreType::kI64Store32: -+ TurboAssembler::Usw(src.gp(), dst_op); -+ break; -+ case StoreType::kI64Store: -+ TurboAssembler::Usd(src.gp(), dst_op); -+ break; -+ case StoreType::kF32Store: -+ TurboAssembler::UStoreFloat(src.fp(), dst_op, t5); -+ break; -+ case StoreType::kF64Store: -+ TurboAssembler::UStoreDouble(src.fp(), dst_op, t5); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, LiftoffRegList pinned) { -+ bailout(kAtomics, "AtomicLoad"); -+} -+ -+void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister src, -+ StoreType type, LiftoffRegList pinned) { -+ bailout(kAtomics, "AtomicStore"); -+} -+ -+void LiftoffAssembler::AtomicAdd(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicAdd"); -+} -+ -+void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicSub"); -+} -+ -+void LiftoffAssembler::AtomicAnd(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicAnd"); -+} -+ -+void LiftoffAssembler::AtomicOr(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicOr"); -+} -+ -+void LiftoffAssembler::AtomicXor(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicXor"); -+} -+ -+void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg, -+ uint32_t offset_imm, -+ LiftoffRegister value, -+ LiftoffRegister result, StoreType type) { -+ bailout(kAtomics, "AtomicExchange"); -+} -+ -+void LiftoffAssembler::AtomicCompareExchange( -+ Register dst_addr, Register offset_reg, uint32_t offset_imm, -+ LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result, -+ StoreType type) { -+ bailout(kAtomics, "AtomicCompareExchange"); -+} -+ -+void LiftoffAssembler::AtomicFence() { sync(); } -+ -+void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, -+ uint32_t caller_slot_idx, -+ ValueType type) { -+ MemOperand src(fp, kSystemPointerSize * (caller_slot_idx + 1)); -+ liftoff::Load(this, dst, src, type); -+} -+ -+void LiftoffAssembler::StoreCallerFrameSlot(LiftoffRegister src, -+ uint32_t caller_slot_idx, -+ ValueType type) { -+ int32_t offset = kSystemPointerSize * (caller_slot_idx + 1); -+ liftoff::Store(this, fp, offset, src, type); -+} -+ -+void LiftoffAssembler::LoadReturnStackSlot(LiftoffRegister dst, int offset, -+ ValueType type) { -+ liftoff::Load(this, dst, MemOperand(sp, offset), type); -+} -+ -+void LiftoffAssembler::MoveStackValue(uint32_t dst_offset, uint32_t src_offset, -+ ValueType type) { -+ DCHECK_NE(dst_offset, src_offset); -+ LiftoffRegister reg = GetUnusedRegister(reg_class_for(type), {}); -+ Fill(reg, src_offset, type); -+ Spill(dst_offset, reg, type); -+} -+ -+void LiftoffAssembler::Move(Register dst, Register src, ValueType type) { -+ DCHECK_NE(dst, src); -+ // TODO(ksreten): Handle different sizes here. -+ TurboAssembler::Move(dst, src); -+} -+ -+void LiftoffAssembler::Move(DoubleRegister dst, DoubleRegister src, -+ ValueType type) { -+ DCHECK_NE(dst, src); -+ TurboAssembler::Move(dst, src); -+} -+ -+void LiftoffAssembler::Spill(int offset, LiftoffRegister reg, ValueType type) { -+ RecordUsedSpillOffset(offset); -+ MemOperand dst = liftoff::GetStackSlot(offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ Sw(reg.gp(), dst); -+ break; -+ case ValueType::kI64: -+ Sd(reg.gp(), dst); -+ break; -+ case ValueType::kF32: -+ StoreFloat(reg.fp(), dst); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::StoreDouble(reg.fp(), dst); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Spill(int offset, WasmValue value) { -+ RecordUsedSpillOffset(offset); -+ MemOperand dst = liftoff::GetStackSlot(offset); -+ switch (value.type().kind()) { -+ case ValueType::kI32: { -+ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); -+ TurboAssembler::li(tmp.gp(), Operand(value.to_i32())); -+ Sw(tmp.gp(), dst); -+ break; -+ } -+ case ValueType::kI64: { -+ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); -+ TurboAssembler::li(tmp.gp(), value.to_i64()); -+ Sd(tmp.gp(), dst); -+ break; -+ } -+ default: -+ // kWasmF32 and kWasmF64 are unreachable, since those -+ // constants are not tracked. -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::Fill(LiftoffRegister reg, int offset, ValueType type) { -+ MemOperand src = liftoff::GetStackSlot(offset); -+ switch (type.kind()) { -+ case ValueType::kI32: -+ Lw(reg.gp(), src); -+ break; -+ case ValueType::kI64: -+ Ld(reg.gp(), src); -+ break; -+ case ValueType::kF32: -+ LoadFloat(reg.fp(), src); -+ break; -+ case ValueType::kF64: -+ TurboAssembler::LoadDouble(reg.fp(), src); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+} -+ -+void LiftoffAssembler::FillI64Half(Register, int offset, RegPairHalf) { -+ UNREACHABLE(); -+} -+ -+void LiftoffAssembler::FillStackSlotsWithZero(int start, int size) { -+ DCHECK_LT(0, size); -+ RecordUsedSpillOffset(start + size); -+ -+ if (size <= 12 * kStackSlotSize) { -+ // Special straight-line code for up to 12 slots. Generates one -+ // instruction per slot (<= 12 instructions total). -+ uint32_t remainder = size; -+ for (; remainder >= kStackSlotSize; remainder -= kStackSlotSize) { -+ Sd(zero_reg, liftoff::GetStackSlot(start + remainder)); -+ } -+ DCHECK(remainder == 4 || remainder == 0); -+ if (remainder) { -+ Sw(zero_reg, liftoff::GetStackSlot(start + remainder)); -+ } -+ } else { -+ // General case for bigger counts (12 instructions). -+ // Use a0 for start address (inclusive), a1 for end address (exclusive). -+ Push(a1, a0); -+ Add64(a0, fp, Operand(-start - size)); -+ Add64(a1, fp, Operand(-start)); -+ -+ Label loop; -+ bind(&loop); -+ Sd(zero_reg, MemOperand(a0)); -+ addi(a0, a0, kSystemPointerSize); -+ BranchShort(&loop, ne, a0, Operand(a1)); -+ -+ Pop(a1, a0); -+ } -+} -+ -+void LiftoffAssembler::emit_i64_clz(LiftoffRegister dst, LiftoffRegister src) { -+ TurboAssembler::Clz64(dst.gp(), src.gp()); -+} -+ -+void LiftoffAssembler::emit_i64_ctz(LiftoffRegister dst, LiftoffRegister src) { -+ TurboAssembler::Ctz64(dst.gp(), src.gp()); -+} -+ -+bool LiftoffAssembler::emit_i64_popcnt(LiftoffRegister dst, -+ LiftoffRegister src) { -+ TurboAssembler::Popcnt64(dst.gp(), src.gp()); -+ return true; -+} -+ -+void LiftoffAssembler::emit_i32_mul(Register dst, Register lhs, Register rhs) { -+ TurboAssembler::Mul32(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero, -+ Label* trap_div_unrepresentable) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ -+ // Check if lhs == kMinInt and rhs == -1, since this case is unrepresentable. -+ TurboAssembler::CompareI(kScratchReg, lhs, Operand(kMinInt), ne); -+ TurboAssembler::CompareI(kScratchReg2, rhs, Operand(-1), ne); -+ add(kScratchReg, kScratchReg, kScratchReg2); -+ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, -+ Operand(zero_reg)); -+ -+ TurboAssembler::Div32(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Divu32(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Mod32(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_i32_remu(Register dst, Register lhs, Register rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); -+ TurboAssembler::Modu32(dst, lhs, rhs); -+} -+ -+#define I32_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name(Register dst, Register lhs, \ -+ Register rhs) { \ -+ instruction(dst, lhs, rhs); \ -+ } -+ -+// clang-format off -+I32_BINOP(add, addw) -+I32_BINOP(sub, subw) -+I32_BINOP(and, and_) -+I32_BINOP(or, or_) -+I32_BINOP(xor, xor_) -+// clang-format on -+ -+#undef I32_BINOP -+ -+#define I32_BINOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register lhs, \ -+ int32_t imm) { \ -+ instruction(dst, lhs, Operand(imm)); \ -+ } -+ -+// clang-format off -+I32_BINOP_I(add, Add32) -+I32_BINOP_I(and, And) -+I32_BINOP_I(or, Or) -+I32_BINOP_I(xor, Xor) -+// clang-format on -+ -+#undef I32_BINOP_I -+ -+void LiftoffAssembler::emit_i32_clz(Register dst, Register src) { -+ TurboAssembler::Clz32(dst, src); -+} -+ -+void LiftoffAssembler::emit_i32_ctz(Register dst, Register src) { -+ TurboAssembler::Ctz32(dst, src); -+} -+ -+bool LiftoffAssembler::emit_i32_popcnt(Register dst, Register src) { -+ TurboAssembler::Popcnt32(dst, src); -+ return true; -+} -+ -+#define I32_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name(Register dst, Register src, \ -+ Register amount) { \ -+ instruction(dst, src, amount); \ -+ } -+#define I32_SHIFTOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register src, \ -+ int amount) { \ -+ instruction(dst, src, amount); \ -+ } -+ -+I32_SHIFTOP(shl, sllw) -+I32_SHIFTOP(sar, sraw) -+I32_SHIFTOP(shr, srlw) -+ -+I32_SHIFTOP_I(shl, slliw) -+I32_SHIFTOP_I(sar, sraiw) -+I32_SHIFTOP_I(shr, srliw) -+ -+#undef I32_SHIFTOP -+#undef I32_SHIFTOP_I -+ -+void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ TurboAssembler::Mul64(dst.gp(), lhs.gp(), rhs.gp()); -+} -+ -+bool LiftoffAssembler::emit_i64_divs(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero, -+ Label* trap_div_unrepresentable) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ -+ // Check if lhs == MinInt64 and rhs == -1, since this case is unrepresentable. -+ TurboAssembler::CompareI(kScratchReg, lhs.gp(), -+ Operand(std::numeric_limits::min()), ne); -+ TurboAssembler::CompareI(kScratchReg2, rhs.gp(), Operand(-1), ne); -+ add(kScratchReg, kScratchReg, kScratchReg2); -+ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, -+ Operand(zero_reg)); -+ -+ TurboAssembler::Div64(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_divu(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Divu64(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_rems(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Mod64(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_i64_remu(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ Label* trap_div_by_zero) { -+ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); -+ TurboAssembler::Modu64(dst.gp(), lhs.gp(), rhs.gp()); -+ return true; -+} -+ -+#define I64_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name( \ -+ LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ -+ instruction(dst.gp(), lhs.gp(), rhs.gp()); \ -+ } -+ -+// clang-format off -+I64_BINOP(add, add) -+I64_BINOP(sub, sub) -+I64_BINOP(and, and_) -+I64_BINOP(or, or_) -+I64_BINOP(xor, xor_) -+// clang-format on -+ -+#undef I64_BINOP -+ -+#define I64_BINOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name##i( \ -+ LiftoffRegister dst, LiftoffRegister lhs, int32_t imm) { \ -+ instruction(dst.gp(), lhs.gp(), Operand(imm)); \ -+ } -+ -+// clang-format off -+I64_BINOP_I(add, Add64) -+I64_BINOP_I(and, And) -+I64_BINOP_I(or, Or) -+I64_BINOP_I(xor, Xor) -+// clang-format on -+ -+#undef I64_BINOP_I -+ -+#define I64_SHIFTOP(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name( \ -+ LiftoffRegister dst, LiftoffRegister src, Register amount) { \ -+ instruction(dst.gp(), src.gp(), amount); \ -+ } -+#define I64_SHIFTOP_I(name, instruction) \ -+ void LiftoffAssembler::emit_i64_##name##i(LiftoffRegister dst, \ -+ LiftoffRegister src, int amount) { \ -+ DCHECK(is_uint6(amount)); \ -+ instruction(dst.gp(), src.gp(), amount); \ -+ } -+ -+I64_SHIFTOP(shl, sll) -+I64_SHIFTOP(sar, sra) -+I64_SHIFTOP(shr, srl) -+ -+I64_SHIFTOP_I(shl, slli) -+I64_SHIFTOP_I(sar, srai) -+I64_SHIFTOP_I(shr, srli) -+ -+#undef I64_SHIFTOP -+#undef I64_SHIFTOP_I -+ -+void LiftoffAssembler::emit_u32_to_intptr(Register dst, Register src) { -+ addw(dst, src, zero_reg); -+} -+ -+void LiftoffAssembler::emit_f32_neg(DoubleRegister dst, DoubleRegister src) { -+ TurboAssembler::Neg_s(dst, src); -+} -+ -+void LiftoffAssembler::emit_f64_neg(DoubleRegister dst, DoubleRegister src) { -+ TurboAssembler::Neg_d(dst, src); -+} -+ -+void LiftoffAssembler::emit_f32_min(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ TurboAssembler::Float32Min(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_f32_max(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ TurboAssembler::Float32Max(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_f32_copysign(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ bailout(kComplexOperation, "f32_copysign"); -+} -+ -+void LiftoffAssembler::emit_f64_min(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ TurboAssembler::Float64Min(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_f64_max(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ TurboAssembler::Float64Max(dst, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_f64_copysign(DoubleRegister dst, DoubleRegister lhs, -+ DoubleRegister rhs) { -+ bailout(kComplexOperation, "f64_copysign"); -+} -+ -+#define FP_BINOP(name, instruction) \ -+ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister lhs, \ -+ DoubleRegister rhs) { \ -+ instruction(dst, lhs, rhs); \ -+ } -+#define FP_UNOP(name, instruction) \ -+ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ -+ instruction(dst, src); \ -+ } -+#define FP_UNOP_RETURN_TRUE(name, instruction) \ -+ bool LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ -+ instruction(dst, src, kScratchDoubleReg); \ -+ return true; \ -+ } -+ -+FP_BINOP(f32_add, fadd_s) -+FP_BINOP(f32_sub, fsub_s) -+FP_BINOP(f32_mul, fmul_s) -+FP_BINOP(f32_div, fdiv_s) -+FP_UNOP(f32_abs, fabs_s) -+FP_UNOP_RETURN_TRUE(f32_ceil, Ceil_s_s) -+FP_UNOP_RETURN_TRUE(f32_floor, Floor_s_s) -+FP_UNOP_RETURN_TRUE(f32_trunc, Trunc_s_s) -+FP_UNOP_RETURN_TRUE(f32_nearest_int, Round_s_s) -+FP_UNOP(f32_sqrt, fsqrt_s) -+FP_BINOP(f64_add, fadd_d) -+FP_BINOP(f64_sub, fsub_d) -+FP_BINOP(f64_mul, fmul_d) -+FP_BINOP(f64_div, fdiv_d) -+FP_UNOP(f64_abs, fabs_d) -+FP_UNOP_RETURN_TRUE(f64_ceil, Ceil_d_d) -+FP_UNOP_RETURN_TRUE(f64_floor, Floor_d_d) -+FP_UNOP_RETURN_TRUE(f64_trunc, Trunc_d_d) -+FP_UNOP_RETURN_TRUE(f64_nearest_int, Round_d_d) -+FP_UNOP(f64_sqrt, fsqrt_d) -+ -+#undef FP_BINOP -+#undef FP_UNOP -+#undef FP_UNOP_RETURN_TRUE -+ -+bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, -+ LiftoffRegister dst, -+ LiftoffRegister src, Label* trap) { -+ switch (opcode) { -+ case kExprI32ConvertI64: -+ // According to WebAssembly spec, if I64 value does not fit the range of -+ // I32, the value is undefined. Therefore, We use sign extension to -+ // implement I64 to I32 truncation -+ TurboAssembler::SignExtendWord(dst.gp(), src.gp()); -+ return true; -+ case kExprI32SConvertF32: -+ case kExprI32UConvertF32: -+ case kExprI32SConvertF64: -+ case kExprI32UConvertF64: -+ case kExprI64SConvertF32: -+ case kExprI64UConvertF32: -+ case kExprI64SConvertF64: -+ case kExprI64UConvertF64: -+ case kExprF32ConvertF64: { -+ // real conversion, if src is out-of-bound of target integer types, -+ // kScratchReg is set to 0 -+ switch (opcode) { -+ case kExprI32SConvertF32: -+ Trunc_w_s(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI32UConvertF32: -+ Trunc_uw_s(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI32SConvertF64: -+ Trunc_w_d(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI32UConvertF64: -+ Trunc_uw_d(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI64SConvertF32: -+ Trunc_l_s(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI64UConvertF32: -+ Trunc_ul_s(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI64SConvertF64: -+ Trunc_l_d(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprI64UConvertF64: -+ Trunc_ul_d(dst.gp(), src.fp(), kScratchReg); -+ break; -+ case kExprF32ConvertF64: -+ fcvt_s_d(dst.fp(), src.fp()); -+ // FIXME (?): what if double cannot be represented by float? -+ // Trunc_s_d(dst.gp(), src.fp(), kScratchReg); -+ break; -+ default: -+ UNREACHABLE(); -+ } -+ -+ // Checking if trap. -+ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); -+ -+ return true; -+ } -+ case kExprI32ReinterpretF32: -+ TurboAssembler::ExtractLowWordFromF64(dst.gp(), src.fp()); -+ return true; -+ case kExprI64SConvertI32: -+ TurboAssembler::SignExtendWord(dst.gp(), src.gp()); -+ return true; -+ case kExprI64UConvertI32: -+ TurboAssembler::ZeroExtendWord(dst.gp(), src.gp()); -+ return true; -+ case kExprI64ReinterpretF64: -+ fmv_x_d(dst.gp(), src.fp()); -+ return true; -+ case kExprF32SConvertI32: { -+ TurboAssembler::Cvt_s_w(dst.fp(), src.gp()); -+ return true; -+ } -+ case kExprF32UConvertI32: -+ TurboAssembler::Cvt_s_uw(dst.fp(), src.gp()); -+ return true; -+ case kExprF32ReinterpretI32: -+ fmv_w_x(dst.fp(), src.gp()); -+ return true; -+ case kExprF64SConvertI32: { -+ TurboAssembler::Cvt_d_w(dst.fp(), src.gp()); -+ return true; -+ } -+ case kExprF64UConvertI32: -+ TurboAssembler::Cvt_d_uw(dst.fp(), src.gp()); -+ return true; -+ case kExprF64ConvertF32: -+ fcvt_d_s(dst.fp(), src.fp()); -+ return true; -+ case kExprF64ReinterpretI64: -+ fmv_d_x(dst.fp(), src.gp()); -+ return true; -+ case kExprI32SConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF32"); -+ return true; -+ case kExprI32UConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF32"); -+ return true; -+ case kExprI32SConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF64"); -+ return true; -+ case kExprI32UConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF64"); -+ return true; -+ case kExprI64SConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF32"); -+ return true; -+ case kExprI64UConvertSatF32: -+ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF32"); -+ return true; -+ case kExprI64SConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF64"); -+ return true; -+ case kExprI64UConvertSatF64: -+ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF64"); -+ return true; -+ default: -+ return false; -+ } -+} -+ -+void LiftoffAssembler::emit_i32_signextend_i8(Register dst, Register src) { -+ slliw(dst, src, 32 - 8); -+ sraiw(dst, dst, 32 - 8); -+} -+ -+void LiftoffAssembler::emit_i32_signextend_i16(Register dst, Register src) { -+ slliw(dst, src, 32 - 16); -+ sraiw(dst, dst, 32 - 16); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i8(LiftoffRegister dst, -+ LiftoffRegister src) { -+ slli(dst.gp(), src.gp(), 64 - 8); -+ srai(dst.gp(), dst.gp(), 64 - 8); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i16(LiftoffRegister dst, -+ LiftoffRegister src) { -+ slli(dst.gp(), src.gp(), 64 - 16); -+ srai(dst.gp(), dst.gp(), 64 - 16); -+} -+ -+void LiftoffAssembler::emit_i64_signextend_i32(LiftoffRegister dst, -+ LiftoffRegister src) { -+ slli(dst.gp(), src.gp(), 64 - 32); -+ srai(dst.gp(), dst.gp(), 64 - 32); -+} -+ -+void LiftoffAssembler::emit_jump(Label* label) { -+ TurboAssembler::Branch(label); -+} -+ -+void LiftoffAssembler::emit_jump(Register target) { -+ TurboAssembler::Jump(target); -+} -+ -+void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, -+ ValueType type, Register lhs, -+ Register rhs) { -+ if (rhs != no_reg) { -+ TurboAssembler::Branch(label, cond, lhs, Operand(rhs)); -+ } else { -+ TurboAssembler::Branch(label, cond, lhs, Operand(zero_reg)); -+ } -+} -+ -+void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { -+ TurboAssembler::Sltu(dst, src, 1); -+} -+ -+void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, -+ Register lhs, Register rhs) { -+ TurboAssembler::CompareI(dst, lhs, Operand(rhs), cond); -+} -+ -+void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { -+ TurboAssembler::Sltu(dst, src.gp(), 1); -+} -+ -+void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ TurboAssembler::CompareI(dst, lhs.gp(), Operand(rhs.gp()), cond); -+} -+ -+static FPUCondition ConditionToConditionCmpFPU(Condition condition) { -+ switch (condition) { -+ case kEqual: -+ return EQ; -+ case kUnequal: -+ return NE; -+ case kUnsignedLessThan: -+ return LT; -+ case kUnsignedGreaterEqual: -+ return GE; -+ case kUnsignedLessEqual: -+ return LE; -+ case kUnsignedGreaterThan: -+ return GT; -+ default: -+ break; -+ } -+ UNREACHABLE(); -+} -+ -+void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, -+ DoubleRegister lhs, -+ DoubleRegister rhs) { -+ FPUCondition fcond = ConditionToConditionCmpFPU(cond); -+ TurboAssembler::CompareF32(dst, fcond, lhs, rhs); -+} -+ -+void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, -+ DoubleRegister lhs, -+ DoubleRegister rhs) { -+ FPUCondition fcond = ConditionToConditionCmpFPU(cond); -+ TurboAssembler::CompareF64(dst, fcond, lhs, rhs); -+} -+ -+bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition, -+ LiftoffRegister true_value, -+ LiftoffRegister false_value, -+ ValueType type) { -+ return false; -+} -+ -+void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, -+ Register offset_reg, uint32_t offset_imm, -+ LoadType type, -+ LoadTransformationKind transform, -+ uint32_t* protected_load_pc) { -+ bailout(kSimd, "load extend and load splat unimplemented"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs, -+ const uint8_t shuffle[16], -+ bool is_swizzle) { -+ bailout(kSimd, "emit_i8x16_shuffle"); -+} -+ -+void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_swizzle"); -+} -+ -+void LiftoffAssembler::emit_i8x16_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_splat"); -+} -+ -+void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_splat"); -+} -+ -+void LiftoffAssembler::emit_i32x4_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_splat"); -+} -+ -+void LiftoffAssembler::emit_i64x2_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i64x2_splat"); -+} -+ -+void LiftoffAssembler::emit_f32x4_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_splat"); -+} -+ -+void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_splat"); -+} -+ -+void LiftoffAssembler::emit_i8x16_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_eq"); -+} -+ -+void LiftoffAssembler::emit_i8x16_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_ne"); -+} -+ -+void LiftoffAssembler::emit_i8x16_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_gt_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_gt_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_ge_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_ge_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_eq"); -+} -+ -+void LiftoffAssembler::emit_i16x8_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_ne"); -+} -+ -+void LiftoffAssembler::emit_i16x8_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_gt_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_gt_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_ge_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_ge_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_eq"); -+} -+ -+void LiftoffAssembler::emit_i32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_ne"); -+} -+ -+void LiftoffAssembler::emit_i32x4_gt_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_gt_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_gt_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_gt_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_ge_s(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_ge_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_ge_u(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_ge_u"); -+} -+ -+void LiftoffAssembler::emit_f32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_eq"); -+} -+ -+void LiftoffAssembler::emit_f32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_ne"); -+} -+ -+void LiftoffAssembler::emit_f32x4_lt(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_lt"); -+} -+ -+void LiftoffAssembler::emit_f32x4_le(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_le"); -+} -+ -+void LiftoffAssembler::emit_f64x2_eq(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_eq"); -+} -+ -+void LiftoffAssembler::emit_f64x2_ne(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_ne"); -+} -+ -+void LiftoffAssembler::emit_f64x2_lt(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_lt"); -+} -+ -+void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_le"); -+} -+ -+void LiftoffAssembler::emit_s128_const(LiftoffRegister dst, -+ const uint8_t imms[16]) { -+ bailout(kSimd, "emit_s128_const"); -+} -+ -+void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) { -+ bailout(kSimd, "emit_s128_not"); -+} -+ -+void LiftoffAssembler::emit_s128_and(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_s128_and"); -+} -+ -+void LiftoffAssembler::emit_s128_or(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_s128_or"); -+} -+ -+void LiftoffAssembler::emit_s128_xor(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_s128_xor"); -+} -+ -+void LiftoffAssembler::emit_s128_and_not(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_s128_and_not"); -+} -+ -+void LiftoffAssembler::emit_s128_select(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ LiftoffRegister mask) { -+ bailout(kSimd, "emit_s128_select"); -+} -+ -+void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_neg"); -+} -+ -+void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_anytrue"); -+} -+ -+void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_alltrue"); -+} -+ -+void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_bitmask"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_shl"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) { -+ bailout(kSimd, "emit_i8x16_shli"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_shr_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i8x16_shri_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_shr_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i8x16_shri_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_add"); -+} -+ -+void LiftoffAssembler::emit_i8x16_add_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_add_saturate_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_add_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_add_saturate_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_sub"); -+} -+ -+void LiftoffAssembler::emit_i8x16_sub_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_sub_saturate_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_sub_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_sub_saturate_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_mul"); -+} -+ -+void LiftoffAssembler::emit_i8x16_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_min_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_min_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_max_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_max_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_neg"); -+} -+ -+void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_anytrue"); -+} -+ -+void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_alltrue"); -+} -+ -+void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_bitmask"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_shl"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) { -+ bailout(kSimd, "emit_i16x8_shli"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_shr_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i16x8_shri_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_shr_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i16x8_shri_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_add"); -+} -+ -+void LiftoffAssembler::emit_i16x8_add_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_add_saturate_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_add_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_add_saturate_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_sub"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sub_saturate_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_sub_saturate_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sub_saturate_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_sub_saturate_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_mul"); -+} -+ -+void LiftoffAssembler::emit_i16x8_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_min_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_min_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_max_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_max_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_neg"); -+} -+ -+void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_v32x4_anytrue"); -+} -+ -+void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_v32x4_alltrue"); -+} -+ -+void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_bitmask"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_shl"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) { -+ bailout(kSimd, "emit_i32x4_shli"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_shr_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i32x4_shri_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_shr_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i32x4_shri_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_add"); -+} -+ -+void LiftoffAssembler::emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_sub"); -+} -+ -+void LiftoffAssembler::emit_i32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_mul"); -+} -+ -+void LiftoffAssembler::emit_i32x4_min_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_min_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_min_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_min_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_max_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_max_s"); -+} -+ -+void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i32x4_max_u"); -+} -+ -+void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i64x2_neg"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shl(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_shl"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shli(LiftoffRegister dst, LiftoffRegister lhs, -+ int32_t rhs) { -+ bailout(kSimd, "emit_i64x2_shli"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shr_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_shr_s"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shri_s(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i64x2_shri_s"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shr_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_shr_u"); -+} -+ -+void LiftoffAssembler::emit_i64x2_shri_u(LiftoffRegister dst, -+ LiftoffRegister lhs, int32_t rhs) { -+ bailout(kSimd, "emit_i64x2_shri_u"); -+} -+ -+void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_add"); -+} -+ -+void LiftoffAssembler::emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_sub"); -+} -+ -+void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i64x2_mul"); -+} -+ -+void LiftoffAssembler::emit_f32x4_abs(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_abs"); -+} -+ -+void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_neg"); -+} -+ -+void LiftoffAssembler::emit_f32x4_sqrt(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_sqrt"); -+} -+ -+bool LiftoffAssembler::emit_f32x4_ceil(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_ceil"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f32x4_floor(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_floor"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f32x4_trunc(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_trunc"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f32x4_nearest_int(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_nearest_int"); -+ return true; -+} -+ -+void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_add"); -+} -+ -+void LiftoffAssembler::emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_sub"); -+} -+ -+void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_mul"); -+} -+ -+void LiftoffAssembler::emit_f32x4_div(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_div"); -+} -+ -+void LiftoffAssembler::emit_f32x4_min(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_min"); -+} -+ -+void LiftoffAssembler::emit_f32x4_max(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_max"); -+} -+ -+void LiftoffAssembler::emit_f32x4_pmin(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_pmin"); -+} -+ -+void LiftoffAssembler::emit_f32x4_pmax(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f32x4_pmax"); -+} -+ -+void LiftoffAssembler::emit_f64x2_abs(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_abs"); -+} -+ -+void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_neg"); -+} -+ -+void LiftoffAssembler::emit_f64x2_sqrt(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_sqrt"); -+} -+ -+bool LiftoffAssembler::emit_f64x2_ceil(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_ceil"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f64x2_floor(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_floor"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f64x2_trunc(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_trunc"); -+ return true; -+} -+ -+bool LiftoffAssembler::emit_f64x2_nearest_int(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f64x2_nearest_int"); -+ return true; -+} -+ -+void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_add"); -+} -+ -+void LiftoffAssembler::emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_sub"); -+} -+ -+void LiftoffAssembler::emit_f64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_mul"); -+} -+ -+void LiftoffAssembler::emit_f64x2_div(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_div"); -+} -+ -+void LiftoffAssembler::emit_f64x2_min(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_min"); -+} -+ -+void LiftoffAssembler::emit_f64x2_max(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_max"); -+} -+ -+void LiftoffAssembler::emit_f64x2_pmin(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_pmin"); -+} -+ -+void LiftoffAssembler::emit_f64x2_pmax(LiftoffRegister dst, LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_f64x2_pmax"); -+} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_f32x4(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_sconvert_f32x4"); -+} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_f32x4(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_uconvert_f32x4"); -+} -+ -+void LiftoffAssembler::emit_f32x4_sconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_sconvert_i32x4"); -+} -+ -+void LiftoffAssembler::emit_f32x4_uconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_f32x4_uconvert_i32x4"); -+} -+ -+void LiftoffAssembler::emit_i8x16_sconvert_i16x8(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_sconvert_i16x8"); -+} -+ -+void LiftoffAssembler::emit_i8x16_uconvert_i16x8(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_uconvert_i16x8"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_sconvert_i32x4"); -+} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i32x4(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_uconvert_i32x4"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i8x16_low(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_sconvert_i8x16_low"); -+} -+ -+void LiftoffAssembler::emit_i16x8_sconvert_i8x16_high(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_sconvert_i8x16_high"); -+} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i8x16_low(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_uconvert_i8x16_low"); -+} -+ -+void LiftoffAssembler::emit_i16x8_uconvert_i8x16_high(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_uconvert_i8x16_high"); -+} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_i16x8_low(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_sconvert_i16x8_low"); -+} -+ -+void LiftoffAssembler::emit_i32x4_sconvert_i16x8_high(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_sconvert_i16x8_high"); -+} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_i16x8_low(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_uconvert_i16x8_low"); -+} -+ -+void LiftoffAssembler::emit_i32x4_uconvert_i16x8_high(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_uconvert_i16x8_high"); -+} -+ -+void LiftoffAssembler::emit_i8x16_rounding_average_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i8x16_rounding_average_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_rounding_average_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ LiftoffRegister rhs) { -+ bailout(kSimd, "emit_i16x8_rounding_average_u"); -+} -+ -+void LiftoffAssembler::emit_i8x16_abs(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i8x16_abs"); -+} -+ -+void LiftoffAssembler::emit_i16x8_abs(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i16x8_abs"); -+} -+ -+void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst, -+ LiftoffRegister src) { -+ bailout(kSimd, "emit_i32x4_abs"); -+} -+ -+void LiftoffAssembler::emit_i8x16_extract_lane_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i8x16_extract_lane_s"); -+} -+ -+void LiftoffAssembler::emit_i8x16_extract_lane_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i8x16_extract_lane_u"); -+} -+ -+void LiftoffAssembler::emit_i16x8_extract_lane_s(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i16x8_extract_lane_s"); -+} -+ -+void LiftoffAssembler::emit_i16x8_extract_lane_u(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i16x8_extract_lane_u"); -+} -+ -+void LiftoffAssembler::emit_i32x4_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i32x4_extract_lane"); -+} -+ -+void LiftoffAssembler::emit_i64x2_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i64x2_extract_lane"); -+} -+ -+void LiftoffAssembler::emit_f32x4_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_f32x4_extract_lane"); -+} -+ -+void LiftoffAssembler::emit_f64x2_extract_lane(LiftoffRegister dst, -+ LiftoffRegister lhs, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_f64x2_extract_lane"); -+} -+ -+void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i8x16_replace_lane"); -+} -+ -+void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i16x8_replace_lane"); -+} -+ -+void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i32x4_replace_lane"); -+} -+ -+void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_i64x2_replace_lane"); -+} -+ -+void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_f32x4_replace_lane"); -+} -+ -+void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, -+ LiftoffRegister src1, -+ LiftoffRegister src2, -+ uint8_t imm_lane_idx) { -+ bailout(kSimd, "emit_f64x2_replace_lane"); -+} -+ -+void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) { -+ TurboAssembler::Uld(limit_address, MemOperand(limit_address)); -+ TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address)); -+} -+ -+void LiftoffAssembler::CallTrapCallbackForTesting() { -+ PrepareCallCFunction(0, GetUnusedRegister(kGpReg, {}).gp()); -+ CallCFunction(ExternalReference::wasm_call_trap_callback_for_testing(), 0); -+} -+ -+void LiftoffAssembler::AssertUnreachable(AbortReason reason) { -+ if (emit_debug_code()) Abort(reason); -+} -+ -+void LiftoffAssembler::PushRegisters(LiftoffRegList regs) { -+ LiftoffRegList gp_regs = regs & kGpCacheRegList; -+ unsigned num_gp_regs = gp_regs.GetNumRegsSet(); -+ if (num_gp_regs) { -+ unsigned offset = num_gp_regs * kSystemPointerSize; -+ Add64(sp, sp, Operand(-offset)); -+ while (!gp_regs.is_empty()) { -+ LiftoffRegister reg = gp_regs.GetFirstRegSet(); -+ offset -= kSystemPointerSize; -+ Sd(reg.gp(), MemOperand(sp, offset)); -+ gp_regs.clear(reg); -+ } -+ DCHECK_EQ(offset, 0); -+ } -+ LiftoffRegList fp_regs = regs & kFpCacheRegList; -+ unsigned num_fp_regs = fp_regs.GetNumRegsSet(); -+ if (num_fp_regs) { -+ Add64(sp, sp, Operand(-(num_fp_regs * kStackSlotSize))); -+ unsigned offset = 0; -+ while (!fp_regs.is_empty()) { -+ LiftoffRegister reg = fp_regs.GetFirstRegSet(); -+ TurboAssembler::StoreDouble(reg.fp(), MemOperand(sp, offset)); -+ fp_regs.clear(reg); -+ offset += sizeof(double); -+ } -+ DCHECK_EQ(offset, num_fp_regs * sizeof(double)); -+ } -+} -+ -+void LiftoffAssembler::PopRegisters(LiftoffRegList regs) { -+ LiftoffRegList fp_regs = regs & kFpCacheRegList; -+ unsigned fp_offset = 0; -+ while (!fp_regs.is_empty()) { -+ LiftoffRegister reg = fp_regs.GetFirstRegSet(); -+ TurboAssembler::LoadDouble(reg.fp(), MemOperand(sp, fp_offset)); -+ fp_regs.clear(reg); -+ fp_offset += sizeof(double); -+ } -+ if (fp_offset) Add64(sp, sp, Operand(fp_offset)); -+ LiftoffRegList gp_regs = regs & kGpCacheRegList; -+ unsigned gp_offset = 0; -+ while (!gp_regs.is_empty()) { -+ LiftoffRegister reg = gp_regs.GetLastRegSet(); -+ Ld(reg.gp(), MemOperand(sp, gp_offset)); -+ gp_regs.clear(reg); -+ gp_offset += kSystemPointerSize; -+ } -+ Add64(sp, sp, Operand(gp_offset)); -+} -+ -+void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) { -+ TurboAssembler::DropAndRet(static_cast(num_stack_slots)); -+} -+ -+void LiftoffAssembler::CallC(const wasm::FunctionSig* sig, -+ const LiftoffRegister* args, -+ const LiftoffRegister* rets, -+ ValueType out_argument_type, int stack_bytes, -+ ExternalReference ext_ref) { -+ Add64(sp, sp, Operand(-stack_bytes)); -+ -+ int arg_bytes = 0; -+ for (ValueType param_type : sig->parameters()) { -+ liftoff::Store(this, sp, arg_bytes, *args++, param_type); -+ arg_bytes += param_type.element_size_bytes(); -+ } -+ DCHECK_LE(arg_bytes, stack_bytes); -+ -+ // Pass a pointer to the buffer with the arguments to the C function. -+ // On RISC-V, the first argument is passed in {a0}. -+ constexpr Register kFirstArgReg = a0; -+ mv(kFirstArgReg, sp); -+ -+ // Now call the C function. -+ constexpr int kNumCCallArgs = 1; -+ PrepareCallCFunction(kNumCCallArgs, kScratchReg); -+ CallCFunction(ext_ref, kNumCCallArgs); -+ -+ // Move return value to the right register. -+ const LiftoffRegister* next_result_reg = rets; -+ if (sig->return_count() > 0) { -+ DCHECK_EQ(1, sig->return_count()); -+ constexpr Register kReturnReg = a0; -+ if (kReturnReg != next_result_reg->gp()) { -+ Move(*next_result_reg, LiftoffRegister(kReturnReg), sig->GetReturn(0)); -+ } -+ ++next_result_reg; -+ } -+ -+ // Load potential output value from the buffer on the stack. -+ if (out_argument_type != kWasmStmt) { -+ liftoff::Load(this, *next_result_reg, MemOperand(sp, 0), out_argument_type); -+ } -+ -+ Add64(sp, sp, Operand(stack_bytes)); -+} -+ -+void LiftoffAssembler::CallNativeWasmCode(Address addr) { -+ Call(addr, RelocInfo::WASM_CALL); -+} -+ -+void LiftoffAssembler::TailCallNativeWasmCode(Address addr) { -+ Jump(addr, RelocInfo::WASM_CALL); -+} -+ -+void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig, -+ compiler::CallDescriptor* call_descriptor, -+ Register target) { -+ if (target == no_reg) { -+ pop(kScratchReg); -+ Call(kScratchReg); -+ } else { -+ Call(target); -+ } -+} -+ -+void LiftoffAssembler::TailCallIndirect(Register target) { -+ if (target == no_reg) { -+ Pop(kScratchReg); -+ Jump(kScratchReg); -+ } else { -+ Jump(target); -+ } -+} -+ -+void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) { -+ // A direct call to a wasm runtime stub defined in this module. -+ // Just encode the stub index. This will be patched at relocation. -+ Call(static_cast
(sid), RelocInfo::WASM_STUB_CALL); -+} -+ -+void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) { -+ Add64(sp, sp, Operand(-size)); -+ TurboAssembler::Move(addr, sp); -+} -+ -+void LiftoffAssembler::DeallocateStackSlot(uint32_t size) { -+ Add64(sp, sp, Operand(size)); -+} -+ -+void LiftoffStackSlots::Construct() { -+ for (auto& slot : slots_) { -+ const LiftoffAssembler::VarState& src = slot.src_; -+ switch (src.loc()) { -+ case LiftoffAssembler::VarState::kStack: -+ asm_->Ld(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); -+ asm_->push(kScratchReg); -+ break; -+ case LiftoffAssembler::VarState::kRegister: -+ liftoff::push(asm_, src.reg(), src.type()); -+ break; -+ case LiftoffAssembler::VarState::kIntConst: { -+ asm_->li(kScratchReg, Operand(src.i32_const())); -+ asm_->push(kScratchReg); -+ break; -+ } -+ } -+ } -+} -+ -+} // namespace wasm -+} // namespace internal -+} // namespace v8 -+ -+#endif // V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ ---- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc -+++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc -@@ -307,6 +307,40 @@ - } - } - -+#elif V8_TARGET_ARCH_RISCV64 -+void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, -+ Address lazy_compile_target) { -+ int start = pc_offset(); -+ li(kWasmCompileLazyFuncIndexRegister, func_index); // max. 2 instr -+ // Jump produces max. 9 instructions (8 for li + 1 for jr) -+ Jump(lazy_compile_target, RelocInfo::NONE); -+ int nop_bytes = start + kLazyCompileTableSlotSize - pc_offset(); -+ DCHECK_EQ(nop_bytes % kInstrSize, 0); -+ for (int i = 0; i < nop_bytes; i += kInstrSize) nop(); -+} -+ -+bool JumpTableAssembler::EmitJumpSlot(Address target) { -+ PatchAndJump(target); -+ return true; -+} -+ -+void JumpTableAssembler::EmitFarJumpSlot(Address target) { -+ JumpToInstructionStream(target); -+} -+ -+// static -+void JumpTableAssembler::PatchFarJumpSlot(Address slot, Address target) { -+ UNREACHABLE(); -+} -+ -+void JumpTableAssembler::NopBytes(int bytes) { -+ DCHECK_LE(0, bytes); -+ DCHECK_EQ(0, bytes % kInstrSize); -+ for (; bytes > 0; bytes -= kInstrSize) { -+ nop(); -+ } -+} -+ - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h -+++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h -@@ -215,6 +215,11 @@ - static constexpr int kJumpTableSlotSize = 8 * kInstrSize; - static constexpr int kFarJumpTableSlotSize = 6 * kInstrSize; - static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; -+#elif V8_TARGET_ARCH_RISCV64 -+ static constexpr int kJumpTableLineSize = 6 * kInstrSize; -+ static constexpr int kJumpTableSlotSize = 6 * kInstrSize; -+ static constexpr int kFarJumpTableSlotSize = 9 * kInstrSize; -+ static constexpr int kLazyCompileTableSlotSize = 9 * kInstrSize; - #else - #error Unknown architecture. - #endif ---- a/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h -+++ b/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h -@@ -102,6 +102,22 @@ - constexpr DoubleRegister kFpParamRegisters[] = {d0, d2}; - constexpr DoubleRegister kFpReturnRegisters[] = {d0, d2}; - -+#elif V8_TARGET_ARCH_RISCV64 -+// =========================================================================== -+// == riscv64 ================================================================= -+// =========================================================================== -+// Note that kGpParamRegisters and kFpParamRegisters are used in -+// Builtins::Generate_WasmCompileLazy (builtins-riscv64.cc) -+constexpr Register kGpParamRegisters[] = {a0, a2, a3, a4, a5, a6, a7}; -+constexpr Register kGpReturnRegisters[] = {a0, a1}; -+constexpr DoubleRegister kFpParamRegisters[] = {fa0, fa1, fa2, fa3, -+ fa4, fa5, fa6}; -+constexpr DoubleRegister kFpReturnRegisters[] = {fa0, fa1}; -+ -+#elif V8_TARGET_ARCH_RISCV -+ -+#error RISCV(32) architecture not supported -+ - #else - // =========================================================================== - // == unknown ================================================================ ---- a/src/3rdparty/chromium/v8/src/wasm/wasm-serialization.cc -+++ b/src/3rdparty/chromium/v8/src/wasm/wasm-serialization.cc -@@ -368,7 +368,8 @@ - writer->WriteVector(code->source_positions()); - writer->WriteVector(code->protected_instructions_data()); - #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM || \ -- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X -+ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X || \ -+ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV32 - // On platforms that don't support misaligned word stores, copy to an aligned - // buffer if necessary so we can relocate the serialized code. - std::unique_ptr aligned_buffer; ---- a/configure.pri -+++ b/configure.pri -@@ -123,6 +123,7 @@ - contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) - contains(QT_ARCH, "mips"): return(true) - contains(QT_ARCH, "mips64"): return(true) -+ contains(QT_ARCH, "riscv64"): return(true) - qtLog("Architecture not supported.") - return(false) - } ---- a/mkspecs/features/functions.prf -+++ b/mkspecs/features/functions.prf -@@ -112,6 +112,7 @@ - contains(qtArch, "mips"): return(mipsel) - contains(qtArch, "mips64"): return(mips64el) - contains(qtArch, "mips64el"): return(mips64el) -+ contains(qtArch, "riscv64"): return(riscv64) - return(unknown) - } - ---- a/src/3rdparty/chromium/base/process/launch_posix.cc -+++ b/src/3rdparty/chromium/base/process/launch_posix.cc -@@ -704,7 +704,7 @@ - alignas(16) char stack_buf[PTHREAD_STACK_MIN]; - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ - defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \ -- defined(ARCH_CPU_PPC64_FAMILY) -+ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) - // The stack grows downward. - void* stack = stack_buf + sizeof(stack_buf); - #else ---- a/src/3rdparty/chromium/build/build_config.h -+++ b/src/3rdparty/chromium/build/build_config.h -@@ -193,6 +193,11 @@ - #define ARCH_CPU_32_BITS 1 - #define ARCH_CPU_BIG_ENDIAN 1 - #endif -+#elif defined(__riscv) && __riscv_xlen == 64 -+#define ARCH_CPU_RISCV_FAMILY 1 -+#define ARCH_CPU_RISCV64 1 -+#define ARCH_CPU_64_BITS 1 -+#define ARCH_CPU_LITTLE_ENDIAN 1 - #else - #error Please add support for your architecture in build/build_config.h - #endif ---- a/src/3rdparty/chromium/build/config/BUILD.gn -+++ b/src/3rdparty/chromium/build/config/BUILD.gn -@@ -238,6 +238,7 @@ - "dl", - "pthread", - "rt", -+ "atomic", - ] - } - } ---- a/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn -+++ b/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn -@@ -298,3 +298,20 @@ - is_clang = false - } - } -+ -+gcc_toolchain("riscv64") { -+ cc = "gcc" -+ cxx = "g++" -+ -+ readelf = "readelf" -+ nm = "nm" -+ ar = "ar" -+ ld = cxx -+ -+ toolchain_args = { -+ current_cpu = "riscv64" -+ current_os = "linux" -+ is_clang = false -+ } -+} -+ ---- a/src/3rdparty/chromium/sandbox/features.gni -+++ b/src/3rdparty/chromium/sandbox/features.gni -@@ -11,7 +11,8 @@ - use_seccomp_bpf = (is_linux || is_chromeos || is_android) && - (current_cpu == "x86" || current_cpu == "x64" || - current_cpu == "arm" || current_cpu == "arm64" || -- current_cpu == "mipsel" || current_cpu == "mips64el") -+ current_cpu == "mipsel" || current_cpu == "mips64el" || -+ current_cpu == "riscv64") - - use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi - ---- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h -@@ -49,6 +49,12 @@ - #define MAX_PUBLIC_SYSCALL __NR_syscalls - #define MAX_SYSCALL MAX_PUBLIC_SYSCALL - -+#elif defined(__riscv) -+ -+#define MIN_SYSCALL 0u -+#define MAX_PUBLIC_SYSCALL 1024u -+#define MAX_SYSCALL MAX_PUBLIC_SYSCALL -+ - #else - #error "Unsupported architecture" - #endif ---- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -+++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h -@@ -346,6 +346,46 @@ - #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] - #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] - #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] -+ -+#elif defined(__riscv) -+struct regs_struct { -+ unsigned long regs[32]; -+}; -+ -+#define SECCOMP_ARCH AUDIT_ARCH_RISCV64 -+ -+#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) -+ -+#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_A0) -+#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_A0+7) -+#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__gregs[REG_PC] -+#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_A0) -+#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_A0+1) -+#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_A0+2) -+#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_A0+3) -+#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_A0+4) -+#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_A0+5) -+ -+#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) -+#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) -+#define SECCOMP_IP_MSB_IDX \ -+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) -+#define SECCOMP_IP_LSB_IDX \ -+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) -+#define SECCOMP_ARG_MSB_IDX(nr) \ -+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) -+#define SECCOMP_ARG_LSB_IDX(nr) \ -+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) -+ -+#define SECCOMP_PT_RESULT(_regs) (_regs).regs[REG_A0] -+#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[REG_A0+7] -+#define SECCOMP_PT_IP(_regs) (_regs).regs[REG_PC] -+#define SECCOMP_PT_PARM1(_regs) (_regs).regs[REG_A0] -+#define SECCOMP_PT_PARM2(_regs) (_regs).regs[REG_A0+1] -+#define SECCOMP_PT_PARM3(_regs) (_regs).regs[REG_A0+2] -+#define SECCOMP_PT_PARM4(_regs) (_regs).regs[REG_A0+3] -+#define SECCOMP_PT_PARM5(_regs) (_regs).regs[REG_A0+4] -+#define SECCOMP_PT_PARM6(_regs) (_regs).regs[REG_A0+5] - #else - #error Unsupported target platform - ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc -@@ -181,7 +181,7 @@ - return RestrictFcntlCommands(); - #endif - --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - // fork() is never used as a system call (clone() is used instead), but we - // have seen it in fallback code on Android. - if (sysno == __NR_fork) { -@@ -231,7 +231,7 @@ - } - - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - if (sysno == __NR_mmap) - return RestrictMmapFlags(); - #endif -@@ -249,7 +249,7 @@ - return RestrictPrctl(); - - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - if (sysno == __NR_socketpair) { - // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. - static_assert(AF_UNIX == PF_UNIX, ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc -@@ -37,7 +37,7 @@ - #include - #include - #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(__arm__) && \ -- !defined(__aarch64__) && !defined(PTRACE_GET_THREAD_AREA) -+ !defined(__aarch64__) && !defined(__riscv) && !defined(PTRACE_GET_THREAD_AREA) - // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance - // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. - // asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't -@@ -410,7 +410,7 @@ - ResultExpr RestrictPtrace() { - const Arg request(0); - return Switch(request).CASES(( --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - PTRACE_GETREGS, - PTRACE_GETFPREGS, - #if defined(TRACE_GET_THREAD_AREA) ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc -@@ -86,7 +86,7 @@ - // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. - bool SyscallSets::IsFileSystem(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_access: // EPERM not a valid errno. - case __NR_chmod: - case __NR_chown: -@@ -118,7 +118,7 @@ - case __NR_faccessat: // EPERM not a valid errno. - case __NR_fchmodat: - case __NR_fchownat: // Should be called chownat ? --#if defined(__x86_64__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv) - case __NR_newfstatat: // fstatat(). EPERM not a valid errno. - #elif defined(__i386__) || defined(__arm__) || \ - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) -@@ -202,7 +202,7 @@ - case __NR_oldfstat: - #endif - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_sync_file_range: // EPERM not a valid errno. - #elif defined(__arm__) - case __NR_arm_sync_file_range: // EPERM not a valid errno. -@@ -226,7 +226,7 @@ - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR_ftruncate64: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_getdents: // EPERM not a valid errno. - #endif - case __NR_getdents64: // EPERM not a valid errno. -@@ -305,7 +305,7 @@ - bool SyscallSets::IsProcessGroupOrSession(int sysno) { - switch (sysno) { - case __NR_setpgid: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_getpgrp: - #endif - case __NR_setsid: -@@ -334,7 +334,7 @@ - case __NR_rt_sigsuspend: - case __NR_rt_tgsigqueueinfo: - case __NR_sigaltstack: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_signalfd: - #endif - case __NR_signalfd4: -@@ -358,12 +358,12 @@ - switch (sysno) { - case __NR_close: - case __NR_dup: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_dup2: - #endif - case __NR_dup3: - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_shutdown: - #endif - return true; -@@ -402,7 +402,7 @@ - return true; - case __NR_clone: // Should be parameter-restricted. - case __NR_setns: // Privileged. --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_fork: - #endif - #if defined(__i386__) || defined(__x86_64__) -@@ -413,7 +413,7 @@ - #endif - case __NR_set_tid_address: - case __NR_unshare: --#if !defined(__mips__) && !defined(__aarch64__) -+#if !defined(__mips__) && !defined(__aarch64__) && !defined(__riscv) - case __NR_vfork: - #endif - default: -@@ -434,7 +434,7 @@ - - bool SyscallSets::IsAllowedEpoll(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_epoll_create: - case __NR_epoll_wait: - #endif -@@ -455,14 +455,14 @@ - - bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_pipe: - #endif - case __NR_pipe2: - return true; - default: - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_socketpair: // We will want to inspect its argument. - #endif - return false; -@@ -472,7 +472,7 @@ - bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { - switch (sysno) { - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_accept: - case __NR_accept4: - case __NR_bind: -@@ -526,7 +526,7 @@ - case __NR_mincore: - case __NR_mlockall: - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_mmap: - #endif - #if defined(__i386__) || defined(__arm__) || \ -@@ -559,7 +559,7 @@ - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR__llseek: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_poll: - #endif - case __NR_ppoll: -@@ -572,7 +572,7 @@ - case __NR_recv: - #endif - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_recvfrom: // Could specify source. - case __NR_recvmsg: // Could specify source. - #endif -@@ -587,7 +587,7 @@ - case __NR_send: - #endif - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_sendmsg: // Could specify destination. - case __NR_sendto: // Could specify destination. - #endif -@@ -637,7 +637,7 @@ - bool SyscallSets::IsAllowedBasicScheduler(int sysno) { - switch (sysno) { - case __NR_sched_yield: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_pause: - #endif - case __NR_nanosleep: -@@ -721,7 +721,7 @@ - case __NR_getcpu: - case __NR_mbind: - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_migrate_pages: - #endif - case __NR_move_pages: -@@ -750,7 +750,7 @@ - switch (sysno) { - case __NR_acct: // Privileged. - #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - case __NR_getrlimit: - #endif - #if defined(__i386__) || defined(__arm__) -@@ -785,7 +785,7 @@ - - bool SyscallSets::IsGlobalSystemStatus(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR__sysctl: - case __NR_sysfs: - #endif -@@ -803,7 +803,7 @@ - - bool SyscallSets::IsEventFd(int sysno) { - switch (sysno) { --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_eventfd: - #endif - case __NR_eventfd2: -@@ -839,7 +839,8 @@ - } - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - bool SyscallSets::IsSystemVSemaphores(int sysno) { - switch (sysno) { - case __NR_semctl: -@@ -855,7 +856,8 @@ - - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - // These give a lot of ambient authority and bypass the setuid sandbox. - bool SyscallSets::IsSystemVSharedMemory(int sysno) { - switch (sysno) { -@@ -871,7 +873,8 @@ - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - bool SyscallSets::IsSystemVMessageQueue(int sysno) { - switch (sysno) { - case __NR_msgctl: -@@ -902,7 +905,8 @@ - - bool SyscallSets::IsAnySystemV(int sysno) { - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || - IsSystemVSharedMemory(sysno); - #elif defined(__i386__) || \ -@@ -935,7 +939,7 @@ - bool SyscallSets::IsInotify(int sysno) { - switch (sysno) { - case __NR_inotify_add_watch: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_inotify_init: - #endif - case __NR_inotify_init1: -@@ -1066,7 +1070,7 @@ - #if defined(__x86_64__) - case __NR_tuxcall: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_vserver: - #endif - return true; ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h -@@ -49,7 +49,7 @@ - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - static bool IsNetworkSocketInformation(int sysno); - #endif - -@@ -72,18 +72,21 @@ - static bool IsAsyncIo(int sysno); - static bool IsKeyManagement(int sysno); - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - static bool IsSystemVSemaphores(int sysno); - #endif - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ - defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - // These give a lot of ambient authority and bypass the setuid sandbox. - static bool IsSystemVSharedMemory(int sysno); - #endif - - #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ -- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) -+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ -+ defined(__riscv) - static bool IsSystemVMessageQueue(int sysno); - #endif - ---- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc -+++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc -@@ -18,7 +18,7 @@ - namespace { - - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ -- defined(ARCH_CPU_MIPS_FAMILY) -+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) - // Number that's not currently used by any Linux kernel ABIs. - const int kInvalidSyscallNumber = 0x351d3; - #else -@@ -312,6 +312,28 @@ - "2:ret\n" - ".cfi_endproc\n" - ".size SyscallAsm, .-SyscallAsm\n" -+#elif defined(__riscv) -+ ".text\n" -+ ".align 2\n" -+ ".type SyscallAsm, %function\n" -+ "SyscallAsm:\n" -+ ".cfi_startproc\n" -+ "bgez a0,1f\n" -+ "la a0,2f\n" -+ "j 2f\n" -+ "1:mv a7, a0\n" -+ "ld a0, (t0)\n" -+ "ld a1, 8(t0)\n" -+ "ld a2, 16(t0)\n" -+ "ld a3, 24(t0)\n" -+ "ld a4, 32(t0)\n" -+ "ld a5, 40(t0)\n" -+ "ld a6, 48(t0)\n" -+ // Enter the kernel -+ "scall\n" -+ "2:ret\n" -+ ".cfi_endproc\n" -+ ".size SyscallAsm, .-SyscallAsm\n" - #endif - ); // asm - -@@ -429,6 +451,18 @@ - ret = inout; - } - -+#elif defined(__riscv) -+ intptr_t ret; -+ { -+ register intptr_t inout __asm__("a0") = nr; -+ register const intptr_t* data __asm__("t0") = args; -+ asm volatile("jal SyscallAsm\n" -+ : "+r"(inout) -+ : "r"(data) -+ : "memory", "a1", "a2", "a3", "a4", "a5", "a6"); -+ ret = inout; -+ } -+ - #else - #error "Unimplemented architecture" - #endif ---- a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc -+++ b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc -@@ -81,7 +81,7 @@ - pid_t pid = -1; - alignas(16) char stack_buf[PTHREAD_STACK_MIN]; - #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ -- defined(ARCH_CPU_MIPS_FAMILY) -+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) - // The stack grows downward. - void* stack = stack_buf + sizeof(stack_buf); - #else ---- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc -+++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc -@@ -128,43 +128,43 @@ - // and are default disabled in Android. So, we should refuse to broker them - // to be consistent with the platform's restrictions. - switch (sysno) { --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_access: - #endif - case __NR_faccessat: - return !fast_check || allowed_command_set_.test(COMMAND_ACCESS); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_mkdir: - #endif - case __NR_mkdirat: - return !fast_check || allowed_command_set_.test(COMMAND_MKDIR); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_open: - #endif - case __NR_openat: - return !fast_check || allowed_command_set_.test(COMMAND_OPEN); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_readlink: - #endif - case __NR_readlinkat: - return !fast_check || allowed_command_set_.test(COMMAND_READLINK); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_rename: - #endif - case __NR_renameat: - case __NR_renameat2: - return !fast_check || allowed_command_set_.test(COMMAND_RENAME); - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_rmdir: - return !fast_check || allowed_command_set_.test(COMMAND_RMDIR); - #endif - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_stat: - case __NR_lstat: - #endif -@@ -174,7 +174,7 @@ - #if defined(__NR_fstatat64) - case __NR_fstatat64: - #endif --#if defined(__x86_64__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv) - case __NR_newfstatat: - #endif - return !fast_check || allowed_command_set_.test(COMMAND_STAT); -@@ -189,7 +189,7 @@ - return !fast_check || allowed_command_set_.test(COMMAND_STAT); - #endif - --#if !defined(__aarch64__) && !defined(OS_ANDROID) -+#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) - case __NR_unlink: - return !fast_check || allowed_command_set_.test(COMMAND_UNLINK); - #endif ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h -@@ -41,6 +41,9 @@ - #ifndef EM_AARCH64 - #define EM_AARCH64 183 - #endif -+#ifndef EM_RISCV -+#define EM_RISCV 243 -+#endif - - #ifndef __AUDIT_ARCH_64BIT - #define __AUDIT_ARCH_64BIT 0x80000000 -@@ -73,6 +76,9 @@ - #ifndef AUDIT_ARCH_AARCH64 - #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) - #endif -+#ifndef AUDIT_ARCH_RISCV64 -+#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) -+#endif - - // For prctl.h - #ifndef PR_SET_SECCOMP ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h -@@ -13,7 +13,7 @@ - // (not undefined, but defined different values and in different memory - // layouts). So, fill the gap here. - #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ -- defined(__aarch64__) -+ defined(__aarch64__) || defined(__riscv) - - #define LINUX_SIGHUP 1 - #define LINUX_SIGINT 2 ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h -@@ -150,7 +150,7 @@ - int st_blocks; - int st_pad4[14]; - }; --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__riscv) - struct kernel_stat { - unsigned long st_dev; - unsigned long st_ino; ---- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h -@@ -35,5 +35,9 @@ - #include "sandbox/linux/system_headers/arm64_linux_syscalls.h" - #endif - -+#if defined(__riscv) && __riscv_xlen == 64 -+#include "sandbox/linux/system_headers/riscv64_linux_syscalls.h" -+#endif -+ - #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_ - ---- /dev/null -+++ b/src/3rdparty/chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h -@@ -0,0 +1,1066 @@ -+// Copyright 2014 The Chromium Authors. All rights reserved. -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ -+#define SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ -+ -+#include -+ -+#if !defined(__NR_io_setup) -+#define __NR_io_setup 0 -+#endif -+ -+#if !defined(__NR_io_destroy) -+#define __NR_io_destroy 1 -+#endif -+ -+#if !defined(__NR_io_submit) -+#define __NR_io_submit 2 -+#endif -+ -+#if !defined(__NR_io_cancel) -+#define __NR_io_cancel 3 -+#endif -+ -+#if !defined(__NR_io_getevents) -+#define __NR_io_getevents 4 -+#endif -+ -+#if !defined(__NR_setxattr) -+#define __NR_setxattr 5 -+#endif -+ -+#if !defined(__NR_lsetxattr) -+#define __NR_lsetxattr 6 -+#endif -+ -+#if !defined(__NR_fsetxattr) -+#define __NR_fsetxattr 7 -+#endif -+ -+#if !defined(__NR_getxattr) -+#define __NR_getxattr 8 -+#endif -+ -+#if !defined(__NR_lgetxattr) -+#define __NR_lgetxattr 9 -+#endif -+ -+#if !defined(__NR_fgetxattr) -+#define __NR_fgetxattr 10 -+#endif -+ -+#if !defined(__NR_listxattr) -+#define __NR_listxattr 11 -+#endif -+ -+#if !defined(__NR_llistxattr) -+#define __NR_llistxattr 12 -+#endif -+ -+#if !defined(__NR_flistxattr) -+#define __NR_flistxattr 13 -+#endif -+ -+#if !defined(__NR_removexattr) -+#define __NR_removexattr 14 -+#endif -+ -+#if !defined(__NR_lremovexattr) -+#define __NR_lremovexattr 15 -+#endif -+ -+#if !defined(__NR_fremovexattr) -+#define __NR_fremovexattr 16 -+#endif -+ -+#if !defined(__NR_getcwd) -+#define __NR_getcwd 17 -+#endif -+ -+#if !defined(__NR_lookup_dcookie) -+#define __NR_lookup_dcookie 18 -+#endif -+ -+#if !defined(__NR_eventfd2) -+#define __NR_eventfd2 19 -+#endif -+ -+#if !defined(__NR_epoll_create1) -+#define __NR_epoll_create1 20 -+#endif -+ -+#if !defined(__NR_epoll_ctl) -+#define __NR_epoll_ctl 21 -+#endif -+ -+#if !defined(__NR_epoll_pwait) -+#define __NR_epoll_pwait 22 -+#endif -+ -+#if !defined(__NR_dup) -+#define __NR_dup 23 -+#endif -+ -+#if !defined(__NR_dup3) -+#define __NR_dup3 24 -+#endif -+ -+#if !defined(__NR_fcntl) -+#define __NR_fcntl 25 -+#endif -+ -+#if !defined(__NR_inotify_init1) -+#define __NR_inotify_init1 26 -+#endif -+ -+#if !defined(__NR_inotify_add_watch) -+#define __NR_inotify_add_watch 27 -+#endif -+ -+#if !defined(__NR_inotify_rm_watch) -+#define __NR_inotify_rm_watch 28 -+#endif -+ -+#if !defined(__NR_ioctl) -+#define __NR_ioctl 29 -+#endif -+ -+#if !defined(__NR_ioprio_set) -+#define __NR_ioprio_set 30 -+#endif -+ -+#if !defined(__NR_ioprio_get) -+#define __NR_ioprio_get 31 -+#endif -+ -+#if !defined(__NR_flock) -+#define __NR_flock 32 -+#endif -+ -+#if !defined(__NR_mknodat) -+#define __NR_mknodat 33 -+#endif -+ -+#if !defined(__NR_mkdirat) -+#define __NR_mkdirat 34 -+#endif -+ -+#if !defined(__NR_unlinkat) -+#define __NR_unlinkat 35 -+#endif -+ -+#if !defined(__NR_symlinkat) -+#define __NR_symlinkat 36 -+#endif -+ -+#if !defined(__NR_linkat) -+#define __NR_linkat 37 -+#endif -+ -+#if !defined(__NR_renameat) -+#define __NR_renameat 38 -+#endif -+ -+#if !defined(__NR_umount2) -+#define __NR_umount2 39 -+#endif -+ -+#if !defined(__NR_mount) -+#define __NR_mount 40 -+#endif -+ -+#if !defined(__NR_pivot_root) -+#define __NR_pivot_root 41 -+#endif -+ -+#if !defined(__NR_nfsservctl) -+#define __NR_nfsservctl 42 -+#endif -+ -+#if !defined(__NR_statfs) -+#define __NR_statfs 43 -+#endif -+ -+#if !defined(__NR_fstatfs) -+#define __NR_fstatfs 44 -+#endif -+ -+#if !defined(__NR_truncate) -+#define __NR_truncate 45 -+#endif -+ -+#if !defined(__NR_ftruncate) -+#define __NR_ftruncate 46 -+#endif -+ -+#if !defined(__NR_fallocate) -+#define __NR_fallocate 47 -+#endif -+ -+#if !defined(__NR_faccessat) -+#define __NR_faccessat 48 -+#endif -+ -+#if !defined(__NR_chdir) -+#define __NR_chdir 49 -+#endif -+ -+#if !defined(__NR_fchdir) -+#define __NR_fchdir 50 -+#endif -+ -+#if !defined(__NR_chroot) -+#define __NR_chroot 51 -+#endif -+ -+#if !defined(__NR_fchmod) -+#define __NR_fchmod 52 -+#endif -+ -+#if !defined(__NR_fchmodat) -+#define __NR_fchmodat 53 -+#endif -+ -+#if !defined(__NR_fchownat) -+#define __NR_fchownat 54 -+#endif -+ -+#if !defined(__NR_fchown) -+#define __NR_fchown 55 -+#endif -+ -+#if !defined(__NR_openat) -+#define __NR_openat 56 -+#endif -+ -+#if !defined(__NR_close) -+#define __NR_close 57 -+#endif -+ -+#if !defined(__NR_vhangup) -+#define __NR_vhangup 58 -+#endif -+ -+#if !defined(__NR_pipe2) -+#define __NR_pipe2 59 -+#endif -+ -+#if !defined(__NR_quotactl) -+#define __NR_quotactl 60 -+#endif -+ -+#if !defined(__NR_getdents64) -+#define __NR_getdents64 61 -+#endif -+ -+#if !defined(__NR_lseek) -+#define __NR_lseek 62 -+#endif -+ -+#if !defined(__NR_read) -+#define __NR_read 63 -+#endif -+ -+#if !defined(__NR_write) -+#define __NR_write 64 -+#endif -+ -+#if !defined(__NR_readv) -+#define __NR_readv 65 -+#endif -+ -+#if !defined(__NR_writev) -+#define __NR_writev 66 -+#endif -+ -+#if !defined(__NR_pread64) -+#define __NR_pread64 67 -+#endif -+ -+#if !defined(__NR_pwrite64) -+#define __NR_pwrite64 68 -+#endif -+ -+#if !defined(__NR_preadv) -+#define __NR_preadv 69 -+#endif -+ -+#if !defined(__NR_pwritev) -+#define __NR_pwritev 70 -+#endif -+ -+#if !defined(__NR_sendfile) -+#define __NR_sendfile 71 -+#endif -+ -+#if !defined(__NR_pselect6) -+#define __NR_pselect6 72 -+#endif -+ -+#if !defined(__NR_ppoll) -+#define __NR_ppoll 73 -+#endif -+ -+#if !defined(__NR_signalfd4) -+#define __NR_signalfd4 74 -+#endif -+ -+#if !defined(__NR_vmsplice) -+#define __NR_vmsplice 75 -+#endif -+ -+#if !defined(__NR_splice) -+#define __NR_splice 76 -+#endif -+ -+#if !defined(__NR_tee) -+#define __NR_tee 77 -+#endif -+ -+#if !defined(__NR_readlinkat) -+#define __NR_readlinkat 78 -+#endif -+ -+#if !defined(__NR_newfstatat) -+#define __NR_newfstatat 79 -+#endif -+ -+#if !defined(__NR_fstat) -+#define __NR_fstat 80 -+#endif -+ -+#if !defined(__NR_sync) -+#define __NR_sync 81 -+#endif -+ -+#if !defined(__NR_fsync) -+#define __NR_fsync 82 -+#endif -+ -+#if !defined(__NR_fdatasync) -+#define __NR_fdatasync 83 -+#endif -+ -+#if !defined(__NR_sync_file_range) -+#define __NR_sync_file_range 84 -+#endif -+ -+#if !defined(__NR_timerfd_create) -+#define __NR_timerfd_create 85 -+#endif -+ -+#if !defined(__NR_timerfd_settime) -+#define __NR_timerfd_settime 86 -+#endif -+ -+#if !defined(__NR_timerfd_gettime) -+#define __NR_timerfd_gettime 87 -+#endif -+ -+#if !defined(__NR_utimensat) -+#define __NR_utimensat 88 -+#endif -+ -+#if !defined(__NR_acct) -+#define __NR_acct 89 -+#endif -+ -+#if !defined(__NR_capget) -+#define __NR_capget 90 -+#endif -+ -+#if !defined(__NR_capset) -+#define __NR_capset 91 -+#endif -+ -+#if !defined(__NR_personality) -+#define __NR_personality 92 -+#endif -+ -+#if !defined(__NR_exit) -+#define __NR_exit 93 -+#endif -+ -+#if !defined(__NR_exit_group) -+#define __NR_exit_group 94 -+#endif -+ -+#if !defined(__NR_waitid) -+#define __NR_waitid 95 -+#endif -+ -+#if !defined(__NR_set_tid_address) -+#define __NR_set_tid_address 96 -+#endif -+ -+#if !defined(__NR_unshare) -+#define __NR_unshare 97 -+#endif -+ -+#if !defined(__NR_futex) -+#define __NR_futex 98 -+#endif -+ -+#if !defined(__NR_set_robust_list) -+#define __NR_set_robust_list 99 -+#endif -+ -+#if !defined(__NR_get_robust_list) -+#define __NR_get_robust_list 100 -+#endif -+ -+#if !defined(__NR_nanosleep) -+#define __NR_nanosleep 101 -+#endif -+ -+#if !defined(__NR_getitimer) -+#define __NR_getitimer 102 -+#endif -+ -+#if !defined(__NR_setitimer) -+#define __NR_setitimer 103 -+#endif -+ -+#if !defined(__NR_kexec_load) -+#define __NR_kexec_load 104 -+#endif -+ -+#if !defined(__NR_init_module) -+#define __NR_init_module 105 -+#endif -+ -+#if !defined(__NR_delete_module) -+#define __NR_delete_module 106 -+#endif -+ -+#if !defined(__NR_timer_create) -+#define __NR_timer_create 107 -+#endif -+ -+#if !defined(__NR_timer_gettime) -+#define __NR_timer_gettime 108 -+#endif -+ -+#if !defined(__NR_timer_getoverrun) -+#define __NR_timer_getoverrun 109 -+#endif -+ -+#if !defined(__NR_timer_settime) -+#define __NR_timer_settime 110 -+#endif -+ -+#if !defined(__NR_timer_delete) -+#define __NR_timer_delete 111 -+#endif -+ -+#if !defined(__NR_clock_settime) -+#define __NR_clock_settime 112 -+#endif -+ -+#if !defined(__NR_clock_gettime) -+#define __NR_clock_gettime 113 -+#endif -+ -+#if !defined(__NR_clock_getres) -+#define __NR_clock_getres 114 -+#endif -+ -+#if !defined(__NR_clock_nanosleep) -+#define __NR_clock_nanosleep 115 -+#endif -+ -+#if !defined(__NR_syslog) -+#define __NR_syslog 116 -+#endif -+ -+#if !defined(__NR_ptrace) -+#define __NR_ptrace 117 -+#endif -+ -+#if !defined(__NR_sched_setparam) -+#define __NR_sched_setparam 118 -+#endif -+ -+#if !defined(__NR_sched_setscheduler) -+#define __NR_sched_setscheduler 119 -+#endif -+ -+#if !defined(__NR_sched_getscheduler) -+#define __NR_sched_getscheduler 120 -+#endif -+ -+#if !defined(__NR_sched_getparam) -+#define __NR_sched_getparam 121 -+#endif -+ -+#if !defined(__NR_sched_setaffinity) -+#define __NR_sched_setaffinity 122 -+#endif -+ -+#if !defined(__NR_sched_getaffinity) -+#define __NR_sched_getaffinity 123 -+#endif -+ -+#if !defined(__NR_sched_yield) -+#define __NR_sched_yield 124 -+#endif -+ -+#if !defined(__NR_sched_get_priority_max) -+#define __NR_sched_get_priority_max 125 -+#endif -+ -+#if !defined(__NR_sched_get_priority_min) -+#define __NR_sched_get_priority_min 126 -+#endif -+ -+#if !defined(__NR_sched_rr_get_interval) -+#define __NR_sched_rr_get_interval 127 -+#endif -+ -+#if !defined(__NR_restart_syscall) -+#define __NR_restart_syscall 128 -+#endif -+ -+#if !defined(__NR_kill) -+#define __NR_kill 129 -+#endif -+ -+#if !defined(__NR_tkill) -+#define __NR_tkill 130 -+#endif -+ -+#if !defined(__NR_tgkill) -+#define __NR_tgkill 131 -+#endif -+ -+#if !defined(__NR_sigaltstack) -+#define __NR_sigaltstack 132 -+#endif -+ -+#if !defined(__NR_rt_sigsuspend) -+#define __NR_rt_sigsuspend 133 -+#endif -+ -+#if !defined(__NR_rt_sigaction) -+#define __NR_rt_sigaction 134 -+#endif -+ -+#if !defined(__NR_rt_sigprocmask) -+#define __NR_rt_sigprocmask 135 -+#endif -+ -+#if !defined(__NR_rt_sigpending) -+#define __NR_rt_sigpending 136 -+#endif -+ -+#if !defined(__NR_rt_sigtimedwait) -+#define __NR_rt_sigtimedwait 137 -+#endif -+ -+#if !defined(__NR_rt_sigqueueinfo) -+#define __NR_rt_sigqueueinfo 138 -+#endif -+ -+#if !defined(__NR_rt_sigreturn) -+#define __NR_rt_sigreturn 139 -+#endif -+ -+#if !defined(__NR_setpriority) -+#define __NR_setpriority 140 -+#endif -+ -+#if !defined(__NR_getpriority) -+#define __NR_getpriority 141 -+#endif -+ -+#if !defined(__NR_reboot) -+#define __NR_reboot 142 -+#endif -+ -+#if !defined(__NR_setregid) -+#define __NR_setregid 143 -+#endif -+ -+#if !defined(__NR_setgid) -+#define __NR_setgid 144 -+#endif -+ -+#if !defined(__NR_setreuid) -+#define __NR_setreuid 145 -+#endif -+ -+#if !defined(__NR_setuid) -+#define __NR_setuid 146 -+#endif -+ -+#if !defined(__NR_setresuid) -+#define __NR_setresuid 147 -+#endif -+ -+#if !defined(__NR_getresuid) -+#define __NR_getresuid 148 -+#endif -+ -+#if !defined(__NR_setresgid) -+#define __NR_setresgid 149 -+#endif -+ -+#if !defined(__NR_getresgid) -+#define __NR_getresgid 150 -+#endif -+ -+#if !defined(__NR_setfsuid) -+#define __NR_setfsuid 151 -+#endif -+ -+#if !defined(__NR_setfsgid) -+#define __NR_setfsgid 152 -+#endif -+ -+#if !defined(__NR_times) -+#define __NR_times 153 -+#endif -+ -+#if !defined(__NR_setpgid) -+#define __NR_setpgid 154 -+#endif -+ -+#if !defined(__NR_getpgid) -+#define __NR_getpgid 155 -+#endif -+ -+#if !defined(__NR_getsid) -+#define __NR_getsid 156 -+#endif -+ -+#if !defined(__NR_setsid) -+#define __NR_setsid 157 -+#endif -+ -+#if !defined(__NR_getgroups) -+#define __NR_getgroups 158 -+#endif -+ -+#if !defined(__NR_setgroups) -+#define __NR_setgroups 159 -+#endif -+ -+#if !defined(__NR_uname) -+#define __NR_uname 160 -+#endif -+ -+#if !defined(__NR_sethostname) -+#define __NR_sethostname 161 -+#endif -+ -+#if !defined(__NR_setdomainname) -+#define __NR_setdomainname 162 -+#endif -+ -+#if !defined(__NR_getrlimit) -+#define __NR_getrlimit 163 -+#endif -+ -+#if !defined(__NR_setrlimit) -+#define __NR_setrlimit 164 -+#endif -+ -+#if !defined(__NR_getrusage) -+#define __NR_getrusage 165 -+#endif -+ -+#if !defined(__NR_umask) -+#define __NR_umask 166 -+#endif -+ -+#if !defined(__NR_prctl) -+#define __NR_prctl 167 -+#endif -+ -+#if !defined(__NR_getcpu) -+#define __NR_getcpu 168 -+#endif -+ -+#if !defined(__NR_gettimeofday) -+#define __NR_gettimeofday 169 -+#endif -+ -+#if !defined(__NR_settimeofday) -+#define __NR_settimeofday 170 -+#endif -+ -+#if !defined(__NR_adjtimex) -+#define __NR_adjtimex 171 -+#endif -+ -+#if !defined(__NR_getpid) -+#define __NR_getpid 172 -+#endif -+ -+#if !defined(__NR_getppid) -+#define __NR_getppid 173 -+#endif -+ -+#if !defined(__NR_getuid) -+#define __NR_getuid 174 -+#endif -+ -+#if !defined(__NR_geteuid) -+#define __NR_geteuid 175 -+#endif -+ -+#if !defined(__NR_getgid) -+#define __NR_getgid 176 -+#endif -+ -+#if !defined(__NR_getegid) -+#define __NR_getegid 177 -+#endif -+ -+#if !defined(__NR_gettid) -+#define __NR_gettid 178 -+#endif -+ -+#if !defined(__NR_sysinfo) -+#define __NR_sysinfo 179 -+#endif -+ -+#if !defined(__NR_mq_open) -+#define __NR_mq_open 180 -+#endif -+ -+#if !defined(__NR_mq_unlink) -+#define __NR_mq_unlink 181 -+#endif -+ -+#if !defined(__NR_mq_timedsend) -+#define __NR_mq_timedsend 182 -+#endif -+ -+#if !defined(__NR_mq_timedreceive) -+#define __NR_mq_timedreceive 183 -+#endif -+ -+#if !defined(__NR_mq_notify) -+#define __NR_mq_notify 184 -+#endif -+ -+#if !defined(__NR_mq_getsetattr) -+#define __NR_mq_getsetattr 185 -+#endif -+ -+#if !defined(__NR_msgget) -+#define __NR_msgget 186 -+#endif -+ -+#if !defined(__NR_msgctl) -+#define __NR_msgctl 187 -+#endif -+ -+#if !defined(__NR_msgrcv) -+#define __NR_msgrcv 188 -+#endif -+ -+#if !defined(__NR_msgsnd) -+#define __NR_msgsnd 189 -+#endif -+ -+#if !defined(__NR_semget) -+#define __NR_semget 190 -+#endif -+ -+#if !defined(__NR_semctl) -+#define __NR_semctl 191 -+#endif -+ -+#if !defined(__NR_semtimedop) -+#define __NR_semtimedop 192 -+#endif -+ -+#if !defined(__NR_semop) -+#define __NR_semop 193 -+#endif -+ -+#if !defined(__NR_shmget) -+#define __NR_shmget 194 -+#endif -+ -+#if !defined(__NR_shmctl) -+#define __NR_shmctl 195 -+#endif -+ -+#if !defined(__NR_shmat) -+#define __NR_shmat 196 -+#endif -+ -+#if !defined(__NR_shmdt) -+#define __NR_shmdt 197 -+#endif -+ -+#if !defined(__NR_socket) -+#define __NR_socket 198 -+#endif -+ -+#if !defined(__NR_socketpair) -+#define __NR_socketpair 199 -+#endif -+ -+#if !defined(__NR_bind) -+#define __NR_bind 200 -+#endif -+ -+#if !defined(__NR_listen) -+#define __NR_listen 201 -+#endif -+ -+#if !defined(__NR_accept) -+#define __NR_accept 202 -+#endif -+ -+#if !defined(__NR_connect) -+#define __NR_connect 203 -+#endif -+ -+#if !defined(__NR_getsockname) -+#define __NR_getsockname 204 -+#endif -+ -+#if !defined(__NR_getpeername) -+#define __NR_getpeername 205 -+#endif -+ -+#if !defined(__NR_sendto) -+#define __NR_sendto 206 -+#endif -+ -+#if !defined(__NR_recvfrom) -+#define __NR_recvfrom 207 -+#endif -+ -+#if !defined(__NR_setsockopt) -+#define __NR_setsockopt 208 -+#endif -+ -+#if !defined(__NR_getsockopt) -+#define __NR_getsockopt 209 -+#endif -+ -+#if !defined(__NR_shutdown) -+#define __NR_shutdown 210 -+#endif -+ -+#if !defined(__NR_sendmsg) -+#define __NR_sendmsg 211 -+#endif -+ -+#if !defined(__NR_recvmsg) -+#define __NR_recvmsg 212 -+#endif -+ -+#if !defined(__NR_readahead) -+#define __NR_readahead 213 -+#endif -+ -+#if !defined(__NR_brk) -+#define __NR_brk 214 -+#endif -+ -+#if !defined(__NR_munmap) -+#define __NR_munmap 215 -+#endif -+ -+#if !defined(__NR_mremap) -+#define __NR_mremap 216 -+#endif -+ -+#if !defined(__NR_add_key) -+#define __NR_add_key 217 -+#endif -+ -+#if !defined(__NR_request_key) -+#define __NR_request_key 218 -+#endif -+ -+#if !defined(__NR_keyctl) -+#define __NR_keyctl 219 -+#endif -+ -+#if !defined(__NR_clone) -+#define __NR_clone 220 -+#endif -+ -+#if !defined(__NR_execve) -+#define __NR_execve 221 -+#endif -+ -+#if !defined(__NR_mmap) -+#define __NR_mmap 222 -+#endif -+ -+#if !defined(__NR_fadvise64) -+#define __NR_fadvise64 223 -+#endif -+ -+#if !defined(__NR_swapon) -+#define __NR_swapon 224 -+#endif -+ -+#if !defined(__NR_swapoff) -+#define __NR_swapoff 225 -+#endif -+ -+#if !defined(__NR_mprotect) -+#define __NR_mprotect 226 -+#endif -+ -+#if !defined(__NR_msync) -+#define __NR_msync 227 -+#endif -+ -+#if !defined(__NR_mlock) -+#define __NR_mlock 228 -+#endif -+ -+#if !defined(__NR_munlock) -+#define __NR_munlock 229 -+#endif -+ -+#if !defined(__NR_mlockall) -+#define __NR_mlockall 230 -+#endif -+ -+#if !defined(__NR_munlockall) -+#define __NR_munlockall 231 -+#endif -+ -+#if !defined(__NR_mincore) -+#define __NR_mincore 232 -+#endif -+ -+#if !defined(__NR_madvise) -+#define __NR_madvise 233 -+#endif -+ -+#if !defined(__NR_remap_file_pages) -+#define __NR_remap_file_pages 234 -+#endif -+ -+#if !defined(__NR_mbind) -+#define __NR_mbind 235 -+#endif -+ -+#if !defined(__NR_get_mempolicy) -+#define __NR_get_mempolicy 236 -+#endif -+ -+#if !defined(__NR_set_mempolicy) -+#define __NR_set_mempolicy 237 -+#endif -+ -+#if !defined(__NR_migrate_pages) -+#define __NR_migrate_pages 238 -+#endif -+ -+#if !defined(__NR_move_pages) -+#define __NR_move_pages 239 -+#endif -+ -+#if !defined(__NR_rt_tgsigqueueinfo) -+#define __NR_rt_tgsigqueueinfo 240 -+#endif -+ -+#if !defined(__NR_perf_event_open) -+#define __NR_perf_event_open 241 -+#endif -+ -+#if !defined(__NR_accept4) -+#define __NR_accept4 242 -+#endif -+ -+#if !defined(__NR_recvmmsg) -+#define __NR_recvmmsg 243 -+#endif -+ -+#if !defined(__NR_wait4) -+#define __NR_wait4 260 -+#endif -+ -+#if !defined(__NR_prlimit64) -+#define __NR_prlimit64 261 -+#endif -+ -+#if !defined(__NR_fanotify_init) -+#define __NR_fanotify_init 262 -+#endif -+ -+#if !defined(__NR_fanotify_mark) -+#define __NR_fanotify_mark 263 -+#endif -+ -+#if !defined(__NR_name_to_handle_at) -+#define __NR_name_to_handle_at 264 -+#endif -+ -+#if !defined(__NR_open_by_handle_at) -+#define __NR_open_by_handle_at 265 -+#endif -+ -+#if !defined(__NR_clock_adjtime) -+#define __NR_clock_adjtime 266 -+#endif -+ -+#if !defined(__NR_syncfs) -+#define __NR_syncfs 267 -+#endif -+ -+#if !defined(__NR_setns) -+#define __NR_setns 268 -+#endif -+ -+#if !defined(__NR_sendmmsg) -+#define __NR_sendmmsg 269 -+#endif -+ -+#if !defined(__NR_process_vm_readv) -+#define __NR_process_vm_readv 270 -+#endif -+ -+#if !defined(__NR_process_vm_writev) -+#define __NR_process_vm_writev 271 -+#endif -+ -+#if !defined(__NR_kcmp) -+#define __NR_kcmp 272 -+#endif -+ -+#if !defined(__NR_finit_module) -+#define __NR_finit_module 273 -+#endif -+ -+#if !defined(__NR_sched_setattr) -+#define __NR_sched_setattr 274 -+#endif -+ -+#if !defined(__NR_sched_getattr) -+#define __NR_sched_getattr 275 -+#endif -+ -+#if !defined(__NR_renameat2) -+#define __NR_renameat2 276 -+#endif -+ -+#if !defined(__NR_seccomp) -+#define __NR_seccomp 277 -+#endif -+ -+#if !defined(__NR_getrandom) -+#define __NR_getrandom 278 -+#endif -+ -+#if !defined(__NR_memfd_create) -+#define __NR_memfd_create 279 -+#endif -+ -+#endif // SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ ---- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc -@@ -38,7 +38,7 @@ - case __NR_sched_setscheduler: - case __NR_sysinfo: - case __NR_uname: --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_readlink: - case __NR_stat: - #endif ---- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -+++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc -@@ -70,7 +70,7 @@ - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) - case __NR_ftruncate64: - #endif --#if !defined(__aarch64__) -+#if !defined(__aarch64__) && !defined(__riscv) - case __NR_getdents: - #endif - case __NR_getdents64: ---- a/src/3rdparty/chromium/sandbox/policy/linux/sandbox_seccomp_bpf_linux.cc -+++ b/src/3rdparty/chromium/sandbox/policy/linux/sandbox_seccomp_bpf_linux.cc -@@ -64,7 +64,7 @@ - - // Make sure that seccomp-bpf does not get disabled by mistake. Also make sure - // that we think twice about this when adding a new architecture. --#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) -+#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) && !defined(ARCH_CPU_RISCV64) - #error "Seccomp-bpf disabled on supported architecture!" - #endif // !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) - ---- a/src/3rdparty/chromium/skia/BUILD.gn -+++ b/src/3rdparty/chromium/skia/BUILD.gn -@@ -821,6 +821,8 @@ - sources = skia_opts.none_sources - } else if (current_cpu == "s390x") { - sources = skia_opts.none_sources -+ } else if (current_cpu == "riscv64") { -+ sources = skia_opts.none_sources - } else { - assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp") - } ---- a/src/3rdparty/chromium/third_party/angle/gni/angle.gni -+++ b/src/3rdparty/chromium/third_party/angle/gni/angle.gni -@@ -54,7 +54,7 @@ - declare_args() { - if (current_cpu == "arm64" || current_cpu == "x64" || - current_cpu == "mips64el" || current_cpu == "s390x" || -- current_cpu == "ppc64") { -+ current_cpu == "ppc64" || current_cpu == "riscv64") { - angle_64bit_current_cpu = true - } else if (current_cpu == "arm" || current_cpu == "x86" || - current_cpu == "mipsel" || current_cpu == "s390" || ---- a/src/3rdparty/chromium/third_party/angle/include/platform/PlatformMethods.h -+++ b/src/3rdparty/chromium/third_party/angle/include/platform/PlatformMethods.h -@@ -9,6 +9,7 @@ - #ifndef ANGLE_PLATFORMMETHODS_H - #define ANGLE_PLATFORMMETHODS_H - -+#include - #include - #include - #include ---- a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn -@@ -38,6 +38,8 @@ - sources = [ "SaveRegisters_mips64.S" ] - } else if (current_cpu == "ppc64") { - sources = [ "SaveRegisters_ppc64.S" ] -+ } else if (current_cpu == "riscv64") { -+ sources = [ "SaveRegisters_riscv64.S" ] - } - - if (current_cpu == "arm") { ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S -@@ -0,0 +1,45 @@ -+/* -+ * typedef void (*PushAllRegistersCallback)(ThreadState*, intptr_t*); -+ * extern "C" void PushAllRegisters(ThreadState*, PushAllRegistersCallback) -+ */ -+ -+.type PushAllRegisters, %function -+.global PushAllRegisters -+.hidden PushAllRegisters -+PushAllRegisters: -+ /* Push all callee-saves registers to get them -+ * on the stack for conservative stack scanning. -+ * Reserve space for callee-saved registers and return address. -+ */ -+ addi sp,sp,-112 -+ /* Save the callee-saved registers and the return address. */ -+ sd ra,0(sp) -+ sd s0,8(sp) -+ sd s1,16(sp) -+ sd s2,24(sp) -+ sd s3,32(sp) -+ sd s4,40(sp) -+ sd s5,48(sp) -+ sd s6,56(sp) -+ sd s7,64(sp) -+ sd s8,72(sp) -+ sd s9,80(sp) -+ sd s10,88(sp) -+ sd s11,96(sp) -+ /* Note: the callee-saved floating point registers do not need to be -+ * copied to the stack, because fp registers never hold heap pointers -+ * and so do not need to be kept visible to the garbage collector. -+ * Pass the first argument untouched in a0 and the -+ * stack pointer to the callback. -+ */ -+ mv ra,a1 -+ mv a1,sp -+ jalr ra -+ /* Restore return address, adjust stack and return. -+ * Note: the copied registers do not need to be reloaded here, -+ * because they were preserved by the called routine. -+ */ -+ ld ra,0(sp) -+ addi sp,sp,112 -+ ret -+.size PushAllRegisters, . - PushAllRegisters ---- a/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h -+++ b/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h -@@ -114,6 +114,8 @@ - #define OPENSSL_32_BIT - #elif defined(__myriad2__) - #define OPENSSL_32_BIT -+#elif defined(__riscv) && __riscv_xlen == 64 -+#define OPENSSL_64_BIT - #else - // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, - // little-endian architectures. Functions will not produce the correct answer ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h -@@ -44,6 +44,8 @@ - typedef MDRawContextARM64_Old RawContextCPU; - #elif defined(__mips__) - typedef MDRawContextMIPS RawContextCPU; -+#elif defined(__riscv) -+typedef MDRawContextRISCV64 RawContextCPU; - #else - #error "This code has not been ported to your platform yet." - #endif ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc -@@ -270,7 +270,23 @@ - out->float_save.fir = mcontext.fpc_eir; - #endif - } --#endif // __mips__ -+#elif defined(__riscv) -+ -+uintptr_t ThreadInfo::GetInstructionPointer() const { -+ return mcontext.__gregs[REG_PC]; -+} -+ -+void ThreadInfo::FillCPUContext(RawContextCPU* out) const { -+ out->context_flags = MD_CONTEXT_RISCV64_FULL; -+ -+ my_memcpy (out->iregs, mcontext.__gregs, MD_CONTEXT_RISCV64_GPR_COUNT * 8); -+ -+ out->float_save.fcsr = mcontext.__fpregs.__d.__fcsr; -+ my_memcpy(&out->float_save.regs, &mcontext.__fpregs.__d.__f, -+ MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT * 8); -+} -+ -+#endif // __riscv - - void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) { - assert(gp_regs || size); -@@ -279,6 +295,11 @@ - *gp_regs = mcontext.gregs; - if (size) - *size = sizeof(mcontext.gregs); -+#elif defined(__riscv) -+ if (gp_regs) -+ *gp_regs = mcontext.__gregs; -+ if (size) -+ *size = sizeof(mcontext.__gregs); - #else - if (gp_regs) - *gp_regs = ®s; -@@ -294,6 +315,11 @@ - *fp_regs = &mcontext.fpregs; - if (size) - *size = sizeof(mcontext.fpregs); -+#elif defined(__riscv) -+ if (fp_regs) -+ *fp_regs = &mcontext.__fpregs; -+ if (size) -+ *size = sizeof(mcontext.__fpregs); - #else - if (fp_regs) - *fp_regs = &fpregs; ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h -@@ -68,7 +68,7 @@ - // Use the structures defined in - struct user_regs_struct regs; - struct user_fpsimd_struct fpregs; --#elif defined(__mips__) -+#elif defined(__mips__) || defined(__riscv) - // Use the structure defined in . - mcontext_t mcontext; - #endif ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc -@@ -461,7 +461,7 @@ - memcpy(&g_crash_context_.float_state, fp_ptr, - sizeof(g_crash_context_.float_state)); - } --#elif !defined(__ARM_EABI__) && !defined(__mips__) -+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - // FP state is not part of user ABI on ARM Linux. - // In case of MIPS Linux FP state is already part of ucontext_t - // and 'float_state' is not a member of CrashContext. -@@ -701,7 +701,7 @@ - } - #endif - --#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__riscv) - // FPU state is not part of ARM EABI ucontext_t. - memcpy(&context.float_state, context.context.uc_mcontext.fpregs, - sizeof(context.float_state)); -@@ -726,6 +726,9 @@ - #elif defined(__mips__) - context.siginfo.si_addr = - reinterpret_cast(context.context.uc_mcontext.pc); -+#elif defined(__riscv) -+ context.siginfo.si_addr = -+ reinterpret_cast(context.context.uc_mcontext.__gregs[REG_PC]); - #else - #error "This code has not been ported to your platform yet." - #endif ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h -@@ -192,7 +192,7 @@ - siginfo_t siginfo; - pid_t tid; // the crashing thread. - ucontext_t context; --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - // #ifdef this out because FP state is not part of user ABI for Linux ARM. - // In case of MIPS Linux FP state is already part of ucontext_t so - // 'float_state' is not required. ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc -@@ -138,7 +138,7 @@ - const MicrodumpExtraInfo& microdump_extra_info, - LinuxDumper* dumper) - : ucontext_(context ? &context->context : NULL), --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - float_state_(context ? &context->float_state : NULL), - #endif - dumper_(dumper), -@@ -337,6 +337,12 @@ - # else - # error "This mips ABI is currently not supported (n32)" - #endif -+#elif defined(__riscv) -+# if __riscv_xlen == 64 -+ const char kArch[] = "riscv64"; -+# else -+# error "This RISC-V ABI is currently not supported" -+#endif - #else - #error "This code has not been ported to your platform yet" - #endif -@@ -409,7 +415,7 @@ - void DumpCPUState() { - RawContextCPU cpu; - my_memset(&cpu, 0, sizeof(RawContextCPU)); --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); - #else - UContextReader::FillCPUContext(&cpu, ucontext_); -@@ -605,7 +611,7 @@ - void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } - - const ucontext_t* const ucontext_; --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - const google_breakpad::fpstate_t* const float_state_; - #endif - LinuxDumper* dumper_; ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc -@@ -112,6 +112,9 @@ - #elif defined(__mips__) - stack_pointer = - reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); -+#elif defined(__riscv) -+ stack_pointer = -+ reinterpret_cast(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]); - #else - #error "This code hasn't been ported to your platform yet." - #endif -@@ -208,6 +211,8 @@ - info.mcontext.mdlo = status->pr_reg[EF_LO]; - info.mcontext.mdhi = status->pr_reg[EF_HI]; - info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; -+#elif defined(__riscv) -+ memcpy(info.mcontext.__gregs, status->pr_reg, sizeof(info.mcontext.__gregs)); - #else // __mips__ - memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); - #endif // __mips__ ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h -@@ -63,7 +63,8 @@ - (defined(__mips__) && _MIPS_SIM == _ABIO32) - typedef Elf32_auxv_t elf_aux_entry; - #elif defined(__x86_64) || defined(__aarch64__) || \ -- (defined(__mips__) && _MIPS_SIM != _ABIO32) -+ (defined(__mips__) && _MIPS_SIM != _ABIO32) || \ -+ (defined(__riscv) && __riscv_xlen == 64) - typedef Elf64_auxv_t elf_aux_entry; - #endif - ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc -@@ -298,6 +298,9 @@ - #elif defined(__mips__) - stack_pointer = - reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); -+#elif defined(__riscv) -+ stack_pointer = -+ reinterpret_cast(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]); - #else - #error "This code hasn't been ported to your platform yet." - #endif ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc -@@ -136,7 +136,7 @@ - : fd_(minidump_fd), - path_(minidump_path), - ucontext_(context ? &context->context : NULL), --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - float_state_(context ? &context->float_state : NULL), - #endif - dumper_(dumper), -@@ -468,7 +468,7 @@ - if (!cpu.Allocate()) - return false; - my_memset(cpu.get(), 0, sizeof(RawContextCPU)); --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); - #else - UContextReader::FillCPUContext(cpu.get(), ucontext_); -@@ -897,7 +897,7 @@ - dirent->location.rva = 0; - } - --#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) -+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || defined(__riscv) - bool WriteCPUInformation(MDRawSystemInfo* sys_info) { - char vendor_id[sizeof(sys_info->cpu.x86_cpu_info.vendor_id) + 1] = {0}; - static const char vendor_id_name[] = "vendor_id"; -@@ -925,6 +925,12 @@ - # else - # error "This mips ABI is currently not supported (n32)" - #endif -+#elif defined(__riscv) -+# if __riscv_xlen == 64 -+ MD_CPU_ARCHITECTURE_RISCV64; -+# else -+# error "This RISC-V ABI is currently not supported" -+# endif - #elif defined(__i386__) - MD_CPU_ARCHITECTURE_X86; - #else -@@ -1333,7 +1339,7 @@ - const char* path_; // Path to the file where the minidum should be written. - - const ucontext_t* const ucontext_; // also from the signal handler --#if !defined(__ARM_EABI__) && !defined(__mips__) -+#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - const google_breakpad::fpstate_t* const float_state_; // ditto - #endif - LinuxDumper* dumper_; ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h -@@ -48,7 +48,7 @@ - - #if defined(__aarch64__) - typedef struct fpsimd_context fpstate_t; --#elif !defined(__ARM_EABI__) && !defined(__mips__) -+#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) - typedef std::remove_pointer::type fpstate_t; - #endif - ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S -@@ -481,6 +481,68 @@ - .cfi_endproc - .size breakpad_getcontext, . - breakpad_getcontext - -+#elif defined(__riscv) && __riscv_xlen == 64 -+ -+#define __NR_rt_sigprocmask 135 -+#define _NSIG8 64 / 8 -+#define SIG_BLOCK 0 -+ -+ .text -+ .global breakpad_getcontext -+ .hidden breakpad_getcontext -+ .type breakpad_getcontext, @function -+ .align 2 -+breakpad_getcontext: -+ sd ra, MCONTEXT_GREGS_OFFSET + 0*8(a0) -+ sd ra, MCONTEXT_GREGS_OFFSET + 1*8(a0) -+ sd sp, MCONTEXT_GREGS_OFFSET + 2*8(a0) -+ sd s0, MCONTEXT_GREGS_OFFSET + 8*8(a0) -+ sd s1, MCONTEXT_GREGS_OFFSET + 9*8(a0) -+ sd x0, MCONTEXT_GREGS_OFFSET + 10*8(a0) /* return 0 by overwriting a0. */ -+ sd s2, MCONTEXT_GREGS_OFFSET + 18*8(a0) -+ sd s3, MCONTEXT_GREGS_OFFSET + 19*8(a0) -+ sd s4, MCONTEXT_GREGS_OFFSET + 20*8(a0) -+ sd s5, MCONTEXT_GREGS_OFFSET + 21*8(a0) -+ sd s6, MCONTEXT_GREGS_OFFSET + 22*8(a0) -+ sd s7, MCONTEXT_GREGS_OFFSET + 23*8(a0) -+ sd s8, MCONTEXT_GREGS_OFFSET + 24*8(a0) -+ sd s9, MCONTEXT_GREGS_OFFSET + 25*8(a0) -+ sd s10, MCONTEXT_GREGS_OFFSET + 26*8(a0) -+ sd s11, MCONTEXT_GREGS_OFFSET + 27*8(a0) -+ -+#ifndef __riscv_float_abi_soft -+ frsr a1 -+ -+ fsd fs0, MCONTEXT_FPREGS_OFFSET + 8*8(a0) -+ fsd fs1, MCONTEXT_FPREGS_OFFSET + 9*8(a0) -+ fsd fs2, MCONTEXT_FPREGS_OFFSET + 18*8(a0) -+ fsd fs3, MCONTEXT_FPREGS_OFFSET + 19*8(a0) -+ fsd fs4, MCONTEXT_FPREGS_OFFSET + 20*8(a0) -+ fsd fs5, MCONTEXT_FPREGS_OFFSET + 21*8(a0) -+ fsd fs6, MCONTEXT_FPREGS_OFFSET + 22*8(a0) -+ fsd fs7, MCONTEXT_FPREGS_OFFSET + 23*8(a0) -+ fsd fs8, MCONTEXT_FPREGS_OFFSET + 24*8(a0) -+ fsd fs9, MCONTEXT_FPREGS_OFFSET + 25*8(a0) -+ fsd fs10, MCONTEXT_FPREGS_OFFSET + 26*8(a0) -+ fsd fs11, MCONTEXT_FPREGS_OFFSET + 27*8(a0) -+ -+ sw a1, MCONTEXT_FSR_OFFSET(a0) -+#endif /* __riscv_float_abi_soft */ -+ -+/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG / 8) */ -+ li a3, _NSIG8 -+ add a2, a0, UCONTEXT_SIGMASK_OFFSET -+ mv a1, zero -+ li a0, SIG_BLOCK -+ -+ li a7, __NR_rt_sigprocmask -+ scall -+ -+ /* Always return 0 for success, even if sigprocmask failed. */ -+ mv a0, zero -+ ret -+ .size breakpad_getcontext, . - breakpad_getcontext -+ - #else - #error "This file has not been ported for your CPU!" - #endif ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc -@@ -65,7 +65,8 @@ - } - - #if defined(__x86_64__) || defined(__aarch64__) || \ -- (defined(__mips__) && _MIPS_SIM == _ABI64) -+ (defined(__mips__) && _MIPS_SIM == _ABI64) || \ -+ (defined(__riscv) && __riscv_xlen == 64) - - struct kernel_stat st; - if (sys_fstat(fd, &st) == -1 || st.st_size < 0) { ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h -@@ -146,6 +146,14 @@ - #endif - #define FPREGS_OFFSET_MXCSR 24 - -+#elif defined(__riscv) -+ -+#define UCONTEXT_SIGMASK_OFFSET 40 -+ -+#define MCONTEXT_GREGS_OFFSET 176 -+#define MCONTEXT_FPREGS_OFFSET 432 -+#define MCONTEXT_FSR_OFFSET (MCONTEXT_FPREGS_OFFSET + 32*8) -+ - #else - #error "This header has not been ported for your CPU" - #endif ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h -@@ -0,0 +1,121 @@ -+/* Copyright 2013 Google Inc. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are -+ * met: -+ * -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above -+ * copyright notice, this list of conditions and the following disclaimer -+ * in the documentation and/or other materials provided with the -+ * distribution. -+ * * Neither the name of Google Inc. nor the names of its -+ * contributors may be used to endorse or promote products derived from -+ * this software without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -+ -+/* minidump_format.h: A cross-platform reimplementation of minidump-related -+ * portions of DbgHelp.h from the Windows Platform SDK. -+ * -+ * (This is C99 source, please don't corrupt it with C++.) -+ * -+ * This file contains the necessary definitions to read minidump files -+ * produced on ARM. These files may be read on any platform provided -+ * that the alignments of these structures on the processing system are -+ * identical to the alignments of these structures on the producing system. -+ * For this reason, precise-sized types are used. The structures defined -+ * by this file have been laid out to minimize alignment problems by -+ * ensuring that all members are aligned on their natural boundaries. -+ * In some cases, tail-padding may be significant when different ABIs specify -+ * different tail-padding behaviors. To avoid problems when reading or -+ * writing affected structures, MD_*_SIZE macros are provided where needed, -+ * containing the useful size of the structures without padding. -+ * -+ * Structures that are defined by Microsoft to contain a zero-length array -+ * are instead defined here to contain an array with one element, as -+ * zero-length arrays are forbidden by standard C and C++. In these cases, -+ * *_minsize constants are provided to be used in place of sizeof. For a -+ * cleaner interface to these sizes when using C++, see minidump_size.h. -+ * -+ * These structures are also sufficient to populate minidump files. -+ * -+ * Because precise data type sizes are crucial for this implementation to -+ * function properly and portably, a set of primitive types with known sizes -+ * are used as the basis of each structure defined by this file. -+ * -+ * Author: Colin Blundell -+ */ -+ -+/* -+ * RISCV64 support -+ */ -+ -+#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ -+#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ -+ -+#include "google_breakpad/common/breakpad_types.h" -+ -+#define MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT 32 -+#define MD_CONTEXT_RISCV64_GPR_COUNT 32 -+ -+typedef struct { -+ /* 32 64-bit floating point registers, f0 .. f31. */ -+ uint64_t regs[MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT]; -+ -+ uint32_t fcsr; /* FPU control and status register */ -+} MDFloatingSaveAreaRISCV64; -+ -+/* For (MDRawContextRISCV64).context_flags. These values indicate the type of -+ * context stored in the structure. */ -+#define MD_CONTEXT_RISCV64 0x00400000 -+#define MD_CONTEXT_RISCV64_CONTROL (MD_CONTEXT_RISCV64 | 0x00000001) -+#define MD_CONTEXT_RISCV64_INTEGER (MD_CONTEXT_RISCV64 | 0x00000002) -+#define MD_CONTEXT_RISCV64_FLOATING_POINT (MD_CONTEXT_RISCV64 | 0x00000004) -+#define MD_CONTEXT_RISCV64_DEBUG (MD_CONTEXT_RISCV64 | 0x00000008) -+#define MD_CONTEXT_RISCV64_FULL (MD_CONTEXT_RISCV64_CONTROL | \ -+ MD_CONTEXT_RISCV64_INTEGER | \ -+ MD_CONTEXT_RISCV64_FLOATING_POINT) -+#define MD_CONTEXT_RISCV64_ALL (MD_CONTEXT_RISCV64_FULL | MD_CONTEXT_RISCV64_DEBUG) -+ -+typedef struct { -+ /* Determines which fields of this struct are populated */ -+ uint32_t context_flags; -+ -+ /* 32 64-bit integer registers, x1 .. x31 + the PC -+ * Note the following fixed uses: -+ * x8 is the frame pointer -+ * x1 is the link register -+ * x2 is the stack pointer -+ * The PC is effectively x0. -+ */ -+ uint64_t iregs[MD_CONTEXT_RISCV64_GPR_COUNT]; -+ -+ /* The next field is included with MD_CONTEXT64_ARM_FLOATING_POINT */ -+ MDFloatingSaveAreaRISCV64 float_save; -+ -+} MDRawContextRISCV64; -+ -+/* Indices into iregs for registers with a dedicated or conventional -+ * purpose. -+ */ -+enum MDRISCV64RegisterNumbers { -+ MD_CONTEXT_RISCV64_REG_FP = 8, -+ MD_CONTEXT_RISCV64_REG_RA = 1, -+ MD_CONTEXT_RISCV64_REG_SP = 2, -+ MD_CONTEXT_RISCV64_REG_PC = 0 -+}; -+ -+#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ */ ---- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h -+++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h -@@ -118,6 +118,7 @@ - #include "minidump_cpu_mips.h" - #include "minidump_cpu_ppc.h" - #include "minidump_cpu_ppc64.h" -+#include "minidump_cpu_riscv64.h" - #include "minidump_cpu_sparc.h" - #include "minidump_cpu_x86.h" - -@@ -660,6 +661,7 @@ - MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */ - MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */ - MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */ -+ MD_CPU_ARCHITECTURE_RISCV64 = 0x8005, /* Breakpad-defined value for RISCV64 */ - MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */ - } MDCPUArchitecture; - ---- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc -+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc -@@ -398,6 +398,51 @@ - return true; - } - -+#elif defined(ARCH_CPU_RISCV_FAMILY) -+ -+template -+bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) { -+ iovec iov; -+ iov.iov_base = dest; -+ iov.iov_len = sizeof(*dest); -+ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(set), &iov) != 0) { -+ PLOG_IF(ERROR, can_log) << "ptrace"; -+ return false; -+ } -+ if (iov.iov_len != sizeof(*dest)) { -+ LOG_IF(ERROR, can_log) << "Unexpected registers size"; -+ return false; -+ } -+ return true; -+} -+ -+bool GetFloatingPointRegisters32(pid_t tid, -+ FloatContext* context, -+ bool can_log) { -+ return false; -+} -+ -+bool GetFloatingPointRegisters64(pid_t tid, -+ FloatContext* context, -+ bool can_log) { -+ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log); -+} -+ -+bool GetThreadArea32(pid_t tid, -+ const ThreadContext& context, -+ LinuxVMAddress* address, -+ bool can_log) { -+ return false; -+} -+ -+bool GetThreadArea64(pid_t tid, -+ const ThreadContext& context, -+ LinuxVMAddress* address, -+ bool can_log) { -+ *address = context.t64.tp; -+ return true; -+} -+ - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY ---- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h -+++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h -@@ -79,6 +79,40 @@ - uint32_t cp0_status; - uint32_t cp0_cause; - uint32_t padding1_; -+#elif defined(ARCH_CPU_RISCV_FAMILY) -+ // Reflects user_regs_struct in asm/ptrace.h. -+ uint32_t pc; -+ uint32_t ra; -+ uint32_t sp; -+ uint32_t gp; -+ uint32_t tp; -+ uint32_t t0; -+ uint32_t t1; -+ uint32_t t2; -+ uint32_t s0; -+ uint32_t s1; -+ uint32_t a0; -+ uint32_t a1; -+ uint32_t a2; -+ uint32_t a3; -+ uint32_t a4; -+ uint32_t a5; -+ uint32_t a6; -+ uint32_t a7; -+ uint32_t s2; -+ uint32_t s3; -+ uint32_t s4; -+ uint32_t s5; -+ uint32_t s6; -+ uint32_t s7; -+ uint32_t s8; -+ uint32_t s9; -+ uint32_t s10; -+ uint32_t s11; -+ uint32_t t3; -+ uint32_t t4; -+ uint32_t t5; -+ uint32_t t6; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -132,6 +166,40 @@ - uint64_t cp0_badvaddr; - uint64_t cp0_status; - uint64_t cp0_cause; -+#elif defined(ARCH_CPU_RISCV_FAMILY) -+ // Reflects user_regs_struct in asm/ptrace.h. -+ uint64_t pc; -+ uint64_t ra; -+ uint64_t sp; -+ uint64_t gp; -+ uint64_t tp; -+ uint64_t t0; -+ uint64_t t1; -+ uint64_t t2; -+ uint64_t s0; -+ uint64_t s1; -+ uint64_t a0; -+ uint64_t a1; -+ uint64_t a2; -+ uint64_t a3; -+ uint64_t a4; -+ uint64_t a5; -+ uint64_t a6; -+ uint64_t a7; -+ uint64_t s2; -+ uint64_t s3; -+ uint64_t s4; -+ uint64_t s5; -+ uint64_t s6; -+ uint64_t s7; -+ uint64_t s8; -+ uint64_t s9; -+ uint64_t s10; -+ uint64_t s11; -+ uint64_t t3; -+ uint64_t t4; -+ uint64_t t5; -+ uint64_t t6; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -143,11 +211,12 @@ - using NativeThreadContext = user_regs; - #elif defined(ARCH_CPU_MIPS_FAMILY) - // No appropriate NativeThreadsContext type available for MIPS -+#elif defined(ARCH_CPU_RISCV_FAMILY) - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 - --#if !defined(ARCH_CPU_MIPS_FAMILY) -+#if !defined(ARCH_CPU_MIPS_FAMILY) && !defined(ARCH_CPU_RISCV_FAMILY) - #if defined(ARCH_CPU_32_BITS) - static_assert(sizeof(t32_t) == sizeof(NativeThreadContext), "Size mismatch"); - #else // ARCH_CPU_64_BITS -@@ -218,6 +287,9 @@ - } fpregs[32]; - uint32_t fpcsr; - uint32_t fpu_id; -+#elif defined(ARCH_CPU_RISCV_FAMILY) -+ uint64_t f[32]; -+ uint32_t fcsr; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -252,6 +324,9 @@ - double fpregs[32]; - uint32_t fpcsr; - uint32_t fpu_id; -+#elif defined(ARCH_CPU_RISCV_FAMILY) -+ uint64_t f[32]; -+ uint32_t fcsr; - #else - #error Port. - #endif // ARCH_CPU_X86_FAMILY -@@ -280,6 +355,7 @@ - static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch"); - #elif defined(ARCH_CPU_MIPS_FAMILY) - // No appropriate floating point context native type for available MIPS. -+#elif defined(ARCH_CPU_RISCV_FAMILY) - #else - #error Port. - #endif // ARCH_CPU_X86 ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/dav1d/config/linux/riscv64/config.h -@@ -0,0 +1,38 @@ -+/* -+ * Autogenerated by the Meson build system. -+ * Do not edit, your changes will be lost. -+ */ -+ -+#pragma once -+ -+#define ARCH_AARCH64 0 -+ -+#define ARCH_ARM 0 -+ -+#define ARCH_PPC64LE 0 -+ -+#define ARCH_X86 0 -+ -+#define ARCH_X86_32 0 -+ -+#define ARCH_X86_64 0 -+ -+#define CONFIG_16BPC 1 -+ -+#define CONFIG_8BPC 1 -+ -+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium -+ -+#define ENDIANNESS_BIG 0 -+ -+#define HAVE_ASM 0 -+ -+#define HAVE_AS_FUNC 0 -+ -+#define HAVE_CLOCK_GETTIME 1 -+ -+#define HAVE_GETAUXVAL 1 -+ -+#define HAVE_POSIX_MEMALIGN 1 -+ -+#define HAVE_UNISTD_H 1 ---- a/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h -+++ b/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h -@@ -88,7 +88,7 @@ - */ - #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ - defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ -- defined(__aarch64__) || defined(__s390__)) \ -+ defined(__aarch64__) || defined(__s390__) || defined(__riscv)) \ - && (defined(__linux) || defined(__ANDROID__)) - - #ifndef SYS_CPLUSPLUS -@@ -301,7 +301,7 @@ - } __attribute__((packed,aligned(4))); - #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) - #define kernel_old_sigaction kernel_sigaction --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__riscv) - // No kernel_old_sigaction defined for arm64. - #endif - -@@ -519,7 +519,7 @@ - int st_blocks; - int st_pad4[14]; - }; --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__riscv) - struct kernel_stat { - unsigned long st_dev; - unsigned long st_ino; -@@ -1065,7 +1065,7 @@ - #define __NR_getrandom (__NR_SYSCALL_BASE + 384) - #endif - /* End of ARM 3/EABI definitions */ --#elif defined(__aarch64__) -+#elif defined(__aarch64__) || defined(__riscv) - #ifndef __NR_setxattr - #define __NR_setxattr 5 - #endif -@@ -1880,7 +1880,7 @@ - - #undef LSS_RETURN - #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ -- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) -+ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) || defined(__riscv)) - /* Failing system calls return a negative result in the range of - * -1..-4095. These are "errno" values with the sign inverted. - */ -@@ -3373,6 +3373,122 @@ - } - LSS_RETURN(int, __ret); - } -+ #elif defined(__riscv) -+ #undef LSS_REG -+ #define LSS_REG(r,a) register int64_t __r##r __asm__("a"#r) = (int64_t)a -+ #undef LSS_BODY -+ #define LSS_BODY(type,name,args...) \ -+ register int64_t __res_a0 __asm__("a0"); \ -+ register int64_t __a7 __asm__("a7") = __NR_##name; \ -+ int64_t __res; \ -+ __asm__ __volatile__ ("scall\n" \ -+ : "=r"(__res_a0) \ -+ : "r"(__a7) , ## args \ -+ : "memory"); \ -+ __res = __res_a0; \ -+ LSS_RETURN(type, __res) -+ #undef _syscall0 -+ #define _syscall0(type, name) \ -+ type LSS_NAME(name)(void) { \ -+ LSS_BODY(type, name); \ -+ } -+ #undef _syscall1 -+ #define _syscall1(type, name, type1, arg1) \ -+ type LSS_NAME(name)(type1 arg1) { \ -+ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ -+ } -+ #undef _syscall2 -+ #define _syscall2(type, name, type1, arg1, type2, arg2) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ -+ } -+ #undef _syscall3 -+ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ -+ } -+ #undef _syscall4 -+ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ -+ } -+ #undef _syscall5 -+ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ -+ type5,arg5) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ -+ type5 arg5) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); LSS_REG(4, arg5); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ -+ "r"(__r4)); \ -+ } -+ #undef _syscall6 -+ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ -+ type5,arg5,type6,arg6) \ -+ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ -+ type5 arg5, type6 arg6) { \ -+ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ -+ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ -+ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ -+ "r"(__r4), "r"(__r5)); \ -+ } -+ -+ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, -+ int flags, void *arg, int *parent_tidptr, -+ void *newtls, int *child_tidptr) { -+ int64_t __res; -+ { -+ register int64_t __res_a0 __asm__("a0"); -+ register uint64_t __flags __asm__("a0") = flags; -+ register void *__stack __asm__("a1") = child_stack; -+ register void *__ptid __asm__("a2") = parent_tidptr; -+ register void *__tls __asm__("a3") = newtls; -+ register int *__ctid __asm__("a4") = child_tidptr; -+ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be -+ * used by the child. -+ */ -+ "addi %2,%2,-16\n" -+ "sd %1, 0(%2)\n" -+ "sd %4, 8(%2)\n" -+ -+ /* %a0 = syscall(%a0 = flags, -+ * %a1 = child_stack, -+ * %a2 = parent_tidptr, -+ * %a3 = newtls, -+ * %a4 = child_tidptr) -+ */ -+ "li a7, %8\n" -+ "scall\n" -+ -+ /* if (%a0 != 0) -+ * return %a0; -+ */ -+ "bnez %0, 1f\n" -+ -+ /* In the child, now. Call "fn(arg)". -+ */ -+ "ld a1, 0(sp)\n" -+ "ld a0, 8(sp)\n" -+ "jalr a1\n" -+ -+ /* Call _exit(%a0). -+ */ -+ "li a7, %9\n" -+ "scall\n" -+ "1:\n" -+ : "=r" (__res_a0) -+ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), -+ "r"(__ptid), "r"(__tls), "r"(__ctid), -+ "i"(__NR_clone), "i"(__NR_exit) -+ : "cc", "memory"); -+ __res = __res_a0; -+ } -+ LSS_RETURN(int, __res); -+ } - #endif - #define __NR__exit __NR_exit - #define __NR__gettid __NR_gettid -@@ -4181,7 +4297,7 @@ - LSS_SC_BODY(4, int, 8, d, type, protocol, sv); - } - #endif -- #if defined(__ARM_EABI__) || defined (__aarch64__) -+ #if defined(__ARM_EABI__) || defined (__aarch64__) || defined(__riscv) - LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, - int, flags) - LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, -@@ -4503,7 +4619,7 @@ - // TODO: define this in an arch-independant way instead of inlining the clone - // syscall body. - --# if defined(__aarch64__) -+# if defined(__aarch64__) || defined(__riscv) - LSS_INLINE pid_t LSS_NAME(fork)(void) { - // No fork syscall on aarch64 - implement by means of the clone syscall. - // Note that this does not reset glibc's cached view of the PID/TID, so ---- a/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn -@@ -149,6 +149,7 @@ - deps += [ ":swiftshader_llvm_ppc" ] - } else if (current_cpu == "x86" || current_cpu == "x64") { - deps += [ ":swiftshader_llvm_x86" ] -+ } else if (current_cpu == "riscv64") { - } else { - assert(false, "Unsupported current_cpu") - } ---- a/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc -+++ b/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc -@@ -30,7 +30,7 @@ - static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr; - - if (!diff_proc) { --#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) -+#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || defined(WEBRTC_ARCH_RISCV_FAMILY) - // For ARM and MIPS processors, always use C version. - // TODO(hclam): Implement a NEON version. - diff_proc = &VectorDifference_C; ---- a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h -+++ b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h -@@ -50,6 +50,10 @@ - #elif defined(__EMSCRIPTEN__) - #define WEBRTC_ARCH_32_BITS - #define WEBRTC_ARCH_LITTLE_ENDIAN -+#elif defined(__riscv) && __riscv_xlen == 64 -+#define WEBRTC_ARCH_RISCV_FAMILY -+#define WEBRTC_ARCH_64_BITS -+#define WEBRTC_ARCH_LITTLE_ENDIAN - #else - #error Please add support for your architecture in rtc_base/system/arch.h - #endif ---- a/src/3rdparty/gn/tools/gn/args.cc -+++ b/src/3rdparty/gn/tools/gn/args.cc -@@ -329,6 +329,7 @@ - static const char kMips64[] = "mips64el"; - static const char kS390X[] = "s390x"; - static const char kPPC64[] = "ppc64"; -+ static const char kRiscv64[] = "riscv64"; - const char* arch = nullptr; - - // Set the host CPU architecture based on the underlying OS, not -@@ -353,6 +354,8 @@ - // This allows us to use the same toolchain as ppc64 BE - // and specific flags are included using the host_byteorder logic. - arch = kPPC64; -+ else if (os_arch == "riscv64") -+ arch = kRiscv64; - else - CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; - ---- a/src/3rdparty/gn/util/build_config.h -+++ b/src/3rdparty/gn/util/build_config.h -@@ -172,6 +172,16 @@ - #define ARCH_CPU_32_BITS 1 - #define ARCH_CPU_BIG_ENDIAN 1 - #endif -+#elif defined(__riscv) -+#define ARCH_CPU_RISCV_FAMILY 1 -+#if __riscv_xlen == 64 -+#define ARCH_CPU_RISCV64 1 -+#define ARCH_CPU_64_BITS 1 -+#else -+#define ARCH_CPU_RISCV32 1 -+#define ARCH_CPU_32_BITS 1 -+#endif -+#define ARCH_CPU_LITTLE_ENDIAN 1 - #else - #error Please add support for your architecture in build_config.h - #endif ---- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/env python3 - # - # Copyright 2014 The Chromium Authors. All rights reserved. - # Use of this source code is governed by a BSD-style license that can be -@@ -37,7 +37,7 @@ - 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], - 'linux': [ - 'ia32', 'x64', 'mipsel', 'mips64el', 'noasm-x64', 'arm', 'arm-neon', -- 'arm64' -+ 'arm64', 'riscv64' - ], - 'mac': ['x64', 'arm64'], - 'win': ['ia32', 'x64', 'arm64'], -@@ -139,6 +139,8 @@ - host_arch = 'mips64el' - elif platform.machine().startswith('arm'): - host_arch = 'arm' -+ elif platform.machine() == 'riscv64': -+ host_arch = 'riscv64' - else: - return None - -@@ -820,6 +822,10 @@ - '--extra-cflags=--target=mips64el-linux-gnuabi64', - '--extra-ldflags=--target=mips64el-linux-gnuabi64', - ]) -+ elif target_arch == 'riscv64': -+ configure_flags['Common'].extend([ -+ '--arch=riscv64', -+ ]) - else: - print( - 'Error: Unknown target arch %r for target OS %r!' % (target_arch, -@@ -833,7 +839,9 @@ - '--disable-inline-asm', - ]) - -- if 'win' not in target_os: -+ if platform.machine() == 'riscv64': -+ pass -+ elif 'win' not in target_os: - configure_flags['Common'].extend([ - '--enable-pic', - '--cc=clang', ---- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh -@@ -10,7 +10,7 @@ - # Copy config files for various architectures: - # - ia32/x64 have config.asm, config.h - # - arm/arm-neon have config.h -- for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do -+ for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el riscv64; do - # Don't waste time on non-existent configs, if no config.h then skip. - [ ! -e "build.$arch.$os/$target/config.h" ] && continue - for f in config.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do ---- a/src/3rdparty/chromium/third_party/ffmpeg/configure -+++ b/src/3rdparty/chromium/third_party/ffmpeg/configure -@@ -1990,6 +1990,7 @@ - parisc - ppc - ppc64 -+ riscv - s390 - sh4 - sparc -@@ -2597,7 +2598,7 @@ - done - - aligned_stack_if_any="aarch64 ppc x86" --fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64" -+fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 riscv64 sparc64 x86_64" - fast_clz_if_any="aarch64 alpha avr32 mips ppc x86" - fast_unaligned_if_any="aarch64 ppc x86" - simd_align_16_if_any="altivec neon sse" -@@ -4890,6 +4891,9 @@ - "Power Macintosh"|ppc*|powerpc*) - arch="ppc" - ;; -+ riscv*) -+ arch="riscv" -+ ;; - s390|s390x) - arch="s390" - ;; -@@ -5290,6 +5294,10 @@ - check_64bit ppc ppc64 - enabled shared && enable_weak pic - ;; -+ riscv) -+ check_64bit riscv32 riscv64 -+ enabled shared && enable_weak pic -+ ;; - s390) - check_64bit s390 s390x - enabled shared && enable_weak pic ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/config.h -@@ -0,0 +1,2626 @@ -+/* Automatically generated by configure - do not modify! */ -+#ifndef FFMPEG_CONFIG_H -+#define FFMPEG_CONFIG_H -+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64 --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */ -+#define FFMPEG_LICENSE "LGPL version 2.1 or later" -+#define CONFIG_THIS_YEAR 2020 -+#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" -+#define AVCONV_DATADIR "/usr/local/share/ffmpeg" -+#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" -+#define av_restrict restrict -+#define EXTERN_PREFIX "" -+#define EXTERN_ASM -+#define BUILDSUF "" -+#define SLIBSUF ".so" -+#define HAVE_MMX2 HAVE_MMXEXT -+#define SWS_MAX_FILTER_SIZE 256 -+#define ARCH_AARCH64 0 -+#define ARCH_ALPHA 0 -+#define ARCH_ARM 0 -+#define ARCH_AVR32 0 -+#define ARCH_AVR32_AP 0 -+#define ARCH_AVR32_UC 0 -+#define ARCH_BFIN 0 -+#define ARCH_IA64 0 -+#define ARCH_M68K 0 -+#define ARCH_MIPS 0 -+#define ARCH_MIPS64 0 -+#define ARCH_PARISC 0 -+#define ARCH_PPC 0 -+#define ARCH_PPC64 0 -+#define ARCH_RISCV 1 -+#define ARCH_S390 0 -+#define ARCH_SH4 0 -+#define ARCH_SPARC 0 -+#define ARCH_SPARC64 0 -+#define ARCH_TILEGX 0 -+#define ARCH_TILEPRO 0 -+#define ARCH_TOMI 0 -+#define ARCH_X86 0 -+#define ARCH_X86_32 0 -+#define ARCH_X86_64 0 -+#define HAVE_ARMV5TE 0 -+#define HAVE_ARMV6 0 -+#define HAVE_ARMV6T2 0 -+#define HAVE_ARMV8 0 -+#define HAVE_NEON 0 -+#define HAVE_VFP 0 -+#define HAVE_VFPV3 0 -+#define HAVE_SETEND 0 -+#define HAVE_ALTIVEC 0 -+#define HAVE_DCBZL 0 -+#define HAVE_LDBRX 0 -+#define HAVE_POWER8 0 -+#define HAVE_PPC4XX 0 -+#define HAVE_VSX 0 -+#define HAVE_AESNI 0 -+#define HAVE_AMD3DNOW 0 -+#define HAVE_AMD3DNOWEXT 0 -+#define HAVE_AVX 0 -+#define HAVE_AVX2 0 -+#define HAVE_AVX512 0 -+#define HAVE_FMA3 0 -+#define HAVE_FMA4 0 -+#define HAVE_MMX 0 -+#define HAVE_MMXEXT 0 -+#define HAVE_SSE 0 -+#define HAVE_SSE2 0 -+#define HAVE_SSE3 0 -+#define HAVE_SSE4 0 -+#define HAVE_SSE42 0 -+#define HAVE_SSSE3 0 -+#define HAVE_XOP 0 -+#define HAVE_CPUNOP 0 -+#define HAVE_I686 0 -+#define HAVE_MIPSFPU 0 -+#define HAVE_MIPS32R2 0 -+#define HAVE_MIPS32R5 0 -+#define HAVE_MIPS64R2 0 -+#define HAVE_MIPS32R6 0 -+#define HAVE_MIPS64R6 0 -+#define HAVE_MIPSDSP 0 -+#define HAVE_MIPSDSPR2 0 -+#define HAVE_MSA 0 -+#define HAVE_MSA2 0 -+#define HAVE_LOONGSON2 0 -+#define HAVE_LOONGSON3 0 -+#define HAVE_MMI 0 -+#define HAVE_ARMV5TE_EXTERNAL 0 -+#define HAVE_ARMV6_EXTERNAL 0 -+#define HAVE_ARMV6T2_EXTERNAL 0 -+#define HAVE_ARMV8_EXTERNAL 0 -+#define HAVE_NEON_EXTERNAL 0 -+#define HAVE_VFP_EXTERNAL 0 -+#define HAVE_VFPV3_EXTERNAL 0 -+#define HAVE_SETEND_EXTERNAL 0 -+#define HAVE_ALTIVEC_EXTERNAL 0 -+#define HAVE_DCBZL_EXTERNAL 0 -+#define HAVE_LDBRX_EXTERNAL 0 -+#define HAVE_POWER8_EXTERNAL 0 -+#define HAVE_PPC4XX_EXTERNAL 0 -+#define HAVE_VSX_EXTERNAL 0 -+#define HAVE_AESNI_EXTERNAL 0 -+#define HAVE_AMD3DNOW_EXTERNAL 0 -+#define HAVE_AMD3DNOWEXT_EXTERNAL 0 -+#define HAVE_AVX_EXTERNAL 0 -+#define HAVE_AVX2_EXTERNAL 0 -+#define HAVE_AVX512_EXTERNAL 0 -+#define HAVE_FMA3_EXTERNAL 0 -+#define HAVE_FMA4_EXTERNAL 0 -+#define HAVE_MMX_EXTERNAL 0 -+#define HAVE_MMXEXT_EXTERNAL 0 -+#define HAVE_SSE_EXTERNAL 0 -+#define HAVE_SSE2_EXTERNAL 0 -+#define HAVE_SSE3_EXTERNAL 0 -+#define HAVE_SSE4_EXTERNAL 0 -+#define HAVE_SSE42_EXTERNAL 0 -+#define HAVE_SSSE3_EXTERNAL 0 -+#define HAVE_XOP_EXTERNAL 0 -+#define HAVE_CPUNOP_EXTERNAL 0 -+#define HAVE_I686_EXTERNAL 0 -+#define HAVE_MIPSFPU_EXTERNAL 0 -+#define HAVE_MIPS32R2_EXTERNAL 0 -+#define HAVE_MIPS32R5_EXTERNAL 0 -+#define HAVE_MIPS64R2_EXTERNAL 0 -+#define HAVE_MIPS32R6_EXTERNAL 0 -+#define HAVE_MIPS64R6_EXTERNAL 0 -+#define HAVE_MIPSDSP_EXTERNAL 0 -+#define HAVE_MIPSDSPR2_EXTERNAL 0 -+#define HAVE_MSA_EXTERNAL 0 -+#define HAVE_MSA2_EXTERNAL 0 -+#define HAVE_LOONGSON2_EXTERNAL 0 -+#define HAVE_LOONGSON3_EXTERNAL 0 -+#define HAVE_MMI_EXTERNAL 0 -+#define HAVE_ARMV5TE_INLINE 0 -+#define HAVE_ARMV6_INLINE 0 -+#define HAVE_ARMV6T2_INLINE 0 -+#define HAVE_ARMV8_INLINE 0 -+#define HAVE_NEON_INLINE 0 -+#define HAVE_VFP_INLINE 0 -+#define HAVE_VFPV3_INLINE 0 -+#define HAVE_SETEND_INLINE 0 -+#define HAVE_ALTIVEC_INLINE 0 -+#define HAVE_DCBZL_INLINE 0 -+#define HAVE_LDBRX_INLINE 0 -+#define HAVE_POWER8_INLINE 0 -+#define HAVE_PPC4XX_INLINE 0 -+#define HAVE_VSX_INLINE 0 -+#define HAVE_AESNI_INLINE 0 -+#define HAVE_AMD3DNOW_INLINE 0 -+#define HAVE_AMD3DNOWEXT_INLINE 0 -+#define HAVE_AVX_INLINE 0 -+#define HAVE_AVX2_INLINE 0 -+#define HAVE_AVX512_INLINE 0 -+#define HAVE_FMA3_INLINE 0 -+#define HAVE_FMA4_INLINE 0 -+#define HAVE_MMX_INLINE 0 -+#define HAVE_MMXEXT_INLINE 0 -+#define HAVE_SSE_INLINE 0 -+#define HAVE_SSE2_INLINE 0 -+#define HAVE_SSE3_INLINE 0 -+#define HAVE_SSE4_INLINE 0 -+#define HAVE_SSE42_INLINE 0 -+#define HAVE_SSSE3_INLINE 0 -+#define HAVE_XOP_INLINE 0 -+#define HAVE_CPUNOP_INLINE 0 -+#define HAVE_I686_INLINE 0 -+#define HAVE_MIPSFPU_INLINE 0 -+#define HAVE_MIPS32R2_INLINE 0 -+#define HAVE_MIPS32R5_INLINE 0 -+#define HAVE_MIPS64R2_INLINE 0 -+#define HAVE_MIPS32R6_INLINE 0 -+#define HAVE_MIPS64R6_INLINE 0 -+#define HAVE_MIPSDSP_INLINE 0 -+#define HAVE_MIPSDSPR2_INLINE 0 -+#define HAVE_MSA_INLINE 0 -+#define HAVE_MSA2_INLINE 0 -+#define HAVE_LOONGSON2_INLINE 0 -+#define HAVE_LOONGSON3_INLINE 0 -+#define HAVE_MMI_INLINE 0 -+#define HAVE_ALIGNED_STACK 0 -+#define HAVE_FAST_64BIT 1 -+#define HAVE_FAST_CLZ 0 -+#define HAVE_FAST_CMOV 0 -+#define HAVE_LOCAL_ALIGNED 0 -+#define HAVE_SIMD_ALIGN_16 0 -+#define HAVE_SIMD_ALIGN_32 0 -+#define HAVE_SIMD_ALIGN_64 0 -+#define HAVE_ATOMIC_CAS_PTR 0 -+#define HAVE_MACHINE_RW_BARRIER 0 -+#define HAVE_MEMORYBARRIER 0 -+#define HAVE_MM_EMPTY 0 -+#define HAVE_RDTSC 0 -+#define HAVE_SEM_TIMEDWAIT 1 -+#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 -+#define HAVE_CABS 0 -+#define HAVE_CEXP 0 -+#define HAVE_INLINE_ASM 1 -+#define HAVE_SYMVER 0 -+#define HAVE_X86ASM 0 -+#define HAVE_BIGENDIAN 0 -+#define HAVE_FAST_UNALIGNED 0 -+#define HAVE_ARPA_INET_H 0 -+#define HAVE_ASM_TYPES_H 1 -+#define HAVE_CDIO_PARANOIA_H 0 -+#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 -+#define HAVE_CUDA_H 0 -+#define HAVE_DISPATCH_DISPATCH_H 0 -+#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 -+#define HAVE_DEV_IC_BT8XX_H 0 -+#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 -+#define HAVE_DIRECT_H 0 -+#define HAVE_DIRENT_H 1 -+#define HAVE_DXGIDEBUG_H 0 -+#define HAVE_DXVA_H 0 -+#define HAVE_ES2_GL_H 0 -+#define HAVE_GSM_H 0 -+#define HAVE_IO_H 0 -+#define HAVE_LINUX_PERF_EVENT_H 1 -+#define HAVE_MACHINE_IOCTL_BT848_H 0 -+#define HAVE_MACHINE_IOCTL_METEOR_H 0 -+#define HAVE_MALLOC_H 1 -+#define HAVE_OPENCV2_CORE_CORE_C_H 0 -+#define HAVE_OPENGL_GL3_H 0 -+#define HAVE_POLL_H 1 -+#define HAVE_SYS_PARAM_H 1 -+#define HAVE_SYS_RESOURCE_H 1 -+#define HAVE_SYS_SELECT_H 1 -+#define HAVE_SYS_SOUNDCARD_H 1 -+#define HAVE_SYS_TIME_H 1 -+#define HAVE_SYS_UN_H 1 -+#define HAVE_SYS_VIDEOIO_H 0 -+#define HAVE_TERMIOS_H 1 -+#define HAVE_UDPLITE_H 0 -+#define HAVE_UNISTD_H 1 -+#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ -+#define HAVE_WINDOWS_H 0 -+#define HAVE_WINSOCK2_H 0 -+#define HAVE_INTRINSICS_NEON 0 -+#define HAVE_ATANF 1 -+#define HAVE_ATAN2F 1 -+#define HAVE_CBRT 1 -+#define HAVE_CBRTF 1 -+#define HAVE_COPYSIGN 1 -+#define HAVE_COSF 1 -+#define HAVE_ERF 1 -+#define HAVE_EXP2 1 -+#define HAVE_EXP2F 1 -+#define HAVE_EXPF 1 -+#define HAVE_HYPOT 1 -+#define HAVE_ISFINITE 1 -+#define HAVE_ISINF 1 -+#define HAVE_ISNAN 1 -+#define HAVE_LDEXPF 1 -+#define HAVE_LLRINT 1 -+#define HAVE_LLRINTF 1 -+#define HAVE_LOG2 1 -+#define HAVE_LOG2F 1 -+#define HAVE_LOG10F 1 -+#define HAVE_LRINT 1 -+#define HAVE_LRINTF 1 -+#define HAVE_POWF 1 -+#define HAVE_RINT 1 -+#define HAVE_ROUND 1 -+#define HAVE_ROUNDF 1 -+#define HAVE_SINF 1 -+#define HAVE_TRUNC 1 -+#define HAVE_TRUNCF 1 -+#define HAVE_DOS_PATHS 0 -+#define HAVE_LIBC_MSVCRT 0 -+#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 -+#define HAVE_SECTION_DATA_REL_RO 1 -+#define HAVE_THREADS 1 -+#define HAVE_UWP 0 -+#define HAVE_WINRT 0 -+#define HAVE_ACCESS 1 -+#define HAVE_ALIGNED_MALLOC 0 -+#define HAVE_ARC4RANDOM 0 -+#define HAVE_CLOCK_GETTIME 1 -+#define HAVE_CLOSESOCKET 0 -+#define HAVE_COMMANDLINETOARGVW 0 -+#define HAVE_FCNTL 1 -+#define HAVE_GETADDRINFO 0 -+#define HAVE_GETHRTIME 0 -+#define HAVE_GETOPT 1 -+#define HAVE_GETMODULEHANDLE 0 -+#define HAVE_GETPROCESSAFFINITYMASK 0 -+#define HAVE_GETPROCESSMEMORYINFO 0 -+#define HAVE_GETPROCESSTIMES 0 -+#define HAVE_GETRUSAGE 1 -+#define HAVE_GETSTDHANDLE 0 -+#define HAVE_GETSYSTEMTIMEASFILETIME 0 -+#define HAVE_GETTIMEOFDAY 1 -+#define HAVE_GLOB 1 -+#define HAVE_GLXGETPROCADDRESS 0 -+#define HAVE_GMTIME_R 1 -+#define HAVE_INET_ATON 0 -+#define HAVE_ISATTY 1 -+#define HAVE_KBHIT 0 -+#define HAVE_LOCALTIME_R 1 -+#define HAVE_LSTAT 1 -+#define HAVE_LZO1X_999_COMPRESS 0 -+#define HAVE_MACH_ABSOLUTE_TIME 0 -+#define HAVE_MAPVIEWOFFILE 0 -+#define HAVE_MEMALIGN 1 -+#define HAVE_MKSTEMP 1 -+#define HAVE_MMAP 1 -+#define HAVE_MPROTECT 1 -+#define HAVE_NANOSLEEP 1 -+#define HAVE_PEEKNAMEDPIPE 0 -+#define HAVE_POSIX_MEMALIGN 1 -+#define HAVE_PTHREAD_CANCEL 1 -+#define HAVE_SCHED_GETAFFINITY 1 -+#define HAVE_SECITEMIMPORT 0 -+#define HAVE_SETCONSOLETEXTATTRIBUTE 0 -+#define HAVE_SETCONSOLECTRLHANDLER 0 -+#define HAVE_SETDLLDIRECTORY 0 -+#define HAVE_SETMODE 0 -+#define HAVE_SETRLIMIT 1 -+#define HAVE_SLEEP 0 -+#define HAVE_STRERROR_R 1 -+#define HAVE_SYSCONF 1 -+#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ -+#define HAVE_USLEEP 1 -+#define HAVE_UTGETOSTYPEFROMSTRING 0 -+#define HAVE_VIRTUALALLOC 0 -+#define HAVE_WGLGETPROCADDRESS 0 -+#define HAVE_BCRYPT 0 -+#define HAVE_VAAPI_DRM 0 -+#define HAVE_VAAPI_X11 0 -+#define HAVE_VDPAU_X11 0 -+#define HAVE_PTHREADS 1 -+#define HAVE_OS2THREADS 0 -+#define HAVE_W32THREADS 0 -+#define HAVE_AS_ARCH_DIRECTIVE 0 -+#define HAVE_AS_DN_DIRECTIVE 0 -+#define HAVE_AS_FPU_DIRECTIVE 0 -+#define HAVE_AS_FUNC 0 -+#define HAVE_AS_OBJECT_ARCH 0 -+#define HAVE_ASM_MOD_Q 0 -+#define HAVE_BLOCKS_EXTENSION 0 -+#define HAVE_EBP_AVAILABLE 0 -+#define HAVE_EBX_AVAILABLE 0 -+#define HAVE_GNU_AS 0 -+#define HAVE_GNU_WINDRES 0 -+#define HAVE_IBM_ASM 0 -+#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 -+#define HAVE_INLINE_ASM_LABELS 1 -+#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 -+#define HAVE_PRAGMA_DEPRECATED 1 -+#define HAVE_RSYNC_CONTIMEOUT 0 -+#define HAVE_SYMVER_ASM_LABEL 0 -+#define HAVE_SYMVER_GNU_ASM 1 -+#define HAVE_VFP_ARGS 0 -+#define HAVE_XFORM_ASM 0 -+#define HAVE_XMM_CLOBBERS 0 -+#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 -+#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 -+#define HAVE_SOCKLEN_T 0 -+#define HAVE_STRUCT_ADDRINFO 0 -+#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 -+#define HAVE_STRUCT_IP_MREQ_SOURCE 0 -+#define HAVE_STRUCT_IPV6_MREQ 0 -+#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 -+#define HAVE_STRUCT_POLLFD 0 -+#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 -+#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 -+#define HAVE_STRUCT_SOCKADDR_IN6 0 -+#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 -+#define HAVE_STRUCT_SOCKADDR_STORAGE 0 -+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 -+#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 -+#define HAVE_LIBDRM_GETFB2 0 -+#define HAVE_MAKEINFO 0 -+#define HAVE_MAKEINFO_HTML 0 -+#define HAVE_OPENCL_D3D11 0 -+#define HAVE_OPENCL_DRM_ARM 0 -+#define HAVE_OPENCL_DRM_BEIGNET 0 -+#define HAVE_OPENCL_DXVA2 0 -+#define HAVE_OPENCL_VAAPI_BEIGNET 0 -+#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 -+#define HAVE_PERL 1 -+#define HAVE_POD2MAN 1 -+#define HAVE_TEXI2HTML 0 -+#define CONFIG_DOC 0 -+#define CONFIG_HTMLPAGES 0 -+#define CONFIG_MANPAGES 0 -+#define CONFIG_PODPAGES 0 -+#define CONFIG_TXTPAGES 0 -+#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 -+#define CONFIG_AVIO_READING_EXAMPLE 1 -+#define CONFIG_DECODE_AUDIO_EXAMPLE 1 -+#define CONFIG_DECODE_VIDEO_EXAMPLE 1 -+#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 -+#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 -+#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 -+#define CONFIG_EXTRACT_MVS_EXAMPLE 1 -+#define CONFIG_FILTER_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 -+#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 -+#define CONFIG_HW_DECODE_EXAMPLE 1 -+#define CONFIG_METADATA_EXAMPLE 1 -+#define CONFIG_MUXING_EXAMPLE 0 -+#define CONFIG_QSVDEC_EXAMPLE 0 -+#define CONFIG_REMUXING_EXAMPLE 1 -+#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 -+#define CONFIG_SCALING_VIDEO_EXAMPLE 0 -+#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 -+#define CONFIG_TRANSCODING_EXAMPLE 0 -+#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 -+#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 -+#define CONFIG_AVISYNTH 0 -+#define CONFIG_FREI0R 0 -+#define CONFIG_LIBCDIO 0 -+#define CONFIG_LIBDAVS2 0 -+#define CONFIG_LIBRUBBERBAND 0 -+#define CONFIG_LIBVIDSTAB 0 -+#define CONFIG_LIBX264 0 -+#define CONFIG_LIBX265 0 -+#define CONFIG_LIBXAVS 0 -+#define CONFIG_LIBXAVS2 0 -+#define CONFIG_LIBXVID 0 -+#define CONFIG_DECKLINK 0 -+#define CONFIG_LIBFDK_AAC 0 -+#define CONFIG_OPENSSL 0 -+#define CONFIG_LIBTLS 0 -+#define CONFIG_GMP 0 -+#define CONFIG_LIBARIBB24 0 -+#define CONFIG_LIBLENSFUN 0 -+#define CONFIG_LIBOPENCORE_AMRNB 0 -+#define CONFIG_LIBOPENCORE_AMRWB 0 -+#define CONFIG_LIBVO_AMRWBENC 0 -+#define CONFIG_MBEDTLS 0 -+#define CONFIG_RKMPP 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_CHROMAPRINT 0 -+#define CONFIG_GCRYPT 0 -+#define CONFIG_GNUTLS 0 -+#define CONFIG_JNI 0 -+#define CONFIG_LADSPA 0 -+#define CONFIG_LIBAOM 0 -+#define CONFIG_LIBASS 0 -+#define CONFIG_LIBBLURAY 0 -+#define CONFIG_LIBBS2B 0 -+#define CONFIG_LIBCACA 0 -+#define CONFIG_LIBCELT 0 -+#define CONFIG_LIBCODEC2 0 -+#define CONFIG_LIBDAV1D 0 -+#define CONFIG_LIBDC1394 0 -+#define CONFIG_LIBDRM 0 -+#define CONFIG_LIBFLITE 0 -+#define CONFIG_LIBFONTCONFIG 0 -+#define CONFIG_LIBFREETYPE 0 -+#define CONFIG_LIBFRIBIDI 0 -+#define CONFIG_LIBGLSLANG 0 -+#define CONFIG_LIBGME 0 -+#define CONFIG_LIBGSM 0 -+#define CONFIG_LIBIEC61883 0 -+#define CONFIG_LIBILBC 0 -+#define CONFIG_LIBJACK 0 -+#define CONFIG_LIBKLVANC 0 -+#define CONFIG_LIBKVAZAAR 0 -+#define CONFIG_LIBMODPLUG 0 -+#define CONFIG_LIBMP3LAME 0 -+#define CONFIG_LIBMYSOFA 0 -+#define CONFIG_LIBOPENCV 0 -+#define CONFIG_LIBOPENH264 0 -+#define CONFIG_LIBOPENJPEG 0 -+#define CONFIG_LIBOPENMPT 0 -+#define CONFIG_LIBOPENVINO 0 -+#define CONFIG_LIBOPUS 1 -+#define CONFIG_LIBPULSE 0 -+#define CONFIG_LIBRABBITMQ 0 -+#define CONFIG_LIBRAV1E 0 -+#define CONFIG_LIBRSVG 0 -+#define CONFIG_LIBRTMP 0 -+#define CONFIG_LIBSHINE 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_LIBSNAPPY 0 -+#define CONFIG_LIBSOXR 0 -+#define CONFIG_LIBSPEEX 0 -+#define CONFIG_LIBSRT 0 -+#define CONFIG_LIBSSH 0 -+#define CONFIG_LIBSVTAV1 0 -+#define CONFIG_LIBTENSORFLOW 0 -+#define CONFIG_LIBTESSERACT 0 -+#define CONFIG_LIBTHEORA 0 -+#define CONFIG_LIBTWOLAME 0 -+#define CONFIG_LIBV4L2 0 -+#define CONFIG_LIBVMAF 0 -+#define CONFIG_LIBVORBIS 0 -+#define CONFIG_LIBVPX 0 -+#define CONFIG_LIBWAVPACK 0 -+#define CONFIG_LIBWEBP 0 -+#define CONFIG_LIBXML2 0 -+#define CONFIG_LIBZIMG 0 -+#define CONFIG_LIBZMQ 0 -+#define CONFIG_LIBZVBI 0 -+#define CONFIG_LV2 0 -+#define CONFIG_MEDIACODEC 0 -+#define CONFIG_OPENAL 0 -+#define CONFIG_OPENGL 0 -+#define CONFIG_POCKETSPHINX 0 -+#define CONFIG_VAPOURSYNTH 0 -+#define CONFIG_ALSA 0 -+#define CONFIG_APPKIT 0 -+#define CONFIG_AVFOUNDATION 0 -+#define CONFIG_BZLIB 0 -+#define CONFIG_COREIMAGE 0 -+#define CONFIG_ICONV 0 -+#define CONFIG_LIBXCB 0 -+#define CONFIG_LIBXCB_SHM 0 -+#define CONFIG_LIBXCB_SHAPE 0 -+#define CONFIG_LIBXCB_XFIXES 0 -+#define CONFIG_LZMA 0 -+#define CONFIG_MEDIAFOUNDATION 0 -+#define CONFIG_SCHANNEL 0 -+#define CONFIG_SDL2 0 -+#define CONFIG_SECURETRANSPORT 0 -+#define CONFIG_SNDIO 0 -+#define CONFIG_XLIB 0 -+#define CONFIG_ZLIB 0 -+#define CONFIG_CUDA_NVCC 0 -+#define CONFIG_CUDA_SDK 0 -+#define CONFIG_LIBNPP 0 -+#define CONFIG_LIBMFX 0 -+#define CONFIG_MMAL 0 -+#define CONFIG_OMX 0 -+#define CONFIG_OPENCL 0 -+#define CONFIG_VULKAN 0 -+#define CONFIG_AMF 0 -+#define CONFIG_AUDIOTOOLBOX 0 -+#define CONFIG_CRYSTALHD 0 -+#define CONFIG_CUDA 0 -+#define CONFIG_CUDA_LLVM 0 -+#define CONFIG_CUVID 0 -+#define CONFIG_D3D11VA 0 -+#define CONFIG_DXVA2 0 -+#define CONFIG_FFNVCODEC 0 -+#define CONFIG_NVDEC 0 -+#define CONFIG_NVENC 0 -+#define CONFIG_VAAPI 0 -+#define CONFIG_VDPAU 0 -+#define CONFIG_VIDEOTOOLBOX 0 -+#define CONFIG_V4L2_M2M 0 -+#define CONFIG_XVMC 0 -+#define CONFIG_FTRAPV 0 -+#define CONFIG_GRAY 0 -+#define CONFIG_HARDCODED_TABLES 0 -+#define CONFIG_OMX_RPI 0 -+#define CONFIG_RUNTIME_CPUDETECT 1 -+#define CONFIG_SAFE_BITSTREAM_READER 1 -+#define CONFIG_SHARED 0 -+#define CONFIG_SMALL 0 -+#define CONFIG_STATIC 1 -+#define CONFIG_SWSCALE_ALPHA 1 -+#define CONFIG_GPL 0 -+#define CONFIG_NONFREE 0 -+#define CONFIG_VERSION3 0 -+#define CONFIG_AVDEVICE 0 -+#define CONFIG_AVFILTER 0 -+#define CONFIG_SWSCALE 0 -+#define CONFIG_POSTPROC 0 -+#define CONFIG_AVFORMAT 1 -+#define CONFIG_AVCODEC 1 -+#define CONFIG_SWRESAMPLE 0 -+#define CONFIG_AVRESAMPLE 0 -+#define CONFIG_AVUTIL 1 -+#define CONFIG_FFPLAY 0 -+#define CONFIG_FFPROBE 0 -+#define CONFIG_FFMPEG 0 -+#define CONFIG_DCT 1 -+#define CONFIG_DWT 0 -+#define CONFIG_ERROR_RESILIENCE 0 -+#define CONFIG_FAAN 0 -+#define CONFIG_FAST_UNALIGNED 0 -+#define CONFIG_FFT 1 -+#define CONFIG_LSP 0 -+#define CONFIG_LZO 0 -+#define CONFIG_MDCT 1 -+#define CONFIG_PIXELUTILS 0 -+#define CONFIG_NETWORK 0 -+#define CONFIG_RDFT 1 -+#define CONFIG_AUTODETECT 0 -+#define CONFIG_FONTCONFIG 0 -+#define CONFIG_LARGE_TESTS 1 -+#define CONFIG_LINUX_PERF 0 -+#define CONFIG_MEMORY_POISONING 0 -+#define CONFIG_NEON_CLOBBER_TEST 0 -+#define CONFIG_OSSFUZZ 0 -+#define CONFIG_PIC 1 -+#define CONFIG_THUMB 0 -+#define CONFIG_VALGRIND_BACKTRACE 0 -+#define CONFIG_XMM_CLOBBER_TEST 0 -+#define CONFIG_BSFS 1 -+#define CONFIG_DECODERS 1 -+#define CONFIG_ENCODERS 0 -+#define CONFIG_HWACCELS 0 -+#define CONFIG_PARSERS 1 -+#define CONFIG_INDEVS 0 -+#define CONFIG_OUTDEVS 0 -+#define CONFIG_FILTERS 0 -+#define CONFIG_DEMUXERS 1 -+#define CONFIG_MUXERS 0 -+#define CONFIG_PROTOCOLS 0 -+#define CONFIG_AANDCTTABLES 0 -+#define CONFIG_AC3DSP 0 -+#define CONFIG_ADTS_HEADER 1 -+#define CONFIG_ATSC_A53 1 -+#define CONFIG_AUDIO_FRAME_QUEUE 0 -+#define CONFIG_AUDIODSP 0 -+#define CONFIG_BLOCKDSP 0 -+#define CONFIG_BSWAPDSP 0 -+#define CONFIG_CABAC 1 -+#define CONFIG_CBS 0 -+#define CONFIG_CBS_AV1 0 -+#define CONFIG_CBS_H264 0 -+#define CONFIG_CBS_H265 0 -+#define CONFIG_CBS_JPEG 0 -+#define CONFIG_CBS_MPEG2 0 -+#define CONFIG_CBS_VP9 0 -+#define CONFIG_DIRAC_PARSE 1 -+#define CONFIG_DNN 0 -+#define CONFIG_DVPROFILE 0 -+#define CONFIG_EXIF 0 -+#define CONFIG_FAANDCT 0 -+#define CONFIG_FAANIDCT 0 -+#define CONFIG_FDCTDSP 0 -+#define CONFIG_FLACDSP 1 -+#define CONFIG_FMTCONVERT 0 -+#define CONFIG_FRAME_THREAD_ENCODER 0 -+#define CONFIG_G722DSP 0 -+#define CONFIG_GOLOMB 1 -+#define CONFIG_GPLV3 0 -+#define CONFIG_H263DSP 0 -+#define CONFIG_H264CHROMA 1 -+#define CONFIG_H264DSP 1 -+#define CONFIG_H264PARSE 1 -+#define CONFIG_H264PRED 1 -+#define CONFIG_H264QPEL 1 -+#define CONFIG_HEVCPARSE 0 -+#define CONFIG_HPELDSP 1 -+#define CONFIG_HUFFMAN 0 -+#define CONFIG_HUFFYUVDSP 0 -+#define CONFIG_HUFFYUVENCDSP 0 -+#define CONFIG_IDCTDSP 0 -+#define CONFIG_IIRFILTER 0 -+#define CONFIG_MDCT15 1 -+#define CONFIG_INTRAX8 0 -+#define CONFIG_ISO_MEDIA 1 -+#define CONFIG_IVIDSP 0 -+#define CONFIG_JPEGTABLES 0 -+#define CONFIG_LGPLV3 0 -+#define CONFIG_LIBX262 0 -+#define CONFIG_LLAUDDSP 0 -+#define CONFIG_LLVIDDSP 0 -+#define CONFIG_LLVIDENCDSP 0 -+#define CONFIG_LPC 0 -+#define CONFIG_LZF 0 -+#define CONFIG_ME_CMP 0 -+#define CONFIG_MPEG_ER 0 -+#define CONFIG_MPEGAUDIO 1 -+#define CONFIG_MPEGAUDIODSP 1 -+#define CONFIG_MPEGAUDIOHEADER 1 -+#define CONFIG_MPEGVIDEO 0 -+#define CONFIG_MPEGVIDEOENC 0 -+#define CONFIG_MSS34DSP 0 -+#define CONFIG_PIXBLOCKDSP 0 -+#define CONFIG_QPELDSP 0 -+#define CONFIG_QSV 0 -+#define CONFIG_QSVDEC 0 -+#define CONFIG_QSVENC 0 -+#define CONFIG_QSVVPP 0 -+#define CONFIG_RANGECODER 0 -+#define CONFIG_RIFFDEC 1 -+#define CONFIG_RIFFENC 0 -+#define CONFIG_RTPDEC 0 -+#define CONFIG_RTPENC_CHAIN 0 -+#define CONFIG_RV34DSP 0 -+#define CONFIG_SCENE_SAD 0 -+#define CONFIG_SINEWIN 1 -+#define CONFIG_SNAPPY 0 -+#define CONFIG_SRTP 0 -+#define CONFIG_STARTCODE 1 -+#define CONFIG_TEXTUREDSP 0 -+#define CONFIG_TEXTUREDSPENC 0 -+#define CONFIG_TPELDSP 0 -+#define CONFIG_VAAPI_1 0 -+#define CONFIG_VAAPI_ENCODE 0 -+#define CONFIG_VC1DSP 0 -+#define CONFIG_VIDEODSP 1 -+#define CONFIG_VP3DSP 1 -+#define CONFIG_VP56DSP 0 -+#define CONFIG_VP8DSP 1 -+#define CONFIG_WMA_FREQS 0 -+#define CONFIG_WMV2DSP 0 -+#define CONFIG_AAC_ADTSTOASC_BSF 0 -+#define CONFIG_AV1_FRAME_MERGE_BSF 0 -+#define CONFIG_AV1_FRAME_SPLIT_BSF 0 -+#define CONFIG_AV1_METADATA_BSF 0 -+#define CONFIG_CHOMP_BSF 0 -+#define CONFIG_DUMP_EXTRADATA_BSF 0 -+#define CONFIG_DCA_CORE_BSF 0 -+#define CONFIG_EAC3_CORE_BSF 0 -+#define CONFIG_EXTRACT_EXTRADATA_BSF 0 -+#define CONFIG_FILTER_UNITS_BSF 0 -+#define CONFIG_H264_METADATA_BSF 0 -+#define CONFIG_H264_MP4TOANNEXB_BSF 0 -+#define CONFIG_H264_REDUNDANT_PPS_BSF 0 -+#define CONFIG_HAPQA_EXTRACT_BSF 0 -+#define CONFIG_HEVC_METADATA_BSF 0 -+#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 -+#define CONFIG_IMX_DUMP_HEADER_BSF 0 -+#define CONFIG_MJPEG2JPEG_BSF 0 -+#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 -+#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 -+#define CONFIG_MPEG2_METADATA_BSF 0 -+#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 -+#define CONFIG_MOV2TEXTSUB_BSF 0 -+#define CONFIG_NOISE_BSF 0 -+#define CONFIG_NULL_BSF 1 -+#define CONFIG_OPUS_METADATA_BSF 0 -+#define CONFIG_PCM_RECHUNK_BSF 0 -+#define CONFIG_PRORES_METADATA_BSF 0 -+#define CONFIG_REMOVE_EXTRADATA_BSF 0 -+#define CONFIG_TEXT2MOVSUB_BSF 0 -+#define CONFIG_TRACE_HEADERS_BSF 0 -+#define CONFIG_TRUEHD_CORE_BSF 0 -+#define CONFIG_VP9_METADATA_BSF 0 -+#define CONFIG_VP9_RAW_REORDER_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 -+#define CONFIG_AASC_DECODER 0 -+#define CONFIG_AIC_DECODER 0 -+#define CONFIG_ALIAS_PIX_DECODER 0 -+#define CONFIG_AGM_DECODER 0 -+#define CONFIG_AMV_DECODER 0 -+#define CONFIG_ANM_DECODER 0 -+#define CONFIG_ANSI_DECODER 0 -+#define CONFIG_APNG_DECODER 0 -+#define CONFIG_ARBC_DECODER 0 -+#define CONFIG_ASV1_DECODER 0 -+#define CONFIG_ASV2_DECODER 0 -+#define CONFIG_AURA_DECODER 0 -+#define CONFIG_AURA2_DECODER 0 -+#define CONFIG_AVRP_DECODER 0 -+#define CONFIG_AVRN_DECODER 0 -+#define CONFIG_AVS_DECODER 0 -+#define CONFIG_AVUI_DECODER 0 -+#define CONFIG_AYUV_DECODER 0 -+#define CONFIG_BETHSOFTVID_DECODER 0 -+#define CONFIG_BFI_DECODER 0 -+#define CONFIG_BINK_DECODER 0 -+#define CONFIG_BITPACKED_DECODER 0 -+#define CONFIG_BMP_DECODER 0 -+#define CONFIG_BMV_VIDEO_DECODER 0 -+#define CONFIG_BRENDER_PIX_DECODER 0 -+#define CONFIG_C93_DECODER 0 -+#define CONFIG_CAVS_DECODER 0 -+#define CONFIG_CDGRAPHICS_DECODER 0 -+#define CONFIG_CDTOONS_DECODER 0 -+#define CONFIG_CDXL_DECODER 0 -+#define CONFIG_CFHD_DECODER 0 -+#define CONFIG_CINEPAK_DECODER 0 -+#define CONFIG_CLEARVIDEO_DECODER 0 -+#define CONFIG_CLJR_DECODER 0 -+#define CONFIG_CLLC_DECODER 0 -+#define CONFIG_COMFORTNOISE_DECODER 0 -+#define CONFIG_CPIA_DECODER 0 -+#define CONFIG_CSCD_DECODER 0 -+#define CONFIG_CYUV_DECODER 0 -+#define CONFIG_DDS_DECODER 0 -+#define CONFIG_DFA_DECODER 0 -+#define CONFIG_DIRAC_DECODER 0 -+#define CONFIG_DNXHD_DECODER 0 -+#define CONFIG_DPX_DECODER 0 -+#define CONFIG_DSICINVIDEO_DECODER 0 -+#define CONFIG_DVAUDIO_DECODER 0 -+#define CONFIG_DVVIDEO_DECODER 0 -+#define CONFIG_DXA_DECODER 0 -+#define CONFIG_DXTORY_DECODER 0 -+#define CONFIG_DXV_DECODER 0 -+#define CONFIG_EACMV_DECODER 0 -+#define CONFIG_EAMAD_DECODER 0 -+#define CONFIG_EATGQ_DECODER 0 -+#define CONFIG_EATGV_DECODER 0 -+#define CONFIG_EATQI_DECODER 0 -+#define CONFIG_EIGHTBPS_DECODER 0 -+#define CONFIG_EIGHTSVX_EXP_DECODER 0 -+#define CONFIG_EIGHTSVX_FIB_DECODER 0 -+#define CONFIG_ESCAPE124_DECODER 0 -+#define CONFIG_ESCAPE130_DECODER 0 -+#define CONFIG_EXR_DECODER 0 -+#define CONFIG_FFV1_DECODER 0 -+#define CONFIG_FFVHUFF_DECODER 0 -+#define CONFIG_FIC_DECODER 0 -+#define CONFIG_FITS_DECODER 0 -+#define CONFIG_FLASHSV_DECODER 0 -+#define CONFIG_FLASHSV2_DECODER 0 -+#define CONFIG_FLIC_DECODER 0 -+#define CONFIG_FLV_DECODER 0 -+#define CONFIG_FMVC_DECODER 0 -+#define CONFIG_FOURXM_DECODER 0 -+#define CONFIG_FRAPS_DECODER 0 -+#define CONFIG_FRWU_DECODER 0 -+#define CONFIG_G2M_DECODER 0 -+#define CONFIG_GDV_DECODER 0 -+#define CONFIG_GIF_DECODER 0 -+#define CONFIG_H261_DECODER 0 -+#define CONFIG_H263_DECODER 0 -+#define CONFIG_H263I_DECODER 0 -+#define CONFIG_H263P_DECODER 0 -+#define CONFIG_H263_V4L2M2M_DECODER 0 -+#define CONFIG_H264_DECODER 1 -+#define CONFIG_H264_CRYSTALHD_DECODER 0 -+#define CONFIG_H264_V4L2M2M_DECODER 0 -+#define CONFIG_H264_MEDIACODEC_DECODER 0 -+#define CONFIG_H264_MMAL_DECODER 0 -+#define CONFIG_H264_QSV_DECODER 0 -+#define CONFIG_H264_RKMPP_DECODER 0 -+#define CONFIG_HAP_DECODER 0 -+#define CONFIG_HEVC_DECODER 0 -+#define CONFIG_HEVC_QSV_DECODER 0 -+#define CONFIG_HEVC_RKMPP_DECODER 0 -+#define CONFIG_HEVC_V4L2M2M_DECODER 0 -+#define CONFIG_HNM4_VIDEO_DECODER 0 -+#define CONFIG_HQ_HQA_DECODER 0 -+#define CONFIG_HQX_DECODER 0 -+#define CONFIG_HUFFYUV_DECODER 0 -+#define CONFIG_HYMT_DECODER 0 -+#define CONFIG_IDCIN_DECODER 0 -+#define CONFIG_IFF_ILBM_DECODER 0 -+#define CONFIG_IMM4_DECODER 0 -+#define CONFIG_IMM5_DECODER 0 -+#define CONFIG_INDEO2_DECODER 0 -+#define CONFIG_INDEO3_DECODER 0 -+#define CONFIG_INDEO4_DECODER 0 -+#define CONFIG_INDEO5_DECODER 0 -+#define CONFIG_INTERPLAY_VIDEO_DECODER 0 -+#define CONFIG_JPEG2000_DECODER 0 -+#define CONFIG_JPEGLS_DECODER 0 -+#define CONFIG_JV_DECODER 0 -+#define CONFIG_KGV1_DECODER 0 -+#define CONFIG_KMVC_DECODER 0 -+#define CONFIG_LAGARITH_DECODER 0 -+#define CONFIG_LOCO_DECODER 0 -+#define CONFIG_LSCR_DECODER 0 -+#define CONFIG_M101_DECODER 0 -+#define CONFIG_MAGICYUV_DECODER 0 -+#define CONFIG_MDEC_DECODER 0 -+#define CONFIG_MIMIC_DECODER 0 -+#define CONFIG_MJPEG_DECODER 0 -+#define CONFIG_MJPEGB_DECODER 0 -+#define CONFIG_MMVIDEO_DECODER 0 -+#define CONFIG_MOTIONPIXELS_DECODER 0 -+#define CONFIG_MPEG1VIDEO_DECODER 0 -+#define CONFIG_MPEG2VIDEO_DECODER 0 -+#define CONFIG_MPEG4_DECODER 0 -+#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG4_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG4_MMAL_DECODER 0 -+#define CONFIG_MPEGVIDEO_DECODER 0 -+#define CONFIG_MPEG1_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_MMAL_DECODER 0 -+#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG2_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_QSV_DECODER 0 -+#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 -+#define CONFIG_MSA1_DECODER 0 -+#define CONFIG_MSCC_DECODER 0 -+#define CONFIG_MSMPEG4V1_DECODER 0 -+#define CONFIG_MSMPEG4V2_DECODER 0 -+#define CONFIG_MSMPEG4V3_DECODER 0 -+#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MSRLE_DECODER 0 -+#define CONFIG_MSS1_DECODER 0 -+#define CONFIG_MSS2_DECODER 0 -+#define CONFIG_MSVIDEO1_DECODER 0 -+#define CONFIG_MSZH_DECODER 0 -+#define CONFIG_MTS2_DECODER 0 -+#define CONFIG_MV30_DECODER 0 -+#define CONFIG_MVC1_DECODER 0 -+#define CONFIG_MVC2_DECODER 0 -+#define CONFIG_MVDV_DECODER 0 -+#define CONFIG_MVHA_DECODER 0 -+#define CONFIG_MWSC_DECODER 0 -+#define CONFIG_MXPEG_DECODER 0 -+#define CONFIG_NOTCHLC_DECODER 0 -+#define CONFIG_NUV_DECODER 0 -+#define CONFIG_PAF_VIDEO_DECODER 0 -+#define CONFIG_PAM_DECODER 0 -+#define CONFIG_PBM_DECODER 0 -+#define CONFIG_PCX_DECODER 0 -+#define CONFIG_PFM_DECODER 0 -+#define CONFIG_PGM_DECODER 0 -+#define CONFIG_PGMYUV_DECODER 0 -+#define CONFIG_PGX_DECODER 0 -+#define CONFIG_PICTOR_DECODER 0 -+#define CONFIG_PIXLET_DECODER 0 -+#define CONFIG_PNG_DECODER 0 -+#define CONFIG_PPM_DECODER 0 -+#define CONFIG_PRORES_DECODER 0 -+#define CONFIG_PROSUMER_DECODER 0 -+#define CONFIG_PSD_DECODER 0 -+#define CONFIG_PTX_DECODER 0 -+#define CONFIG_QDRAW_DECODER 0 -+#define CONFIG_QPEG_DECODER 0 -+#define CONFIG_QTRLE_DECODER 0 -+#define CONFIG_R10K_DECODER 0 -+#define CONFIG_R210_DECODER 0 -+#define CONFIG_RASC_DECODER 0 -+#define CONFIG_RAWVIDEO_DECODER 0 -+#define CONFIG_RL2_DECODER 0 -+#define CONFIG_ROQ_DECODER 0 -+#define CONFIG_RPZA_DECODER 0 -+#define CONFIG_RSCC_DECODER 0 -+#define CONFIG_RV10_DECODER 0 -+#define CONFIG_RV20_DECODER 0 -+#define CONFIG_RV30_DECODER 0 -+#define CONFIG_RV40_DECODER 0 -+#define CONFIG_S302M_DECODER 0 -+#define CONFIG_SANM_DECODER 0 -+#define CONFIG_SCPR_DECODER 0 -+#define CONFIG_SCREENPRESSO_DECODER 0 -+#define CONFIG_SGI_DECODER 0 -+#define CONFIG_SGIRLE_DECODER 0 -+#define CONFIG_SHEERVIDEO_DECODER 0 -+#define CONFIG_SMACKER_DECODER 0 -+#define CONFIG_SMC_DECODER 0 -+#define CONFIG_SMVJPEG_DECODER 0 -+#define CONFIG_SNOW_DECODER 0 -+#define CONFIG_SP5X_DECODER 0 -+#define CONFIG_SPEEDHQ_DECODER 0 -+#define CONFIG_SRGC_DECODER 0 -+#define CONFIG_SUNRAST_DECODER 0 -+#define CONFIG_SVQ1_DECODER 0 -+#define CONFIG_SVQ3_DECODER 0 -+#define CONFIG_TARGA_DECODER 0 -+#define CONFIG_TARGA_Y216_DECODER 0 -+#define CONFIG_TDSC_DECODER 0 -+#define CONFIG_THEORA_DECODER 1 -+#define CONFIG_THP_DECODER 0 -+#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 -+#define CONFIG_TIFF_DECODER 0 -+#define CONFIG_TMV_DECODER 0 -+#define CONFIG_TRUEMOTION1_DECODER 0 -+#define CONFIG_TRUEMOTION2_DECODER 0 -+#define CONFIG_TRUEMOTION2RT_DECODER 0 -+#define CONFIG_TSCC_DECODER 0 -+#define CONFIG_TSCC2_DECODER 0 -+#define CONFIG_TXD_DECODER 0 -+#define CONFIG_ULTI_DECODER 0 -+#define CONFIG_UTVIDEO_DECODER 0 -+#define CONFIG_V210_DECODER 0 -+#define CONFIG_V210X_DECODER 0 -+#define CONFIG_V308_DECODER 0 -+#define CONFIG_V408_DECODER 0 -+#define CONFIG_V410_DECODER 0 -+#define CONFIG_VB_DECODER 0 -+#define CONFIG_VBLE_DECODER 0 -+#define CONFIG_VC1_DECODER 0 -+#define CONFIG_VC1_CRYSTALHD_DECODER 0 -+#define CONFIG_VC1IMAGE_DECODER 0 -+#define CONFIG_VC1_MMAL_DECODER 0 -+#define CONFIG_VC1_QSV_DECODER 0 -+#define CONFIG_VC1_V4L2M2M_DECODER 0 -+#define CONFIG_VCR1_DECODER 0 -+#define CONFIG_VMDVIDEO_DECODER 0 -+#define CONFIG_VMNC_DECODER 0 -+#define CONFIG_VP3_DECODER 1 -+#define CONFIG_VP4_DECODER 0 -+#define CONFIG_VP5_DECODER 0 -+#define CONFIG_VP6_DECODER 0 -+#define CONFIG_VP6A_DECODER 0 -+#define CONFIG_VP6F_DECODER 0 -+#define CONFIG_VP7_DECODER 0 -+#define CONFIG_VP8_DECODER 1 -+#define CONFIG_VP8_RKMPP_DECODER 0 -+#define CONFIG_VP8_V4L2M2M_DECODER 0 -+#define CONFIG_VP9_DECODER 0 -+#define CONFIG_VP9_RKMPP_DECODER 0 -+#define CONFIG_VP9_V4L2M2M_DECODER 0 -+#define CONFIG_VQA_DECODER 0 -+#define CONFIG_WEBP_DECODER 0 -+#define CONFIG_WCMV_DECODER 0 -+#define CONFIG_WRAPPED_AVFRAME_DECODER 0 -+#define CONFIG_WMV1_DECODER 0 -+#define CONFIG_WMV2_DECODER 0 -+#define CONFIG_WMV3_DECODER 0 -+#define CONFIG_WMV3_CRYSTALHD_DECODER 0 -+#define CONFIG_WMV3IMAGE_DECODER 0 -+#define CONFIG_WNV1_DECODER 0 -+#define CONFIG_XAN_WC3_DECODER 0 -+#define CONFIG_XAN_WC4_DECODER 0 -+#define CONFIG_XBM_DECODER 0 -+#define CONFIG_XFACE_DECODER 0 -+#define CONFIG_XL_DECODER 0 -+#define CONFIG_XPM_DECODER 0 -+#define CONFIG_XWD_DECODER 0 -+#define CONFIG_Y41P_DECODER 0 -+#define CONFIG_YLC_DECODER 0 -+#define CONFIG_YOP_DECODER 0 -+#define CONFIG_YUV4_DECODER 0 -+#define CONFIG_ZERO12V_DECODER 0 -+#define CONFIG_ZEROCODEC_DECODER 0 -+#define CONFIG_ZLIB_DECODER 0 -+#define CONFIG_ZMBV_DECODER 0 -+#define CONFIG_AAC_DECODER 1 -+#define CONFIG_AAC_FIXED_DECODER 0 -+#define CONFIG_AAC_LATM_DECODER 0 -+#define CONFIG_AC3_DECODER 0 -+#define CONFIG_AC3_FIXED_DECODER 0 -+#define CONFIG_ACELP_KELVIN_DECODER 0 -+#define CONFIG_ALAC_DECODER 0 -+#define CONFIG_ALS_DECODER 0 -+#define CONFIG_AMRNB_DECODER 0 -+#define CONFIG_AMRWB_DECODER 0 -+#define CONFIG_APE_DECODER 0 -+#define CONFIG_APTX_DECODER 0 -+#define CONFIG_APTX_HD_DECODER 0 -+#define CONFIG_ATRAC1_DECODER 0 -+#define CONFIG_ATRAC3_DECODER 0 -+#define CONFIG_ATRAC3AL_DECODER 0 -+#define CONFIG_ATRAC3P_DECODER 0 -+#define CONFIG_ATRAC3PAL_DECODER 0 -+#define CONFIG_ATRAC9_DECODER 0 -+#define CONFIG_BINKAUDIO_DCT_DECODER 0 -+#define CONFIG_BINKAUDIO_RDFT_DECODER 0 -+#define CONFIG_BMV_AUDIO_DECODER 0 -+#define CONFIG_COOK_DECODER 0 -+#define CONFIG_DCA_DECODER 0 -+#define CONFIG_DOLBY_E_DECODER 0 -+#define CONFIG_DSD_LSBF_DECODER 0 -+#define CONFIG_DSD_MSBF_DECODER 0 -+#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 -+#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 -+#define CONFIG_DSICINAUDIO_DECODER 0 -+#define CONFIG_DSS_SP_DECODER 0 -+#define CONFIG_DST_DECODER 0 -+#define CONFIG_EAC3_DECODER 0 -+#define CONFIG_EVRC_DECODER 0 -+#define CONFIG_FFWAVESYNTH_DECODER 0 -+#define CONFIG_FLAC_DECODER 1 -+#define CONFIG_G723_1_DECODER 0 -+#define CONFIG_G729_DECODER 0 -+#define CONFIG_GSM_DECODER 0 -+#define CONFIG_GSM_MS_DECODER 0 -+#define CONFIG_HCA_DECODER 0 -+#define CONFIG_HCOM_DECODER 0 -+#define CONFIG_IAC_DECODER 0 -+#define CONFIG_ILBC_DECODER 0 -+#define CONFIG_IMC_DECODER 0 -+#define CONFIG_INTERPLAY_ACM_DECODER 0 -+#define CONFIG_MACE3_DECODER 0 -+#define CONFIG_MACE6_DECODER 0 -+#define CONFIG_METASOUND_DECODER 0 -+#define CONFIG_MLP_DECODER 0 -+#define CONFIG_MP1_DECODER 0 -+#define CONFIG_MP1FLOAT_DECODER 0 -+#define CONFIG_MP2_DECODER 0 -+#define CONFIG_MP2FLOAT_DECODER 0 -+#define CONFIG_MP3FLOAT_DECODER 0 -+#define CONFIG_MP3_DECODER 1 -+#define CONFIG_MP3ADUFLOAT_DECODER 0 -+#define CONFIG_MP3ADU_DECODER 0 -+#define CONFIG_MP3ON4FLOAT_DECODER 0 -+#define CONFIG_MP3ON4_DECODER 0 -+#define CONFIG_MPC7_DECODER 0 -+#define CONFIG_MPC8_DECODER 0 -+#define CONFIG_NELLYMOSER_DECODER 0 -+#define CONFIG_ON2AVC_DECODER 0 -+#define CONFIG_OPUS_DECODER 0 -+#define CONFIG_PAF_AUDIO_DECODER 0 -+#define CONFIG_QCELP_DECODER 0 -+#define CONFIG_QDM2_DECODER 0 -+#define CONFIG_QDMC_DECODER 0 -+#define CONFIG_RA_144_DECODER 0 -+#define CONFIG_RA_288_DECODER 0 -+#define CONFIG_RALF_DECODER 0 -+#define CONFIG_SBC_DECODER 0 -+#define CONFIG_SHORTEN_DECODER 0 -+#define CONFIG_SIPR_DECODER 0 -+#define CONFIG_SIREN_DECODER 0 -+#define CONFIG_SMACKAUD_DECODER 0 -+#define CONFIG_SONIC_DECODER 0 -+#define CONFIG_TAK_DECODER 0 -+#define CONFIG_TRUEHD_DECODER 0 -+#define CONFIG_TRUESPEECH_DECODER 0 -+#define CONFIG_TTA_DECODER 0 -+#define CONFIG_TWINVQ_DECODER 0 -+#define CONFIG_VMDAUDIO_DECODER 0 -+#define CONFIG_VORBIS_DECODER 1 -+#define CONFIG_WAVPACK_DECODER 0 -+#define CONFIG_WMALOSSLESS_DECODER 0 -+#define CONFIG_WMAPRO_DECODER 0 -+#define CONFIG_WMAV1_DECODER 0 -+#define CONFIG_WMAV2_DECODER 0 -+#define CONFIG_WMAVOICE_DECODER 0 -+#define CONFIG_WS_SND1_DECODER 0 -+#define CONFIG_XMA1_DECODER 0 -+#define CONFIG_XMA2_DECODER 0 -+#define CONFIG_PCM_ALAW_DECODER 1 -+#define CONFIG_PCM_BLURAY_DECODER 0 -+#define CONFIG_PCM_DVD_DECODER 0 -+#define CONFIG_PCM_F16LE_DECODER 0 -+#define CONFIG_PCM_F24LE_DECODER 0 -+#define CONFIG_PCM_F32BE_DECODER 0 -+#define CONFIG_PCM_F32LE_DECODER 1 -+#define CONFIG_PCM_F64BE_DECODER 0 -+#define CONFIG_PCM_F64LE_DECODER 0 -+#define CONFIG_PCM_LXF_DECODER 0 -+#define CONFIG_PCM_MULAW_DECODER 1 -+#define CONFIG_PCM_S8_DECODER 0 -+#define CONFIG_PCM_S8_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16BE_DECODER 1 -+#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16LE_DECODER 1 -+#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S24BE_DECODER 1 -+#define CONFIG_PCM_S24DAUD_DECODER 0 -+#define CONFIG_PCM_S24LE_DECODER 1 -+#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S32BE_DECODER 0 -+#define CONFIG_PCM_S32LE_DECODER 1 -+#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S64BE_DECODER 0 -+#define CONFIG_PCM_S64LE_DECODER 0 -+#define CONFIG_PCM_U8_DECODER 1 -+#define CONFIG_PCM_U16BE_DECODER 0 -+#define CONFIG_PCM_U16LE_DECODER 0 -+#define CONFIG_PCM_U24BE_DECODER 0 -+#define CONFIG_PCM_U24LE_DECODER 0 -+#define CONFIG_PCM_U32BE_DECODER 0 -+#define CONFIG_PCM_U32LE_DECODER 0 -+#define CONFIG_PCM_VIDC_DECODER 0 -+#define CONFIG_DERF_DPCM_DECODER 0 -+#define CONFIG_GREMLIN_DPCM_DECODER 0 -+#define CONFIG_INTERPLAY_DPCM_DECODER 0 -+#define CONFIG_ROQ_DPCM_DECODER 0 -+#define CONFIG_SDX2_DPCM_DECODER 0 -+#define CONFIG_SOL_DPCM_DECODER 0 -+#define CONFIG_XAN_DPCM_DECODER 0 -+#define CONFIG_ADPCM_4XM_DECODER 0 -+#define CONFIG_ADPCM_ADX_DECODER 0 -+#define CONFIG_ADPCM_AFC_DECODER 0 -+#define CONFIG_ADPCM_AGM_DECODER 0 -+#define CONFIG_ADPCM_AICA_DECODER 0 -+#define CONFIG_ADPCM_ARGO_DECODER 0 -+#define CONFIG_ADPCM_CT_DECODER 0 -+#define CONFIG_ADPCM_DTK_DECODER 0 -+#define CONFIG_ADPCM_EA_DECODER 0 -+#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 -+#define CONFIG_ADPCM_EA_R1_DECODER 0 -+#define CONFIG_ADPCM_EA_R2_DECODER 0 -+#define CONFIG_ADPCM_EA_R3_DECODER 0 -+#define CONFIG_ADPCM_EA_XAS_DECODER 0 -+#define CONFIG_ADPCM_G722_DECODER 0 -+#define CONFIG_ADPCM_G726_DECODER 0 -+#define CONFIG_ADPCM_G726LE_DECODER 0 -+#define CONFIG_ADPCM_IMA_AMV_DECODER 0 -+#define CONFIG_ADPCM_IMA_ALP_DECODER 0 -+#define CONFIG_ADPCM_IMA_APC_DECODER 0 -+#define CONFIG_ADPCM_IMA_APM_DECODER 0 -+#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 -+#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK3_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK4_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_ISS_DECODER 0 -+#define CONFIG_ADPCM_IMA_MTF_DECODER 0 -+#define CONFIG_ADPCM_IMA_OKI_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_DECODER 0 -+#define CONFIG_ADPCM_IMA_RAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_SSI_DECODER 0 -+#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 -+#define CONFIG_ADPCM_IMA_WAV_DECODER 0 -+#define CONFIG_ADPCM_IMA_WS_DECODER 0 -+#define CONFIG_ADPCM_MS_DECODER 0 -+#define CONFIG_ADPCM_MTAF_DECODER 0 -+#define CONFIG_ADPCM_PSX_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_2_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_3_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_4_DECODER 0 -+#define CONFIG_ADPCM_SWF_DECODER 0 -+#define CONFIG_ADPCM_THP_DECODER 0 -+#define CONFIG_ADPCM_THP_LE_DECODER 0 -+#define CONFIG_ADPCM_VIMA_DECODER 0 -+#define CONFIG_ADPCM_XA_DECODER 0 -+#define CONFIG_ADPCM_YAMAHA_DECODER 0 -+#define CONFIG_ADPCM_ZORK_DECODER 0 -+#define CONFIG_SSA_DECODER 0 -+#define CONFIG_ASS_DECODER 0 -+#define CONFIG_CCAPTION_DECODER 0 -+#define CONFIG_DVBSUB_DECODER 0 -+#define CONFIG_DVDSUB_DECODER 0 -+#define CONFIG_JACOSUB_DECODER 0 -+#define CONFIG_MICRODVD_DECODER 0 -+#define CONFIG_MOVTEXT_DECODER 0 -+#define CONFIG_MPL2_DECODER 0 -+#define CONFIG_PGSSUB_DECODER 0 -+#define CONFIG_PJS_DECODER 0 -+#define CONFIG_REALTEXT_DECODER 0 -+#define CONFIG_SAMI_DECODER 0 -+#define CONFIG_SRT_DECODER 0 -+#define CONFIG_STL_DECODER 0 -+#define CONFIG_SUBRIP_DECODER 0 -+#define CONFIG_SUBVIEWER_DECODER 0 -+#define CONFIG_SUBVIEWER1_DECODER 0 -+#define CONFIG_TEXT_DECODER 0 -+#define CONFIG_VPLAYER_DECODER 0 -+#define CONFIG_WEBVTT_DECODER 0 -+#define CONFIG_XSUB_DECODER 0 -+#define CONFIG_AAC_AT_DECODER 0 -+#define CONFIG_AC3_AT_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 -+#define CONFIG_ALAC_AT_DECODER 0 -+#define CONFIG_AMR_NB_AT_DECODER 0 -+#define CONFIG_EAC3_AT_DECODER 0 -+#define CONFIG_GSM_MS_AT_DECODER 0 -+#define CONFIG_ILBC_AT_DECODER 0 -+#define CONFIG_MP1_AT_DECODER 0 -+#define CONFIG_MP2_AT_DECODER 0 -+#define CONFIG_MP3_AT_DECODER 0 -+#define CONFIG_PCM_ALAW_AT_DECODER 0 -+#define CONFIG_PCM_MULAW_AT_DECODER 0 -+#define CONFIG_QDMC_AT_DECODER 0 -+#define CONFIG_QDM2_AT_DECODER 0 -+#define CONFIG_LIBARIBB24_DECODER 0 -+#define CONFIG_LIBCELT_DECODER 0 -+#define CONFIG_LIBCODEC2_DECODER 0 -+#define CONFIG_LIBDAV1D_DECODER 0 -+#define CONFIG_LIBDAVS2_DECODER 0 -+#define CONFIG_LIBFDK_AAC_DECODER 0 -+#define CONFIG_LIBGSM_DECODER 0 -+#define CONFIG_LIBGSM_MS_DECODER 0 -+#define CONFIG_LIBILBC_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 -+#define CONFIG_LIBOPENJPEG_DECODER 0 -+#define CONFIG_LIBOPUS_DECODER 1 -+#define CONFIG_LIBRSVG_DECODER 0 -+#define CONFIG_LIBSPEEX_DECODER 0 -+#define CONFIG_LIBVORBIS_DECODER 0 -+#define CONFIG_LIBVPX_VP8_DECODER 0 -+#define CONFIG_LIBVPX_VP9_DECODER 0 -+#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 -+#define CONFIG_BINTEXT_DECODER 0 -+#define CONFIG_XBIN_DECODER 0 -+#define CONFIG_IDF_DECODER 0 -+#define CONFIG_LIBAOM_AV1_DECODER 0 -+#define CONFIG_LIBOPENH264_DECODER 0 -+#define CONFIG_H264_CUVID_DECODER 0 -+#define CONFIG_HEVC_CUVID_DECODER 0 -+#define CONFIG_HEVC_MEDIACODEC_DECODER 0 -+#define CONFIG_MJPEG_CUVID_DECODER 0 -+#define CONFIG_MJPEG_QSV_DECODER 0 -+#define CONFIG_MPEG1_CUVID_DECODER 0 -+#define CONFIG_MPEG2_CUVID_DECODER 0 -+#define CONFIG_MPEG4_CUVID_DECODER 0 -+#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 -+#define CONFIG_VC1_CUVID_DECODER 0 -+#define CONFIG_VP8_CUVID_DECODER 0 -+#define CONFIG_VP8_MEDIACODEC_DECODER 0 -+#define CONFIG_VP8_QSV_DECODER 0 -+#define CONFIG_VP9_CUVID_DECODER 0 -+#define CONFIG_VP9_MEDIACODEC_DECODER 0 -+#define CONFIG_VP9_QSV_DECODER 0 -+#define CONFIG_A64MULTI_ENCODER 0 -+#define CONFIG_A64MULTI5_ENCODER 0 -+#define CONFIG_ALIAS_PIX_ENCODER 0 -+#define CONFIG_AMV_ENCODER 0 -+#define CONFIG_APNG_ENCODER 0 -+#define CONFIG_ASV1_ENCODER 0 -+#define CONFIG_ASV2_ENCODER 0 -+#define CONFIG_AVRP_ENCODER 0 -+#define CONFIG_AVUI_ENCODER 0 -+#define CONFIG_AYUV_ENCODER 0 -+#define CONFIG_BMP_ENCODER 0 -+#define CONFIG_CFHD_ENCODER 0 -+#define CONFIG_CINEPAK_ENCODER 0 -+#define CONFIG_CLJR_ENCODER 0 -+#define CONFIG_COMFORTNOISE_ENCODER 0 -+#define CONFIG_DNXHD_ENCODER 0 -+#define CONFIG_DPX_ENCODER 0 -+#define CONFIG_DVVIDEO_ENCODER 0 -+#define CONFIG_FFV1_ENCODER 0 -+#define CONFIG_FFVHUFF_ENCODER 0 -+#define CONFIG_FITS_ENCODER 0 -+#define CONFIG_FLASHSV_ENCODER 0 -+#define CONFIG_FLASHSV2_ENCODER 0 -+#define CONFIG_FLV_ENCODER 0 -+#define CONFIG_GIF_ENCODER 0 -+#define CONFIG_H261_ENCODER 0 -+#define CONFIG_H263_ENCODER 0 -+#define CONFIG_H263P_ENCODER 0 -+#define CONFIG_HAP_ENCODER 0 -+#define CONFIG_HUFFYUV_ENCODER 0 -+#define CONFIG_JPEG2000_ENCODER 0 -+#define CONFIG_JPEGLS_ENCODER 0 -+#define CONFIG_LJPEG_ENCODER 0 -+#define CONFIG_MAGICYUV_ENCODER 0 -+#define CONFIG_MJPEG_ENCODER 0 -+#define CONFIG_MPEG1VIDEO_ENCODER 0 -+#define CONFIG_MPEG2VIDEO_ENCODER 0 -+#define CONFIG_MPEG4_ENCODER 0 -+#define CONFIG_MSMPEG4V2_ENCODER 0 -+#define CONFIG_MSMPEG4V3_ENCODER 0 -+#define CONFIG_MSVIDEO1_ENCODER 0 -+#define CONFIG_PAM_ENCODER 0 -+#define CONFIG_PBM_ENCODER 0 -+#define CONFIG_PCX_ENCODER 0 -+#define CONFIG_PGM_ENCODER 0 -+#define CONFIG_PGMYUV_ENCODER 0 -+#define CONFIG_PNG_ENCODER 0 -+#define CONFIG_PPM_ENCODER 0 -+#define CONFIG_PRORES_ENCODER 0 -+#define CONFIG_PRORES_AW_ENCODER 0 -+#define CONFIG_PRORES_KS_ENCODER 0 -+#define CONFIG_QTRLE_ENCODER 0 -+#define CONFIG_R10K_ENCODER 0 -+#define CONFIG_R210_ENCODER 0 -+#define CONFIG_RAWVIDEO_ENCODER 0 -+#define CONFIG_ROQ_ENCODER 0 -+#define CONFIG_RPZA_ENCODER 0 -+#define CONFIG_RV10_ENCODER 0 -+#define CONFIG_RV20_ENCODER 0 -+#define CONFIG_S302M_ENCODER 0 -+#define CONFIG_SGI_ENCODER 0 -+#define CONFIG_SNOW_ENCODER 0 -+#define CONFIG_SUNRAST_ENCODER 0 -+#define CONFIG_SVQ1_ENCODER 0 -+#define CONFIG_TARGA_ENCODER 0 -+#define CONFIG_TIFF_ENCODER 0 -+#define CONFIG_UTVIDEO_ENCODER 0 -+#define CONFIG_V210_ENCODER 0 -+#define CONFIG_V308_ENCODER 0 -+#define CONFIG_V408_ENCODER 0 -+#define CONFIG_V410_ENCODER 0 -+#define CONFIG_VC2_ENCODER 0 -+#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 -+#define CONFIG_WMV1_ENCODER 0 -+#define CONFIG_WMV2_ENCODER 0 -+#define CONFIG_XBM_ENCODER 0 -+#define CONFIG_XFACE_ENCODER 0 -+#define CONFIG_XWD_ENCODER 0 -+#define CONFIG_Y41P_ENCODER 0 -+#define CONFIG_YUV4_ENCODER 0 -+#define CONFIG_ZLIB_ENCODER 0 -+#define CONFIG_ZMBV_ENCODER 0 -+#define CONFIG_AAC_ENCODER 0 -+#define CONFIG_AC3_ENCODER 0 -+#define CONFIG_AC3_FIXED_ENCODER 0 -+#define CONFIG_ALAC_ENCODER 0 -+#define CONFIG_APTX_ENCODER 0 -+#define CONFIG_APTX_HD_ENCODER 0 -+#define CONFIG_DCA_ENCODER 0 -+#define CONFIG_EAC3_ENCODER 0 -+#define CONFIG_FLAC_ENCODER 0 -+#define CONFIG_G723_1_ENCODER 0 -+#define CONFIG_MLP_ENCODER 0 -+#define CONFIG_MP2_ENCODER 0 -+#define CONFIG_MP2FIXED_ENCODER 0 -+#define CONFIG_NELLYMOSER_ENCODER 0 -+#define CONFIG_OPUS_ENCODER 0 -+#define CONFIG_RA_144_ENCODER 0 -+#define CONFIG_SBC_ENCODER 0 -+#define CONFIG_SONIC_ENCODER 0 -+#define CONFIG_SONIC_LS_ENCODER 0 -+#define CONFIG_TRUEHD_ENCODER 0 -+#define CONFIG_TTA_ENCODER 0 -+#define CONFIG_VORBIS_ENCODER 0 -+#define CONFIG_WAVPACK_ENCODER 0 -+#define CONFIG_WMAV1_ENCODER 0 -+#define CONFIG_WMAV2_ENCODER 0 -+#define CONFIG_PCM_ALAW_ENCODER 0 -+#define CONFIG_PCM_DVD_ENCODER 0 -+#define CONFIG_PCM_F32BE_ENCODER 0 -+#define CONFIG_PCM_F32LE_ENCODER 0 -+#define CONFIG_PCM_F64BE_ENCODER 0 -+#define CONFIG_PCM_F64LE_ENCODER 0 -+#define CONFIG_PCM_MULAW_ENCODER 0 -+#define CONFIG_PCM_S8_ENCODER 0 -+#define CONFIG_PCM_S8_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16BE_ENCODER 0 -+#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16LE_ENCODER 0 -+#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S24BE_ENCODER 0 -+#define CONFIG_PCM_S24DAUD_ENCODER 0 -+#define CONFIG_PCM_S24LE_ENCODER 0 -+#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S32BE_ENCODER 0 -+#define CONFIG_PCM_S32LE_ENCODER 0 -+#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S64BE_ENCODER 0 -+#define CONFIG_PCM_S64LE_ENCODER 0 -+#define CONFIG_PCM_U8_ENCODER 0 -+#define CONFIG_PCM_U16BE_ENCODER 0 -+#define CONFIG_PCM_U16LE_ENCODER 0 -+#define CONFIG_PCM_U24BE_ENCODER 0 -+#define CONFIG_PCM_U24LE_ENCODER 0 -+#define CONFIG_PCM_U32BE_ENCODER 0 -+#define CONFIG_PCM_U32LE_ENCODER 0 -+#define CONFIG_PCM_VIDC_ENCODER 0 -+#define CONFIG_ROQ_DPCM_ENCODER 0 -+#define CONFIG_ADPCM_ADX_ENCODER 0 -+#define CONFIG_ADPCM_ARGO_ENCODER 0 -+#define CONFIG_ADPCM_G722_ENCODER 0 -+#define CONFIG_ADPCM_G726_ENCODER 0 -+#define CONFIG_ADPCM_G726LE_ENCODER 0 -+#define CONFIG_ADPCM_IMA_APM_ENCODER 0 -+#define CONFIG_ADPCM_IMA_QT_ENCODER 0 -+#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 -+#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 -+#define CONFIG_ADPCM_MS_ENCODER 0 -+#define CONFIG_ADPCM_SWF_ENCODER 0 -+#define CONFIG_ADPCM_YAMAHA_ENCODER 0 -+#define CONFIG_SSA_ENCODER 0 -+#define CONFIG_ASS_ENCODER 0 -+#define CONFIG_DVBSUB_ENCODER 0 -+#define CONFIG_DVDSUB_ENCODER 0 -+#define CONFIG_MOVTEXT_ENCODER 0 -+#define CONFIG_SRT_ENCODER 0 -+#define CONFIG_SUBRIP_ENCODER 0 -+#define CONFIG_TEXT_ENCODER 0 -+#define CONFIG_WEBVTT_ENCODER 0 -+#define CONFIG_XSUB_ENCODER 0 -+#define CONFIG_AAC_AT_ENCODER 0 -+#define CONFIG_ALAC_AT_ENCODER 0 -+#define CONFIG_ILBC_AT_ENCODER 0 -+#define CONFIG_PCM_ALAW_AT_ENCODER 0 -+#define CONFIG_PCM_MULAW_AT_ENCODER 0 -+#define CONFIG_LIBAOM_AV1_ENCODER 0 -+#define CONFIG_LIBCODEC2_ENCODER 0 -+#define CONFIG_LIBFDK_AAC_ENCODER 0 -+#define CONFIG_LIBGSM_ENCODER 0 -+#define CONFIG_LIBGSM_MS_ENCODER 0 -+#define CONFIG_LIBILBC_ENCODER 0 -+#define CONFIG_LIBMP3LAME_ENCODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 -+#define CONFIG_LIBOPENJPEG_ENCODER 0 -+#define CONFIG_LIBOPUS_ENCODER 0 -+#define CONFIG_LIBRAV1E_ENCODER 0 -+#define CONFIG_LIBSHINE_ENCODER 0 -+#define CONFIG_LIBSPEEX_ENCODER 0 -+#define CONFIG_LIBSVTAV1_ENCODER 0 -+#define CONFIG_LIBTHEORA_ENCODER 0 -+#define CONFIG_LIBTWOLAME_ENCODER 0 -+#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 -+#define CONFIG_LIBVORBIS_ENCODER 0 -+#define CONFIG_LIBVPX_VP8_ENCODER 0 -+#define CONFIG_LIBVPX_VP9_ENCODER 0 -+#define CONFIG_LIBWAVPACK_ENCODER 0 -+#define CONFIG_LIBWEBP_ANIM_ENCODER 0 -+#define CONFIG_LIBWEBP_ENCODER 0 -+#define CONFIG_LIBX262_ENCODER 0 -+#define CONFIG_LIBX264_ENCODER 0 -+#define CONFIG_LIBX264RGB_ENCODER 0 -+#define CONFIG_LIBX265_ENCODER 0 -+#define CONFIG_LIBXAVS_ENCODER 0 -+#define CONFIG_LIBXAVS2_ENCODER 0 -+#define CONFIG_LIBXVID_ENCODER 0 -+#define CONFIG_AAC_MF_ENCODER 0 -+#define CONFIG_AC3_MF_ENCODER 0 -+#define CONFIG_H263_V4L2M2M_ENCODER 0 -+#define CONFIG_LIBOPENH264_ENCODER 0 -+#define CONFIG_H264_AMF_ENCODER 0 -+#define CONFIG_H264_MF_ENCODER 0 -+#define CONFIG_H264_NVENC_ENCODER 0 -+#define CONFIG_H264_OMX_ENCODER 0 -+#define CONFIG_H264_QSV_ENCODER 0 -+#define CONFIG_H264_V4L2M2M_ENCODER 0 -+#define CONFIG_H264_VAAPI_ENCODER 0 -+#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_NVENC_ENCODER 0 -+#define CONFIG_NVENC_H264_ENCODER 0 -+#define CONFIG_NVENC_HEVC_ENCODER 0 -+#define CONFIG_HEVC_AMF_ENCODER 0 -+#define CONFIG_HEVC_MF_ENCODER 0 -+#define CONFIG_HEVC_NVENC_ENCODER 0 -+#define CONFIG_HEVC_QSV_ENCODER 0 -+#define CONFIG_HEVC_V4L2M2M_ENCODER 0 -+#define CONFIG_HEVC_VAAPI_ENCODER 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_LIBKVAZAAR_ENCODER 0 -+#define CONFIG_MJPEG_QSV_ENCODER 0 -+#define CONFIG_MJPEG_VAAPI_ENCODER 0 -+#define CONFIG_MP3_MF_ENCODER 0 -+#define CONFIG_MPEG2_QSV_ENCODER 0 -+#define CONFIG_MPEG2_VAAPI_ENCODER 0 -+#define CONFIG_MPEG4_OMX_ENCODER 0 -+#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_VAAPI_ENCODER 0 -+#define CONFIG_VP9_VAAPI_ENCODER 0 -+#define CONFIG_VP9_QSV_ENCODER 0 -+#define CONFIG_H263_VAAPI_HWACCEL 0 -+#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_H264_D3D11VA_HWACCEL 0 -+#define CONFIG_H264_D3D11VA2_HWACCEL 0 -+#define CONFIG_H264_DXVA2_HWACCEL 0 -+#define CONFIG_H264_NVDEC_HWACCEL 0 -+#define CONFIG_H264_VAAPI_HWACCEL 0 -+#define CONFIG_H264_VDPAU_HWACCEL 0 -+#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 -+#define CONFIG_HEVC_DXVA2_HWACCEL 0 -+#define CONFIG_HEVC_NVDEC_HWACCEL 0 -+#define CONFIG_HEVC_VAAPI_HWACCEL 0 -+#define CONFIG_HEVC_VDPAU_HWACCEL 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MJPEG_NVDEC_HWACCEL 0 -+#define CONFIG_MJPEG_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG1_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG1_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG1_XVMC_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 -+#define CONFIG_MPEG2_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG2_DXVA2_HWACCEL 0 -+#define CONFIG_MPEG2_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG2_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG2_XVMC_HWACCEL 0 -+#define CONFIG_MPEG4_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG4_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG4_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA2_HWACCEL 0 -+#define CONFIG_VC1_DXVA2_HWACCEL 0 -+#define CONFIG_VC1_NVDEC_HWACCEL 0 -+#define CONFIG_VC1_VAAPI_HWACCEL 0 -+#define CONFIG_VC1_VDPAU_HWACCEL 0 -+#define CONFIG_VP8_NVDEC_HWACCEL 0 -+#define CONFIG_VP8_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA2_HWACCEL 0 -+#define CONFIG_VP9_DXVA2_HWACCEL 0 -+#define CONFIG_VP9_NVDEC_HWACCEL 0 -+#define CONFIG_VP9_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_VDPAU_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 -+#define CONFIG_WMV3_DXVA2_HWACCEL 0 -+#define CONFIG_WMV3_NVDEC_HWACCEL 0 -+#define CONFIG_WMV3_VAAPI_HWACCEL 0 -+#define CONFIG_WMV3_VDPAU_HWACCEL 0 -+#define CONFIG_AAC_PARSER 1 -+#define CONFIG_AAC_LATM_PARSER 0 -+#define CONFIG_AC3_PARSER 0 -+#define CONFIG_ADX_PARSER 0 -+#define CONFIG_AV1_PARSER 0 -+#define CONFIG_AVS2_PARSER 0 -+#define CONFIG_BMP_PARSER 0 -+#define CONFIG_CAVSVIDEO_PARSER 0 -+#define CONFIG_COOK_PARSER 0 -+#define CONFIG_DCA_PARSER 0 -+#define CONFIG_DIRAC_PARSER 0 -+#define CONFIG_DNXHD_PARSER 0 -+#define CONFIG_DPX_PARSER 0 -+#define CONFIG_DVAUDIO_PARSER 0 -+#define CONFIG_DVBSUB_PARSER 0 -+#define CONFIG_DVDSUB_PARSER 0 -+#define CONFIG_DVD_NAV_PARSER 0 -+#define CONFIG_FLAC_PARSER 1 -+#define CONFIG_G723_1_PARSER 0 -+#define CONFIG_G729_PARSER 0 -+#define CONFIG_GIF_PARSER 0 -+#define CONFIG_GSM_PARSER 0 -+#define CONFIG_H261_PARSER 0 -+#define CONFIG_H263_PARSER 0 -+#define CONFIG_H264_PARSER 1 -+#define CONFIG_HEVC_PARSER 0 -+#define CONFIG_JPEG2000_PARSER 0 -+#define CONFIG_MJPEG_PARSER 0 -+#define CONFIG_MLP_PARSER 0 -+#define CONFIG_MPEG4VIDEO_PARSER 0 -+#define CONFIG_MPEGAUDIO_PARSER 1 -+#define CONFIG_MPEGVIDEO_PARSER 0 -+#define CONFIG_OPUS_PARSER 1 -+#define CONFIG_PNG_PARSER 0 -+#define CONFIG_PNM_PARSER 0 -+#define CONFIG_RV30_PARSER 0 -+#define CONFIG_RV40_PARSER 0 -+#define CONFIG_SBC_PARSER 0 -+#define CONFIG_SIPR_PARSER 0 -+#define CONFIG_TAK_PARSER 0 -+#define CONFIG_VC1_PARSER 0 -+#define CONFIG_VORBIS_PARSER 1 -+#define CONFIG_VP3_PARSER 1 -+#define CONFIG_VP8_PARSER 1 -+#define CONFIG_VP9_PARSER 1 -+#define CONFIG_WEBP_PARSER 0 -+#define CONFIG_XMA_PARSER 0 -+#define CONFIG_ALSA_INDEV 0 -+#define CONFIG_ANDROID_CAMERA_INDEV 0 -+#define CONFIG_AVFOUNDATION_INDEV 0 -+#define CONFIG_BKTR_INDEV 0 -+#define CONFIG_DECKLINK_INDEV 0 -+#define CONFIG_DSHOW_INDEV 0 -+#define CONFIG_FBDEV_INDEV 0 -+#define CONFIG_GDIGRAB_INDEV 0 -+#define CONFIG_IEC61883_INDEV 0 -+#define CONFIG_JACK_INDEV 0 -+#define CONFIG_KMSGRAB_INDEV 0 -+#define CONFIG_LAVFI_INDEV 0 -+#define CONFIG_OPENAL_INDEV 0 -+#define CONFIG_OSS_INDEV 0 -+#define CONFIG_PULSE_INDEV 0 -+#define CONFIG_SNDIO_INDEV 0 -+#define CONFIG_V4L2_INDEV 0 -+#define CONFIG_VFWCAP_INDEV 0 -+#define CONFIG_XCBGRAB_INDEV 0 -+#define CONFIG_LIBCDIO_INDEV 0 -+#define CONFIG_LIBDC1394_INDEV 0 -+#define CONFIG_ALSA_OUTDEV 0 -+#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 -+#define CONFIG_CACA_OUTDEV 0 -+#define CONFIG_DECKLINK_OUTDEV 0 -+#define CONFIG_FBDEV_OUTDEV 0 -+#define CONFIG_OPENGL_OUTDEV 0 -+#define CONFIG_OSS_OUTDEV 0 -+#define CONFIG_PULSE_OUTDEV 0 -+#define CONFIG_SDL2_OUTDEV 0 -+#define CONFIG_SNDIO_OUTDEV 0 -+#define CONFIG_V4L2_OUTDEV 0 -+#define CONFIG_XV_OUTDEV 0 -+#define CONFIG_ABENCH_FILTER 0 -+#define CONFIG_ACOMPRESSOR_FILTER 0 -+#define CONFIG_ACONTRAST_FILTER 0 -+#define CONFIG_ACOPY_FILTER 0 -+#define CONFIG_ACUE_FILTER 0 -+#define CONFIG_ACROSSFADE_FILTER 0 -+#define CONFIG_ACROSSOVER_FILTER 0 -+#define CONFIG_ACRUSHER_FILTER 0 -+#define CONFIG_ADECLICK_FILTER 0 -+#define CONFIG_ADECLIP_FILTER 0 -+#define CONFIG_ADELAY_FILTER 0 -+#define CONFIG_ADERIVATIVE_FILTER 0 -+#define CONFIG_AECHO_FILTER 0 -+#define CONFIG_AEMPHASIS_FILTER 0 -+#define CONFIG_AEVAL_FILTER 0 -+#define CONFIG_AFADE_FILTER 0 -+#define CONFIG_AFFTDN_FILTER 0 -+#define CONFIG_AFFTFILT_FILTER 0 -+#define CONFIG_AFIR_FILTER 0 -+#define CONFIG_AFORMAT_FILTER 0 -+#define CONFIG_AGATE_FILTER 0 -+#define CONFIG_AIIR_FILTER 0 -+#define CONFIG_AINTEGRAL_FILTER 0 -+#define CONFIG_AINTERLEAVE_FILTER 0 -+#define CONFIG_ALIMITER_FILTER 0 -+#define CONFIG_ALLPASS_FILTER 0 -+#define CONFIG_ALOOP_FILTER 0 -+#define CONFIG_AMERGE_FILTER 0 -+#define CONFIG_AMETADATA_FILTER 0 -+#define CONFIG_AMIX_FILTER 0 -+#define CONFIG_AMULTIPLY_FILTER 0 -+#define CONFIG_ANEQUALIZER_FILTER 0 -+#define CONFIG_ANLMDN_FILTER 0 -+#define CONFIG_ANLMS_FILTER 0 -+#define CONFIG_ANULL_FILTER 0 -+#define CONFIG_APAD_FILTER 0 -+#define CONFIG_APERMS_FILTER 0 -+#define CONFIG_APHASER_FILTER 0 -+#define CONFIG_APULSATOR_FILTER 0 -+#define CONFIG_AREALTIME_FILTER 0 -+#define CONFIG_ARESAMPLE_FILTER 0 -+#define CONFIG_AREVERSE_FILTER 0 -+#define CONFIG_ARNNDN_FILTER 0 -+#define CONFIG_ASELECT_FILTER 0 -+#define CONFIG_ASENDCMD_FILTER 0 -+#define CONFIG_ASETNSAMPLES_FILTER 0 -+#define CONFIG_ASETPTS_FILTER 0 -+#define CONFIG_ASETRATE_FILTER 0 -+#define CONFIG_ASETTB_FILTER 0 -+#define CONFIG_ASHOWINFO_FILTER 0 -+#define CONFIG_ASIDEDATA_FILTER 0 -+#define CONFIG_ASOFTCLIP_FILTER 0 -+#define CONFIG_ASPLIT_FILTER 0 -+#define CONFIG_ASR_FILTER 0 -+#define CONFIG_ASTATS_FILTER 0 -+#define CONFIG_ASTREAMSELECT_FILTER 0 -+#define CONFIG_ASUBBOOST_FILTER 0 -+#define CONFIG_ATEMPO_FILTER 0 -+#define CONFIG_ATRIM_FILTER 0 -+#define CONFIG_AXCORRELATE_FILTER 0 -+#define CONFIG_AZMQ_FILTER 0 -+#define CONFIG_BANDPASS_FILTER 0 -+#define CONFIG_BANDREJECT_FILTER 0 -+#define CONFIG_BASS_FILTER 0 -+#define CONFIG_BIQUAD_FILTER 0 -+#define CONFIG_BS2B_FILTER 0 -+#define CONFIG_CHROMABER_VULKAN_FILTER 0 -+#define CONFIG_CHANNELMAP_FILTER 0 -+#define CONFIG_CHANNELSPLIT_FILTER 0 -+#define CONFIG_CHORUS_FILTER 0 -+#define CONFIG_COMPAND_FILTER 0 -+#define CONFIG_COMPENSATIONDELAY_FILTER 0 -+#define CONFIG_CROSSFEED_FILTER 0 -+#define CONFIG_CRYSTALIZER_FILTER 0 -+#define CONFIG_DCSHIFT_FILTER 0 -+#define CONFIG_DEESSER_FILTER 0 -+#define CONFIG_DRMETER_FILTER 0 -+#define CONFIG_DYNAUDNORM_FILTER 0 -+#define CONFIG_EARWAX_FILTER 0 -+#define CONFIG_EBUR128_FILTER 0 -+#define CONFIG_EQUALIZER_FILTER 0 -+#define CONFIG_EXTRASTEREO_FILTER 0 -+#define CONFIG_FIREQUALIZER_FILTER 0 -+#define CONFIG_FLANGER_FILTER 0 -+#define CONFIG_HAAS_FILTER 0 -+#define CONFIG_HDCD_FILTER 0 -+#define CONFIG_HEADPHONE_FILTER 0 -+#define CONFIG_HIGHPASS_FILTER 0 -+#define CONFIG_HIGHSHELF_FILTER 0 -+#define CONFIG_JOIN_FILTER 0 -+#define CONFIG_LADSPA_FILTER 0 -+#define CONFIG_LOUDNORM_FILTER 0 -+#define CONFIG_LOWPASS_FILTER 0 -+#define CONFIG_LOWSHELF_FILTER 0 -+#define CONFIG_LV2_FILTER 0 -+#define CONFIG_MCOMPAND_FILTER 0 -+#define CONFIG_PAN_FILTER 0 -+#define CONFIG_REPLAYGAIN_FILTER 0 -+#define CONFIG_RESAMPLE_FILTER 0 -+#define CONFIG_RUBBERBAND_FILTER 0 -+#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 -+#define CONFIG_SIDECHAINGATE_FILTER 0 -+#define CONFIG_SILENCEDETECT_FILTER 0 -+#define CONFIG_SILENCEREMOVE_FILTER 0 -+#define CONFIG_SOFALIZER_FILTER 0 -+#define CONFIG_STEREOTOOLS_FILTER 0 -+#define CONFIG_STEREOWIDEN_FILTER 0 -+#define CONFIG_SUPEREQUALIZER_FILTER 0 -+#define CONFIG_SURROUND_FILTER 0 -+#define CONFIG_TREBLE_FILTER 0 -+#define CONFIG_TREMOLO_FILTER 0 -+#define CONFIG_VIBRATO_FILTER 0 -+#define CONFIG_VOLUME_FILTER 0 -+#define CONFIG_VOLUMEDETECT_FILTER 0 -+#define CONFIG_AEVALSRC_FILTER 0 -+#define CONFIG_AFIRSRC_FILTER 0 -+#define CONFIG_ANOISESRC_FILTER 0 -+#define CONFIG_ANULLSRC_FILTER 0 -+#define CONFIG_FLITE_FILTER 0 -+#define CONFIG_HILBERT_FILTER 0 -+#define CONFIG_SINC_FILTER 0 -+#define CONFIG_SINE_FILTER 0 -+#define CONFIG_ANULLSINK_FILTER 0 -+#define CONFIG_ADDROI_FILTER 0 -+#define CONFIG_ALPHAEXTRACT_FILTER 0 -+#define CONFIG_ALPHAMERGE_FILTER 0 -+#define CONFIG_AMPLIFY_FILTER 0 -+#define CONFIG_ASS_FILTER 0 -+#define CONFIG_ATADENOISE_FILTER 0 -+#define CONFIG_AVGBLUR_FILTER 0 -+#define CONFIG_AVGBLUR_OPENCL_FILTER 0 -+#define CONFIG_AVGBLUR_VULKAN_FILTER 0 -+#define CONFIG_BBOX_FILTER 0 -+#define CONFIG_BENCH_FILTER 0 -+#define CONFIG_BILATERAL_FILTER 0 -+#define CONFIG_BITPLANENOISE_FILTER 0 -+#define CONFIG_BLACKDETECT_FILTER 0 -+#define CONFIG_BLACKFRAME_FILTER 0 -+#define CONFIG_BLEND_FILTER 0 -+#define CONFIG_BM3D_FILTER 0 -+#define CONFIG_BOXBLUR_FILTER 0 -+#define CONFIG_BOXBLUR_OPENCL_FILTER 0 -+#define CONFIG_BWDIF_FILTER 0 -+#define CONFIG_CAS_FILTER 0 -+#define CONFIG_CHROMAHOLD_FILTER 0 -+#define CONFIG_CHROMAKEY_FILTER 0 -+#define CONFIG_CHROMANR_FILTER 0 -+#define CONFIG_CHROMASHIFT_FILTER 0 -+#define CONFIG_CIESCOPE_FILTER 0 -+#define CONFIG_CODECVIEW_FILTER 0 -+#define CONFIG_COLORBALANCE_FILTER 0 -+#define CONFIG_COLORCHANNELMIXER_FILTER 0 -+#define CONFIG_COLORKEY_FILTER 0 -+#define CONFIG_COLORKEY_OPENCL_FILTER 0 -+#define CONFIG_COLORHOLD_FILTER 0 -+#define CONFIG_COLORLEVELS_FILTER 0 -+#define CONFIG_COLORMATRIX_FILTER 0 -+#define CONFIG_COLORSPACE_FILTER 0 -+#define CONFIG_CONVOLUTION_FILTER 0 -+#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 -+#define CONFIG_CONVOLVE_FILTER 0 -+#define CONFIG_COPY_FILTER 0 -+#define CONFIG_COREIMAGE_FILTER 0 -+#define CONFIG_COVER_RECT_FILTER 0 -+#define CONFIG_CROP_FILTER 0 -+#define CONFIG_CROPDETECT_FILTER 0 -+#define CONFIG_CUE_FILTER 0 -+#define CONFIG_CURVES_FILTER 0 -+#define CONFIG_DATASCOPE_FILTER 0 -+#define CONFIG_DBLUR_FILTER 0 -+#define CONFIG_DCTDNOIZ_FILTER 0 -+#define CONFIG_DEBAND_FILTER 0 -+#define CONFIG_DEBLOCK_FILTER 0 -+#define CONFIG_DECIMATE_FILTER 0 -+#define CONFIG_DECONVOLVE_FILTER 0 -+#define CONFIG_DEDOT_FILTER 0 -+#define CONFIG_DEFLATE_FILTER 0 -+#define CONFIG_DEFLICKER_FILTER 0 -+#define CONFIG_DEINTERLACE_QSV_FILTER 0 -+#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 -+#define CONFIG_DEJUDDER_FILTER 0 -+#define CONFIG_DELOGO_FILTER 0 -+#define CONFIG_DENOISE_VAAPI_FILTER 0 -+#define CONFIG_DERAIN_FILTER 0 -+#define CONFIG_DESHAKE_FILTER 0 -+#define CONFIG_DESHAKE_OPENCL_FILTER 0 -+#define CONFIG_DESPILL_FILTER 0 -+#define CONFIG_DETELECINE_FILTER 0 -+#define CONFIG_DILATION_FILTER 0 -+#define CONFIG_DILATION_OPENCL_FILTER 0 -+#define CONFIG_DISPLACE_FILTER 0 -+#define CONFIG_DNN_PROCESSING_FILTER 0 -+#define CONFIG_DOUBLEWEAVE_FILTER 0 -+#define CONFIG_DRAWBOX_FILTER 0 -+#define CONFIG_DRAWGRAPH_FILTER 0 -+#define CONFIG_DRAWGRID_FILTER 0 -+#define CONFIG_DRAWTEXT_FILTER 0 -+#define CONFIG_EDGEDETECT_FILTER 0 -+#define CONFIG_ELBG_FILTER 0 -+#define CONFIG_ENTROPY_FILTER 0 -+#define CONFIG_EQ_FILTER 0 -+#define CONFIG_EROSION_FILTER 0 -+#define CONFIG_EROSION_OPENCL_FILTER 0 -+#define CONFIG_EXTRACTPLANES_FILTER 0 -+#define CONFIG_FADE_FILTER 0 -+#define CONFIG_FFTDNOIZ_FILTER 0 -+#define CONFIG_FFTFILT_FILTER 0 -+#define CONFIG_FIELD_FILTER 0 -+#define CONFIG_FIELDHINT_FILTER 0 -+#define CONFIG_FIELDMATCH_FILTER 0 -+#define CONFIG_FIELDORDER_FILTER 0 -+#define CONFIG_FILLBORDERS_FILTER 0 -+#define CONFIG_FIND_RECT_FILTER 0 -+#define CONFIG_FLOODFILL_FILTER 0 -+#define CONFIG_FORMAT_FILTER 0 -+#define CONFIG_FPS_FILTER 0 -+#define CONFIG_FRAMEPACK_FILTER 0 -+#define CONFIG_FRAMERATE_FILTER 0 -+#define CONFIG_FRAMESTEP_FILTER 0 -+#define CONFIG_FREEZEDETECT_FILTER 0 -+#define CONFIG_FREEZEFRAMES_FILTER 0 -+#define CONFIG_FREI0R_FILTER 0 -+#define CONFIG_FSPP_FILTER 0 -+#define CONFIG_GBLUR_FILTER 0 -+#define CONFIG_GEQ_FILTER 0 -+#define CONFIG_GRADFUN_FILTER 0 -+#define CONFIG_GRAPHMONITOR_FILTER 0 -+#define CONFIG_GREYEDGE_FILTER 0 -+#define CONFIG_HALDCLUT_FILTER 0 -+#define CONFIG_HFLIP_FILTER 0 -+#define CONFIG_HISTEQ_FILTER 0 -+#define CONFIG_HISTOGRAM_FILTER 0 -+#define CONFIG_HQDN3D_FILTER 0 -+#define CONFIG_HQX_FILTER 0 -+#define CONFIG_HSTACK_FILTER 0 -+#define CONFIG_HUE_FILTER 0 -+#define CONFIG_HWDOWNLOAD_FILTER 0 -+#define CONFIG_HWMAP_FILTER 0 -+#define CONFIG_HWUPLOAD_FILTER 0 -+#define CONFIG_HWUPLOAD_CUDA_FILTER 0 -+#define CONFIG_HYSTERESIS_FILTER 0 -+#define CONFIG_IDET_FILTER 0 -+#define CONFIG_IL_FILTER 0 -+#define CONFIG_INFLATE_FILTER 0 -+#define CONFIG_INTERLACE_FILTER 0 -+#define CONFIG_INTERLEAVE_FILTER 0 -+#define CONFIG_KERNDEINT_FILTER 0 -+#define CONFIG_LAGFUN_FILTER 0 -+#define CONFIG_LENSCORRECTION_FILTER 0 -+#define CONFIG_LENSFUN_FILTER 0 -+#define CONFIG_LIBVMAF_FILTER 0 -+#define CONFIG_LIMITER_FILTER 0 -+#define CONFIG_LOOP_FILTER 0 -+#define CONFIG_LUMAKEY_FILTER 0 -+#define CONFIG_LUT_FILTER 0 -+#define CONFIG_LUT1D_FILTER 0 -+#define CONFIG_LUT2_FILTER 0 -+#define CONFIG_LUT3D_FILTER 0 -+#define CONFIG_LUTRGB_FILTER 0 -+#define CONFIG_LUTYUV_FILTER 0 -+#define CONFIG_MASKEDCLAMP_FILTER 0 -+#define CONFIG_MASKEDMAX_FILTER 0 -+#define CONFIG_MASKEDMERGE_FILTER 0 -+#define CONFIG_MASKEDMIN_FILTER 0 -+#define CONFIG_MASKEDTHRESHOLD_FILTER 0 -+#define CONFIG_MASKFUN_FILTER 0 -+#define CONFIG_MCDEINT_FILTER 0 -+#define CONFIG_MEDIAN_FILTER 0 -+#define CONFIG_MERGEPLANES_FILTER 0 -+#define CONFIG_MESTIMATE_FILTER 0 -+#define CONFIG_METADATA_FILTER 0 -+#define CONFIG_MIDEQUALIZER_FILTER 0 -+#define CONFIG_MINTERPOLATE_FILTER 0 -+#define CONFIG_MIX_FILTER 0 -+#define CONFIG_MPDECIMATE_FILTER 0 -+#define CONFIG_NEGATE_FILTER 0 -+#define CONFIG_NLMEANS_FILTER 0 -+#define CONFIG_NLMEANS_OPENCL_FILTER 0 -+#define CONFIG_NNEDI_FILTER 0 -+#define CONFIG_NOFORMAT_FILTER 0 -+#define CONFIG_NOISE_FILTER 0 -+#define CONFIG_NORMALIZE_FILTER 0 -+#define CONFIG_NULL_FILTER 0 -+#define CONFIG_OCR_FILTER 0 -+#define CONFIG_OCV_FILTER 0 -+#define CONFIG_OSCILLOSCOPE_FILTER 0 -+#define CONFIG_OVERLAY_FILTER 0 -+#define CONFIG_OVERLAY_OPENCL_FILTER 0 -+#define CONFIG_OVERLAY_QSV_FILTER 0 -+#define CONFIG_OVERLAY_VULKAN_FILTER 0 -+#define CONFIG_OVERLAY_CUDA_FILTER 0 -+#define CONFIG_OWDENOISE_FILTER 0 -+#define CONFIG_PAD_FILTER 0 -+#define CONFIG_PAD_OPENCL_FILTER 0 -+#define CONFIG_PALETTEGEN_FILTER 0 -+#define CONFIG_PALETTEUSE_FILTER 0 -+#define CONFIG_PERMS_FILTER 0 -+#define CONFIG_PERSPECTIVE_FILTER 0 -+#define CONFIG_PHASE_FILTER 0 -+#define CONFIG_PHOTOSENSITIVITY_FILTER 0 -+#define CONFIG_PIXDESCTEST_FILTER 0 -+#define CONFIG_PIXSCOPE_FILTER 0 -+#define CONFIG_PP_FILTER 0 -+#define CONFIG_PP7_FILTER 0 -+#define CONFIG_PREMULTIPLY_FILTER 0 -+#define CONFIG_PREWITT_FILTER 0 -+#define CONFIG_PREWITT_OPENCL_FILTER 0 -+#define CONFIG_PROCAMP_VAAPI_FILTER 0 -+#define CONFIG_PROGRAM_OPENCL_FILTER 0 -+#define CONFIG_PSEUDOCOLOR_FILTER 0 -+#define CONFIG_PSNR_FILTER 0 -+#define CONFIG_PULLUP_FILTER 0 -+#define CONFIG_QP_FILTER 0 -+#define CONFIG_RANDOM_FILTER 0 -+#define CONFIG_READEIA608_FILTER 0 -+#define CONFIG_READVITC_FILTER 0 -+#define CONFIG_REALTIME_FILTER 0 -+#define CONFIG_REMAP_FILTER 0 -+#define CONFIG_REMOVEGRAIN_FILTER 0 -+#define CONFIG_REMOVELOGO_FILTER 0 -+#define CONFIG_REPEATFIELDS_FILTER 0 -+#define CONFIG_REVERSE_FILTER 0 -+#define CONFIG_RGBASHIFT_FILTER 0 -+#define CONFIG_ROBERTS_FILTER 0 -+#define CONFIG_ROBERTS_OPENCL_FILTER 0 -+#define CONFIG_ROTATE_FILTER 0 -+#define CONFIG_SAB_FILTER 0 -+#define CONFIG_SCALE_FILTER 0 -+#define CONFIG_SCALE_CUDA_FILTER 0 -+#define CONFIG_SCALE_NPP_FILTER 0 -+#define CONFIG_SCALE_QSV_FILTER 0 -+#define CONFIG_SCALE_VAAPI_FILTER 0 -+#define CONFIG_SCALE_VULKAN_FILTER 0 -+#define CONFIG_SCALE2REF_FILTER 0 -+#define CONFIG_SCDET_FILTER 0 -+#define CONFIG_SCROLL_FILTER 0 -+#define CONFIG_SELECT_FILTER 0 -+#define CONFIG_SELECTIVECOLOR_FILTER 0 -+#define CONFIG_SENDCMD_FILTER 0 -+#define CONFIG_SEPARATEFIELDS_FILTER 0 -+#define CONFIG_SETDAR_FILTER 0 -+#define CONFIG_SETFIELD_FILTER 0 -+#define CONFIG_SETPARAMS_FILTER 0 -+#define CONFIG_SETPTS_FILTER 0 -+#define CONFIG_SETRANGE_FILTER 0 -+#define CONFIG_SETSAR_FILTER 0 -+#define CONFIG_SETTB_FILTER 0 -+#define CONFIG_SHARPNESS_VAAPI_FILTER 0 -+#define CONFIG_SHOWINFO_FILTER 0 -+#define CONFIG_SHOWPALETTE_FILTER 0 -+#define CONFIG_SHUFFLEFRAMES_FILTER 0 -+#define CONFIG_SHUFFLEPLANES_FILTER 0 -+#define CONFIG_SIDEDATA_FILTER 0 -+#define CONFIG_SIGNALSTATS_FILTER 0 -+#define CONFIG_SIGNATURE_FILTER 0 -+#define CONFIG_SMARTBLUR_FILTER 0 -+#define CONFIG_SOBEL_FILTER 0 -+#define CONFIG_SOBEL_OPENCL_FILTER 0 -+#define CONFIG_SPLIT_FILTER 0 -+#define CONFIG_SPP_FILTER 0 -+#define CONFIG_SR_FILTER 0 -+#define CONFIG_SSIM_FILTER 0 -+#define CONFIG_STEREO3D_FILTER 0 -+#define CONFIG_STREAMSELECT_FILTER 0 -+#define CONFIG_SUBTITLES_FILTER 0 -+#define CONFIG_SUPER2XSAI_FILTER 0 -+#define CONFIG_SWAPRECT_FILTER 0 -+#define CONFIG_SWAPUV_FILTER 0 -+#define CONFIG_TBLEND_FILTER 0 -+#define CONFIG_TELECINE_FILTER 0 -+#define CONFIG_THISTOGRAM_FILTER 0 -+#define CONFIG_THRESHOLD_FILTER 0 -+#define CONFIG_THUMBNAIL_FILTER 0 -+#define CONFIG_THUMBNAIL_CUDA_FILTER 0 -+#define CONFIG_TILE_FILTER 0 -+#define CONFIG_TINTERLACE_FILTER 0 -+#define CONFIG_TLUT2_FILTER 0 -+#define CONFIG_TMEDIAN_FILTER 0 -+#define CONFIG_TMIX_FILTER 0 -+#define CONFIG_TONEMAP_FILTER 0 -+#define CONFIG_TONEMAP_OPENCL_FILTER 0 -+#define CONFIG_TONEMAP_VAAPI_FILTER 0 -+#define CONFIG_TPAD_FILTER 0 -+#define CONFIG_TRANSPOSE_FILTER 0 -+#define CONFIG_TRANSPOSE_NPP_FILTER 0 -+#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 -+#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 -+#define CONFIG_TRIM_FILTER 0 -+#define CONFIG_UNPREMULTIPLY_FILTER 0 -+#define CONFIG_UNSHARP_FILTER 0 -+#define CONFIG_UNSHARP_OPENCL_FILTER 0 -+#define CONFIG_UNTILE_FILTER 0 -+#define CONFIG_USPP_FILTER 0 -+#define CONFIG_V360_FILTER 0 -+#define CONFIG_VAGUEDENOISER_FILTER 0 -+#define CONFIG_VECTORSCOPE_FILTER 0 -+#define CONFIG_VFLIP_FILTER 0 -+#define CONFIG_VFRDET_FILTER 0 -+#define CONFIG_VIBRANCE_FILTER 0 -+#define CONFIG_VIDSTABDETECT_FILTER 0 -+#define CONFIG_VIDSTABTRANSFORM_FILTER 0 -+#define CONFIG_VIGNETTE_FILTER 0 -+#define CONFIG_VMAFMOTION_FILTER 0 -+#define CONFIG_VPP_QSV_FILTER 0 -+#define CONFIG_VSTACK_FILTER 0 -+#define CONFIG_W3FDIF_FILTER 0 -+#define CONFIG_WAVEFORM_FILTER 0 -+#define CONFIG_WEAVE_FILTER 0 -+#define CONFIG_XBR_FILTER 0 -+#define CONFIG_XFADE_FILTER 0 -+#define CONFIG_XFADE_OPENCL_FILTER 0 -+#define CONFIG_XMEDIAN_FILTER 0 -+#define CONFIG_XSTACK_FILTER 0 -+#define CONFIG_YADIF_FILTER 0 -+#define CONFIG_YADIF_CUDA_FILTER 0 -+#define CONFIG_YAEPBLUR_FILTER 0 -+#define CONFIG_ZMQ_FILTER 0 -+#define CONFIG_ZOOMPAN_FILTER 0 -+#define CONFIG_ZSCALE_FILTER 0 -+#define CONFIG_ALLRGB_FILTER 0 -+#define CONFIG_ALLYUV_FILTER 0 -+#define CONFIG_CELLAUTO_FILTER 0 -+#define CONFIG_COLOR_FILTER 0 -+#define CONFIG_COREIMAGESRC_FILTER 0 -+#define CONFIG_FREI0R_SRC_FILTER 0 -+#define CONFIG_GRADIENTS_FILTER 0 -+#define CONFIG_HALDCLUTSRC_FILTER 0 -+#define CONFIG_LIFE_FILTER 0 -+#define CONFIG_MANDELBROT_FILTER 0 -+#define CONFIG_MPTESTSRC_FILTER 0 -+#define CONFIG_NULLSRC_FILTER 0 -+#define CONFIG_OPENCLSRC_FILTER 0 -+#define CONFIG_PAL75BARS_FILTER 0 -+#define CONFIG_PAL100BARS_FILTER 0 -+#define CONFIG_RGBTESTSRC_FILTER 0 -+#define CONFIG_SIERPINSKI_FILTER 0 -+#define CONFIG_SMPTEBARS_FILTER 0 -+#define CONFIG_SMPTEHDBARS_FILTER 0 -+#define CONFIG_TESTSRC_FILTER 0 -+#define CONFIG_TESTSRC2_FILTER 0 -+#define CONFIG_YUVTESTSRC_FILTER 0 -+#define CONFIG_NULLSINK_FILTER 0 -+#define CONFIG_ABITSCOPE_FILTER 0 -+#define CONFIG_ADRAWGRAPH_FILTER 0 -+#define CONFIG_AGRAPHMONITOR_FILTER 0 -+#define CONFIG_AHISTOGRAM_FILTER 0 -+#define CONFIG_APHASEMETER_FILTER 0 -+#define CONFIG_AVECTORSCOPE_FILTER 0 -+#define CONFIG_CONCAT_FILTER 0 -+#define CONFIG_SHOWCQT_FILTER 0 -+#define CONFIG_SHOWFREQS_FILTER 0 -+#define CONFIG_SHOWSPATIAL_FILTER 0 -+#define CONFIG_SHOWSPECTRUM_FILTER 0 -+#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 -+#define CONFIG_SHOWVOLUME_FILTER 0 -+#define CONFIG_SHOWWAVES_FILTER 0 -+#define CONFIG_SHOWWAVESPIC_FILTER 0 -+#define CONFIG_SPECTRUMSYNTH_FILTER 0 -+#define CONFIG_AMOVIE_FILTER 0 -+#define CONFIG_MOVIE_FILTER 0 -+#define CONFIG_AFIFO_FILTER 0 -+#define CONFIG_FIFO_FILTER 0 -+#define CONFIG_AA_DEMUXER 0 -+#define CONFIG_AAC_DEMUXER 1 -+#define CONFIG_AC3_DEMUXER 0 -+#define CONFIG_ACM_DEMUXER 0 -+#define CONFIG_ACT_DEMUXER 0 -+#define CONFIG_ADF_DEMUXER 0 -+#define CONFIG_ADP_DEMUXER 0 -+#define CONFIG_ADS_DEMUXER 0 -+#define CONFIG_ADX_DEMUXER 0 -+#define CONFIG_AEA_DEMUXER 0 -+#define CONFIG_AFC_DEMUXER 0 -+#define CONFIG_AIFF_DEMUXER 0 -+#define CONFIG_AIX_DEMUXER 0 -+#define CONFIG_ALP_DEMUXER 0 -+#define CONFIG_AMR_DEMUXER 0 -+#define CONFIG_AMRNB_DEMUXER 0 -+#define CONFIG_AMRWB_DEMUXER 0 -+#define CONFIG_ANM_DEMUXER 0 -+#define CONFIG_APC_DEMUXER 0 -+#define CONFIG_APE_DEMUXER 0 -+#define CONFIG_APM_DEMUXER 0 -+#define CONFIG_APNG_DEMUXER 0 -+#define CONFIG_APTX_DEMUXER 0 -+#define CONFIG_APTX_HD_DEMUXER 0 -+#define CONFIG_AQTITLE_DEMUXER 0 -+#define CONFIG_ARGO_ASF_DEMUXER 0 -+#define CONFIG_ASF_DEMUXER 0 -+#define CONFIG_ASF_O_DEMUXER 0 -+#define CONFIG_ASS_DEMUXER 0 -+#define CONFIG_AST_DEMUXER 0 -+#define CONFIG_AU_DEMUXER 0 -+#define CONFIG_AV1_DEMUXER 0 -+#define CONFIG_AVI_DEMUXER 0 -+#define CONFIG_AVISYNTH_DEMUXER 0 -+#define CONFIG_AVR_DEMUXER 0 -+#define CONFIG_AVS_DEMUXER 0 -+#define CONFIG_AVS2_DEMUXER 0 -+#define CONFIG_BETHSOFTVID_DEMUXER 0 -+#define CONFIG_BFI_DEMUXER 0 -+#define CONFIG_BINTEXT_DEMUXER 0 -+#define CONFIG_BINK_DEMUXER 0 -+#define CONFIG_BIT_DEMUXER 0 -+#define CONFIG_BMV_DEMUXER 0 -+#define CONFIG_BFSTM_DEMUXER 0 -+#define CONFIG_BRSTM_DEMUXER 0 -+#define CONFIG_BOA_DEMUXER 0 -+#define CONFIG_C93_DEMUXER 0 -+#define CONFIG_CAF_DEMUXER 0 -+#define CONFIG_CAVSVIDEO_DEMUXER 0 -+#define CONFIG_CDG_DEMUXER 0 -+#define CONFIG_CDXL_DEMUXER 0 -+#define CONFIG_CINE_DEMUXER 0 -+#define CONFIG_CODEC2_DEMUXER 0 -+#define CONFIG_CODEC2RAW_DEMUXER 0 -+#define CONFIG_CONCAT_DEMUXER 0 -+#define CONFIG_DASH_DEMUXER 0 -+#define CONFIG_DATA_DEMUXER 0 -+#define CONFIG_DAUD_DEMUXER 0 -+#define CONFIG_DCSTR_DEMUXER 0 -+#define CONFIG_DERF_DEMUXER 0 -+#define CONFIG_DFA_DEMUXER 0 -+#define CONFIG_DHAV_DEMUXER 0 -+#define CONFIG_DIRAC_DEMUXER 0 -+#define CONFIG_DNXHD_DEMUXER 0 -+#define CONFIG_DSF_DEMUXER 0 -+#define CONFIG_DSICIN_DEMUXER 0 -+#define CONFIG_DSS_DEMUXER 0 -+#define CONFIG_DTS_DEMUXER 0 -+#define CONFIG_DTSHD_DEMUXER 0 -+#define CONFIG_DV_DEMUXER 0 -+#define CONFIG_DVBSUB_DEMUXER 0 -+#define CONFIG_DVBTXT_DEMUXER 0 -+#define CONFIG_DXA_DEMUXER 0 -+#define CONFIG_EA_DEMUXER 0 -+#define CONFIG_EA_CDATA_DEMUXER 0 -+#define CONFIG_EAC3_DEMUXER 0 -+#define CONFIG_EPAF_DEMUXER 0 -+#define CONFIG_FFMETADATA_DEMUXER 0 -+#define CONFIG_FILMSTRIP_DEMUXER 0 -+#define CONFIG_FITS_DEMUXER 0 -+#define CONFIG_FLAC_DEMUXER 1 -+#define CONFIG_FLIC_DEMUXER 0 -+#define CONFIG_FLV_DEMUXER 0 -+#define CONFIG_LIVE_FLV_DEMUXER 0 -+#define CONFIG_FOURXM_DEMUXER 0 -+#define CONFIG_FRM_DEMUXER 0 -+#define CONFIG_FSB_DEMUXER 0 -+#define CONFIG_FWSE_DEMUXER 0 -+#define CONFIG_G722_DEMUXER 0 -+#define CONFIG_G723_1_DEMUXER 0 -+#define CONFIG_G726_DEMUXER 0 -+#define CONFIG_G726LE_DEMUXER 0 -+#define CONFIG_G729_DEMUXER 0 -+#define CONFIG_GDV_DEMUXER 0 -+#define CONFIG_GENH_DEMUXER 0 -+#define CONFIG_GIF_DEMUXER 0 -+#define CONFIG_GSM_DEMUXER 0 -+#define CONFIG_GXF_DEMUXER 0 -+#define CONFIG_H261_DEMUXER 0 -+#define CONFIG_H263_DEMUXER 0 -+#define CONFIG_H264_DEMUXER 0 -+#define CONFIG_HCA_DEMUXER 0 -+#define CONFIG_HCOM_DEMUXER 0 -+#define CONFIG_HEVC_DEMUXER 0 -+#define CONFIG_HLS_DEMUXER 0 -+#define CONFIG_HNM_DEMUXER 0 -+#define CONFIG_ICO_DEMUXER 0 -+#define CONFIG_IDCIN_DEMUXER 0 -+#define CONFIG_IDF_DEMUXER 0 -+#define CONFIG_IFF_DEMUXER 0 -+#define CONFIG_IFV_DEMUXER 0 -+#define CONFIG_ILBC_DEMUXER 0 -+#define CONFIG_IMAGE2_DEMUXER 0 -+#define CONFIG_IMAGE2PIPE_DEMUXER 0 -+#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 -+#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 -+#define CONFIG_INGENIENT_DEMUXER 0 -+#define CONFIG_IPMOVIE_DEMUXER 0 -+#define CONFIG_IRCAM_DEMUXER 0 -+#define CONFIG_ISS_DEMUXER 0 -+#define CONFIG_IV8_DEMUXER 0 -+#define CONFIG_IVF_DEMUXER 0 -+#define CONFIG_IVR_DEMUXER 0 -+#define CONFIG_JACOSUB_DEMUXER 0 -+#define CONFIG_JV_DEMUXER 0 -+#define CONFIG_KUX_DEMUXER 0 -+#define CONFIG_KVAG_DEMUXER 0 -+#define CONFIG_LMLM4_DEMUXER 0 -+#define CONFIG_LOAS_DEMUXER 0 -+#define CONFIG_LRC_DEMUXER 0 -+#define CONFIG_LVF_DEMUXER 0 -+#define CONFIG_LXF_DEMUXER 0 -+#define CONFIG_M4V_DEMUXER 0 -+#define CONFIG_MCC_DEMUXER 0 -+#define CONFIG_MATROSKA_DEMUXER 1 -+#define CONFIG_MGSTS_DEMUXER 0 -+#define CONFIG_MICRODVD_DEMUXER 0 -+#define CONFIG_MJPEG_DEMUXER 0 -+#define CONFIG_MJPEG_2000_DEMUXER 0 -+#define CONFIG_MLP_DEMUXER 0 -+#define CONFIG_MLV_DEMUXER 0 -+#define CONFIG_MM_DEMUXER 0 -+#define CONFIG_MMF_DEMUXER 0 -+#define CONFIG_MOV_DEMUXER 1 -+#define CONFIG_MP3_DEMUXER 1 -+#define CONFIG_MPC_DEMUXER 0 -+#define CONFIG_MPC8_DEMUXER 0 -+#define CONFIG_MPEGPS_DEMUXER 0 -+#define CONFIG_MPEGTS_DEMUXER 0 -+#define CONFIG_MPEGTSRAW_DEMUXER 0 -+#define CONFIG_MPEGVIDEO_DEMUXER 0 -+#define CONFIG_MPJPEG_DEMUXER 0 -+#define CONFIG_MPL2_DEMUXER 0 -+#define CONFIG_MPSUB_DEMUXER 0 -+#define CONFIG_MSF_DEMUXER 0 -+#define CONFIG_MSNWC_TCP_DEMUXER 0 -+#define CONFIG_MTAF_DEMUXER 0 -+#define CONFIG_MTV_DEMUXER 0 -+#define CONFIG_MUSX_DEMUXER 0 -+#define CONFIG_MV_DEMUXER 0 -+#define CONFIG_MVI_DEMUXER 0 -+#define CONFIG_MXF_DEMUXER 0 -+#define CONFIG_MXG_DEMUXER 0 -+#define CONFIG_NC_DEMUXER 0 -+#define CONFIG_NISTSPHERE_DEMUXER 0 -+#define CONFIG_NSP_DEMUXER 0 -+#define CONFIG_NSV_DEMUXER 0 -+#define CONFIG_NUT_DEMUXER 0 -+#define CONFIG_NUV_DEMUXER 0 -+#define CONFIG_OBU_DEMUXER 0 -+#define CONFIG_OGG_DEMUXER 1 -+#define CONFIG_OMA_DEMUXER 0 -+#define CONFIG_PAF_DEMUXER 0 -+#define CONFIG_PCM_ALAW_DEMUXER 0 -+#define CONFIG_PCM_MULAW_DEMUXER 0 -+#define CONFIG_PCM_VIDC_DEMUXER 0 -+#define CONFIG_PCM_F64BE_DEMUXER 0 -+#define CONFIG_PCM_F64LE_DEMUXER 0 -+#define CONFIG_PCM_F32BE_DEMUXER 0 -+#define CONFIG_PCM_F32LE_DEMUXER 0 -+#define CONFIG_PCM_S32BE_DEMUXER 0 -+#define CONFIG_PCM_S32LE_DEMUXER 0 -+#define CONFIG_PCM_S24BE_DEMUXER 0 -+#define CONFIG_PCM_S24LE_DEMUXER 0 -+#define CONFIG_PCM_S16BE_DEMUXER 0 -+#define CONFIG_PCM_S16LE_DEMUXER 0 -+#define CONFIG_PCM_S8_DEMUXER 0 -+#define CONFIG_PCM_U32BE_DEMUXER 0 -+#define CONFIG_PCM_U32LE_DEMUXER 0 -+#define CONFIG_PCM_U24BE_DEMUXER 0 -+#define CONFIG_PCM_U24LE_DEMUXER 0 -+#define CONFIG_PCM_U16BE_DEMUXER 0 -+#define CONFIG_PCM_U16LE_DEMUXER 0 -+#define CONFIG_PCM_U8_DEMUXER 0 -+#define CONFIG_PJS_DEMUXER 0 -+#define CONFIG_PMP_DEMUXER 0 -+#define CONFIG_PP_BNK_DEMUXER 0 -+#define CONFIG_PVA_DEMUXER 0 -+#define CONFIG_PVF_DEMUXER 0 -+#define CONFIG_QCP_DEMUXER 0 -+#define CONFIG_R3D_DEMUXER 0 -+#define CONFIG_RAWVIDEO_DEMUXER 0 -+#define CONFIG_REALTEXT_DEMUXER 0 -+#define CONFIG_REDSPARK_DEMUXER 0 -+#define CONFIG_RL2_DEMUXER 0 -+#define CONFIG_RM_DEMUXER 0 -+#define CONFIG_ROQ_DEMUXER 0 -+#define CONFIG_RPL_DEMUXER 0 -+#define CONFIG_RSD_DEMUXER 0 -+#define CONFIG_RSO_DEMUXER 0 -+#define CONFIG_RTP_DEMUXER 0 -+#define CONFIG_RTSP_DEMUXER 0 -+#define CONFIG_S337M_DEMUXER 0 -+#define CONFIG_SAMI_DEMUXER 0 -+#define CONFIG_SAP_DEMUXER 0 -+#define CONFIG_SBC_DEMUXER 0 -+#define CONFIG_SBG_DEMUXER 0 -+#define CONFIG_SCC_DEMUXER 0 -+#define CONFIG_SDP_DEMUXER 0 -+#define CONFIG_SDR2_DEMUXER 0 -+#define CONFIG_SDS_DEMUXER 0 -+#define CONFIG_SDX_DEMUXER 0 -+#define CONFIG_SEGAFILM_DEMUXER 0 -+#define CONFIG_SER_DEMUXER 0 -+#define CONFIG_SHORTEN_DEMUXER 0 -+#define CONFIG_SIFF_DEMUXER 0 -+#define CONFIG_SLN_DEMUXER 0 -+#define CONFIG_SMACKER_DEMUXER 0 -+#define CONFIG_SMJPEG_DEMUXER 0 -+#define CONFIG_SMUSH_DEMUXER 0 -+#define CONFIG_SOL_DEMUXER 0 -+#define CONFIG_SOX_DEMUXER 0 -+#define CONFIG_SPDIF_DEMUXER 0 -+#define CONFIG_SRT_DEMUXER 0 -+#define CONFIG_STR_DEMUXER 0 -+#define CONFIG_STL_DEMUXER 0 -+#define CONFIG_SUBVIEWER1_DEMUXER 0 -+#define CONFIG_SUBVIEWER_DEMUXER 0 -+#define CONFIG_SUP_DEMUXER 0 -+#define CONFIG_SVAG_DEMUXER 0 -+#define CONFIG_SWF_DEMUXER 0 -+#define CONFIG_TAK_DEMUXER 0 -+#define CONFIG_TEDCAPTIONS_DEMUXER 0 -+#define CONFIG_THP_DEMUXER 0 -+#define CONFIG_THREEDOSTR_DEMUXER 0 -+#define CONFIG_TIERTEXSEQ_DEMUXER 0 -+#define CONFIG_TMV_DEMUXER 0 -+#define CONFIG_TRUEHD_DEMUXER 0 -+#define CONFIG_TTA_DEMUXER 0 -+#define CONFIG_TXD_DEMUXER 0 -+#define CONFIG_TTY_DEMUXER 0 -+#define CONFIG_TY_DEMUXER 0 -+#define CONFIG_V210_DEMUXER 0 -+#define CONFIG_V210X_DEMUXER 0 -+#define CONFIG_VAG_DEMUXER 0 -+#define CONFIG_VC1_DEMUXER 0 -+#define CONFIG_VC1T_DEMUXER 0 -+#define CONFIG_VIVIDAS_DEMUXER 0 -+#define CONFIG_VIVO_DEMUXER 0 -+#define CONFIG_VMD_DEMUXER 0 -+#define CONFIG_VOBSUB_DEMUXER 0 -+#define CONFIG_VOC_DEMUXER 0 -+#define CONFIG_VPK_DEMUXER 0 -+#define CONFIG_VPLAYER_DEMUXER 0 -+#define CONFIG_VQF_DEMUXER 0 -+#define CONFIG_W64_DEMUXER 0 -+#define CONFIG_WAV_DEMUXER 1 -+#define CONFIG_WC3_DEMUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 -+#define CONFIG_WEBVTT_DEMUXER 0 -+#define CONFIG_WSAUD_DEMUXER 0 -+#define CONFIG_WSD_DEMUXER 0 -+#define CONFIG_WSVQA_DEMUXER 0 -+#define CONFIG_WTV_DEMUXER 0 -+#define CONFIG_WVE_DEMUXER 0 -+#define CONFIG_WV_DEMUXER 0 -+#define CONFIG_XA_DEMUXER 0 -+#define CONFIG_XBIN_DEMUXER 0 -+#define CONFIG_XMV_DEMUXER 0 -+#define CONFIG_XVAG_DEMUXER 0 -+#define CONFIG_XWMA_DEMUXER 0 -+#define CONFIG_YOP_DEMUXER 0 -+#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 -+#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 -+#define CONFIG_LIBGME_DEMUXER 0 -+#define CONFIG_LIBMODPLUG_DEMUXER 0 -+#define CONFIG_LIBOPENMPT_DEMUXER 0 -+#define CONFIG_VAPOURSYNTH_DEMUXER 0 -+#define CONFIG_A64_MUXER 0 -+#define CONFIG_AC3_MUXER 0 -+#define CONFIG_ADTS_MUXER 0 -+#define CONFIG_ADX_MUXER 0 -+#define CONFIG_AIFF_MUXER 0 -+#define CONFIG_AMR_MUXER 0 -+#define CONFIG_APM_MUXER 0 -+#define CONFIG_APNG_MUXER 0 -+#define CONFIG_APTX_MUXER 0 -+#define CONFIG_APTX_HD_MUXER 0 -+#define CONFIG_ARGO_ASF_MUXER 0 -+#define CONFIG_ASF_MUXER 0 -+#define CONFIG_ASS_MUXER 0 -+#define CONFIG_AST_MUXER 0 -+#define CONFIG_ASF_STREAM_MUXER 0 -+#define CONFIG_AU_MUXER 0 -+#define CONFIG_AVI_MUXER 0 -+#define CONFIG_AVM2_MUXER 0 -+#define CONFIG_AVS2_MUXER 0 -+#define CONFIG_BIT_MUXER 0 -+#define CONFIG_CAF_MUXER 0 -+#define CONFIG_CAVSVIDEO_MUXER 0 -+#define CONFIG_CODEC2_MUXER 0 -+#define CONFIG_CODEC2RAW_MUXER 0 -+#define CONFIG_CRC_MUXER 0 -+#define CONFIG_DASH_MUXER 0 -+#define CONFIG_DATA_MUXER 0 -+#define CONFIG_DAUD_MUXER 0 -+#define CONFIG_DIRAC_MUXER 0 -+#define CONFIG_DNXHD_MUXER 0 -+#define CONFIG_DTS_MUXER 0 -+#define CONFIG_DV_MUXER 0 -+#define CONFIG_EAC3_MUXER 0 -+#define CONFIG_F4V_MUXER 0 -+#define CONFIG_FFMETADATA_MUXER 0 -+#define CONFIG_FIFO_MUXER 0 -+#define CONFIG_FIFO_TEST_MUXER 0 -+#define CONFIG_FILMSTRIP_MUXER 0 -+#define CONFIG_FITS_MUXER 0 -+#define CONFIG_FLAC_MUXER 0 -+#define CONFIG_FLV_MUXER 0 -+#define CONFIG_FRAMECRC_MUXER 0 -+#define CONFIG_FRAMEHASH_MUXER 0 -+#define CONFIG_FRAMEMD5_MUXER 0 -+#define CONFIG_G722_MUXER 0 -+#define CONFIG_G723_1_MUXER 0 -+#define CONFIG_G726_MUXER 0 -+#define CONFIG_G726LE_MUXER 0 -+#define CONFIG_GIF_MUXER 0 -+#define CONFIG_GSM_MUXER 0 -+#define CONFIG_GXF_MUXER 0 -+#define CONFIG_H261_MUXER 0 -+#define CONFIG_H263_MUXER 0 -+#define CONFIG_H264_MUXER 0 -+#define CONFIG_HASH_MUXER 0 -+#define CONFIG_HDS_MUXER 0 -+#define CONFIG_HEVC_MUXER 0 -+#define CONFIG_HLS_MUXER 0 -+#define CONFIG_ICO_MUXER 0 -+#define CONFIG_ILBC_MUXER 0 -+#define CONFIG_IMAGE2_MUXER 0 -+#define CONFIG_IMAGE2PIPE_MUXER 0 -+#define CONFIG_IPOD_MUXER 0 -+#define CONFIG_IRCAM_MUXER 0 -+#define CONFIG_ISMV_MUXER 0 -+#define CONFIG_IVF_MUXER 0 -+#define CONFIG_JACOSUB_MUXER 0 -+#define CONFIG_KVAG_MUXER 0 -+#define CONFIG_LATM_MUXER 0 -+#define CONFIG_LRC_MUXER 0 -+#define CONFIG_M4V_MUXER 0 -+#define CONFIG_MD5_MUXER 0 -+#define CONFIG_MATROSKA_MUXER 0 -+#define CONFIG_MATROSKA_AUDIO_MUXER 0 -+#define CONFIG_MICRODVD_MUXER 0 -+#define CONFIG_MJPEG_MUXER 0 -+#define CONFIG_MLP_MUXER 0 -+#define CONFIG_MMF_MUXER 0 -+#define CONFIG_MOV_MUXER 0 -+#define CONFIG_MP2_MUXER 0 -+#define CONFIG_MP3_MUXER 0 -+#define CONFIG_MP4_MUXER 0 -+#define CONFIG_MPEG1SYSTEM_MUXER 0 -+#define CONFIG_MPEG1VCD_MUXER 0 -+#define CONFIG_MPEG1VIDEO_MUXER 0 -+#define CONFIG_MPEG2DVD_MUXER 0 -+#define CONFIG_MPEG2SVCD_MUXER 0 -+#define CONFIG_MPEG2VIDEO_MUXER 0 -+#define CONFIG_MPEG2VOB_MUXER 0 -+#define CONFIG_MPEGTS_MUXER 0 -+#define CONFIG_MPJPEG_MUXER 0 -+#define CONFIG_MXF_MUXER 0 -+#define CONFIG_MXF_D10_MUXER 0 -+#define CONFIG_MXF_OPATOM_MUXER 0 -+#define CONFIG_NULL_MUXER 0 -+#define CONFIG_NUT_MUXER 0 -+#define CONFIG_OGA_MUXER 0 -+#define CONFIG_OGG_MUXER 0 -+#define CONFIG_OGV_MUXER 0 -+#define CONFIG_OMA_MUXER 0 -+#define CONFIG_OPUS_MUXER 0 -+#define CONFIG_PCM_ALAW_MUXER 0 -+#define CONFIG_PCM_MULAW_MUXER 0 -+#define CONFIG_PCM_VIDC_MUXER 0 -+#define CONFIG_PCM_F64BE_MUXER 0 -+#define CONFIG_PCM_F64LE_MUXER 0 -+#define CONFIG_PCM_F32BE_MUXER 0 -+#define CONFIG_PCM_F32LE_MUXER 0 -+#define CONFIG_PCM_S32BE_MUXER 0 -+#define CONFIG_PCM_S32LE_MUXER 0 -+#define CONFIG_PCM_S24BE_MUXER 0 -+#define CONFIG_PCM_S24LE_MUXER 0 -+#define CONFIG_PCM_S16BE_MUXER 0 -+#define CONFIG_PCM_S16LE_MUXER 0 -+#define CONFIG_PCM_S8_MUXER 0 -+#define CONFIG_PCM_U32BE_MUXER 0 -+#define CONFIG_PCM_U32LE_MUXER 0 -+#define CONFIG_PCM_U24BE_MUXER 0 -+#define CONFIG_PCM_U24LE_MUXER 0 -+#define CONFIG_PCM_U16BE_MUXER 0 -+#define CONFIG_PCM_U16LE_MUXER 0 -+#define CONFIG_PCM_U8_MUXER 0 -+#define CONFIG_PSP_MUXER 0 -+#define CONFIG_RAWVIDEO_MUXER 0 -+#define CONFIG_RM_MUXER 0 -+#define CONFIG_ROQ_MUXER 0 -+#define CONFIG_RSO_MUXER 0 -+#define CONFIG_RTP_MUXER 0 -+#define CONFIG_RTP_MPEGTS_MUXER 0 -+#define CONFIG_RTSP_MUXER 0 -+#define CONFIG_SAP_MUXER 0 -+#define CONFIG_SBC_MUXER 0 -+#define CONFIG_SCC_MUXER 0 -+#define CONFIG_SEGAFILM_MUXER 0 -+#define CONFIG_SEGMENT_MUXER 0 -+#define CONFIG_STREAM_SEGMENT_MUXER 0 -+#define CONFIG_SINGLEJPEG_MUXER 0 -+#define CONFIG_SMJPEG_MUXER 0 -+#define CONFIG_SMOOTHSTREAMING_MUXER 0 -+#define CONFIG_SOX_MUXER 0 -+#define CONFIG_SPX_MUXER 0 -+#define CONFIG_SPDIF_MUXER 0 -+#define CONFIG_SRT_MUXER 0 -+#define CONFIG_STREAMHASH_MUXER 0 -+#define CONFIG_SUP_MUXER 0 -+#define CONFIG_SWF_MUXER 0 -+#define CONFIG_TEE_MUXER 0 -+#define CONFIG_TG2_MUXER 0 -+#define CONFIG_TGP_MUXER 0 -+#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 -+#define CONFIG_TRUEHD_MUXER 0 -+#define CONFIG_TTA_MUXER 0 -+#define CONFIG_UNCODEDFRAMECRC_MUXER 0 -+#define CONFIG_VC1_MUXER 0 -+#define CONFIG_VC1T_MUXER 0 -+#define CONFIG_VOC_MUXER 0 -+#define CONFIG_W64_MUXER 0 -+#define CONFIG_WAV_MUXER 0 -+#define CONFIG_WEBM_MUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 -+#define CONFIG_WEBM_CHUNK_MUXER 0 -+#define CONFIG_WEBP_MUXER 0 -+#define CONFIG_WEBVTT_MUXER 0 -+#define CONFIG_WTV_MUXER 0 -+#define CONFIG_WV_MUXER 0 -+#define CONFIG_YUV4MPEGPIPE_MUXER 0 -+#define CONFIG_CHROMAPRINT_MUXER 0 -+#define CONFIG_ASYNC_PROTOCOL 0 -+#define CONFIG_BLURAY_PROTOCOL 0 -+#define CONFIG_CACHE_PROTOCOL 0 -+#define CONFIG_CONCAT_PROTOCOL 0 -+#define CONFIG_CRYPTO_PROTOCOL 0 -+#define CONFIG_DATA_PROTOCOL 0 -+#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 -+#define CONFIG_FFRTMPHTTP_PROTOCOL 0 -+#define CONFIG_FILE_PROTOCOL 0 -+#define CONFIG_FTP_PROTOCOL 0 -+#define CONFIG_GOPHER_PROTOCOL 0 -+#define CONFIG_HLS_PROTOCOL 0 -+#define CONFIG_HTTP_PROTOCOL 0 -+#define CONFIG_HTTPPROXY_PROTOCOL 0 -+#define CONFIG_HTTPS_PROTOCOL 0 -+#define CONFIG_ICECAST_PROTOCOL 0 -+#define CONFIG_MMSH_PROTOCOL 0 -+#define CONFIG_MMST_PROTOCOL 0 -+#define CONFIG_MD5_PROTOCOL 0 -+#define CONFIG_PIPE_PROTOCOL 0 -+#define CONFIG_PROMPEG_PROTOCOL 0 -+#define CONFIG_RTMP_PROTOCOL 0 -+#define CONFIG_RTMPE_PROTOCOL 0 -+#define CONFIG_RTMPS_PROTOCOL 0 -+#define CONFIG_RTMPT_PROTOCOL 0 -+#define CONFIG_RTMPTE_PROTOCOL 0 -+#define CONFIG_RTMPTS_PROTOCOL 0 -+#define CONFIG_RTP_PROTOCOL 0 -+#define CONFIG_SCTP_PROTOCOL 0 -+#define CONFIG_SRTP_PROTOCOL 0 -+#define CONFIG_SUBFILE_PROTOCOL 0 -+#define CONFIG_TEE_PROTOCOL 0 -+#define CONFIG_TCP_PROTOCOL 0 -+#define CONFIG_TLS_PROTOCOL 0 -+#define CONFIG_UDP_PROTOCOL 0 -+#define CONFIG_UDPLITE_PROTOCOL 0 -+#define CONFIG_UNIX_PROTOCOL 0 -+#define CONFIG_LIBAMQP_PROTOCOL 0 -+#define CONFIG_LIBRTMP_PROTOCOL 0 -+#define CONFIG_LIBRTMPE_PROTOCOL 0 -+#define CONFIG_LIBRTMPS_PROTOCOL 0 -+#define CONFIG_LIBRTMPT_PROTOCOL 0 -+#define CONFIG_LIBRTMPTE_PROTOCOL 0 -+#define CONFIG_LIBSRT_PROTOCOL 0 -+#define CONFIG_LIBSSH_PROTOCOL 0 -+#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 -+#define CONFIG_LIBZMQ_PROTOCOL 0 -+#endif /* FFMPEG_CONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/bsf_list.c -@@ -0,0 +1,3 @@ -+static const AVBitStreamFilter * const bitstream_filters[] = { -+ &ff_null_bsf, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/codec_list.c -@@ -0,0 +1,20 @@ -+static const AVCodec * const codec_list[] = { -+ &ff_h264_decoder, -+ &ff_theora_decoder, -+ &ff_vp3_decoder, -+ &ff_vp8_decoder, -+ &ff_aac_decoder, -+ &ff_flac_decoder, -+ &ff_mp3_decoder, -+ &ff_vorbis_decoder, -+ &ff_pcm_alaw_decoder, -+ &ff_pcm_f32le_decoder, -+ &ff_pcm_mulaw_decoder, -+ &ff_pcm_s16be_decoder, -+ &ff_pcm_s16le_decoder, -+ &ff_pcm_s24be_decoder, -+ &ff_pcm_s24le_decoder, -+ &ff_pcm_s32le_decoder, -+ &ff_pcm_u8_decoder, -+ &ff_libopus_decoder, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/parser_list.c -@@ -0,0 +1,11 @@ -+static const AVCodecParser * const parser_list[] = { -+ &ff_aac_parser, -+ &ff_flac_parser, -+ &ff_h264_parser, -+ &ff_mpegaudio_parser, -+ &ff_opus_parser, -+ &ff_vorbis_parser, -+ &ff_vp3_parser, -+ &ff_vp8_parser, -+ &ff_vp9_parser, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/demuxer_list.c -@@ -0,0 +1,9 @@ -+static const AVInputFormat * const demuxer_list[] = { -+ &ff_aac_demuxer, -+ &ff_flac_demuxer, -+ &ff_matroska_demuxer, -+ &ff_mov_demuxer, -+ &ff_mp3_demuxer, -+ &ff_ogg_demuxer, -+ &ff_wav_demuxer, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/muxer_list.c -@@ -0,0 +1,2 @@ -+static const AVOutputFormat * const muxer_list[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/protocol_list.c -@@ -0,0 +1,2 @@ -+static const URLProtocol * const url_protocols[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavutil/avconfig.h -@@ -0,0 +1,6 @@ -+/* Generated by ffmpeg configure */ -+#ifndef AVUTIL_AVCONFIG_H -+#define AVUTIL_AVCONFIG_H -+#define AV_HAVE_BIGENDIAN 0 -+#define AV_HAVE_FAST_UNALIGNED 0 -+#endif /* AVUTIL_AVCONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/config.h -@@ -0,0 +1,2626 @@ -+/* Automatically generated by configure - do not modify! */ -+#ifndef FFMPEG_CONFIG_H -+#define FFMPEG_CONFIG_H -+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64 --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */ -+#define FFMPEG_LICENSE "LGPL version 2.1 or later" -+#define CONFIG_THIS_YEAR 2020 -+#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" -+#define AVCONV_DATADIR "/usr/local/share/ffmpeg" -+#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" -+#define av_restrict restrict -+#define EXTERN_PREFIX "" -+#define EXTERN_ASM -+#define BUILDSUF "" -+#define SLIBSUF ".so" -+#define HAVE_MMX2 HAVE_MMXEXT -+#define SWS_MAX_FILTER_SIZE 256 -+#define ARCH_AARCH64 0 -+#define ARCH_ALPHA 0 -+#define ARCH_ARM 0 -+#define ARCH_AVR32 0 -+#define ARCH_AVR32_AP 0 -+#define ARCH_AVR32_UC 0 -+#define ARCH_BFIN 0 -+#define ARCH_IA64 0 -+#define ARCH_M68K 0 -+#define ARCH_MIPS 0 -+#define ARCH_MIPS64 0 -+#define ARCH_PARISC 0 -+#define ARCH_PPC 0 -+#define ARCH_PPC64 0 -+#define ARCH_RISCV 1 -+#define ARCH_S390 0 -+#define ARCH_SH4 0 -+#define ARCH_SPARC 0 -+#define ARCH_SPARC64 0 -+#define ARCH_TILEGX 0 -+#define ARCH_TILEPRO 0 -+#define ARCH_TOMI 0 -+#define ARCH_X86 0 -+#define ARCH_X86_32 0 -+#define ARCH_X86_64 0 -+#define HAVE_ARMV5TE 0 -+#define HAVE_ARMV6 0 -+#define HAVE_ARMV6T2 0 -+#define HAVE_ARMV8 0 -+#define HAVE_NEON 0 -+#define HAVE_VFP 0 -+#define HAVE_VFPV3 0 -+#define HAVE_SETEND 0 -+#define HAVE_ALTIVEC 0 -+#define HAVE_DCBZL 0 -+#define HAVE_LDBRX 0 -+#define HAVE_POWER8 0 -+#define HAVE_PPC4XX 0 -+#define HAVE_VSX 0 -+#define HAVE_AESNI 0 -+#define HAVE_AMD3DNOW 0 -+#define HAVE_AMD3DNOWEXT 0 -+#define HAVE_AVX 0 -+#define HAVE_AVX2 0 -+#define HAVE_AVX512 0 -+#define HAVE_FMA3 0 -+#define HAVE_FMA4 0 -+#define HAVE_MMX 0 -+#define HAVE_MMXEXT 0 -+#define HAVE_SSE 0 -+#define HAVE_SSE2 0 -+#define HAVE_SSE3 0 -+#define HAVE_SSE4 0 -+#define HAVE_SSE42 0 -+#define HAVE_SSSE3 0 -+#define HAVE_XOP 0 -+#define HAVE_CPUNOP 0 -+#define HAVE_I686 0 -+#define HAVE_MIPSFPU 0 -+#define HAVE_MIPS32R2 0 -+#define HAVE_MIPS32R5 0 -+#define HAVE_MIPS64R2 0 -+#define HAVE_MIPS32R6 0 -+#define HAVE_MIPS64R6 0 -+#define HAVE_MIPSDSP 0 -+#define HAVE_MIPSDSPR2 0 -+#define HAVE_MSA 0 -+#define HAVE_MSA2 0 -+#define HAVE_LOONGSON2 0 -+#define HAVE_LOONGSON3 0 -+#define HAVE_MMI 0 -+#define HAVE_ARMV5TE_EXTERNAL 0 -+#define HAVE_ARMV6_EXTERNAL 0 -+#define HAVE_ARMV6T2_EXTERNAL 0 -+#define HAVE_ARMV8_EXTERNAL 0 -+#define HAVE_NEON_EXTERNAL 0 -+#define HAVE_VFP_EXTERNAL 0 -+#define HAVE_VFPV3_EXTERNAL 0 -+#define HAVE_SETEND_EXTERNAL 0 -+#define HAVE_ALTIVEC_EXTERNAL 0 -+#define HAVE_DCBZL_EXTERNAL 0 -+#define HAVE_LDBRX_EXTERNAL 0 -+#define HAVE_POWER8_EXTERNAL 0 -+#define HAVE_PPC4XX_EXTERNAL 0 -+#define HAVE_VSX_EXTERNAL 0 -+#define HAVE_AESNI_EXTERNAL 0 -+#define HAVE_AMD3DNOW_EXTERNAL 0 -+#define HAVE_AMD3DNOWEXT_EXTERNAL 0 -+#define HAVE_AVX_EXTERNAL 0 -+#define HAVE_AVX2_EXTERNAL 0 -+#define HAVE_AVX512_EXTERNAL 0 -+#define HAVE_FMA3_EXTERNAL 0 -+#define HAVE_FMA4_EXTERNAL 0 -+#define HAVE_MMX_EXTERNAL 0 -+#define HAVE_MMXEXT_EXTERNAL 0 -+#define HAVE_SSE_EXTERNAL 0 -+#define HAVE_SSE2_EXTERNAL 0 -+#define HAVE_SSE3_EXTERNAL 0 -+#define HAVE_SSE4_EXTERNAL 0 -+#define HAVE_SSE42_EXTERNAL 0 -+#define HAVE_SSSE3_EXTERNAL 0 -+#define HAVE_XOP_EXTERNAL 0 -+#define HAVE_CPUNOP_EXTERNAL 0 -+#define HAVE_I686_EXTERNAL 0 -+#define HAVE_MIPSFPU_EXTERNAL 0 -+#define HAVE_MIPS32R2_EXTERNAL 0 -+#define HAVE_MIPS32R5_EXTERNAL 0 -+#define HAVE_MIPS64R2_EXTERNAL 0 -+#define HAVE_MIPS32R6_EXTERNAL 0 -+#define HAVE_MIPS64R6_EXTERNAL 0 -+#define HAVE_MIPSDSP_EXTERNAL 0 -+#define HAVE_MIPSDSPR2_EXTERNAL 0 -+#define HAVE_MSA_EXTERNAL 0 -+#define HAVE_MSA2_EXTERNAL 0 -+#define HAVE_LOONGSON2_EXTERNAL 0 -+#define HAVE_LOONGSON3_EXTERNAL 0 -+#define HAVE_MMI_EXTERNAL 0 -+#define HAVE_ARMV5TE_INLINE 0 -+#define HAVE_ARMV6_INLINE 0 -+#define HAVE_ARMV6T2_INLINE 0 -+#define HAVE_ARMV8_INLINE 0 -+#define HAVE_NEON_INLINE 0 -+#define HAVE_VFP_INLINE 0 -+#define HAVE_VFPV3_INLINE 0 -+#define HAVE_SETEND_INLINE 0 -+#define HAVE_ALTIVEC_INLINE 0 -+#define HAVE_DCBZL_INLINE 0 -+#define HAVE_LDBRX_INLINE 0 -+#define HAVE_POWER8_INLINE 0 -+#define HAVE_PPC4XX_INLINE 0 -+#define HAVE_VSX_INLINE 0 -+#define HAVE_AESNI_INLINE 0 -+#define HAVE_AMD3DNOW_INLINE 0 -+#define HAVE_AMD3DNOWEXT_INLINE 0 -+#define HAVE_AVX_INLINE 0 -+#define HAVE_AVX2_INLINE 0 -+#define HAVE_AVX512_INLINE 0 -+#define HAVE_FMA3_INLINE 0 -+#define HAVE_FMA4_INLINE 0 -+#define HAVE_MMX_INLINE 0 -+#define HAVE_MMXEXT_INLINE 0 -+#define HAVE_SSE_INLINE 0 -+#define HAVE_SSE2_INLINE 0 -+#define HAVE_SSE3_INLINE 0 -+#define HAVE_SSE4_INLINE 0 -+#define HAVE_SSE42_INLINE 0 -+#define HAVE_SSSE3_INLINE 0 -+#define HAVE_XOP_INLINE 0 -+#define HAVE_CPUNOP_INLINE 0 -+#define HAVE_I686_INLINE 0 -+#define HAVE_MIPSFPU_INLINE 0 -+#define HAVE_MIPS32R2_INLINE 0 -+#define HAVE_MIPS32R5_INLINE 0 -+#define HAVE_MIPS64R2_INLINE 0 -+#define HAVE_MIPS32R6_INLINE 0 -+#define HAVE_MIPS64R6_INLINE 0 -+#define HAVE_MIPSDSP_INLINE 0 -+#define HAVE_MIPSDSPR2_INLINE 0 -+#define HAVE_MSA_INLINE 0 -+#define HAVE_MSA2_INLINE 0 -+#define HAVE_LOONGSON2_INLINE 0 -+#define HAVE_LOONGSON3_INLINE 0 -+#define HAVE_MMI_INLINE 0 -+#define HAVE_ALIGNED_STACK 0 -+#define HAVE_FAST_64BIT 1 -+#define HAVE_FAST_CLZ 0 -+#define HAVE_FAST_CMOV 0 -+#define HAVE_LOCAL_ALIGNED 0 -+#define HAVE_SIMD_ALIGN_16 0 -+#define HAVE_SIMD_ALIGN_32 0 -+#define HAVE_SIMD_ALIGN_64 0 -+#define HAVE_ATOMIC_CAS_PTR 0 -+#define HAVE_MACHINE_RW_BARRIER 0 -+#define HAVE_MEMORYBARRIER 0 -+#define HAVE_MM_EMPTY 0 -+#define HAVE_RDTSC 0 -+#define HAVE_SEM_TIMEDWAIT 1 -+#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 -+#define HAVE_CABS 0 -+#define HAVE_CEXP 0 -+#define HAVE_INLINE_ASM 1 -+#define HAVE_SYMVER 0 -+#define HAVE_X86ASM 0 -+#define HAVE_BIGENDIAN 0 -+#define HAVE_FAST_UNALIGNED 0 -+#define HAVE_ARPA_INET_H 0 -+#define HAVE_ASM_TYPES_H 1 -+#define HAVE_CDIO_PARANOIA_H 0 -+#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 -+#define HAVE_CUDA_H 0 -+#define HAVE_DISPATCH_DISPATCH_H 0 -+#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 -+#define HAVE_DEV_IC_BT8XX_H 0 -+#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 -+#define HAVE_DIRECT_H 0 -+#define HAVE_DIRENT_H 1 -+#define HAVE_DXGIDEBUG_H 0 -+#define HAVE_DXVA_H 0 -+#define HAVE_ES2_GL_H 0 -+#define HAVE_GSM_H 0 -+#define HAVE_IO_H 0 -+#define HAVE_LINUX_PERF_EVENT_H 1 -+#define HAVE_MACHINE_IOCTL_BT848_H 0 -+#define HAVE_MACHINE_IOCTL_METEOR_H 0 -+#define HAVE_MALLOC_H 1 -+#define HAVE_OPENCV2_CORE_CORE_C_H 0 -+#define HAVE_OPENGL_GL3_H 0 -+#define HAVE_POLL_H 1 -+#define HAVE_SYS_PARAM_H 1 -+#define HAVE_SYS_RESOURCE_H 1 -+#define HAVE_SYS_SELECT_H 1 -+#define HAVE_SYS_SOUNDCARD_H 1 -+#define HAVE_SYS_TIME_H 1 -+#define HAVE_SYS_UN_H 1 -+#define HAVE_SYS_VIDEOIO_H 0 -+#define HAVE_TERMIOS_H 1 -+#define HAVE_UDPLITE_H 0 -+#define HAVE_UNISTD_H 1 -+#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ -+#define HAVE_WINDOWS_H 0 -+#define HAVE_WINSOCK2_H 0 -+#define HAVE_INTRINSICS_NEON 0 -+#define HAVE_ATANF 1 -+#define HAVE_ATAN2F 1 -+#define HAVE_CBRT 1 -+#define HAVE_CBRTF 1 -+#define HAVE_COPYSIGN 1 -+#define HAVE_COSF 1 -+#define HAVE_ERF 1 -+#define HAVE_EXP2 1 -+#define HAVE_EXP2F 1 -+#define HAVE_EXPF 1 -+#define HAVE_HYPOT 1 -+#define HAVE_ISFINITE 1 -+#define HAVE_ISINF 1 -+#define HAVE_ISNAN 1 -+#define HAVE_LDEXPF 1 -+#define HAVE_LLRINT 1 -+#define HAVE_LLRINTF 1 -+#define HAVE_LOG2 1 -+#define HAVE_LOG2F 1 -+#define HAVE_LOG10F 1 -+#define HAVE_LRINT 1 -+#define HAVE_LRINTF 1 -+#define HAVE_POWF 1 -+#define HAVE_RINT 1 -+#define HAVE_ROUND 1 -+#define HAVE_ROUNDF 1 -+#define HAVE_SINF 1 -+#define HAVE_TRUNC 1 -+#define HAVE_TRUNCF 1 -+#define HAVE_DOS_PATHS 0 -+#define HAVE_LIBC_MSVCRT 0 -+#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 -+#define HAVE_SECTION_DATA_REL_RO 1 -+#define HAVE_THREADS 1 -+#define HAVE_UWP 0 -+#define HAVE_WINRT 0 -+#define HAVE_ACCESS 1 -+#define HAVE_ALIGNED_MALLOC 0 -+#define HAVE_ARC4RANDOM 0 -+#define HAVE_CLOCK_GETTIME 1 -+#define HAVE_CLOSESOCKET 0 -+#define HAVE_COMMANDLINETOARGVW 0 -+#define HAVE_FCNTL 1 -+#define HAVE_GETADDRINFO 0 -+#define HAVE_GETHRTIME 0 -+#define HAVE_GETOPT 1 -+#define HAVE_GETMODULEHANDLE 0 -+#define HAVE_GETPROCESSAFFINITYMASK 0 -+#define HAVE_GETPROCESSMEMORYINFO 0 -+#define HAVE_GETPROCESSTIMES 0 -+#define HAVE_GETRUSAGE 1 -+#define HAVE_GETSTDHANDLE 0 -+#define HAVE_GETSYSTEMTIMEASFILETIME 0 -+#define HAVE_GETTIMEOFDAY 1 -+#define HAVE_GLOB 1 -+#define HAVE_GLXGETPROCADDRESS 0 -+#define HAVE_GMTIME_R 1 -+#define HAVE_INET_ATON 0 -+#define HAVE_ISATTY 1 -+#define HAVE_KBHIT 0 -+#define HAVE_LOCALTIME_R 1 -+#define HAVE_LSTAT 1 -+#define HAVE_LZO1X_999_COMPRESS 0 -+#define HAVE_MACH_ABSOLUTE_TIME 0 -+#define HAVE_MAPVIEWOFFILE 0 -+#define HAVE_MEMALIGN 1 -+#define HAVE_MKSTEMP 1 -+#define HAVE_MMAP 1 -+#define HAVE_MPROTECT 1 -+#define HAVE_NANOSLEEP 1 -+#define HAVE_PEEKNAMEDPIPE 0 -+#define HAVE_POSIX_MEMALIGN 1 -+#define HAVE_PTHREAD_CANCEL 1 -+#define HAVE_SCHED_GETAFFINITY 1 -+#define HAVE_SECITEMIMPORT 0 -+#define HAVE_SETCONSOLETEXTATTRIBUTE 0 -+#define HAVE_SETCONSOLECTRLHANDLER 0 -+#define HAVE_SETDLLDIRECTORY 0 -+#define HAVE_SETMODE 0 -+#define HAVE_SETRLIMIT 1 -+#define HAVE_SLEEP 0 -+#define HAVE_STRERROR_R 1 -+#define HAVE_SYSCONF 1 -+#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ -+#define HAVE_USLEEP 1 -+#define HAVE_UTGETOSTYPEFROMSTRING 0 -+#define HAVE_VIRTUALALLOC 0 -+#define HAVE_WGLGETPROCADDRESS 0 -+#define HAVE_BCRYPT 0 -+#define HAVE_VAAPI_DRM 0 -+#define HAVE_VAAPI_X11 0 -+#define HAVE_VDPAU_X11 0 -+#define HAVE_PTHREADS 1 -+#define HAVE_OS2THREADS 0 -+#define HAVE_W32THREADS 0 -+#define HAVE_AS_ARCH_DIRECTIVE 0 -+#define HAVE_AS_DN_DIRECTIVE 0 -+#define HAVE_AS_FPU_DIRECTIVE 0 -+#define HAVE_AS_FUNC 0 -+#define HAVE_AS_OBJECT_ARCH 0 -+#define HAVE_ASM_MOD_Q 0 -+#define HAVE_BLOCKS_EXTENSION 0 -+#define HAVE_EBP_AVAILABLE 0 -+#define HAVE_EBX_AVAILABLE 0 -+#define HAVE_GNU_AS 0 -+#define HAVE_GNU_WINDRES 0 -+#define HAVE_IBM_ASM 0 -+#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 -+#define HAVE_INLINE_ASM_LABELS 1 -+#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 -+#define HAVE_PRAGMA_DEPRECATED 1 -+#define HAVE_RSYNC_CONTIMEOUT 0 -+#define HAVE_SYMVER_ASM_LABEL 0 -+#define HAVE_SYMVER_GNU_ASM 1 -+#define HAVE_VFP_ARGS 0 -+#define HAVE_XFORM_ASM 0 -+#define HAVE_XMM_CLOBBERS 0 -+#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 -+#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 -+#define HAVE_SOCKLEN_T 0 -+#define HAVE_STRUCT_ADDRINFO 0 -+#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 -+#define HAVE_STRUCT_IP_MREQ_SOURCE 0 -+#define HAVE_STRUCT_IPV6_MREQ 0 -+#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 -+#define HAVE_STRUCT_POLLFD 0 -+#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 -+#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 -+#define HAVE_STRUCT_SOCKADDR_IN6 0 -+#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 -+#define HAVE_STRUCT_SOCKADDR_STORAGE 0 -+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 -+#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 -+#define HAVE_LIBDRM_GETFB2 0 -+#define HAVE_MAKEINFO 0 -+#define HAVE_MAKEINFO_HTML 0 -+#define HAVE_OPENCL_D3D11 0 -+#define HAVE_OPENCL_DRM_ARM 0 -+#define HAVE_OPENCL_DRM_BEIGNET 0 -+#define HAVE_OPENCL_DXVA2 0 -+#define HAVE_OPENCL_VAAPI_BEIGNET 0 -+#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 -+#define HAVE_PERL 1 -+#define HAVE_POD2MAN 1 -+#define HAVE_TEXI2HTML 0 -+#define CONFIG_DOC 0 -+#define CONFIG_HTMLPAGES 0 -+#define CONFIG_MANPAGES 0 -+#define CONFIG_PODPAGES 0 -+#define CONFIG_TXTPAGES 0 -+#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 -+#define CONFIG_AVIO_READING_EXAMPLE 1 -+#define CONFIG_DECODE_AUDIO_EXAMPLE 1 -+#define CONFIG_DECODE_VIDEO_EXAMPLE 1 -+#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 -+#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 -+#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 -+#define CONFIG_EXTRACT_MVS_EXAMPLE 1 -+#define CONFIG_FILTER_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 -+#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 -+#define CONFIG_HW_DECODE_EXAMPLE 1 -+#define CONFIG_METADATA_EXAMPLE 1 -+#define CONFIG_MUXING_EXAMPLE 0 -+#define CONFIG_QSVDEC_EXAMPLE 0 -+#define CONFIG_REMUXING_EXAMPLE 1 -+#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 -+#define CONFIG_SCALING_VIDEO_EXAMPLE 0 -+#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 -+#define CONFIG_TRANSCODING_EXAMPLE 0 -+#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 -+#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 -+#define CONFIG_AVISYNTH 0 -+#define CONFIG_FREI0R 0 -+#define CONFIG_LIBCDIO 0 -+#define CONFIG_LIBDAVS2 0 -+#define CONFIG_LIBRUBBERBAND 0 -+#define CONFIG_LIBVIDSTAB 0 -+#define CONFIG_LIBX264 0 -+#define CONFIG_LIBX265 0 -+#define CONFIG_LIBXAVS 0 -+#define CONFIG_LIBXAVS2 0 -+#define CONFIG_LIBXVID 0 -+#define CONFIG_DECKLINK 0 -+#define CONFIG_LIBFDK_AAC 0 -+#define CONFIG_OPENSSL 0 -+#define CONFIG_LIBTLS 0 -+#define CONFIG_GMP 0 -+#define CONFIG_LIBARIBB24 0 -+#define CONFIG_LIBLENSFUN 0 -+#define CONFIG_LIBOPENCORE_AMRNB 0 -+#define CONFIG_LIBOPENCORE_AMRWB 0 -+#define CONFIG_LIBVO_AMRWBENC 0 -+#define CONFIG_MBEDTLS 0 -+#define CONFIG_RKMPP 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_CHROMAPRINT 0 -+#define CONFIG_GCRYPT 0 -+#define CONFIG_GNUTLS 0 -+#define CONFIG_JNI 0 -+#define CONFIG_LADSPA 0 -+#define CONFIG_LIBAOM 0 -+#define CONFIG_LIBASS 0 -+#define CONFIG_LIBBLURAY 0 -+#define CONFIG_LIBBS2B 0 -+#define CONFIG_LIBCACA 0 -+#define CONFIG_LIBCELT 0 -+#define CONFIG_LIBCODEC2 0 -+#define CONFIG_LIBDAV1D 0 -+#define CONFIG_LIBDC1394 0 -+#define CONFIG_LIBDRM 0 -+#define CONFIG_LIBFLITE 0 -+#define CONFIG_LIBFONTCONFIG 0 -+#define CONFIG_LIBFREETYPE 0 -+#define CONFIG_LIBFRIBIDI 0 -+#define CONFIG_LIBGLSLANG 0 -+#define CONFIG_LIBGME 0 -+#define CONFIG_LIBGSM 0 -+#define CONFIG_LIBIEC61883 0 -+#define CONFIG_LIBILBC 0 -+#define CONFIG_LIBJACK 0 -+#define CONFIG_LIBKLVANC 0 -+#define CONFIG_LIBKVAZAAR 0 -+#define CONFIG_LIBMODPLUG 0 -+#define CONFIG_LIBMP3LAME 0 -+#define CONFIG_LIBMYSOFA 0 -+#define CONFIG_LIBOPENCV 0 -+#define CONFIG_LIBOPENH264 0 -+#define CONFIG_LIBOPENJPEG 0 -+#define CONFIG_LIBOPENMPT 0 -+#define CONFIG_LIBOPENVINO 0 -+#define CONFIG_LIBOPUS 1 -+#define CONFIG_LIBPULSE 0 -+#define CONFIG_LIBRABBITMQ 0 -+#define CONFIG_LIBRAV1E 0 -+#define CONFIG_LIBRSVG 0 -+#define CONFIG_LIBRTMP 0 -+#define CONFIG_LIBSHINE 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_LIBSNAPPY 0 -+#define CONFIG_LIBSOXR 0 -+#define CONFIG_LIBSPEEX 0 -+#define CONFIG_LIBSRT 0 -+#define CONFIG_LIBSSH 0 -+#define CONFIG_LIBSVTAV1 0 -+#define CONFIG_LIBTENSORFLOW 0 -+#define CONFIG_LIBTESSERACT 0 -+#define CONFIG_LIBTHEORA 0 -+#define CONFIG_LIBTWOLAME 0 -+#define CONFIG_LIBV4L2 0 -+#define CONFIG_LIBVMAF 0 -+#define CONFIG_LIBVORBIS 0 -+#define CONFIG_LIBVPX 0 -+#define CONFIG_LIBWAVPACK 0 -+#define CONFIG_LIBWEBP 0 -+#define CONFIG_LIBXML2 0 -+#define CONFIG_LIBZIMG 0 -+#define CONFIG_LIBZMQ 0 -+#define CONFIG_LIBZVBI 0 -+#define CONFIG_LV2 0 -+#define CONFIG_MEDIACODEC 0 -+#define CONFIG_OPENAL 0 -+#define CONFIG_OPENGL 0 -+#define CONFIG_POCKETSPHINX 0 -+#define CONFIG_VAPOURSYNTH 0 -+#define CONFIG_ALSA 0 -+#define CONFIG_APPKIT 0 -+#define CONFIG_AVFOUNDATION 0 -+#define CONFIG_BZLIB 0 -+#define CONFIG_COREIMAGE 0 -+#define CONFIG_ICONV 0 -+#define CONFIG_LIBXCB 0 -+#define CONFIG_LIBXCB_SHM 0 -+#define CONFIG_LIBXCB_SHAPE 0 -+#define CONFIG_LIBXCB_XFIXES 0 -+#define CONFIG_LZMA 0 -+#define CONFIG_MEDIAFOUNDATION 0 -+#define CONFIG_SCHANNEL 0 -+#define CONFIG_SDL2 0 -+#define CONFIG_SECURETRANSPORT 0 -+#define CONFIG_SNDIO 0 -+#define CONFIG_XLIB 0 -+#define CONFIG_ZLIB 0 -+#define CONFIG_CUDA_NVCC 0 -+#define CONFIG_CUDA_SDK 0 -+#define CONFIG_LIBNPP 0 -+#define CONFIG_LIBMFX 0 -+#define CONFIG_MMAL 0 -+#define CONFIG_OMX 0 -+#define CONFIG_OPENCL 0 -+#define CONFIG_VULKAN 0 -+#define CONFIG_AMF 0 -+#define CONFIG_AUDIOTOOLBOX 0 -+#define CONFIG_CRYSTALHD 0 -+#define CONFIG_CUDA 0 -+#define CONFIG_CUDA_LLVM 0 -+#define CONFIG_CUVID 0 -+#define CONFIG_D3D11VA 0 -+#define CONFIG_DXVA2 0 -+#define CONFIG_FFNVCODEC 0 -+#define CONFIG_NVDEC 0 -+#define CONFIG_NVENC 0 -+#define CONFIG_VAAPI 0 -+#define CONFIG_VDPAU 0 -+#define CONFIG_VIDEOTOOLBOX 0 -+#define CONFIG_V4L2_M2M 0 -+#define CONFIG_XVMC 0 -+#define CONFIG_FTRAPV 0 -+#define CONFIG_GRAY 0 -+#define CONFIG_HARDCODED_TABLES 0 -+#define CONFIG_OMX_RPI 0 -+#define CONFIG_RUNTIME_CPUDETECT 1 -+#define CONFIG_SAFE_BITSTREAM_READER 1 -+#define CONFIG_SHARED 0 -+#define CONFIG_SMALL 0 -+#define CONFIG_STATIC 1 -+#define CONFIG_SWSCALE_ALPHA 1 -+#define CONFIG_GPL 0 -+#define CONFIG_NONFREE 0 -+#define CONFIG_VERSION3 0 -+#define CONFIG_AVDEVICE 0 -+#define CONFIG_AVFILTER 0 -+#define CONFIG_SWSCALE 0 -+#define CONFIG_POSTPROC 0 -+#define CONFIG_AVFORMAT 1 -+#define CONFIG_AVCODEC 1 -+#define CONFIG_SWRESAMPLE 0 -+#define CONFIG_AVRESAMPLE 0 -+#define CONFIG_AVUTIL 1 -+#define CONFIG_FFPLAY 0 -+#define CONFIG_FFPROBE 0 -+#define CONFIG_FFMPEG 0 -+#define CONFIG_DCT 1 -+#define CONFIG_DWT 0 -+#define CONFIG_ERROR_RESILIENCE 1 -+#define CONFIG_FAAN 0 -+#define CONFIG_FAST_UNALIGNED 0 -+#define CONFIG_FFT 1 -+#define CONFIG_LSP 1 -+#define CONFIG_LZO 0 -+#define CONFIG_MDCT 1 -+#define CONFIG_PIXELUTILS 0 -+#define CONFIG_NETWORK 0 -+#define CONFIG_RDFT 1 -+#define CONFIG_AUTODETECT 0 -+#define CONFIG_FONTCONFIG 0 -+#define CONFIG_LARGE_TESTS 1 -+#define CONFIG_LINUX_PERF 0 -+#define CONFIG_MEMORY_POISONING 0 -+#define CONFIG_NEON_CLOBBER_TEST 0 -+#define CONFIG_OSSFUZZ 0 -+#define CONFIG_PIC 1 -+#define CONFIG_THUMB 0 -+#define CONFIG_VALGRIND_BACKTRACE 0 -+#define CONFIG_XMM_CLOBBER_TEST 0 -+#define CONFIG_BSFS 1 -+#define CONFIG_DECODERS 1 -+#define CONFIG_ENCODERS 0 -+#define CONFIG_HWACCELS 0 -+#define CONFIG_PARSERS 1 -+#define CONFIG_INDEVS 0 -+#define CONFIG_OUTDEVS 0 -+#define CONFIG_FILTERS 0 -+#define CONFIG_DEMUXERS 1 -+#define CONFIG_MUXERS 0 -+#define CONFIG_PROTOCOLS 0 -+#define CONFIG_AANDCTTABLES 0 -+#define CONFIG_AC3DSP 0 -+#define CONFIG_ADTS_HEADER 1 -+#define CONFIG_ATSC_A53 1 -+#define CONFIG_AUDIO_FRAME_QUEUE 0 -+#define CONFIG_AUDIODSP 0 -+#define CONFIG_BLOCKDSP 1 -+#define CONFIG_BSWAPDSP 0 -+#define CONFIG_CABAC 1 -+#define CONFIG_CBS 0 -+#define CONFIG_CBS_AV1 0 -+#define CONFIG_CBS_H264 0 -+#define CONFIG_CBS_H265 0 -+#define CONFIG_CBS_JPEG 0 -+#define CONFIG_CBS_MPEG2 0 -+#define CONFIG_CBS_VP9 0 -+#define CONFIG_DIRAC_PARSE 1 -+#define CONFIG_DNN 0 -+#define CONFIG_DVPROFILE 0 -+#define CONFIG_EXIF 1 -+#define CONFIG_FAANDCT 0 -+#define CONFIG_FAANIDCT 0 -+#define CONFIG_FDCTDSP 1 -+#define CONFIG_FLACDSP 1 -+#define CONFIG_FMTCONVERT 0 -+#define CONFIG_FRAME_THREAD_ENCODER 0 -+#define CONFIG_G722DSP 0 -+#define CONFIG_GOLOMB 1 -+#define CONFIG_GPLV3 0 -+#define CONFIG_H263DSP 1 -+#define CONFIG_H264CHROMA 1 -+#define CONFIG_H264DSP 1 -+#define CONFIG_H264PARSE 1 -+#define CONFIG_H264PRED 1 -+#define CONFIG_H264QPEL 1 -+#define CONFIG_HEVCPARSE 0 -+#define CONFIG_HPELDSP 1 -+#define CONFIG_HUFFMAN 0 -+#define CONFIG_HUFFYUVDSP 0 -+#define CONFIG_HUFFYUVENCDSP 0 -+#define CONFIG_IDCTDSP 1 -+#define CONFIG_IIRFILTER 0 -+#define CONFIG_MDCT15 1 -+#define CONFIG_INTRAX8 0 -+#define CONFIG_ISO_MEDIA 1 -+#define CONFIG_IVIDSP 0 -+#define CONFIG_JPEGTABLES 0 -+#define CONFIG_LGPLV3 0 -+#define CONFIG_LIBX262 0 -+#define CONFIG_LLAUDDSP 0 -+#define CONFIG_LLVIDDSP 0 -+#define CONFIG_LLVIDENCDSP 0 -+#define CONFIG_LPC 0 -+#define CONFIG_LZF 0 -+#define CONFIG_ME_CMP 1 -+#define CONFIG_MPEG_ER 1 -+#define CONFIG_MPEGAUDIO 1 -+#define CONFIG_MPEGAUDIODSP 1 -+#define CONFIG_MPEGAUDIOHEADER 1 -+#define CONFIG_MPEGVIDEO 1 -+#define CONFIG_MPEGVIDEOENC 0 -+#define CONFIG_MSS34DSP 0 -+#define CONFIG_PIXBLOCKDSP 1 -+#define CONFIG_QPELDSP 1 -+#define CONFIG_QSV 0 -+#define CONFIG_QSVDEC 0 -+#define CONFIG_QSVENC 0 -+#define CONFIG_QSVVPP 0 -+#define CONFIG_RANGECODER 0 -+#define CONFIG_RIFFDEC 1 -+#define CONFIG_RIFFENC 0 -+#define CONFIG_RTPDEC 0 -+#define CONFIG_RTPENC_CHAIN 0 -+#define CONFIG_RV34DSP 0 -+#define CONFIG_SCENE_SAD 0 -+#define CONFIG_SINEWIN 1 -+#define CONFIG_SNAPPY 0 -+#define CONFIG_SRTP 0 -+#define CONFIG_STARTCODE 1 -+#define CONFIG_TEXTUREDSP 0 -+#define CONFIG_TEXTUREDSPENC 0 -+#define CONFIG_TPELDSP 0 -+#define CONFIG_VAAPI_1 0 -+#define CONFIG_VAAPI_ENCODE 0 -+#define CONFIG_VC1DSP 0 -+#define CONFIG_VIDEODSP 1 -+#define CONFIG_VP3DSP 1 -+#define CONFIG_VP56DSP 0 -+#define CONFIG_VP8DSP 1 -+#define CONFIG_WMA_FREQS 0 -+#define CONFIG_WMV2DSP 0 -+#define CONFIG_AAC_ADTSTOASC_BSF 0 -+#define CONFIG_AV1_FRAME_MERGE_BSF 0 -+#define CONFIG_AV1_FRAME_SPLIT_BSF 0 -+#define CONFIG_AV1_METADATA_BSF 0 -+#define CONFIG_CHOMP_BSF 0 -+#define CONFIG_DUMP_EXTRADATA_BSF 0 -+#define CONFIG_DCA_CORE_BSF 0 -+#define CONFIG_EAC3_CORE_BSF 0 -+#define CONFIG_EXTRACT_EXTRADATA_BSF 0 -+#define CONFIG_FILTER_UNITS_BSF 0 -+#define CONFIG_H264_METADATA_BSF 0 -+#define CONFIG_H264_MP4TOANNEXB_BSF 0 -+#define CONFIG_H264_REDUNDANT_PPS_BSF 0 -+#define CONFIG_HAPQA_EXTRACT_BSF 0 -+#define CONFIG_HEVC_METADATA_BSF 0 -+#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 -+#define CONFIG_IMX_DUMP_HEADER_BSF 0 -+#define CONFIG_MJPEG2JPEG_BSF 0 -+#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 -+#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 -+#define CONFIG_MPEG2_METADATA_BSF 0 -+#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 -+#define CONFIG_MOV2TEXTSUB_BSF 0 -+#define CONFIG_NOISE_BSF 0 -+#define CONFIG_NULL_BSF 1 -+#define CONFIG_OPUS_METADATA_BSF 0 -+#define CONFIG_PCM_RECHUNK_BSF 0 -+#define CONFIG_PRORES_METADATA_BSF 0 -+#define CONFIG_REMOVE_EXTRADATA_BSF 0 -+#define CONFIG_TEXT2MOVSUB_BSF 0 -+#define CONFIG_TRACE_HEADERS_BSF 0 -+#define CONFIG_TRUEHD_CORE_BSF 0 -+#define CONFIG_VP9_METADATA_BSF 0 -+#define CONFIG_VP9_RAW_REORDER_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 -+#define CONFIG_AASC_DECODER 0 -+#define CONFIG_AIC_DECODER 0 -+#define CONFIG_ALIAS_PIX_DECODER 0 -+#define CONFIG_AGM_DECODER 0 -+#define CONFIG_AMV_DECODER 0 -+#define CONFIG_ANM_DECODER 0 -+#define CONFIG_ANSI_DECODER 0 -+#define CONFIG_APNG_DECODER 0 -+#define CONFIG_ARBC_DECODER 0 -+#define CONFIG_ASV1_DECODER 0 -+#define CONFIG_ASV2_DECODER 0 -+#define CONFIG_AURA_DECODER 0 -+#define CONFIG_AURA2_DECODER 0 -+#define CONFIG_AVRP_DECODER 0 -+#define CONFIG_AVRN_DECODER 0 -+#define CONFIG_AVS_DECODER 0 -+#define CONFIG_AVUI_DECODER 0 -+#define CONFIG_AYUV_DECODER 0 -+#define CONFIG_BETHSOFTVID_DECODER 0 -+#define CONFIG_BFI_DECODER 0 -+#define CONFIG_BINK_DECODER 0 -+#define CONFIG_BITPACKED_DECODER 0 -+#define CONFIG_BMP_DECODER 0 -+#define CONFIG_BMV_VIDEO_DECODER 0 -+#define CONFIG_BRENDER_PIX_DECODER 0 -+#define CONFIG_C93_DECODER 0 -+#define CONFIG_CAVS_DECODER 0 -+#define CONFIG_CDGRAPHICS_DECODER 0 -+#define CONFIG_CDTOONS_DECODER 0 -+#define CONFIG_CDXL_DECODER 0 -+#define CONFIG_CFHD_DECODER 0 -+#define CONFIG_CINEPAK_DECODER 0 -+#define CONFIG_CLEARVIDEO_DECODER 0 -+#define CONFIG_CLJR_DECODER 0 -+#define CONFIG_CLLC_DECODER 0 -+#define CONFIG_COMFORTNOISE_DECODER 0 -+#define CONFIG_CPIA_DECODER 0 -+#define CONFIG_CSCD_DECODER 0 -+#define CONFIG_CYUV_DECODER 0 -+#define CONFIG_DDS_DECODER 0 -+#define CONFIG_DFA_DECODER 0 -+#define CONFIG_DIRAC_DECODER 0 -+#define CONFIG_DNXHD_DECODER 0 -+#define CONFIG_DPX_DECODER 0 -+#define CONFIG_DSICINVIDEO_DECODER 0 -+#define CONFIG_DVAUDIO_DECODER 0 -+#define CONFIG_DVVIDEO_DECODER 0 -+#define CONFIG_DXA_DECODER 0 -+#define CONFIG_DXTORY_DECODER 0 -+#define CONFIG_DXV_DECODER 0 -+#define CONFIG_EACMV_DECODER 0 -+#define CONFIG_EAMAD_DECODER 0 -+#define CONFIG_EATGQ_DECODER 0 -+#define CONFIG_EATGV_DECODER 0 -+#define CONFIG_EATQI_DECODER 0 -+#define CONFIG_EIGHTBPS_DECODER 0 -+#define CONFIG_EIGHTSVX_EXP_DECODER 0 -+#define CONFIG_EIGHTSVX_FIB_DECODER 0 -+#define CONFIG_ESCAPE124_DECODER 0 -+#define CONFIG_ESCAPE130_DECODER 0 -+#define CONFIG_EXR_DECODER 0 -+#define CONFIG_FFV1_DECODER 0 -+#define CONFIG_FFVHUFF_DECODER 0 -+#define CONFIG_FIC_DECODER 0 -+#define CONFIG_FITS_DECODER 0 -+#define CONFIG_FLASHSV_DECODER 0 -+#define CONFIG_FLASHSV2_DECODER 0 -+#define CONFIG_FLIC_DECODER 0 -+#define CONFIG_FLV_DECODER 0 -+#define CONFIG_FMVC_DECODER 0 -+#define CONFIG_FOURXM_DECODER 0 -+#define CONFIG_FRAPS_DECODER 0 -+#define CONFIG_FRWU_DECODER 0 -+#define CONFIG_G2M_DECODER 0 -+#define CONFIG_GDV_DECODER 0 -+#define CONFIG_GIF_DECODER 0 -+#define CONFIG_H261_DECODER 0 -+#define CONFIG_H263_DECODER 1 -+#define CONFIG_H263I_DECODER 0 -+#define CONFIG_H263P_DECODER 0 -+#define CONFIG_H263_V4L2M2M_DECODER 0 -+#define CONFIG_H264_DECODER 1 -+#define CONFIG_H264_CRYSTALHD_DECODER 0 -+#define CONFIG_H264_V4L2M2M_DECODER 0 -+#define CONFIG_H264_MEDIACODEC_DECODER 0 -+#define CONFIG_H264_MMAL_DECODER 0 -+#define CONFIG_H264_QSV_DECODER 0 -+#define CONFIG_H264_RKMPP_DECODER 0 -+#define CONFIG_HAP_DECODER 0 -+#define CONFIG_HEVC_DECODER 0 -+#define CONFIG_HEVC_QSV_DECODER 0 -+#define CONFIG_HEVC_RKMPP_DECODER 0 -+#define CONFIG_HEVC_V4L2M2M_DECODER 0 -+#define CONFIG_HNM4_VIDEO_DECODER 0 -+#define CONFIG_HQ_HQA_DECODER 0 -+#define CONFIG_HQX_DECODER 0 -+#define CONFIG_HUFFYUV_DECODER 0 -+#define CONFIG_HYMT_DECODER 0 -+#define CONFIG_IDCIN_DECODER 0 -+#define CONFIG_IFF_ILBM_DECODER 0 -+#define CONFIG_IMM4_DECODER 0 -+#define CONFIG_IMM5_DECODER 0 -+#define CONFIG_INDEO2_DECODER 0 -+#define CONFIG_INDEO3_DECODER 0 -+#define CONFIG_INDEO4_DECODER 0 -+#define CONFIG_INDEO5_DECODER 0 -+#define CONFIG_INTERPLAY_VIDEO_DECODER 0 -+#define CONFIG_JPEG2000_DECODER 0 -+#define CONFIG_JPEGLS_DECODER 0 -+#define CONFIG_JV_DECODER 0 -+#define CONFIG_KGV1_DECODER 0 -+#define CONFIG_KMVC_DECODER 0 -+#define CONFIG_LAGARITH_DECODER 0 -+#define CONFIG_LOCO_DECODER 0 -+#define CONFIG_LSCR_DECODER 0 -+#define CONFIG_M101_DECODER 0 -+#define CONFIG_MAGICYUV_DECODER 0 -+#define CONFIG_MDEC_DECODER 0 -+#define CONFIG_MIMIC_DECODER 0 -+#define CONFIG_MJPEG_DECODER 0 -+#define CONFIG_MJPEGB_DECODER 0 -+#define CONFIG_MMVIDEO_DECODER 0 -+#define CONFIG_MOTIONPIXELS_DECODER 0 -+#define CONFIG_MPEG1VIDEO_DECODER 0 -+#define CONFIG_MPEG2VIDEO_DECODER 0 -+#define CONFIG_MPEG4_DECODER 1 -+#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG4_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG4_MMAL_DECODER 0 -+#define CONFIG_MPEGVIDEO_DECODER 0 -+#define CONFIG_MPEG1_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_MMAL_DECODER 0 -+#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG2_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_QSV_DECODER 0 -+#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 -+#define CONFIG_MSA1_DECODER 0 -+#define CONFIG_MSCC_DECODER 0 -+#define CONFIG_MSMPEG4V1_DECODER 0 -+#define CONFIG_MSMPEG4V2_DECODER 0 -+#define CONFIG_MSMPEG4V3_DECODER 0 -+#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MSRLE_DECODER 0 -+#define CONFIG_MSS1_DECODER 0 -+#define CONFIG_MSS2_DECODER 0 -+#define CONFIG_MSVIDEO1_DECODER 0 -+#define CONFIG_MSZH_DECODER 0 -+#define CONFIG_MTS2_DECODER 0 -+#define CONFIG_MV30_DECODER 0 -+#define CONFIG_MVC1_DECODER 0 -+#define CONFIG_MVC2_DECODER 0 -+#define CONFIG_MVDV_DECODER 0 -+#define CONFIG_MVHA_DECODER 0 -+#define CONFIG_MWSC_DECODER 0 -+#define CONFIG_MXPEG_DECODER 0 -+#define CONFIG_NOTCHLC_DECODER 0 -+#define CONFIG_NUV_DECODER 0 -+#define CONFIG_PAF_VIDEO_DECODER 0 -+#define CONFIG_PAM_DECODER 0 -+#define CONFIG_PBM_DECODER 0 -+#define CONFIG_PCX_DECODER 0 -+#define CONFIG_PFM_DECODER 0 -+#define CONFIG_PGM_DECODER 0 -+#define CONFIG_PGMYUV_DECODER 0 -+#define CONFIG_PGX_DECODER 0 -+#define CONFIG_PICTOR_DECODER 0 -+#define CONFIG_PIXLET_DECODER 0 -+#define CONFIG_PNG_DECODER 0 -+#define CONFIG_PPM_DECODER 0 -+#define CONFIG_PRORES_DECODER 0 -+#define CONFIG_PROSUMER_DECODER 0 -+#define CONFIG_PSD_DECODER 0 -+#define CONFIG_PTX_DECODER 0 -+#define CONFIG_QDRAW_DECODER 0 -+#define CONFIG_QPEG_DECODER 0 -+#define CONFIG_QTRLE_DECODER 0 -+#define CONFIG_R10K_DECODER 0 -+#define CONFIG_R210_DECODER 0 -+#define CONFIG_RASC_DECODER 0 -+#define CONFIG_RAWVIDEO_DECODER 0 -+#define CONFIG_RL2_DECODER 0 -+#define CONFIG_ROQ_DECODER 0 -+#define CONFIG_RPZA_DECODER 0 -+#define CONFIG_RSCC_DECODER 0 -+#define CONFIG_RV10_DECODER 0 -+#define CONFIG_RV20_DECODER 0 -+#define CONFIG_RV30_DECODER 0 -+#define CONFIG_RV40_DECODER 0 -+#define CONFIG_S302M_DECODER 0 -+#define CONFIG_SANM_DECODER 0 -+#define CONFIG_SCPR_DECODER 0 -+#define CONFIG_SCREENPRESSO_DECODER 0 -+#define CONFIG_SGI_DECODER 0 -+#define CONFIG_SGIRLE_DECODER 0 -+#define CONFIG_SHEERVIDEO_DECODER 0 -+#define CONFIG_SMACKER_DECODER 0 -+#define CONFIG_SMC_DECODER 0 -+#define CONFIG_SMVJPEG_DECODER 0 -+#define CONFIG_SNOW_DECODER 0 -+#define CONFIG_SP5X_DECODER 0 -+#define CONFIG_SPEEDHQ_DECODER 0 -+#define CONFIG_SRGC_DECODER 0 -+#define CONFIG_SUNRAST_DECODER 0 -+#define CONFIG_SVQ1_DECODER 0 -+#define CONFIG_SVQ3_DECODER 0 -+#define CONFIG_TARGA_DECODER 0 -+#define CONFIG_TARGA_Y216_DECODER 0 -+#define CONFIG_TDSC_DECODER 0 -+#define CONFIG_THEORA_DECODER 1 -+#define CONFIG_THP_DECODER 0 -+#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 -+#define CONFIG_TIFF_DECODER 0 -+#define CONFIG_TMV_DECODER 0 -+#define CONFIG_TRUEMOTION1_DECODER 0 -+#define CONFIG_TRUEMOTION2_DECODER 0 -+#define CONFIG_TRUEMOTION2RT_DECODER 0 -+#define CONFIG_TSCC_DECODER 0 -+#define CONFIG_TSCC2_DECODER 0 -+#define CONFIG_TXD_DECODER 0 -+#define CONFIG_ULTI_DECODER 0 -+#define CONFIG_UTVIDEO_DECODER 0 -+#define CONFIG_V210_DECODER 0 -+#define CONFIG_V210X_DECODER 0 -+#define CONFIG_V308_DECODER 0 -+#define CONFIG_V408_DECODER 0 -+#define CONFIG_V410_DECODER 0 -+#define CONFIG_VB_DECODER 0 -+#define CONFIG_VBLE_DECODER 0 -+#define CONFIG_VC1_DECODER 0 -+#define CONFIG_VC1_CRYSTALHD_DECODER 0 -+#define CONFIG_VC1IMAGE_DECODER 0 -+#define CONFIG_VC1_MMAL_DECODER 0 -+#define CONFIG_VC1_QSV_DECODER 0 -+#define CONFIG_VC1_V4L2M2M_DECODER 0 -+#define CONFIG_VCR1_DECODER 0 -+#define CONFIG_VMDVIDEO_DECODER 0 -+#define CONFIG_VMNC_DECODER 0 -+#define CONFIG_VP3_DECODER 1 -+#define CONFIG_VP4_DECODER 0 -+#define CONFIG_VP5_DECODER 0 -+#define CONFIG_VP6_DECODER 0 -+#define CONFIG_VP6A_DECODER 0 -+#define CONFIG_VP6F_DECODER 0 -+#define CONFIG_VP7_DECODER 0 -+#define CONFIG_VP8_DECODER 1 -+#define CONFIG_VP8_RKMPP_DECODER 0 -+#define CONFIG_VP8_V4L2M2M_DECODER 0 -+#define CONFIG_VP9_DECODER 0 -+#define CONFIG_VP9_RKMPP_DECODER 0 -+#define CONFIG_VP9_V4L2M2M_DECODER 0 -+#define CONFIG_VQA_DECODER 0 -+#define CONFIG_WEBP_DECODER 0 -+#define CONFIG_WCMV_DECODER 0 -+#define CONFIG_WRAPPED_AVFRAME_DECODER 0 -+#define CONFIG_WMV1_DECODER 0 -+#define CONFIG_WMV2_DECODER 0 -+#define CONFIG_WMV3_DECODER 0 -+#define CONFIG_WMV3_CRYSTALHD_DECODER 0 -+#define CONFIG_WMV3IMAGE_DECODER 0 -+#define CONFIG_WNV1_DECODER 0 -+#define CONFIG_XAN_WC3_DECODER 0 -+#define CONFIG_XAN_WC4_DECODER 0 -+#define CONFIG_XBM_DECODER 0 -+#define CONFIG_XFACE_DECODER 0 -+#define CONFIG_XL_DECODER 0 -+#define CONFIG_XPM_DECODER 0 -+#define CONFIG_XWD_DECODER 0 -+#define CONFIG_Y41P_DECODER 0 -+#define CONFIG_YLC_DECODER 0 -+#define CONFIG_YOP_DECODER 0 -+#define CONFIG_YUV4_DECODER 0 -+#define CONFIG_ZERO12V_DECODER 0 -+#define CONFIG_ZEROCODEC_DECODER 0 -+#define CONFIG_ZLIB_DECODER 0 -+#define CONFIG_ZMBV_DECODER 0 -+#define CONFIG_AAC_DECODER 1 -+#define CONFIG_AAC_FIXED_DECODER 0 -+#define CONFIG_AAC_LATM_DECODER 0 -+#define CONFIG_AC3_DECODER 0 -+#define CONFIG_AC3_FIXED_DECODER 0 -+#define CONFIG_ACELP_KELVIN_DECODER 0 -+#define CONFIG_ALAC_DECODER 0 -+#define CONFIG_ALS_DECODER 0 -+#define CONFIG_AMRNB_DECODER 1 -+#define CONFIG_AMRWB_DECODER 1 -+#define CONFIG_APE_DECODER 0 -+#define CONFIG_APTX_DECODER 0 -+#define CONFIG_APTX_HD_DECODER 0 -+#define CONFIG_ATRAC1_DECODER 0 -+#define CONFIG_ATRAC3_DECODER 0 -+#define CONFIG_ATRAC3AL_DECODER 0 -+#define CONFIG_ATRAC3P_DECODER 0 -+#define CONFIG_ATRAC3PAL_DECODER 0 -+#define CONFIG_ATRAC9_DECODER 0 -+#define CONFIG_BINKAUDIO_DCT_DECODER 0 -+#define CONFIG_BINKAUDIO_RDFT_DECODER 0 -+#define CONFIG_BMV_AUDIO_DECODER 0 -+#define CONFIG_COOK_DECODER 0 -+#define CONFIG_DCA_DECODER 0 -+#define CONFIG_DOLBY_E_DECODER 0 -+#define CONFIG_DSD_LSBF_DECODER 0 -+#define CONFIG_DSD_MSBF_DECODER 0 -+#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 -+#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 -+#define CONFIG_DSICINAUDIO_DECODER 0 -+#define CONFIG_DSS_SP_DECODER 0 -+#define CONFIG_DST_DECODER 0 -+#define CONFIG_EAC3_DECODER 0 -+#define CONFIG_EVRC_DECODER 0 -+#define CONFIG_FFWAVESYNTH_DECODER 0 -+#define CONFIG_FLAC_DECODER 1 -+#define CONFIG_G723_1_DECODER 0 -+#define CONFIG_G729_DECODER 0 -+#define CONFIG_GSM_DECODER 0 -+#define CONFIG_GSM_MS_DECODER 1 -+#define CONFIG_HCA_DECODER 0 -+#define CONFIG_HCOM_DECODER 0 -+#define CONFIG_IAC_DECODER 0 -+#define CONFIG_ILBC_DECODER 0 -+#define CONFIG_IMC_DECODER 0 -+#define CONFIG_INTERPLAY_ACM_DECODER 0 -+#define CONFIG_MACE3_DECODER 0 -+#define CONFIG_MACE6_DECODER 0 -+#define CONFIG_METASOUND_DECODER 0 -+#define CONFIG_MLP_DECODER 0 -+#define CONFIG_MP1_DECODER 0 -+#define CONFIG_MP1FLOAT_DECODER 0 -+#define CONFIG_MP2_DECODER 0 -+#define CONFIG_MP2FLOAT_DECODER 0 -+#define CONFIG_MP3FLOAT_DECODER 0 -+#define CONFIG_MP3_DECODER 1 -+#define CONFIG_MP3ADUFLOAT_DECODER 0 -+#define CONFIG_MP3ADU_DECODER 0 -+#define CONFIG_MP3ON4FLOAT_DECODER 0 -+#define CONFIG_MP3ON4_DECODER 0 -+#define CONFIG_MPC7_DECODER 0 -+#define CONFIG_MPC8_DECODER 0 -+#define CONFIG_NELLYMOSER_DECODER 0 -+#define CONFIG_ON2AVC_DECODER 0 -+#define CONFIG_OPUS_DECODER 0 -+#define CONFIG_PAF_AUDIO_DECODER 0 -+#define CONFIG_QCELP_DECODER 0 -+#define CONFIG_QDM2_DECODER 0 -+#define CONFIG_QDMC_DECODER 0 -+#define CONFIG_RA_144_DECODER 0 -+#define CONFIG_RA_288_DECODER 0 -+#define CONFIG_RALF_DECODER 0 -+#define CONFIG_SBC_DECODER 0 -+#define CONFIG_SHORTEN_DECODER 0 -+#define CONFIG_SIPR_DECODER 0 -+#define CONFIG_SIREN_DECODER 0 -+#define CONFIG_SMACKAUD_DECODER 0 -+#define CONFIG_SONIC_DECODER 0 -+#define CONFIG_TAK_DECODER 0 -+#define CONFIG_TRUEHD_DECODER 0 -+#define CONFIG_TRUESPEECH_DECODER 0 -+#define CONFIG_TTA_DECODER 0 -+#define CONFIG_TWINVQ_DECODER 0 -+#define CONFIG_VMDAUDIO_DECODER 0 -+#define CONFIG_VORBIS_DECODER 1 -+#define CONFIG_WAVPACK_DECODER 0 -+#define CONFIG_WMALOSSLESS_DECODER 0 -+#define CONFIG_WMAPRO_DECODER 0 -+#define CONFIG_WMAV1_DECODER 0 -+#define CONFIG_WMAV2_DECODER 0 -+#define CONFIG_WMAVOICE_DECODER 0 -+#define CONFIG_WS_SND1_DECODER 0 -+#define CONFIG_XMA1_DECODER 0 -+#define CONFIG_XMA2_DECODER 0 -+#define CONFIG_PCM_ALAW_DECODER 1 -+#define CONFIG_PCM_BLURAY_DECODER 0 -+#define CONFIG_PCM_DVD_DECODER 0 -+#define CONFIG_PCM_F16LE_DECODER 0 -+#define CONFIG_PCM_F24LE_DECODER 0 -+#define CONFIG_PCM_F32BE_DECODER 0 -+#define CONFIG_PCM_F32LE_DECODER 1 -+#define CONFIG_PCM_F64BE_DECODER 0 -+#define CONFIG_PCM_F64LE_DECODER 0 -+#define CONFIG_PCM_LXF_DECODER 0 -+#define CONFIG_PCM_MULAW_DECODER 1 -+#define CONFIG_PCM_S8_DECODER 0 -+#define CONFIG_PCM_S8_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16BE_DECODER 1 -+#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16LE_DECODER 1 -+#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S24BE_DECODER 1 -+#define CONFIG_PCM_S24DAUD_DECODER 0 -+#define CONFIG_PCM_S24LE_DECODER 1 -+#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S32BE_DECODER 0 -+#define CONFIG_PCM_S32LE_DECODER 1 -+#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S64BE_DECODER 0 -+#define CONFIG_PCM_S64LE_DECODER 0 -+#define CONFIG_PCM_U8_DECODER 1 -+#define CONFIG_PCM_U16BE_DECODER 0 -+#define CONFIG_PCM_U16LE_DECODER 0 -+#define CONFIG_PCM_U24BE_DECODER 0 -+#define CONFIG_PCM_U24LE_DECODER 0 -+#define CONFIG_PCM_U32BE_DECODER 0 -+#define CONFIG_PCM_U32LE_DECODER 0 -+#define CONFIG_PCM_VIDC_DECODER 0 -+#define CONFIG_DERF_DPCM_DECODER 0 -+#define CONFIG_GREMLIN_DPCM_DECODER 0 -+#define CONFIG_INTERPLAY_DPCM_DECODER 0 -+#define CONFIG_ROQ_DPCM_DECODER 0 -+#define CONFIG_SDX2_DPCM_DECODER 0 -+#define CONFIG_SOL_DPCM_DECODER 0 -+#define CONFIG_XAN_DPCM_DECODER 0 -+#define CONFIG_ADPCM_4XM_DECODER 0 -+#define CONFIG_ADPCM_ADX_DECODER 0 -+#define CONFIG_ADPCM_AFC_DECODER 0 -+#define CONFIG_ADPCM_AGM_DECODER 0 -+#define CONFIG_ADPCM_AICA_DECODER 0 -+#define CONFIG_ADPCM_ARGO_DECODER 0 -+#define CONFIG_ADPCM_CT_DECODER 0 -+#define CONFIG_ADPCM_DTK_DECODER 0 -+#define CONFIG_ADPCM_EA_DECODER 0 -+#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 -+#define CONFIG_ADPCM_EA_R1_DECODER 0 -+#define CONFIG_ADPCM_EA_R2_DECODER 0 -+#define CONFIG_ADPCM_EA_R3_DECODER 0 -+#define CONFIG_ADPCM_EA_XAS_DECODER 0 -+#define CONFIG_ADPCM_G722_DECODER 0 -+#define CONFIG_ADPCM_G726_DECODER 0 -+#define CONFIG_ADPCM_G726LE_DECODER 0 -+#define CONFIG_ADPCM_IMA_AMV_DECODER 0 -+#define CONFIG_ADPCM_IMA_ALP_DECODER 0 -+#define CONFIG_ADPCM_IMA_APC_DECODER 0 -+#define CONFIG_ADPCM_IMA_APM_DECODER 0 -+#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 -+#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK3_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK4_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_ISS_DECODER 0 -+#define CONFIG_ADPCM_IMA_MTF_DECODER 0 -+#define CONFIG_ADPCM_IMA_OKI_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_DECODER 0 -+#define CONFIG_ADPCM_IMA_RAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_SSI_DECODER 0 -+#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 -+#define CONFIG_ADPCM_IMA_WAV_DECODER 0 -+#define CONFIG_ADPCM_IMA_WS_DECODER 0 -+#define CONFIG_ADPCM_MS_DECODER 0 -+#define CONFIG_ADPCM_MTAF_DECODER 0 -+#define CONFIG_ADPCM_PSX_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_2_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_3_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_4_DECODER 0 -+#define CONFIG_ADPCM_SWF_DECODER 0 -+#define CONFIG_ADPCM_THP_DECODER 0 -+#define CONFIG_ADPCM_THP_LE_DECODER 0 -+#define CONFIG_ADPCM_VIMA_DECODER 0 -+#define CONFIG_ADPCM_XA_DECODER 0 -+#define CONFIG_ADPCM_YAMAHA_DECODER 0 -+#define CONFIG_ADPCM_ZORK_DECODER 0 -+#define CONFIG_SSA_DECODER 0 -+#define CONFIG_ASS_DECODER 0 -+#define CONFIG_CCAPTION_DECODER 0 -+#define CONFIG_DVBSUB_DECODER 0 -+#define CONFIG_DVDSUB_DECODER 0 -+#define CONFIG_JACOSUB_DECODER 0 -+#define CONFIG_MICRODVD_DECODER 0 -+#define CONFIG_MOVTEXT_DECODER 0 -+#define CONFIG_MPL2_DECODER 0 -+#define CONFIG_PGSSUB_DECODER 0 -+#define CONFIG_PJS_DECODER 0 -+#define CONFIG_REALTEXT_DECODER 0 -+#define CONFIG_SAMI_DECODER 0 -+#define CONFIG_SRT_DECODER 0 -+#define CONFIG_STL_DECODER 0 -+#define CONFIG_SUBRIP_DECODER 0 -+#define CONFIG_SUBVIEWER_DECODER 0 -+#define CONFIG_SUBVIEWER1_DECODER 0 -+#define CONFIG_TEXT_DECODER 0 -+#define CONFIG_VPLAYER_DECODER 0 -+#define CONFIG_WEBVTT_DECODER 0 -+#define CONFIG_XSUB_DECODER 0 -+#define CONFIG_AAC_AT_DECODER 0 -+#define CONFIG_AC3_AT_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 -+#define CONFIG_ALAC_AT_DECODER 0 -+#define CONFIG_AMR_NB_AT_DECODER 0 -+#define CONFIG_EAC3_AT_DECODER 0 -+#define CONFIG_GSM_MS_AT_DECODER 0 -+#define CONFIG_ILBC_AT_DECODER 0 -+#define CONFIG_MP1_AT_DECODER 0 -+#define CONFIG_MP2_AT_DECODER 0 -+#define CONFIG_MP3_AT_DECODER 0 -+#define CONFIG_PCM_ALAW_AT_DECODER 0 -+#define CONFIG_PCM_MULAW_AT_DECODER 0 -+#define CONFIG_QDMC_AT_DECODER 0 -+#define CONFIG_QDM2_AT_DECODER 0 -+#define CONFIG_LIBARIBB24_DECODER 0 -+#define CONFIG_LIBCELT_DECODER 0 -+#define CONFIG_LIBCODEC2_DECODER 0 -+#define CONFIG_LIBDAV1D_DECODER 0 -+#define CONFIG_LIBDAVS2_DECODER 0 -+#define CONFIG_LIBFDK_AAC_DECODER 0 -+#define CONFIG_LIBGSM_DECODER 0 -+#define CONFIG_LIBGSM_MS_DECODER 0 -+#define CONFIG_LIBILBC_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 -+#define CONFIG_LIBOPENJPEG_DECODER 0 -+#define CONFIG_LIBOPUS_DECODER 1 -+#define CONFIG_LIBRSVG_DECODER 0 -+#define CONFIG_LIBSPEEX_DECODER 0 -+#define CONFIG_LIBVORBIS_DECODER 0 -+#define CONFIG_LIBVPX_VP8_DECODER 0 -+#define CONFIG_LIBVPX_VP9_DECODER 0 -+#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 -+#define CONFIG_BINTEXT_DECODER 0 -+#define CONFIG_XBIN_DECODER 0 -+#define CONFIG_IDF_DECODER 0 -+#define CONFIG_LIBAOM_AV1_DECODER 0 -+#define CONFIG_LIBOPENH264_DECODER 0 -+#define CONFIG_H264_CUVID_DECODER 0 -+#define CONFIG_HEVC_CUVID_DECODER 0 -+#define CONFIG_HEVC_MEDIACODEC_DECODER 0 -+#define CONFIG_MJPEG_CUVID_DECODER 0 -+#define CONFIG_MJPEG_QSV_DECODER 0 -+#define CONFIG_MPEG1_CUVID_DECODER 0 -+#define CONFIG_MPEG2_CUVID_DECODER 0 -+#define CONFIG_MPEG4_CUVID_DECODER 0 -+#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 -+#define CONFIG_VC1_CUVID_DECODER 0 -+#define CONFIG_VP8_CUVID_DECODER 0 -+#define CONFIG_VP8_MEDIACODEC_DECODER 0 -+#define CONFIG_VP8_QSV_DECODER 0 -+#define CONFIG_VP9_CUVID_DECODER 0 -+#define CONFIG_VP9_MEDIACODEC_DECODER 0 -+#define CONFIG_VP9_QSV_DECODER 0 -+#define CONFIG_A64MULTI_ENCODER 0 -+#define CONFIG_A64MULTI5_ENCODER 0 -+#define CONFIG_ALIAS_PIX_ENCODER 0 -+#define CONFIG_AMV_ENCODER 0 -+#define CONFIG_APNG_ENCODER 0 -+#define CONFIG_ASV1_ENCODER 0 -+#define CONFIG_ASV2_ENCODER 0 -+#define CONFIG_AVRP_ENCODER 0 -+#define CONFIG_AVUI_ENCODER 0 -+#define CONFIG_AYUV_ENCODER 0 -+#define CONFIG_BMP_ENCODER 0 -+#define CONFIG_CFHD_ENCODER 0 -+#define CONFIG_CINEPAK_ENCODER 0 -+#define CONFIG_CLJR_ENCODER 0 -+#define CONFIG_COMFORTNOISE_ENCODER 0 -+#define CONFIG_DNXHD_ENCODER 0 -+#define CONFIG_DPX_ENCODER 0 -+#define CONFIG_DVVIDEO_ENCODER 0 -+#define CONFIG_FFV1_ENCODER 0 -+#define CONFIG_FFVHUFF_ENCODER 0 -+#define CONFIG_FITS_ENCODER 0 -+#define CONFIG_FLASHSV_ENCODER 0 -+#define CONFIG_FLASHSV2_ENCODER 0 -+#define CONFIG_FLV_ENCODER 0 -+#define CONFIG_GIF_ENCODER 0 -+#define CONFIG_H261_ENCODER 0 -+#define CONFIG_H263_ENCODER 0 -+#define CONFIG_H263P_ENCODER 0 -+#define CONFIG_HAP_ENCODER 0 -+#define CONFIG_HUFFYUV_ENCODER 0 -+#define CONFIG_JPEG2000_ENCODER 0 -+#define CONFIG_JPEGLS_ENCODER 0 -+#define CONFIG_LJPEG_ENCODER 0 -+#define CONFIG_MAGICYUV_ENCODER 0 -+#define CONFIG_MJPEG_ENCODER 0 -+#define CONFIG_MPEG1VIDEO_ENCODER 0 -+#define CONFIG_MPEG2VIDEO_ENCODER 0 -+#define CONFIG_MPEG4_ENCODER 0 -+#define CONFIG_MSMPEG4V2_ENCODER 0 -+#define CONFIG_MSMPEG4V3_ENCODER 0 -+#define CONFIG_MSVIDEO1_ENCODER 0 -+#define CONFIG_PAM_ENCODER 0 -+#define CONFIG_PBM_ENCODER 0 -+#define CONFIG_PCX_ENCODER 0 -+#define CONFIG_PGM_ENCODER 0 -+#define CONFIG_PGMYUV_ENCODER 0 -+#define CONFIG_PNG_ENCODER 0 -+#define CONFIG_PPM_ENCODER 0 -+#define CONFIG_PRORES_ENCODER 0 -+#define CONFIG_PRORES_AW_ENCODER 0 -+#define CONFIG_PRORES_KS_ENCODER 0 -+#define CONFIG_QTRLE_ENCODER 0 -+#define CONFIG_R10K_ENCODER 0 -+#define CONFIG_R210_ENCODER 0 -+#define CONFIG_RAWVIDEO_ENCODER 0 -+#define CONFIG_ROQ_ENCODER 0 -+#define CONFIG_RPZA_ENCODER 0 -+#define CONFIG_RV10_ENCODER 0 -+#define CONFIG_RV20_ENCODER 0 -+#define CONFIG_S302M_ENCODER 0 -+#define CONFIG_SGI_ENCODER 0 -+#define CONFIG_SNOW_ENCODER 0 -+#define CONFIG_SUNRAST_ENCODER 0 -+#define CONFIG_SVQ1_ENCODER 0 -+#define CONFIG_TARGA_ENCODER 0 -+#define CONFIG_TIFF_ENCODER 0 -+#define CONFIG_UTVIDEO_ENCODER 0 -+#define CONFIG_V210_ENCODER 0 -+#define CONFIG_V308_ENCODER 0 -+#define CONFIG_V408_ENCODER 0 -+#define CONFIG_V410_ENCODER 0 -+#define CONFIG_VC2_ENCODER 0 -+#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 -+#define CONFIG_WMV1_ENCODER 0 -+#define CONFIG_WMV2_ENCODER 0 -+#define CONFIG_XBM_ENCODER 0 -+#define CONFIG_XFACE_ENCODER 0 -+#define CONFIG_XWD_ENCODER 0 -+#define CONFIG_Y41P_ENCODER 0 -+#define CONFIG_YUV4_ENCODER 0 -+#define CONFIG_ZLIB_ENCODER 0 -+#define CONFIG_ZMBV_ENCODER 0 -+#define CONFIG_AAC_ENCODER 0 -+#define CONFIG_AC3_ENCODER 0 -+#define CONFIG_AC3_FIXED_ENCODER 0 -+#define CONFIG_ALAC_ENCODER 0 -+#define CONFIG_APTX_ENCODER 0 -+#define CONFIG_APTX_HD_ENCODER 0 -+#define CONFIG_DCA_ENCODER 0 -+#define CONFIG_EAC3_ENCODER 0 -+#define CONFIG_FLAC_ENCODER 0 -+#define CONFIG_G723_1_ENCODER 0 -+#define CONFIG_MLP_ENCODER 0 -+#define CONFIG_MP2_ENCODER 0 -+#define CONFIG_MP2FIXED_ENCODER 0 -+#define CONFIG_NELLYMOSER_ENCODER 0 -+#define CONFIG_OPUS_ENCODER 0 -+#define CONFIG_RA_144_ENCODER 0 -+#define CONFIG_SBC_ENCODER 0 -+#define CONFIG_SONIC_ENCODER 0 -+#define CONFIG_SONIC_LS_ENCODER 0 -+#define CONFIG_TRUEHD_ENCODER 0 -+#define CONFIG_TTA_ENCODER 0 -+#define CONFIG_VORBIS_ENCODER 0 -+#define CONFIG_WAVPACK_ENCODER 0 -+#define CONFIG_WMAV1_ENCODER 0 -+#define CONFIG_WMAV2_ENCODER 0 -+#define CONFIG_PCM_ALAW_ENCODER 0 -+#define CONFIG_PCM_DVD_ENCODER 0 -+#define CONFIG_PCM_F32BE_ENCODER 0 -+#define CONFIG_PCM_F32LE_ENCODER 0 -+#define CONFIG_PCM_F64BE_ENCODER 0 -+#define CONFIG_PCM_F64LE_ENCODER 0 -+#define CONFIG_PCM_MULAW_ENCODER 0 -+#define CONFIG_PCM_S8_ENCODER 0 -+#define CONFIG_PCM_S8_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16BE_ENCODER 0 -+#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16LE_ENCODER 0 -+#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S24BE_ENCODER 0 -+#define CONFIG_PCM_S24DAUD_ENCODER 0 -+#define CONFIG_PCM_S24LE_ENCODER 0 -+#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S32BE_ENCODER 0 -+#define CONFIG_PCM_S32LE_ENCODER 0 -+#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S64BE_ENCODER 0 -+#define CONFIG_PCM_S64LE_ENCODER 0 -+#define CONFIG_PCM_U8_ENCODER 0 -+#define CONFIG_PCM_U16BE_ENCODER 0 -+#define CONFIG_PCM_U16LE_ENCODER 0 -+#define CONFIG_PCM_U24BE_ENCODER 0 -+#define CONFIG_PCM_U24LE_ENCODER 0 -+#define CONFIG_PCM_U32BE_ENCODER 0 -+#define CONFIG_PCM_U32LE_ENCODER 0 -+#define CONFIG_PCM_VIDC_ENCODER 0 -+#define CONFIG_ROQ_DPCM_ENCODER 0 -+#define CONFIG_ADPCM_ADX_ENCODER 0 -+#define CONFIG_ADPCM_ARGO_ENCODER 0 -+#define CONFIG_ADPCM_G722_ENCODER 0 -+#define CONFIG_ADPCM_G726_ENCODER 0 -+#define CONFIG_ADPCM_G726LE_ENCODER 0 -+#define CONFIG_ADPCM_IMA_APM_ENCODER 0 -+#define CONFIG_ADPCM_IMA_QT_ENCODER 0 -+#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 -+#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 -+#define CONFIG_ADPCM_MS_ENCODER 0 -+#define CONFIG_ADPCM_SWF_ENCODER 0 -+#define CONFIG_ADPCM_YAMAHA_ENCODER 0 -+#define CONFIG_SSA_ENCODER 0 -+#define CONFIG_ASS_ENCODER 0 -+#define CONFIG_DVBSUB_ENCODER 0 -+#define CONFIG_DVDSUB_ENCODER 0 -+#define CONFIG_MOVTEXT_ENCODER 0 -+#define CONFIG_SRT_ENCODER 0 -+#define CONFIG_SUBRIP_ENCODER 0 -+#define CONFIG_TEXT_ENCODER 0 -+#define CONFIG_WEBVTT_ENCODER 0 -+#define CONFIG_XSUB_ENCODER 0 -+#define CONFIG_AAC_AT_ENCODER 0 -+#define CONFIG_ALAC_AT_ENCODER 0 -+#define CONFIG_ILBC_AT_ENCODER 0 -+#define CONFIG_PCM_ALAW_AT_ENCODER 0 -+#define CONFIG_PCM_MULAW_AT_ENCODER 0 -+#define CONFIG_LIBAOM_AV1_ENCODER 0 -+#define CONFIG_LIBCODEC2_ENCODER 0 -+#define CONFIG_LIBFDK_AAC_ENCODER 0 -+#define CONFIG_LIBGSM_ENCODER 0 -+#define CONFIG_LIBGSM_MS_ENCODER 0 -+#define CONFIG_LIBILBC_ENCODER 0 -+#define CONFIG_LIBMP3LAME_ENCODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 -+#define CONFIG_LIBOPENJPEG_ENCODER 0 -+#define CONFIG_LIBOPUS_ENCODER 0 -+#define CONFIG_LIBRAV1E_ENCODER 0 -+#define CONFIG_LIBSHINE_ENCODER 0 -+#define CONFIG_LIBSPEEX_ENCODER 0 -+#define CONFIG_LIBSVTAV1_ENCODER 0 -+#define CONFIG_LIBTHEORA_ENCODER 0 -+#define CONFIG_LIBTWOLAME_ENCODER 0 -+#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 -+#define CONFIG_LIBVORBIS_ENCODER 0 -+#define CONFIG_LIBVPX_VP8_ENCODER 0 -+#define CONFIG_LIBVPX_VP9_ENCODER 0 -+#define CONFIG_LIBWAVPACK_ENCODER 0 -+#define CONFIG_LIBWEBP_ANIM_ENCODER 0 -+#define CONFIG_LIBWEBP_ENCODER 0 -+#define CONFIG_LIBX262_ENCODER 0 -+#define CONFIG_LIBX264_ENCODER 0 -+#define CONFIG_LIBX264RGB_ENCODER 0 -+#define CONFIG_LIBX265_ENCODER 0 -+#define CONFIG_LIBXAVS_ENCODER 0 -+#define CONFIG_LIBXAVS2_ENCODER 0 -+#define CONFIG_LIBXVID_ENCODER 0 -+#define CONFIG_AAC_MF_ENCODER 0 -+#define CONFIG_AC3_MF_ENCODER 0 -+#define CONFIG_H263_V4L2M2M_ENCODER 0 -+#define CONFIG_LIBOPENH264_ENCODER 0 -+#define CONFIG_H264_AMF_ENCODER 0 -+#define CONFIG_H264_MF_ENCODER 0 -+#define CONFIG_H264_NVENC_ENCODER 0 -+#define CONFIG_H264_OMX_ENCODER 0 -+#define CONFIG_H264_QSV_ENCODER 0 -+#define CONFIG_H264_V4L2M2M_ENCODER 0 -+#define CONFIG_H264_VAAPI_ENCODER 0 -+#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_NVENC_ENCODER 0 -+#define CONFIG_NVENC_H264_ENCODER 0 -+#define CONFIG_NVENC_HEVC_ENCODER 0 -+#define CONFIG_HEVC_AMF_ENCODER 0 -+#define CONFIG_HEVC_MF_ENCODER 0 -+#define CONFIG_HEVC_NVENC_ENCODER 0 -+#define CONFIG_HEVC_QSV_ENCODER 0 -+#define CONFIG_HEVC_V4L2M2M_ENCODER 0 -+#define CONFIG_HEVC_VAAPI_ENCODER 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_LIBKVAZAAR_ENCODER 0 -+#define CONFIG_MJPEG_QSV_ENCODER 0 -+#define CONFIG_MJPEG_VAAPI_ENCODER 0 -+#define CONFIG_MP3_MF_ENCODER 0 -+#define CONFIG_MPEG2_QSV_ENCODER 0 -+#define CONFIG_MPEG2_VAAPI_ENCODER 0 -+#define CONFIG_MPEG4_OMX_ENCODER 0 -+#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_VAAPI_ENCODER 0 -+#define CONFIG_VP9_VAAPI_ENCODER 0 -+#define CONFIG_VP9_QSV_ENCODER 0 -+#define CONFIG_H263_VAAPI_HWACCEL 0 -+#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_H264_D3D11VA_HWACCEL 0 -+#define CONFIG_H264_D3D11VA2_HWACCEL 0 -+#define CONFIG_H264_DXVA2_HWACCEL 0 -+#define CONFIG_H264_NVDEC_HWACCEL 0 -+#define CONFIG_H264_VAAPI_HWACCEL 0 -+#define CONFIG_H264_VDPAU_HWACCEL 0 -+#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 -+#define CONFIG_HEVC_DXVA2_HWACCEL 0 -+#define CONFIG_HEVC_NVDEC_HWACCEL 0 -+#define CONFIG_HEVC_VAAPI_HWACCEL 0 -+#define CONFIG_HEVC_VDPAU_HWACCEL 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MJPEG_NVDEC_HWACCEL 0 -+#define CONFIG_MJPEG_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG1_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG1_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG1_XVMC_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 -+#define CONFIG_MPEG2_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG2_DXVA2_HWACCEL 0 -+#define CONFIG_MPEG2_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG2_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG2_XVMC_HWACCEL 0 -+#define CONFIG_MPEG4_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG4_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG4_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA2_HWACCEL 0 -+#define CONFIG_VC1_DXVA2_HWACCEL 0 -+#define CONFIG_VC1_NVDEC_HWACCEL 0 -+#define CONFIG_VC1_VAAPI_HWACCEL 0 -+#define CONFIG_VC1_VDPAU_HWACCEL 0 -+#define CONFIG_VP8_NVDEC_HWACCEL 0 -+#define CONFIG_VP8_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA2_HWACCEL 0 -+#define CONFIG_VP9_DXVA2_HWACCEL 0 -+#define CONFIG_VP9_NVDEC_HWACCEL 0 -+#define CONFIG_VP9_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_VDPAU_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 -+#define CONFIG_WMV3_DXVA2_HWACCEL 0 -+#define CONFIG_WMV3_NVDEC_HWACCEL 0 -+#define CONFIG_WMV3_VAAPI_HWACCEL 0 -+#define CONFIG_WMV3_VDPAU_HWACCEL 0 -+#define CONFIG_AAC_PARSER 1 -+#define CONFIG_AAC_LATM_PARSER 0 -+#define CONFIG_AC3_PARSER 0 -+#define CONFIG_ADX_PARSER 0 -+#define CONFIG_AV1_PARSER 0 -+#define CONFIG_AVS2_PARSER 0 -+#define CONFIG_BMP_PARSER 0 -+#define CONFIG_CAVSVIDEO_PARSER 0 -+#define CONFIG_COOK_PARSER 0 -+#define CONFIG_DCA_PARSER 0 -+#define CONFIG_DIRAC_PARSER 0 -+#define CONFIG_DNXHD_PARSER 0 -+#define CONFIG_DPX_PARSER 0 -+#define CONFIG_DVAUDIO_PARSER 0 -+#define CONFIG_DVBSUB_PARSER 0 -+#define CONFIG_DVDSUB_PARSER 0 -+#define CONFIG_DVD_NAV_PARSER 0 -+#define CONFIG_FLAC_PARSER 1 -+#define CONFIG_G723_1_PARSER 0 -+#define CONFIG_G729_PARSER 0 -+#define CONFIG_GIF_PARSER 0 -+#define CONFIG_GSM_PARSER 1 -+#define CONFIG_H261_PARSER 0 -+#define CONFIG_H263_PARSER 1 -+#define CONFIG_H264_PARSER 1 -+#define CONFIG_HEVC_PARSER 0 -+#define CONFIG_JPEG2000_PARSER 0 -+#define CONFIG_MJPEG_PARSER 0 -+#define CONFIG_MLP_PARSER 0 -+#define CONFIG_MPEG4VIDEO_PARSER 1 -+#define CONFIG_MPEGAUDIO_PARSER 1 -+#define CONFIG_MPEGVIDEO_PARSER 0 -+#define CONFIG_OPUS_PARSER 1 -+#define CONFIG_PNG_PARSER 0 -+#define CONFIG_PNM_PARSER 0 -+#define CONFIG_RV30_PARSER 0 -+#define CONFIG_RV40_PARSER 0 -+#define CONFIG_SBC_PARSER 0 -+#define CONFIG_SIPR_PARSER 0 -+#define CONFIG_TAK_PARSER 0 -+#define CONFIG_VC1_PARSER 0 -+#define CONFIG_VORBIS_PARSER 1 -+#define CONFIG_VP3_PARSER 1 -+#define CONFIG_VP8_PARSER 1 -+#define CONFIG_VP9_PARSER 1 -+#define CONFIG_WEBP_PARSER 0 -+#define CONFIG_XMA_PARSER 0 -+#define CONFIG_ALSA_INDEV 0 -+#define CONFIG_ANDROID_CAMERA_INDEV 0 -+#define CONFIG_AVFOUNDATION_INDEV 0 -+#define CONFIG_BKTR_INDEV 0 -+#define CONFIG_DECKLINK_INDEV 0 -+#define CONFIG_DSHOW_INDEV 0 -+#define CONFIG_FBDEV_INDEV 0 -+#define CONFIG_GDIGRAB_INDEV 0 -+#define CONFIG_IEC61883_INDEV 0 -+#define CONFIG_JACK_INDEV 0 -+#define CONFIG_KMSGRAB_INDEV 0 -+#define CONFIG_LAVFI_INDEV 0 -+#define CONFIG_OPENAL_INDEV 0 -+#define CONFIG_OSS_INDEV 0 -+#define CONFIG_PULSE_INDEV 0 -+#define CONFIG_SNDIO_INDEV 0 -+#define CONFIG_V4L2_INDEV 0 -+#define CONFIG_VFWCAP_INDEV 0 -+#define CONFIG_XCBGRAB_INDEV 0 -+#define CONFIG_LIBCDIO_INDEV 0 -+#define CONFIG_LIBDC1394_INDEV 0 -+#define CONFIG_ALSA_OUTDEV 0 -+#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 -+#define CONFIG_CACA_OUTDEV 0 -+#define CONFIG_DECKLINK_OUTDEV 0 -+#define CONFIG_FBDEV_OUTDEV 0 -+#define CONFIG_OPENGL_OUTDEV 0 -+#define CONFIG_OSS_OUTDEV 0 -+#define CONFIG_PULSE_OUTDEV 0 -+#define CONFIG_SDL2_OUTDEV 0 -+#define CONFIG_SNDIO_OUTDEV 0 -+#define CONFIG_V4L2_OUTDEV 0 -+#define CONFIG_XV_OUTDEV 0 -+#define CONFIG_ABENCH_FILTER 0 -+#define CONFIG_ACOMPRESSOR_FILTER 0 -+#define CONFIG_ACONTRAST_FILTER 0 -+#define CONFIG_ACOPY_FILTER 0 -+#define CONFIG_ACUE_FILTER 0 -+#define CONFIG_ACROSSFADE_FILTER 0 -+#define CONFIG_ACROSSOVER_FILTER 0 -+#define CONFIG_ACRUSHER_FILTER 0 -+#define CONFIG_ADECLICK_FILTER 0 -+#define CONFIG_ADECLIP_FILTER 0 -+#define CONFIG_ADELAY_FILTER 0 -+#define CONFIG_ADERIVATIVE_FILTER 0 -+#define CONFIG_AECHO_FILTER 0 -+#define CONFIG_AEMPHASIS_FILTER 0 -+#define CONFIG_AEVAL_FILTER 0 -+#define CONFIG_AFADE_FILTER 0 -+#define CONFIG_AFFTDN_FILTER 0 -+#define CONFIG_AFFTFILT_FILTER 0 -+#define CONFIG_AFIR_FILTER 0 -+#define CONFIG_AFORMAT_FILTER 0 -+#define CONFIG_AGATE_FILTER 0 -+#define CONFIG_AIIR_FILTER 0 -+#define CONFIG_AINTEGRAL_FILTER 0 -+#define CONFIG_AINTERLEAVE_FILTER 0 -+#define CONFIG_ALIMITER_FILTER 0 -+#define CONFIG_ALLPASS_FILTER 0 -+#define CONFIG_ALOOP_FILTER 0 -+#define CONFIG_AMERGE_FILTER 0 -+#define CONFIG_AMETADATA_FILTER 0 -+#define CONFIG_AMIX_FILTER 0 -+#define CONFIG_AMULTIPLY_FILTER 0 -+#define CONFIG_ANEQUALIZER_FILTER 0 -+#define CONFIG_ANLMDN_FILTER 0 -+#define CONFIG_ANLMS_FILTER 0 -+#define CONFIG_ANULL_FILTER 0 -+#define CONFIG_APAD_FILTER 0 -+#define CONFIG_APERMS_FILTER 0 -+#define CONFIG_APHASER_FILTER 0 -+#define CONFIG_APULSATOR_FILTER 0 -+#define CONFIG_AREALTIME_FILTER 0 -+#define CONFIG_ARESAMPLE_FILTER 0 -+#define CONFIG_AREVERSE_FILTER 0 -+#define CONFIG_ARNNDN_FILTER 0 -+#define CONFIG_ASELECT_FILTER 0 -+#define CONFIG_ASENDCMD_FILTER 0 -+#define CONFIG_ASETNSAMPLES_FILTER 0 -+#define CONFIG_ASETPTS_FILTER 0 -+#define CONFIG_ASETRATE_FILTER 0 -+#define CONFIG_ASETTB_FILTER 0 -+#define CONFIG_ASHOWINFO_FILTER 0 -+#define CONFIG_ASIDEDATA_FILTER 0 -+#define CONFIG_ASOFTCLIP_FILTER 0 -+#define CONFIG_ASPLIT_FILTER 0 -+#define CONFIG_ASR_FILTER 0 -+#define CONFIG_ASTATS_FILTER 0 -+#define CONFIG_ASTREAMSELECT_FILTER 0 -+#define CONFIG_ASUBBOOST_FILTER 0 -+#define CONFIG_ATEMPO_FILTER 0 -+#define CONFIG_ATRIM_FILTER 0 -+#define CONFIG_AXCORRELATE_FILTER 0 -+#define CONFIG_AZMQ_FILTER 0 -+#define CONFIG_BANDPASS_FILTER 0 -+#define CONFIG_BANDREJECT_FILTER 0 -+#define CONFIG_BASS_FILTER 0 -+#define CONFIG_BIQUAD_FILTER 0 -+#define CONFIG_BS2B_FILTER 0 -+#define CONFIG_CHROMABER_VULKAN_FILTER 0 -+#define CONFIG_CHANNELMAP_FILTER 0 -+#define CONFIG_CHANNELSPLIT_FILTER 0 -+#define CONFIG_CHORUS_FILTER 0 -+#define CONFIG_COMPAND_FILTER 0 -+#define CONFIG_COMPENSATIONDELAY_FILTER 0 -+#define CONFIG_CROSSFEED_FILTER 0 -+#define CONFIG_CRYSTALIZER_FILTER 0 -+#define CONFIG_DCSHIFT_FILTER 0 -+#define CONFIG_DEESSER_FILTER 0 -+#define CONFIG_DRMETER_FILTER 0 -+#define CONFIG_DYNAUDNORM_FILTER 0 -+#define CONFIG_EARWAX_FILTER 0 -+#define CONFIG_EBUR128_FILTER 0 -+#define CONFIG_EQUALIZER_FILTER 0 -+#define CONFIG_EXTRASTEREO_FILTER 0 -+#define CONFIG_FIREQUALIZER_FILTER 0 -+#define CONFIG_FLANGER_FILTER 0 -+#define CONFIG_HAAS_FILTER 0 -+#define CONFIG_HDCD_FILTER 0 -+#define CONFIG_HEADPHONE_FILTER 0 -+#define CONFIG_HIGHPASS_FILTER 0 -+#define CONFIG_HIGHSHELF_FILTER 0 -+#define CONFIG_JOIN_FILTER 0 -+#define CONFIG_LADSPA_FILTER 0 -+#define CONFIG_LOUDNORM_FILTER 0 -+#define CONFIG_LOWPASS_FILTER 0 -+#define CONFIG_LOWSHELF_FILTER 0 -+#define CONFIG_LV2_FILTER 0 -+#define CONFIG_MCOMPAND_FILTER 0 -+#define CONFIG_PAN_FILTER 0 -+#define CONFIG_REPLAYGAIN_FILTER 0 -+#define CONFIG_RESAMPLE_FILTER 0 -+#define CONFIG_RUBBERBAND_FILTER 0 -+#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 -+#define CONFIG_SIDECHAINGATE_FILTER 0 -+#define CONFIG_SILENCEDETECT_FILTER 0 -+#define CONFIG_SILENCEREMOVE_FILTER 0 -+#define CONFIG_SOFALIZER_FILTER 0 -+#define CONFIG_STEREOTOOLS_FILTER 0 -+#define CONFIG_STEREOWIDEN_FILTER 0 -+#define CONFIG_SUPEREQUALIZER_FILTER 0 -+#define CONFIG_SURROUND_FILTER 0 -+#define CONFIG_TREBLE_FILTER 0 -+#define CONFIG_TREMOLO_FILTER 0 -+#define CONFIG_VIBRATO_FILTER 0 -+#define CONFIG_VOLUME_FILTER 0 -+#define CONFIG_VOLUMEDETECT_FILTER 0 -+#define CONFIG_AEVALSRC_FILTER 0 -+#define CONFIG_AFIRSRC_FILTER 0 -+#define CONFIG_ANOISESRC_FILTER 0 -+#define CONFIG_ANULLSRC_FILTER 0 -+#define CONFIG_FLITE_FILTER 0 -+#define CONFIG_HILBERT_FILTER 0 -+#define CONFIG_SINC_FILTER 0 -+#define CONFIG_SINE_FILTER 0 -+#define CONFIG_ANULLSINK_FILTER 0 -+#define CONFIG_ADDROI_FILTER 0 -+#define CONFIG_ALPHAEXTRACT_FILTER 0 -+#define CONFIG_ALPHAMERGE_FILTER 0 -+#define CONFIG_AMPLIFY_FILTER 0 -+#define CONFIG_ASS_FILTER 0 -+#define CONFIG_ATADENOISE_FILTER 0 -+#define CONFIG_AVGBLUR_FILTER 0 -+#define CONFIG_AVGBLUR_OPENCL_FILTER 0 -+#define CONFIG_AVGBLUR_VULKAN_FILTER 0 -+#define CONFIG_BBOX_FILTER 0 -+#define CONFIG_BENCH_FILTER 0 -+#define CONFIG_BILATERAL_FILTER 0 -+#define CONFIG_BITPLANENOISE_FILTER 0 -+#define CONFIG_BLACKDETECT_FILTER 0 -+#define CONFIG_BLACKFRAME_FILTER 0 -+#define CONFIG_BLEND_FILTER 0 -+#define CONFIG_BM3D_FILTER 0 -+#define CONFIG_BOXBLUR_FILTER 0 -+#define CONFIG_BOXBLUR_OPENCL_FILTER 0 -+#define CONFIG_BWDIF_FILTER 0 -+#define CONFIG_CAS_FILTER 0 -+#define CONFIG_CHROMAHOLD_FILTER 0 -+#define CONFIG_CHROMAKEY_FILTER 0 -+#define CONFIG_CHROMANR_FILTER 0 -+#define CONFIG_CHROMASHIFT_FILTER 0 -+#define CONFIG_CIESCOPE_FILTER 0 -+#define CONFIG_CODECVIEW_FILTER 0 -+#define CONFIG_COLORBALANCE_FILTER 0 -+#define CONFIG_COLORCHANNELMIXER_FILTER 0 -+#define CONFIG_COLORKEY_FILTER 0 -+#define CONFIG_COLORKEY_OPENCL_FILTER 0 -+#define CONFIG_COLORHOLD_FILTER 0 -+#define CONFIG_COLORLEVELS_FILTER 0 -+#define CONFIG_COLORMATRIX_FILTER 0 -+#define CONFIG_COLORSPACE_FILTER 0 -+#define CONFIG_CONVOLUTION_FILTER 0 -+#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 -+#define CONFIG_CONVOLVE_FILTER 0 -+#define CONFIG_COPY_FILTER 0 -+#define CONFIG_COREIMAGE_FILTER 0 -+#define CONFIG_COVER_RECT_FILTER 0 -+#define CONFIG_CROP_FILTER 0 -+#define CONFIG_CROPDETECT_FILTER 0 -+#define CONFIG_CUE_FILTER 0 -+#define CONFIG_CURVES_FILTER 0 -+#define CONFIG_DATASCOPE_FILTER 0 -+#define CONFIG_DBLUR_FILTER 0 -+#define CONFIG_DCTDNOIZ_FILTER 0 -+#define CONFIG_DEBAND_FILTER 0 -+#define CONFIG_DEBLOCK_FILTER 0 -+#define CONFIG_DECIMATE_FILTER 0 -+#define CONFIG_DECONVOLVE_FILTER 0 -+#define CONFIG_DEDOT_FILTER 0 -+#define CONFIG_DEFLATE_FILTER 0 -+#define CONFIG_DEFLICKER_FILTER 0 -+#define CONFIG_DEINTERLACE_QSV_FILTER 0 -+#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 -+#define CONFIG_DEJUDDER_FILTER 0 -+#define CONFIG_DELOGO_FILTER 0 -+#define CONFIG_DENOISE_VAAPI_FILTER 0 -+#define CONFIG_DERAIN_FILTER 0 -+#define CONFIG_DESHAKE_FILTER 0 -+#define CONFIG_DESHAKE_OPENCL_FILTER 0 -+#define CONFIG_DESPILL_FILTER 0 -+#define CONFIG_DETELECINE_FILTER 0 -+#define CONFIG_DILATION_FILTER 0 -+#define CONFIG_DILATION_OPENCL_FILTER 0 -+#define CONFIG_DISPLACE_FILTER 0 -+#define CONFIG_DNN_PROCESSING_FILTER 0 -+#define CONFIG_DOUBLEWEAVE_FILTER 0 -+#define CONFIG_DRAWBOX_FILTER 0 -+#define CONFIG_DRAWGRAPH_FILTER 0 -+#define CONFIG_DRAWGRID_FILTER 0 -+#define CONFIG_DRAWTEXT_FILTER 0 -+#define CONFIG_EDGEDETECT_FILTER 0 -+#define CONFIG_ELBG_FILTER 0 -+#define CONFIG_ENTROPY_FILTER 0 -+#define CONFIG_EQ_FILTER 0 -+#define CONFIG_EROSION_FILTER 0 -+#define CONFIG_EROSION_OPENCL_FILTER 0 -+#define CONFIG_EXTRACTPLANES_FILTER 0 -+#define CONFIG_FADE_FILTER 0 -+#define CONFIG_FFTDNOIZ_FILTER 0 -+#define CONFIG_FFTFILT_FILTER 0 -+#define CONFIG_FIELD_FILTER 0 -+#define CONFIG_FIELDHINT_FILTER 0 -+#define CONFIG_FIELDMATCH_FILTER 0 -+#define CONFIG_FIELDORDER_FILTER 0 -+#define CONFIG_FILLBORDERS_FILTER 0 -+#define CONFIG_FIND_RECT_FILTER 0 -+#define CONFIG_FLOODFILL_FILTER 0 -+#define CONFIG_FORMAT_FILTER 0 -+#define CONFIG_FPS_FILTER 0 -+#define CONFIG_FRAMEPACK_FILTER 0 -+#define CONFIG_FRAMERATE_FILTER 0 -+#define CONFIG_FRAMESTEP_FILTER 0 -+#define CONFIG_FREEZEDETECT_FILTER 0 -+#define CONFIG_FREEZEFRAMES_FILTER 0 -+#define CONFIG_FREI0R_FILTER 0 -+#define CONFIG_FSPP_FILTER 0 -+#define CONFIG_GBLUR_FILTER 0 -+#define CONFIG_GEQ_FILTER 0 -+#define CONFIG_GRADFUN_FILTER 0 -+#define CONFIG_GRAPHMONITOR_FILTER 0 -+#define CONFIG_GREYEDGE_FILTER 0 -+#define CONFIG_HALDCLUT_FILTER 0 -+#define CONFIG_HFLIP_FILTER 0 -+#define CONFIG_HISTEQ_FILTER 0 -+#define CONFIG_HISTOGRAM_FILTER 0 -+#define CONFIG_HQDN3D_FILTER 0 -+#define CONFIG_HQX_FILTER 0 -+#define CONFIG_HSTACK_FILTER 0 -+#define CONFIG_HUE_FILTER 0 -+#define CONFIG_HWDOWNLOAD_FILTER 0 -+#define CONFIG_HWMAP_FILTER 0 -+#define CONFIG_HWUPLOAD_FILTER 0 -+#define CONFIG_HWUPLOAD_CUDA_FILTER 0 -+#define CONFIG_HYSTERESIS_FILTER 0 -+#define CONFIG_IDET_FILTER 0 -+#define CONFIG_IL_FILTER 0 -+#define CONFIG_INFLATE_FILTER 0 -+#define CONFIG_INTERLACE_FILTER 0 -+#define CONFIG_INTERLEAVE_FILTER 0 -+#define CONFIG_KERNDEINT_FILTER 0 -+#define CONFIG_LAGFUN_FILTER 0 -+#define CONFIG_LENSCORRECTION_FILTER 0 -+#define CONFIG_LENSFUN_FILTER 0 -+#define CONFIG_LIBVMAF_FILTER 0 -+#define CONFIG_LIMITER_FILTER 0 -+#define CONFIG_LOOP_FILTER 0 -+#define CONFIG_LUMAKEY_FILTER 0 -+#define CONFIG_LUT_FILTER 0 -+#define CONFIG_LUT1D_FILTER 0 -+#define CONFIG_LUT2_FILTER 0 -+#define CONFIG_LUT3D_FILTER 0 -+#define CONFIG_LUTRGB_FILTER 0 -+#define CONFIG_LUTYUV_FILTER 0 -+#define CONFIG_MASKEDCLAMP_FILTER 0 -+#define CONFIG_MASKEDMAX_FILTER 0 -+#define CONFIG_MASKEDMERGE_FILTER 0 -+#define CONFIG_MASKEDMIN_FILTER 0 -+#define CONFIG_MASKEDTHRESHOLD_FILTER 0 -+#define CONFIG_MASKFUN_FILTER 0 -+#define CONFIG_MCDEINT_FILTER 0 -+#define CONFIG_MEDIAN_FILTER 0 -+#define CONFIG_MERGEPLANES_FILTER 0 -+#define CONFIG_MESTIMATE_FILTER 0 -+#define CONFIG_METADATA_FILTER 0 -+#define CONFIG_MIDEQUALIZER_FILTER 0 -+#define CONFIG_MINTERPOLATE_FILTER 0 -+#define CONFIG_MIX_FILTER 0 -+#define CONFIG_MPDECIMATE_FILTER 0 -+#define CONFIG_NEGATE_FILTER 0 -+#define CONFIG_NLMEANS_FILTER 0 -+#define CONFIG_NLMEANS_OPENCL_FILTER 0 -+#define CONFIG_NNEDI_FILTER 0 -+#define CONFIG_NOFORMAT_FILTER 0 -+#define CONFIG_NOISE_FILTER 0 -+#define CONFIG_NORMALIZE_FILTER 0 -+#define CONFIG_NULL_FILTER 0 -+#define CONFIG_OCR_FILTER 0 -+#define CONFIG_OCV_FILTER 0 -+#define CONFIG_OSCILLOSCOPE_FILTER 0 -+#define CONFIG_OVERLAY_FILTER 0 -+#define CONFIG_OVERLAY_OPENCL_FILTER 0 -+#define CONFIG_OVERLAY_QSV_FILTER 0 -+#define CONFIG_OVERLAY_VULKAN_FILTER 0 -+#define CONFIG_OVERLAY_CUDA_FILTER 0 -+#define CONFIG_OWDENOISE_FILTER 0 -+#define CONFIG_PAD_FILTER 0 -+#define CONFIG_PAD_OPENCL_FILTER 0 -+#define CONFIG_PALETTEGEN_FILTER 0 -+#define CONFIG_PALETTEUSE_FILTER 0 -+#define CONFIG_PERMS_FILTER 0 -+#define CONFIG_PERSPECTIVE_FILTER 0 -+#define CONFIG_PHASE_FILTER 0 -+#define CONFIG_PHOTOSENSITIVITY_FILTER 0 -+#define CONFIG_PIXDESCTEST_FILTER 0 -+#define CONFIG_PIXSCOPE_FILTER 0 -+#define CONFIG_PP_FILTER 0 -+#define CONFIG_PP7_FILTER 0 -+#define CONFIG_PREMULTIPLY_FILTER 0 -+#define CONFIG_PREWITT_FILTER 0 -+#define CONFIG_PREWITT_OPENCL_FILTER 0 -+#define CONFIG_PROCAMP_VAAPI_FILTER 0 -+#define CONFIG_PROGRAM_OPENCL_FILTER 0 -+#define CONFIG_PSEUDOCOLOR_FILTER 0 -+#define CONFIG_PSNR_FILTER 0 -+#define CONFIG_PULLUP_FILTER 0 -+#define CONFIG_QP_FILTER 0 -+#define CONFIG_RANDOM_FILTER 0 -+#define CONFIG_READEIA608_FILTER 0 -+#define CONFIG_READVITC_FILTER 0 -+#define CONFIG_REALTIME_FILTER 0 -+#define CONFIG_REMAP_FILTER 0 -+#define CONFIG_REMOVEGRAIN_FILTER 0 -+#define CONFIG_REMOVELOGO_FILTER 0 -+#define CONFIG_REPEATFIELDS_FILTER 0 -+#define CONFIG_REVERSE_FILTER 0 -+#define CONFIG_RGBASHIFT_FILTER 0 -+#define CONFIG_ROBERTS_FILTER 0 -+#define CONFIG_ROBERTS_OPENCL_FILTER 0 -+#define CONFIG_ROTATE_FILTER 0 -+#define CONFIG_SAB_FILTER 0 -+#define CONFIG_SCALE_FILTER 0 -+#define CONFIG_SCALE_CUDA_FILTER 0 -+#define CONFIG_SCALE_NPP_FILTER 0 -+#define CONFIG_SCALE_QSV_FILTER 0 -+#define CONFIG_SCALE_VAAPI_FILTER 0 -+#define CONFIG_SCALE_VULKAN_FILTER 0 -+#define CONFIG_SCALE2REF_FILTER 0 -+#define CONFIG_SCDET_FILTER 0 -+#define CONFIG_SCROLL_FILTER 0 -+#define CONFIG_SELECT_FILTER 0 -+#define CONFIG_SELECTIVECOLOR_FILTER 0 -+#define CONFIG_SENDCMD_FILTER 0 -+#define CONFIG_SEPARATEFIELDS_FILTER 0 -+#define CONFIG_SETDAR_FILTER 0 -+#define CONFIG_SETFIELD_FILTER 0 -+#define CONFIG_SETPARAMS_FILTER 0 -+#define CONFIG_SETPTS_FILTER 0 -+#define CONFIG_SETRANGE_FILTER 0 -+#define CONFIG_SETSAR_FILTER 0 -+#define CONFIG_SETTB_FILTER 0 -+#define CONFIG_SHARPNESS_VAAPI_FILTER 0 -+#define CONFIG_SHOWINFO_FILTER 0 -+#define CONFIG_SHOWPALETTE_FILTER 0 -+#define CONFIG_SHUFFLEFRAMES_FILTER 0 -+#define CONFIG_SHUFFLEPLANES_FILTER 0 -+#define CONFIG_SIDEDATA_FILTER 0 -+#define CONFIG_SIGNALSTATS_FILTER 0 -+#define CONFIG_SIGNATURE_FILTER 0 -+#define CONFIG_SMARTBLUR_FILTER 0 -+#define CONFIG_SOBEL_FILTER 0 -+#define CONFIG_SOBEL_OPENCL_FILTER 0 -+#define CONFIG_SPLIT_FILTER 0 -+#define CONFIG_SPP_FILTER 0 -+#define CONFIG_SR_FILTER 0 -+#define CONFIG_SSIM_FILTER 0 -+#define CONFIG_STEREO3D_FILTER 0 -+#define CONFIG_STREAMSELECT_FILTER 0 -+#define CONFIG_SUBTITLES_FILTER 0 -+#define CONFIG_SUPER2XSAI_FILTER 0 -+#define CONFIG_SWAPRECT_FILTER 0 -+#define CONFIG_SWAPUV_FILTER 0 -+#define CONFIG_TBLEND_FILTER 0 -+#define CONFIG_TELECINE_FILTER 0 -+#define CONFIG_THISTOGRAM_FILTER 0 -+#define CONFIG_THRESHOLD_FILTER 0 -+#define CONFIG_THUMBNAIL_FILTER 0 -+#define CONFIG_THUMBNAIL_CUDA_FILTER 0 -+#define CONFIG_TILE_FILTER 0 -+#define CONFIG_TINTERLACE_FILTER 0 -+#define CONFIG_TLUT2_FILTER 0 -+#define CONFIG_TMEDIAN_FILTER 0 -+#define CONFIG_TMIX_FILTER 0 -+#define CONFIG_TONEMAP_FILTER 0 -+#define CONFIG_TONEMAP_OPENCL_FILTER 0 -+#define CONFIG_TONEMAP_VAAPI_FILTER 0 -+#define CONFIG_TPAD_FILTER 0 -+#define CONFIG_TRANSPOSE_FILTER 0 -+#define CONFIG_TRANSPOSE_NPP_FILTER 0 -+#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 -+#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 -+#define CONFIG_TRIM_FILTER 0 -+#define CONFIG_UNPREMULTIPLY_FILTER 0 -+#define CONFIG_UNSHARP_FILTER 0 -+#define CONFIG_UNSHARP_OPENCL_FILTER 0 -+#define CONFIG_UNTILE_FILTER 0 -+#define CONFIG_USPP_FILTER 0 -+#define CONFIG_V360_FILTER 0 -+#define CONFIG_VAGUEDENOISER_FILTER 0 -+#define CONFIG_VECTORSCOPE_FILTER 0 -+#define CONFIG_VFLIP_FILTER 0 -+#define CONFIG_VFRDET_FILTER 0 -+#define CONFIG_VIBRANCE_FILTER 0 -+#define CONFIG_VIDSTABDETECT_FILTER 0 -+#define CONFIG_VIDSTABTRANSFORM_FILTER 0 -+#define CONFIG_VIGNETTE_FILTER 0 -+#define CONFIG_VMAFMOTION_FILTER 0 -+#define CONFIG_VPP_QSV_FILTER 0 -+#define CONFIG_VSTACK_FILTER 0 -+#define CONFIG_W3FDIF_FILTER 0 -+#define CONFIG_WAVEFORM_FILTER 0 -+#define CONFIG_WEAVE_FILTER 0 -+#define CONFIG_XBR_FILTER 0 -+#define CONFIG_XFADE_FILTER 0 -+#define CONFIG_XFADE_OPENCL_FILTER 0 -+#define CONFIG_XMEDIAN_FILTER 0 -+#define CONFIG_XSTACK_FILTER 0 -+#define CONFIG_YADIF_FILTER 0 -+#define CONFIG_YADIF_CUDA_FILTER 0 -+#define CONFIG_YAEPBLUR_FILTER 0 -+#define CONFIG_ZMQ_FILTER 0 -+#define CONFIG_ZOOMPAN_FILTER 0 -+#define CONFIG_ZSCALE_FILTER 0 -+#define CONFIG_ALLRGB_FILTER 0 -+#define CONFIG_ALLYUV_FILTER 0 -+#define CONFIG_CELLAUTO_FILTER 0 -+#define CONFIG_COLOR_FILTER 0 -+#define CONFIG_COREIMAGESRC_FILTER 0 -+#define CONFIG_FREI0R_SRC_FILTER 0 -+#define CONFIG_GRADIENTS_FILTER 0 -+#define CONFIG_HALDCLUTSRC_FILTER 0 -+#define CONFIG_LIFE_FILTER 0 -+#define CONFIG_MANDELBROT_FILTER 0 -+#define CONFIG_MPTESTSRC_FILTER 0 -+#define CONFIG_NULLSRC_FILTER 0 -+#define CONFIG_OPENCLSRC_FILTER 0 -+#define CONFIG_PAL75BARS_FILTER 0 -+#define CONFIG_PAL100BARS_FILTER 0 -+#define CONFIG_RGBTESTSRC_FILTER 0 -+#define CONFIG_SIERPINSKI_FILTER 0 -+#define CONFIG_SMPTEBARS_FILTER 0 -+#define CONFIG_SMPTEHDBARS_FILTER 0 -+#define CONFIG_TESTSRC_FILTER 0 -+#define CONFIG_TESTSRC2_FILTER 0 -+#define CONFIG_YUVTESTSRC_FILTER 0 -+#define CONFIG_NULLSINK_FILTER 0 -+#define CONFIG_ABITSCOPE_FILTER 0 -+#define CONFIG_ADRAWGRAPH_FILTER 0 -+#define CONFIG_AGRAPHMONITOR_FILTER 0 -+#define CONFIG_AHISTOGRAM_FILTER 0 -+#define CONFIG_APHASEMETER_FILTER 0 -+#define CONFIG_AVECTORSCOPE_FILTER 0 -+#define CONFIG_CONCAT_FILTER 0 -+#define CONFIG_SHOWCQT_FILTER 0 -+#define CONFIG_SHOWFREQS_FILTER 0 -+#define CONFIG_SHOWSPATIAL_FILTER 0 -+#define CONFIG_SHOWSPECTRUM_FILTER 0 -+#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 -+#define CONFIG_SHOWVOLUME_FILTER 0 -+#define CONFIG_SHOWWAVES_FILTER 0 -+#define CONFIG_SHOWWAVESPIC_FILTER 0 -+#define CONFIG_SPECTRUMSYNTH_FILTER 0 -+#define CONFIG_AMOVIE_FILTER 0 -+#define CONFIG_MOVIE_FILTER 0 -+#define CONFIG_AFIFO_FILTER 0 -+#define CONFIG_FIFO_FILTER 0 -+#define CONFIG_AA_DEMUXER 0 -+#define CONFIG_AAC_DEMUXER 1 -+#define CONFIG_AC3_DEMUXER 0 -+#define CONFIG_ACM_DEMUXER 0 -+#define CONFIG_ACT_DEMUXER 0 -+#define CONFIG_ADF_DEMUXER 0 -+#define CONFIG_ADP_DEMUXER 0 -+#define CONFIG_ADS_DEMUXER 0 -+#define CONFIG_ADX_DEMUXER 0 -+#define CONFIG_AEA_DEMUXER 0 -+#define CONFIG_AFC_DEMUXER 0 -+#define CONFIG_AIFF_DEMUXER 0 -+#define CONFIG_AIX_DEMUXER 0 -+#define CONFIG_ALP_DEMUXER 0 -+#define CONFIG_AMR_DEMUXER 1 -+#define CONFIG_AMRNB_DEMUXER 0 -+#define CONFIG_AMRWB_DEMUXER 0 -+#define CONFIG_ANM_DEMUXER 0 -+#define CONFIG_APC_DEMUXER 0 -+#define CONFIG_APE_DEMUXER 0 -+#define CONFIG_APM_DEMUXER 0 -+#define CONFIG_APNG_DEMUXER 0 -+#define CONFIG_APTX_DEMUXER 0 -+#define CONFIG_APTX_HD_DEMUXER 0 -+#define CONFIG_AQTITLE_DEMUXER 0 -+#define CONFIG_ARGO_ASF_DEMUXER 0 -+#define CONFIG_ASF_DEMUXER 0 -+#define CONFIG_ASF_O_DEMUXER 0 -+#define CONFIG_ASS_DEMUXER 0 -+#define CONFIG_AST_DEMUXER 0 -+#define CONFIG_AU_DEMUXER 0 -+#define CONFIG_AV1_DEMUXER 0 -+#define CONFIG_AVI_DEMUXER 1 -+#define CONFIG_AVISYNTH_DEMUXER 0 -+#define CONFIG_AVR_DEMUXER 0 -+#define CONFIG_AVS_DEMUXER 0 -+#define CONFIG_AVS2_DEMUXER 0 -+#define CONFIG_BETHSOFTVID_DEMUXER 0 -+#define CONFIG_BFI_DEMUXER 0 -+#define CONFIG_BINTEXT_DEMUXER 0 -+#define CONFIG_BINK_DEMUXER 0 -+#define CONFIG_BIT_DEMUXER 0 -+#define CONFIG_BMV_DEMUXER 0 -+#define CONFIG_BFSTM_DEMUXER 0 -+#define CONFIG_BRSTM_DEMUXER 0 -+#define CONFIG_BOA_DEMUXER 0 -+#define CONFIG_C93_DEMUXER 0 -+#define CONFIG_CAF_DEMUXER 0 -+#define CONFIG_CAVSVIDEO_DEMUXER 0 -+#define CONFIG_CDG_DEMUXER 0 -+#define CONFIG_CDXL_DEMUXER 0 -+#define CONFIG_CINE_DEMUXER 0 -+#define CONFIG_CODEC2_DEMUXER 0 -+#define CONFIG_CODEC2RAW_DEMUXER 0 -+#define CONFIG_CONCAT_DEMUXER 0 -+#define CONFIG_DASH_DEMUXER 0 -+#define CONFIG_DATA_DEMUXER 0 -+#define CONFIG_DAUD_DEMUXER 0 -+#define CONFIG_DCSTR_DEMUXER 0 -+#define CONFIG_DERF_DEMUXER 0 -+#define CONFIG_DFA_DEMUXER 0 -+#define CONFIG_DHAV_DEMUXER 0 -+#define CONFIG_DIRAC_DEMUXER 0 -+#define CONFIG_DNXHD_DEMUXER 0 -+#define CONFIG_DSF_DEMUXER 0 -+#define CONFIG_DSICIN_DEMUXER 0 -+#define CONFIG_DSS_DEMUXER 0 -+#define CONFIG_DTS_DEMUXER 0 -+#define CONFIG_DTSHD_DEMUXER 0 -+#define CONFIG_DV_DEMUXER 0 -+#define CONFIG_DVBSUB_DEMUXER 0 -+#define CONFIG_DVBTXT_DEMUXER 0 -+#define CONFIG_DXA_DEMUXER 0 -+#define CONFIG_EA_DEMUXER 0 -+#define CONFIG_EA_CDATA_DEMUXER 0 -+#define CONFIG_EAC3_DEMUXER 0 -+#define CONFIG_EPAF_DEMUXER 0 -+#define CONFIG_FFMETADATA_DEMUXER 0 -+#define CONFIG_FILMSTRIP_DEMUXER 0 -+#define CONFIG_FITS_DEMUXER 0 -+#define CONFIG_FLAC_DEMUXER 1 -+#define CONFIG_FLIC_DEMUXER 0 -+#define CONFIG_FLV_DEMUXER 0 -+#define CONFIG_LIVE_FLV_DEMUXER 0 -+#define CONFIG_FOURXM_DEMUXER 0 -+#define CONFIG_FRM_DEMUXER 0 -+#define CONFIG_FSB_DEMUXER 0 -+#define CONFIG_FWSE_DEMUXER 0 -+#define CONFIG_G722_DEMUXER 0 -+#define CONFIG_G723_1_DEMUXER 0 -+#define CONFIG_G726_DEMUXER 0 -+#define CONFIG_G726LE_DEMUXER 0 -+#define CONFIG_G729_DEMUXER 0 -+#define CONFIG_GDV_DEMUXER 0 -+#define CONFIG_GENH_DEMUXER 0 -+#define CONFIG_GIF_DEMUXER 0 -+#define CONFIG_GSM_DEMUXER 0 -+#define CONFIG_GXF_DEMUXER 0 -+#define CONFIG_H261_DEMUXER 0 -+#define CONFIG_H263_DEMUXER 0 -+#define CONFIG_H264_DEMUXER 0 -+#define CONFIG_HCA_DEMUXER 0 -+#define CONFIG_HCOM_DEMUXER 0 -+#define CONFIG_HEVC_DEMUXER 0 -+#define CONFIG_HLS_DEMUXER 0 -+#define CONFIG_HNM_DEMUXER 0 -+#define CONFIG_ICO_DEMUXER 0 -+#define CONFIG_IDCIN_DEMUXER 0 -+#define CONFIG_IDF_DEMUXER 0 -+#define CONFIG_IFF_DEMUXER 0 -+#define CONFIG_IFV_DEMUXER 0 -+#define CONFIG_ILBC_DEMUXER 0 -+#define CONFIG_IMAGE2_DEMUXER 0 -+#define CONFIG_IMAGE2PIPE_DEMUXER 0 -+#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 -+#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 -+#define CONFIG_INGENIENT_DEMUXER 0 -+#define CONFIG_IPMOVIE_DEMUXER 0 -+#define CONFIG_IRCAM_DEMUXER 0 -+#define CONFIG_ISS_DEMUXER 0 -+#define CONFIG_IV8_DEMUXER 0 -+#define CONFIG_IVF_DEMUXER 0 -+#define CONFIG_IVR_DEMUXER 0 -+#define CONFIG_JACOSUB_DEMUXER 0 -+#define CONFIG_JV_DEMUXER 0 -+#define CONFIG_KUX_DEMUXER 0 -+#define CONFIG_KVAG_DEMUXER 0 -+#define CONFIG_LMLM4_DEMUXER 0 -+#define CONFIG_LOAS_DEMUXER 0 -+#define CONFIG_LRC_DEMUXER 0 -+#define CONFIG_LVF_DEMUXER 0 -+#define CONFIG_LXF_DEMUXER 0 -+#define CONFIG_M4V_DEMUXER 0 -+#define CONFIG_MCC_DEMUXER 0 -+#define CONFIG_MATROSKA_DEMUXER 1 -+#define CONFIG_MGSTS_DEMUXER 0 -+#define CONFIG_MICRODVD_DEMUXER 0 -+#define CONFIG_MJPEG_DEMUXER 0 -+#define CONFIG_MJPEG_2000_DEMUXER 0 -+#define CONFIG_MLP_DEMUXER 0 -+#define CONFIG_MLV_DEMUXER 0 -+#define CONFIG_MM_DEMUXER 0 -+#define CONFIG_MMF_DEMUXER 0 -+#define CONFIG_MOV_DEMUXER 1 -+#define CONFIG_MP3_DEMUXER 1 -+#define CONFIG_MPC_DEMUXER 0 -+#define CONFIG_MPC8_DEMUXER 0 -+#define CONFIG_MPEGPS_DEMUXER 0 -+#define CONFIG_MPEGTS_DEMUXER 0 -+#define CONFIG_MPEGTSRAW_DEMUXER 0 -+#define CONFIG_MPEGVIDEO_DEMUXER 0 -+#define CONFIG_MPJPEG_DEMUXER 0 -+#define CONFIG_MPL2_DEMUXER 0 -+#define CONFIG_MPSUB_DEMUXER 0 -+#define CONFIG_MSF_DEMUXER 0 -+#define CONFIG_MSNWC_TCP_DEMUXER 0 -+#define CONFIG_MTAF_DEMUXER 0 -+#define CONFIG_MTV_DEMUXER 0 -+#define CONFIG_MUSX_DEMUXER 0 -+#define CONFIG_MV_DEMUXER 0 -+#define CONFIG_MVI_DEMUXER 0 -+#define CONFIG_MXF_DEMUXER 0 -+#define CONFIG_MXG_DEMUXER 0 -+#define CONFIG_NC_DEMUXER 0 -+#define CONFIG_NISTSPHERE_DEMUXER 0 -+#define CONFIG_NSP_DEMUXER 0 -+#define CONFIG_NSV_DEMUXER 0 -+#define CONFIG_NUT_DEMUXER 0 -+#define CONFIG_NUV_DEMUXER 0 -+#define CONFIG_OBU_DEMUXER 0 -+#define CONFIG_OGG_DEMUXER 1 -+#define CONFIG_OMA_DEMUXER 0 -+#define CONFIG_PAF_DEMUXER 0 -+#define CONFIG_PCM_ALAW_DEMUXER 0 -+#define CONFIG_PCM_MULAW_DEMUXER 0 -+#define CONFIG_PCM_VIDC_DEMUXER 0 -+#define CONFIG_PCM_F64BE_DEMUXER 0 -+#define CONFIG_PCM_F64LE_DEMUXER 0 -+#define CONFIG_PCM_F32BE_DEMUXER 0 -+#define CONFIG_PCM_F32LE_DEMUXER 0 -+#define CONFIG_PCM_S32BE_DEMUXER 0 -+#define CONFIG_PCM_S32LE_DEMUXER 0 -+#define CONFIG_PCM_S24BE_DEMUXER 0 -+#define CONFIG_PCM_S24LE_DEMUXER 0 -+#define CONFIG_PCM_S16BE_DEMUXER 0 -+#define CONFIG_PCM_S16LE_DEMUXER 0 -+#define CONFIG_PCM_S8_DEMUXER 0 -+#define CONFIG_PCM_U32BE_DEMUXER 0 -+#define CONFIG_PCM_U32LE_DEMUXER 0 -+#define CONFIG_PCM_U24BE_DEMUXER 0 -+#define CONFIG_PCM_U24LE_DEMUXER 0 -+#define CONFIG_PCM_U16BE_DEMUXER 0 -+#define CONFIG_PCM_U16LE_DEMUXER 0 -+#define CONFIG_PCM_U8_DEMUXER 0 -+#define CONFIG_PJS_DEMUXER 0 -+#define CONFIG_PMP_DEMUXER 0 -+#define CONFIG_PP_BNK_DEMUXER 0 -+#define CONFIG_PVA_DEMUXER 0 -+#define CONFIG_PVF_DEMUXER 0 -+#define CONFIG_QCP_DEMUXER 0 -+#define CONFIG_R3D_DEMUXER 0 -+#define CONFIG_RAWVIDEO_DEMUXER 0 -+#define CONFIG_REALTEXT_DEMUXER 0 -+#define CONFIG_REDSPARK_DEMUXER 0 -+#define CONFIG_RL2_DEMUXER 0 -+#define CONFIG_RM_DEMUXER 0 -+#define CONFIG_ROQ_DEMUXER 0 -+#define CONFIG_RPL_DEMUXER 0 -+#define CONFIG_RSD_DEMUXER 0 -+#define CONFIG_RSO_DEMUXER 0 -+#define CONFIG_RTP_DEMUXER 0 -+#define CONFIG_RTSP_DEMUXER 0 -+#define CONFIG_S337M_DEMUXER 0 -+#define CONFIG_SAMI_DEMUXER 0 -+#define CONFIG_SAP_DEMUXER 0 -+#define CONFIG_SBC_DEMUXER 0 -+#define CONFIG_SBG_DEMUXER 0 -+#define CONFIG_SCC_DEMUXER 0 -+#define CONFIG_SDP_DEMUXER 0 -+#define CONFIG_SDR2_DEMUXER 0 -+#define CONFIG_SDS_DEMUXER 0 -+#define CONFIG_SDX_DEMUXER 0 -+#define CONFIG_SEGAFILM_DEMUXER 0 -+#define CONFIG_SER_DEMUXER 0 -+#define CONFIG_SHORTEN_DEMUXER 0 -+#define CONFIG_SIFF_DEMUXER 0 -+#define CONFIG_SLN_DEMUXER 0 -+#define CONFIG_SMACKER_DEMUXER 0 -+#define CONFIG_SMJPEG_DEMUXER 0 -+#define CONFIG_SMUSH_DEMUXER 0 -+#define CONFIG_SOL_DEMUXER 0 -+#define CONFIG_SOX_DEMUXER 0 -+#define CONFIG_SPDIF_DEMUXER 0 -+#define CONFIG_SRT_DEMUXER 0 -+#define CONFIG_STR_DEMUXER 0 -+#define CONFIG_STL_DEMUXER 0 -+#define CONFIG_SUBVIEWER1_DEMUXER 0 -+#define CONFIG_SUBVIEWER_DEMUXER 0 -+#define CONFIG_SUP_DEMUXER 0 -+#define CONFIG_SVAG_DEMUXER 0 -+#define CONFIG_SWF_DEMUXER 0 -+#define CONFIG_TAK_DEMUXER 0 -+#define CONFIG_TEDCAPTIONS_DEMUXER 0 -+#define CONFIG_THP_DEMUXER 0 -+#define CONFIG_THREEDOSTR_DEMUXER 0 -+#define CONFIG_TIERTEXSEQ_DEMUXER 0 -+#define CONFIG_TMV_DEMUXER 0 -+#define CONFIG_TRUEHD_DEMUXER 0 -+#define CONFIG_TTA_DEMUXER 0 -+#define CONFIG_TXD_DEMUXER 0 -+#define CONFIG_TTY_DEMUXER 0 -+#define CONFIG_TY_DEMUXER 0 -+#define CONFIG_V210_DEMUXER 0 -+#define CONFIG_V210X_DEMUXER 0 -+#define CONFIG_VAG_DEMUXER 0 -+#define CONFIG_VC1_DEMUXER 0 -+#define CONFIG_VC1T_DEMUXER 0 -+#define CONFIG_VIVIDAS_DEMUXER 0 -+#define CONFIG_VIVO_DEMUXER 0 -+#define CONFIG_VMD_DEMUXER 0 -+#define CONFIG_VOBSUB_DEMUXER 0 -+#define CONFIG_VOC_DEMUXER 0 -+#define CONFIG_VPK_DEMUXER 0 -+#define CONFIG_VPLAYER_DEMUXER 0 -+#define CONFIG_VQF_DEMUXER 0 -+#define CONFIG_W64_DEMUXER 0 -+#define CONFIG_WAV_DEMUXER 1 -+#define CONFIG_WC3_DEMUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 -+#define CONFIG_WEBVTT_DEMUXER 0 -+#define CONFIG_WSAUD_DEMUXER 0 -+#define CONFIG_WSD_DEMUXER 0 -+#define CONFIG_WSVQA_DEMUXER 0 -+#define CONFIG_WTV_DEMUXER 0 -+#define CONFIG_WVE_DEMUXER 0 -+#define CONFIG_WV_DEMUXER 0 -+#define CONFIG_XA_DEMUXER 0 -+#define CONFIG_XBIN_DEMUXER 0 -+#define CONFIG_XMV_DEMUXER 0 -+#define CONFIG_XVAG_DEMUXER 0 -+#define CONFIG_XWMA_DEMUXER 0 -+#define CONFIG_YOP_DEMUXER 0 -+#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 -+#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 -+#define CONFIG_LIBGME_DEMUXER 0 -+#define CONFIG_LIBMODPLUG_DEMUXER 0 -+#define CONFIG_LIBOPENMPT_DEMUXER 0 -+#define CONFIG_VAPOURSYNTH_DEMUXER 0 -+#define CONFIG_A64_MUXER 0 -+#define CONFIG_AC3_MUXER 0 -+#define CONFIG_ADTS_MUXER 0 -+#define CONFIG_ADX_MUXER 0 -+#define CONFIG_AIFF_MUXER 0 -+#define CONFIG_AMR_MUXER 0 -+#define CONFIG_APM_MUXER 0 -+#define CONFIG_APNG_MUXER 0 -+#define CONFIG_APTX_MUXER 0 -+#define CONFIG_APTX_HD_MUXER 0 -+#define CONFIG_ARGO_ASF_MUXER 0 -+#define CONFIG_ASF_MUXER 0 -+#define CONFIG_ASS_MUXER 0 -+#define CONFIG_AST_MUXER 0 -+#define CONFIG_ASF_STREAM_MUXER 0 -+#define CONFIG_AU_MUXER 0 -+#define CONFIG_AVI_MUXER 0 -+#define CONFIG_AVM2_MUXER 0 -+#define CONFIG_AVS2_MUXER 0 -+#define CONFIG_BIT_MUXER 0 -+#define CONFIG_CAF_MUXER 0 -+#define CONFIG_CAVSVIDEO_MUXER 0 -+#define CONFIG_CODEC2_MUXER 0 -+#define CONFIG_CODEC2RAW_MUXER 0 -+#define CONFIG_CRC_MUXER 0 -+#define CONFIG_DASH_MUXER 0 -+#define CONFIG_DATA_MUXER 0 -+#define CONFIG_DAUD_MUXER 0 -+#define CONFIG_DIRAC_MUXER 0 -+#define CONFIG_DNXHD_MUXER 0 -+#define CONFIG_DTS_MUXER 0 -+#define CONFIG_DV_MUXER 0 -+#define CONFIG_EAC3_MUXER 0 -+#define CONFIG_F4V_MUXER 0 -+#define CONFIG_FFMETADATA_MUXER 0 -+#define CONFIG_FIFO_MUXER 0 -+#define CONFIG_FIFO_TEST_MUXER 0 -+#define CONFIG_FILMSTRIP_MUXER 0 -+#define CONFIG_FITS_MUXER 0 -+#define CONFIG_FLAC_MUXER 0 -+#define CONFIG_FLV_MUXER 0 -+#define CONFIG_FRAMECRC_MUXER 0 -+#define CONFIG_FRAMEHASH_MUXER 0 -+#define CONFIG_FRAMEMD5_MUXER 0 -+#define CONFIG_G722_MUXER 0 -+#define CONFIG_G723_1_MUXER 0 -+#define CONFIG_G726_MUXER 0 -+#define CONFIG_G726LE_MUXER 0 -+#define CONFIG_GIF_MUXER 0 -+#define CONFIG_GSM_MUXER 0 -+#define CONFIG_GXF_MUXER 0 -+#define CONFIG_H261_MUXER 0 -+#define CONFIG_H263_MUXER 0 -+#define CONFIG_H264_MUXER 0 -+#define CONFIG_HASH_MUXER 0 -+#define CONFIG_HDS_MUXER 0 -+#define CONFIG_HEVC_MUXER 0 -+#define CONFIG_HLS_MUXER 0 -+#define CONFIG_ICO_MUXER 0 -+#define CONFIG_ILBC_MUXER 0 -+#define CONFIG_IMAGE2_MUXER 0 -+#define CONFIG_IMAGE2PIPE_MUXER 0 -+#define CONFIG_IPOD_MUXER 0 -+#define CONFIG_IRCAM_MUXER 0 -+#define CONFIG_ISMV_MUXER 0 -+#define CONFIG_IVF_MUXER 0 -+#define CONFIG_JACOSUB_MUXER 0 -+#define CONFIG_KVAG_MUXER 0 -+#define CONFIG_LATM_MUXER 0 -+#define CONFIG_LRC_MUXER 0 -+#define CONFIG_M4V_MUXER 0 -+#define CONFIG_MD5_MUXER 0 -+#define CONFIG_MATROSKA_MUXER 0 -+#define CONFIG_MATROSKA_AUDIO_MUXER 0 -+#define CONFIG_MICRODVD_MUXER 0 -+#define CONFIG_MJPEG_MUXER 0 -+#define CONFIG_MLP_MUXER 0 -+#define CONFIG_MMF_MUXER 0 -+#define CONFIG_MOV_MUXER 0 -+#define CONFIG_MP2_MUXER 0 -+#define CONFIG_MP3_MUXER 0 -+#define CONFIG_MP4_MUXER 0 -+#define CONFIG_MPEG1SYSTEM_MUXER 0 -+#define CONFIG_MPEG1VCD_MUXER 0 -+#define CONFIG_MPEG1VIDEO_MUXER 0 -+#define CONFIG_MPEG2DVD_MUXER 0 -+#define CONFIG_MPEG2SVCD_MUXER 0 -+#define CONFIG_MPEG2VIDEO_MUXER 0 -+#define CONFIG_MPEG2VOB_MUXER 0 -+#define CONFIG_MPEGTS_MUXER 0 -+#define CONFIG_MPJPEG_MUXER 0 -+#define CONFIG_MXF_MUXER 0 -+#define CONFIG_MXF_D10_MUXER 0 -+#define CONFIG_MXF_OPATOM_MUXER 0 -+#define CONFIG_NULL_MUXER 0 -+#define CONFIG_NUT_MUXER 0 -+#define CONFIG_OGA_MUXER 0 -+#define CONFIG_OGG_MUXER 0 -+#define CONFIG_OGV_MUXER 0 -+#define CONFIG_OMA_MUXER 0 -+#define CONFIG_OPUS_MUXER 0 -+#define CONFIG_PCM_ALAW_MUXER 0 -+#define CONFIG_PCM_MULAW_MUXER 0 -+#define CONFIG_PCM_VIDC_MUXER 0 -+#define CONFIG_PCM_F64BE_MUXER 0 -+#define CONFIG_PCM_F64LE_MUXER 0 -+#define CONFIG_PCM_F32BE_MUXER 0 -+#define CONFIG_PCM_F32LE_MUXER 0 -+#define CONFIG_PCM_S32BE_MUXER 0 -+#define CONFIG_PCM_S32LE_MUXER 0 -+#define CONFIG_PCM_S24BE_MUXER 0 -+#define CONFIG_PCM_S24LE_MUXER 0 -+#define CONFIG_PCM_S16BE_MUXER 0 -+#define CONFIG_PCM_S16LE_MUXER 0 -+#define CONFIG_PCM_S8_MUXER 0 -+#define CONFIG_PCM_U32BE_MUXER 0 -+#define CONFIG_PCM_U32LE_MUXER 0 -+#define CONFIG_PCM_U24BE_MUXER 0 -+#define CONFIG_PCM_U24LE_MUXER 0 -+#define CONFIG_PCM_U16BE_MUXER 0 -+#define CONFIG_PCM_U16LE_MUXER 0 -+#define CONFIG_PCM_U8_MUXER 0 -+#define CONFIG_PSP_MUXER 0 -+#define CONFIG_RAWVIDEO_MUXER 0 -+#define CONFIG_RM_MUXER 0 -+#define CONFIG_ROQ_MUXER 0 -+#define CONFIG_RSO_MUXER 0 -+#define CONFIG_RTP_MUXER 0 -+#define CONFIG_RTP_MPEGTS_MUXER 0 -+#define CONFIG_RTSP_MUXER 0 -+#define CONFIG_SAP_MUXER 0 -+#define CONFIG_SBC_MUXER 0 -+#define CONFIG_SCC_MUXER 0 -+#define CONFIG_SEGAFILM_MUXER 0 -+#define CONFIG_SEGMENT_MUXER 0 -+#define CONFIG_STREAM_SEGMENT_MUXER 0 -+#define CONFIG_SINGLEJPEG_MUXER 0 -+#define CONFIG_SMJPEG_MUXER 0 -+#define CONFIG_SMOOTHSTREAMING_MUXER 0 -+#define CONFIG_SOX_MUXER 0 -+#define CONFIG_SPX_MUXER 0 -+#define CONFIG_SPDIF_MUXER 0 -+#define CONFIG_SRT_MUXER 0 -+#define CONFIG_STREAMHASH_MUXER 0 -+#define CONFIG_SUP_MUXER 0 -+#define CONFIG_SWF_MUXER 0 -+#define CONFIG_TEE_MUXER 0 -+#define CONFIG_TG2_MUXER 0 -+#define CONFIG_TGP_MUXER 0 -+#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 -+#define CONFIG_TRUEHD_MUXER 0 -+#define CONFIG_TTA_MUXER 0 -+#define CONFIG_UNCODEDFRAMECRC_MUXER 0 -+#define CONFIG_VC1_MUXER 0 -+#define CONFIG_VC1T_MUXER 0 -+#define CONFIG_VOC_MUXER 0 -+#define CONFIG_W64_MUXER 0 -+#define CONFIG_WAV_MUXER 0 -+#define CONFIG_WEBM_MUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 -+#define CONFIG_WEBM_CHUNK_MUXER 0 -+#define CONFIG_WEBP_MUXER 0 -+#define CONFIG_WEBVTT_MUXER 0 -+#define CONFIG_WTV_MUXER 0 -+#define CONFIG_WV_MUXER 0 -+#define CONFIG_YUV4MPEGPIPE_MUXER 0 -+#define CONFIG_CHROMAPRINT_MUXER 0 -+#define CONFIG_ASYNC_PROTOCOL 0 -+#define CONFIG_BLURAY_PROTOCOL 0 -+#define CONFIG_CACHE_PROTOCOL 0 -+#define CONFIG_CONCAT_PROTOCOL 0 -+#define CONFIG_CRYPTO_PROTOCOL 0 -+#define CONFIG_DATA_PROTOCOL 0 -+#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 -+#define CONFIG_FFRTMPHTTP_PROTOCOL 0 -+#define CONFIG_FILE_PROTOCOL 0 -+#define CONFIG_FTP_PROTOCOL 0 -+#define CONFIG_GOPHER_PROTOCOL 0 -+#define CONFIG_HLS_PROTOCOL 0 -+#define CONFIG_HTTP_PROTOCOL 0 -+#define CONFIG_HTTPPROXY_PROTOCOL 0 -+#define CONFIG_HTTPS_PROTOCOL 0 -+#define CONFIG_ICECAST_PROTOCOL 0 -+#define CONFIG_MMSH_PROTOCOL 0 -+#define CONFIG_MMST_PROTOCOL 0 -+#define CONFIG_MD5_PROTOCOL 0 -+#define CONFIG_PIPE_PROTOCOL 0 -+#define CONFIG_PROMPEG_PROTOCOL 0 -+#define CONFIG_RTMP_PROTOCOL 0 -+#define CONFIG_RTMPE_PROTOCOL 0 -+#define CONFIG_RTMPS_PROTOCOL 0 -+#define CONFIG_RTMPT_PROTOCOL 0 -+#define CONFIG_RTMPTE_PROTOCOL 0 -+#define CONFIG_RTMPTS_PROTOCOL 0 -+#define CONFIG_RTP_PROTOCOL 0 -+#define CONFIG_SCTP_PROTOCOL 0 -+#define CONFIG_SRTP_PROTOCOL 0 -+#define CONFIG_SUBFILE_PROTOCOL 0 -+#define CONFIG_TEE_PROTOCOL 0 -+#define CONFIG_TCP_PROTOCOL 0 -+#define CONFIG_TLS_PROTOCOL 0 -+#define CONFIG_UDP_PROTOCOL 0 -+#define CONFIG_UDPLITE_PROTOCOL 0 -+#define CONFIG_UNIX_PROTOCOL 0 -+#define CONFIG_LIBAMQP_PROTOCOL 0 -+#define CONFIG_LIBRTMP_PROTOCOL 0 -+#define CONFIG_LIBRTMPE_PROTOCOL 0 -+#define CONFIG_LIBRTMPS_PROTOCOL 0 -+#define CONFIG_LIBRTMPT_PROTOCOL 0 -+#define CONFIG_LIBRTMPTE_PROTOCOL 0 -+#define CONFIG_LIBSRT_PROTOCOL 0 -+#define CONFIG_LIBSSH_PROTOCOL 0 -+#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 -+#define CONFIG_LIBZMQ_PROTOCOL 0 -+#endif /* FFMPEG_CONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/bsf_list.c -@@ -0,0 +1,3 @@ -+static const AVBitStreamFilter * const bitstream_filters[] = { -+ &ff_null_bsf, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/codec_list.c -@@ -0,0 +1,25 @@ -+static const AVCodec * const codec_list[] = { -+ &ff_h263_decoder, -+ &ff_h264_decoder, -+ &ff_mpeg4_decoder, -+ &ff_theora_decoder, -+ &ff_vp3_decoder, -+ &ff_vp8_decoder, -+ &ff_aac_decoder, -+ &ff_amrnb_decoder, -+ &ff_amrwb_decoder, -+ &ff_flac_decoder, -+ &ff_gsm_ms_decoder, -+ &ff_mp3_decoder, -+ &ff_vorbis_decoder, -+ &ff_pcm_alaw_decoder, -+ &ff_pcm_f32le_decoder, -+ &ff_pcm_mulaw_decoder, -+ &ff_pcm_s16be_decoder, -+ &ff_pcm_s16le_decoder, -+ &ff_pcm_s24be_decoder, -+ &ff_pcm_s24le_decoder, -+ &ff_pcm_s32le_decoder, -+ &ff_pcm_u8_decoder, -+ &ff_libopus_decoder, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/parser_list.c -@@ -0,0 +1,14 @@ -+static const AVCodecParser * const parser_list[] = { -+ &ff_aac_parser, -+ &ff_flac_parser, -+ &ff_gsm_parser, -+ &ff_h263_parser, -+ &ff_h264_parser, -+ &ff_mpeg4video_parser, -+ &ff_mpegaudio_parser, -+ &ff_opus_parser, -+ &ff_vorbis_parser, -+ &ff_vp3_parser, -+ &ff_vp8_parser, -+ &ff_vp9_parser, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/demuxer_list.c -@@ -0,0 +1,11 @@ -+static const AVInputFormat * const demuxer_list[] = { -+ &ff_aac_demuxer, -+ &ff_amr_demuxer, -+ &ff_avi_demuxer, -+ &ff_flac_demuxer, -+ &ff_matroska_demuxer, -+ &ff_mov_demuxer, -+ &ff_mp3_demuxer, -+ &ff_ogg_demuxer, -+ &ff_wav_demuxer, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/muxer_list.c -@@ -0,0 +1,2 @@ -+static const AVOutputFormat * const muxer_list[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/protocol_list.c -@@ -0,0 +1,2 @@ -+static const URLProtocol * const url_protocols[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavutil/avconfig.h -@@ -0,0 +1,6 @@ -+/* Generated by ffmpeg configure */ -+#ifndef AVUTIL_AVCONFIG_H -+#define AVUTIL_AVCONFIG_H -+#define AV_HAVE_BIGENDIAN 0 -+#define AV_HAVE_FAST_UNALIGNED 0 -+#endif /* AVUTIL_AVCONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/config.h -@@ -0,0 +1,2626 @@ -+/* Automatically generated by configure - do not modify! */ -+#ifndef FFMPEG_CONFIG_H -+#define FFMPEG_CONFIG_H -+/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64" -- elide long configuration string from binary */ -+#define FFMPEG_LICENSE "LGPL version 2.1 or later" -+#define CONFIG_THIS_YEAR 2020 -+#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" -+#define AVCONV_DATADIR "/usr/local/share/ffmpeg" -+#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" -+#define av_restrict restrict -+#define EXTERN_PREFIX "" -+#define EXTERN_ASM -+#define BUILDSUF "" -+#define SLIBSUF ".so" -+#define HAVE_MMX2 HAVE_MMXEXT -+#define SWS_MAX_FILTER_SIZE 256 -+#define ARCH_AARCH64 0 -+#define ARCH_ALPHA 0 -+#define ARCH_ARM 0 -+#define ARCH_AVR32 0 -+#define ARCH_AVR32_AP 0 -+#define ARCH_AVR32_UC 0 -+#define ARCH_BFIN 0 -+#define ARCH_IA64 0 -+#define ARCH_M68K 0 -+#define ARCH_MIPS 0 -+#define ARCH_MIPS64 0 -+#define ARCH_PARISC 0 -+#define ARCH_PPC 0 -+#define ARCH_PPC64 0 -+#define ARCH_RISCV 1 -+#define ARCH_S390 0 -+#define ARCH_SH4 0 -+#define ARCH_SPARC 0 -+#define ARCH_SPARC64 0 -+#define ARCH_TILEGX 0 -+#define ARCH_TILEPRO 0 -+#define ARCH_TOMI 0 -+#define ARCH_X86 0 -+#define ARCH_X86_32 0 -+#define ARCH_X86_64 0 -+#define HAVE_ARMV5TE 0 -+#define HAVE_ARMV6 0 -+#define HAVE_ARMV6T2 0 -+#define HAVE_ARMV8 0 -+#define HAVE_NEON 0 -+#define HAVE_VFP 0 -+#define HAVE_VFPV3 0 -+#define HAVE_SETEND 0 -+#define HAVE_ALTIVEC 0 -+#define HAVE_DCBZL 0 -+#define HAVE_LDBRX 0 -+#define HAVE_POWER8 0 -+#define HAVE_PPC4XX 0 -+#define HAVE_VSX 0 -+#define HAVE_AESNI 0 -+#define HAVE_AMD3DNOW 0 -+#define HAVE_AMD3DNOWEXT 0 -+#define HAVE_AVX 0 -+#define HAVE_AVX2 0 -+#define HAVE_AVX512 0 -+#define HAVE_FMA3 0 -+#define HAVE_FMA4 0 -+#define HAVE_MMX 0 -+#define HAVE_MMXEXT 0 -+#define HAVE_SSE 0 -+#define HAVE_SSE2 0 -+#define HAVE_SSE3 0 -+#define HAVE_SSE4 0 -+#define HAVE_SSE42 0 -+#define HAVE_SSSE3 0 -+#define HAVE_XOP 0 -+#define HAVE_CPUNOP 0 -+#define HAVE_I686 0 -+#define HAVE_MIPSFPU 0 -+#define HAVE_MIPS32R2 0 -+#define HAVE_MIPS32R5 0 -+#define HAVE_MIPS64R2 0 -+#define HAVE_MIPS32R6 0 -+#define HAVE_MIPS64R6 0 -+#define HAVE_MIPSDSP 0 -+#define HAVE_MIPSDSPR2 0 -+#define HAVE_MSA 0 -+#define HAVE_MSA2 0 -+#define HAVE_LOONGSON2 0 -+#define HAVE_LOONGSON3 0 -+#define HAVE_MMI 0 -+#define HAVE_ARMV5TE_EXTERNAL 0 -+#define HAVE_ARMV6_EXTERNAL 0 -+#define HAVE_ARMV6T2_EXTERNAL 0 -+#define HAVE_ARMV8_EXTERNAL 0 -+#define HAVE_NEON_EXTERNAL 0 -+#define HAVE_VFP_EXTERNAL 0 -+#define HAVE_VFPV3_EXTERNAL 0 -+#define HAVE_SETEND_EXTERNAL 0 -+#define HAVE_ALTIVEC_EXTERNAL 0 -+#define HAVE_DCBZL_EXTERNAL 0 -+#define HAVE_LDBRX_EXTERNAL 0 -+#define HAVE_POWER8_EXTERNAL 0 -+#define HAVE_PPC4XX_EXTERNAL 0 -+#define HAVE_VSX_EXTERNAL 0 -+#define HAVE_AESNI_EXTERNAL 0 -+#define HAVE_AMD3DNOW_EXTERNAL 0 -+#define HAVE_AMD3DNOWEXT_EXTERNAL 0 -+#define HAVE_AVX_EXTERNAL 0 -+#define HAVE_AVX2_EXTERNAL 0 -+#define HAVE_AVX512_EXTERNAL 0 -+#define HAVE_FMA3_EXTERNAL 0 -+#define HAVE_FMA4_EXTERNAL 0 -+#define HAVE_MMX_EXTERNAL 0 -+#define HAVE_MMXEXT_EXTERNAL 0 -+#define HAVE_SSE_EXTERNAL 0 -+#define HAVE_SSE2_EXTERNAL 0 -+#define HAVE_SSE3_EXTERNAL 0 -+#define HAVE_SSE4_EXTERNAL 0 -+#define HAVE_SSE42_EXTERNAL 0 -+#define HAVE_SSSE3_EXTERNAL 0 -+#define HAVE_XOP_EXTERNAL 0 -+#define HAVE_CPUNOP_EXTERNAL 0 -+#define HAVE_I686_EXTERNAL 0 -+#define HAVE_MIPSFPU_EXTERNAL 0 -+#define HAVE_MIPS32R2_EXTERNAL 0 -+#define HAVE_MIPS32R5_EXTERNAL 0 -+#define HAVE_MIPS64R2_EXTERNAL 0 -+#define HAVE_MIPS32R6_EXTERNAL 0 -+#define HAVE_MIPS64R6_EXTERNAL 0 -+#define HAVE_MIPSDSP_EXTERNAL 0 -+#define HAVE_MIPSDSPR2_EXTERNAL 0 -+#define HAVE_MSA_EXTERNAL 0 -+#define HAVE_MSA2_EXTERNAL 0 -+#define HAVE_LOONGSON2_EXTERNAL 0 -+#define HAVE_LOONGSON3_EXTERNAL 0 -+#define HAVE_MMI_EXTERNAL 0 -+#define HAVE_ARMV5TE_INLINE 0 -+#define HAVE_ARMV6_INLINE 0 -+#define HAVE_ARMV6T2_INLINE 0 -+#define HAVE_ARMV8_INLINE 0 -+#define HAVE_NEON_INLINE 0 -+#define HAVE_VFP_INLINE 0 -+#define HAVE_VFPV3_INLINE 0 -+#define HAVE_SETEND_INLINE 0 -+#define HAVE_ALTIVEC_INLINE 0 -+#define HAVE_DCBZL_INLINE 0 -+#define HAVE_LDBRX_INLINE 0 -+#define HAVE_POWER8_INLINE 0 -+#define HAVE_PPC4XX_INLINE 0 -+#define HAVE_VSX_INLINE 0 -+#define HAVE_AESNI_INLINE 0 -+#define HAVE_AMD3DNOW_INLINE 0 -+#define HAVE_AMD3DNOWEXT_INLINE 0 -+#define HAVE_AVX_INLINE 0 -+#define HAVE_AVX2_INLINE 0 -+#define HAVE_AVX512_INLINE 0 -+#define HAVE_FMA3_INLINE 0 -+#define HAVE_FMA4_INLINE 0 -+#define HAVE_MMX_INLINE 0 -+#define HAVE_MMXEXT_INLINE 0 -+#define HAVE_SSE_INLINE 0 -+#define HAVE_SSE2_INLINE 0 -+#define HAVE_SSE3_INLINE 0 -+#define HAVE_SSE4_INLINE 0 -+#define HAVE_SSE42_INLINE 0 -+#define HAVE_SSSE3_INLINE 0 -+#define HAVE_XOP_INLINE 0 -+#define HAVE_CPUNOP_INLINE 0 -+#define HAVE_I686_INLINE 0 -+#define HAVE_MIPSFPU_INLINE 0 -+#define HAVE_MIPS32R2_INLINE 0 -+#define HAVE_MIPS32R5_INLINE 0 -+#define HAVE_MIPS64R2_INLINE 0 -+#define HAVE_MIPS32R6_INLINE 0 -+#define HAVE_MIPS64R6_INLINE 0 -+#define HAVE_MIPSDSP_INLINE 0 -+#define HAVE_MIPSDSPR2_INLINE 0 -+#define HAVE_MSA_INLINE 0 -+#define HAVE_MSA2_INLINE 0 -+#define HAVE_LOONGSON2_INLINE 0 -+#define HAVE_LOONGSON3_INLINE 0 -+#define HAVE_MMI_INLINE 0 -+#define HAVE_ALIGNED_STACK 0 -+#define HAVE_FAST_64BIT 1 -+#define HAVE_FAST_CLZ 0 -+#define HAVE_FAST_CMOV 0 -+#define HAVE_LOCAL_ALIGNED 0 -+#define HAVE_SIMD_ALIGN_16 0 -+#define HAVE_SIMD_ALIGN_32 0 -+#define HAVE_SIMD_ALIGN_64 0 -+#define HAVE_ATOMIC_CAS_PTR 0 -+#define HAVE_MACHINE_RW_BARRIER 0 -+#define HAVE_MEMORYBARRIER 0 -+#define HAVE_MM_EMPTY 0 -+#define HAVE_RDTSC 0 -+#define HAVE_SEM_TIMEDWAIT 1 -+#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 -+#define HAVE_CABS 0 -+#define HAVE_CEXP 0 -+#define HAVE_INLINE_ASM 1 -+#define HAVE_SYMVER 0 -+#define HAVE_X86ASM 0 -+#define HAVE_BIGENDIAN 0 -+#define HAVE_FAST_UNALIGNED 0 -+#define HAVE_ARPA_INET_H 0 -+#define HAVE_ASM_TYPES_H 1 -+#define HAVE_CDIO_PARANOIA_H 0 -+#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 -+#define HAVE_CUDA_H 0 -+#define HAVE_DISPATCH_DISPATCH_H 0 -+#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 -+#define HAVE_DEV_IC_BT8XX_H 0 -+#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 -+#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 -+#define HAVE_DIRECT_H 0 -+#define HAVE_DIRENT_H 1 -+#define HAVE_DXGIDEBUG_H 0 -+#define HAVE_DXVA_H 0 -+#define HAVE_ES2_GL_H 0 -+#define HAVE_GSM_H 0 -+#define HAVE_IO_H 0 -+#define HAVE_LINUX_PERF_EVENT_H 1 -+#define HAVE_MACHINE_IOCTL_BT848_H 0 -+#define HAVE_MACHINE_IOCTL_METEOR_H 0 -+#define HAVE_MALLOC_H 1 -+#define HAVE_OPENCV2_CORE_CORE_C_H 0 -+#define HAVE_OPENGL_GL3_H 0 -+#define HAVE_POLL_H 1 -+#define HAVE_SYS_PARAM_H 1 -+#define HAVE_SYS_RESOURCE_H 1 -+#define HAVE_SYS_SELECT_H 1 -+#define HAVE_SYS_SOUNDCARD_H 1 -+#define HAVE_SYS_TIME_H 1 -+#define HAVE_SYS_UN_H 1 -+#define HAVE_SYS_VIDEOIO_H 0 -+#define HAVE_TERMIOS_H 1 -+#define HAVE_UDPLITE_H 0 -+#define HAVE_UNISTD_H 1 -+#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ -+#define HAVE_WINDOWS_H 0 -+#define HAVE_WINSOCK2_H 0 -+#define HAVE_INTRINSICS_NEON 0 -+#define HAVE_ATANF 1 -+#define HAVE_ATAN2F 1 -+#define HAVE_CBRT 1 -+#define HAVE_CBRTF 1 -+#define HAVE_COPYSIGN 1 -+#define HAVE_COSF 1 -+#define HAVE_ERF 1 -+#define HAVE_EXP2 1 -+#define HAVE_EXP2F 1 -+#define HAVE_EXPF 1 -+#define HAVE_HYPOT 1 -+#define HAVE_ISFINITE 1 -+#define HAVE_ISINF 1 -+#define HAVE_ISNAN 1 -+#define HAVE_LDEXPF 1 -+#define HAVE_LLRINT 1 -+#define HAVE_LLRINTF 1 -+#define HAVE_LOG2 1 -+#define HAVE_LOG2F 1 -+#define HAVE_LOG10F 1 -+#define HAVE_LRINT 1 -+#define HAVE_LRINTF 1 -+#define HAVE_POWF 1 -+#define HAVE_RINT 1 -+#define HAVE_ROUND 1 -+#define HAVE_ROUNDF 1 -+#define HAVE_SINF 1 -+#define HAVE_TRUNC 1 -+#define HAVE_TRUNCF 1 -+#define HAVE_DOS_PATHS 0 -+#define HAVE_LIBC_MSVCRT 0 -+#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 -+#define HAVE_SECTION_DATA_REL_RO 1 -+#define HAVE_THREADS 1 -+#define HAVE_UWP 0 -+#define HAVE_WINRT 0 -+#define HAVE_ACCESS 1 -+#define HAVE_ALIGNED_MALLOC 0 -+#define HAVE_ARC4RANDOM 0 -+#define HAVE_CLOCK_GETTIME 1 -+#define HAVE_CLOSESOCKET 0 -+#define HAVE_COMMANDLINETOARGVW 0 -+#define HAVE_FCNTL 1 -+#define HAVE_GETADDRINFO 0 -+#define HAVE_GETHRTIME 0 -+#define HAVE_GETOPT 1 -+#define HAVE_GETMODULEHANDLE 0 -+#define HAVE_GETPROCESSAFFINITYMASK 0 -+#define HAVE_GETPROCESSMEMORYINFO 0 -+#define HAVE_GETPROCESSTIMES 0 -+#define HAVE_GETRUSAGE 1 -+#define HAVE_GETSTDHANDLE 0 -+#define HAVE_GETSYSTEMTIMEASFILETIME 0 -+#define HAVE_GETTIMEOFDAY 1 -+#define HAVE_GLOB 1 -+#define HAVE_GLXGETPROCADDRESS 0 -+#define HAVE_GMTIME_R 1 -+#define HAVE_INET_ATON 0 -+#define HAVE_ISATTY 1 -+#define HAVE_KBHIT 0 -+#define HAVE_LOCALTIME_R 1 -+#define HAVE_LSTAT 1 -+#define HAVE_LZO1X_999_COMPRESS 0 -+#define HAVE_MACH_ABSOLUTE_TIME 0 -+#define HAVE_MAPVIEWOFFILE 0 -+#define HAVE_MEMALIGN 1 -+#define HAVE_MKSTEMP 1 -+#define HAVE_MMAP 1 -+#define HAVE_MPROTECT 1 -+#define HAVE_NANOSLEEP 1 -+#define HAVE_PEEKNAMEDPIPE 0 -+#define HAVE_POSIX_MEMALIGN 1 -+#define HAVE_PTHREAD_CANCEL 1 -+#define HAVE_SCHED_GETAFFINITY 1 -+#define HAVE_SECITEMIMPORT 0 -+#define HAVE_SETCONSOLETEXTATTRIBUTE 0 -+#define HAVE_SETCONSOLECTRLHANDLER 0 -+#define HAVE_SETDLLDIRECTORY 0 -+#define HAVE_SETMODE 0 -+#define HAVE_SETRLIMIT 1 -+#define HAVE_SLEEP 0 -+#define HAVE_STRERROR_R 1 -+#define HAVE_SYSCONF 1 -+#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ -+#define HAVE_USLEEP 1 -+#define HAVE_UTGETOSTYPEFROMSTRING 0 -+#define HAVE_VIRTUALALLOC 0 -+#define HAVE_WGLGETPROCADDRESS 0 -+#define HAVE_BCRYPT 0 -+#define HAVE_VAAPI_DRM 0 -+#define HAVE_VAAPI_X11 0 -+#define HAVE_VDPAU_X11 0 -+#define HAVE_PTHREADS 1 -+#define HAVE_OS2THREADS 0 -+#define HAVE_W32THREADS 0 -+#define HAVE_AS_ARCH_DIRECTIVE 0 -+#define HAVE_AS_DN_DIRECTIVE 0 -+#define HAVE_AS_FPU_DIRECTIVE 0 -+#define HAVE_AS_FUNC 0 -+#define HAVE_AS_OBJECT_ARCH 0 -+#define HAVE_ASM_MOD_Q 0 -+#define HAVE_BLOCKS_EXTENSION 0 -+#define HAVE_EBP_AVAILABLE 0 -+#define HAVE_EBX_AVAILABLE 0 -+#define HAVE_GNU_AS 0 -+#define HAVE_GNU_WINDRES 0 -+#define HAVE_IBM_ASM 0 -+#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 -+#define HAVE_INLINE_ASM_LABELS 1 -+#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 -+#define HAVE_PRAGMA_DEPRECATED 1 -+#define HAVE_RSYNC_CONTIMEOUT 0 -+#define HAVE_SYMVER_ASM_LABEL 0 -+#define HAVE_SYMVER_GNU_ASM 1 -+#define HAVE_VFP_ARGS 0 -+#define HAVE_XFORM_ASM 0 -+#define HAVE_XMM_CLOBBERS 0 -+#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 -+#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 -+#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 -+#define HAVE_SOCKLEN_T 0 -+#define HAVE_STRUCT_ADDRINFO 0 -+#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 -+#define HAVE_STRUCT_IP_MREQ_SOURCE 0 -+#define HAVE_STRUCT_IPV6_MREQ 0 -+#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 -+#define HAVE_STRUCT_POLLFD 0 -+#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 -+#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 -+#define HAVE_STRUCT_SOCKADDR_IN6 0 -+#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 -+#define HAVE_STRUCT_SOCKADDR_STORAGE 0 -+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 -+#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 -+#define HAVE_LIBDRM_GETFB2 0 -+#define HAVE_MAKEINFO 0 -+#define HAVE_MAKEINFO_HTML 0 -+#define HAVE_OPENCL_D3D11 0 -+#define HAVE_OPENCL_DRM_ARM 0 -+#define HAVE_OPENCL_DRM_BEIGNET 0 -+#define HAVE_OPENCL_DXVA2 0 -+#define HAVE_OPENCL_VAAPI_BEIGNET 0 -+#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 -+#define HAVE_PERL 1 -+#define HAVE_POD2MAN 1 -+#define HAVE_TEXI2HTML 0 -+#define CONFIG_DOC 0 -+#define CONFIG_HTMLPAGES 0 -+#define CONFIG_MANPAGES 0 -+#define CONFIG_PODPAGES 0 -+#define CONFIG_TXTPAGES 0 -+#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 -+#define CONFIG_AVIO_READING_EXAMPLE 1 -+#define CONFIG_DECODE_AUDIO_EXAMPLE 1 -+#define CONFIG_DECODE_VIDEO_EXAMPLE 1 -+#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 -+#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 -+#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 -+#define CONFIG_EXTRACT_MVS_EXAMPLE 1 -+#define CONFIG_FILTER_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 -+#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 -+#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 -+#define CONFIG_HW_DECODE_EXAMPLE 1 -+#define CONFIG_METADATA_EXAMPLE 1 -+#define CONFIG_MUXING_EXAMPLE 0 -+#define CONFIG_QSVDEC_EXAMPLE 0 -+#define CONFIG_REMUXING_EXAMPLE 1 -+#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 -+#define CONFIG_SCALING_VIDEO_EXAMPLE 0 -+#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 -+#define CONFIG_TRANSCODING_EXAMPLE 0 -+#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 -+#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 -+#define CONFIG_AVISYNTH 0 -+#define CONFIG_FREI0R 0 -+#define CONFIG_LIBCDIO 0 -+#define CONFIG_LIBDAVS2 0 -+#define CONFIG_LIBRUBBERBAND 0 -+#define CONFIG_LIBVIDSTAB 0 -+#define CONFIG_LIBX264 0 -+#define CONFIG_LIBX265 0 -+#define CONFIG_LIBXAVS 0 -+#define CONFIG_LIBXAVS2 0 -+#define CONFIG_LIBXVID 0 -+#define CONFIG_DECKLINK 0 -+#define CONFIG_LIBFDK_AAC 0 -+#define CONFIG_OPENSSL 0 -+#define CONFIG_LIBTLS 0 -+#define CONFIG_GMP 0 -+#define CONFIG_LIBARIBB24 0 -+#define CONFIG_LIBLENSFUN 0 -+#define CONFIG_LIBOPENCORE_AMRNB 0 -+#define CONFIG_LIBOPENCORE_AMRWB 0 -+#define CONFIG_LIBVO_AMRWBENC 0 -+#define CONFIG_MBEDTLS 0 -+#define CONFIG_RKMPP 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_CHROMAPRINT 0 -+#define CONFIG_GCRYPT 0 -+#define CONFIG_GNUTLS 0 -+#define CONFIG_JNI 0 -+#define CONFIG_LADSPA 0 -+#define CONFIG_LIBAOM 0 -+#define CONFIG_LIBASS 0 -+#define CONFIG_LIBBLURAY 0 -+#define CONFIG_LIBBS2B 0 -+#define CONFIG_LIBCACA 0 -+#define CONFIG_LIBCELT 0 -+#define CONFIG_LIBCODEC2 0 -+#define CONFIG_LIBDAV1D 0 -+#define CONFIG_LIBDC1394 0 -+#define CONFIG_LIBDRM 0 -+#define CONFIG_LIBFLITE 0 -+#define CONFIG_LIBFONTCONFIG 0 -+#define CONFIG_LIBFREETYPE 0 -+#define CONFIG_LIBFRIBIDI 0 -+#define CONFIG_LIBGLSLANG 0 -+#define CONFIG_LIBGME 0 -+#define CONFIG_LIBGSM 0 -+#define CONFIG_LIBIEC61883 0 -+#define CONFIG_LIBILBC 0 -+#define CONFIG_LIBJACK 0 -+#define CONFIG_LIBKLVANC 0 -+#define CONFIG_LIBKVAZAAR 0 -+#define CONFIG_LIBMODPLUG 0 -+#define CONFIG_LIBMP3LAME 0 -+#define CONFIG_LIBMYSOFA 0 -+#define CONFIG_LIBOPENCV 0 -+#define CONFIG_LIBOPENH264 0 -+#define CONFIG_LIBOPENJPEG 0 -+#define CONFIG_LIBOPENMPT 0 -+#define CONFIG_LIBOPENVINO 0 -+#define CONFIG_LIBOPUS 1 -+#define CONFIG_LIBPULSE 0 -+#define CONFIG_LIBRABBITMQ 0 -+#define CONFIG_LIBRAV1E 0 -+#define CONFIG_LIBRSVG 0 -+#define CONFIG_LIBRTMP 0 -+#define CONFIG_LIBSHINE 0 -+#define CONFIG_LIBSMBCLIENT 0 -+#define CONFIG_LIBSNAPPY 0 -+#define CONFIG_LIBSOXR 0 -+#define CONFIG_LIBSPEEX 0 -+#define CONFIG_LIBSRT 0 -+#define CONFIG_LIBSSH 0 -+#define CONFIG_LIBSVTAV1 0 -+#define CONFIG_LIBTENSORFLOW 0 -+#define CONFIG_LIBTESSERACT 0 -+#define CONFIG_LIBTHEORA 0 -+#define CONFIG_LIBTWOLAME 0 -+#define CONFIG_LIBV4L2 0 -+#define CONFIG_LIBVMAF 0 -+#define CONFIG_LIBVORBIS 0 -+#define CONFIG_LIBVPX 0 -+#define CONFIG_LIBWAVPACK 0 -+#define CONFIG_LIBWEBP 0 -+#define CONFIG_LIBXML2 0 -+#define CONFIG_LIBZIMG 0 -+#define CONFIG_LIBZMQ 0 -+#define CONFIG_LIBZVBI 0 -+#define CONFIG_LV2 0 -+#define CONFIG_MEDIACODEC 0 -+#define CONFIG_OPENAL 0 -+#define CONFIG_OPENGL 0 -+#define CONFIG_POCKETSPHINX 0 -+#define CONFIG_VAPOURSYNTH 0 -+#define CONFIG_ALSA 0 -+#define CONFIG_APPKIT 0 -+#define CONFIG_AVFOUNDATION 0 -+#define CONFIG_BZLIB 0 -+#define CONFIG_COREIMAGE 0 -+#define CONFIG_ICONV 0 -+#define CONFIG_LIBXCB 0 -+#define CONFIG_LIBXCB_SHM 0 -+#define CONFIG_LIBXCB_SHAPE 0 -+#define CONFIG_LIBXCB_XFIXES 0 -+#define CONFIG_LZMA 0 -+#define CONFIG_MEDIAFOUNDATION 0 -+#define CONFIG_SCHANNEL 0 -+#define CONFIG_SDL2 0 -+#define CONFIG_SECURETRANSPORT 0 -+#define CONFIG_SNDIO 0 -+#define CONFIG_XLIB 0 -+#define CONFIG_ZLIB 0 -+#define CONFIG_CUDA_NVCC 0 -+#define CONFIG_CUDA_SDK 0 -+#define CONFIG_LIBNPP 0 -+#define CONFIG_LIBMFX 0 -+#define CONFIG_MMAL 0 -+#define CONFIG_OMX 0 -+#define CONFIG_OPENCL 0 -+#define CONFIG_VULKAN 0 -+#define CONFIG_AMF 0 -+#define CONFIG_AUDIOTOOLBOX 0 -+#define CONFIG_CRYSTALHD 0 -+#define CONFIG_CUDA 0 -+#define CONFIG_CUDA_LLVM 0 -+#define CONFIG_CUVID 0 -+#define CONFIG_D3D11VA 0 -+#define CONFIG_DXVA2 0 -+#define CONFIG_FFNVCODEC 0 -+#define CONFIG_NVDEC 0 -+#define CONFIG_NVENC 0 -+#define CONFIG_VAAPI 0 -+#define CONFIG_VDPAU 0 -+#define CONFIG_VIDEOTOOLBOX 0 -+#define CONFIG_V4L2_M2M 0 -+#define CONFIG_XVMC 0 -+#define CONFIG_FTRAPV 0 -+#define CONFIG_GRAY 0 -+#define CONFIG_HARDCODED_TABLES 0 -+#define CONFIG_OMX_RPI 0 -+#define CONFIG_RUNTIME_CPUDETECT 1 -+#define CONFIG_SAFE_BITSTREAM_READER 1 -+#define CONFIG_SHARED 0 -+#define CONFIG_SMALL 0 -+#define CONFIG_STATIC 1 -+#define CONFIG_SWSCALE_ALPHA 1 -+#define CONFIG_GPL 0 -+#define CONFIG_NONFREE 0 -+#define CONFIG_VERSION3 0 -+#define CONFIG_AVDEVICE 0 -+#define CONFIG_AVFILTER 0 -+#define CONFIG_SWSCALE 0 -+#define CONFIG_POSTPROC 0 -+#define CONFIG_AVFORMAT 1 -+#define CONFIG_AVCODEC 1 -+#define CONFIG_SWRESAMPLE 0 -+#define CONFIG_AVRESAMPLE 0 -+#define CONFIG_AVUTIL 1 -+#define CONFIG_FFPLAY 0 -+#define CONFIG_FFPROBE 0 -+#define CONFIG_FFMPEG 0 -+#define CONFIG_DCT 1 -+#define CONFIG_DWT 0 -+#define CONFIG_ERROR_RESILIENCE 0 -+#define CONFIG_FAAN 0 -+#define CONFIG_FAST_UNALIGNED 0 -+#define CONFIG_FFT 1 -+#define CONFIG_LSP 0 -+#define CONFIG_LZO 0 -+#define CONFIG_MDCT 1 -+#define CONFIG_PIXELUTILS 0 -+#define CONFIG_NETWORK 0 -+#define CONFIG_RDFT 1 -+#define CONFIG_AUTODETECT 0 -+#define CONFIG_FONTCONFIG 0 -+#define CONFIG_LARGE_TESTS 1 -+#define CONFIG_LINUX_PERF 0 -+#define CONFIG_MEMORY_POISONING 0 -+#define CONFIG_NEON_CLOBBER_TEST 0 -+#define CONFIG_OSSFUZZ 0 -+#define CONFIG_PIC 1 -+#define CONFIG_THUMB 0 -+#define CONFIG_VALGRIND_BACKTRACE 0 -+#define CONFIG_XMM_CLOBBER_TEST 0 -+#define CONFIG_BSFS 1 -+#define CONFIG_DECODERS 1 -+#define CONFIG_ENCODERS 0 -+#define CONFIG_HWACCELS 0 -+#define CONFIG_PARSERS 1 -+#define CONFIG_INDEVS 0 -+#define CONFIG_OUTDEVS 0 -+#define CONFIG_FILTERS 0 -+#define CONFIG_DEMUXERS 1 -+#define CONFIG_MUXERS 0 -+#define CONFIG_PROTOCOLS 0 -+#define CONFIG_AANDCTTABLES 0 -+#define CONFIG_AC3DSP 0 -+#define CONFIG_ADTS_HEADER 0 -+#define CONFIG_ATSC_A53 0 -+#define CONFIG_AUDIO_FRAME_QUEUE 0 -+#define CONFIG_AUDIODSP 0 -+#define CONFIG_BLOCKDSP 0 -+#define CONFIG_BSWAPDSP 0 -+#define CONFIG_CABAC 0 -+#define CONFIG_CBS 0 -+#define CONFIG_CBS_AV1 0 -+#define CONFIG_CBS_H264 0 -+#define CONFIG_CBS_H265 0 -+#define CONFIG_CBS_JPEG 0 -+#define CONFIG_CBS_MPEG2 0 -+#define CONFIG_CBS_VP9 0 -+#define CONFIG_DIRAC_PARSE 1 -+#define CONFIG_DNN 0 -+#define CONFIG_DVPROFILE 0 -+#define CONFIG_EXIF 0 -+#define CONFIG_FAANDCT 0 -+#define CONFIG_FAANIDCT 0 -+#define CONFIG_FDCTDSP 0 -+#define CONFIG_FLACDSP 1 -+#define CONFIG_FMTCONVERT 0 -+#define CONFIG_FRAME_THREAD_ENCODER 0 -+#define CONFIG_G722DSP 0 -+#define CONFIG_GOLOMB 1 -+#define CONFIG_GPLV3 0 -+#define CONFIG_H263DSP 0 -+#define CONFIG_H264CHROMA 0 -+#define CONFIG_H264DSP 0 -+#define CONFIG_H264PARSE 0 -+#define CONFIG_H264PRED 1 -+#define CONFIG_H264QPEL 0 -+#define CONFIG_HEVCPARSE 0 -+#define CONFIG_HPELDSP 1 -+#define CONFIG_HUFFMAN 0 -+#define CONFIG_HUFFYUVDSP 0 -+#define CONFIG_HUFFYUVENCDSP 0 -+#define CONFIG_IDCTDSP 0 -+#define CONFIG_IIRFILTER 0 -+#define CONFIG_MDCT15 0 -+#define CONFIG_INTRAX8 0 -+#define CONFIG_ISO_MEDIA 1 -+#define CONFIG_IVIDSP 0 -+#define CONFIG_JPEGTABLES 0 -+#define CONFIG_LGPLV3 0 -+#define CONFIG_LIBX262 0 -+#define CONFIG_LLAUDDSP 0 -+#define CONFIG_LLVIDDSP 0 -+#define CONFIG_LLVIDENCDSP 0 -+#define CONFIG_LPC 0 -+#define CONFIG_LZF 0 -+#define CONFIG_ME_CMP 0 -+#define CONFIG_MPEG_ER 0 -+#define CONFIG_MPEGAUDIO 1 -+#define CONFIG_MPEGAUDIODSP 1 -+#define CONFIG_MPEGAUDIOHEADER 1 -+#define CONFIG_MPEGVIDEO 0 -+#define CONFIG_MPEGVIDEOENC 0 -+#define CONFIG_MSS34DSP 0 -+#define CONFIG_PIXBLOCKDSP 0 -+#define CONFIG_QPELDSP 0 -+#define CONFIG_QSV 0 -+#define CONFIG_QSVDEC 0 -+#define CONFIG_QSVENC 0 -+#define CONFIG_QSVVPP 0 -+#define CONFIG_RANGECODER 0 -+#define CONFIG_RIFFDEC 1 -+#define CONFIG_RIFFENC 0 -+#define CONFIG_RTPDEC 0 -+#define CONFIG_RTPENC_CHAIN 0 -+#define CONFIG_RV34DSP 0 -+#define CONFIG_SCENE_SAD 0 -+#define CONFIG_SINEWIN 0 -+#define CONFIG_SNAPPY 0 -+#define CONFIG_SRTP 0 -+#define CONFIG_STARTCODE 0 -+#define CONFIG_TEXTUREDSP 0 -+#define CONFIG_TEXTUREDSPENC 0 -+#define CONFIG_TPELDSP 0 -+#define CONFIG_VAAPI_1 0 -+#define CONFIG_VAAPI_ENCODE 0 -+#define CONFIG_VC1DSP 0 -+#define CONFIG_VIDEODSP 1 -+#define CONFIG_VP3DSP 1 -+#define CONFIG_VP56DSP 0 -+#define CONFIG_VP8DSP 1 -+#define CONFIG_WMA_FREQS 0 -+#define CONFIG_WMV2DSP 0 -+#define CONFIG_AAC_ADTSTOASC_BSF 0 -+#define CONFIG_AV1_FRAME_MERGE_BSF 0 -+#define CONFIG_AV1_FRAME_SPLIT_BSF 0 -+#define CONFIG_AV1_METADATA_BSF 0 -+#define CONFIG_CHOMP_BSF 0 -+#define CONFIG_DUMP_EXTRADATA_BSF 0 -+#define CONFIG_DCA_CORE_BSF 0 -+#define CONFIG_EAC3_CORE_BSF 0 -+#define CONFIG_EXTRACT_EXTRADATA_BSF 0 -+#define CONFIG_FILTER_UNITS_BSF 0 -+#define CONFIG_H264_METADATA_BSF 0 -+#define CONFIG_H264_MP4TOANNEXB_BSF 0 -+#define CONFIG_H264_REDUNDANT_PPS_BSF 0 -+#define CONFIG_HAPQA_EXTRACT_BSF 0 -+#define CONFIG_HEVC_METADATA_BSF 0 -+#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 -+#define CONFIG_IMX_DUMP_HEADER_BSF 0 -+#define CONFIG_MJPEG2JPEG_BSF 0 -+#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 -+#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 -+#define CONFIG_MPEG2_METADATA_BSF 0 -+#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 -+#define CONFIG_MOV2TEXTSUB_BSF 0 -+#define CONFIG_NOISE_BSF 0 -+#define CONFIG_NULL_BSF 1 -+#define CONFIG_OPUS_METADATA_BSF 0 -+#define CONFIG_PCM_RECHUNK_BSF 0 -+#define CONFIG_PRORES_METADATA_BSF 0 -+#define CONFIG_REMOVE_EXTRADATA_BSF 0 -+#define CONFIG_TEXT2MOVSUB_BSF 0 -+#define CONFIG_TRACE_HEADERS_BSF 0 -+#define CONFIG_TRUEHD_CORE_BSF 0 -+#define CONFIG_VP9_METADATA_BSF 0 -+#define CONFIG_VP9_RAW_REORDER_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_BSF 0 -+#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 -+#define CONFIG_AASC_DECODER 0 -+#define CONFIG_AIC_DECODER 0 -+#define CONFIG_ALIAS_PIX_DECODER 0 -+#define CONFIG_AGM_DECODER 0 -+#define CONFIG_AMV_DECODER 0 -+#define CONFIG_ANM_DECODER 0 -+#define CONFIG_ANSI_DECODER 0 -+#define CONFIG_APNG_DECODER 0 -+#define CONFIG_ARBC_DECODER 0 -+#define CONFIG_ASV1_DECODER 0 -+#define CONFIG_ASV2_DECODER 0 -+#define CONFIG_AURA_DECODER 0 -+#define CONFIG_AURA2_DECODER 0 -+#define CONFIG_AVRP_DECODER 0 -+#define CONFIG_AVRN_DECODER 0 -+#define CONFIG_AVS_DECODER 0 -+#define CONFIG_AVUI_DECODER 0 -+#define CONFIG_AYUV_DECODER 0 -+#define CONFIG_BETHSOFTVID_DECODER 0 -+#define CONFIG_BFI_DECODER 0 -+#define CONFIG_BINK_DECODER 0 -+#define CONFIG_BITPACKED_DECODER 0 -+#define CONFIG_BMP_DECODER 0 -+#define CONFIG_BMV_VIDEO_DECODER 0 -+#define CONFIG_BRENDER_PIX_DECODER 0 -+#define CONFIG_C93_DECODER 0 -+#define CONFIG_CAVS_DECODER 0 -+#define CONFIG_CDGRAPHICS_DECODER 0 -+#define CONFIG_CDTOONS_DECODER 0 -+#define CONFIG_CDXL_DECODER 0 -+#define CONFIG_CFHD_DECODER 0 -+#define CONFIG_CINEPAK_DECODER 0 -+#define CONFIG_CLEARVIDEO_DECODER 0 -+#define CONFIG_CLJR_DECODER 0 -+#define CONFIG_CLLC_DECODER 0 -+#define CONFIG_COMFORTNOISE_DECODER 0 -+#define CONFIG_CPIA_DECODER 0 -+#define CONFIG_CSCD_DECODER 0 -+#define CONFIG_CYUV_DECODER 0 -+#define CONFIG_DDS_DECODER 0 -+#define CONFIG_DFA_DECODER 0 -+#define CONFIG_DIRAC_DECODER 0 -+#define CONFIG_DNXHD_DECODER 0 -+#define CONFIG_DPX_DECODER 0 -+#define CONFIG_DSICINVIDEO_DECODER 0 -+#define CONFIG_DVAUDIO_DECODER 0 -+#define CONFIG_DVVIDEO_DECODER 0 -+#define CONFIG_DXA_DECODER 0 -+#define CONFIG_DXTORY_DECODER 0 -+#define CONFIG_DXV_DECODER 0 -+#define CONFIG_EACMV_DECODER 0 -+#define CONFIG_EAMAD_DECODER 0 -+#define CONFIG_EATGQ_DECODER 0 -+#define CONFIG_EATGV_DECODER 0 -+#define CONFIG_EATQI_DECODER 0 -+#define CONFIG_EIGHTBPS_DECODER 0 -+#define CONFIG_EIGHTSVX_EXP_DECODER 0 -+#define CONFIG_EIGHTSVX_FIB_DECODER 0 -+#define CONFIG_ESCAPE124_DECODER 0 -+#define CONFIG_ESCAPE130_DECODER 0 -+#define CONFIG_EXR_DECODER 0 -+#define CONFIG_FFV1_DECODER 0 -+#define CONFIG_FFVHUFF_DECODER 0 -+#define CONFIG_FIC_DECODER 0 -+#define CONFIG_FITS_DECODER 0 -+#define CONFIG_FLASHSV_DECODER 0 -+#define CONFIG_FLASHSV2_DECODER 0 -+#define CONFIG_FLIC_DECODER 0 -+#define CONFIG_FLV_DECODER 0 -+#define CONFIG_FMVC_DECODER 0 -+#define CONFIG_FOURXM_DECODER 0 -+#define CONFIG_FRAPS_DECODER 0 -+#define CONFIG_FRWU_DECODER 0 -+#define CONFIG_G2M_DECODER 0 -+#define CONFIG_GDV_DECODER 0 -+#define CONFIG_GIF_DECODER 0 -+#define CONFIG_H261_DECODER 0 -+#define CONFIG_H263_DECODER 0 -+#define CONFIG_H263I_DECODER 0 -+#define CONFIG_H263P_DECODER 0 -+#define CONFIG_H263_V4L2M2M_DECODER 0 -+#define CONFIG_H264_DECODER 0 -+#define CONFIG_H264_CRYSTALHD_DECODER 0 -+#define CONFIG_H264_V4L2M2M_DECODER 0 -+#define CONFIG_H264_MEDIACODEC_DECODER 0 -+#define CONFIG_H264_MMAL_DECODER 0 -+#define CONFIG_H264_QSV_DECODER 0 -+#define CONFIG_H264_RKMPP_DECODER 0 -+#define CONFIG_HAP_DECODER 0 -+#define CONFIG_HEVC_DECODER 0 -+#define CONFIG_HEVC_QSV_DECODER 0 -+#define CONFIG_HEVC_RKMPP_DECODER 0 -+#define CONFIG_HEVC_V4L2M2M_DECODER 0 -+#define CONFIG_HNM4_VIDEO_DECODER 0 -+#define CONFIG_HQ_HQA_DECODER 0 -+#define CONFIG_HQX_DECODER 0 -+#define CONFIG_HUFFYUV_DECODER 0 -+#define CONFIG_HYMT_DECODER 0 -+#define CONFIG_IDCIN_DECODER 0 -+#define CONFIG_IFF_ILBM_DECODER 0 -+#define CONFIG_IMM4_DECODER 0 -+#define CONFIG_IMM5_DECODER 0 -+#define CONFIG_INDEO2_DECODER 0 -+#define CONFIG_INDEO3_DECODER 0 -+#define CONFIG_INDEO4_DECODER 0 -+#define CONFIG_INDEO5_DECODER 0 -+#define CONFIG_INTERPLAY_VIDEO_DECODER 0 -+#define CONFIG_JPEG2000_DECODER 0 -+#define CONFIG_JPEGLS_DECODER 0 -+#define CONFIG_JV_DECODER 0 -+#define CONFIG_KGV1_DECODER 0 -+#define CONFIG_KMVC_DECODER 0 -+#define CONFIG_LAGARITH_DECODER 0 -+#define CONFIG_LOCO_DECODER 0 -+#define CONFIG_LSCR_DECODER 0 -+#define CONFIG_M101_DECODER 0 -+#define CONFIG_MAGICYUV_DECODER 0 -+#define CONFIG_MDEC_DECODER 0 -+#define CONFIG_MIMIC_DECODER 0 -+#define CONFIG_MJPEG_DECODER 0 -+#define CONFIG_MJPEGB_DECODER 0 -+#define CONFIG_MMVIDEO_DECODER 0 -+#define CONFIG_MOTIONPIXELS_DECODER 0 -+#define CONFIG_MPEG1VIDEO_DECODER 0 -+#define CONFIG_MPEG2VIDEO_DECODER 0 -+#define CONFIG_MPEG4_DECODER 0 -+#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG4_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG4_MMAL_DECODER 0 -+#define CONFIG_MPEGVIDEO_DECODER 0 -+#define CONFIG_MPEG1_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_MMAL_DECODER 0 -+#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 -+#define CONFIG_MPEG2_V4L2M2M_DECODER 0 -+#define CONFIG_MPEG2_QSV_DECODER 0 -+#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 -+#define CONFIG_MSA1_DECODER 0 -+#define CONFIG_MSCC_DECODER 0 -+#define CONFIG_MSMPEG4V1_DECODER 0 -+#define CONFIG_MSMPEG4V2_DECODER 0 -+#define CONFIG_MSMPEG4V3_DECODER 0 -+#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 -+#define CONFIG_MSRLE_DECODER 0 -+#define CONFIG_MSS1_DECODER 0 -+#define CONFIG_MSS2_DECODER 0 -+#define CONFIG_MSVIDEO1_DECODER 0 -+#define CONFIG_MSZH_DECODER 0 -+#define CONFIG_MTS2_DECODER 0 -+#define CONFIG_MV30_DECODER 0 -+#define CONFIG_MVC1_DECODER 0 -+#define CONFIG_MVC2_DECODER 0 -+#define CONFIG_MVDV_DECODER 0 -+#define CONFIG_MVHA_DECODER 0 -+#define CONFIG_MWSC_DECODER 0 -+#define CONFIG_MXPEG_DECODER 0 -+#define CONFIG_NOTCHLC_DECODER 0 -+#define CONFIG_NUV_DECODER 0 -+#define CONFIG_PAF_VIDEO_DECODER 0 -+#define CONFIG_PAM_DECODER 0 -+#define CONFIG_PBM_DECODER 0 -+#define CONFIG_PCX_DECODER 0 -+#define CONFIG_PFM_DECODER 0 -+#define CONFIG_PGM_DECODER 0 -+#define CONFIG_PGMYUV_DECODER 0 -+#define CONFIG_PGX_DECODER 0 -+#define CONFIG_PICTOR_DECODER 0 -+#define CONFIG_PIXLET_DECODER 0 -+#define CONFIG_PNG_DECODER 0 -+#define CONFIG_PPM_DECODER 0 -+#define CONFIG_PRORES_DECODER 0 -+#define CONFIG_PROSUMER_DECODER 0 -+#define CONFIG_PSD_DECODER 0 -+#define CONFIG_PTX_DECODER 0 -+#define CONFIG_QDRAW_DECODER 0 -+#define CONFIG_QPEG_DECODER 0 -+#define CONFIG_QTRLE_DECODER 0 -+#define CONFIG_R10K_DECODER 0 -+#define CONFIG_R210_DECODER 0 -+#define CONFIG_RASC_DECODER 0 -+#define CONFIG_RAWVIDEO_DECODER 0 -+#define CONFIG_RL2_DECODER 0 -+#define CONFIG_ROQ_DECODER 0 -+#define CONFIG_RPZA_DECODER 0 -+#define CONFIG_RSCC_DECODER 0 -+#define CONFIG_RV10_DECODER 0 -+#define CONFIG_RV20_DECODER 0 -+#define CONFIG_RV30_DECODER 0 -+#define CONFIG_RV40_DECODER 0 -+#define CONFIG_S302M_DECODER 0 -+#define CONFIG_SANM_DECODER 0 -+#define CONFIG_SCPR_DECODER 0 -+#define CONFIG_SCREENPRESSO_DECODER 0 -+#define CONFIG_SGI_DECODER 0 -+#define CONFIG_SGIRLE_DECODER 0 -+#define CONFIG_SHEERVIDEO_DECODER 0 -+#define CONFIG_SMACKER_DECODER 0 -+#define CONFIG_SMC_DECODER 0 -+#define CONFIG_SMVJPEG_DECODER 0 -+#define CONFIG_SNOW_DECODER 0 -+#define CONFIG_SP5X_DECODER 0 -+#define CONFIG_SPEEDHQ_DECODER 0 -+#define CONFIG_SRGC_DECODER 0 -+#define CONFIG_SUNRAST_DECODER 0 -+#define CONFIG_SVQ1_DECODER 0 -+#define CONFIG_SVQ3_DECODER 0 -+#define CONFIG_TARGA_DECODER 0 -+#define CONFIG_TARGA_Y216_DECODER 0 -+#define CONFIG_TDSC_DECODER 0 -+#define CONFIG_THEORA_DECODER 1 -+#define CONFIG_THP_DECODER 0 -+#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 -+#define CONFIG_TIFF_DECODER 0 -+#define CONFIG_TMV_DECODER 0 -+#define CONFIG_TRUEMOTION1_DECODER 0 -+#define CONFIG_TRUEMOTION2_DECODER 0 -+#define CONFIG_TRUEMOTION2RT_DECODER 0 -+#define CONFIG_TSCC_DECODER 0 -+#define CONFIG_TSCC2_DECODER 0 -+#define CONFIG_TXD_DECODER 0 -+#define CONFIG_ULTI_DECODER 0 -+#define CONFIG_UTVIDEO_DECODER 0 -+#define CONFIG_V210_DECODER 0 -+#define CONFIG_V210X_DECODER 0 -+#define CONFIG_V308_DECODER 0 -+#define CONFIG_V408_DECODER 0 -+#define CONFIG_V410_DECODER 0 -+#define CONFIG_VB_DECODER 0 -+#define CONFIG_VBLE_DECODER 0 -+#define CONFIG_VC1_DECODER 0 -+#define CONFIG_VC1_CRYSTALHD_DECODER 0 -+#define CONFIG_VC1IMAGE_DECODER 0 -+#define CONFIG_VC1_MMAL_DECODER 0 -+#define CONFIG_VC1_QSV_DECODER 0 -+#define CONFIG_VC1_V4L2M2M_DECODER 0 -+#define CONFIG_VCR1_DECODER 0 -+#define CONFIG_VMDVIDEO_DECODER 0 -+#define CONFIG_VMNC_DECODER 0 -+#define CONFIG_VP3_DECODER 1 -+#define CONFIG_VP4_DECODER 0 -+#define CONFIG_VP5_DECODER 0 -+#define CONFIG_VP6_DECODER 0 -+#define CONFIG_VP6A_DECODER 0 -+#define CONFIG_VP6F_DECODER 0 -+#define CONFIG_VP7_DECODER 0 -+#define CONFIG_VP8_DECODER 1 -+#define CONFIG_VP8_RKMPP_DECODER 0 -+#define CONFIG_VP8_V4L2M2M_DECODER 0 -+#define CONFIG_VP9_DECODER 0 -+#define CONFIG_VP9_RKMPP_DECODER 0 -+#define CONFIG_VP9_V4L2M2M_DECODER 0 -+#define CONFIG_VQA_DECODER 0 -+#define CONFIG_WEBP_DECODER 0 -+#define CONFIG_WCMV_DECODER 0 -+#define CONFIG_WRAPPED_AVFRAME_DECODER 0 -+#define CONFIG_WMV1_DECODER 0 -+#define CONFIG_WMV2_DECODER 0 -+#define CONFIG_WMV3_DECODER 0 -+#define CONFIG_WMV3_CRYSTALHD_DECODER 0 -+#define CONFIG_WMV3IMAGE_DECODER 0 -+#define CONFIG_WNV1_DECODER 0 -+#define CONFIG_XAN_WC3_DECODER 0 -+#define CONFIG_XAN_WC4_DECODER 0 -+#define CONFIG_XBM_DECODER 0 -+#define CONFIG_XFACE_DECODER 0 -+#define CONFIG_XL_DECODER 0 -+#define CONFIG_XPM_DECODER 0 -+#define CONFIG_XWD_DECODER 0 -+#define CONFIG_Y41P_DECODER 0 -+#define CONFIG_YLC_DECODER 0 -+#define CONFIG_YOP_DECODER 0 -+#define CONFIG_YUV4_DECODER 0 -+#define CONFIG_ZERO12V_DECODER 0 -+#define CONFIG_ZEROCODEC_DECODER 0 -+#define CONFIG_ZLIB_DECODER 0 -+#define CONFIG_ZMBV_DECODER 0 -+#define CONFIG_AAC_DECODER 0 -+#define CONFIG_AAC_FIXED_DECODER 0 -+#define CONFIG_AAC_LATM_DECODER 0 -+#define CONFIG_AC3_DECODER 0 -+#define CONFIG_AC3_FIXED_DECODER 0 -+#define CONFIG_ACELP_KELVIN_DECODER 0 -+#define CONFIG_ALAC_DECODER 0 -+#define CONFIG_ALS_DECODER 0 -+#define CONFIG_AMRNB_DECODER 0 -+#define CONFIG_AMRWB_DECODER 0 -+#define CONFIG_APE_DECODER 0 -+#define CONFIG_APTX_DECODER 0 -+#define CONFIG_APTX_HD_DECODER 0 -+#define CONFIG_ATRAC1_DECODER 0 -+#define CONFIG_ATRAC3_DECODER 0 -+#define CONFIG_ATRAC3AL_DECODER 0 -+#define CONFIG_ATRAC3P_DECODER 0 -+#define CONFIG_ATRAC3PAL_DECODER 0 -+#define CONFIG_ATRAC9_DECODER 0 -+#define CONFIG_BINKAUDIO_DCT_DECODER 0 -+#define CONFIG_BINKAUDIO_RDFT_DECODER 0 -+#define CONFIG_BMV_AUDIO_DECODER 0 -+#define CONFIG_COOK_DECODER 0 -+#define CONFIG_DCA_DECODER 0 -+#define CONFIG_DOLBY_E_DECODER 0 -+#define CONFIG_DSD_LSBF_DECODER 0 -+#define CONFIG_DSD_MSBF_DECODER 0 -+#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 -+#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 -+#define CONFIG_DSICINAUDIO_DECODER 0 -+#define CONFIG_DSS_SP_DECODER 0 -+#define CONFIG_DST_DECODER 0 -+#define CONFIG_EAC3_DECODER 0 -+#define CONFIG_EVRC_DECODER 0 -+#define CONFIG_FFWAVESYNTH_DECODER 0 -+#define CONFIG_FLAC_DECODER 1 -+#define CONFIG_G723_1_DECODER 0 -+#define CONFIG_G729_DECODER 0 -+#define CONFIG_GSM_DECODER 0 -+#define CONFIG_GSM_MS_DECODER 0 -+#define CONFIG_HCA_DECODER 0 -+#define CONFIG_HCOM_DECODER 0 -+#define CONFIG_IAC_DECODER 0 -+#define CONFIG_ILBC_DECODER 0 -+#define CONFIG_IMC_DECODER 0 -+#define CONFIG_INTERPLAY_ACM_DECODER 0 -+#define CONFIG_MACE3_DECODER 0 -+#define CONFIG_MACE6_DECODER 0 -+#define CONFIG_METASOUND_DECODER 0 -+#define CONFIG_MLP_DECODER 0 -+#define CONFIG_MP1_DECODER 0 -+#define CONFIG_MP1FLOAT_DECODER 0 -+#define CONFIG_MP2_DECODER 0 -+#define CONFIG_MP2FLOAT_DECODER 0 -+#define CONFIG_MP3FLOAT_DECODER 0 -+#define CONFIG_MP3_DECODER 1 -+#define CONFIG_MP3ADUFLOAT_DECODER 0 -+#define CONFIG_MP3ADU_DECODER 0 -+#define CONFIG_MP3ON4FLOAT_DECODER 0 -+#define CONFIG_MP3ON4_DECODER 0 -+#define CONFIG_MPC7_DECODER 0 -+#define CONFIG_MPC8_DECODER 0 -+#define CONFIG_NELLYMOSER_DECODER 0 -+#define CONFIG_ON2AVC_DECODER 0 -+#define CONFIG_OPUS_DECODER 0 -+#define CONFIG_PAF_AUDIO_DECODER 0 -+#define CONFIG_QCELP_DECODER 0 -+#define CONFIG_QDM2_DECODER 0 -+#define CONFIG_QDMC_DECODER 0 -+#define CONFIG_RA_144_DECODER 0 -+#define CONFIG_RA_288_DECODER 0 -+#define CONFIG_RALF_DECODER 0 -+#define CONFIG_SBC_DECODER 0 -+#define CONFIG_SHORTEN_DECODER 0 -+#define CONFIG_SIPR_DECODER 0 -+#define CONFIG_SIREN_DECODER 0 -+#define CONFIG_SMACKAUD_DECODER 0 -+#define CONFIG_SONIC_DECODER 0 -+#define CONFIG_TAK_DECODER 0 -+#define CONFIG_TRUEHD_DECODER 0 -+#define CONFIG_TRUESPEECH_DECODER 0 -+#define CONFIG_TTA_DECODER 0 -+#define CONFIG_TWINVQ_DECODER 0 -+#define CONFIG_VMDAUDIO_DECODER 0 -+#define CONFIG_VORBIS_DECODER 1 -+#define CONFIG_WAVPACK_DECODER 0 -+#define CONFIG_WMALOSSLESS_DECODER 0 -+#define CONFIG_WMAPRO_DECODER 0 -+#define CONFIG_WMAV1_DECODER 0 -+#define CONFIG_WMAV2_DECODER 0 -+#define CONFIG_WMAVOICE_DECODER 0 -+#define CONFIG_WS_SND1_DECODER 0 -+#define CONFIG_XMA1_DECODER 0 -+#define CONFIG_XMA2_DECODER 0 -+#define CONFIG_PCM_ALAW_DECODER 1 -+#define CONFIG_PCM_BLURAY_DECODER 0 -+#define CONFIG_PCM_DVD_DECODER 0 -+#define CONFIG_PCM_F16LE_DECODER 0 -+#define CONFIG_PCM_F24LE_DECODER 0 -+#define CONFIG_PCM_F32BE_DECODER 0 -+#define CONFIG_PCM_F32LE_DECODER 1 -+#define CONFIG_PCM_F64BE_DECODER 0 -+#define CONFIG_PCM_F64LE_DECODER 0 -+#define CONFIG_PCM_LXF_DECODER 0 -+#define CONFIG_PCM_MULAW_DECODER 1 -+#define CONFIG_PCM_S8_DECODER 0 -+#define CONFIG_PCM_S8_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16BE_DECODER 1 -+#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S16LE_DECODER 1 -+#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S24BE_DECODER 1 -+#define CONFIG_PCM_S24DAUD_DECODER 0 -+#define CONFIG_PCM_S24LE_DECODER 1 -+#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S32BE_DECODER 0 -+#define CONFIG_PCM_S32LE_DECODER 1 -+#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 -+#define CONFIG_PCM_S64BE_DECODER 0 -+#define CONFIG_PCM_S64LE_DECODER 0 -+#define CONFIG_PCM_U8_DECODER 1 -+#define CONFIG_PCM_U16BE_DECODER 0 -+#define CONFIG_PCM_U16LE_DECODER 0 -+#define CONFIG_PCM_U24BE_DECODER 0 -+#define CONFIG_PCM_U24LE_DECODER 0 -+#define CONFIG_PCM_U32BE_DECODER 0 -+#define CONFIG_PCM_U32LE_DECODER 0 -+#define CONFIG_PCM_VIDC_DECODER 0 -+#define CONFIG_DERF_DPCM_DECODER 0 -+#define CONFIG_GREMLIN_DPCM_DECODER 0 -+#define CONFIG_INTERPLAY_DPCM_DECODER 0 -+#define CONFIG_ROQ_DPCM_DECODER 0 -+#define CONFIG_SDX2_DPCM_DECODER 0 -+#define CONFIG_SOL_DPCM_DECODER 0 -+#define CONFIG_XAN_DPCM_DECODER 0 -+#define CONFIG_ADPCM_4XM_DECODER 0 -+#define CONFIG_ADPCM_ADX_DECODER 0 -+#define CONFIG_ADPCM_AFC_DECODER 0 -+#define CONFIG_ADPCM_AGM_DECODER 0 -+#define CONFIG_ADPCM_AICA_DECODER 0 -+#define CONFIG_ADPCM_ARGO_DECODER 0 -+#define CONFIG_ADPCM_CT_DECODER 0 -+#define CONFIG_ADPCM_DTK_DECODER 0 -+#define CONFIG_ADPCM_EA_DECODER 0 -+#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 -+#define CONFIG_ADPCM_EA_R1_DECODER 0 -+#define CONFIG_ADPCM_EA_R2_DECODER 0 -+#define CONFIG_ADPCM_EA_R3_DECODER 0 -+#define CONFIG_ADPCM_EA_XAS_DECODER 0 -+#define CONFIG_ADPCM_G722_DECODER 0 -+#define CONFIG_ADPCM_G726_DECODER 0 -+#define CONFIG_ADPCM_G726LE_DECODER 0 -+#define CONFIG_ADPCM_IMA_AMV_DECODER 0 -+#define CONFIG_ADPCM_IMA_ALP_DECODER 0 -+#define CONFIG_ADPCM_IMA_APC_DECODER 0 -+#define CONFIG_ADPCM_IMA_APM_DECODER 0 -+#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 -+#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK3_DECODER 0 -+#define CONFIG_ADPCM_IMA_DK4_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 -+#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_ISS_DECODER 0 -+#define CONFIG_ADPCM_IMA_MTF_DECODER 0 -+#define CONFIG_ADPCM_IMA_OKI_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_DECODER 0 -+#define CONFIG_ADPCM_IMA_RAD_DECODER 0 -+#define CONFIG_ADPCM_IMA_SSI_DECODER 0 -+#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 -+#define CONFIG_ADPCM_IMA_WAV_DECODER 0 -+#define CONFIG_ADPCM_IMA_WS_DECODER 0 -+#define CONFIG_ADPCM_MS_DECODER 0 -+#define CONFIG_ADPCM_MTAF_DECODER 0 -+#define CONFIG_ADPCM_PSX_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_2_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_3_DECODER 0 -+#define CONFIG_ADPCM_SBPRO_4_DECODER 0 -+#define CONFIG_ADPCM_SWF_DECODER 0 -+#define CONFIG_ADPCM_THP_DECODER 0 -+#define CONFIG_ADPCM_THP_LE_DECODER 0 -+#define CONFIG_ADPCM_VIMA_DECODER 0 -+#define CONFIG_ADPCM_XA_DECODER 0 -+#define CONFIG_ADPCM_YAMAHA_DECODER 0 -+#define CONFIG_ADPCM_ZORK_DECODER 0 -+#define CONFIG_SSA_DECODER 0 -+#define CONFIG_ASS_DECODER 0 -+#define CONFIG_CCAPTION_DECODER 0 -+#define CONFIG_DVBSUB_DECODER 0 -+#define CONFIG_DVDSUB_DECODER 0 -+#define CONFIG_JACOSUB_DECODER 0 -+#define CONFIG_MICRODVD_DECODER 0 -+#define CONFIG_MOVTEXT_DECODER 0 -+#define CONFIG_MPL2_DECODER 0 -+#define CONFIG_PGSSUB_DECODER 0 -+#define CONFIG_PJS_DECODER 0 -+#define CONFIG_REALTEXT_DECODER 0 -+#define CONFIG_SAMI_DECODER 0 -+#define CONFIG_SRT_DECODER 0 -+#define CONFIG_STL_DECODER 0 -+#define CONFIG_SUBRIP_DECODER 0 -+#define CONFIG_SUBVIEWER_DECODER 0 -+#define CONFIG_SUBVIEWER1_DECODER 0 -+#define CONFIG_TEXT_DECODER 0 -+#define CONFIG_VPLAYER_DECODER 0 -+#define CONFIG_WEBVTT_DECODER 0 -+#define CONFIG_XSUB_DECODER 0 -+#define CONFIG_AAC_AT_DECODER 0 -+#define CONFIG_AC3_AT_DECODER 0 -+#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 -+#define CONFIG_ALAC_AT_DECODER 0 -+#define CONFIG_AMR_NB_AT_DECODER 0 -+#define CONFIG_EAC3_AT_DECODER 0 -+#define CONFIG_GSM_MS_AT_DECODER 0 -+#define CONFIG_ILBC_AT_DECODER 0 -+#define CONFIG_MP1_AT_DECODER 0 -+#define CONFIG_MP2_AT_DECODER 0 -+#define CONFIG_MP3_AT_DECODER 0 -+#define CONFIG_PCM_ALAW_AT_DECODER 0 -+#define CONFIG_PCM_MULAW_AT_DECODER 0 -+#define CONFIG_QDMC_AT_DECODER 0 -+#define CONFIG_QDM2_AT_DECODER 0 -+#define CONFIG_LIBARIBB24_DECODER 0 -+#define CONFIG_LIBCELT_DECODER 0 -+#define CONFIG_LIBCODEC2_DECODER 0 -+#define CONFIG_LIBDAV1D_DECODER 0 -+#define CONFIG_LIBDAVS2_DECODER 0 -+#define CONFIG_LIBFDK_AAC_DECODER 0 -+#define CONFIG_LIBGSM_DECODER 0 -+#define CONFIG_LIBGSM_MS_DECODER 0 -+#define CONFIG_LIBILBC_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 -+#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 -+#define CONFIG_LIBOPENJPEG_DECODER 0 -+#define CONFIG_LIBOPUS_DECODER 1 -+#define CONFIG_LIBRSVG_DECODER 0 -+#define CONFIG_LIBSPEEX_DECODER 0 -+#define CONFIG_LIBVORBIS_DECODER 0 -+#define CONFIG_LIBVPX_VP8_DECODER 0 -+#define CONFIG_LIBVPX_VP9_DECODER 0 -+#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 -+#define CONFIG_BINTEXT_DECODER 0 -+#define CONFIG_XBIN_DECODER 0 -+#define CONFIG_IDF_DECODER 0 -+#define CONFIG_LIBAOM_AV1_DECODER 0 -+#define CONFIG_LIBOPENH264_DECODER 0 -+#define CONFIG_H264_CUVID_DECODER 0 -+#define CONFIG_HEVC_CUVID_DECODER 0 -+#define CONFIG_HEVC_MEDIACODEC_DECODER 0 -+#define CONFIG_MJPEG_CUVID_DECODER 0 -+#define CONFIG_MJPEG_QSV_DECODER 0 -+#define CONFIG_MPEG1_CUVID_DECODER 0 -+#define CONFIG_MPEG2_CUVID_DECODER 0 -+#define CONFIG_MPEG4_CUVID_DECODER 0 -+#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 -+#define CONFIG_VC1_CUVID_DECODER 0 -+#define CONFIG_VP8_CUVID_DECODER 0 -+#define CONFIG_VP8_MEDIACODEC_DECODER 0 -+#define CONFIG_VP8_QSV_DECODER 0 -+#define CONFIG_VP9_CUVID_DECODER 0 -+#define CONFIG_VP9_MEDIACODEC_DECODER 0 -+#define CONFIG_VP9_QSV_DECODER 0 -+#define CONFIG_A64MULTI_ENCODER 0 -+#define CONFIG_A64MULTI5_ENCODER 0 -+#define CONFIG_ALIAS_PIX_ENCODER 0 -+#define CONFIG_AMV_ENCODER 0 -+#define CONFIG_APNG_ENCODER 0 -+#define CONFIG_ASV1_ENCODER 0 -+#define CONFIG_ASV2_ENCODER 0 -+#define CONFIG_AVRP_ENCODER 0 -+#define CONFIG_AVUI_ENCODER 0 -+#define CONFIG_AYUV_ENCODER 0 -+#define CONFIG_BMP_ENCODER 0 -+#define CONFIG_CFHD_ENCODER 0 -+#define CONFIG_CINEPAK_ENCODER 0 -+#define CONFIG_CLJR_ENCODER 0 -+#define CONFIG_COMFORTNOISE_ENCODER 0 -+#define CONFIG_DNXHD_ENCODER 0 -+#define CONFIG_DPX_ENCODER 0 -+#define CONFIG_DVVIDEO_ENCODER 0 -+#define CONFIG_FFV1_ENCODER 0 -+#define CONFIG_FFVHUFF_ENCODER 0 -+#define CONFIG_FITS_ENCODER 0 -+#define CONFIG_FLASHSV_ENCODER 0 -+#define CONFIG_FLASHSV2_ENCODER 0 -+#define CONFIG_FLV_ENCODER 0 -+#define CONFIG_GIF_ENCODER 0 -+#define CONFIG_H261_ENCODER 0 -+#define CONFIG_H263_ENCODER 0 -+#define CONFIG_H263P_ENCODER 0 -+#define CONFIG_HAP_ENCODER 0 -+#define CONFIG_HUFFYUV_ENCODER 0 -+#define CONFIG_JPEG2000_ENCODER 0 -+#define CONFIG_JPEGLS_ENCODER 0 -+#define CONFIG_LJPEG_ENCODER 0 -+#define CONFIG_MAGICYUV_ENCODER 0 -+#define CONFIG_MJPEG_ENCODER 0 -+#define CONFIG_MPEG1VIDEO_ENCODER 0 -+#define CONFIG_MPEG2VIDEO_ENCODER 0 -+#define CONFIG_MPEG4_ENCODER 0 -+#define CONFIG_MSMPEG4V2_ENCODER 0 -+#define CONFIG_MSMPEG4V3_ENCODER 0 -+#define CONFIG_MSVIDEO1_ENCODER 0 -+#define CONFIG_PAM_ENCODER 0 -+#define CONFIG_PBM_ENCODER 0 -+#define CONFIG_PCX_ENCODER 0 -+#define CONFIG_PGM_ENCODER 0 -+#define CONFIG_PGMYUV_ENCODER 0 -+#define CONFIG_PNG_ENCODER 0 -+#define CONFIG_PPM_ENCODER 0 -+#define CONFIG_PRORES_ENCODER 0 -+#define CONFIG_PRORES_AW_ENCODER 0 -+#define CONFIG_PRORES_KS_ENCODER 0 -+#define CONFIG_QTRLE_ENCODER 0 -+#define CONFIG_R10K_ENCODER 0 -+#define CONFIG_R210_ENCODER 0 -+#define CONFIG_RAWVIDEO_ENCODER 0 -+#define CONFIG_ROQ_ENCODER 0 -+#define CONFIG_RPZA_ENCODER 0 -+#define CONFIG_RV10_ENCODER 0 -+#define CONFIG_RV20_ENCODER 0 -+#define CONFIG_S302M_ENCODER 0 -+#define CONFIG_SGI_ENCODER 0 -+#define CONFIG_SNOW_ENCODER 0 -+#define CONFIG_SUNRAST_ENCODER 0 -+#define CONFIG_SVQ1_ENCODER 0 -+#define CONFIG_TARGA_ENCODER 0 -+#define CONFIG_TIFF_ENCODER 0 -+#define CONFIG_UTVIDEO_ENCODER 0 -+#define CONFIG_V210_ENCODER 0 -+#define CONFIG_V308_ENCODER 0 -+#define CONFIG_V408_ENCODER 0 -+#define CONFIG_V410_ENCODER 0 -+#define CONFIG_VC2_ENCODER 0 -+#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 -+#define CONFIG_WMV1_ENCODER 0 -+#define CONFIG_WMV2_ENCODER 0 -+#define CONFIG_XBM_ENCODER 0 -+#define CONFIG_XFACE_ENCODER 0 -+#define CONFIG_XWD_ENCODER 0 -+#define CONFIG_Y41P_ENCODER 0 -+#define CONFIG_YUV4_ENCODER 0 -+#define CONFIG_ZLIB_ENCODER 0 -+#define CONFIG_ZMBV_ENCODER 0 -+#define CONFIG_AAC_ENCODER 0 -+#define CONFIG_AC3_ENCODER 0 -+#define CONFIG_AC3_FIXED_ENCODER 0 -+#define CONFIG_ALAC_ENCODER 0 -+#define CONFIG_APTX_ENCODER 0 -+#define CONFIG_APTX_HD_ENCODER 0 -+#define CONFIG_DCA_ENCODER 0 -+#define CONFIG_EAC3_ENCODER 0 -+#define CONFIG_FLAC_ENCODER 0 -+#define CONFIG_G723_1_ENCODER 0 -+#define CONFIG_MLP_ENCODER 0 -+#define CONFIG_MP2_ENCODER 0 -+#define CONFIG_MP2FIXED_ENCODER 0 -+#define CONFIG_NELLYMOSER_ENCODER 0 -+#define CONFIG_OPUS_ENCODER 0 -+#define CONFIG_RA_144_ENCODER 0 -+#define CONFIG_SBC_ENCODER 0 -+#define CONFIG_SONIC_ENCODER 0 -+#define CONFIG_SONIC_LS_ENCODER 0 -+#define CONFIG_TRUEHD_ENCODER 0 -+#define CONFIG_TTA_ENCODER 0 -+#define CONFIG_VORBIS_ENCODER 0 -+#define CONFIG_WAVPACK_ENCODER 0 -+#define CONFIG_WMAV1_ENCODER 0 -+#define CONFIG_WMAV2_ENCODER 0 -+#define CONFIG_PCM_ALAW_ENCODER 0 -+#define CONFIG_PCM_DVD_ENCODER 0 -+#define CONFIG_PCM_F32BE_ENCODER 0 -+#define CONFIG_PCM_F32LE_ENCODER 0 -+#define CONFIG_PCM_F64BE_ENCODER 0 -+#define CONFIG_PCM_F64LE_ENCODER 0 -+#define CONFIG_PCM_MULAW_ENCODER 0 -+#define CONFIG_PCM_S8_ENCODER 0 -+#define CONFIG_PCM_S8_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16BE_ENCODER 0 -+#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S16LE_ENCODER 0 -+#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S24BE_ENCODER 0 -+#define CONFIG_PCM_S24DAUD_ENCODER 0 -+#define CONFIG_PCM_S24LE_ENCODER 0 -+#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S32BE_ENCODER 0 -+#define CONFIG_PCM_S32LE_ENCODER 0 -+#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 -+#define CONFIG_PCM_S64BE_ENCODER 0 -+#define CONFIG_PCM_S64LE_ENCODER 0 -+#define CONFIG_PCM_U8_ENCODER 0 -+#define CONFIG_PCM_U16BE_ENCODER 0 -+#define CONFIG_PCM_U16LE_ENCODER 0 -+#define CONFIG_PCM_U24BE_ENCODER 0 -+#define CONFIG_PCM_U24LE_ENCODER 0 -+#define CONFIG_PCM_U32BE_ENCODER 0 -+#define CONFIG_PCM_U32LE_ENCODER 0 -+#define CONFIG_PCM_VIDC_ENCODER 0 -+#define CONFIG_ROQ_DPCM_ENCODER 0 -+#define CONFIG_ADPCM_ADX_ENCODER 0 -+#define CONFIG_ADPCM_ARGO_ENCODER 0 -+#define CONFIG_ADPCM_G722_ENCODER 0 -+#define CONFIG_ADPCM_G726_ENCODER 0 -+#define CONFIG_ADPCM_G726LE_ENCODER 0 -+#define CONFIG_ADPCM_IMA_APM_ENCODER 0 -+#define CONFIG_ADPCM_IMA_QT_ENCODER 0 -+#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 -+#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 -+#define CONFIG_ADPCM_MS_ENCODER 0 -+#define CONFIG_ADPCM_SWF_ENCODER 0 -+#define CONFIG_ADPCM_YAMAHA_ENCODER 0 -+#define CONFIG_SSA_ENCODER 0 -+#define CONFIG_ASS_ENCODER 0 -+#define CONFIG_DVBSUB_ENCODER 0 -+#define CONFIG_DVDSUB_ENCODER 0 -+#define CONFIG_MOVTEXT_ENCODER 0 -+#define CONFIG_SRT_ENCODER 0 -+#define CONFIG_SUBRIP_ENCODER 0 -+#define CONFIG_TEXT_ENCODER 0 -+#define CONFIG_WEBVTT_ENCODER 0 -+#define CONFIG_XSUB_ENCODER 0 -+#define CONFIG_AAC_AT_ENCODER 0 -+#define CONFIG_ALAC_AT_ENCODER 0 -+#define CONFIG_ILBC_AT_ENCODER 0 -+#define CONFIG_PCM_ALAW_AT_ENCODER 0 -+#define CONFIG_PCM_MULAW_AT_ENCODER 0 -+#define CONFIG_LIBAOM_AV1_ENCODER 0 -+#define CONFIG_LIBCODEC2_ENCODER 0 -+#define CONFIG_LIBFDK_AAC_ENCODER 0 -+#define CONFIG_LIBGSM_ENCODER 0 -+#define CONFIG_LIBGSM_MS_ENCODER 0 -+#define CONFIG_LIBILBC_ENCODER 0 -+#define CONFIG_LIBMP3LAME_ENCODER 0 -+#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 -+#define CONFIG_LIBOPENJPEG_ENCODER 0 -+#define CONFIG_LIBOPUS_ENCODER 0 -+#define CONFIG_LIBRAV1E_ENCODER 0 -+#define CONFIG_LIBSHINE_ENCODER 0 -+#define CONFIG_LIBSPEEX_ENCODER 0 -+#define CONFIG_LIBSVTAV1_ENCODER 0 -+#define CONFIG_LIBTHEORA_ENCODER 0 -+#define CONFIG_LIBTWOLAME_ENCODER 0 -+#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 -+#define CONFIG_LIBVORBIS_ENCODER 0 -+#define CONFIG_LIBVPX_VP8_ENCODER 0 -+#define CONFIG_LIBVPX_VP9_ENCODER 0 -+#define CONFIG_LIBWAVPACK_ENCODER 0 -+#define CONFIG_LIBWEBP_ANIM_ENCODER 0 -+#define CONFIG_LIBWEBP_ENCODER 0 -+#define CONFIG_LIBX262_ENCODER 0 -+#define CONFIG_LIBX264_ENCODER 0 -+#define CONFIG_LIBX264RGB_ENCODER 0 -+#define CONFIG_LIBX265_ENCODER 0 -+#define CONFIG_LIBXAVS_ENCODER 0 -+#define CONFIG_LIBXAVS2_ENCODER 0 -+#define CONFIG_LIBXVID_ENCODER 0 -+#define CONFIG_AAC_MF_ENCODER 0 -+#define CONFIG_AC3_MF_ENCODER 0 -+#define CONFIG_H263_V4L2M2M_ENCODER 0 -+#define CONFIG_LIBOPENH264_ENCODER 0 -+#define CONFIG_H264_AMF_ENCODER 0 -+#define CONFIG_H264_MF_ENCODER 0 -+#define CONFIG_H264_NVENC_ENCODER 0 -+#define CONFIG_H264_OMX_ENCODER 0 -+#define CONFIG_H264_QSV_ENCODER 0 -+#define CONFIG_H264_V4L2M2M_ENCODER 0 -+#define CONFIG_H264_VAAPI_ENCODER 0 -+#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_NVENC_ENCODER 0 -+#define CONFIG_NVENC_H264_ENCODER 0 -+#define CONFIG_NVENC_HEVC_ENCODER 0 -+#define CONFIG_HEVC_AMF_ENCODER 0 -+#define CONFIG_HEVC_MF_ENCODER 0 -+#define CONFIG_HEVC_NVENC_ENCODER 0 -+#define CONFIG_HEVC_QSV_ENCODER 0 -+#define CONFIG_HEVC_V4L2M2M_ENCODER 0 -+#define CONFIG_HEVC_VAAPI_ENCODER 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 -+#define CONFIG_LIBKVAZAAR_ENCODER 0 -+#define CONFIG_MJPEG_QSV_ENCODER 0 -+#define CONFIG_MJPEG_VAAPI_ENCODER 0 -+#define CONFIG_MP3_MF_ENCODER 0 -+#define CONFIG_MPEG2_QSV_ENCODER 0 -+#define CONFIG_MPEG2_VAAPI_ENCODER 0 -+#define CONFIG_MPEG4_OMX_ENCODER 0 -+#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_V4L2M2M_ENCODER 0 -+#define CONFIG_VP8_VAAPI_ENCODER 0 -+#define CONFIG_VP9_VAAPI_ENCODER 0 -+#define CONFIG_VP9_QSV_ENCODER 0 -+#define CONFIG_H263_VAAPI_HWACCEL 0 -+#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_H264_D3D11VA_HWACCEL 0 -+#define CONFIG_H264_D3D11VA2_HWACCEL 0 -+#define CONFIG_H264_DXVA2_HWACCEL 0 -+#define CONFIG_H264_NVDEC_HWACCEL 0 -+#define CONFIG_H264_VAAPI_HWACCEL 0 -+#define CONFIG_H264_VDPAU_HWACCEL 0 -+#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA_HWACCEL 0 -+#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 -+#define CONFIG_HEVC_DXVA2_HWACCEL 0 -+#define CONFIG_HEVC_NVDEC_HWACCEL 0 -+#define CONFIG_HEVC_VAAPI_HWACCEL 0 -+#define CONFIG_HEVC_VDPAU_HWACCEL 0 -+#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MJPEG_NVDEC_HWACCEL 0 -+#define CONFIG_MJPEG_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG1_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG1_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG1_XVMC_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 -+#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 -+#define CONFIG_MPEG2_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG2_DXVA2_HWACCEL 0 -+#define CONFIG_MPEG2_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG2_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_MPEG2_XVMC_HWACCEL 0 -+#define CONFIG_MPEG4_NVDEC_HWACCEL 0 -+#define CONFIG_MPEG4_VAAPI_HWACCEL 0 -+#define CONFIG_MPEG4_VDPAU_HWACCEL 0 -+#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA_HWACCEL 0 -+#define CONFIG_VC1_D3D11VA2_HWACCEL 0 -+#define CONFIG_VC1_DXVA2_HWACCEL 0 -+#define CONFIG_VC1_NVDEC_HWACCEL 0 -+#define CONFIG_VC1_VAAPI_HWACCEL 0 -+#define CONFIG_VC1_VDPAU_HWACCEL 0 -+#define CONFIG_VP8_NVDEC_HWACCEL 0 -+#define CONFIG_VP8_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA_HWACCEL 0 -+#define CONFIG_VP9_D3D11VA2_HWACCEL 0 -+#define CONFIG_VP9_DXVA2_HWACCEL 0 -+#define CONFIG_VP9_NVDEC_HWACCEL 0 -+#define CONFIG_VP9_VAAPI_HWACCEL 0 -+#define CONFIG_VP9_VDPAU_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA_HWACCEL 0 -+#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 -+#define CONFIG_WMV3_DXVA2_HWACCEL 0 -+#define CONFIG_WMV3_NVDEC_HWACCEL 0 -+#define CONFIG_WMV3_VAAPI_HWACCEL 0 -+#define CONFIG_WMV3_VDPAU_HWACCEL 0 -+#define CONFIG_AAC_PARSER 0 -+#define CONFIG_AAC_LATM_PARSER 0 -+#define CONFIG_AC3_PARSER 0 -+#define CONFIG_ADX_PARSER 0 -+#define CONFIG_AV1_PARSER 0 -+#define CONFIG_AVS2_PARSER 0 -+#define CONFIG_BMP_PARSER 0 -+#define CONFIG_CAVSVIDEO_PARSER 0 -+#define CONFIG_COOK_PARSER 0 -+#define CONFIG_DCA_PARSER 0 -+#define CONFIG_DIRAC_PARSER 0 -+#define CONFIG_DNXHD_PARSER 0 -+#define CONFIG_DPX_PARSER 0 -+#define CONFIG_DVAUDIO_PARSER 0 -+#define CONFIG_DVBSUB_PARSER 0 -+#define CONFIG_DVDSUB_PARSER 0 -+#define CONFIG_DVD_NAV_PARSER 0 -+#define CONFIG_FLAC_PARSER 1 -+#define CONFIG_G723_1_PARSER 0 -+#define CONFIG_G729_PARSER 0 -+#define CONFIG_GIF_PARSER 0 -+#define CONFIG_GSM_PARSER 0 -+#define CONFIG_H261_PARSER 0 -+#define CONFIG_H263_PARSER 0 -+#define CONFIG_H264_PARSER 0 -+#define CONFIG_HEVC_PARSER 0 -+#define CONFIG_JPEG2000_PARSER 0 -+#define CONFIG_MJPEG_PARSER 0 -+#define CONFIG_MLP_PARSER 0 -+#define CONFIG_MPEG4VIDEO_PARSER 0 -+#define CONFIG_MPEGAUDIO_PARSER 1 -+#define CONFIG_MPEGVIDEO_PARSER 0 -+#define CONFIG_OPUS_PARSER 1 -+#define CONFIG_PNG_PARSER 0 -+#define CONFIG_PNM_PARSER 0 -+#define CONFIG_RV30_PARSER 0 -+#define CONFIG_RV40_PARSER 0 -+#define CONFIG_SBC_PARSER 0 -+#define CONFIG_SIPR_PARSER 0 -+#define CONFIG_TAK_PARSER 0 -+#define CONFIG_VC1_PARSER 0 -+#define CONFIG_VORBIS_PARSER 1 -+#define CONFIG_VP3_PARSER 1 -+#define CONFIG_VP8_PARSER 1 -+#define CONFIG_VP9_PARSER 1 -+#define CONFIG_WEBP_PARSER 0 -+#define CONFIG_XMA_PARSER 0 -+#define CONFIG_ALSA_INDEV 0 -+#define CONFIG_ANDROID_CAMERA_INDEV 0 -+#define CONFIG_AVFOUNDATION_INDEV 0 -+#define CONFIG_BKTR_INDEV 0 -+#define CONFIG_DECKLINK_INDEV 0 -+#define CONFIG_DSHOW_INDEV 0 -+#define CONFIG_FBDEV_INDEV 0 -+#define CONFIG_GDIGRAB_INDEV 0 -+#define CONFIG_IEC61883_INDEV 0 -+#define CONFIG_JACK_INDEV 0 -+#define CONFIG_KMSGRAB_INDEV 0 -+#define CONFIG_LAVFI_INDEV 0 -+#define CONFIG_OPENAL_INDEV 0 -+#define CONFIG_OSS_INDEV 0 -+#define CONFIG_PULSE_INDEV 0 -+#define CONFIG_SNDIO_INDEV 0 -+#define CONFIG_V4L2_INDEV 0 -+#define CONFIG_VFWCAP_INDEV 0 -+#define CONFIG_XCBGRAB_INDEV 0 -+#define CONFIG_LIBCDIO_INDEV 0 -+#define CONFIG_LIBDC1394_INDEV 0 -+#define CONFIG_ALSA_OUTDEV 0 -+#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 -+#define CONFIG_CACA_OUTDEV 0 -+#define CONFIG_DECKLINK_OUTDEV 0 -+#define CONFIG_FBDEV_OUTDEV 0 -+#define CONFIG_OPENGL_OUTDEV 0 -+#define CONFIG_OSS_OUTDEV 0 -+#define CONFIG_PULSE_OUTDEV 0 -+#define CONFIG_SDL2_OUTDEV 0 -+#define CONFIG_SNDIO_OUTDEV 0 -+#define CONFIG_V4L2_OUTDEV 0 -+#define CONFIG_XV_OUTDEV 0 -+#define CONFIG_ABENCH_FILTER 0 -+#define CONFIG_ACOMPRESSOR_FILTER 0 -+#define CONFIG_ACONTRAST_FILTER 0 -+#define CONFIG_ACOPY_FILTER 0 -+#define CONFIG_ACUE_FILTER 0 -+#define CONFIG_ACROSSFADE_FILTER 0 -+#define CONFIG_ACROSSOVER_FILTER 0 -+#define CONFIG_ACRUSHER_FILTER 0 -+#define CONFIG_ADECLICK_FILTER 0 -+#define CONFIG_ADECLIP_FILTER 0 -+#define CONFIG_ADELAY_FILTER 0 -+#define CONFIG_ADERIVATIVE_FILTER 0 -+#define CONFIG_AECHO_FILTER 0 -+#define CONFIG_AEMPHASIS_FILTER 0 -+#define CONFIG_AEVAL_FILTER 0 -+#define CONFIG_AFADE_FILTER 0 -+#define CONFIG_AFFTDN_FILTER 0 -+#define CONFIG_AFFTFILT_FILTER 0 -+#define CONFIG_AFIR_FILTER 0 -+#define CONFIG_AFORMAT_FILTER 0 -+#define CONFIG_AGATE_FILTER 0 -+#define CONFIG_AIIR_FILTER 0 -+#define CONFIG_AINTEGRAL_FILTER 0 -+#define CONFIG_AINTERLEAVE_FILTER 0 -+#define CONFIG_ALIMITER_FILTER 0 -+#define CONFIG_ALLPASS_FILTER 0 -+#define CONFIG_ALOOP_FILTER 0 -+#define CONFIG_AMERGE_FILTER 0 -+#define CONFIG_AMETADATA_FILTER 0 -+#define CONFIG_AMIX_FILTER 0 -+#define CONFIG_AMULTIPLY_FILTER 0 -+#define CONFIG_ANEQUALIZER_FILTER 0 -+#define CONFIG_ANLMDN_FILTER 0 -+#define CONFIG_ANLMS_FILTER 0 -+#define CONFIG_ANULL_FILTER 0 -+#define CONFIG_APAD_FILTER 0 -+#define CONFIG_APERMS_FILTER 0 -+#define CONFIG_APHASER_FILTER 0 -+#define CONFIG_APULSATOR_FILTER 0 -+#define CONFIG_AREALTIME_FILTER 0 -+#define CONFIG_ARESAMPLE_FILTER 0 -+#define CONFIG_AREVERSE_FILTER 0 -+#define CONFIG_ARNNDN_FILTER 0 -+#define CONFIG_ASELECT_FILTER 0 -+#define CONFIG_ASENDCMD_FILTER 0 -+#define CONFIG_ASETNSAMPLES_FILTER 0 -+#define CONFIG_ASETPTS_FILTER 0 -+#define CONFIG_ASETRATE_FILTER 0 -+#define CONFIG_ASETTB_FILTER 0 -+#define CONFIG_ASHOWINFO_FILTER 0 -+#define CONFIG_ASIDEDATA_FILTER 0 -+#define CONFIG_ASOFTCLIP_FILTER 0 -+#define CONFIG_ASPLIT_FILTER 0 -+#define CONFIG_ASR_FILTER 0 -+#define CONFIG_ASTATS_FILTER 0 -+#define CONFIG_ASTREAMSELECT_FILTER 0 -+#define CONFIG_ASUBBOOST_FILTER 0 -+#define CONFIG_ATEMPO_FILTER 0 -+#define CONFIG_ATRIM_FILTER 0 -+#define CONFIG_AXCORRELATE_FILTER 0 -+#define CONFIG_AZMQ_FILTER 0 -+#define CONFIG_BANDPASS_FILTER 0 -+#define CONFIG_BANDREJECT_FILTER 0 -+#define CONFIG_BASS_FILTER 0 -+#define CONFIG_BIQUAD_FILTER 0 -+#define CONFIG_BS2B_FILTER 0 -+#define CONFIG_CHROMABER_VULKAN_FILTER 0 -+#define CONFIG_CHANNELMAP_FILTER 0 -+#define CONFIG_CHANNELSPLIT_FILTER 0 -+#define CONFIG_CHORUS_FILTER 0 -+#define CONFIG_COMPAND_FILTER 0 -+#define CONFIG_COMPENSATIONDELAY_FILTER 0 -+#define CONFIG_CROSSFEED_FILTER 0 -+#define CONFIG_CRYSTALIZER_FILTER 0 -+#define CONFIG_DCSHIFT_FILTER 0 -+#define CONFIG_DEESSER_FILTER 0 -+#define CONFIG_DRMETER_FILTER 0 -+#define CONFIG_DYNAUDNORM_FILTER 0 -+#define CONFIG_EARWAX_FILTER 0 -+#define CONFIG_EBUR128_FILTER 0 -+#define CONFIG_EQUALIZER_FILTER 0 -+#define CONFIG_EXTRASTEREO_FILTER 0 -+#define CONFIG_FIREQUALIZER_FILTER 0 -+#define CONFIG_FLANGER_FILTER 0 -+#define CONFIG_HAAS_FILTER 0 -+#define CONFIG_HDCD_FILTER 0 -+#define CONFIG_HEADPHONE_FILTER 0 -+#define CONFIG_HIGHPASS_FILTER 0 -+#define CONFIG_HIGHSHELF_FILTER 0 -+#define CONFIG_JOIN_FILTER 0 -+#define CONFIG_LADSPA_FILTER 0 -+#define CONFIG_LOUDNORM_FILTER 0 -+#define CONFIG_LOWPASS_FILTER 0 -+#define CONFIG_LOWSHELF_FILTER 0 -+#define CONFIG_LV2_FILTER 0 -+#define CONFIG_MCOMPAND_FILTER 0 -+#define CONFIG_PAN_FILTER 0 -+#define CONFIG_REPLAYGAIN_FILTER 0 -+#define CONFIG_RESAMPLE_FILTER 0 -+#define CONFIG_RUBBERBAND_FILTER 0 -+#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 -+#define CONFIG_SIDECHAINGATE_FILTER 0 -+#define CONFIG_SILENCEDETECT_FILTER 0 -+#define CONFIG_SILENCEREMOVE_FILTER 0 -+#define CONFIG_SOFALIZER_FILTER 0 -+#define CONFIG_STEREOTOOLS_FILTER 0 -+#define CONFIG_STEREOWIDEN_FILTER 0 -+#define CONFIG_SUPEREQUALIZER_FILTER 0 -+#define CONFIG_SURROUND_FILTER 0 -+#define CONFIG_TREBLE_FILTER 0 -+#define CONFIG_TREMOLO_FILTER 0 -+#define CONFIG_VIBRATO_FILTER 0 -+#define CONFIG_VOLUME_FILTER 0 -+#define CONFIG_VOLUMEDETECT_FILTER 0 -+#define CONFIG_AEVALSRC_FILTER 0 -+#define CONFIG_AFIRSRC_FILTER 0 -+#define CONFIG_ANOISESRC_FILTER 0 -+#define CONFIG_ANULLSRC_FILTER 0 -+#define CONFIG_FLITE_FILTER 0 -+#define CONFIG_HILBERT_FILTER 0 -+#define CONFIG_SINC_FILTER 0 -+#define CONFIG_SINE_FILTER 0 -+#define CONFIG_ANULLSINK_FILTER 0 -+#define CONFIG_ADDROI_FILTER 0 -+#define CONFIG_ALPHAEXTRACT_FILTER 0 -+#define CONFIG_ALPHAMERGE_FILTER 0 -+#define CONFIG_AMPLIFY_FILTER 0 -+#define CONFIG_ASS_FILTER 0 -+#define CONFIG_ATADENOISE_FILTER 0 -+#define CONFIG_AVGBLUR_FILTER 0 -+#define CONFIG_AVGBLUR_OPENCL_FILTER 0 -+#define CONFIG_AVGBLUR_VULKAN_FILTER 0 -+#define CONFIG_BBOX_FILTER 0 -+#define CONFIG_BENCH_FILTER 0 -+#define CONFIG_BILATERAL_FILTER 0 -+#define CONFIG_BITPLANENOISE_FILTER 0 -+#define CONFIG_BLACKDETECT_FILTER 0 -+#define CONFIG_BLACKFRAME_FILTER 0 -+#define CONFIG_BLEND_FILTER 0 -+#define CONFIG_BM3D_FILTER 0 -+#define CONFIG_BOXBLUR_FILTER 0 -+#define CONFIG_BOXBLUR_OPENCL_FILTER 0 -+#define CONFIG_BWDIF_FILTER 0 -+#define CONFIG_CAS_FILTER 0 -+#define CONFIG_CHROMAHOLD_FILTER 0 -+#define CONFIG_CHROMAKEY_FILTER 0 -+#define CONFIG_CHROMANR_FILTER 0 -+#define CONFIG_CHROMASHIFT_FILTER 0 -+#define CONFIG_CIESCOPE_FILTER 0 -+#define CONFIG_CODECVIEW_FILTER 0 -+#define CONFIG_COLORBALANCE_FILTER 0 -+#define CONFIG_COLORCHANNELMIXER_FILTER 0 -+#define CONFIG_COLORKEY_FILTER 0 -+#define CONFIG_COLORKEY_OPENCL_FILTER 0 -+#define CONFIG_COLORHOLD_FILTER 0 -+#define CONFIG_COLORLEVELS_FILTER 0 -+#define CONFIG_COLORMATRIX_FILTER 0 -+#define CONFIG_COLORSPACE_FILTER 0 -+#define CONFIG_CONVOLUTION_FILTER 0 -+#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 -+#define CONFIG_CONVOLVE_FILTER 0 -+#define CONFIG_COPY_FILTER 0 -+#define CONFIG_COREIMAGE_FILTER 0 -+#define CONFIG_COVER_RECT_FILTER 0 -+#define CONFIG_CROP_FILTER 0 -+#define CONFIG_CROPDETECT_FILTER 0 -+#define CONFIG_CUE_FILTER 0 -+#define CONFIG_CURVES_FILTER 0 -+#define CONFIG_DATASCOPE_FILTER 0 -+#define CONFIG_DBLUR_FILTER 0 -+#define CONFIG_DCTDNOIZ_FILTER 0 -+#define CONFIG_DEBAND_FILTER 0 -+#define CONFIG_DEBLOCK_FILTER 0 -+#define CONFIG_DECIMATE_FILTER 0 -+#define CONFIG_DECONVOLVE_FILTER 0 -+#define CONFIG_DEDOT_FILTER 0 -+#define CONFIG_DEFLATE_FILTER 0 -+#define CONFIG_DEFLICKER_FILTER 0 -+#define CONFIG_DEINTERLACE_QSV_FILTER 0 -+#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 -+#define CONFIG_DEJUDDER_FILTER 0 -+#define CONFIG_DELOGO_FILTER 0 -+#define CONFIG_DENOISE_VAAPI_FILTER 0 -+#define CONFIG_DERAIN_FILTER 0 -+#define CONFIG_DESHAKE_FILTER 0 -+#define CONFIG_DESHAKE_OPENCL_FILTER 0 -+#define CONFIG_DESPILL_FILTER 0 -+#define CONFIG_DETELECINE_FILTER 0 -+#define CONFIG_DILATION_FILTER 0 -+#define CONFIG_DILATION_OPENCL_FILTER 0 -+#define CONFIG_DISPLACE_FILTER 0 -+#define CONFIG_DNN_PROCESSING_FILTER 0 -+#define CONFIG_DOUBLEWEAVE_FILTER 0 -+#define CONFIG_DRAWBOX_FILTER 0 -+#define CONFIG_DRAWGRAPH_FILTER 0 -+#define CONFIG_DRAWGRID_FILTER 0 -+#define CONFIG_DRAWTEXT_FILTER 0 -+#define CONFIG_EDGEDETECT_FILTER 0 -+#define CONFIG_ELBG_FILTER 0 -+#define CONFIG_ENTROPY_FILTER 0 -+#define CONFIG_EQ_FILTER 0 -+#define CONFIG_EROSION_FILTER 0 -+#define CONFIG_EROSION_OPENCL_FILTER 0 -+#define CONFIG_EXTRACTPLANES_FILTER 0 -+#define CONFIG_FADE_FILTER 0 -+#define CONFIG_FFTDNOIZ_FILTER 0 -+#define CONFIG_FFTFILT_FILTER 0 -+#define CONFIG_FIELD_FILTER 0 -+#define CONFIG_FIELDHINT_FILTER 0 -+#define CONFIG_FIELDMATCH_FILTER 0 -+#define CONFIG_FIELDORDER_FILTER 0 -+#define CONFIG_FILLBORDERS_FILTER 0 -+#define CONFIG_FIND_RECT_FILTER 0 -+#define CONFIG_FLOODFILL_FILTER 0 -+#define CONFIG_FORMAT_FILTER 0 -+#define CONFIG_FPS_FILTER 0 -+#define CONFIG_FRAMEPACK_FILTER 0 -+#define CONFIG_FRAMERATE_FILTER 0 -+#define CONFIG_FRAMESTEP_FILTER 0 -+#define CONFIG_FREEZEDETECT_FILTER 0 -+#define CONFIG_FREEZEFRAMES_FILTER 0 -+#define CONFIG_FREI0R_FILTER 0 -+#define CONFIG_FSPP_FILTER 0 -+#define CONFIG_GBLUR_FILTER 0 -+#define CONFIG_GEQ_FILTER 0 -+#define CONFIG_GRADFUN_FILTER 0 -+#define CONFIG_GRAPHMONITOR_FILTER 0 -+#define CONFIG_GREYEDGE_FILTER 0 -+#define CONFIG_HALDCLUT_FILTER 0 -+#define CONFIG_HFLIP_FILTER 0 -+#define CONFIG_HISTEQ_FILTER 0 -+#define CONFIG_HISTOGRAM_FILTER 0 -+#define CONFIG_HQDN3D_FILTER 0 -+#define CONFIG_HQX_FILTER 0 -+#define CONFIG_HSTACK_FILTER 0 -+#define CONFIG_HUE_FILTER 0 -+#define CONFIG_HWDOWNLOAD_FILTER 0 -+#define CONFIG_HWMAP_FILTER 0 -+#define CONFIG_HWUPLOAD_FILTER 0 -+#define CONFIG_HWUPLOAD_CUDA_FILTER 0 -+#define CONFIG_HYSTERESIS_FILTER 0 -+#define CONFIG_IDET_FILTER 0 -+#define CONFIG_IL_FILTER 0 -+#define CONFIG_INFLATE_FILTER 0 -+#define CONFIG_INTERLACE_FILTER 0 -+#define CONFIG_INTERLEAVE_FILTER 0 -+#define CONFIG_KERNDEINT_FILTER 0 -+#define CONFIG_LAGFUN_FILTER 0 -+#define CONFIG_LENSCORRECTION_FILTER 0 -+#define CONFIG_LENSFUN_FILTER 0 -+#define CONFIG_LIBVMAF_FILTER 0 -+#define CONFIG_LIMITER_FILTER 0 -+#define CONFIG_LOOP_FILTER 0 -+#define CONFIG_LUMAKEY_FILTER 0 -+#define CONFIG_LUT_FILTER 0 -+#define CONFIG_LUT1D_FILTER 0 -+#define CONFIG_LUT2_FILTER 0 -+#define CONFIG_LUT3D_FILTER 0 -+#define CONFIG_LUTRGB_FILTER 0 -+#define CONFIG_LUTYUV_FILTER 0 -+#define CONFIG_MASKEDCLAMP_FILTER 0 -+#define CONFIG_MASKEDMAX_FILTER 0 -+#define CONFIG_MASKEDMERGE_FILTER 0 -+#define CONFIG_MASKEDMIN_FILTER 0 -+#define CONFIG_MASKEDTHRESHOLD_FILTER 0 -+#define CONFIG_MASKFUN_FILTER 0 -+#define CONFIG_MCDEINT_FILTER 0 -+#define CONFIG_MEDIAN_FILTER 0 -+#define CONFIG_MERGEPLANES_FILTER 0 -+#define CONFIG_MESTIMATE_FILTER 0 -+#define CONFIG_METADATA_FILTER 0 -+#define CONFIG_MIDEQUALIZER_FILTER 0 -+#define CONFIG_MINTERPOLATE_FILTER 0 -+#define CONFIG_MIX_FILTER 0 -+#define CONFIG_MPDECIMATE_FILTER 0 -+#define CONFIG_NEGATE_FILTER 0 -+#define CONFIG_NLMEANS_FILTER 0 -+#define CONFIG_NLMEANS_OPENCL_FILTER 0 -+#define CONFIG_NNEDI_FILTER 0 -+#define CONFIG_NOFORMAT_FILTER 0 -+#define CONFIG_NOISE_FILTER 0 -+#define CONFIG_NORMALIZE_FILTER 0 -+#define CONFIG_NULL_FILTER 0 -+#define CONFIG_OCR_FILTER 0 -+#define CONFIG_OCV_FILTER 0 -+#define CONFIG_OSCILLOSCOPE_FILTER 0 -+#define CONFIG_OVERLAY_FILTER 0 -+#define CONFIG_OVERLAY_OPENCL_FILTER 0 -+#define CONFIG_OVERLAY_QSV_FILTER 0 -+#define CONFIG_OVERLAY_VULKAN_FILTER 0 -+#define CONFIG_OVERLAY_CUDA_FILTER 0 -+#define CONFIG_OWDENOISE_FILTER 0 -+#define CONFIG_PAD_FILTER 0 -+#define CONFIG_PAD_OPENCL_FILTER 0 -+#define CONFIG_PALETTEGEN_FILTER 0 -+#define CONFIG_PALETTEUSE_FILTER 0 -+#define CONFIG_PERMS_FILTER 0 -+#define CONFIG_PERSPECTIVE_FILTER 0 -+#define CONFIG_PHASE_FILTER 0 -+#define CONFIG_PHOTOSENSITIVITY_FILTER 0 -+#define CONFIG_PIXDESCTEST_FILTER 0 -+#define CONFIG_PIXSCOPE_FILTER 0 -+#define CONFIG_PP_FILTER 0 -+#define CONFIG_PP7_FILTER 0 -+#define CONFIG_PREMULTIPLY_FILTER 0 -+#define CONFIG_PREWITT_FILTER 0 -+#define CONFIG_PREWITT_OPENCL_FILTER 0 -+#define CONFIG_PROCAMP_VAAPI_FILTER 0 -+#define CONFIG_PROGRAM_OPENCL_FILTER 0 -+#define CONFIG_PSEUDOCOLOR_FILTER 0 -+#define CONFIG_PSNR_FILTER 0 -+#define CONFIG_PULLUP_FILTER 0 -+#define CONFIG_QP_FILTER 0 -+#define CONFIG_RANDOM_FILTER 0 -+#define CONFIG_READEIA608_FILTER 0 -+#define CONFIG_READVITC_FILTER 0 -+#define CONFIG_REALTIME_FILTER 0 -+#define CONFIG_REMAP_FILTER 0 -+#define CONFIG_REMOVEGRAIN_FILTER 0 -+#define CONFIG_REMOVELOGO_FILTER 0 -+#define CONFIG_REPEATFIELDS_FILTER 0 -+#define CONFIG_REVERSE_FILTER 0 -+#define CONFIG_RGBASHIFT_FILTER 0 -+#define CONFIG_ROBERTS_FILTER 0 -+#define CONFIG_ROBERTS_OPENCL_FILTER 0 -+#define CONFIG_ROTATE_FILTER 0 -+#define CONFIG_SAB_FILTER 0 -+#define CONFIG_SCALE_FILTER 0 -+#define CONFIG_SCALE_CUDA_FILTER 0 -+#define CONFIG_SCALE_NPP_FILTER 0 -+#define CONFIG_SCALE_QSV_FILTER 0 -+#define CONFIG_SCALE_VAAPI_FILTER 0 -+#define CONFIG_SCALE_VULKAN_FILTER 0 -+#define CONFIG_SCALE2REF_FILTER 0 -+#define CONFIG_SCDET_FILTER 0 -+#define CONFIG_SCROLL_FILTER 0 -+#define CONFIG_SELECT_FILTER 0 -+#define CONFIG_SELECTIVECOLOR_FILTER 0 -+#define CONFIG_SENDCMD_FILTER 0 -+#define CONFIG_SEPARATEFIELDS_FILTER 0 -+#define CONFIG_SETDAR_FILTER 0 -+#define CONFIG_SETFIELD_FILTER 0 -+#define CONFIG_SETPARAMS_FILTER 0 -+#define CONFIG_SETPTS_FILTER 0 -+#define CONFIG_SETRANGE_FILTER 0 -+#define CONFIG_SETSAR_FILTER 0 -+#define CONFIG_SETTB_FILTER 0 -+#define CONFIG_SHARPNESS_VAAPI_FILTER 0 -+#define CONFIG_SHOWINFO_FILTER 0 -+#define CONFIG_SHOWPALETTE_FILTER 0 -+#define CONFIG_SHUFFLEFRAMES_FILTER 0 -+#define CONFIG_SHUFFLEPLANES_FILTER 0 -+#define CONFIG_SIDEDATA_FILTER 0 -+#define CONFIG_SIGNALSTATS_FILTER 0 -+#define CONFIG_SIGNATURE_FILTER 0 -+#define CONFIG_SMARTBLUR_FILTER 0 -+#define CONFIG_SOBEL_FILTER 0 -+#define CONFIG_SOBEL_OPENCL_FILTER 0 -+#define CONFIG_SPLIT_FILTER 0 -+#define CONFIG_SPP_FILTER 0 -+#define CONFIG_SR_FILTER 0 -+#define CONFIG_SSIM_FILTER 0 -+#define CONFIG_STEREO3D_FILTER 0 -+#define CONFIG_STREAMSELECT_FILTER 0 -+#define CONFIG_SUBTITLES_FILTER 0 -+#define CONFIG_SUPER2XSAI_FILTER 0 -+#define CONFIG_SWAPRECT_FILTER 0 -+#define CONFIG_SWAPUV_FILTER 0 -+#define CONFIG_TBLEND_FILTER 0 -+#define CONFIG_TELECINE_FILTER 0 -+#define CONFIG_THISTOGRAM_FILTER 0 -+#define CONFIG_THRESHOLD_FILTER 0 -+#define CONFIG_THUMBNAIL_FILTER 0 -+#define CONFIG_THUMBNAIL_CUDA_FILTER 0 -+#define CONFIG_TILE_FILTER 0 -+#define CONFIG_TINTERLACE_FILTER 0 -+#define CONFIG_TLUT2_FILTER 0 -+#define CONFIG_TMEDIAN_FILTER 0 -+#define CONFIG_TMIX_FILTER 0 -+#define CONFIG_TONEMAP_FILTER 0 -+#define CONFIG_TONEMAP_OPENCL_FILTER 0 -+#define CONFIG_TONEMAP_VAAPI_FILTER 0 -+#define CONFIG_TPAD_FILTER 0 -+#define CONFIG_TRANSPOSE_FILTER 0 -+#define CONFIG_TRANSPOSE_NPP_FILTER 0 -+#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 -+#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 -+#define CONFIG_TRIM_FILTER 0 -+#define CONFIG_UNPREMULTIPLY_FILTER 0 -+#define CONFIG_UNSHARP_FILTER 0 -+#define CONFIG_UNSHARP_OPENCL_FILTER 0 -+#define CONFIG_UNTILE_FILTER 0 -+#define CONFIG_USPP_FILTER 0 -+#define CONFIG_V360_FILTER 0 -+#define CONFIG_VAGUEDENOISER_FILTER 0 -+#define CONFIG_VECTORSCOPE_FILTER 0 -+#define CONFIG_VFLIP_FILTER 0 -+#define CONFIG_VFRDET_FILTER 0 -+#define CONFIG_VIBRANCE_FILTER 0 -+#define CONFIG_VIDSTABDETECT_FILTER 0 -+#define CONFIG_VIDSTABTRANSFORM_FILTER 0 -+#define CONFIG_VIGNETTE_FILTER 0 -+#define CONFIG_VMAFMOTION_FILTER 0 -+#define CONFIG_VPP_QSV_FILTER 0 -+#define CONFIG_VSTACK_FILTER 0 -+#define CONFIG_W3FDIF_FILTER 0 -+#define CONFIG_WAVEFORM_FILTER 0 -+#define CONFIG_WEAVE_FILTER 0 -+#define CONFIG_XBR_FILTER 0 -+#define CONFIG_XFADE_FILTER 0 -+#define CONFIG_XFADE_OPENCL_FILTER 0 -+#define CONFIG_XMEDIAN_FILTER 0 -+#define CONFIG_XSTACK_FILTER 0 -+#define CONFIG_YADIF_FILTER 0 -+#define CONFIG_YADIF_CUDA_FILTER 0 -+#define CONFIG_YAEPBLUR_FILTER 0 -+#define CONFIG_ZMQ_FILTER 0 -+#define CONFIG_ZOOMPAN_FILTER 0 -+#define CONFIG_ZSCALE_FILTER 0 -+#define CONFIG_ALLRGB_FILTER 0 -+#define CONFIG_ALLYUV_FILTER 0 -+#define CONFIG_CELLAUTO_FILTER 0 -+#define CONFIG_COLOR_FILTER 0 -+#define CONFIG_COREIMAGESRC_FILTER 0 -+#define CONFIG_FREI0R_SRC_FILTER 0 -+#define CONFIG_GRADIENTS_FILTER 0 -+#define CONFIG_HALDCLUTSRC_FILTER 0 -+#define CONFIG_LIFE_FILTER 0 -+#define CONFIG_MANDELBROT_FILTER 0 -+#define CONFIG_MPTESTSRC_FILTER 0 -+#define CONFIG_NULLSRC_FILTER 0 -+#define CONFIG_OPENCLSRC_FILTER 0 -+#define CONFIG_PAL75BARS_FILTER 0 -+#define CONFIG_PAL100BARS_FILTER 0 -+#define CONFIG_RGBTESTSRC_FILTER 0 -+#define CONFIG_SIERPINSKI_FILTER 0 -+#define CONFIG_SMPTEBARS_FILTER 0 -+#define CONFIG_SMPTEHDBARS_FILTER 0 -+#define CONFIG_TESTSRC_FILTER 0 -+#define CONFIG_TESTSRC2_FILTER 0 -+#define CONFIG_YUVTESTSRC_FILTER 0 -+#define CONFIG_NULLSINK_FILTER 0 -+#define CONFIG_ABITSCOPE_FILTER 0 -+#define CONFIG_ADRAWGRAPH_FILTER 0 -+#define CONFIG_AGRAPHMONITOR_FILTER 0 -+#define CONFIG_AHISTOGRAM_FILTER 0 -+#define CONFIG_APHASEMETER_FILTER 0 -+#define CONFIG_AVECTORSCOPE_FILTER 0 -+#define CONFIG_CONCAT_FILTER 0 -+#define CONFIG_SHOWCQT_FILTER 0 -+#define CONFIG_SHOWFREQS_FILTER 0 -+#define CONFIG_SHOWSPATIAL_FILTER 0 -+#define CONFIG_SHOWSPECTRUM_FILTER 0 -+#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 -+#define CONFIG_SHOWVOLUME_FILTER 0 -+#define CONFIG_SHOWWAVES_FILTER 0 -+#define CONFIG_SHOWWAVESPIC_FILTER 0 -+#define CONFIG_SPECTRUMSYNTH_FILTER 0 -+#define CONFIG_AMOVIE_FILTER 0 -+#define CONFIG_MOVIE_FILTER 0 -+#define CONFIG_AFIFO_FILTER 0 -+#define CONFIG_FIFO_FILTER 0 -+#define CONFIG_AA_DEMUXER 0 -+#define CONFIG_AAC_DEMUXER 0 -+#define CONFIG_AC3_DEMUXER 0 -+#define CONFIG_ACM_DEMUXER 0 -+#define CONFIG_ACT_DEMUXER 0 -+#define CONFIG_ADF_DEMUXER 0 -+#define CONFIG_ADP_DEMUXER 0 -+#define CONFIG_ADS_DEMUXER 0 -+#define CONFIG_ADX_DEMUXER 0 -+#define CONFIG_AEA_DEMUXER 0 -+#define CONFIG_AFC_DEMUXER 0 -+#define CONFIG_AIFF_DEMUXER 0 -+#define CONFIG_AIX_DEMUXER 0 -+#define CONFIG_ALP_DEMUXER 0 -+#define CONFIG_AMR_DEMUXER 0 -+#define CONFIG_AMRNB_DEMUXER 0 -+#define CONFIG_AMRWB_DEMUXER 0 -+#define CONFIG_ANM_DEMUXER 0 -+#define CONFIG_APC_DEMUXER 0 -+#define CONFIG_APE_DEMUXER 0 -+#define CONFIG_APM_DEMUXER 0 -+#define CONFIG_APNG_DEMUXER 0 -+#define CONFIG_APTX_DEMUXER 0 -+#define CONFIG_APTX_HD_DEMUXER 0 -+#define CONFIG_AQTITLE_DEMUXER 0 -+#define CONFIG_ARGO_ASF_DEMUXER 0 -+#define CONFIG_ASF_DEMUXER 0 -+#define CONFIG_ASF_O_DEMUXER 0 -+#define CONFIG_ASS_DEMUXER 0 -+#define CONFIG_AST_DEMUXER 0 -+#define CONFIG_AU_DEMUXER 0 -+#define CONFIG_AV1_DEMUXER 0 -+#define CONFIG_AVI_DEMUXER 0 -+#define CONFIG_AVISYNTH_DEMUXER 0 -+#define CONFIG_AVR_DEMUXER 0 -+#define CONFIG_AVS_DEMUXER 0 -+#define CONFIG_AVS2_DEMUXER 0 -+#define CONFIG_BETHSOFTVID_DEMUXER 0 -+#define CONFIG_BFI_DEMUXER 0 -+#define CONFIG_BINTEXT_DEMUXER 0 -+#define CONFIG_BINK_DEMUXER 0 -+#define CONFIG_BIT_DEMUXER 0 -+#define CONFIG_BMV_DEMUXER 0 -+#define CONFIG_BFSTM_DEMUXER 0 -+#define CONFIG_BRSTM_DEMUXER 0 -+#define CONFIG_BOA_DEMUXER 0 -+#define CONFIG_C93_DEMUXER 0 -+#define CONFIG_CAF_DEMUXER 0 -+#define CONFIG_CAVSVIDEO_DEMUXER 0 -+#define CONFIG_CDG_DEMUXER 0 -+#define CONFIG_CDXL_DEMUXER 0 -+#define CONFIG_CINE_DEMUXER 0 -+#define CONFIG_CODEC2_DEMUXER 0 -+#define CONFIG_CODEC2RAW_DEMUXER 0 -+#define CONFIG_CONCAT_DEMUXER 0 -+#define CONFIG_DASH_DEMUXER 0 -+#define CONFIG_DATA_DEMUXER 0 -+#define CONFIG_DAUD_DEMUXER 0 -+#define CONFIG_DCSTR_DEMUXER 0 -+#define CONFIG_DERF_DEMUXER 0 -+#define CONFIG_DFA_DEMUXER 0 -+#define CONFIG_DHAV_DEMUXER 0 -+#define CONFIG_DIRAC_DEMUXER 0 -+#define CONFIG_DNXHD_DEMUXER 0 -+#define CONFIG_DSF_DEMUXER 0 -+#define CONFIG_DSICIN_DEMUXER 0 -+#define CONFIG_DSS_DEMUXER 0 -+#define CONFIG_DTS_DEMUXER 0 -+#define CONFIG_DTSHD_DEMUXER 0 -+#define CONFIG_DV_DEMUXER 0 -+#define CONFIG_DVBSUB_DEMUXER 0 -+#define CONFIG_DVBTXT_DEMUXER 0 -+#define CONFIG_DXA_DEMUXER 0 -+#define CONFIG_EA_DEMUXER 0 -+#define CONFIG_EA_CDATA_DEMUXER 0 -+#define CONFIG_EAC3_DEMUXER 0 -+#define CONFIG_EPAF_DEMUXER 0 -+#define CONFIG_FFMETADATA_DEMUXER 0 -+#define CONFIG_FILMSTRIP_DEMUXER 0 -+#define CONFIG_FITS_DEMUXER 0 -+#define CONFIG_FLAC_DEMUXER 1 -+#define CONFIG_FLIC_DEMUXER 0 -+#define CONFIG_FLV_DEMUXER 0 -+#define CONFIG_LIVE_FLV_DEMUXER 0 -+#define CONFIG_FOURXM_DEMUXER 0 -+#define CONFIG_FRM_DEMUXER 0 -+#define CONFIG_FSB_DEMUXER 0 -+#define CONFIG_FWSE_DEMUXER 0 -+#define CONFIG_G722_DEMUXER 0 -+#define CONFIG_G723_1_DEMUXER 0 -+#define CONFIG_G726_DEMUXER 0 -+#define CONFIG_G726LE_DEMUXER 0 -+#define CONFIG_G729_DEMUXER 0 -+#define CONFIG_GDV_DEMUXER 0 -+#define CONFIG_GENH_DEMUXER 0 -+#define CONFIG_GIF_DEMUXER 0 -+#define CONFIG_GSM_DEMUXER 0 -+#define CONFIG_GXF_DEMUXER 0 -+#define CONFIG_H261_DEMUXER 0 -+#define CONFIG_H263_DEMUXER 0 -+#define CONFIG_H264_DEMUXER 0 -+#define CONFIG_HCA_DEMUXER 0 -+#define CONFIG_HCOM_DEMUXER 0 -+#define CONFIG_HEVC_DEMUXER 0 -+#define CONFIG_HLS_DEMUXER 0 -+#define CONFIG_HNM_DEMUXER 0 -+#define CONFIG_ICO_DEMUXER 0 -+#define CONFIG_IDCIN_DEMUXER 0 -+#define CONFIG_IDF_DEMUXER 0 -+#define CONFIG_IFF_DEMUXER 0 -+#define CONFIG_IFV_DEMUXER 0 -+#define CONFIG_ILBC_DEMUXER 0 -+#define CONFIG_IMAGE2_DEMUXER 0 -+#define CONFIG_IMAGE2PIPE_DEMUXER 0 -+#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 -+#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 -+#define CONFIG_INGENIENT_DEMUXER 0 -+#define CONFIG_IPMOVIE_DEMUXER 0 -+#define CONFIG_IRCAM_DEMUXER 0 -+#define CONFIG_ISS_DEMUXER 0 -+#define CONFIG_IV8_DEMUXER 0 -+#define CONFIG_IVF_DEMUXER 0 -+#define CONFIG_IVR_DEMUXER 0 -+#define CONFIG_JACOSUB_DEMUXER 0 -+#define CONFIG_JV_DEMUXER 0 -+#define CONFIG_KUX_DEMUXER 0 -+#define CONFIG_KVAG_DEMUXER 0 -+#define CONFIG_LMLM4_DEMUXER 0 -+#define CONFIG_LOAS_DEMUXER 0 -+#define CONFIG_LRC_DEMUXER 0 -+#define CONFIG_LVF_DEMUXER 0 -+#define CONFIG_LXF_DEMUXER 0 -+#define CONFIG_M4V_DEMUXER 0 -+#define CONFIG_MCC_DEMUXER 0 -+#define CONFIG_MATROSKA_DEMUXER 1 -+#define CONFIG_MGSTS_DEMUXER 0 -+#define CONFIG_MICRODVD_DEMUXER 0 -+#define CONFIG_MJPEG_DEMUXER 0 -+#define CONFIG_MJPEG_2000_DEMUXER 0 -+#define CONFIG_MLP_DEMUXER 0 -+#define CONFIG_MLV_DEMUXER 0 -+#define CONFIG_MM_DEMUXER 0 -+#define CONFIG_MMF_DEMUXER 0 -+#define CONFIG_MOV_DEMUXER 1 -+#define CONFIG_MP3_DEMUXER 1 -+#define CONFIG_MPC_DEMUXER 0 -+#define CONFIG_MPC8_DEMUXER 0 -+#define CONFIG_MPEGPS_DEMUXER 0 -+#define CONFIG_MPEGTS_DEMUXER 0 -+#define CONFIG_MPEGTSRAW_DEMUXER 0 -+#define CONFIG_MPEGVIDEO_DEMUXER 0 -+#define CONFIG_MPJPEG_DEMUXER 0 -+#define CONFIG_MPL2_DEMUXER 0 -+#define CONFIG_MPSUB_DEMUXER 0 -+#define CONFIG_MSF_DEMUXER 0 -+#define CONFIG_MSNWC_TCP_DEMUXER 0 -+#define CONFIG_MTAF_DEMUXER 0 -+#define CONFIG_MTV_DEMUXER 0 -+#define CONFIG_MUSX_DEMUXER 0 -+#define CONFIG_MV_DEMUXER 0 -+#define CONFIG_MVI_DEMUXER 0 -+#define CONFIG_MXF_DEMUXER 0 -+#define CONFIG_MXG_DEMUXER 0 -+#define CONFIG_NC_DEMUXER 0 -+#define CONFIG_NISTSPHERE_DEMUXER 0 -+#define CONFIG_NSP_DEMUXER 0 -+#define CONFIG_NSV_DEMUXER 0 -+#define CONFIG_NUT_DEMUXER 0 -+#define CONFIG_NUV_DEMUXER 0 -+#define CONFIG_OBU_DEMUXER 0 -+#define CONFIG_OGG_DEMUXER 1 -+#define CONFIG_OMA_DEMUXER 0 -+#define CONFIG_PAF_DEMUXER 0 -+#define CONFIG_PCM_ALAW_DEMUXER 0 -+#define CONFIG_PCM_MULAW_DEMUXER 0 -+#define CONFIG_PCM_VIDC_DEMUXER 0 -+#define CONFIG_PCM_F64BE_DEMUXER 0 -+#define CONFIG_PCM_F64LE_DEMUXER 0 -+#define CONFIG_PCM_F32BE_DEMUXER 0 -+#define CONFIG_PCM_F32LE_DEMUXER 0 -+#define CONFIG_PCM_S32BE_DEMUXER 0 -+#define CONFIG_PCM_S32LE_DEMUXER 0 -+#define CONFIG_PCM_S24BE_DEMUXER 0 -+#define CONFIG_PCM_S24LE_DEMUXER 0 -+#define CONFIG_PCM_S16BE_DEMUXER 0 -+#define CONFIG_PCM_S16LE_DEMUXER 0 -+#define CONFIG_PCM_S8_DEMUXER 0 -+#define CONFIG_PCM_U32BE_DEMUXER 0 -+#define CONFIG_PCM_U32LE_DEMUXER 0 -+#define CONFIG_PCM_U24BE_DEMUXER 0 -+#define CONFIG_PCM_U24LE_DEMUXER 0 -+#define CONFIG_PCM_U16BE_DEMUXER 0 -+#define CONFIG_PCM_U16LE_DEMUXER 0 -+#define CONFIG_PCM_U8_DEMUXER 0 -+#define CONFIG_PJS_DEMUXER 0 -+#define CONFIG_PMP_DEMUXER 0 -+#define CONFIG_PP_BNK_DEMUXER 0 -+#define CONFIG_PVA_DEMUXER 0 -+#define CONFIG_PVF_DEMUXER 0 -+#define CONFIG_QCP_DEMUXER 0 -+#define CONFIG_R3D_DEMUXER 0 -+#define CONFIG_RAWVIDEO_DEMUXER 0 -+#define CONFIG_REALTEXT_DEMUXER 0 -+#define CONFIG_REDSPARK_DEMUXER 0 -+#define CONFIG_RL2_DEMUXER 0 -+#define CONFIG_RM_DEMUXER 0 -+#define CONFIG_ROQ_DEMUXER 0 -+#define CONFIG_RPL_DEMUXER 0 -+#define CONFIG_RSD_DEMUXER 0 -+#define CONFIG_RSO_DEMUXER 0 -+#define CONFIG_RTP_DEMUXER 0 -+#define CONFIG_RTSP_DEMUXER 0 -+#define CONFIG_S337M_DEMUXER 0 -+#define CONFIG_SAMI_DEMUXER 0 -+#define CONFIG_SAP_DEMUXER 0 -+#define CONFIG_SBC_DEMUXER 0 -+#define CONFIG_SBG_DEMUXER 0 -+#define CONFIG_SCC_DEMUXER 0 -+#define CONFIG_SDP_DEMUXER 0 -+#define CONFIG_SDR2_DEMUXER 0 -+#define CONFIG_SDS_DEMUXER 0 -+#define CONFIG_SDX_DEMUXER 0 -+#define CONFIG_SEGAFILM_DEMUXER 0 -+#define CONFIG_SER_DEMUXER 0 -+#define CONFIG_SHORTEN_DEMUXER 0 -+#define CONFIG_SIFF_DEMUXER 0 -+#define CONFIG_SLN_DEMUXER 0 -+#define CONFIG_SMACKER_DEMUXER 0 -+#define CONFIG_SMJPEG_DEMUXER 0 -+#define CONFIG_SMUSH_DEMUXER 0 -+#define CONFIG_SOL_DEMUXER 0 -+#define CONFIG_SOX_DEMUXER 0 -+#define CONFIG_SPDIF_DEMUXER 0 -+#define CONFIG_SRT_DEMUXER 0 -+#define CONFIG_STR_DEMUXER 0 -+#define CONFIG_STL_DEMUXER 0 -+#define CONFIG_SUBVIEWER1_DEMUXER 0 -+#define CONFIG_SUBVIEWER_DEMUXER 0 -+#define CONFIG_SUP_DEMUXER 0 -+#define CONFIG_SVAG_DEMUXER 0 -+#define CONFIG_SWF_DEMUXER 0 -+#define CONFIG_TAK_DEMUXER 0 -+#define CONFIG_TEDCAPTIONS_DEMUXER 0 -+#define CONFIG_THP_DEMUXER 0 -+#define CONFIG_THREEDOSTR_DEMUXER 0 -+#define CONFIG_TIERTEXSEQ_DEMUXER 0 -+#define CONFIG_TMV_DEMUXER 0 -+#define CONFIG_TRUEHD_DEMUXER 0 -+#define CONFIG_TTA_DEMUXER 0 -+#define CONFIG_TXD_DEMUXER 0 -+#define CONFIG_TTY_DEMUXER 0 -+#define CONFIG_TY_DEMUXER 0 -+#define CONFIG_V210_DEMUXER 0 -+#define CONFIG_V210X_DEMUXER 0 -+#define CONFIG_VAG_DEMUXER 0 -+#define CONFIG_VC1_DEMUXER 0 -+#define CONFIG_VC1T_DEMUXER 0 -+#define CONFIG_VIVIDAS_DEMUXER 0 -+#define CONFIG_VIVO_DEMUXER 0 -+#define CONFIG_VMD_DEMUXER 0 -+#define CONFIG_VOBSUB_DEMUXER 0 -+#define CONFIG_VOC_DEMUXER 0 -+#define CONFIG_VPK_DEMUXER 0 -+#define CONFIG_VPLAYER_DEMUXER 0 -+#define CONFIG_VQF_DEMUXER 0 -+#define CONFIG_W64_DEMUXER 0 -+#define CONFIG_WAV_DEMUXER 1 -+#define CONFIG_WC3_DEMUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 -+#define CONFIG_WEBVTT_DEMUXER 0 -+#define CONFIG_WSAUD_DEMUXER 0 -+#define CONFIG_WSD_DEMUXER 0 -+#define CONFIG_WSVQA_DEMUXER 0 -+#define CONFIG_WTV_DEMUXER 0 -+#define CONFIG_WVE_DEMUXER 0 -+#define CONFIG_WV_DEMUXER 0 -+#define CONFIG_XA_DEMUXER 0 -+#define CONFIG_XBIN_DEMUXER 0 -+#define CONFIG_XMV_DEMUXER 0 -+#define CONFIG_XVAG_DEMUXER 0 -+#define CONFIG_XWMA_DEMUXER 0 -+#define CONFIG_YOP_DEMUXER 0 -+#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 -+#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 -+#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 -+#define CONFIG_LIBGME_DEMUXER 0 -+#define CONFIG_LIBMODPLUG_DEMUXER 0 -+#define CONFIG_LIBOPENMPT_DEMUXER 0 -+#define CONFIG_VAPOURSYNTH_DEMUXER 0 -+#define CONFIG_A64_MUXER 0 -+#define CONFIG_AC3_MUXER 0 -+#define CONFIG_ADTS_MUXER 0 -+#define CONFIG_ADX_MUXER 0 -+#define CONFIG_AIFF_MUXER 0 -+#define CONFIG_AMR_MUXER 0 -+#define CONFIG_APM_MUXER 0 -+#define CONFIG_APNG_MUXER 0 -+#define CONFIG_APTX_MUXER 0 -+#define CONFIG_APTX_HD_MUXER 0 -+#define CONFIG_ARGO_ASF_MUXER 0 -+#define CONFIG_ASF_MUXER 0 -+#define CONFIG_ASS_MUXER 0 -+#define CONFIG_AST_MUXER 0 -+#define CONFIG_ASF_STREAM_MUXER 0 -+#define CONFIG_AU_MUXER 0 -+#define CONFIG_AVI_MUXER 0 -+#define CONFIG_AVM2_MUXER 0 -+#define CONFIG_AVS2_MUXER 0 -+#define CONFIG_BIT_MUXER 0 -+#define CONFIG_CAF_MUXER 0 -+#define CONFIG_CAVSVIDEO_MUXER 0 -+#define CONFIG_CODEC2_MUXER 0 -+#define CONFIG_CODEC2RAW_MUXER 0 -+#define CONFIG_CRC_MUXER 0 -+#define CONFIG_DASH_MUXER 0 -+#define CONFIG_DATA_MUXER 0 -+#define CONFIG_DAUD_MUXER 0 -+#define CONFIG_DIRAC_MUXER 0 -+#define CONFIG_DNXHD_MUXER 0 -+#define CONFIG_DTS_MUXER 0 -+#define CONFIG_DV_MUXER 0 -+#define CONFIG_EAC3_MUXER 0 -+#define CONFIG_F4V_MUXER 0 -+#define CONFIG_FFMETADATA_MUXER 0 -+#define CONFIG_FIFO_MUXER 0 -+#define CONFIG_FIFO_TEST_MUXER 0 -+#define CONFIG_FILMSTRIP_MUXER 0 -+#define CONFIG_FITS_MUXER 0 -+#define CONFIG_FLAC_MUXER 0 -+#define CONFIG_FLV_MUXER 0 -+#define CONFIG_FRAMECRC_MUXER 0 -+#define CONFIG_FRAMEHASH_MUXER 0 -+#define CONFIG_FRAMEMD5_MUXER 0 -+#define CONFIG_G722_MUXER 0 -+#define CONFIG_G723_1_MUXER 0 -+#define CONFIG_G726_MUXER 0 -+#define CONFIG_G726LE_MUXER 0 -+#define CONFIG_GIF_MUXER 0 -+#define CONFIG_GSM_MUXER 0 -+#define CONFIG_GXF_MUXER 0 -+#define CONFIG_H261_MUXER 0 -+#define CONFIG_H263_MUXER 0 -+#define CONFIG_H264_MUXER 0 -+#define CONFIG_HASH_MUXER 0 -+#define CONFIG_HDS_MUXER 0 -+#define CONFIG_HEVC_MUXER 0 -+#define CONFIG_HLS_MUXER 0 -+#define CONFIG_ICO_MUXER 0 -+#define CONFIG_ILBC_MUXER 0 -+#define CONFIG_IMAGE2_MUXER 0 -+#define CONFIG_IMAGE2PIPE_MUXER 0 -+#define CONFIG_IPOD_MUXER 0 -+#define CONFIG_IRCAM_MUXER 0 -+#define CONFIG_ISMV_MUXER 0 -+#define CONFIG_IVF_MUXER 0 -+#define CONFIG_JACOSUB_MUXER 0 -+#define CONFIG_KVAG_MUXER 0 -+#define CONFIG_LATM_MUXER 0 -+#define CONFIG_LRC_MUXER 0 -+#define CONFIG_M4V_MUXER 0 -+#define CONFIG_MD5_MUXER 0 -+#define CONFIG_MATROSKA_MUXER 0 -+#define CONFIG_MATROSKA_AUDIO_MUXER 0 -+#define CONFIG_MICRODVD_MUXER 0 -+#define CONFIG_MJPEG_MUXER 0 -+#define CONFIG_MLP_MUXER 0 -+#define CONFIG_MMF_MUXER 0 -+#define CONFIG_MOV_MUXER 0 -+#define CONFIG_MP2_MUXER 0 -+#define CONFIG_MP3_MUXER 0 -+#define CONFIG_MP4_MUXER 0 -+#define CONFIG_MPEG1SYSTEM_MUXER 0 -+#define CONFIG_MPEG1VCD_MUXER 0 -+#define CONFIG_MPEG1VIDEO_MUXER 0 -+#define CONFIG_MPEG2DVD_MUXER 0 -+#define CONFIG_MPEG2SVCD_MUXER 0 -+#define CONFIG_MPEG2VIDEO_MUXER 0 -+#define CONFIG_MPEG2VOB_MUXER 0 -+#define CONFIG_MPEGTS_MUXER 0 -+#define CONFIG_MPJPEG_MUXER 0 -+#define CONFIG_MXF_MUXER 0 -+#define CONFIG_MXF_D10_MUXER 0 -+#define CONFIG_MXF_OPATOM_MUXER 0 -+#define CONFIG_NULL_MUXER 0 -+#define CONFIG_NUT_MUXER 0 -+#define CONFIG_OGA_MUXER 0 -+#define CONFIG_OGG_MUXER 0 -+#define CONFIG_OGV_MUXER 0 -+#define CONFIG_OMA_MUXER 0 -+#define CONFIG_OPUS_MUXER 0 -+#define CONFIG_PCM_ALAW_MUXER 0 -+#define CONFIG_PCM_MULAW_MUXER 0 -+#define CONFIG_PCM_VIDC_MUXER 0 -+#define CONFIG_PCM_F64BE_MUXER 0 -+#define CONFIG_PCM_F64LE_MUXER 0 -+#define CONFIG_PCM_F32BE_MUXER 0 -+#define CONFIG_PCM_F32LE_MUXER 0 -+#define CONFIG_PCM_S32BE_MUXER 0 -+#define CONFIG_PCM_S32LE_MUXER 0 -+#define CONFIG_PCM_S24BE_MUXER 0 -+#define CONFIG_PCM_S24LE_MUXER 0 -+#define CONFIG_PCM_S16BE_MUXER 0 -+#define CONFIG_PCM_S16LE_MUXER 0 -+#define CONFIG_PCM_S8_MUXER 0 -+#define CONFIG_PCM_U32BE_MUXER 0 -+#define CONFIG_PCM_U32LE_MUXER 0 -+#define CONFIG_PCM_U24BE_MUXER 0 -+#define CONFIG_PCM_U24LE_MUXER 0 -+#define CONFIG_PCM_U16BE_MUXER 0 -+#define CONFIG_PCM_U16LE_MUXER 0 -+#define CONFIG_PCM_U8_MUXER 0 -+#define CONFIG_PSP_MUXER 0 -+#define CONFIG_RAWVIDEO_MUXER 0 -+#define CONFIG_RM_MUXER 0 -+#define CONFIG_ROQ_MUXER 0 -+#define CONFIG_RSO_MUXER 0 -+#define CONFIG_RTP_MUXER 0 -+#define CONFIG_RTP_MPEGTS_MUXER 0 -+#define CONFIG_RTSP_MUXER 0 -+#define CONFIG_SAP_MUXER 0 -+#define CONFIG_SBC_MUXER 0 -+#define CONFIG_SCC_MUXER 0 -+#define CONFIG_SEGAFILM_MUXER 0 -+#define CONFIG_SEGMENT_MUXER 0 -+#define CONFIG_STREAM_SEGMENT_MUXER 0 -+#define CONFIG_SINGLEJPEG_MUXER 0 -+#define CONFIG_SMJPEG_MUXER 0 -+#define CONFIG_SMOOTHSTREAMING_MUXER 0 -+#define CONFIG_SOX_MUXER 0 -+#define CONFIG_SPX_MUXER 0 -+#define CONFIG_SPDIF_MUXER 0 -+#define CONFIG_SRT_MUXER 0 -+#define CONFIG_STREAMHASH_MUXER 0 -+#define CONFIG_SUP_MUXER 0 -+#define CONFIG_SWF_MUXER 0 -+#define CONFIG_TEE_MUXER 0 -+#define CONFIG_TG2_MUXER 0 -+#define CONFIG_TGP_MUXER 0 -+#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 -+#define CONFIG_TRUEHD_MUXER 0 -+#define CONFIG_TTA_MUXER 0 -+#define CONFIG_UNCODEDFRAMECRC_MUXER 0 -+#define CONFIG_VC1_MUXER 0 -+#define CONFIG_VC1T_MUXER 0 -+#define CONFIG_VOC_MUXER 0 -+#define CONFIG_W64_MUXER 0 -+#define CONFIG_WAV_MUXER 0 -+#define CONFIG_WEBM_MUXER 0 -+#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 -+#define CONFIG_WEBM_CHUNK_MUXER 0 -+#define CONFIG_WEBP_MUXER 0 -+#define CONFIG_WEBVTT_MUXER 0 -+#define CONFIG_WTV_MUXER 0 -+#define CONFIG_WV_MUXER 0 -+#define CONFIG_YUV4MPEGPIPE_MUXER 0 -+#define CONFIG_CHROMAPRINT_MUXER 0 -+#define CONFIG_ASYNC_PROTOCOL 0 -+#define CONFIG_BLURAY_PROTOCOL 0 -+#define CONFIG_CACHE_PROTOCOL 0 -+#define CONFIG_CONCAT_PROTOCOL 0 -+#define CONFIG_CRYPTO_PROTOCOL 0 -+#define CONFIG_DATA_PROTOCOL 0 -+#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 -+#define CONFIG_FFRTMPHTTP_PROTOCOL 0 -+#define CONFIG_FILE_PROTOCOL 0 -+#define CONFIG_FTP_PROTOCOL 0 -+#define CONFIG_GOPHER_PROTOCOL 0 -+#define CONFIG_HLS_PROTOCOL 0 -+#define CONFIG_HTTP_PROTOCOL 0 -+#define CONFIG_HTTPPROXY_PROTOCOL 0 -+#define CONFIG_HTTPS_PROTOCOL 0 -+#define CONFIG_ICECAST_PROTOCOL 0 -+#define CONFIG_MMSH_PROTOCOL 0 -+#define CONFIG_MMST_PROTOCOL 0 -+#define CONFIG_MD5_PROTOCOL 0 -+#define CONFIG_PIPE_PROTOCOL 0 -+#define CONFIG_PROMPEG_PROTOCOL 0 -+#define CONFIG_RTMP_PROTOCOL 0 -+#define CONFIG_RTMPE_PROTOCOL 0 -+#define CONFIG_RTMPS_PROTOCOL 0 -+#define CONFIG_RTMPT_PROTOCOL 0 -+#define CONFIG_RTMPTE_PROTOCOL 0 -+#define CONFIG_RTMPTS_PROTOCOL 0 -+#define CONFIG_RTP_PROTOCOL 0 -+#define CONFIG_SCTP_PROTOCOL 0 -+#define CONFIG_SRTP_PROTOCOL 0 -+#define CONFIG_SUBFILE_PROTOCOL 0 -+#define CONFIG_TEE_PROTOCOL 0 -+#define CONFIG_TCP_PROTOCOL 0 -+#define CONFIG_TLS_PROTOCOL 0 -+#define CONFIG_UDP_PROTOCOL 0 -+#define CONFIG_UDPLITE_PROTOCOL 0 -+#define CONFIG_UNIX_PROTOCOL 0 -+#define CONFIG_LIBAMQP_PROTOCOL 0 -+#define CONFIG_LIBRTMP_PROTOCOL 0 -+#define CONFIG_LIBRTMPE_PROTOCOL 0 -+#define CONFIG_LIBRTMPS_PROTOCOL 0 -+#define CONFIG_LIBRTMPT_PROTOCOL 0 -+#define CONFIG_LIBRTMPTE_PROTOCOL 0 -+#define CONFIG_LIBSRT_PROTOCOL 0 -+#define CONFIG_LIBSSH_PROTOCOL 0 -+#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 -+#define CONFIG_LIBZMQ_PROTOCOL 0 -+#endif /* FFMPEG_CONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/bsf_list.c -@@ -0,0 +1,3 @@ -+static const AVBitStreamFilter * const bitstream_filters[] = { -+ &ff_null_bsf, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/codec_list.c -@@ -0,0 +1,18 @@ -+static const AVCodec * const codec_list[] = { -+ &ff_theora_decoder, -+ &ff_vp3_decoder, -+ &ff_vp8_decoder, -+ &ff_flac_decoder, -+ &ff_mp3_decoder, -+ &ff_vorbis_decoder, -+ &ff_pcm_alaw_decoder, -+ &ff_pcm_f32le_decoder, -+ &ff_pcm_mulaw_decoder, -+ &ff_pcm_s16be_decoder, -+ &ff_pcm_s16le_decoder, -+ &ff_pcm_s24be_decoder, -+ &ff_pcm_s24le_decoder, -+ &ff_pcm_s32le_decoder, -+ &ff_pcm_u8_decoder, -+ &ff_libopus_decoder, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/parser_list.c -@@ -0,0 +1,9 @@ -+static const AVCodecParser * const parser_list[] = { -+ &ff_flac_parser, -+ &ff_mpegaudio_parser, -+ &ff_opus_parser, -+ &ff_vorbis_parser, -+ &ff_vp3_parser, -+ &ff_vp8_parser, -+ &ff_vp9_parser, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/demuxer_list.c -@@ -0,0 +1,8 @@ -+static const AVInputFormat * const demuxer_list[] = { -+ &ff_flac_demuxer, -+ &ff_matroska_demuxer, -+ &ff_mov_demuxer, -+ &ff_mp3_demuxer, -+ &ff_ogg_demuxer, -+ &ff_wav_demuxer, -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/muxer_list.c -@@ -0,0 +1,2 @@ -+static const AVOutputFormat * const muxer_list[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/protocol_list.c -@@ -0,0 +1,2 @@ -+static const URLProtocol * const url_protocols[] = { -+ NULL }; ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavutil/avconfig.h -@@ -0,0 +1,6 @@ -+/* Generated by ffmpeg configure */ -+#ifndef AVUTIL_AVCONFIG_H -+#define AVUTIL_AVCONFIG_H -+#define AV_HAVE_BIGENDIAN 0 -+#define AV_HAVE_FAST_UNALIGNED 0 -+#endif /* AVUTIL_AVCONFIG_H */ ---- /dev/null -+++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavutil/ffversion.h -@@ -0,0 +1,5 @@ -+/* Automatically generated by version.sh, do not manually edit! */ -+#ifndef AVUTIL_FFVERSION_H -+#define AVUTIL_FFVERSION_H -+#define FFMPEG_VERSION "N-99931-gb6530ca24d" -+#endif /* AVUTIL_FFVERSION_H */ ---- a/src/3rdparty/chromium/base/BUILD.gn -+++ b/src/3rdparty/chromium/base/BUILD.gn -@@ -1308,7 +1308,7 @@ - # Needed for if using newer C++ library than sysroot, except if - # building inside the cros_sdk environment - use host_toolchain as a - # more robust check for this. -- if (!use_sysroot && -+ if (current_cpu == "riscv64" || !use_sysroot && - (is_android || ((is_linux || is_chromeos) && !is_chromecast && !use_qt)) && - host_toolchain != "//build/toolchain/cros:host") { - libs += [ "atomic" ] diff --git a/debian/patches/breakpad-getcontext.patch b/debian/patches/breakpad-getcontext.patch index 6579d913c4..6d46411756 100644 --- a/debian/patches/breakpad-getcontext.patch +++ b/debian/patches/breakpad-getcontext.patch @@ -1,6 +1,6 @@ Description: use system getcontext instead of breakpad's own Author: Dmitry Shachnev -Forwarded: no +Forwarded: not-needed Last-Update: 2021-03-16 --- a/src/3rdparty/chromium/third_party/breakpad/BUILD.gn diff --git a/debian/patches/build-with-c++17.patch b/debian/patches/build-with-c++17.patch new file mode 100644 index 0000000000..af9347eccd --- /dev/null +++ b/debian/patches/build-with-c++17.patch @@ -0,0 +1,89 @@ +Description: Build with C++17, which is required by ICU 75. +Author: Soren Stoutner +Forwarded: not-needed +Last-Update: 2024-05-21 +Origin: Arch Linux, https://gitlab.archlinux.org/archlinux/packaging/packages/qt5-webengine/-/blob/main/qt5-webengine-icu-75.patch?ref_type=heads + +--- a/src/3rdparty/chromium/build/config/compiler/BUILD.gn ++++ b/src/3rdparty/chromium/build/config/compiler/BUILD.gn +@@ -566,7 +566,7 @@ config("compiler") { + # Override Chromium's default for projects that wish to stay on C++11. + cflags_cc += [ "-std=${standard_prefix}++11" ] + } else { +- cflags_cc += [ "-std=${standard_prefix}++14" ] ++ cflags_cc += [ "-std=${standard_prefix}++17" ] + } + } else if (!is_win && !is_nacl) { + if (target_os == "android") { +--- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h ++++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h +@@ -195,7 +195,7 @@ NumPartitionPagesPerSuperPage() { + // + // __STDCPP_DEFAULT_NEW_ALIGNMENT__ is C++17. As such, it is not defined on all + // platforms, as Chrome's requirement is C++14 as of 2020. +-#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) ++#if 0 + static constexpr size_t kAlignment = + std::max(alignof(std::max_align_t), __STDCPP_DEFAULT_NEW_ALIGNMENT__); + #else +--- a/src/3rdparty/chromium/third_party/webrtc/common_video/h264/sps_parser.h ++++ b/src/3rdparty/chromium/third_party/webrtc/common_video/h264/sps_parser.h +@@ -12,6 +12,7 @@ + #define COMMON_VIDEO_H264_SPS_PARSER_H_ + + #include "absl/types/optional.h" ++#include + + namespace rtc { + class BitBuffer; +--- a/src/3rdparty/chromium/third_party/webrtc/common_video/h264/pps_parser.h ++++ b/src/3rdparty/chromium/third_party/webrtc/common_video/h264/pps_parser.h +@@ -12,6 +12,7 @@ + #define COMMON_VIDEO_H264_PPS_PARSER_H_ + + #include "absl/types/optional.h" ++#include + + namespace rtc { + class BitBuffer; +--- a/src/3rdparty/chromium/third_party/webrtc/modules/include/module_common_types_public.h ++++ b/src/3rdparty/chromium/third_party/webrtc/modules/include/module_common_types_public.h +@@ -14,6 +14,7 @@ + #include + + #include "absl/types/optional.h" ++#include + + namespace webrtc { + +--- a/src/3rdparty/chromium/third_party/webrtc/modules/audio_processing/aec3/reverb_model_estimator.h ++++ b/src/3rdparty/chromium/third_party/webrtc/modules/audio_processing/aec3/reverb_model_estimator.h +@@ -13,6 +13,7 @@ + + #include + #include ++#include + + #include "absl/types/optional.h" + #include "api/array_view.h" +--- a/src/3rdparty/chromium/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.cc ++++ b/src/3rdparty/chromium/third_party/blink/renderer/core/page/scrolling/text_fragment_selector_generator.cc +@@ -15,6 +15,7 @@ + #include "third_party/blink/renderer/core/page/scrolling/text_fragment_anchor_metrics.h" + #include "third_party/blink/renderer/core/page/scrolling/text_fragment_finder.h" + #include "third_party/blink/renderer/platform/text/text_boundaries.h" ++#include "absl/base/attributes.h" + + namespace blink { + +--- a/src/3rdparty/chromium/third_party/abseil-cpp/absl/base/options.h ++++ b/src/3rdparty/chromium/third_party/abseil-cpp/absl/base/options.h +@@ -180,7 +180,7 @@ + // absl::variant is a typedef of std::variant, use the feature macro + // ABSL_USES_STD_VARIANT. + +-#define ABSL_OPTION_USE_STD_VARIANT 2 ++#define ABSL_OPTION_USE_STD_VARIANT 0 + + + // ABSL_OPTION_USE_INLINE_NAMESPACE diff --git a/debian/patches/chromium-python3.patch b/debian/patches/chromium-python3.patch deleted file mode 100644 index d3c84a28bf..0000000000 --- a/debian/patches/chromium-python3.patch +++ /dev/null @@ -1,1687 +0,0 @@ -Description: update Chromium code for compatibility with Python 3 -Origin: https://github.com/archlinux/svntogit-packages/blob/packages/qt5-webengine/trunk/qt5-webengine-chromium-python3.patch -Last-Update: 2022-11-25 - ---- a/src/3rdparty/chromium/build/print_python_deps.py -+++ b/src/3rdparty/chromium/build/print_python_deps.py -@@ -1,4 +1,4 @@ --#!/usr/bin/python2.7 -+#!/usr/bin/python3 - # Copyright 2016 The Chromium Authors. All rights reserved. - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. -@@ -152,7 +152,7 @@ def main(): - - # Trybots run with vpython as default Python, but with a different config - # from //.vpython. To make the is_vpython test work, and to match the behavior -- # of dev machines, the shebang line must be run with python2.7. -+ # of dev machines, the shebang line must be run with python3. - # - # E.g. $HOME/.vpython-root/dd50d3/bin/python - # E.g. /b/s/w/ir/cache/vpython/ab5c79/bin/python ---- a/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py -+++ b/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py -@@ -7,7 +7,7 @@ - Converts a given ASCII proto into a binary resource. - - """ -- -+from __future__ import print_function - import abc - import imp - import optparse -@@ -196,12 +196,12 @@ class BinaryProtoGenerator: - self._ImportProtoModules(opts.path) - - if not self.VerifyArgs(opts): -- print "Wrong arguments" -+ print("Wrong arguments") - return 1 - - try: - self._GenerateBinaryProtos(opts) - except Exception as e: -- print "ERROR: Failed to render binary version of %s:\n %s\n%s" % ( -- opts.infile, str(e), traceback.format_exc()) -+ print("ERROR: Failed to render binary version of %s:\n %s\n%s" % -+ (opts.infile, str(e), traceback.format_exc())) - return 1 ---- a/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py -+++ b/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py -@@ -74,7 +74,7 @@ def main(argv): - for filename in parsed_args.source_files: - add_file_to_grd(doc, os.path.basename(filename)) - -- with open(parsed_args.output_filename, 'w') as output_file: -+ with open(parsed_args.output_filename, 'wb') as output_file: - output_file.write(doc.toxml(encoding='UTF-8')) - - ---- a/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn -+++ b/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn -@@ -2,9 +2,11 @@ - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. - -+import("//build/config/python.gni") - import("//mojo/public/tools/bindings/mojom.gni") - import("//third_party/jinja2/jinja2.gni") - -+# TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds. - action("precompile_templates") { - sources = mojom_generator_sources - sources += [ ---- a/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py -+++ b/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py -@@ -18,7 +18,6 @@ import os - import re - import sys - --from cStringIO import StringIO - from optparse import OptionParser - - sys.path.insert( -@@ -41,12 +40,9 @@ def main(): - pattern = re.compile(options.pattern) - files = [f for f in os.listdir(options.directory) if pattern.match(f)] - -- stream = StringIO() -- for f in files: -- print(f, file=stream) -+ contents = '\n'.join(f for f in files) + '\n' -+ WriteFile(contents, options.output) - -- WriteFile(stream.getvalue(), options.output) -- stream.close() - - if __name__ == '__main__': - sys.exit(main()) ---- a/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py -+++ b/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py -@@ -25,6 +25,10 @@ sys.path.append(os.path.join(os.path.dir - 'build', 'android', 'gyp')) - from util import build_utils - -+# TODO(crbug.com/1174969): Remove this once Python2 is obsoleted. -+if sys.version_info.major != 2: -+ basestring = str -+ long = int - - GENERATOR_PREFIX = 'java' - ---- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py -+++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py -@@ -136,9 +136,14 @@ class Stylizer(object): - - def WriteFile(contents, full_path): - # If |contents| is same with the file content, we skip updating. -+ if not isinstance(contents, bytes): -+ data = contents.encode('utf8') -+ else: -+ data = contents -+ - if os.path.isfile(full_path): - with open(full_path, 'rb') as destination_file: -- if destination_file.read() == contents: -+ if destination_file.read() == data: - return - - # Make sure the containing directory exists. -@@ -146,11 +151,8 @@ def WriteFile(contents, full_path): - fileutil.EnsureDirectoryExists(full_dir) - - # Dump the data to disk. -- with open(full_path, "wb") as f: -- if not isinstance(contents, bytes): -- f.write(contents.encode('utf-8')) -- else: -- f.write(contents) -+ with open(full_path, 'wb') as f: -+ f.write(data) - - - def AddComputedData(module): ---- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py -+++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py -@@ -398,7 +398,8 @@ class Field(object): - - - class StructField(Field): -- pass -+ def __hash__(self): -+ return super(Field, self).__hash__() - - - class UnionField(Field): ---- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py -+++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py -@@ -75,9 +75,9 @@ def PrecompileTemplates(generator_module - os.path.dirname(module.__file__), generator.GetTemplatePrefix()) - ])) - jinja_env.filters.update(generator.GetFilters()) -- jinja_env.compile_templates( -- os.path.join(output_dir, "%s.zip" % generator.GetTemplatePrefix()), -- extensions=["tmpl"], -- zip="stored", -- py_compile=True, -- ignore_errors=False) -+ jinja_env.compile_templates(os.path.join( -+ output_dir, "%s.zip" % generator.GetTemplatePrefix()), -+ extensions=["tmpl"], -+ zip="stored", -+ py_compile=sys.version_info.major < 3, -+ ignore_errors=False) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py -@@ -344,7 +344,7 @@ def make_default_value_expr(idl_type, de - """ - assert default_value.is_type_compatible_with(idl_type) - -- class DefaultValueExpr: -+ class DefaultValueExpr(object): - _ALLOWED_SYMBOLS_IN_DEPS = ("isolate") - - def __init__(self, initializer_expr, initializer_deps, -@@ -502,7 +502,7 @@ def make_v8_to_blink_value(blink_var_nam - assert isinstance(blink_var_name, str) - assert isinstance(v8_value_expr, str) - assert isinstance(idl_type, web_idl.IdlType) -- assert (argument_index is None or isinstance(argument_index, (int, long))) -+ assert (argument_index is None or isinstance(argument_index, int)) - assert (default_value is None - or isinstance(default_value, web_idl.LiteralConstant)) - -@@ -622,7 +622,7 @@ def make_v8_to_blink_value_variadic(blin - """ - assert isinstance(blink_var_name, str) - assert isinstance(v8_array, str) -- assert isinstance(v8_array_start_index, (int, long)) -+ assert isinstance(v8_array_start_index, int) - assert isinstance(idl_type, web_idl.IdlType) - - pattern = ("auto&& ${{{_1}}} = " ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py -@@ -177,7 +177,7 @@ def generate_callback_interface(callback - prop_install_mode=PropInstallMode.UNCONDITIONAL, - trampoline_var_name=None, - attribute_entries=[], -- constant_entries=filter(is_unconditional, constant_entries), -+ constant_entries=list(filter(is_unconditional, constant_entries)), - exposed_construct_entries=[], - operation_entries=[]) - (install_interface_template_decl, install_interface_template_def, ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py -@@ -503,13 +503,13 @@ class CompositeNode(CodeNode): - gensym_kwargs = {} - template_vars = {} - for arg in args: -- assert isinstance(arg, (CodeNode, int, long, str)) -+ assert isinstance(arg, (CodeNode, int, str)) - gensym = CodeNode.gensym() - gensym_args.append("${{{}}}".format(gensym)) - template_vars[gensym] = arg - for key, value in kwargs.items(): -- assert isinstance(key, (int, long, str)) -- assert isinstance(value, (CodeNode, int, long, str)) -+ assert isinstance(key, (int, str)) -+ assert isinstance(value, (CodeNode, int, str)) - gensym = CodeNode.gensym() - gensym_kwargs[key] = "${{{}}}".format(gensym) - template_vars[gensym] = value -@@ -602,7 +602,7 @@ class ListNode(CodeNode): - def insert(self, index, node): - if node is None: - return -- assert isinstance(index, (int, long)) -+ assert isinstance(index, int) - assert isinstance(node, CodeNode) - assert node.outer is None and node.prev is None - -@@ -721,7 +721,7 @@ class SymbolScopeNode(SequenceNode): - if not scope_chains: - return counts - -- self_index = iter(scope_chains).next().index(self) -+ self_index = next(iter(scope_chains)).index(self) - scope_chains = map( - lambda scope_chain: scope_chain[self_index + 1:], scope_chains) - scope_to_likeliness = {} ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py -@@ -109,7 +109,7 @@ def expr_and(terms): - - if any(term.is_always_false for term in terms): - return _Expr(False) -- terms = filter(lambda x: not x.is_always_true, terms) -+ terms = list(filter(lambda x: not x.is_always_true, terms)) - if not terms: - return _Expr(True) - if len(terms) == 1: -@@ -124,7 +124,7 @@ def expr_or(terms): - - if any(term.is_always_true for term in terms): - return _Expr(True) -- terms = filter(lambda x: not x.is_always_false, terms) -+ terms = list(filter(lambda x: not x.is_always_false, terms)) - if not terms: - return _Expr(False) - if len(terms) == 1: -@@ -222,7 +222,7 @@ def expr_from_exposure(exposure, - elif exposure.only_in_secure_contexts is False: - secure_context_term = _Expr(True) - else: -- terms = map(ref_enabled, exposure.only_in_secure_contexts) -+ terms = list(map(ref_enabled, exposure.only_in_secure_contexts)) - secure_context_term = expr_or( - [_Expr("${is_in_secure_context}"), - expr_not(expr_and(terms))]) -@@ -275,10 +275,11 @@ def expr_from_exposure(exposure, - - # [ContextEnabled] - if exposure.context_enabled_features: -- terms = map( -- lambda feature: _Expr( -- "${{context_feature_settings}}->is{}Enabled()".format( -- feature)), exposure.context_enabled_features) -+ terms = list( -+ map( -+ lambda feature: _Expr( -+ "${{context_feature_settings}}->is{}Enabled()".format( -+ feature)), exposure.context_enabled_features)) - context_enabled_terms.append( - expr_and([_Expr("${context_feature_settings}"), - expr_or(terms)])) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py -@@ -23,7 +23,7 @@ class _TemplateFormatter(string.Formatte - self._template_formatter_indexing_count_ = 0 - - def get_value(self, key, args, kwargs): -- if isinstance(key, (int, long)): -+ if isinstance(key, int): - return args[key] - assert isinstance(key, str) - if not key: ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py -@@ -116,4 +116,4 @@ def write_code_node_to_file(code_node, f - # stderr=format_result.error_message)) - # - # web_idl.file_io.write_to_file_if_changed(filepath, format_result.contents) -- web_idl.file_io.write_to_file_if_changed(filepath, rendered_text) -+ web_idl.file_io.write_to_file_if_changed(filepath, rendered_text.encode('utf-8')) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py -@@ -993,7 +993,7 @@ def make_dict_trace_func(cg_context): - _2 = _blink_member_name(member).value_var - return TextNode(_format(pattern, _1=_1, _2=_2)) - -- body.extend(map(make_trace_member_node, own_members)) -+ body.extend(list(map(make_trace_member_node, own_members))) - body.append(TextNode("BaseClass::Trace(visitor);")) - - return func_decl, func_def ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py -@@ -582,7 +582,7 @@ def _make_blink_api_call(code_node, - overriding_args=None): - assert isinstance(code_node, SymbolScopeNode) - assert isinstance(cg_context, CodeGenContext) -- assert num_of_args is None or isinstance(num_of_args, (int, long)) -+ assert num_of_args is None or isinstance(num_of_args, int) - assert (overriding_args is None - or (isinstance(overriding_args, (list, tuple)) - and all(isinstance(arg, str) for arg in overriding_args))) -@@ -1196,8 +1196,10 @@ def make_overload_dispatcher(cg_context) - did_use_break = did_use_break or can_fail - - conditional = expr_or( -- map(lambda item: expr_from_exposure(item.function_like.exposure), -- items)) -+ list( -+ map( -+ lambda item: expr_from_exposure(item.function_like.exposure -+ ), items))) - if not conditional.is_always_true: - node = CxxUnlikelyIfNode(cond=conditional, body=node) - -@@ -4642,7 +4644,7 @@ class _PropEntryConstructorGroup(_PropEn - def __init__(self, is_context_dependent, exposure_conditional, world, - constructor_group, ctor_callback_name, ctor_func_length): - assert isinstance(ctor_callback_name, str) -- assert isinstance(ctor_func_length, (int, long)) -+ assert isinstance(ctor_func_length, int) - - _PropEntryBase.__init__(self, is_context_dependent, - exposure_conditional, world, constructor_group) -@@ -4670,7 +4672,7 @@ class _PropEntryOperationGroup(_PropEntr - op_func_length, - no_alloc_direct_callback_name=None): - assert isinstance(op_callback_name, str) -- assert isinstance(op_func_length, (int, long)) -+ assert isinstance(op_func_length, int) - - _PropEntryBase.__init__(self, is_context_dependent, - exposure_conditional, world, operation_group) -@@ -5175,9 +5177,9 @@ def make_install_interface_template(cg_c - ]) - - if class_like.identifier == "CSSStyleDeclaration": -- css_properties = filter( -- lambda attr: "CSSProperty" in attr.extended_attributes, -- class_like.attributes) -+ css_properties = list( -+ filter(lambda attr: "CSSProperty" in attr.extended_attributes, -+ class_like.attributes)) - if css_properties: - prop_name_list = "".join( - map(lambda attr: "\"{}\", ".format(attr.identifier), -@@ -5567,8 +5569,8 @@ ${instance_object} = ${v8_context}->Glob - "V8DOMConfiguration::InstallConstants(${isolate}, " - "${interface_template}, ${prototype_template}, " - "kConstantCallbackTable, base::size(kConstantCallbackTable));") -- constant_callback_entries = filter(lambda entry: entry.const_callback_name, -- constant_entries) -+ constant_callback_entries = list(filter(lambda entry: entry.const_callback_name, -+ constant_entries)) - install_properties(table_name, constant_callback_entries, - _make_constant_callback_registration_table, - installer_call_text) -@@ -5584,8 +5586,8 @@ ${instance_object} = ${v8_context}->Glob - "V8DOMConfiguration::InstallConstants(${isolate}, " - "${interface_template}, ${prototype_template}, " - "kConstantValueTable, base::size(kConstantValueTable));") -- constant_value_entries = filter( -- lambda entry: not entry.const_callback_name, constant_entries) -+ constant_value_entries = list(filter( -+ lambda entry: not entry.const_callback_name, constant_entries)) - install_properties(table_name, constant_value_entries, - _make_constant_value_registration_table, - installer_call_text) -@@ -6336,8 +6338,8 @@ def make_v8_context_snapshot_api(cg_cont - assert isinstance(component, web_idl.Component) - - derived_interfaces = cg_context.interface.deriveds -- derived_names = map(lambda interface: interface.identifier, -- derived_interfaces) -+ derived_names = list( -+ map(lambda interface: interface.identifier, derived_interfaces)) - derived_names.append(cg_context.interface.identifier) - if not ("Window" in derived_names or "HTMLDocument" in derived_names): - return None, None -@@ -6411,9 +6413,11 @@ def _make_v8_context_snapshot_get_refere - collect_callbacks(named_properties_object_callback_defs) - collect_callbacks(cross_origin_property_callback_defs) - -- entry_nodes = map( -- lambda name: TextNode("reinterpret_cast({}),".format(name)), -- filter(None, callback_names)) -+ entry_nodes = list( -+ map( -+ lambda name: TextNode("reinterpret_cast({}),".format(name -+ )), -+ filter(None, callback_names))) - table_node = ListNode([ - TextNode("using namespace ${class_name}Callbacks;"), - TextNode("static const intptr_t kReferenceTable[] = {"), -@@ -6451,10 +6455,11 @@ def _make_v8_context_snapshot_install_pr - class_name=None, - prop_install_mode=PropInstallMode.V8_CONTEXT_SNAPSHOT, - trampoline_var_name=None, -- attribute_entries=filter(selector, attribute_entries), -- constant_entries=filter(selector, constant_entries), -- exposed_construct_entries=filter(selector, exposed_construct_entries), -- operation_entries=filter(selector, operation_entries)) -+ attribute_entries=list(filter(selector, attribute_entries)), -+ constant_entries=list(filter(selector, constant_entries)), -+ exposed_construct_entries=list( -+ filter(selector, exposed_construct_entries)), -+ operation_entries=list(filter(selector, operation_entries))) - - return func_decl, func_def - -@@ -6810,11 +6815,11 @@ def generate_interface(interface_identif - class_name=impl_class_name, - prop_install_mode=PropInstallMode.UNCONDITIONAL, - trampoline_var_name=tp_install_unconditional_props, -- attribute_entries=filter(is_unconditional, attribute_entries), -- constant_entries=filter(is_unconditional, constant_entries), -- exposed_construct_entries=filter(is_unconditional, -- exposed_construct_entries), -- operation_entries=filter(is_unconditional, operation_entries)) -+ attribute_entries=list(filter(is_unconditional, attribute_entries)), -+ constant_entries=list(filter(is_unconditional, constant_entries)), -+ exposed_construct_entries=list( -+ filter(is_unconditional, exposed_construct_entries)), -+ operation_entries=list(filter(is_unconditional, operation_entries))) - (install_context_independent_props_decl, - install_context_independent_props_def, - install_context_independent_props_trampoline) = make_install_properties( -@@ -6823,11 +6828,14 @@ def generate_interface(interface_identif - class_name=impl_class_name, - prop_install_mode=PropInstallMode.CONTEXT_INDEPENDENT, - trampoline_var_name=tp_install_context_independent_props, -- attribute_entries=filter(is_context_independent, attribute_entries), -- constant_entries=filter(is_context_independent, constant_entries), -- exposed_construct_entries=filter(is_context_independent, -- exposed_construct_entries), -- operation_entries=filter(is_context_independent, operation_entries)) -+ attribute_entries=list( -+ filter(is_context_independent, attribute_entries)), -+ constant_entries=list(filter(is_context_independent, -+ constant_entries)), -+ exposed_construct_entries=list( -+ filter(is_context_independent, exposed_construct_entries)), -+ operation_entries=list( -+ filter(is_context_independent, operation_entries))) - (install_context_dependent_props_decl, install_context_dependent_props_def, - install_context_dependent_props_trampoline) = make_install_properties( - cg_context, -@@ -6835,11 +6843,13 @@ def generate_interface(interface_identif - class_name=impl_class_name, - prop_install_mode=PropInstallMode.CONTEXT_DEPENDENT, - trampoline_var_name=tp_install_context_dependent_props, -- attribute_entries=filter(is_context_dependent, attribute_entries), -- constant_entries=filter(is_context_dependent, constant_entries), -- exposed_construct_entries=filter(is_context_dependent, -- exposed_construct_entries), -- operation_entries=filter(is_context_dependent, operation_entries)) -+ attribute_entries=list(filter(is_context_dependent, -+ attribute_entries)), -+ constant_entries=list(filter(is_context_dependent, constant_entries)), -+ exposed_construct_entries=list( -+ filter(is_context_dependent, exposed_construct_entries)), -+ operation_entries=list(filter(is_context_dependent, -+ operation_entries))) - (install_interface_template_decl, install_interface_template_def, - install_interface_template_trampoline) = make_install_interface_template( - cg_context, ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py -@@ -105,7 +105,7 @@ class MakoRenderer(object): - on_error = self._caller_stack_on_error - if (len(current) <= len(on_error) - and all(current[i] == on_error[i] -- for i in xrange(len(current)))): -+ for i in range(len(current)))): - pass # Error happened in a deeper caller. - else: - self._caller_stack_on_error = list(self._caller_stack) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py -@@ -70,8 +70,13 @@ def gn_format(contents, filename=None): - - - def _invoke_format_command(command_line, filename, contents): -- proc = subprocess.Popen( -- command_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE) -+ kwargs = {} -+ if sys.version_info.major != 2: -+ kwargs['encoding'] = 'utf-8' -+ proc = subprocess.Popen(command_line, -+ stdin=subprocess.PIPE, -+ stdout=subprocess.PIPE, -+ **kwargs) - stdout_output, stderr_output = proc.communicate(input=contents) - exit_code = proc.wait() - ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py -@@ -2,6 +2,7 @@ - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. - -+import functools - import multiprocessing - - from .package_initializer import package_initializer -@@ -76,7 +77,7 @@ class TaskQueue(object): - if not report_progress: - return - -- done_count = reduce( -+ done_count = functools.reduce( - lambda count, worker_task: count + bool(worker_task.ready()), - self._worker_tasks, 0) - report_progress(len(self._worker_tasks), done_count) -@@ -85,4 +86,4 @@ class TaskQueue(object): - def _task_queue_run_tasks(tasks): - for task in tasks: - func, args, kwargs = task -- apply(func, args, kwargs) -+ func(*args, **kwargs) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py -@@ -13,6 +13,7 @@ import re - import sys - - from idl_types import set_ancestors, IdlType -+from itertools import groupby - from v8_globals import includes - from v8_interface import constant_filters - from v8_types import set_component_dirs -@@ -43,6 +44,7 @@ TEMPLATES_DIR = os.path.normpath( - # after path[0] == invoking script dir - sys.path.insert(1, THIRD_PARTY_DIR) - import jinja2 -+from jinja2.filters import make_attrgetter, environmentfilter - - - def generate_indented_conditional(code, conditional): -@@ -88,6 +90,13 @@ def runtime_enabled_if(code, name): - return generate_indented_conditional(code, function) - - -+@environmentfilter -+def do_stringify_key_group_by(environment, value, attribute): -+ expr = make_attrgetter(environment, attribute) -+ key = lambda item: '' if expr(item) is None else str(expr(item)) -+ return groupby(sorted(value, key=key), expr) -+ -+ - def initialize_jinja_env(cache_dir): - jinja_env = jinja2.Environment( - loader=jinja2.FileSystemLoader(TEMPLATES_DIR), -@@ -117,6 +126,7 @@ def initialize_jinja_env(cache_dir): - }) - jinja_env.filters.update(constant_filters()) - jinja_env.filters.update(method_filters()) -+ jinja_env.filters["stringifykeygroupby"] = do_stringify_key_group_by - return jinja_env - - ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py -@@ -80,7 +80,7 @@ def read_idl_file(reader, idl_filename): - assert len(interfaces) == 1, ( - "Expected one interface in file %r, found %d" % - (idl_filename, len(interfaces))) -- return (interfaces.values()[0], includes) -+ return (list(interfaces.values())[0], includes) - - - def interface_is_global(interface): -@@ -281,7 +281,7 @@ def main(): - - info_provider = create_component_info_provider( - os.path.normpath(options.info_dir), options.target_component) -- idl_filenames = map(str.strip, open(options.idl_files_list)) -+ idl_filenames = list(map(str.strip, open(options.idl_files_list))) - - generate_origin_trial_features(info_provider, options, idl_filenames) - return 0 ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py -@@ -394,7 +394,8 @@ class IdlInterface(object): - else: - raise ValueError('Unrecognized node class: %s' % child_class) - -- if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1: -+ if len(list(filter(None, -+ [self.iterable, self.maplike, self.setlike]))) > 1: - raise ValueError( - 'Interface can only have one of iterable<>, maplike<> and setlike<>.' - ) -@@ -512,6 +513,9 @@ class IdlAttribute(TypedObject): - def accept(self, visitor): - visitor.visit_attribute(self) - -+ def __lt__(self, other): -+ return self.name < other.name -+ - - ################################################################################ - # Constants -@@ -852,7 +856,7 @@ class IdlIncludes(object): - ################################################################################ - - --class Exposure: -+class Exposure(object): - """An Exposure holds one Exposed or RuntimeEnabled condition. - Each exposure has two properties: exposed and runtime_enabled. - Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py -@@ -55,8 +55,8 @@ def validate_blink_idl_definitions(idl_f - definitions. There is no filename convention in this case. - - Otherwise, an IDL file is invalid. - """ -- targets = ( -- definitions.interfaces.values() + definitions.dictionaries.values()) -+ targets = (list(definitions.interfaces.values()) + -+ list(definitions.dictionaries.values())) - number_of_targets = len(targets) - if number_of_targets > 1: - raise Exception( ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py -@@ -349,7 +349,7 @@ class IdlUnionType(IdlTypeBase): - return True - - def single_matching_member_type(self, predicate): -- matching_types = filter(predicate, self.flattened_member_types) -+ matching_types = list(filter(predicate, self.flattened_member_types)) - if len(matching_types) > 1: - raise ValueError('%s is ambiguous.' % self.name) - return matching_types[0] if matching_types else None ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py -@@ -196,8 +196,9 @@ class ComponentInfoProviderModules(Compo - - @property - def callback_functions(self): -- return dict(self._component_info_core['callback_functions'].items() + -- self._component_info_modules['callback_functions'].items()) -+ return dict( -+ list(self._component_info_core['callback_functions'].items()) + -+ list(self._component_info_modules['callback_functions'].items())) - - @property - def specifier_for_export(self): -@@ -209,8 +210,8 @@ class ComponentInfoProviderModules(Compo - - - def load_interfaces_info_overall_pickle(info_dir): -- with open(os.path.join(info_dir, -- 'interfaces_info.pickle')) as interface_info_file: -+ with open(os.path.join(info_dir, 'interfaces_info.pickle'), -+ mode='rb') as interface_info_file: - return pickle.load(interface_info_file) - - -@@ -236,23 +237,20 @@ def merge_dict_recursively(target, diff) - - def create_component_info_provider_core(info_dir): - interfaces_info = load_interfaces_info_overall_pickle(info_dir) -- with open( -- os.path.join(info_dir, 'core', -- 'component_info_core.pickle')) as component_info_file: -+ with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'), -+ mode='rb') as component_info_file: - component_info = pickle.load(component_info_file) - return ComponentInfoProviderCore(interfaces_info, component_info) - - - def create_component_info_provider_modules(info_dir): - interfaces_info = load_interfaces_info_overall_pickle(info_dir) -- with open( -- os.path.join(info_dir, 'core', -- 'component_info_core.pickle')) as component_info_file: -+ with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'), -+ mode='rb') as component_info_file: - component_info_core = pickle.load(component_info_file) -- with open( -- os.path.join( -- info_dir, 'modules', -- 'component_info_modules.pickle')) as component_info_file: -+ with open(os.path.join(info_dir, 'modules', -+ 'component_info_modules.pickle'), -+ mode='rb') as component_info_file: - component_info_modules = pickle.load(component_info_file) - return ComponentInfoProviderModules(interfaces_info, component_info_core, - component_info_modules) -@@ -356,7 +354,7 @@ def write_pickle_file(pickle_filename, d - pickle_filename = abs(pickle_filename) - # If |data| is same with the file content, we skip updating. - if os.path.isfile(pickle_filename): -- with open(pickle_filename) as pickle_file: -+ with open(pickle_filename, 'rb') as pickle_file: - try: - if pickle.load(pickle_file) == data: - return ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py -@@ -189,7 +189,7 @@ def context_enabled_features(attributes) - return sorted([ - member for member in members - if member.get(KEY) and not member.get('exposed_test') -- ]) -+ ], key=lambda item: item['name']) - - def member_filter_by_name(members, name): - return [member for member in members if member[KEY] == name] -@@ -612,7 +612,8 @@ def interface_context(interface, interfa - sorted( - origin_trial_features(interface, context['constants'], - context['attributes'], context['methods']) + -- context_enabled_features(context['attributes'])), -+ context_enabled_features(context['attributes']), -+ key=lambda item: item['name']), - }) - if context['optional_features']: - includes.add('platform/bindings/v8_per_context_data.h') -@@ -1356,9 +1357,9 @@ def resolution_tests_methods(effective_o - - # Extract argument and IDL type to simplify accessing these in each loop. - arguments = [method['arguments'][index] for method in methods] -- arguments_methods = zip(arguments, methods) -+ arguments_methods = list(zip(arguments, methods)) - idl_types = [argument['idl_type_object'] for argument in arguments] -- idl_types_methods = zip(idl_types, methods) -+ idl_types_methods = list(zip(idl_types, methods)) - - # We can’t do a single loop through all methods or simply sort them, because - # a method may be listed in multiple steps of the resolution algorithm, and ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py -@@ -46,6 +46,10 @@ import v8_types - import v8_utilities - from v8_utilities import (has_extended_attribute_value, is_unforgeable) - -+# TODO: Remove this once Python2 is obsoleted. -+if sys.version_info.major != 2: -+ basestring = str -+ - - def method_is_visible(method, interface_is_partial): - if 'overloads' in method: ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py -@@ -271,7 +271,7 @@ EXPOSED_WORKERS = set([ - ]) - - --class ExposureSet: -+class ExposureSet(object): - """An ExposureSet is a collection of Exposure instructions.""" - - def __init__(self, exposures=None): ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py -@@ -91,11 +91,13 @@ class CallbackInterface(UserDefinedType, - for operation_ir in ir.operations - ]) - self._operation_groups = tuple([ -- OperationGroup( -- operation_group_ir, -- filter(lambda x: x.identifier == operation_group_ir.identifier, -- self._operations), -- owner=self) for operation_group_ir in ir.operation_groups -+ OperationGroup(operation_group_ir, -+ list( -+ filter( -+ lambda x: x.identifier == operation_group_ir -+ .identifier, self._operations)), -+ owner=self) -+ for operation_group_ir in ir.operation_groups - ]) - - @property ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py -@@ -156,4 +156,4 @@ class Database(object): - return self._view_by_kind(Database._Kind.UNION) - - def _view_by_kind(self, kind): -- return self._impl.find_by_kind(kind).values() -+ return list(self._impl.find_by_kind(kind).values()) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py -@@ -8,8 +8,11 @@ from .runtime_enabled_features import Ru - class _Feature(str): - """Represents a runtime-enabled feature.""" - -+ def __new__(cls, value): -+ return str.__new__(cls, value) -+ - def __init__(self, value): -- str.__init__(self, value) -+ str.__init__(self) - self._is_context_dependent = ( - RuntimeEnabledFeatures.is_context_dependent(self)) - ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py -@@ -71,8 +71,9 @@ class FunctionLike(WithIdentifier): - def num_of_required_arguments(self): - """Returns the number of required arguments.""" - return len( -- filter(lambda arg: not (arg.is_optional or arg.is_variadic), -- self.arguments)) -+ list( -+ filter(lambda arg: not (arg.is_optional or arg.is_variadic), -+ self.arguments))) - - - class OverloadGroup(WithIdentifier): -@@ -171,8 +172,7 @@ class OverloadGroup(WithIdentifier): - Returns the effective overload set. - https://heycam.github.io/webidl/#compute-the-effective-overload-set - """ -- assert argument_count is None or isinstance(argument_count, -- (int, long)) -+ assert argument_count is None or isinstance(argument_count, int) - - N = argument_count - S = [] -@@ -188,21 +188,21 @@ class OverloadGroup(WithIdentifier): - - S.append( - OverloadGroup.EffectiveOverloadItem( -- X, map(lambda arg: arg.idl_type, X.arguments), -- map(lambda arg: arg.optionality, X.arguments))) -+ X, list(map(lambda arg: arg.idl_type, X.arguments)), -+ list(map(lambda arg: arg.optionality, X.arguments)))) - - if X.is_variadic: -- for i in xrange(n, max(maxarg, N)): -- t = map(lambda arg: arg.idl_type, X.arguments) -- o = map(lambda arg: arg.optionality, X.arguments) -- for _ in xrange(n, i + 1): -+ for i in range(n, max(maxarg, N)): -+ t = list(map(lambda arg: arg.idl_type, X.arguments)) -+ o = list(map(lambda arg: arg.optionality, X.arguments)) -+ for _ in range(n, i + 1): - t.append(X.arguments[-1].idl_type) - o.append(X.arguments[-1].optionality) - S.append(OverloadGroup.EffectiveOverloadItem(X, t, o)) - -- t = map(lambda arg: arg.idl_type, X.arguments) -- o = map(lambda arg: arg.optionality, X.arguments) -- for i in xrange(n - 1, -1, -1): -+ t = list(map(lambda arg: arg.idl_type, X.arguments)) -+ o = list(map(lambda arg: arg.optionality, X.arguments)) -+ for i in range(n - 1, -1, -1): - if X.arguments[i].optionality == IdlType.Optionality.REQUIRED: - break - S.append(OverloadGroup.EffectiveOverloadItem(X, t[:i], o[:i])) -@@ -222,7 +222,7 @@ class OverloadGroup(WithIdentifier): - for item in items) - assert len(items) > 1 - -- for index in xrange(len(items[0].type_list)): -+ for index in range(len(items[0].type_list)): - # Assume that the given items are valid, and we only need to test - # the two types. - if OverloadGroup.are_distinguishable_types( ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py -@@ -149,8 +149,8 @@ class IdlCompiler(object): - for old_ir in old_irs: - new_ir = make_copy(old_ir) - self._ir_map.add(new_ir) -- new_ir.attributes = filter(not_disabled, new_ir.attributes) -- new_ir.operations = filter(not_disabled, new_ir.operations) -+ new_ir.attributes = list(filter(not_disabled, new_ir.attributes)) -+ new_ir.operations = list(filter(not_disabled, new_ir.operations)) - - def _record_defined_in_partial_and_mixin(self): - old_irs = self._ir_map.irs_of_kinds( -@@ -231,7 +231,7 @@ class IdlCompiler(object): - only_to_members_of_partial_or_mixin=False) - propagate_to_exposure(propagate) - -- map(process_member_like, ir.iter_all_members()) -+ list(map(process_member_like, ir.iter_all_members())) - - def process_member_like(ir): - propagate = functools.partial(propagate_extattr, ir=ir) -@@ -257,7 +257,7 @@ class IdlCompiler(object): - - self._ir_map.move_to_new_phase() - -- map(process_interface_like, old_irs) -+ list(map(process_interface_like, old_irs)) - - def _determine_blink_headers(self): - irs = self._ir_map.irs_of_kinds( -@@ -422,9 +422,9 @@ class IdlCompiler(object): - assert not new_interface.deriveds - derived_set = identifier_to_derived_set.get( - new_interface.identifier, set()) -- new_interface.deriveds = map( -- lambda id_: self._ref_to_idl_def_factory.create(id_), -- sorted(derived_set)) -+ new_interface.deriveds = list( -+ map(lambda id_: self._ref_to_idl_def_factory.create(id_), -+ sorted(derived_set))) - - def _supplement_missing_html_constructor_operation(self): - # Temporary mitigation of misuse of [HTMLConstructor] -@@ -553,7 +553,8 @@ class IdlCompiler(object): - self._ir_map.add(new_ir) - - for group in new_ir.iter_all_overload_groups(): -- exposures = map(lambda overload: overload.exposure, group) -+ exposures = list(map(lambda overload: overload.exposure, -+ group)) - - # [Exposed] - if any(not exposure.global_names_and_features -@@ -653,8 +654,8 @@ class IdlCompiler(object): - constructs = set() - for global_name in global_names: - constructs.update(exposed_map.get(global_name, [])) -- new_ir.exposed_constructs = map( -- self._ref_to_idl_def_factory.create, sorted(constructs)) -+ new_ir.exposed_constructs = list( -+ map(self._ref_to_idl_def_factory.create, sorted(constructs))) - - assert not new_ir.legacy_window_aliases - if new_ir.identifier != 'Window': ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py -@@ -180,8 +180,9 @@ class Interface(UserDefinedType, WithExt - self._constructor_groups = tuple([ - ConstructorGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._constructors), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._constructors)), - owner=self) for group_ir in ir.constructor_groups - ]) - assert len(self._constructor_groups) <= 1 -@@ -192,8 +193,9 @@ class Interface(UserDefinedType, WithExt - self._named_constructor_groups = tuple([ - ConstructorGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._named_constructors), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._named_constructors)), - owner=self) for group_ir in ir.named_constructor_groups - ]) - self._operations = tuple([ -@@ -203,22 +205,23 @@ class Interface(UserDefinedType, WithExt - self._operation_groups = tuple([ - OperationGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._operations), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._operations)), - owner=self) for group_ir in ir.operation_groups - ]) - self._exposed_constructs = tuple(ir.exposed_constructs) - self._legacy_window_aliases = tuple(ir.legacy_window_aliases) - self._indexed_and_named_properties = None -- indexed_and_named_property_operations = filter( -- lambda x: x.is_indexed_or_named_property_operation, -- self._operations) -+ indexed_and_named_property_operations = list( -+ filter(lambda x: x.is_indexed_or_named_property_operation, -+ self._operations)) - if indexed_and_named_property_operations: - self._indexed_and_named_properties = IndexedAndNamedProperties( - indexed_and_named_property_operations, owner=self) - self._stringifier = None -- stringifier_operation_irs = filter(lambda x: x.is_stringifier, -- ir.operations) -+ stringifier_operation_irs = list( -+ filter(lambda x: x.is_stringifier, ir.operations)) - if stringifier_operation_irs: - assert len(stringifier_operation_irs) == 1 - op_ir = make_copy(stringifier_operation_irs[0]) -@@ -231,8 +234,9 @@ class Interface(UserDefinedType, WithExt - attribute = None - if operation.stringifier_attribute: - attr_id = operation.stringifier_attribute -- attributes = filter(lambda x: x.identifier == attr_id, -- self._attributes) -+ attributes = list( -+ filter(lambda x: x.identifier == attr_id, -+ self._attributes)) - assert len(attributes) == 1 - attribute = attributes[0] - self._stringifier = Stringifier(operation, attribute, owner=self) -@@ -578,8 +582,9 @@ class Iterable(WithDebugInfo): - self._operation_groups = tuple([ - OperationGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._operations), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._operations)), - owner=owner) for group_ir in ir.operation_groups - ]) - -@@ -666,8 +671,9 @@ class Maplike(WithDebugInfo): - self._operation_groups = tuple([ - OperationGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._operations), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._operations)), - owner=owner) for group_ir in ir.operation_groups - ]) - -@@ -755,8 +761,9 @@ class Setlike(WithDebugInfo): - self._operation_groups = tuple([ - OperationGroup( - group_ir, -- filter(lambda x: x.identifier == group_ir.identifier, -- self._operations), -+ list( -+ filter(lambda x: x.identifier == group_ir.identifier, -+ self._operations)), - owner=owner) for group_ir in ir.operation_groups - ]) - ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py -@@ -2,6 +2,8 @@ - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. - -+import sys -+ - from .argument import Argument - from .ast_group import AstGroup - from .attribute import Attribute -@@ -30,6 +32,11 @@ from .operation import Operation - from .typedef import Typedef - - -+# TODO: Remove this once Python2 is obsoleted. -+if sys.version_info.major != 2: -+ long = int -+ -+ - def load_and_register_idl_definitions(filepaths, register_ir, - create_ref_to_idl_def, idl_type_factory): - """ -@@ -160,7 +167,7 @@ class _IRBuilder(object): - child_nodes = list(node.GetChildren()) - extended_attributes = self._take_extended_attributes(child_nodes) - -- members = map(self._build_interface_member, child_nodes) -+ members = list(map(self._build_interface_member, child_nodes)) - attributes = [] - constants = [] - operations = [] -@@ -302,7 +309,7 @@ class _IRBuilder(object): - child_nodes = list(node.GetChildren()) - inherited = self._take_inheritance(child_nodes) - extended_attributes = self._take_extended_attributes(child_nodes) -- own_members = map(self._build_dictionary_member, child_nodes) -+ own_members = list(map(self._build_dictionary_member, child_nodes)) - - return Dictionary.IR( - identifier=Identifier(node.GetName()), -@@ -336,7 +343,7 @@ class _IRBuilder(object): - - child_nodes = list(node.GetChildren()) - extended_attributes = self._take_extended_attributes(child_nodes) -- members = map(self._build_interface_member, child_nodes) -+ members = list(map(self._build_interface_member, child_nodes)) - constants = [] - operations = [] - for member in members: -@@ -456,8 +463,8 @@ class _IRBuilder(object): - assert len(child_nodes) == 1 - child = child_nodes[0] - if child.GetClass() == 'Arguments': -- arguments = map(build_extattr_argument, -- child.GetChildren()) -+ arguments = list( -+ map(build_extattr_argument, child.GetChildren())) - elif child.GetClass() == 'Call': - assert len(child.GetChildren()) == 1 - grand_child = child.GetChildren()[0] -@@ -486,7 +493,9 @@ class _IRBuilder(object): - - assert node.GetClass() == 'ExtAttributes' - return ExtendedAttributes( -- filter(None, map(build_extended_attribute, node.GetChildren()))) -+ list( -+ filter(None, map(build_extended_attribute, -+ node.GetChildren())))) - - def _build_inheritance(self, node): - assert node.GetClass() == 'Inherit' -@@ -506,7 +515,7 @@ class _IRBuilder(object): - - def _build_iterable(self, node): - assert node.GetClass() == 'Iterable' -- types = map(self._build_type, node.GetChildren()) -+ types = list(map(self._build_type, node.GetChildren())) - assert len(types) == 1 or len(types) == 2 - if len(types) == 1: # value iterator - key_type, value_type = (None, types[0]) -@@ -584,7 +593,7 @@ class _IRBuilder(object): - def _build_maplike(self, node, interface_identifier): - assert node.GetClass() == 'Maplike' - assert isinstance(interface_identifier, Identifier) -- types = map(self._build_type, node.GetChildren()) -+ types = list(map(self._build_type, node.GetChildren())) - assert len(types) == 2 - key_type, value_type = types - is_readonly = bool(node.GetProperty('READONLY')) -@@ -676,7 +685,7 @@ class _IRBuilder(object): - def _build_setlike(self, node, interface_identifier): - assert node.GetClass() == 'Setlike' - assert isinstance(interface_identifier, Identifier) -- types = map(self._build_type, node.GetChildren()) -+ types = list(map(self._build_type, node.GetChildren())) - assert len(types) == 1 - value_type = types[0] - is_readonly = bool(node.GetProperty('READONLY')) -@@ -838,7 +847,7 @@ class _IRBuilder(object): - - def build_union_type(node, extended_attributes): - return self._idl_type_factory.union_type( -- member_types=map(self._build_type, node.GetChildren()), -+ member_types=list(map(self._build_type, node.GetChildren())), - is_optional=is_optional, - extended_attributes=extended_attributes, - debug_info=self._build_debug_info(node)) ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py -@@ -3,6 +3,13 @@ - # found in the LICENSE file. - - -+import sys -+ -+# TODO: Remove this once Python2 is obsoleted. -+if sys.version_info.major != 2: -+ long = int -+ basestring = str -+ - def make_copy(obj, memo=None): - """ - Creates a copy of the given object, which should be an IR or part of IR. ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py -@@ -107,11 +107,13 @@ class Namespace(UserDefinedType, WithExt - for operation_ir in ir.operations - ]) - self._operation_groups = tuple([ -- OperationGroup( -- operation_group_ir, -- filter(lambda x: x.identifier == operation_group_ir.identifier, -- self._operations), -- owner=self) for operation_group_ir in ir.operation_groups -+ OperationGroup(operation_group_ir, -+ list( -+ filter( -+ lambda x: x.identifier == operation_group_ir -+ .identifier, self._operations)), -+ owner=self) -+ for operation_group_ir in ir.operation_groups - ]) - - @property ---- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl -@@ -59,9 +59,9 @@ void {{v8_class}}::ToImpl(v8::Isolate* i - DCHECK(executionContext); - {% endif %}{# has_origin_trial_members #} - {% endif %}{# members #} -- {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %} -+ {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %} - {% filter origin_trial_enabled(origin_trial_test, "executionContext") %} -- {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %} -+ {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %} - {% filter runtime_enabled(feature_name) %} - {% for member in member_list %} - v8::Local {{member.v8_value}}; -@@ -147,9 +147,9 @@ bool toV8{{cpp_class}}(const {{cpp_class - DCHECK(executionContext); - {% endif %}{# has_origin_trial_members #} - {% endif %}{# members #} -- {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %} -+ {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %} - {% filter origin_trial_enabled(origin_trial_test, "executionContext") %} -- {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %} -+ {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %} - {% filter runtime_enabled(feature_name) %} - {% for member in member_list %} - v8::Local {{member.v8_value}}; ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py -@@ -71,7 +71,7 @@ class Expansion(object): - def enabled_longhands(self): - include = lambda longhand: not longhand[ - 'runtime_flag'] or self.is_enabled(longhand['runtime_flag']) -- return filter(include, self._longhands) -+ return list(filter(include, self._longhands)) - - @property - def index(self): -@@ -87,8 +87,9 @@ class Expansion(object): - - def create_expansions(longhands): - flags = collect_runtime_flags(longhands) -- expansions = map(lambda mask: Expansion(longhands, flags, mask), -- range(1 << len(flags))) -+ expansions = list( -+ map(lambda mask: Expansion(longhands, flags, mask), -+ range(1 << len(flags)))) - assert len(expansions) > 0 - # We generate 2^N expansions for N flags, so enforce some limit. - assert len(flags) <= 4, 'Too many runtime flags for a single shorthand' -@@ -114,14 +115,14 @@ class StylePropertyShorthandWriter(json5 - - self._longhand_dictionary = defaultdict(list) - for property_ in json5_properties.shorthands: -- property_['longhand_enum_keys'] = map(enum_key_for_css_property, -- property_['longhands']) -- property_['longhand_property_ids'] = map(id_for_css_property, -- property_['longhands']) -- -- longhands = map( -- lambda name: json5_properties.properties_by_name[name], -- property_['longhands']) -+ property_['longhand_enum_keys'] = list( -+ map(enum_key_for_css_property, property_['longhands'])) -+ property_['longhand_property_ids'] = list( -+ map(id_for_css_property, property_['longhands'])) -+ -+ longhands = list( -+ map(lambda name: json5_properties.properties_by_name[name], -+ property_['longhands'])) - property_['expansions'] = create_expansions(longhands) - for longhand_enum_key in property_['longhand_enum_keys']: - self._longhand_dictionary[longhand_enum_key].append(property_) ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py -@@ -42,8 +42,8 @@ class CSSPropertyInstancesWriter(json5_g - aliases = self._css_properties.aliases - - # Lists of PropertyClassData. -- self._property_classes_by_id = map(self.get_class, properties) -- self._alias_classes_by_id = map(self.get_class, aliases) -+ self._property_classes_by_id = list(map(self.get_class, properties)) -+ self._alias_classes_by_id = list(map(self.get_class, aliases)) - - # Sort by enum value. - self._property_classes_by_id.sort(key=lambda t: t.enum_value) ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py -@@ -95,7 +95,7 @@ def main(): - - open(args.output_file, 'wb').write( - generate_gperf(gperf_path, -- open(infile).read(), gperf_args)) -+ open(infile).read(), gperf_args).encode('utf-8')) - - - if __name__ == '__main__': ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py -@@ -66,7 +66,7 @@ class InFile(object): - self._defaults = defaults - self._valid_values = copy.deepcopy( - valid_values if valid_values else {}) -- self._parse(map(str.strip, lines)) -+ self._parse(list(map(str.strip, lines))) - - @classmethod - def load_from_files(self, file_paths, defaults, valid_values, ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py -@@ -32,10 +32,15 @@ import os - import os.path - import shlex - import shutil -+import sys - import optparse - - from in_file import InFile - -+# TODO: Remove this once Python2 is obsoleted. -+if sys.version_info.major != 2: -+ basestring = str -+ - - ######################################################### - # This is now deprecated - use json5_generator.py instead ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py -@@ -138,7 +138,7 @@ class RuntimeFeatureWriter(BaseRuntimeFe - except Exception: - # If trouble unpickling, overwrite - pass -- with open(os.path.abspath(file_name), 'w') as pickle_file: -+ with open(os.path.abspath(file_name), 'wb') as pickle_file: - pickle.dump(features_map, pickle_file) - - def _template_inputs(self): ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl -@@ -26,7 +26,7 @@ using {{namespace}}FunctionMap = HashMap - - static {{namespace}}FunctionMap* g_{{namespace|lower}}_constructors = nullptr; - --{% for tag in tags|sort if not tag.noConstructor %} -+{% for tag in tags|sort(attribute='name') if not tag.noConstructor %} - static {{namespace}}Element* {{namespace}}{{tag.name.to_upper_camel_case()}}Constructor( - Document& document, const CreateElementFlags flags) { - {% if tag.runtimeEnabled %} -@@ -52,7 +52,7 @@ static void Create{{namespace}}FunctionM - // Empty array initializer lists are illegal [dcl.init.aggr] and will not - // compile in MSVC. If tags list is empty, add check to skip this. - static const Create{{namespace}}FunctionMapData data[] = { -- {% for tag in tags|sort if not tag.noConstructor %} -+ {% for tag in tags|sort(attribute='name') if not tag.noConstructor %} - { {{cpp_namespace}}::{{tag|symbol}}Tag, {{namespace}}{{tag.name.to_upper_camel_case()}}Constructor }, - {% endfor %} - }; ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.cc.tmpl -@@ -22,7 +22,7 @@ HTMLTypeMap CreateHTMLTypeMap() { - const char* name; - HTMLElementType type; - } kTags[] = { -- {% for tag in tags|sort %} -+ {% for tag in tags|sort(attribute='name') %} - { "{{tag.name}}", HTMLElementType::k{{tag.js_interface}} }, - {% endfor %} - }; -@@ -42,7 +42,7 @@ HTMLElementType htmlElementTypeForTag(co - if (it == html_type_map.end()) - return HTMLElementType::kHTMLUnknownElement; - -- {% for tag in tags|sort %} -+ {% for tag in tags|sort(attribute='name') %} - {% if tag.runtimeEnabled %} - if (tagName == "{{tag.name}}") { - if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled(document->GetExecutionContext())) { ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl -@@ -15,7 +15,7 @@ namespace blink { - class Document; - - // Type checking. --{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} -+{% for tag in tags|sort(attribute='name') if not tag.multipleTagNames and not tag.noTypeHelpers %} - class {{tag.interface}}; - template <> - inline bool IsElementOfType(const Node& node) { ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl -@@ -25,7 +25,7 @@ - - - {% macro trie_leaf(index, object, return_macro, lowercase_data) %} --{% set name, value = object.items()[0] %} -+{% set name, value = (object.items()|list)[0] %} - {% if name|length %} - if ( - {%- for c in name -%} -@@ -45,7 +45,7 @@ return {{ return_macro(value) }}; - - - {% macro trie_switch(trie, index, return_macro, lowercase_data) %} --{% if trie|length == 1 and trie.values()[0] is string %} -+{% if trie|length == 1 and (trie.values()|list)[0] is string %} - {{ trie_leaf(index, trie, return_macro, lowercase_data) -}} - {% else %} - {% if lowercase_data %} ---- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl -+++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl -@@ -24,12 +24,12 @@ namespace {{cpp_namespace}} { - {{symbol_export}}extern const WTF::AtomicString& {{namespace_prefix}}NamespaceURI; - - // Tags --{% for tag in tags|sort %} -+{% for tag in tags|sort(attribute='name') %} - {{symbol_export}}extern const blink::{{namespace}}QualifiedName& {{tag|symbol}}Tag; - {% endfor %} - - // Attributes --{% for attr in attrs|sort %} -+{% for attr in attrs|sort(attribute='name') %} - {{symbol_export}}extern const blink::QualifiedName& {{attr|symbol}}Attr; - {% endfor %} - ---- a/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py -+++ b/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py -@@ -201,6 +201,10 @@ def _compute_python_dependencies(root_di - - paths = set() - for path in module_paths: -+ # Builtin/namespaced modules may return None for the file path. -+ if not path: -+ continue -+ - path = os.path.abspath(path) - - if not path.startswith(root_dir): ---- a/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn -+++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn -@@ -2,6 +2,8 @@ - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. - -+import("//build/config/python.gni") -+ - import("//third_party/blink/public/public_features.gni") - import("./all_devtools_files.gni") - import("./all_devtools_modules.gni") ---- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py -+++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py -@@ -45,7 +45,8 @@ def rollup(input_path, output_path, file - ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] + - ['--plugin', rollup_plugin], - stdout=subprocess.PIPE, -- stderr=subprocess.PIPE) -+ stderr=subprocess.PIPE, -+ text=True) - out, error = rollup_process.communicate() - if not out: - raise Exception("rollup failed: " + error) ---- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py -+++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py -@@ -10,7 +10,7 @@ Builds applications in release mode: - and the application loader into a single script. - """ - --from cStringIO import StringIO -+from io import StringIO - from os import path - from os.path import join - import copy -@@ -145,8 +145,7 @@ class ReleaseBuilder(object): - resource_content = read_file(path.join(self.application_dir, resource_name)) - if not (resource_name.endswith('.html') - or resource_name.endswith('md')): -- resource_content += resource_source_url(resource_name).encode( -- 'utf-8') -+ resource_content += resource_source_url(resource_name) - resource_content = resource_content.replace('\\', '\\\\') - resource_content = resource_content.replace('\n', '\\n') - resource_content = resource_content.replace('"', '\\"') -@@ -173,7 +172,9 @@ class ReleaseBuilder(object): - def _concatenate_application_script(self, output): - output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors()) - if self.descriptors.extends: -- output.write('Root.applicationDescriptor.modules.push(...%s);' % json.dumps(self.descriptors.application.values())) -+ output.write( -+ 'Root.applicationDescriptor.modules.push(...%s);' % -+ json.dumps(list(self.descriptors.application.values()))) - else: - output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json()) - ---- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py -+++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py -@@ -123,7 +123,7 @@ def main(argv): - - try: - os.makedirs(path.join(output_directory, 'Images')) -- except OSError, e: -+ except OSError as e: - if e.errno != errno.EEXIST: - raise e - -@@ -147,7 +147,7 @@ def main(argv): - shutil.copy(path.join(dirname, filename), path.join(output_directory, 'Images')) - add_file_to_grd(doc, path.join('Images', filename)) - -- with open(parsed_args.output_filename, 'w') as output_file: -+ with open(parsed_args.output_filename, 'wb') as output_file: - output_file.write(doc.toxml(encoding='UTF-8')) - - ---- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py -+++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py -@@ -7,6 +7,8 @@ - Utilities for the modular DevTools build. - """ - -+from __future__ import print_function -+ - import collections - from os import path - import os -@@ -40,7 +42,7 @@ def load_and_parse_json(filename): - try: - return json.loads(read_file(filename)) - except: -- print 'ERROR: Failed to parse %s' % filename -+ print('ERROR: Failed to parse %s' % filename) - raise - - class Descriptors: -@@ -57,7 +59,7 @@ class Descriptors: - - def application_json(self): - result = dict() -- result['modules'] = self.application.values() -+ result['modules'] = list(self.application.values()) - return json.dumps(result) - - def all_compiled_files(self): ---- a/src/3rdparty/chromium/third_party/jinja2/tests.py -+++ b/src/3rdparty/chromium/third_party/jinja2/tests.py -@@ -10,7 +10,7 @@ - """ - import operator - import re --from collections import Mapping -+from collections.abc import Mapping - from jinja2.runtime import Undefined - from jinja2._compat import text_type, string_types, integer_types - import decimal ---- a/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py -+++ b/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py -@@ -48,9 +48,10 @@ def ReadFilteredData(path): - data = ukm_model.UKM_XML_TYPE.Parse(ukm_file.read()) - event_tag = ukm_model._EVENT_TYPE.tag - metric_tag = ukm_model._METRIC_TYPE.tag -- data[event_tag] = filter(ukm_model.IsNotObsolete, data[event_tag]) -+ data[event_tag] = list(filter(ukm_model.IsNotObsolete, data[event_tag])) - for event in data[event_tag]: -- event[metric_tag] = filter(ukm_model.IsNotObsolete, event[metric_tag]) -+ event[metric_tag] = list( -+ filter(ukm_model.IsNotObsolete, event[metric_tag])) - return data - - ---- a/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py -+++ b/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py -@@ -45,12 +45,15 @@ Example Output: ./ui/ozone/generate_cons - } // namespace ui - """ - -+try: -+ from StringIO import StringIO # for Python 2 -+except ImportError: -+ from io import StringIO # for Python 3 - import optparse - import os - import collections - import re - import sys --import string - - - def GetTypedefName(typename): -@@ -68,7 +71,7 @@ def GetConstructorName(typename, platfor - This is just "Create" + typename + platform. - """ - -- return 'Create' + typename + string.capitalize(platform) -+ return 'Create' + typename + platform.capitalize() - - - def GenerateConstructorList(out, namespace, export, typenames, platforms, -@@ -163,12 +166,14 @@ def main(argv): - sys.exit(1) - - # Write to standard output or file specified by --output_cc. -- out_cc = sys.stdout -+ out_cc = getattr(sys.stdout, 'buffer', sys.stdout) - if options.output_cc: - out_cc = open(options.output_cc, 'wb') - -- GenerateConstructorList(out_cc, options.namespace, options.export, -+ out_cc_str = StringIO() -+ GenerateConstructorList(out_cc_str, options.namespace, options.export, - typenames, platforms, includes, usings) -+ out_cc.write(out_cc_str.getvalue().encode('utf-8')) - - if options.output_cc: - out_cc.close() ---- a/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py -+++ b/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py -@@ -49,12 +49,15 @@ Example Output: ./generate_ozone_platfor - - """ - -+try: -+ from StringIO import StringIO # for Python 2 -+except ImportError: -+ from io import StringIO # for Python 3 - import optparse - import os - import collections - import re - import sys --import string - - - def GetConstantName(name): -@@ -63,7 +66,7 @@ def GetConstantName(name): - We just capitalize the platform name and prepend "CreateOzonePlatform". - """ - -- return 'kPlatform' + string.capitalize(name) -+ return 'kPlatform' + name.capitalize() - - - def GeneratePlatformListText(out, platforms): -@@ -149,9 +152,9 @@ def main(argv): - platforms.insert(0, options.default) - - # Write to standard output or file specified by --output_{cc,h}. -- out_cc = sys.stdout -- out_h = sys.stdout -- out_txt = sys.stdout -+ out_cc = getattr(sys.stdout, 'buffer', sys.stdout) -+ out_h = getattr(sys.stdout, 'buffer', sys.stdout) -+ out_txt = getattr(sys.stdout, 'buffer', sys.stdout) - if options.output_cc: - out_cc = open(options.output_cc, 'wb') - if options.output_h: -@@ -159,9 +162,16 @@ def main(argv): - if options.output_txt: - out_txt = open(options.output_txt, 'wb') - -- GeneratePlatformListText(out_txt, platforms) -- GeneratePlatformListHeader(out_h, platforms) -- GeneratePlatformListSource(out_cc, platforms) -+ out_txt_str = StringIO() -+ out_h_str = StringIO() -+ out_cc_str = StringIO() -+ -+ GeneratePlatformListText(out_txt_str, platforms) -+ out_txt.write(out_txt_str.getvalue().encode('utf-8')) -+ GeneratePlatformListHeader(out_h_str, platforms) -+ out_h.write(out_h_str.getvalue().encode('utf-8')) -+ GeneratePlatformListSource(out_cc_str, platforms) -+ out_cc.write(out_cc_str.getvalue().encode('utf-8')) - - if options.output_cc: - out_cc.close() diff --git a/debian/patches/ffmpeg-x86-optimization.patch b/debian/patches/ffmpeg-x86-optimization.patch deleted file mode 100644 index cff8df9a43..0000000000 --- a/debian/patches/ffmpeg-x86-optimization.patch +++ /dev/null @@ -1,64 +0,0 @@ -Description: avcodec/x86/mathops: clip constants used with shift instructions within inline assembly - Fixes assembling with gas from binutils >= 2.41. -Origin: upstream, https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/effadce6c756247e -Bug: https://bugs.debian.org/1038132 -Last-Update: 2023-07-21 - ---- a/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h -+++ b/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h -@@ -35,12 +35,20 @@ - static av_always_inline av_const int MULL(int a, int b, unsigned shift) - { - int rt, dummy; -+ if (__builtin_constant_p(shift)) - __asm__ ( - "imull %3 \n\t" - "shrdl %4, %%edx, %%eax \n\t" - :"=a"(rt), "=d"(dummy) -- :"a"(a), "rm"(b), "ci"((uint8_t)shift) -+ :"a"(a), "rm"(b), "i"(shift & 0x1F) - ); -+ else -+ __asm__ ( -+ "imull %3 \n\t" -+ "shrdl %4, %%edx, %%eax \n\t" -+ :"=a"(rt), "=d"(dummy) -+ :"a"(a), "rm"(b), "c"((uint8_t)shift) -+ ); - return rt; - } - -@@ -113,19 +121,31 @@ __asm__ volatile(\ - // avoid +32 for shift optimization (gcc should do that ...) - #define NEG_SSR32 NEG_SSR32 - static inline int32_t NEG_SSR32( int32_t a, int8_t s){ -+ if (__builtin_constant_p(s)) - __asm__ ("sarl %1, %0\n\t" - : "+r" (a) -- : "ic" ((uint8_t)(-s)) -+ : "i" (-s & 0x1F) - ); -+ else -+ __asm__ ("sarl %1, %0\n\t" -+ : "+r" (a) -+ : "c" ((uint8_t)(-s)) -+ ); - return a; - } - - #define NEG_USR32 NEG_USR32 - static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ -+ if (__builtin_constant_p(s)) - __asm__ ("shrl %1, %0\n\t" - : "+r" (a) -- : "ic" ((uint8_t)(-s)) -+ : "i" (-s & 0x1F) - ); -+ else -+ __asm__ ("shrl %1, %0\n\t" -+ : "+r" (a) -+ : "c" ((uint8_t)(-s)) -+ ); - return a; - } - diff --git a/debian/patches/fix-example-pro-files.patch b/debian/patches/fix-example-pro-files.patch index 9e2f158df8..9129b255ad 100644 --- a/debian/patches/fix-example-pro-files.patch +++ b/debian/patches/fix-example-pro-files.patch @@ -1,5 +1,5 @@ Description: Fix example .pro files so that they build correctly on Debian. -Author: Soren Stoutner +Author: Soren Stoutner Forwarded: not-needed Last-Update: 2023-07-04 diff --git a/debian/patches/icu74.patch b/debian/patches/icu74.patch deleted file mode 100644 index 3ac7c6ce02..0000000000 --- a/debian/patches/icu74.patch +++ /dev/null @@ -1,17 +0,0 @@ -Description: fix static_assert failure with ICU 74 -Origin: Gentoo, https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-qt/qtwebengine/files/qtwebengine-6.5.3-icu74.patch -Last-Update: 2023-12-25 - ---- a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc -+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc -@@ -162,7 +162,9 @@ static const unsigned char kAsciiLineBre - }; - // clang-format on - --#if U_ICU_VERSION_MAJOR_NUM >= 58 -+#if U_ICU_VERSION_MAJOR_NUM >= 74 -+#define BA_LB_COUNT (U_LB_COUNT - 8) -+#elif U_ICU_VERSION_MAJOR_NUM >= 58 - #define BA_LB_COUNT (U_LB_COUNT - 3) - #else - #define BA_LB_COUNT U_LB_COUNT diff --git a/debian/patches/mips64el-no-dav1d.patch b/debian/patches/mips64el-no-dav1d.patch index e3bbab501f..8572fcefeb 100644 --- a/debian/patches/mips64el-no-dav1d.patch +++ b/debian/patches/mips64el-no-dav1d.patch @@ -1,7 +1,7 @@ Description: disable dav1d support on mipsel/mips64el dav1d does not support MIPS, and there is no config directory for it. Author: Dmitry Shachnev -Forwarded: no +Forwarded: not-needed Last-Update: 2021-02-14 --- a/src/3rdparty/chromium/media/media_options.gni diff --git a/debian/patches/mips64el-ptrace-include.patch b/debian/patches/mips64el-ptrace-include.patch index 6c8814f0c8..a18c9bd970 100644 --- a/debian/patches/mips64el-ptrace-include.patch +++ b/debian/patches/mips64el-ptrace-include.patch @@ -1,6 +1,6 @@ Description: on mipsel PTRACE_GET_THREAD_AREA is defined in asm/ptrace.h Author: Dmitry Shachnev -Forwarded: no +Forwarded: not-needed Last-Update: 2020-03-17 --- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc diff --git a/debian/patches/mips64el-v8-regexp.patch b/debian/patches/mips64el-v8-regexp.patch new file mode 100644 index 0000000000..8be9480146 --- /dev/null +++ b/debian/patches/mips64el-v8-regexp.patch @@ -0,0 +1,140 @@ +Description: fix stack check in native code when interrupt was requested +Origin: upstream v8, commits: + - https://github.com/v8/v8/commit/3ebf2052a1b27039 + - https://github.com/v8/v8/commit/1ec3c714bf75f01e +Last-Update: 2024-07-04 + +--- a/src/3rdparty/chromium/v8/src/codegen/mips64/assembler-mips64.h ++++ b/src/3rdparty/chromium/v8/src/codegen/mips64/assembler-mips64.h +@@ -69,7 +69,6 @@ class Operand { + : rm_(no_reg), rmode_(RelocInfo::EXTERNAL_REFERENCE) { + value_.immediate = static_cast(f.address()); + } +- V8_INLINE explicit Operand(const char* s); + explicit Operand(Handle handle); + V8_INLINE explicit Operand(Smi value) : rm_(no_reg), rmode_(RelocInfo::NONE) { + value_.immediate = static_cast(value.ptr()); +--- a/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.cc ++++ b/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.cc +@@ -698,6 +698,8 @@ Handle RegExpMacroAssemblerM + + ExternalReference stack_limit = + ExternalReference::address_of_jslimit(masm_->isolate()); ++ Operand extra_space_for_variables(num_registers_ * kPointerSize); ++ + __ li(a0, Operand(stack_limit)); + __ Ld(a0, MemOperand(a0)); + __ Dsubu(a0, sp, a0); +@@ -705,14 +707,14 @@ Handle RegExpMacroAssemblerM + __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg)); + // Check if there is room for the variable number of registers above + // the stack limit. +- __ Branch(&stack_ok, hs, a0, Operand(num_registers_ * kPointerSize)); ++ __ Branch(&stack_ok, hs, a0, extra_space_for_variables); + // Exit with OutOfMemory exception. There is not enough space on the stack + // for our working registers. + __ li(v0, Operand(EXCEPTION)); + __ jmp(&return_v0); + + __ bind(&stack_limit_hit); +- CallCheckStackGuardState(a0); ++ CallCheckStackGuardState(a0, extra_space_for_variables); + // If returned value is non-zero, we exit with the returned value as result. + __ Branch(&return_v0, ne, v0, Operand(zero_reg)); + +@@ -1122,7 +1124,8 @@ bool RegExpMacroAssemblerMIPS::CanReadUn + + // Private methods: + +-void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) { ++void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch, ++ Operand extra_space) { + DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); + DCHECK(!masm_->options().isolate_independent_code); + +@@ -1135,6 +1138,9 @@ void RegExpMacroAssemblerMIPS::CallCheck + __ And(sp, sp, Operand(-stack_alignment)); + __ Sd(scratch, MemOperand(sp)); + ++ // Extra space for variables to consider in stack check. ++ __ li(a3, extra_space); ++ // RegExp code frame pointer. + __ mov(a2, frame_pointer()); + // Code of self. + __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); +@@ -1143,16 +1149,6 @@ void RegExpMacroAssemblerMIPS::CallCheck + DCHECK(IsAligned(stack_alignment, kPointerSize)); + __ Dsubu(sp, sp, Operand(stack_alignment)); + +- // The stack pointer now points to cell where the return address will be +- // written. Arguments are in registers, meaning we treat the return address as +- // argument 5. Since DirectCEntry will handle allocating space for the C +- // argument slots, we don't need to care about that here. This is how the +- // stack will look (sp meaning the value of sp at this moment): +- // [sp + 3] - empty slot if needed for alignment. +- // [sp + 2] - saved sp. +- // [sp + 1] - second word reserved for return value. +- // [sp + 0] - first word reserved for return value. +- + // a0 will point to the return address, placed by DirectCEntry. + __ mov(a0, sp); + +@@ -1166,17 +1162,6 @@ void RegExpMacroAssemblerMIPS::CallCheck + __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); + __ Call(kScratchReg); + +- // DirectCEntry allocated space for the C argument slots so we have to +- // drop them with the return address from the stack with loading saved sp. +- // At this point stack must look: +- // [sp + 7] - empty slot if needed for alignment. +- // [sp + 6] - saved sp. +- // [sp + 5] - second word reserved for return value. +- // [sp + 4] - first word reserved for return value. +- // [sp + 3] - C argument slot. +- // [sp + 2] - C argument slot. +- // [sp + 1] - C argument slot. +- // [sp + 0] - C argument slot. + __ Ld(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize)); + + __ li(code_pointer(), Operand(masm_->CodeObject())); +@@ -1197,7 +1182,8 @@ static T* frame_entry_address(Address re + + int64_t RegExpMacroAssemblerMIPS::CheckStackGuardState(Address* return_address, + Address raw_code, +- Address re_frame) { ++ Address re_frame, ++ uintptr_t extra_space) { + Code re_code = Code::cast(Object(raw_code)); + return NativeRegExpMacroAssembler::CheckStackGuardState( + frame_entry(re_frame, kIsolate), +@@ -1207,7 +1193,8 @@ int64_t RegExpMacroAssemblerMIPS::CheckS + return_address, re_code, + frame_entry_address
(re_frame, kInputString), + frame_entry_address(re_frame, kInputStart), +- frame_entry_address(re_frame, kInputEnd)); ++ frame_entry_address(re_frame, kInputEnd), ++ extra_space); + } + + +--- a/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.h ++++ b/src/3rdparty/chromium/v8/src/regexp/mips64/regexp-macro-assembler-mips64.h +@@ -90,7 +90,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssem + // returning. + // {raw_code} is an Address because this is called via ExternalReference. + static int64_t CheckStackGuardState(Address* return_address, Address raw_code, +- Address re_frame); ++ Address re_frame, uintptr_t extra_space); + + void print_regexp_frame_constants(); + +@@ -140,7 +140,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssem + + + // Generate a call to CheckStackGuardState. +- void CallCheckStackGuardState(Register scratch); ++ void CallCheckStackGuardState(Register scratch, ++ Operand extra_space = Operand(0)); + + // The ebp-relative location of a regexp register. + MemOperand register_location(int register_index); diff --git a/debian/patches/ninja-1.12.patch b/debian/patches/ninja-1.12.patch new file mode 100644 index 0000000000..df2b1b2b9d --- /dev/null +++ b/debian/patches/ninja-1.12.patch @@ -0,0 +1,47 @@ +Description: Build with Ninja 1.12. +Author: Soren Stoutner +Forwarded: Cherry-picked from upstream. +Origin: upstream, https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/555586 +Origin: upstream, https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/560295 +Last-Update: 2024-05-22 + +--- a/src/3rdparty/chromium/content/public/browser/BUILD.gn ++++ b/src/3rdparty/chromium/content/public/browser/BUILD.gn +@@ -469,6 +469,7 @@ jumbo_source_set("browser_sources") { + "//build:chromeos_buildflags", + "//cc", + "//components/viz/host", ++ "//components/spellcheck:buildflags", + "//content/browser", # Must not be public_deps! + "//device/fido", + "//gpu", +--- a/src/3rdparty/chromium/components/history/core/browser/BUILD.gn ++++ b/src/3rdparty/chromium/components/history/core/browser/BUILD.gn +@@ -105,6 +105,7 @@ static_library("browser") { + "//components/keyed_service/core", + "//components/prefs", + "//components/query_parser", ++ "//components/signin/public/base:signin_buildflags", + "//components/signin/public/identity_manager", + "//components/sync", + "//components/url_formatter", +--- a/src/3rdparty/chromium/components/webcrypto/BUILD.gn ++++ b/src/3rdparty/chromium/components/webcrypto/BUILD.gn +@@ -62,6 +62,7 @@ static_library("webcrypto") { + "//crypto", + "//crypto:platform", + "//third_party/blink/public:blink_headers", ++ "//third_party/blink/renderer/platform/heap:heap", + ] + } + +--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/BUILD.gn ++++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/BUILD.gn +@@ -121,6 +121,7 @@ blink_platform_sources("heap") { + } + + visibility = [ ++ "//components/webcrypto:webcrypto", + "//third_party/blink/renderer/platform:platform", + "//third_party/blink/renderer/platform/instrumentation:instrumentation", + "//third_party/blink/renderer/platform/loader:loader", diff --git a/debian/patches/python3.11.patch b/debian/patches/python3.11.patch deleted file mode 100644 index 37c040ec70..0000000000 --- a/debian/patches/python3.11.patch +++ /dev/null @@ -1,46 +0,0 @@ -Description: fix build with Python 3.11 -Author: Dmitry Shachnev -Last-Update: 2023-01-08 - ---- a/src/3rdparty/chromium/tools/grit/grit/util.py -+++ b/src/3rdparty/chromium/tools/grit/grit/util.py -@@ -211,7 +211,7 @@ def ReadFile(filename, encoding): - mode = 'rb' - encoding = None - else: -- mode = 'rU' -+ mode = 'r' - - with io.open(abs(filename), mode, encoding=encoding) as f: - return f.read() ---- a/src/3rdparty/chromium/tools/metrics/structured/model.py -+++ b/src/3rdparty/chromium/tools/metrics/structured/model.py -@@ -26,7 +26,7 @@ _METRIC_TYPE = models.ObjectNodeType( - 'metric', - attributes=[ - ('name', unicode, r'^[A-Za-z0-9_.]+$'), -- ('kind', unicode, r'^(?i)(|hashed-string|int)$'), -+ ('kind', unicode, r'(?i)^(|hashed-string|int)$'), - ], - alphabetization=[ - (_OBSOLETE_TYPE.tag, lambda _: 1), ---- a/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py -+++ b/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py -@@ -42,7 +42,7 @@ _INDEX_TYPE = models.ObjectNodeType( - _STATISTICS_TYPE = models.ObjectNodeType( - 'statistics', - attributes=[ -- ('export', str, r'^(?i)(|true|false)$'), -+ ('export', str, r'(?i)^(|true|false)$'), - ], - children=[ - models.ChildType(_QUANTILES_TYPE.tag, _QUANTILES_TYPE, multiple=False), -@@ -94,7 +94,7 @@ _EVENT_TYPE = models.ObjectNodeType( - 'event', - attributes=[ - ('name', str, r'^[A-Za-z0-9.]+$'), -- ('singular', str, r'^(?i)(|true|false)$'), -+ ('singular', str, r'(?i)^(|true|false)$'), - ], - alphabetization=[ - (_OBSOLETE_TYPE.tag, _KEEP_ORDER), diff --git a/debian/patches/python3.12-imp.patch b/debian/patches/python3.12-imp.patch new file mode 100644 index 0000000000..b879e3ee9d --- /dev/null +++ b/debian/patches/python3.12-imp.patch @@ -0,0 +1,24 @@ +Description: stop using imp module which was removed in Python 3.12 +Origin: upstream, https://chromium.googlesource.com/chromium/src/+/f5f6e361d037c316 +Last-Update: 2024-06-30 + +--- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/fileutil.py ++++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/fileutil.py +@@ -3,7 +3,6 @@ + # found in the LICENSE file. + + import errno +-import imp + import os.path + import sys + +--- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/parse/lexer.py ++++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/parse/lexer.py +@@ -2,7 +2,6 @@ + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +-import imp + import os.path + import sys + diff --git a/debian/patches/python3.12-six.patch b/debian/patches/python3.12-six.patch new file mode 100644 index 0000000000..f1f5ae143c --- /dev/null +++ b/debian/patches/python3.12-six.patch @@ -0,0 +1,56 @@ +Description: implement find_spec() for _SixMetaPathImporter +Origin: upstream, https://github.com/benjaminp/six/commit/25916292d96f5f09 +Last-Update: 2024-03-17 + +--- a/src/3rdparty/chromium/third_party/protobuf/third_party/six/six.py ++++ b/src/3rdparty/chromium/third_party/protobuf/third_party/six/six.py +@@ -71,6 +71,11 @@ else: + MAXSIZE = int((1 << 63) - 1) + del X + ++if PY34: ++ from importlib.util import spec_from_loader ++else: ++ spec_from_loader = None ++ + + def _add_doc(func, doc): + """Add documentation to a function.""" +@@ -186,6 +191,11 @@ class _SixMetaPathImporter(object): + return self + return None + ++ def find_spec(self, fullname, path, target=None): ++ if fullname in self.known_modules: ++ return spec_from_loader(fullname, self) ++ return None ++ + def __get_module(self, fullname): + try: + return self.known_modules[fullname] +--- a/src/3rdparty/chromium/tools/grit/third_party/six/__init__.py ++++ b/src/3rdparty/chromium/tools/grit/third_party/six/__init__.py +@@ -71,6 +71,11 @@ else: + MAXSIZE = int((1 << 63) - 1) + del X + ++if PY34: ++ from importlib.util import spec_from_loader ++else: ++ spec_from_loader = None ++ + + def _add_doc(func, doc): + """Add documentation to a function.""" +@@ -186,6 +191,11 @@ class _SixMetaPathImporter(object): + return self + return None + ++ def find_spec(self, fullname, path, target=None): ++ if fullname in self.known_modules: ++ return spec_from_loader(fullname, self) ++ return None ++ + def __get_module(self, fullname): + try: + return self.known_modules[fullname] diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch deleted file mode 100644 index 1ed6e4c062..0000000000 --- a/debian/patches/python3.patch +++ /dev/null @@ -1,159 +0,0 @@ -Description: replace Python 2 with Python 3 in the build system -Author: Dmitry Shachnev -Last-Update: 2022-11-25 -Forwarded: not-needed - ---- a/configure.pri -+++ b/configure.pri -@@ -6,23 +6,6 @@ QTWEBENGINE_SOURCE_TREE = $$PWD - - equals(QMAKE_HOST.os, Windows): EXE_SUFFIX = .exe - --defineTest(isPythonVersionSupported) { -- python = $$system_quote($$system_path($$1)) -- python_version = $$system('$$python -c "import sys; print(sys.version_info[0:3])"') -- python_version ~= s/[()]//g -- python_version = $$split(python_version, ',') -- python_major_version = $$first(python_version) -- greaterThan(python_major_version, 2) { -- qtLog("Python version 3 is not supported by Chromium.") -- return(false) -- } -- python_minor_version = $$member(python_version, 1) -- python_patch_version = $$member(python_version, 2) -- greaterThan(python_major_version, 1): greaterThan(python_minor_version, 6): greaterThan(python_patch_version, 4): return(true) -- qtLog("Unsupported python version: $${python_major_version}.$${python_minor_version}.$${python_patch_version}.") -- return(false) --} -- - defineTest(qtConfTest_detectJumboBuild) { - mergeLimit = $$eval(config.input.merge_limit) - mergeLimit = $$find(mergeLimit, "\\d") -@@ -52,22 +35,18 @@ defineTest(qtConfReport_jumboBuild) { - qtConfReportPadded($${1}, $$mergeLimit) - } - --defineTest(qtConfTest_detectPython2) { -- python = $$qtConfFindInPath("python2$$EXE_SUFFIX") -+defineTest(qtConfTest_detectPython3) { -+ python = $$qtConfFindInPath("python3$$EXE_SUFFIX") - isEmpty(python) { -- qtLog("'python2$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.") -+ qtLog("'python3$$EXE_SUFFIX' not found in PATH. Checking for 'python$$EXE_SUFFIX'.") - python = $$qtConfFindInPath("python$$EXE_SUFFIX") - } - isEmpty(python) { - qtLog("'python$$EXE_SUFFIX' not found in PATH. Giving up.") - return(false) - } -- !isPythonVersionSupported($$python) { -- qtLog("A suitable Python 2 executable could not be located.") -- return(false) -- } - -- # Make tests.python2.location available in configure.json. -+ # Make tests.python3.location available in configure.json. - $${1}.location = $$clean_path($$python) - export($${1}.location) - $${1}.cache += location ---- a/mkspecs/features/functions.prf -+++ b/mkspecs/features/functions.prf -@@ -44,11 +44,11 @@ defineReplace(which) { - - # Returns the unquoted path to the python executable. - defineReplace(pythonPath) { -- isEmpty(QMAKE_PYTHON2) { -+ isEmpty(QMAKE_PYTHON3) { - # Fallback for building QtWebEngine with Qt < 5.8 -- QMAKE_PYTHON2 = python -+ QMAKE_PYTHON3 = python - } -- return($$QMAKE_PYTHON2) -+ return($$QMAKE_PYTHON3) - } - - # Returns the python executable for use with shell / make targets. ---- a/src/buildtools/config/support.pri -+++ b/src/buildtools/config/support.pri -@@ -21,7 +21,7 @@ defineReplace(qtwebengine_checkWebEngine - !qtwebengine_checkForGperf(QtWebEngine):return(false) - !qtwebengine_checkForBison(QtWebEngine):return(false) - !qtwebengine_checkForFlex(QtWebEngine):return(false) -- !qtwebengine_checkForPython2(QtWebEngine):return(false) -+ !qtwebengine_checkForPython3(QtWebEngine):return(false) - !qtwebengine_checkForNodejs(QtWebEngine):return(false) - !qtwebengine_checkForSanitizer(QtWebEngine):return(false) - linux:!qtwebengine_checkForPkgCfg(QtWebEngine):return(false) -@@ -51,7 +51,7 @@ defineReplace(qtwebengine_checkPdfError) - !qtwebengine_checkForGperf(QtPdf):return(false) - !qtwebengine_checkForBison(QtPdf):return(false) - !qtwebengine_checkForFlex(QtPdf):return(false) -- !qtwebengine_checkForPython2(QtPdf):return(false) -+ !qtwebengine_checkForPython3(QtPdf):return(false) - !qtwebengine_checkForSanitizer(QtPdf):return(false) - linux:!qtwebengine_checkForPkgCfg(QtPdf):return(false) - linux:!qtwebengine_checkForHostPkgCfg(QtPdf):return(false) -@@ -143,10 +143,10 @@ defineTest(qtwebengine_checkForFlex) { - return(true) - } - --defineTest(qtwebengine_checkForPython2) { -+defineTest(qtwebengine_checkForPython3) { - module = $$1 -- !qtConfig(webengine-python2) { -- qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build $${module}.") -+ !qtConfig(webengine-python3) { -+ qtwebengine_skipBuild("Python version 3 is required to build $${module}.") - return(false) - } - return(true) ---- a/src/buildtools/configure.json -+++ b/src/buildtools/configure.json -@@ -301,9 +301,9 @@ - "label": "system ninja", - "type": "detectNinja" - }, -- "webengine-python2": { -- "label": "python2", -- "type": "detectPython2", -+ "webengine-python3": { -+ "label": "python3", -+ "type": "detectPython3", - "log": "location" - }, - "webengine-winversion": { -@@ -380,7 +380,7 @@ - && features.webengine-gperf - && features.webengine-bison - && features.webengine-flex -- && features.webengine-python2 -+ && features.webengine-python3 - && features.webengine-nodejs - && (!config.sanitizer || features.webengine-sanitizer) - && (!config.linux || features.pkg-config) -@@ -406,7 +406,7 @@ - && features.webengine-gperf - && features.webengine-bison - && features.webengine-flex -- && features.webengine-python2 -+ && features.webengine-python3 - && (!config.sanitizer || features.webengine-sanitizer) - && (!config.linux || features.pkg-config) - && (!config.linux || features.webengine-host-pkg-config) -@@ -429,12 +429,12 @@ - "autoDetect": "features.private_tests", - "output": [ "privateFeature" ] - }, -- "webengine-python2": { -- "label": "python2", -- "condition": "tests.webengine-python2", -+ "webengine-python3": { -+ "label": "python3", -+ "condition": "tests.webengine-python3", - "output": [ - "privateFeature", -- { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" } -+ { "type": "varAssign", "name": "QMAKE_PYTHON3", "value": "tests.webengine-python3.location" } - ] - }, - "webengine-gperf": { diff --git a/debian/patches/sandbox-time64-syscalls.patch b/debian/patches/sandbox-time64-syscalls.patch index 092fb37b56..d3a325f08a 100644 --- a/debian/patches/sandbox-time64-syscalls.patch +++ b/debian/patches/sandbox-time64-syscalls.patch @@ -2,7 +2,7 @@ Description: fix seccomp-bpf failures in syscall 422 (futex_time64) glibc 2.33 and newer uses this syscall on 32-bit platforms: https://sourceware.org/git/?p=glibc.git;a=commit;h=29e9874a048f47e2 Author: Fabian Vogt -Forwarded: no +Forwarded: not-needed Last-Update: 2022-11-25 --- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc diff --git a/debian/patches/series b/debian/patches/series index 9fb77685f1..31eb382904 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,9 +5,8 @@ system-nspr-prtime.patch system-icu-utf.patch # Fix python problems. -python3.patch -chromium-python3.patch -python3.11.patch +python3.12-imp.patch +python3.12-six.patch # General patches. verbose-gn-bootstrap.patch @@ -22,7 +21,7 @@ mips64el-kernel_stat64.patch armhf-no-thumb.patch disable-catapult.patch pipewire-0.3.patch -ffmpeg-x86-optimization.patch fix-example-pro-files.patch - -icu74.patch +build-with-c++17.patch +ninja-1.12.patch +mips64el-v8-regexp.patch diff --git a/debian/patches/system-openjpeg2.patch b/debian/patches/system-openjpeg2.patch index 051a9baf84..e80dee86ad 100644 --- a/debian/patches/system-openjpeg2.patch +++ b/debian/patches/system-openjpeg2.patch @@ -1,12 +1,12 @@ Description: Use system libopenjpeg2 -Author: Soren Stoutner +Author: Soren Stoutner Forwarded: https://bugreports.qt.io/browse/QTBUG-63889 Last-Update: 2023-01-28 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json -@@ -114,6 +114,12 @@ +@@ -115,6 +115,12 @@ "-ljpeg" ] }, @@ -19,7 +19,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ "webengine-libevent": { "label": "libevent", "sources": [ -@@ -611,6 +617,11 @@ +@@ -633,6 +639,11 @@ "condition": "config.unix && features.system-jpeg && libs.webengine-jpeglib", "output": [ "privateFeature" ] }, @@ -31,7 +31,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ "webengine-qt-jpeg" : { "label": "qtlibjpeg", "condition": "config.static && !features.system-jpeg && features.jpeg", -@@ -819,6 +830,7 @@ +@@ -846,6 +857,7 @@ "webengine-system-lcms2", "webengine-system-png", "webengine-system-jpeg", @@ -41,7 +41,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ ] --- a/src/buildtools/config/linux.pri +++ b/src/buildtools/config/linux.pri -@@ -164,6 +164,11 @@ +@@ -164,6 +164,11 @@ host_build { } else { gn_args += use_system_libjpeg=false } diff --git a/debian/patches/verbose-gn-bootstrap.patch b/debian/patches/verbose-gn-bootstrap.patch index 24a127ccf6..08fe84a52c 100644 --- a/debian/patches/verbose-gn-bootstrap.patch +++ b/debian/patches/verbose-gn-bootstrap.patch @@ -1,6 +1,6 @@ Description: print compiler commands, honor $NINJAJOBS when bootstrapping gn Author: Dmitry Shachnev -Forwarded: no +Forwarded: not-needed Last-Update: 2021-06-18 --- a/src/buildtools/gn.pro diff --git a/debian/rules b/debian/rules index 40c01f40f6..8c23562141 100755 --- a/debian/rules +++ b/debian/rules @@ -61,24 +61,9 @@ touch_files = src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/ src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/acorn/package/dist/acorn.js \ src/3rdparty/chromium/third_party/web-animations-js/sources/web-animations-next-lite.min.js -ifeq (loong64, $(DEB_HOST_ARCH)) - TARGET_PATCH = patch_loong64 -else ifeq (riscv64, $(DEB_HOST_ARCH)) - TARGET_PATCH = patch_riscv64 -endif - -patch_loong64: - patch -p1 < debian/patches/Port-for-loongarch64.patch - -patch_riscv64: - patch -p1 < debian/patches/add-riscv64-support.patch - %: dh $@ --with pkgkde_symbolshelper -override_dh_autoreconf: $(TARGET_PATCH) - dh_autoreconf - override_dh_auto_clean: dh_auto_clean @@ -93,7 +78,7 @@ override_dh_auto_clean: done override_dh_auto_configure: - qmake QT_BUILD_PARTS+=tests QMAKE_EXTRA_ARGS+="$(config_args)" QMAKE_PYTHON3=python3 $(qmake_args) + qmake QT_BUILD_PARTS+=tests QMAKE_EXTRA_ARGS+="$(config_args)" QMAKE_PYTHON2=python3 $(qmake_args) # Create js files, that are needed for building step for arch and indep builds cd $(CURDIR)/src/3rdparty/chromium/third_party/jstemplate/; \ @@ -107,7 +92,11 @@ override_dh_auto_configure: touch $(CURDIR)/$${fname}; \ done - /usr/lib/qt5/bin/syncqt.pl Source -version ${DEB_VERSION_UPSTREAM:+dfsg=} + /usr/lib/qt5/bin/syncqt.pl Source -version $(word 1,$(subst +, ,$(DEB_VERSION_UPSTREAM))) + + # Link against the system version of dagre-layout. The bundled version was removed by debian/copyright. + mkdir -p src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout + ln -s /usr/share/nodejs/dagre/dist/dagre.js -t src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout override_dh_auto_build-arch: dh_auto_build -- -Onone @@ -131,7 +120,7 @@ override_dh_auto_install-arch: # Do not require matching versions of Qt dependencies set -eu && \ - VERSION=${DEB_VERSION_UPSTREAM:+dfsg=} && \ + VERSION=$(word 1,$(subst +, ,$(DEB_VERSION_UPSTREAM))) && \ QT_VERSION=$$(qmake -query QT_VERSION) && \ sed -i "s/$$VERSION /$$QT_VERSION /" debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/*/*Config.cmake @@ -169,8 +158,9 @@ endef get-orig-source: @set -eux && \ TEMPDIR=$$(mktemp -d) && \ - VERSION=${DEB_VERSION_UPSTREAM:+dfsg=} && \ - SUBMODULE_COMMIT=8df91f886e7fffb61408e2426f8a90d763a3b6ea && \ + VERSION=$(word 1,$(subst +, ,$(DEB_VERSION_UPSTREAM))) && \ + DFSG=$(word 2,$(subst +, ,$(DEB_VERSION_UPSTREAM))) && \ + SUBMODULE_COMMIT=fdfef5b37af3bed8402d7c7e20a5487f2602b0a6 && \ echo "$${GET_FILES_EXCLUDED}" >$${TEMPDIR}/get_files_excluded.py && \ cd $${TEMPDIR} && \ wget https://github.com/qt/qtwebengine/archive/v$${VERSION}-lts.tar.gz && \ @@ -184,5 +174,5 @@ get-orig-source: cd src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules && \ ls -A | grep -Ev '^(@types|rollup|typescript)$$' | xargs rm -rf && \ cd $${TEMPDIR} && \ - tar cJ --owner=root --group=root --sort=name -f $(CURDIR)/../qtwebengine-opensource-src_$${VERSION}+dfsg.orig.tar.xz qtwebengine-$${VERSION}-lts && \ + tar cJ --owner=root --group=root --sort=name -f $(CURDIR)/../qtwebengine-opensource-src_$${VERSION}+$${DFSG}.orig.tar.xz qtwebengine-$${VERSION}-lts && \ rm -rf $${TEMPDIR} diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index 3b60993f1a..ac9a147922 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -10,33 +10,93 @@ qtwebengine-opensource-src source: license-problem-json-evil [src/3rdparty/chrom # The old, non-hinted Lintian syntax is required because FTP Masters is running an older version of Lintian. The following line can be removed at some point in the future. qtwebengine-opensource-src source: license-problem-json-evil src/3rdparty/chromium/third_party/angle/third_party/rapidjson/src/license.txt +# This notice file is simply a symlink to the Apache 2 LICENSE file. As no extra information is contained in the NOTICE file, the requirements are already fulfilled with the entry in debian/copyright. +qtwebengine-opensource-src source: missing-notice-file-for-apache-license [src/3rdparty/chromium/third_party/ukey2/src/NOTICE] + # Source is in debian/missing-sources/jquery-1.3.2.js, replaced by build step with self-minified version qtwebengine-opensource-src source: source-is-missing [examples/webenginewidgets/contentmanipulation/jquery.min.js] # Source is in debian/missing-sources/mocha-6.1.4 qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/mocha/mocha.js] -# Valid files, with very long lines (files are not minified) +# Source is in src/3rdparty/chromium/third_party/blink/renderer/devtools/scripts/javascript_natives/index.js +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/javascript_metadata/NativeFunctions.js] + +# Source is in src/3rdparty/chromium/components/variations/proto/devtools/client_variations_uncompiled.js +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/components/variations/proto/devtools/client_variations.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/chromium/client-variations/ClientVariations.js] + +# Source is in src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/intl-messageformat/package/dist/ +# The ideal would be to package the upstream intl-messageformat, but the embedded version in Qt5 WebEngine is very old (4.4.0 vs. 10.5.8 on 28 November 2023). +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/intl-messageformat/package/core.js] + +# this is not compiled, despite the filename +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/polymer/v3_0/components-chromium/paper-spinner/paper-spinner-lite.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/js/jstemplate_compiled.js] + +# Valid files with very long lines (files are not minified) +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/chrome/browser/resources/omnibox/omnibox.html] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/chrome/browser/resources/signin/profile_picker/icons.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/content/browser/webrtc/resources/webrtc_internals.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/net/base/dir_header.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/axe-core/axe.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/autofill-popup-location.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/bugzilla-48077.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/contenteditable-link.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/dictionary-scrolled-iframe.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/linkjump-1.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/linkjump-2.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/linkjump-4.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/popup-width-restriction-within-screen.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/resources/testframe-link_text.html] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/win/milliondollar.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/renderer/core/testing/data/fixed_layout.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/renderer/core/testing/data/resize_scroll_fixed_layout.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/renderer/core/testing/data/resize_scroll_fixed_width.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/renderer/core/testing/data/resize_scroll_mobile.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/axe-core/axe.js] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/codemirror/package/addon/hint/html-hint.js] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/codemirror/package/mode/*] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/codemirror/package/src/util/misc.js] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/inspector_overlay/debug/*] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/tsc.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/tsserver.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/tsserverlibrary.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/typescript.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/typescriptServices.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/node_modules/typescript/lib/typingsInstaller.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/google-closure-library/closure/goog/demos/textarea.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/google-closure-library/closure/goog/deps.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/google-closure-library/closure/goog/i18n/datetimesymbolsext.js] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/google-closure-library/closure/goog/ui/ac/renderer_test.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/leveldatabase/src/doc/benchmark.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/lottie/lottie_worker.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/webxr_test_pages/webxr-samples/attribution.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/webxr_test_pages/webxr-samples/explainer.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/webxr_test_pages/webxr-samples/js/webxr-polyfill.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/webxr_test_pages/webxr-samples/js/webxr-polyfill.module.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/tools/win/sizeviewer/codemirror.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/accessibility/extensions/chromevoxclassic/cvox2/background/sre_browser.js] -# base64-encoded image/data, this is normal +# Valid files with lots of Unicode characters. +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/components/dom_distiller/core/html/preview.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/skia/modules/skparagraph/test.html] + +# base64-encoded or SVG image/data, this is normal +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/chrome/browser/resources/management/icons.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/chrome/browser/resources/nearby_share/shared/nearby_shared_icons.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/chrome/browser/resources/pdf/elements/icons.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/components/android_system_error_page/resources/load_error.html] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/image-resampling-with-scale.html] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/blink/manual_tests/svg-image-resampling-with-scale.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/d3/src/d3.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/report-assets/template.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/lighthouse/report-assets/templates.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/google-closure-library/doc/_includes/favicon.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/tools/binary_size/libsupersize/static/viewer.html] qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/tools/page_cycler/acid3/acid3.acidtests.org/index.html] - -# source is in src/3rdparty/chromium/third_party/blink/renderer/devtools/scripts/javascript_natives/index.js -qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/javascript_metadata/NativeFunctions.js] - -# source is in src/3rdparty/chromium/components/variations/proto/devtools/client_variations_uncompiled.js -qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/components/variations/proto/devtools/client_variations.js] -qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/chromium/client-variations/ClientVariations.js] - -# this is not compiled, despite the filename -qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/third_party/polymer/v3_0/components-chromium/paper-spinner/paper-spinner-lite.js] -qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/js/jstemplate_compiled.js] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/login/account_picker/chromeos_user_pod_template.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/cr_components/chromeos/network/network_icons.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/cr_elements/icons.html] +qtwebengine-opensource-src source: source-is-missing [src/3rdparty/chromium/ui/webui/resources/cr_elements/mwb_shared_icons.html] diff --git a/src/3rdparty/chromium/AUTHORS b/src/3rdparty/chromium/AUTHORS index 92f53ac669..9d61a61e57 100644 --- a/src/3rdparty/chromium/AUTHORS +++ b/src/3rdparty/chromium/AUTHORS @@ -631,6 +631,7 @@ Luke Inman-Semerau Luke Seunghoe Gu Luke Zarko Luoxi Pan +Lyra Rebane Maarten Lankhorst Magnus Danielsson Mahesh Kulkarni diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h b/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h index e77003eab2..31ac05b86f 100644 --- a/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h +++ b/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h @@ -119,6 +119,21 @@ AslrMask(uintptr_t bits) { return AslrAddress(0x20000000ULL); } + #elif defined(OS_LINUX) + + // Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on + // page size and number of levels of translation pages used. We use + // 39-bit as base as all setups should support this, lowered to 38-bit + // as ASLROffset() could cause a carry. + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t + ASLRMask() { + return AslrMask(38); + } + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t + ASLROffset() { + return AslrAddress(0x1000000000ULL); + } + #else // ARM64 on Linux has 39-bit user space. Use 38 bits since ASLROffset() diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h index c42fe2835f..9e4f7b9557 100644 --- a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h +++ b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h @@ -24,6 +24,31 @@ // elimination. #define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) +// This should work for all POSIX (if needed), but currently all other +// supported OS/architecture combinations use either hard-coded values +// (such as x86) or have means to determine these values without needing +// atomics (such as macOS on arm64). + +// Page allocator constants are run-time constant +#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) + +#include +#include + +namespace base::internal { + +// Holds the current page size and shift, where size = 1 << shift +// Use PageAllocationGranularity(), PageAllocationGranularityShift() +// to initialize and retrieve these values safely. +struct PageCharacteristics { + std::atomic size; + std::atomic shift; +}; +extern PageCharacteristics page_characteristics; + +} // namespace base::internal + #else // When defined, page size constants are fixed at compile time. When not @@ -36,11 +61,12 @@ #endif -namespace { - -#if !defined(OS_APPLE) +namespace base { +// Forward declaration, implementation below +PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t +PageAllocationGranularity(); -constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { +PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() { #if defined(OS_WIN) || defined(ARCH_CPU_PPC64) // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page // sizes. Since 64kB is the de facto standard on the platform and binaries @@ -49,21 +75,37 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { return 16; // 64kB #elif defined(_MIPS_ARCH_LOONGSON) return 14; // 16kB +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) + // page sizes. Retrieve from or initialize cache. + int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed); + if (UNLIKELY(shift == 0)) { + shift = __builtin_ctz((int)base::PageAllocationGranularity()); + base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed); + } + return shift; +#elif defined(OS_APPLE) + return vm_page_shift; #else return 12; // 4kB #endif } -#endif - -} // namespace - -namespace base { - PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t PageAllocationGranularity() { #if defined(OS_APPLE) + // This is literally equivalent to |1 << PageAllocationGranularityShift()| + // below, but was separated out for OS_APPLE to avoid << on a non-constexpr. return vm_page_size; +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or + // initialize cache. + int size = internal::page_characteristics.size.load(std::memory_order_relaxed); + if (UNLIKELY(size == 0)) { + size = getpagesize(); + internal::page_characteristics.size.store(size, std::memory_order_relaxed); + } + return size; #else return 1ULL << PageAllocationGranularityShift(); #endif diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc index 03883bcb11..90efc51c83 100644 --- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc +++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc @@ -75,6 +75,12 @@ void PartitionAddressSpace::UninitForTesting() { internal::AddressPoolManager::GetInstance()->ResetForTesting(); } +#if defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + +PageCharacteristics page_characteristics; + +#endif // defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + #endif // defined(PA_HAS_64_BITS_POINTERS) } // namespace internal diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc index daeb6d5cb1..7c434b5e69 100644 --- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc +++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc @@ -522,7 +522,7 @@ static size_t PartitionPurgePage(internal::PartitionPage* page, #if defined(PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR) constexpr size_t kMaxSlotCount = (PartitionPageSize() * kMaxPartitionPagesPerSlotSpan) / SystemPageSize(); -#elif defined(OS_APPLE) +#elif defined(OS_APPLE) || (defined(OS_LINUX) && defined(ARCH_CPU_ARM64)) // It's better for slot_usage to be stack-allocated and fixed-size, which // demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is // always SystemPageSize() << 2, so regardless of what the run time page size diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h index c8268ec30a..f03ba1e4ab 100644 --- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h +++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h @@ -57,10 +57,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PartitionPageShift() { return 18; // 256 KiB } -#elif defined(OS_APPLE) +#elif defined(OS_APPLE) || \ + (defined(OS_LINUX) && defined(ARCH_CPU_ARM64)) PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PartitionPageShift() { - return vm_page_shift + 2; + return PageAllocationGranularityShift() + 2; } #else PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int diff --git a/src/3rdparty/chromium/build/android/gyp/java_cpp_enum.py b/src/3rdparty/chromium/build/android/gyp/java_cpp_enum.py index 0b9ee541e4..5fd66b93b9 100755 --- a/src/3rdparty/chromium/build/android/gyp/java_cpp_enum.py +++ b/src/3rdparty/chromium/build/android/gyp/java_cpp_enum.py @@ -186,8 +186,9 @@ class HeaderParser(object): enum_name_re = r'(\w+)' optional_fixed_type_re = r'(\:\s*(\w+\s*\w+?))?' enum_start_re = re.compile(r'^\s*(?:\[cpp.*\])?\s*enum\s+' + - optional_class_or_struct_re + '\s*' + enum_name_re + '\s*' + - optional_fixed_type_re + '\s*{\s*') + optional_class_or_struct_re + r'\s*' + + enum_name_re + r'\s*' + optional_fixed_type_re + + r'\s*{\s*') enum_single_line_re = re.compile( r'^\s*(?:\[cpp.*\])?\s*enum.*{(?P.*)}.*$') diff --git a/src/3rdparty/chromium/build/print_python_deps.py b/src/3rdparty/chromium/build/print_python_deps.py index fd29c0972c..2a0118563e 100755 --- a/src/3rdparty/chromium/build/print_python_deps.py +++ b/src/3rdparty/chromium/build/print_python_deps.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.7 +#!/usr/bin/python3 # Copyright 2016 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -152,7 +152,7 @@ def main(): # Trybots run with vpython as default Python, but with a different config # from //.vpython. To make the is_vpython test work, and to match the behavior - # of dev machines, the shebang line must be run with python2.7. + # of dev machines, the shebang line must be run with python3. # # E.g. $HOME/.vpython-root/dd50d3/bin/python # E.g. /b/s/w/ir/cache/vpython/ab5c79/bin/python diff --git a/src/3rdparty/chromium/build/util/python2_action.py b/src/3rdparty/chromium/build/util/python2_action.py index a62d065ce1..d23ec8eaf2 100644 --- a/src/3rdparty/chromium/build/util/python2_action.py +++ b/src/3rdparty/chromium/build/util/python2_action.py @@ -6,17 +6,5 @@ import subprocess import sys -if sys.version_info.major == 2: - # If we get here, we're already Python2, so just re-execute the - # command without the wrapper. - exe = sys.executable -elif sys.executable.endswith('.exe'): - # If we get here, we're a Python3 executable likely running on - # Windows, so look for the Python2 wrapper in depot_tools. - exe = 'python.bat' -else: - # If we get here, we are a Python3 executable. Hope that we can find - # a `python2.7` in path somewhere. - exe = 'python2.7' - +exe = sys.executable sys.exit(subprocess.call([exe] + sys.argv[1:])) diff --git a/src/3rdparty/chromium/components/crx_file/crx_verifier.cc b/src/3rdparty/chromium/components/crx_file/crx_verifier.cc index cbd7d777b6..d03cadb150 100644 --- a/src/3rdparty/chromium/components/crx_file/crx_verifier.cc +++ b/src/3rdparty/chromium/components/crx_file/crx_verifier.cc @@ -4,6 +4,7 @@ #include "components/crx_file/crx_verifier.h" +#include #include #include #include @@ -44,6 +45,9 @@ constexpr uint8_t kPublisherTestKeyHash[] = { 0x5f, 0x64, 0xf3, 0xa6, 0x17, 0x03, 0x0d, 0xde, 0x21, 0x61, 0xbe, 0xb7, 0x95, 0x91, 0x95, 0x83, 0x68, 0x12, 0xe9, 0x78, 0x1e}; +constexpr uint8_t kEocd[] = {'P', 'K', 0x05, 0x06}; +constexpr uint8_t kEocd64[] = {'P', 'K', 0x06, 0x07}; + using VerifierCollection = std::vector>; using RepeatedProof = google::protobuf::RepeatedPtrField; @@ -109,6 +113,18 @@ VerifierResult VerifyCrx3( if (ReadAndHashBuffer(header_bytes.data(), header_size, file, hash) != static_cast(header_size)) return VerifierResult::ERROR_HEADER_INVALID; + + // If the header contains a ZIP EOCD or EOCD64 token, unzipping may not work + // correctly. + if (std::search(std::begin(header_bytes), std::end(header_bytes), + std::begin(kEocd), + std::end(kEocd)) != std::end(header_bytes) || + std::search(std::begin(header_bytes), std::end(header_bytes), + std::begin(kEocd64), + std::end(kEocd64)) != std::end(header_bytes)) { + return VerifierResult::ERROR_HEADER_INVALID; + } + CrxFileHeader header; if (!header.ParseFromArray(header_bytes.data(), header_size)) return VerifierResult::ERROR_HEADER_INVALID; diff --git a/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py b/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py index 7422ead969..f98e87594e 100755 --- a/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py +++ b/src/3rdparty/chromium/components/resources/protobufs/binary_proto_generator.py @@ -7,9 +7,8 @@ Converts a given ASCII proto into a binary resource. """ - +from __future__ import print_function import abc -import imp import optparse import os import re @@ -17,6 +16,12 @@ import sys import traceback +PY34 = sys.version_info[0:2] >= (3, 4) + +if PY34: + from importlib import util as imp_util +else: + import imp class GoogleProtobufModuleImporter: """A custom module importer for importing google.protobuf. @@ -67,8 +72,16 @@ def load_module(self, fullname): # but is included for completeness. raise ImportError(fullname) - filepath = self._fullname_to_filepath(fullname) - return imp.load_source(fullname, filepath) + if PY34: + filepath = self._fullname_to_filepath(fullname) + spec = imp_util.spec_from_file_location(fullname, filepath) + loaded = imp_util.module_from_spec(spec) + spec.loader.exec_module(loaded) + + else: + return imp.load_source(fullname, filepath) + + return loaded class BinaryProtoGenerator: @@ -196,12 +209,12 @@ def Run(self): self._ImportProtoModules(opts.path) if not self.VerifyArgs(opts): - print "Wrong arguments" + print("Wrong arguments") return 1 try: self._GenerateBinaryProtos(opts) except Exception as e: - print "ERROR: Failed to render binary version of %s:\n %s\n%s" % ( - opts.infile, str(e), traceback.format_exc()) + print("ERROR: Failed to render binary version of %s:\n %s\n%s" % + (opts.infile, str(e), traceback.format_exc())) return 1 diff --git a/src/3rdparty/chromium/components/update_client/protocol_parser_json.cc b/src/3rdparty/chromium/components/update_client/protocol_parser_json.cc index 71d3e54e6b..a165b42f08 100644 --- a/src/3rdparty/chromium/components/update_client/protocol_parser_json.cc +++ b/src/3rdparty/chromium/components/update_client/protocol_parser_json.cc @@ -168,7 +168,7 @@ bool ParseUpdateCheck(const base::Value& updatecheck_node, } for (const auto& kv : updatecheck_node.DictItems()) { - if (kv.first.front() == '_' && kv.second.is_string()) { + if (!kv.first.empty() && kv.first.front() == '_' && kv.second.is_string()) { result->custom_attributes[kv.first] = kv.second.GetString(); } } diff --git a/src/3rdparty/chromium/components/variations/seed_response.h b/src/3rdparty/chromium/components/variations/seed_response.h index 058bb11044..6879450e06 100644 --- a/src/3rdparty/chromium/components/variations/seed_response.h +++ b/src/3rdparty/chromium/components/variations/seed_response.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_VARIATIONS_SEED_RESPONSE_H_ #define COMPONENTS_VARIATIONS_SEED_RESPONSE_H_ +#include #include namespace variations { diff --git a/src/3rdparty/chromium/components/variations/service/generate_ui_string_overrider.py b/src/3rdparty/chromium/components/variations/service/generate_ui_string_overrider.py index 859b758ef8..2da8713403 100755 --- a/src/3rdparty/chromium/components/variations/service/generate_ui_string_overrider.py +++ b/src/3rdparty/chromium/components/variations/service/generate_ui_string_overrider.py @@ -20,7 +20,7 @@ # #define IDS_FOO_MESSAGE 1234 # With generate whitelist flag: # #define IDS_FOO_MESSAGE (::ui::AllowlistedResource<1234>(), 1234) -RESOURCE_EXTRACT_REGEX = re.compile('^#define (\S*).* (\d+)\)?$', re.MULTILINE) +RESOURCE_EXTRACT_REGEX = re.compile(r'^#define (\S*).* (\d+)\)?$', re.MULTILINE) class Error(Exception): """Base error class for all exceptions in generated_resources_map.""" diff --git a/src/3rdparty/chromium/components/viz/service/frame_sinks/compositor_frame_sink_support.cc b/src/3rdparty/chromium/components/viz/service/frame_sinks/compositor_frame_sink_support.cc index 7e10b2b6e5..a1133b220f 100644 --- a/src/3rdparty/chromium/components/viz/service/frame_sinks/compositor_frame_sink_support.cc +++ b/src/3rdparty/chromium/components/viz/service/frame_sinks/compositor_frame_sink_support.cc @@ -635,7 +635,7 @@ void CompositorFrameSinkSupport::DidPresentCompositorFrame( DCHECK_LE(pending_received_frame_times_.size(), 25u); auto received_frame_timestamp = pending_received_frame_times_.find(frame_token); - DCHECK(received_frame_timestamp != pending_received_frame_times_.end()); + CHECK(received_frame_timestamp != pending_received_frame_times_.end()); FrameTimingDetails details; details.received_compositor_frame_timestamp = @@ -648,8 +648,7 @@ void CompositorFrameSinkSupport::DidPresentCompositorFrame( pending_received_frame_times_.erase(received_frame_timestamp); // We should only ever get one PresentationFeedback per frame_token. - DCHECK(frame_timing_details_.find(frame_token) == - frame_timing_details_.end()); + CHECK(!frame_timing_details_.contains(frame_token)); frame_timing_details_.emplace(frame_token, details); UpdateNeedsBeginFramesInternal(); diff --git a/src/3rdparty/chromium/content/browser/loader/navigation_url_loader_impl.cc b/src/3rdparty/chromium/content/browser/loader/navigation_url_loader_impl.cc index f54cfd9a61..41c78e2fe1 100644 --- a/src/3rdparty/chromium/content/browser/loader/navigation_url_loader_impl.cc +++ b/src/3rdparty/chromium/content/browser/loader/navigation_url_loader_impl.cc @@ -560,10 +560,10 @@ void NavigationURLLoaderImpl::MaybeStartLoader( next_interceptor->MaybeCreateLoader( *resource_request_, browser_context_, base::BindOnce(&NavigationURLLoaderImpl::MaybeStartLoader, - base::Unretained(this), next_interceptor), + weak_factory_.GetWeakPtr(), next_interceptor), base::BindOnce( &NavigationURLLoaderImpl::FallbackToNonInterceptedRequest, - base::Unretained(this))); + weak_factory_.GetWeakPtr())); return; } diff --git a/src/3rdparty/chromium/content/browser/media/capture/web_contents_video_capture_device.cc b/src/3rdparty/chromium/content/browser/media/capture/web_contents_video_capture_device.cc index 0093df22c2..6100fe8167 100644 --- a/src/3rdparty/chromium/content/browser/media/capture/web_contents_video_capture_device.cc +++ b/src/3rdparty/chromium/content/browser/media/capture/web_contents_video_capture_device.cc @@ -41,7 +41,7 @@ class WebContentsVideoCaptureDevice::FrameTracker int main_render_frame_id) : device_(std::move(device)), device_task_runner_(base::ThreadTaskRunnerHandle::Get()), - cursor_controller_(cursor_controller) { + cursor_controller_(cursor_controller->GetWeakPtr()) { DCHECK(device_task_runner_); DCHECK(cursor_controller_); @@ -184,7 +184,9 @@ class WebContentsVideoCaptureDevice::FrameTracker // Note: MouseCursorOverlayController runs on the UI thread. It's also // important that SetTargetView() be called in the current stack while // |native_view| is known to be a valid pointer. http://crbug.com/818679 - cursor_controller_->SetTargetView(native_view); + if (cursor_controller_) { + cursor_controller_->SetTargetView(native_view); + } } } else { device_task_runner_->PostTask( @@ -192,7 +194,9 @@ class WebContentsVideoCaptureDevice::FrameTracker base::BindOnce( &WebContentsVideoCaptureDevice::OnTargetPermanentlyLost, device_)); - cursor_controller_->SetTargetView(gfx::NativeView()); + if (cursor_controller_) { + cursor_controller_->SetTargetView(gfx::NativeView()); + } } } @@ -200,10 +204,11 @@ class WebContentsVideoCaptureDevice::FrameTracker const base::WeakPtr device_; const scoped_refptr device_task_runner_; - // Owned by FrameSinkVideoCaptureDevice. This will be valid for the life of - // FrameTracker because the FrameTracker deleter task will be posted to the UI - // thread before the MouseCursorOverlayController deleter task. - MouseCursorOverlayController* const cursor_controller_; + // Owned by FrameSinkVideoCaptureDevice. This may only be accessed on the + // UI thread. This is not guaranteed to be valid and must be checked before + // use. + // https://crbug.com/1480152 + const base::WeakPtr cursor_controller_; viz::FrameSinkId target_frame_sink_id_; gfx::NativeView target_native_view_ = gfx::NativeView(); diff --git a/src/3rdparty/chromium/content/browser/renderer_host/render_frame_host_impl.cc b/src/3rdparty/chromium/content/browser/renderer_host/render_frame_host_impl.cc index ad9a55dc31..49c747b287 100644 --- a/src/3rdparty/chromium/content/browser/renderer_host/render_frame_host_impl.cc +++ b/src/3rdparty/chromium/content/browser/renderer_host/render_frame_host_impl.cc @@ -2068,6 +2068,13 @@ void RenderFrameHostImpl::RenderProcessGone( ResetNavigationRequests(); ResetLoadingState(); + // Also, clear any pending navigations that have been blocked while the + // embedder is processing window.open() requests. This is consistent + // with clearing NavigationRequests and loading state above, and it also + // makes sense because certain parts of `pending_navigate_`, like the + // NavigationClient remote interface, can no longer be used. + pending_navigate_.reset(); + // Any future UpdateState or UpdateTitle messages from this or a recreated // process should be ignored until the next commit. set_nav_entry_id(0); @@ -2366,17 +2373,29 @@ void RenderFrameHostImpl::Init() { return; waiting_for_init_ = false; + if (pending_navigate_) { - frame_tree_node()->navigator().OnBeginNavigation( - frame_tree_node(), std::move(pending_navigate_->common_params), - std::move(pending_navigate_->begin_navigation_params), - std::move(pending_navigate_->blob_url_loader_factory), - std::move(pending_navigate_->navigation_client), - std::move(pending_navigate_->navigation_initiator), + // Transfer `pending_navigate_` to a local variable, to avoid resetting it + // after OnBeginNavigation since `this` might already be destroyed (see + // below). + // + // This shouldn't matter for early RFH swaps out of crashed frames, since + // `pending_navigate_` is cleared when the renderer process dies, but it + // may matter for other current/future use cases of the early RFH swap. + std::unique_ptr pending_navigation = + std::move(pending_navigate_); + frame_tree_node()->navigator().OnBeginNavigation( + frame_tree_node(), std::move(pending_navigation->common_params), + std::move(pending_navigation->begin_navigation_params), + std::move(pending_navigation->blob_url_loader_factory), + std::move(pending_navigation->navigation_client), + std::move(pending_navigation->navigation_initiator), EnsurePrefetchedSignedExchangeCache(), MaybeCreateWebBundleHandleTracker()); - pending_navigate_.reset(); - } + + // DO NOT ADD CODE after this, as `this` might be deleted if an early + // RenderFrameHost swap was performed when starting the navigation above. + } } void RenderFrameHostImpl::PropagateEmbeddingTokenToParentFrame() { diff --git a/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py b/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py index 037f9497dc..be393d21f9 100755 --- a/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py +++ b/src/3rdparty/chromium/content/browser/tracing/generate_trace_viewer_grd.py @@ -74,7 +74,7 @@ def main(argv): for filename in parsed_args.source_files: add_file_to_grd(doc, os.path.basename(filename)) - with open(parsed_args.output_filename, 'w') as output_file: + with open(parsed_args.output_filename, 'wb') as output_file: output_file.write(doc.toxml(encoding='UTF-8')) diff --git a/src/3rdparty/chromium/content/browser/web_contents/web_contents_impl.cc b/src/3rdparty/chromium/content/browser/web_contents/web_contents_impl.cc index 0627170ed0..23d4268a1b 100644 --- a/src/3rdparty/chromium/content/browser/web_contents/web_contents_impl.cc +++ b/src/3rdparty/chromium/content/browser/web_contents/web_contents_impl.cc @@ -3278,7 +3278,12 @@ void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { } if (delegate_) { + // This may spin the message loop and destroy this object crbug.com/1506535 + base::WeakPtr weak_ptr = weak_factory_.GetWeakPtr(); delegate_->ExitFullscreenModeForTab(this); + if (!weak_ptr) { + return; + } if (keyboard_lock_widget_) delegate_->CancelKeyboardLockRequest(this); diff --git a/src/3rdparty/chromium/content/gpu/in_process_gpu_thread.cc b/src/3rdparty/chromium/content/gpu/in_process_gpu_thread.cc index efe399b0a7..210ee7d72b 100644 --- a/src/3rdparty/chromium/content/gpu/in_process_gpu_thread.cc +++ b/src/3rdparty/chromium/content/gpu/in_process_gpu_thread.cc @@ -24,6 +24,10 @@ #include "base/android/jni_android.h" #endif +#if defined(OS_WIN) +#include +#endif + namespace content { InProcessGpuThread::InProcessGpuThread( @@ -41,6 +45,10 @@ InProcessGpuThread::~InProcessGpuThread() { void InProcessGpuThread::Init() { base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; +#if defined(OS_WIN) + ImmDisableIME(0); +#endif + #if defined(OS_ANDROID) // Call AttachCurrentThreadWithName, before any other AttachCurrentThread() // calls. The latter causes Java VM to assign Thread-??? to the thread name. diff --git a/src/3rdparty/chromium/extensions/browser/api/web_request/form_data_parser.cc b/src/3rdparty/chromium/extensions/browser/api/web_request/form_data_parser.cc index 448b9aa5b6..123d4d7769 100644 --- a/src/3rdparty/chromium/extensions/browser/api/web_request/form_data_parser.cc +++ b/src/3rdparty/chromium/extensions/browser/api/web_request/form_data_parser.cc @@ -421,7 +421,7 @@ bool FormDataParserUrlEncoded::GetNextNameValue(Result* result) { bool FormDataParserUrlEncoded::SetSource(base::StringPiece source) { if (source_set_) return false; // We do not allow multiple sources for this parser. - source_.set(source.data(), source.size()); + source_ = re2::StringPiece(source.data(), source.size()); source_set_ = true; source_malformed_ = false; return true; @@ -565,7 +565,7 @@ bool FormDataParserMultipart::GetNextNameValue(Result* result) { bool FormDataParserMultipart::SetSource(base::StringPiece source) { if (source.data() == NULL || !source_.empty()) return false; - source_.set(source.data(), source.size()); + source_ = re2::StringPiece(source.data(), source.size()); switch (state_) { case STATE_INIT: diff --git a/src/3rdparty/chromium/gpu/config/gpu_control_list_format.txt b/src/3rdparty/chromium/gpu/config/gpu_control_list_format.txt index ab0f0a0336..e8baf93ba6 100644 --- a/src/3rdparty/chromium/gpu/config/gpu_control_list_format.txt +++ b/src/3rdparty/chromium/gpu/config/gpu_control_list_format.txt @@ -77,9 +77,10 @@ // 29. "intel_gpu_series" is a list of gpu series names. Currently supported // series include: "broadwater", "eaglelake", "ironlake", "sandybridge", // "baytrail", "ivybridge", "haswell", "cherrytrail", "broadwell", -// "apollolake", "skylake", "geminilake", "kabylake", "coffeelake", -// "whiskeylake", "cometlake", "cannonlake", "icelake", "elkhartlake", -// "jasperlake", "tigerlake". +// "apollolake", "skylake", "geminilake", "kabylake", "amberlake", +// "coffeelake", "whiskeylake", "cometlake", "cannonlake", "icelake", +// "elkhartlake", "jasperlake", "tigerlake", "rocketlake", "DG1", +// "alderlake", "alchemist", "raptorlake", "meteorlake". // 30. "hardware_overlay" is either "supported" or "unsupported". Currently it // only applies on Windows where hardware overlays may be supported on // certain Intel GPUs. By default it's "dont_care" and there is no need to diff --git a/src/3rdparty/chromium/gpu/config/gpu_driver_bug_workarounds.h b/src/3rdparty/chromium/gpu/config/gpu_driver_bug_workarounds.h index 1d9d56670f..8be31b1fd0 100644 --- a/src/3rdparty/chromium/gpu/config/gpu_driver_bug_workarounds.h +++ b/src/3rdparty/chromium/gpu/config/gpu_driver_bug_workarounds.h @@ -5,6 +5,7 @@ #ifndef GPU_CONFIG_GPU_DRIVER_BUG_WORKAROUNDS_H_ #define GPU_CONFIG_GPU_DRIVER_BUG_WORKAROUNDS_H_ +#include #include #include "base/macros.h" diff --git a/src/3rdparty/chromium/gpu/config/gpu_info.h b/src/3rdparty/chromium/gpu/config/gpu_info.h index 1589fee915..c400448cb9 100644 --- a/src/3rdparty/chromium/gpu/config/gpu_info.h +++ b/src/3rdparty/chromium/gpu/config/gpu_info.h @@ -58,6 +58,7 @@ enum class IntelGpuSeriesType { kSkylake = 8, kGeminilake = 9, kKabylake = 10, + kAmberlake = 23, kCoffeelake = 11, kWhiskeylake = 12, kCometlake = 13, @@ -69,8 +70,14 @@ enum class IntelGpuSeriesType { kJasperlake = 20, // Intel 12th gen kTigerlake = 21, + kRocketlake = 24, + kDG1 = 25, + kAlderlake = 22, + kAlchemist = 26, + kRaptorlake = 27, + kMeteorlake = 28, // Please also update |gpu_series_map| in process_json.py. - kMaxValue = kTigerlake, + kMaxValue = kMeteorlake, }; // Video profile. This *must* match media::VideoCodecProfile. diff --git a/src/3rdparty/chromium/gpu/config/gpu_util.cc b/src/3rdparty/chromium/gpu/config/gpu_util.cc index 105f489515..b115b4bd5c 100644 --- a/src/3rdparty/chromium/gpu/config/gpu_util.cc +++ b/src/3rdparty/chromium/gpu/config/gpu_util.cc @@ -872,6 +872,8 @@ IntelGpuSeriesType GetIntelGpuSeriesType(uint32_t vendor_id, case 0x3100: return IntelGpuSeriesType::kGeminilake; case 0x5900: + if (device_id == 0x591C) + return IntelGpuSeriesType::kAmberlake; return IntelGpuSeriesType::kKabylake; case 0x8700: if (device_id == 0x87C0) @@ -894,6 +896,19 @@ IntelGpuSeriesType GetIntelGpuSeriesType(uint32_t vendor_id, return IntelGpuSeriesType::kJasperlake; case 0x9A00: return IntelGpuSeriesType::kTigerlake; + case 0x4c00: + return IntelGpuSeriesType::kRocketlake; + case 0x4900: + return IntelGpuSeriesType::kDG1; + case 0x4600: + return IntelGpuSeriesType::kAlderlake; + case 0x4F00: + case 0x5600: + return IntelGpuSeriesType::kAlchemist; + case 0xa700: + return IntelGpuSeriesType::kRaptorlake; + case 0x7d00: + return IntelGpuSeriesType::kMeteorlake; default: break; } @@ -923,6 +938,7 @@ std::string GetIntelGpuGeneration(uint32_t vendor_id, uint32_t device_id) { case IntelGpuSeriesType::kSkylake: case IntelGpuSeriesType::kGeminilake: case IntelGpuSeriesType::kKabylake: + case IntelGpuSeriesType::kAmberlake: case IntelGpuSeriesType::kCoffeelake: case IntelGpuSeriesType::kWhiskeylake: case IntelGpuSeriesType::kCometlake: @@ -934,6 +950,12 @@ std::string GetIntelGpuGeneration(uint32_t vendor_id, uint32_t device_id) { case IntelGpuSeriesType::kJasperlake: return "11"; case IntelGpuSeriesType::kTigerlake: + case IntelGpuSeriesType::kRocketlake: + case IntelGpuSeriesType::kDG1: + case IntelGpuSeriesType::kAlderlake: + case IntelGpuSeriesType::kAlchemist: + case IntelGpuSeriesType::kRaptorlake: + case IntelGpuSeriesType::kMeteorlake: return "12"; default: break; diff --git a/src/3rdparty/chromium/gpu/config/process_json.py b/src/3rdparty/chromium/gpu/config/process_json.py index 6a609fe932..392f98633d 100755 --- a/src/3rdparty/chromium/gpu/config/process_json.py +++ b/src/3rdparty/chromium/gpu/config/process_json.py @@ -678,6 +678,7 @@ def write_intel_gpu_series_list(entry_id, is_exception, exception_id, 'apollolake': 'kApollolake', 'skylake': 'kSkylake', 'geminilake': 'kGeminilake', + 'amberlake': 'kAmberlake', 'kabylake': 'kKabylake', 'coffeelake': 'kCoffeelake', 'whiskeylake': 'kWhiskeylake', @@ -686,7 +687,13 @@ def write_intel_gpu_series_list(entry_id, is_exception, exception_id, 'icelake': 'kIcelake', 'elkhartlake': 'kElkhartlake', 'jasperlake': 'kJasperlake', - 'tigerlake': 'kTigerlake' + 'tigerlake': 'kTigerlake', + 'rocketlake': 'kRocketlake', + 'dg1': 'kDG1', + 'alderlake': 'kAlderlake', + 'alchemist': 'kAlchemist', + 'raptorlake': 'kRaptorlake', + 'meteorlake': 'kMeteorlake' } for series in intel_gpu_series_list: assert series in intel_gpu_series_map diff --git a/src/3rdparty/chromium/ipc/ipc_mojo_bootstrap.cc b/src/3rdparty/chromium/ipc/ipc_mojo_bootstrap.cc index 616382cb8f..9a9eeef847 100644 --- a/src/3rdparty/chromium/ipc/ipc_mojo_bootstrap.cc +++ b/src/3rdparty/chromium/ipc/ipc_mojo_bootstrap.cc @@ -702,13 +702,12 @@ class ChannelAssociatedGroupController // handle. DCHECK(!endpoint->client()); DCHECK(endpoint->peer_closed()); - MarkClosedAndMaybeRemove(endpoint); + MarkClosed(endpoint); } else { - MarkPeerClosedAndMaybeRemove(endpoint); + MarkPeerClosed(endpoint); } } - - DCHECK(endpoints_.empty()); + endpoints_.clear(); GetMemoryDumpProvider().RemoveController(this); } @@ -755,15 +754,19 @@ class ChannelAssociatedGroupController base::AutoLock locker(lock_); encountered_error_ = true; + std::vector endpoints_to_remove; std::vector> endpoints_to_notify; for (auto iter = endpoints_.begin(); iter != endpoints_.end();) { Endpoint* endpoint = iter->second.get(); ++iter; - if (endpoint->client()) + if (endpoint->client()) { endpoints_to_notify.push_back(endpoint); + } - MarkPeerClosedAndMaybeRemove(endpoint); + if (MarkPeerClosed(endpoint)) { + endpoints_to_remove.push_back(endpoint->id()); + } } for (auto& endpoint : endpoints_to_notify) { @@ -772,6 +775,10 @@ class ChannelAssociatedGroupController if (endpoint->client()) NotifyEndpointOfError(endpoint.get(), false /* force_async */); } + + for (uint32_t id : endpoints_to_remove) { + endpoints_.erase(id); + } } void NotifyEndpointOfError(Endpoint* endpoint, bool force_async) { @@ -806,19 +813,33 @@ class ChannelAssociatedGroupController NotifyEndpointOfError(endpoint, false /* force_async */); } - void MarkClosedAndMaybeRemove(Endpoint* endpoint) { + // Marks `endpoint` as closed and returns true if and only if its peer was + // also already closed. + bool MarkClosed(Endpoint* endpoint) { lock_.AssertAcquired(); endpoint->set_closed(); - if (endpoint->closed() && endpoint->peer_closed()) - endpoints_.erase(endpoint->id()); + return endpoint->peer_closed(); } - void MarkPeerClosedAndMaybeRemove(Endpoint* endpoint) { + // Marks `endpoint` as having a closed peer and returns true if and only if + // `endpoint` itself was also already closed. + bool MarkPeerClosed(Endpoint* endpoint) { lock_.AssertAcquired(); endpoint->set_peer_closed(); endpoint->SignalSyncMessageEvent(); - if (endpoint->closed() && endpoint->peer_closed()) + return endpoint->closed(); + } + + void MarkClosedAndMaybeRemove(Endpoint* endpoint) { + if (MarkClosed(endpoint)) { endpoints_.erase(endpoint->id()); + } + } + + void MarkPeerClosedAndMaybeRemove(Endpoint* endpoint) { + if (MarkPeerClosed(endpoint)) { + endpoints_.erase(endpoint->id()); + } } Endpoint* FindOrInsertEndpoint(mojo::InterfaceId id, bool* inserted) { diff --git a/src/3rdparty/chromium/media/formats/mp2t/ts_section_cets_pssh.cc b/src/3rdparty/chromium/media/formats/mp2t/ts_section_cets_pssh.cc index 976d4b5389..3d30eb7741 100644 --- a/src/3rdparty/chromium/media/formats/mp2t/ts_section_cets_pssh.cc +++ b/src/3rdparty/chromium/media/formats/mp2t/ts_section_cets_pssh.cc @@ -32,6 +32,11 @@ bool TsSectionCetsPssh::Parse(bool payload_unit_start_indicator, RCHECK(bit_reader.SkipBits(31)); int box_length_bits = bit_reader.bits_available(); std::string pssh; + if (!box_length_bits) { + // Ignore if there are no bits to read. + return false; + } + RCHECK(box_length_bits % 8 == 0); RCHECK(bit_reader.ReadString(box_length_bits, &pssh)); // Now check that the first 4 bytes are of the form {0x00, 0x00, 0x00, X}, // where X is the box length in bytes. diff --git a/src/3rdparty/chromium/mojo/core/channel_posix.cc b/src/3rdparty/chromium/mojo/core/channel_posix.cc index d7d9d6cfee..0e8b3884da 100644 --- a/src/3rdparty/chromium/mojo/core/channel_posix.cc +++ b/src/3rdparty/chromium/mojo/core/channel_posix.cc @@ -242,18 +242,23 @@ class ChannelPosix : public Channel, void ShutDownOnIOThread() { base::CurrentThread::Get()->RemoveDestructionObserver(this); - read_watcher_.reset(); - write_watcher_.reset(); - if (leak_handle_) { - ignore_result(socket_.release()); - server_.TakePlatformHandle().release(); - } else { - socket_.reset(); - ignore_result(server_.TakePlatformHandle()); + { + base::AutoLock lock(write_lock_); + reject_writes_ = true; + read_watcher_.reset(); + write_watcher_.reset(); + if (leak_handle_) { + std::ignore = socket_.release(); + server_.TakePlatformHandle().release(); + } else { + socket_.reset(); + std::ignore = server_.TakePlatformHandle(); + } + #if defined(OS_IOS) + base::AutoLock fd_lock(fds_to_close_lock_); + fds_to_close_.clear(); + #endif } -#if defined(OS_IOS) - fds_to_close_.clear(); -#endif // May destroy the |this| if it was the last reference. self_ = nullptr; diff --git a/src/3rdparty/chromium/mojo/public/cpp/bindings/lib/message.cc b/src/3rdparty/chromium/mojo/public/cpp/bindings/lib/message.cc index 8c48994760..ba0b148adb 100644 --- a/src/3rdparty/chromium/mojo/public/cpp/bindings/lib/message.cc +++ b/src/3rdparty/chromium/mojo/public/cpp/bindings/lib/message.cc @@ -270,7 +270,7 @@ Message::Message(base::span payload, void* buffer; uint32_t buffer_size; - DCHECK(base::IsValueInRangeForNumericType(payload.size())); + CHECK(base::IsValueInRangeForNumericType(payload.size())); DCHECK(base::IsValueInRangeForNumericType(handles.size())); MojoAppendMessageDataOptions options; options.struct_size = sizeof(options); diff --git a/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn b/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn index fc04b5dd0b..708958e438 100644 --- a/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn +++ b/src/3rdparty/chromium/mojo/public/tools/bindings/BUILD.gn @@ -2,9 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/python.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//third_party/jinja2/jinja2.gni") +# TODO(crbug.com/1194274): Investigate nondeterminism in Py3 builds. action("precompile_templates") { sources = mojom_generator_sources sources += [ diff --git a/src/3rdparty/chromium/mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py b/src/3rdparty/chromium/mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py index be8985cedc..e42ee0edf6 100755 --- a/src/3rdparty/chromium/mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py +++ b/src/3rdparty/chromium/mojo/public/tools/bindings/concatenate_and_replace_closure_exports.py @@ -31,7 +31,7 @@ def FilterLine(filename, line, output): return if line.startswith("goog.provide"): - match = re.match("goog.provide\('([^']+)'\);", line) + match = re.match(r"goog.provide\('([^']+)'\);", line) if not match: print("Invalid goog.provide line in %s:\n%s" % (filename, line)) exit(1) diff --git a/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py b/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py index 79c9e50efc..8b78d09241 100644 --- a/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py +++ b/src/3rdparty/chromium/mojo/public/tools/bindings/gen_data_files_list.py @@ -18,7 +18,6 @@ import re import sys -from cStringIO import StringIO from optparse import OptionParser sys.path.insert( @@ -41,12 +40,9 @@ def main(): pattern = re.compile(options.pattern) files = [f for f in os.listdir(options.directory) if pattern.match(f)] - stream = StringIO() - for f in files: - print(f, file=stream) + contents = '\n'.join(f for f in files) + '\n' + WriteFile(contents, options.output) - WriteFile(stream.getvalue(), options.output) - stream.close() if __name__ == '__main__': sys.exit(main()) diff --git a/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py b/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py index 96b2fdfae0..00b9dccd00 100644 --- a/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py +++ b/src/3rdparty/chromium/mojo/public/tools/bindings/generators/mojom_java_generator.py @@ -25,6 +25,10 @@ 'build', 'android', 'gyp')) from util import build_utils +# TODO(crbug.com/1174969): Remove this once Python2 is obsoleted. +if sys.version_info.major != 2: + basestring = str + long = int GENERATOR_PREFIX = 'java' diff --git a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py index de62260a5c..4a1c73fcf8 100644 --- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py +++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/generator.py @@ -136,9 +136,14 @@ def StylizeModule(self, mojom_namespace): def WriteFile(contents, full_path): # If |contents| is same with the file content, we skip updating. + if not isinstance(contents, bytes): + data = contents.encode('utf8') + else: + data = contents + if os.path.isfile(full_path): with open(full_path, 'rb') as destination_file: - if destination_file.read() == contents: + if destination_file.read() == data: return # Make sure the containing directory exists. @@ -146,11 +151,8 @@ def WriteFile(contents, full_path): fileutil.EnsureDirectoryExists(full_dir) # Dump the data to disk. - with open(full_path, "wb") as f: - if not isinstance(contents, bytes): - f.write(contents.encode('utf-8')) - else: - f.write(contents) + with open(full_path, 'wb') as f: + f.write(data) def AddComputedData(module): diff --git a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py index ebbc9b322e..3d026429bb 100644 --- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py +++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/module.py @@ -398,7 +398,8 @@ def __hash__(self): class StructField(Field): - pass + def __hash__(self): + return super(Field, self).__hash__() class UnionField(Field): diff --git a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py index 7a30056024..8d9e26fb7f 100644 --- a/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py +++ b/src/3rdparty/chromium/mojo/public/tools/mojom/mojom/generate/template_expander.py @@ -75,9 +75,9 @@ def PrecompileTemplates(generator_modules, output_dir): os.path.dirname(module.__file__), generator.GetTemplatePrefix()) ])) jinja_env.filters.update(generator.GetFilters()) - jinja_env.compile_templates( - os.path.join(output_dir, "%s.zip" % generator.GetTemplatePrefix()), - extensions=["tmpl"], - zip="stored", - py_compile=True, - ignore_errors=False) + jinja_env.compile_templates(os.path.join( + output_dir, "%s.zip" % generator.GetTemplatePrefix()), + extensions=["tmpl"], + zip="stored", + py_compile=sys.version_info.major < 3, + ignore_errors=False) diff --git a/src/3rdparty/chromium/net/quic/quic_chromium_client_stream.cc b/src/3rdparty/chromium/net/quic/quic_chromium_client_stream.cc index cd5e352381..e50e91042c 100644 --- a/src/3rdparty/chromium/net/quic/quic_chromium_client_stream.cc +++ b/src/3rdparty/chromium/net/quic/quic_chromium_client_stream.cc @@ -172,6 +172,10 @@ int QuicChromiumClientStream::Handle::ReadBody( if (!stream_) return net_error_; + if (stream_->read_side_closed()) { + return OK; + } + int rv = stream_->Read(buffer, buffer_len); if (rv != ERR_IO_PENDING) return rv; diff --git a/src/3rdparty/chromium/net/third_party/quiche/src/quic/core/quic_stream.h b/src/3rdparty/chromium/net/third_party/quiche/src/quic/core/quic_stream.h index f0a5a714a2..ca9e56911f 100644 --- a/src/3rdparty/chromium/net/third_party/quiche/src/quic/core/quic_stream.h +++ b/src/3rdparty/chromium/net/third_party/quiche/src/quic/core/quic_stream.h @@ -206,6 +206,7 @@ class QUIC_EXPORT_PRIVATE QuicStream return sequencer_.ignore_read_data() || read_side_closed_; } bool write_side_closed() const { return write_side_closed_; } + bool read_side_closed() const { return read_side_closed_; } bool IsZombie() const { return read_side_closed_ && write_side_closed_ && IsWaitingForAcks(); diff --git a/src/3rdparty/chromium/sandbox/policy/mac/package_sb_file.py b/src/3rdparty/chromium/sandbox/policy/mac/package_sb_file.py index 934fd2261b..152c386002 100755 --- a/src/3rdparty/chromium/sandbox/policy/mac/package_sb_file.py +++ b/src/3rdparty/chromium/sandbox/policy/mac/package_sb_file.py @@ -3,6 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function import os import sys @@ -28,7 +29,7 @@ def escape_for_c(line): def pack_file(argv): if len(argv) != 2: - print >> sys.stderr, 'usage: package_sb_file.py input_filename output_dir' + print('usage: package_sb_file.py input_filename output_dir', file=sys.stderr) return 1 input_filename = argv[0] output_directory = argv[1] @@ -37,14 +38,14 @@ def pack_file(argv): output_h_file = output_directory + '/' + input_basename + '.h' output_cc_file = output_directory + '/' + input_basename + '.cc' try: - with open(input_filename, 'rb') as infile: - with open(output_h_file, 'wb') as outfile: + with open(input_filename, 'r') as infile: + with open(output_h_file, 'w') as outfile: outfile.write(header) outfile.write(h_include) outfile.write(namespace) outfile.write(h_definition % module_name) outfile.write(namespace_end) - with open(output_cc_file, 'wb') as outfile: + with open(output_cc_file, 'w') as outfile: outfile.write(header) outfile.write(cc_include % module_name) outfile.write(namespace) @@ -56,7 +57,7 @@ def pack_file(argv): outfile.write(cc_definition_end) outfile.write(namespace_end) except IOError: - print >> sys.stderr, 'Failed to process %s' % input_filename + print('Failed to process %s' % input_filename, file = sys.stderr) return 1 return 0 diff --git a/src/3rdparty/chromium/services/device/usb/mojo/device_impl.cc b/src/3rdparty/chromium/services/device/usb/mojo/device_impl.cc index bc70814864..4c6affe583 100644 --- a/src/3rdparty/chromium/services/device/usb/mojo/device_impl.cc +++ b/src/3rdparty/chromium/services/device/usb/mojo/device_impl.cc @@ -16,6 +16,7 @@ #include "base/callback.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted_memory.h" +#include "base/optional.h" #include "base/stl_util.h" #include "services/device/public/cpp/usb/usb_utils.h" #include "services/device/usb/usb_descriptors.h" @@ -84,6 +85,20 @@ void OnIsochronousTransferOut( std::move(callback).Run(std::move(packets)); } +// Returns the sum of `packet_lengths`, or nullopt if the sum would overflow. +base::Optional TotalPacketLength( + base::span packet_lengths) { + uint32_t total_bytes = 0; + for (const uint32_t packet_length : packet_lengths) { + // Check for overflow. + if (std::numeric_limits::max() - total_bytes < packet_length) { + return base::nullopt; + } + total_bytes += packet_length; + } + return total_bytes; +} + } // namespace // static @@ -368,6 +383,15 @@ void DeviceImpl::IsochronousTransferIn( return; } + base::Optional total_bytes = TotalPacketLength(packet_lengths); + if (!total_bytes.has_value()) { + mojo::ReportBadMessage("Invalid isochronous packet lengths."); + std::move(callback).Run( + {}, BuildIsochronousPacketArray( + packet_lengths, mojom::UsbTransferStatus::TRANSFER_ERROR)); + return; + } + uint8_t endpoint_address = endpoint_number | 0x80; device_handle_->IsochronousTransferIn( endpoint_address, packet_lengths, timeout, @@ -386,6 +410,14 @@ void DeviceImpl::IsochronousTransferOut( return; } + base::Optional total_bytes = TotalPacketLength(packet_lengths); + if (!total_bytes.has_value() || total_bytes.value() != data.size()) { + mojo::ReportBadMessage("Invalid isochronous packet lengths."); + std::move(callback).Run(BuildIsochronousPacketArray( + packet_lengths, mojom::UsbTransferStatus::TRANSFER_ERROR)); + return; + } + uint8_t endpoint_address = endpoint_number; auto buffer = base::MakeRefCounted(data); device_handle_->IsochronousTransferOut( diff --git a/src/3rdparty/chromium/services/network/network_context.cc b/src/3rdparty/chromium/services/network/network_context.cc index 795b2d5d7d..035ee94c9b 100644 --- a/src/3rdparty/chromium/services/network/network_context.cc +++ b/src/3rdparty/chromium/services/network/network_context.cc @@ -477,6 +477,8 @@ NetworkContext::NetworkContext( } NetworkContext::~NetworkContext() { + is_destructing_ = true; + // May be nullptr in tests. if (network_service_) network_service_->DeregisterNetworkContext(this); @@ -518,6 +520,12 @@ NetworkContext::~NetworkContext() { } #endif // BUILDFLAG(IS_CT_SUPPORTED) } + + // Clear `url_loader_factories_` before deleting the contents, as it can + // result in re-entrant calls to DestroyURLLoaderFactory(). + std::set, + base::UniquePtrComparator> + url_loader_factories = std::move(url_loader_factories_); } // static @@ -641,6 +649,9 @@ void NetworkContext::DisableQuic() { void NetworkContext::DestroyURLLoaderFactory( cors::CorsURLLoaderFactory* url_loader_factory) { + if (is_destructing_) { + return; + } const int32_t process_id = url_loader_factory->process_id(); auto it = url_loader_factories_.find(url_loader_factory); diff --git a/src/3rdparty/chromium/services/network/network_context.h b/src/3rdparty/chromium/services/network/network_context.h index a9c3c62457..7d006d4864 100644 --- a/src/3rdparty/chromium/services/network/network_context.h +++ b/src/3rdparty/chromium/services/network/network_context.h @@ -726,15 +726,14 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext // HttpAuthHandle via |NetworkContext::CreateHttpAuthHandlerFactory|. net::HttpAuthPreferences http_auth_merged_preferences_; + // True once the destructor has been called. Used to guard against re-entrant + // calls to DestroyURLLoaderFactory(). + bool is_destructing_ = false; + // CorsURLLoaderFactory assumes that fields owned by the NetworkContext always // live longer than the factory. Therefore we want the factories to be - // destroyed before other fields above. In particular: - // - This must be below |url_request_context_| so that the URLRequestContext - // outlives all the URLLoaderFactories and URLLoaders that depend on it; - // for the same reason, it must also be below |network_context_|. - // - This must be below |loader_count_per_process_| that is touched by - // CorsURLLoaderFactory::DestroyURLLoader (see also - // https://crbug.com/1174943). + // destroyed before other fields above. This is accomplished by explicitly + // clearing `url_loader_factories_` in the destructor. std::set, base::UniquePtrComparator> url_loader_factories_; diff --git a/src/3rdparty/chromium/services/network/public/cpp/source_stream_to_data_pipe.cc b/src/3rdparty/chromium/services/network/public/cpp/source_stream_to_data_pipe.cc index d6ade7b0ec..615804ad8d 100644 --- a/src/3rdparty/chromium/services/network/public/cpp/source_stream_to_data_pipe.cc +++ b/src/3rdparty/chromium/services/network/public/cpp/source_stream_to_data_pipe.cc @@ -53,9 +53,9 @@ void SourceStreamToDataPipe::ReadMore() { scoped_refptr buffer( new network::NetToMojoIOBuffer(pending_write_.get())); - int result = source_->Read( - buffer.get(), base::checked_cast(num_bytes), - base::BindOnce(&SourceStreamToDataPipe::DidRead, base::Unretained(this))); + int result = source_->Read(buffer.get(), base::checked_cast(num_bytes), + base::BindOnce(&SourceStreamToDataPipe::DidRead, + weak_factory_.GetWeakPtr())); if (result != net::ERR_IO_PENDING) DidRead(result); diff --git a/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.cc b/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.cc index e8b9ff4983..d79b97fd37 100644 --- a/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.cc +++ b/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.cc @@ -164,13 +164,13 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { } // The transfer buffer is used to serialize Dawn commands - transfer_buffer_ = + auto transfer_buffer = std::make_unique(webgpu_helper.get()); // The WebGPUImplementation exposes the WebGPUInterface, as well as the // gpu::ContextSupport interface. auto webgpu_impl = std::make_unique( - webgpu_helper.get(), transfer_buffer_.get(), command_buffer_.get()); + webgpu_helper.get(), transfer_buffer.get(), command_buffer_.get()); bind_result_ = webgpu_impl->Initialize(memory_limits_); if (bind_result_ != gpu::ContextResult::kSuccess) { DLOG(ERROR) << "Failed to initialize WebGPUImplementation."; @@ -182,8 +182,11 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { std::string unique_context_name = base::StringPrintf("%s-%p", type_name.c_str(), webgpu_impl.get()); + // IMPORTANT: These hold raw_ptrs to each other, so must be set together. + // See note in the header (and keep it up to date if things change). impl_ = webgpu_impl.get(); webgpu_interface_ = std::move(webgpu_impl); + transfer_buffer_ = std::move(transfer_buffer); helper_ = std::move(webgpu_helper); } else if (attributes_.enable_raster_interface && !attributes_.enable_gles2_interface && @@ -201,14 +204,14 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { } // The transfer buffer is used to copy resources between the client // process and the GPU process. - transfer_buffer_ = + auto transfer_buffer = std::make_unique(raster_helper.get()); // The RasterImplementation exposes the RasterInterface, as well as the // gpu::ContextSupport interface. DCHECK(channel_); auto raster_impl = std::make_unique( - raster_helper.get(), transfer_buffer_.get(), + raster_helper.get(), transfer_buffer.get(), attributes_.bind_generates_resource, attributes_.lose_context_when_out_of_memory, command_buffer_.get(), channel_->image_decode_accelerator_proxy()); @@ -225,8 +228,11 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { raster_impl->TraceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); + // IMPORTANT: These hold raw_ptrs to each other, so must be set together. + // See note in the header (and keep it up to date if things change). impl_ = raster_impl.get(); raster_interface_ = std::move(raster_impl); + transfer_buffer_ = std::move(transfer_buffer); helper_ = std::move(raster_helper); } else { // The GLES2 helper writes the command buffer protocol. @@ -241,7 +247,7 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { // The transfer buffer is used to copy resources between the client // process and the GPU process. - transfer_buffer_ = + auto transfer_buffer = std::make_unique(gles2_helper.get()); // The GLES2Implementation exposes the OpenGLES2 API, as well as the @@ -254,13 +260,13 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { // we only use it if grcontext_support was requested. gles2_impl = std::make_unique< skia_bindings::GLES2ImplementationWithGrContextSupport>( - gles2_helper.get(), /*share_group=*/nullptr, transfer_buffer_.get(), + gles2_helper.get(), /*share_group=*/nullptr, transfer_buffer.get(), attributes_.bind_generates_resource, attributes_.lose_context_when_out_of_memory, support_client_side_arrays, command_buffer_.get()); } else { gles2_impl = std::make_unique( - gles2_helper.get(), /*share_group=*/nullptr, transfer_buffer_.get(), + gles2_helper.get(), /*share_group=*/nullptr, transfer_buffer.get(), attributes_.bind_generates_resource, attributes_.lose_context_when_out_of_memory, support_client_side_arrays, command_buffer_.get()); @@ -271,8 +277,11 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { return bind_result_; } + // IMPORTANT: These hold raw_ptrs to each other, so must be set together. + // See note in the header (and keep it up to date if things change). impl_ = gles2_impl.get(); gles2_impl_ = std::move(gles2_impl); + transfer_buffer_ = std::move(transfer_buffer); helper_ = std::move(gles2_helper); } @@ -306,6 +315,7 @@ gpu::ContextResult ContextProviderCommandBuffer::BindToCurrentThread() { switches::kEnableGpuClientTracing)) { // This wraps the real GLES2Implementation and we should always use this // instead when it's present. + // IMPORTANT: This holds a raw_ptr to gles2_impl_. trace_impl_ = std::make_unique( gles2_impl_.get()); gl = trace_impl_.get(); diff --git a/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.h b/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.h index 22d80baf76..0ac70dae7e 100644 --- a/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.h +++ b/src/3rdparty/chromium/services/viz/public/cpp/gpu/context_provider_command_buffer.h @@ -156,18 +156,44 @@ class ContextProviderCommandBuffer // associated shared images are destroyed. std::unique_ptr shared_image_interface_; - base::Lock context_lock_; // Referenced by command_buffer_. + ////////////////////////////////////////////////////////////////////////////// + // IMPORTANT NOTE: All of the objects in this block are part of a complex // + // graph of raw pointers (holder or pointee of various raw_ptrs). They are // + // defined in topological order: only later items point to earlier items. // + // - When writing any member, always ensure its pointers to earlier members + // are guaranteed to stay alive. + // - When clearing OR overwriting any member, always ensure objects that + // point to it have already been cleared. + // - The topological order of definitions guarantees that the + // destructors will be called in the correct order (bottom to top). + // - When overwriting multiple members, similarly do so in reverse order. + // + // Please note these comments are likely not to stay perfectly up-to-date. + + base::Lock context_lock_; + // Points to the context_lock_ field of `this`. std::unique_ptr command_buffer_; + + // Points to command_buffer_. std::unique_ptr helper_; + // Points to helper_. std::unique_ptr transfer_buffer_; - // Owned by either gles2_impl_ or raster_interface_, not both. - gpu::ImplementationBase* impl_; + // Points to transfer_buffer_, helper_, and command_buffer_. std::unique_ptr gles2_impl_; + // Points to gles2_impl_. std::unique_ptr trace_impl_; - std::unique_ptr raster_interface_; + // Points to transfer_buffer_, helper_, and command_buffer_. + std::unique_ptr raster_interface_; + // Points to transfer_buffer_, helper_, and command_buffer_. std::unique_ptr webgpu_interface_; + // END IMPORTANT NOTE // + ////////////////////////////////////////////////////////////////////////////// + + // Owned by either gles2_impl_ or raster_interface_, not both. + gpu::ImplementationBase* impl_ = nullptr; + std::unique_ptr gr_context_; #if BUILDFLAG(SKIA_USE_DAWN) std::unique_ptr diff --git a/src/3rdparty/chromium/third_party/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp b/src/3rdparty/chromium/third_party/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp index 1950375b9b..a098da4bfd 100644 --- a/src/3rdparty/chromium/third_party/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp +++ b/src/3rdparty/chromium/third_party/angle/src/libANGLE/renderer/vulkan/TextureVk.cpp @@ -466,8 +466,28 @@ angle::Result TextureVk::copyImage(const gl::Context *context, gl::GetInternalFormatInfo(internalFormat, GL_UNSIGNED_BYTE); const vk::Format &vkFormat = renderer->getFormat(internalFormatInfo.sizedInternalFormat); + // The texture level being redefined might be the same as the one bound to the framebuffer. + // This _could_ be supported by using a temp image before redefining the level (and potentially + // discarding the image). However, this is currently unimplemented. + FramebufferVk *framebufferVk = vk::GetImpl(source); + RenderTargetVk *colorReadRT = framebufferVk->getColorReadRenderTarget(); + vk::ImageHelper *srcImage = &colorReadRT->getImageForCopy(); + const bool isCubeMap = index.getType() == gl::TextureType::CubeMap; + gl::LevelIndex levelIndex(getNativeImageIndex(index).getLevelIndex()); + const uint32_t layerIndex = index.hasLayer() ? index.getLayerIndex() : 0; + const uint32_t redefinedFace = isCubeMap ? layerIndex : 0; + const uint32_t sourceFace = isCubeMap ? colorReadRT->getLayerIndex() : 0; + const bool isSelfCopy = mImage == srcImage && levelIndex == colorReadRT->getLevelIndex() && + redefinedFace == sourceFace; + ANGLE_TRY(redefineLevel(context, index, vkFormat, newImageSize)); + if (isSelfCopy) + { + UNIMPLEMENTED(); + return angle::Result::Continue; + } + return copySubImageImpl(context, index, gl::Offset(0, 0, 0), sourceArea, internalFormatInfo, source); } @@ -1393,7 +1413,8 @@ angle::Result TextureVk::redefineLevel(const gl::Context *context, mImage->getLevelCount() == 1 && mImage->getBaseLevel() == levelIndexGL; // If incompatible, and redefining the single-level image, release it so it can be - // recreated immediately. This is an optimization to avoid an extra copy. + // recreated immediately. This is needed so that the texture can be reallocated with + // the correct format/size. if (!isCompatibleRedefinition && isUpdateToSingleLevelImage) { releaseImage(contextVk); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py index 3225ecca6e..fc078d31b5 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/blink_v8_bridge.py @@ -344,7 +344,7 @@ def make_default_value_expr(idl_type, default_value): """ assert default_value.is_type_compatible_with(idl_type) - class DefaultValueExpr: + class DefaultValueExpr(object): _ALLOWED_SYMBOLS_IN_DEPS = ("isolate") def __init__(self, initializer_expr, initializer_deps, @@ -502,7 +502,7 @@ def make_v8_to_blink_value(blink_var_name, assert isinstance(blink_var_name, str) assert isinstance(v8_value_expr, str) assert isinstance(idl_type, web_idl.IdlType) - assert (argument_index is None or isinstance(argument_index, (int, long))) + assert (argument_index is None or isinstance(argument_index, int)) assert (default_value is None or isinstance(default_value, web_idl.LiteralConstant)) @@ -622,7 +622,7 @@ def make_v8_to_blink_value_variadic(blink_var_name, v8_array, """ assert isinstance(blink_var_name, str) assert isinstance(v8_array, str) - assert isinstance(v8_array_start_index, (int, long)) + assert isinstance(v8_array_start_index, int) assert isinstance(idl_type, web_idl.IdlType) pattern = ("auto&& ${{{_1}}} = " diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py index 4a6df51306..8b51f23a40 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/callback_interface.py @@ -177,7 +177,7 @@ def generate_callback_interface(callback_interface_identifier): prop_install_mode=PropInstallMode.UNCONDITIONAL, trampoline_var_name=None, attribute_entries=[], - constant_entries=filter(is_unconditional, constant_entries), + constant_entries=list(filter(is_unconditional, constant_entries)), exposed_construct_entries=[], operation_entries=[]) (install_interface_template_decl, install_interface_template_def, diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py index 52972fefe2..e5ae9d9629 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/code_node.py @@ -503,13 +503,13 @@ def __init__(self, template_format_str, *args, **kwargs): gensym_kwargs = {} template_vars = {} for arg in args: - assert isinstance(arg, (CodeNode, int, long, str)) + assert isinstance(arg, (CodeNode, int, str)) gensym = CodeNode.gensym() gensym_args.append("${{{}}}".format(gensym)) template_vars[gensym] = arg for key, value in kwargs.items(): - assert isinstance(key, (int, long, str)) - assert isinstance(value, (CodeNode, int, long, str)) + assert isinstance(key, (int, str)) + assert isinstance(value, (CodeNode, int, str)) gensym = CodeNode.gensym() gensym_kwargs[key] = "${{{}}}".format(gensym) template_vars[gensym] = value @@ -602,7 +602,7 @@ def extend(self, nodes): def insert(self, index, node): if node is None: return - assert isinstance(index, (int, long)) + assert isinstance(index, int) assert isinstance(node, CodeNode) assert node.outer is None and node.prev is None @@ -721,7 +721,7 @@ def analyze_symbol_usage(render_state): if not scope_chains: return counts - self_index = iter(scope_chains).next().index(self) + self_index = next(iter(scope_chains)).index(self) scope_chains = map( lambda scope_chain: scope_chain[self_index + 1:], scope_chains) scope_to_likeliness = {} diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py index a229a6c71c..5fa288dabf 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_expr.py @@ -109,7 +109,7 @@ def expr_and(terms): if any(term.is_always_false for term in terms): return _Expr(False) - terms = filter(lambda x: not x.is_always_true, terms) + terms = list(filter(lambda x: not x.is_always_true, terms)) if not terms: return _Expr(True) if len(terms) == 1: @@ -124,7 +124,7 @@ def expr_or(terms): if any(term.is_always_true for term in terms): return _Expr(True) - terms = filter(lambda x: not x.is_always_false, terms) + terms = list(filter(lambda x: not x.is_always_false, terms)) if not terms: return _Expr(False) if len(terms) == 1: @@ -222,7 +222,7 @@ def ref_selected(features): elif exposure.only_in_secure_contexts is False: secure_context_term = _Expr(True) else: - terms = map(ref_enabled, exposure.only_in_secure_contexts) + terms = list(map(ref_enabled, exposure.only_in_secure_contexts)) secure_context_term = expr_or( [_Expr("${is_in_secure_context}"), expr_not(expr_and(terms))]) @@ -275,10 +275,11 @@ def ref_selected(features): # [ContextEnabled] if exposure.context_enabled_features: - terms = map( - lambda feature: _Expr( - "${{context_feature_settings}}->is{}Enabled()".format( - feature)), exposure.context_enabled_features) + terms = list( + map( + lambda feature: _Expr( + "${{context_feature_settings}}->is{}Enabled()".format( + feature)), exposure.context_enabled_features)) context_enabled_terms.append( expr_and([_Expr("${context_feature_settings}"), expr_or(terms)])) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py index 87d26eec3c..f3e9d38247 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_format.py @@ -23,7 +23,7 @@ def __init__(self): self._template_formatter_indexing_count_ = 0 def get_value(self, key, args, kwargs): - if isinstance(key, (int, long)): + if isinstance(key, int): return args[key] assert isinstance(key, str) if not key: diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py index 2bcc4fed49..e72282aa69 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/codegen_utils.py @@ -116,4 +116,4 @@ def write_code_node_to_file(code_node, filepath): # stderr=format_result.error_message)) # # web_idl.file_io.write_to_file_if_changed(filepath, format_result.contents) - web_idl.file_io.write_to_file_if_changed(filepath, rendered_text) + web_idl.file_io.write_to_file_if_changed(filepath, rendered_text.encode('utf-8')) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py index b39f010041..4d68202296 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/dictionary.py @@ -993,7 +993,7 @@ def make_trace_member_node(member): _2 = _blink_member_name(member).value_var return TextNode(_format(pattern, _1=_1, _2=_2)) - body.extend(map(make_trace_member_node, own_members)) + body.extend(list(map(make_trace_member_node, own_members))) body.append(TextNode("BaseClass::Trace(visitor);")) return func_decl, func_def diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py index 10ff30656a..bfdf7128aa 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/interface.py @@ -582,7 +582,7 @@ def _make_blink_api_call(code_node, overriding_args=None): assert isinstance(code_node, SymbolScopeNode) assert isinstance(cg_context, CodeGenContext) - assert num_of_args is None or isinstance(num_of_args, (int, long)) + assert num_of_args is None or isinstance(num_of_args, int) assert (overriding_args is None or (isinstance(overriding_args, (list, tuple)) and all(isinstance(arg, str) for arg in overriding_args))) @@ -1196,8 +1196,10 @@ def make_overload_dispatcher(cg_context): did_use_break = did_use_break or can_fail conditional = expr_or( - map(lambda item: expr_from_exposure(item.function_like.exposure), - items)) + list( + map( + lambda item: expr_from_exposure(item.function_like.exposure + ), items))) if not conditional.is_always_true: node = CxxUnlikelyIfNode(cond=conditional, body=node) @@ -4642,7 +4644,7 @@ class _PropEntryConstructorGroup(_PropEntryBase): def __init__(self, is_context_dependent, exposure_conditional, world, constructor_group, ctor_callback_name, ctor_func_length): assert isinstance(ctor_callback_name, str) - assert isinstance(ctor_func_length, (int, long)) + assert isinstance(ctor_func_length, int) _PropEntryBase.__init__(self, is_context_dependent, exposure_conditional, world, constructor_group) @@ -4670,7 +4672,7 @@ def __init__(self, op_func_length, no_alloc_direct_callback_name=None): assert isinstance(op_callback_name, str) - assert isinstance(op_func_length, (int, long)) + assert isinstance(op_func_length, int) _PropEntryBase.__init__(self, is_context_dependent, exposure_conditional, world, operation_group) @@ -5175,9 +5177,9 @@ def make_install_interface_template(cg_context, function_name, class_name, api_c ]) if class_like.identifier == "CSSStyleDeclaration": - css_properties = filter( - lambda attr: "CSSProperty" in attr.extended_attributes, - class_like.attributes) + css_properties = list( + filter(lambda attr: "CSSProperty" in attr.extended_attributes, + class_like.attributes)) if css_properties: prop_name_list = "".join( map(lambda attr: "\"{}\", ".format(attr.identifier), @@ -5567,8 +5569,8 @@ def install_properties(table_name, target_entries, make_table_func, "V8DOMConfiguration::InstallConstants(${isolate}, " "${interface_template}, ${prototype_template}, " "kConstantCallbackTable, base::size(kConstantCallbackTable));") - constant_callback_entries = filter(lambda entry: entry.const_callback_name, - constant_entries) + constant_callback_entries = list(filter(lambda entry: entry.const_callback_name, + constant_entries)) install_properties(table_name, constant_callback_entries, _make_constant_callback_registration_table, installer_call_text) @@ -5584,8 +5586,8 @@ def install_properties(table_name, target_entries, make_table_func, "V8DOMConfiguration::InstallConstants(${isolate}, " "${interface_template}, ${prototype_template}, " "kConstantValueTable, base::size(kConstantValueTable));") - constant_value_entries = filter( - lambda entry: not entry.const_callback_name, constant_entries) + constant_value_entries = list(filter( + lambda entry: not entry.const_callback_name, constant_entries)) install_properties(table_name, constant_value_entries, _make_constant_value_registration_table, installer_call_text) @@ -6336,8 +6338,8 @@ def make_v8_context_snapshot_api(cg_context, component, attribute_entries, assert isinstance(component, web_idl.Component) derived_interfaces = cg_context.interface.deriveds - derived_names = map(lambda interface: interface.identifier, - derived_interfaces) + derived_names = list( + map(lambda interface: interface.identifier, derived_interfaces)) derived_names.append(cg_context.interface.identifier) if not ("Window" in derived_names or "HTMLDocument" in derived_names): return None, None @@ -6411,9 +6413,11 @@ def collect_callbacks(node): collect_callbacks(named_properties_object_callback_defs) collect_callbacks(cross_origin_property_callback_defs) - entry_nodes = map( - lambda name: TextNode("reinterpret_cast({}),".format(name)), - filter(None, callback_names)) + entry_nodes = list( + map( + lambda name: TextNode("reinterpret_cast({}),".format(name + )), + filter(None, callback_names))) table_node = ListNode([ TextNode("using namespace ${class_name}Callbacks;"), TextNode("static const intptr_t kReferenceTable[] = {"), @@ -6451,10 +6455,11 @@ def selector(entry): class_name=None, prop_install_mode=PropInstallMode.V8_CONTEXT_SNAPSHOT, trampoline_var_name=None, - attribute_entries=filter(selector, attribute_entries), - constant_entries=filter(selector, constant_entries), - exposed_construct_entries=filter(selector, exposed_construct_entries), - operation_entries=filter(selector, operation_entries)) + attribute_entries=list(filter(selector, attribute_entries)), + constant_entries=list(filter(selector, constant_entries)), + exposed_construct_entries=list( + filter(selector, exposed_construct_entries)), + operation_entries=list(filter(selector, operation_entries))) return func_decl, func_def @@ -6810,11 +6815,11 @@ def add_custom_callback_impl_decl(**params): class_name=impl_class_name, prop_install_mode=PropInstallMode.UNCONDITIONAL, trampoline_var_name=tp_install_unconditional_props, - attribute_entries=filter(is_unconditional, attribute_entries), - constant_entries=filter(is_unconditional, constant_entries), - exposed_construct_entries=filter(is_unconditional, - exposed_construct_entries), - operation_entries=filter(is_unconditional, operation_entries)) + attribute_entries=list(filter(is_unconditional, attribute_entries)), + constant_entries=list(filter(is_unconditional, constant_entries)), + exposed_construct_entries=list( + filter(is_unconditional, exposed_construct_entries)), + operation_entries=list(filter(is_unconditional, operation_entries))) (install_context_independent_props_decl, install_context_independent_props_def, install_context_independent_props_trampoline) = make_install_properties( @@ -6823,11 +6828,14 @@ def add_custom_callback_impl_decl(**params): class_name=impl_class_name, prop_install_mode=PropInstallMode.CONTEXT_INDEPENDENT, trampoline_var_name=tp_install_context_independent_props, - attribute_entries=filter(is_context_independent, attribute_entries), - constant_entries=filter(is_context_independent, constant_entries), - exposed_construct_entries=filter(is_context_independent, - exposed_construct_entries), - operation_entries=filter(is_context_independent, operation_entries)) + attribute_entries=list( + filter(is_context_independent, attribute_entries)), + constant_entries=list(filter(is_context_independent, + constant_entries)), + exposed_construct_entries=list( + filter(is_context_independent, exposed_construct_entries)), + operation_entries=list( + filter(is_context_independent, operation_entries))) (install_context_dependent_props_decl, install_context_dependent_props_def, install_context_dependent_props_trampoline) = make_install_properties( cg_context, @@ -6835,11 +6843,13 @@ def add_custom_callback_impl_decl(**params): class_name=impl_class_name, prop_install_mode=PropInstallMode.CONTEXT_DEPENDENT, trampoline_var_name=tp_install_context_dependent_props, - attribute_entries=filter(is_context_dependent, attribute_entries), - constant_entries=filter(is_context_dependent, constant_entries), - exposed_construct_entries=filter(is_context_dependent, - exposed_construct_entries), - operation_entries=filter(is_context_dependent, operation_entries)) + attribute_entries=list(filter(is_context_dependent, + attribute_entries)), + constant_entries=list(filter(is_context_dependent, constant_entries)), + exposed_construct_entries=list( + filter(is_context_dependent, exposed_construct_entries)), + operation_entries=list(filter(is_context_dependent, + operation_entries))) (install_interface_template_decl, install_interface_template_def, install_interface_template_trampoline) = make_install_interface_template( cg_context, diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py index b4c7055386..f3a2fcd772 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/mako_renderer.py @@ -105,7 +105,7 @@ def render(self, caller, template, template_vars): on_error = self._caller_stack_on_error if (len(current) <= len(on_error) and all(current[i] == on_error[i] - for i in xrange(len(current)))): + for i in range(len(current)))): pass # Error happened in a deeper caller. else: self._caller_stack_on_error = list(self._caller_stack) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py index dc3493cc39..017d3d47bb 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/style_format.py @@ -70,8 +70,13 @@ def gn_format(contents, filename=None): def _invoke_format_command(command_line, filename, contents): - proc = subprocess.Popen( - command_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + kwargs = {} + if sys.version_info.major != 2: + kwargs['encoding'] = 'utf-8' + proc = subprocess.Popen(command_line, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + **kwargs) stdout_output, stderr_output = proc.communicate(input=contents) exit_code = proc.wait() diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py index 0d8f4c0f30..e666a9b668 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/bind_gen/task_queue.py @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import functools import multiprocessing from .package_initializer import package_initializer @@ -76,7 +77,7 @@ def _report_worker_task_progress(self, report_progress): if not report_progress: return - done_count = reduce( + done_count = functools.reduce( lambda count, worker_task: count + bool(worker_task.ready()), self._worker_tasks, 0) report_progress(len(self._worker_tasks), done_count) @@ -85,4 +86,4 @@ def _report_worker_task_progress(self, report_progress): def _task_queue_run_tasks(tasks): for task in tasks: func, args, kwargs = task - apply(func, args, kwargs) + func(*args, **kwargs) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py index e8280be721..e49e6eb965 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/code_generator.py @@ -13,6 +13,7 @@ import sys from idl_types import set_ancestors, IdlType +from itertools import groupby from v8_globals import includes from v8_interface import constant_filters from v8_types import set_component_dirs @@ -43,6 +44,7 @@ # after path[0] == invoking script dir sys.path.insert(1, THIRD_PARTY_DIR) import jinja2 +from jinja2.filters import make_attrgetter, environmentfilter def generate_indented_conditional(code, conditional): @@ -88,6 +90,13 @@ def runtime_enabled_if(code, name): return generate_indented_conditional(code, function) +@environmentfilter +def do_stringify_key_group_by(environment, value, attribute): + expr = make_attrgetter(environment, attribute) + key = lambda item: '' if expr(item) is None else str(expr(item)) + return groupby(sorted(value, key=key), expr) + + def initialize_jinja_env(cache_dir): jinja_env = jinja2.Environment( loader=jinja2.FileSystemLoader(TEMPLATES_DIR), @@ -117,6 +126,7 @@ def initialize_jinja_env(cache_dir): }) jinja_env.filters.update(constant_filters()) jinja_env.filters.update(method_filters()) + jinja_env.filters["stringifykeygroupby"] = do_stringify_key_group_by return jinja_env diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py index 130004eae8..04c0fabcef 100755 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py @@ -80,7 +80,7 @@ def read_idl_file(reader, idl_filename): assert len(interfaces) == 1, ( "Expected one interface in file %r, found %d" % (idl_filename, len(interfaces))) - return (interfaces.values()[0], includes) + return (list(interfaces.values())[0], includes) def interface_is_global(interface): @@ -281,7 +281,7 @@ def main(): info_provider = create_component_info_provider( os.path.normpath(options.info_dir), options.target_component) - idl_filenames = map(str.strip, open(options.idl_files_list)) + idl_filenames = list(map(str.strip, open(options.idl_files_list))) generate_origin_trial_features(info_provider, options, idl_filenames) return 0 diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py index 14e6e9d3f8..b027818aef 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_definitions.py @@ -394,7 +394,8 @@ def is_invalid_attribute_type(idl_type): else: raise ValueError('Unrecognized node class: %s' % child_class) - if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1: + if len(list(filter(None, + [self.iterable, self.maplike, self.setlike]))) > 1: raise ValueError( 'Interface can only have one of iterable<>, maplike<> and setlike<>.' ) @@ -512,6 +513,9 @@ def __init__(self, node=None): def accept(self, visitor): visitor.visit_attribute(self) + def __lt__(self, other): + return self.name < other.name + ################################################################################ # Constants @@ -852,7 +856,7 @@ def accept(self, visitor): ################################################################################ -class Exposure: +class Exposure(object): """An Exposure holds one Exposed or RuntimeEnabled condition. Each exposure has two properties: exposed and runtime_enabled. Exposure(e, r) corresponds to [Exposed(e r)]. Exposure(e) corresponds to diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py index 8d72865a6c..b80eebdcd6 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_reader.py @@ -55,8 +55,8 @@ def validate_blink_idl_definitions(idl_filename, idl_file_basename, definitions. There is no filename convention in this case. - Otherwise, an IDL file is invalid. """ - targets = ( - definitions.interfaces.values() + definitions.dictionaries.values()) + targets = (list(definitions.interfaces.values()) + + list(definitions.dictionaries.values())) number_of_targets = len(targets) if number_of_targets > 1: raise Exception( diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py index cd4f0c3513..ab95e9c0b0 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/idl_types.py @@ -349,7 +349,7 @@ def is_union_type(self): return True def single_matching_member_type(self, predicate): - matching_types = filter(predicate, self.flattened_member_types) + matching_types = list(filter(predicate, self.flattened_member_types)) if len(matching_types) > 1: raise ValueError('%s is ambiguous.' % self.name) return matching_types[0] if matching_types else None diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py index e1677ee7bd..3c5006f064 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/utilities.py @@ -196,8 +196,9 @@ def include_path_for_union_types(self, union_type): @property def callback_functions(self): - return dict(self._component_info_core['callback_functions'].items() + - self._component_info_modules['callback_functions'].items()) + return dict( + list(self._component_info_core['callback_functions'].items()) + + list(self._component_info_modules['callback_functions'].items())) @property def specifier_for_export(self): @@ -209,8 +210,8 @@ def include_path_for_export(self): def load_interfaces_info_overall_pickle(info_dir): - with open(os.path.join(info_dir, - 'interfaces_info.pickle')) as interface_info_file: + with open(os.path.join(info_dir, 'interfaces_info.pickle'), + mode='rb') as interface_info_file: return pickle.load(interface_info_file) @@ -236,23 +237,20 @@ def merge_dict_recursively(target, diff): def create_component_info_provider_core(info_dir): interfaces_info = load_interfaces_info_overall_pickle(info_dir) - with open( - os.path.join(info_dir, 'core', - 'component_info_core.pickle')) as component_info_file: + with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'), + mode='rb') as component_info_file: component_info = pickle.load(component_info_file) return ComponentInfoProviderCore(interfaces_info, component_info) def create_component_info_provider_modules(info_dir): interfaces_info = load_interfaces_info_overall_pickle(info_dir) - with open( - os.path.join(info_dir, 'core', - 'component_info_core.pickle')) as component_info_file: + with open(os.path.join(info_dir, 'core', 'component_info_core.pickle'), + mode='rb') as component_info_file: component_info_core = pickle.load(component_info_file) - with open( - os.path.join( - info_dir, 'modules', - 'component_info_modules.pickle')) as component_info_file: + with open(os.path.join(info_dir, 'modules', + 'component_info_modules.pickle'), + mode='rb') as component_info_file: component_info_modules = pickle.load(component_info_file) return ComponentInfoProviderModules(interfaces_info, component_info_core, component_info_modules) @@ -356,7 +354,7 @@ def write_pickle_file(pickle_filename, data): pickle_filename = abs(pickle_filename) # If |data| is same with the file content, we skip updating. if os.path.isfile(pickle_filename): - with open(pickle_filename) as pickle_file: + with open(pickle_filename, 'rb') as pickle_file: try: if pickle.load(pickle_file) == data: return diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py index a43260414d..a85b03abe7 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_interface.py @@ -189,7 +189,7 @@ def member_filter(members): return sorted([ member for member in members if member.get(KEY) and not member.get('exposed_test') - ]) + ], key=lambda item: item['name']) def member_filter_by_name(members, name): return [member for member in members if member[KEY] == name] @@ -612,7 +612,8 @@ def interface_context(interface, interfaces, component_info): sorted( origin_trial_features(interface, context['constants'], context['attributes'], context['methods']) + - context_enabled_features(context['attributes'])), + context_enabled_features(context['attributes']), + key=lambda item: item['name']), }) if context['optional_features']: includes.add('platform/bindings/v8_per_context_data.h') @@ -1356,9 +1357,9 @@ def resolution_tests_methods(effective_overloads): # Extract argument and IDL type to simplify accessing these in each loop. arguments = [method['arguments'][index] for method in methods] - arguments_methods = zip(arguments, methods) + arguments_methods = list(zip(arguments, methods)) idl_types = [argument['idl_type_object'] for argument in arguments] - idl_types_methods = zip(idl_types, methods) + idl_types_methods = list(zip(idl_types, methods)) # We can’t do a single loop through all methods or simply sort them, because # a method may be listed in multiple steps of the resolution algorithm, and diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py index 5f1f89a3de..6ee8a40779 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_methods.py @@ -46,6 +46,10 @@ import v8_utilities from v8_utilities import (has_extended_attribute_value, is_unforgeable) +# TODO: Remove this once Python2 is obsoleted. +if sys.version_info.major != 2: + basestring = str + def method_is_visible(method, interface_is_partial): if 'overloads' in method: diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py index 2ecd692332..fcfc48371b 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/v8_utilities.py @@ -271,7 +271,7 @@ def deprecate_as(member): ]) -class ExposureSet: +class ExposureSet(object): """An ExposureSet is a collection of Exposure instructions.""" def __init__(self, exposures=None): diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py index 13fb7c7068..b73b771068 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/callback_interface.py @@ -91,11 +91,13 @@ def __init__(self, ir): for operation_ir in ir.operations ]) self._operation_groups = tuple([ - OperationGroup( - operation_group_ir, - filter(lambda x: x.identifier == operation_group_ir.identifier, - self._operations), - owner=self) for operation_group_ir in ir.operation_groups + OperationGroup(operation_group_ir, + list( + filter( + lambda x: x.identifier == operation_group_ir + .identifier, self._operations)), + owner=self) + for operation_group_ir in ir.operation_groups ]) @property diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py index c92cf48eb2..f5d5912944 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/database.py @@ -156,4 +156,4 @@ def union_types(self): return self._view_by_kind(Database._Kind.UNION) def _view_by_kind(self, kind): - return self._impl.find_by_kind(kind).values() + return list(self._impl.find_by_kind(kind).values()) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py index abaeef39c3..e36cf7439a 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/exposure.py @@ -8,8 +8,11 @@ class _Feature(str): """Represents a runtime-enabled feature.""" + def __new__(cls, value): + return str.__new__(cls, value) + def __init__(self, value): - str.__init__(self, value) + str.__init__(self) self._is_context_dependent = ( RuntimeEnabledFeatures.is_context_dependent(self)) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py index 648c70d803..1712f19c67 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/function_like.py @@ -71,8 +71,9 @@ def is_variadic(self): def num_of_required_arguments(self): """Returns the number of required arguments.""" return len( - filter(lambda arg: not (arg.is_optional or arg.is_variadic), - self.arguments)) + list( + filter(lambda arg: not (arg.is_optional or arg.is_variadic), + self.arguments))) class OverloadGroup(WithIdentifier): @@ -171,8 +172,7 @@ def effective_overload_set(self, argument_count=None): Returns the effective overload set. https://heycam.github.io/webidl/#compute-the-effective-overload-set """ - assert argument_count is None or isinstance(argument_count, - (int, long)) + assert argument_count is None or isinstance(argument_count, int) N = argument_count S = [] @@ -188,21 +188,21 @@ def effective_overload_set(self, argument_count=None): S.append( OverloadGroup.EffectiveOverloadItem( - X, map(lambda arg: arg.idl_type, X.arguments), - map(lambda arg: arg.optionality, X.arguments))) + X, list(map(lambda arg: arg.idl_type, X.arguments)), + list(map(lambda arg: arg.optionality, X.arguments)))) if X.is_variadic: - for i in xrange(n, max(maxarg, N)): - t = map(lambda arg: arg.idl_type, X.arguments) - o = map(lambda arg: arg.optionality, X.arguments) - for _ in xrange(n, i + 1): + for i in range(n, max(maxarg, N)): + t = list(map(lambda arg: arg.idl_type, X.arguments)) + o = list(map(lambda arg: arg.optionality, X.arguments)) + for _ in range(n, i + 1): t.append(X.arguments[-1].idl_type) o.append(X.arguments[-1].optionality) S.append(OverloadGroup.EffectiveOverloadItem(X, t, o)) - t = map(lambda arg: arg.idl_type, X.arguments) - o = map(lambda arg: arg.optionality, X.arguments) - for i in xrange(n - 1, -1, -1): + t = list(map(lambda arg: arg.idl_type, X.arguments)) + o = list(map(lambda arg: arg.optionality, X.arguments)) + for i in range(n - 1, -1, -1): if X.arguments[i].optionality == IdlType.Optionality.REQUIRED: break S.append(OverloadGroup.EffectiveOverloadItem(X, t[:i], o[:i])) @@ -222,7 +222,7 @@ def distinguishing_argument_index(items_of_effective_overload_set): for item in items) assert len(items) > 1 - for index in xrange(len(items[0].type_list)): + for index in range(len(items[0].type_list)): # Assume that the given items are valid, and we only need to test # the two types. if OverloadGroup.are_distinguishable_types( diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py index c5ee2bd8a3..5831507248 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/idl_compiler.py @@ -149,8 +149,8 @@ def _remove_legacy_interface_members(self): for old_ir in old_irs: new_ir = make_copy(old_ir) self._ir_map.add(new_ir) - new_ir.attributes = filter(not_disabled, new_ir.attributes) - new_ir.operations = filter(not_disabled, new_ir.operations) + new_ir.attributes = list(filter(not_disabled, new_ir.attributes)) + new_ir.operations = list(filter(not_disabled, new_ir.operations)) def _record_defined_in_partial_and_mixin(self): old_irs = self._ir_map.irs_of_kinds( @@ -231,7 +231,7 @@ def process_interface_like(ir): only_to_members_of_partial_or_mixin=False) propagate_to_exposure(propagate) - map(process_member_like, ir.iter_all_members()) + list(map(process_member_like, ir.iter_all_members())) def process_member_like(ir): propagate = functools.partial(propagate_extattr, ir=ir) @@ -257,7 +257,7 @@ def propagate_to_exposure(propagate): self._ir_map.move_to_new_phase() - map(process_interface_like, old_irs) + list(map(process_interface_like, old_irs)) def _determine_blink_headers(self): irs = self._ir_map.irs_of_kinds( @@ -422,9 +422,9 @@ def is_own_member(member): assert not new_interface.deriveds derived_set = identifier_to_derived_set.get( new_interface.identifier, set()) - new_interface.deriveds = map( - lambda id_: self._ref_to_idl_def_factory.create(id_), - sorted(derived_set)) + new_interface.deriveds = list( + map(lambda id_: self._ref_to_idl_def_factory.create(id_), + sorted(derived_set))) def _supplement_missing_html_constructor_operation(self): # Temporary mitigation of misuse of [HTMLConstructor] @@ -553,7 +553,8 @@ def _calculate_group_exposure(self): self._ir_map.add(new_ir) for group in new_ir.iter_all_overload_groups(): - exposures = map(lambda overload: overload.exposure, group) + exposures = list(map(lambda overload: overload.exposure, + group)) # [Exposed] if any(not exposure.global_names_and_features @@ -653,8 +654,8 @@ def make_legacy_window_alias(ir): constructs = set() for global_name in global_names: constructs.update(exposed_map.get(global_name, [])) - new_ir.exposed_constructs = map( - self._ref_to_idl_def_factory.create, sorted(constructs)) + new_ir.exposed_constructs = list( + map(self._ref_to_idl_def_factory.create, sorted(constructs))) assert not new_ir.legacy_window_aliases if new_ir.identifier != 'Window': diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py index 65d24e529d..067ef2eb0b 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/interface.py @@ -180,8 +180,9 @@ def __init__(self, ir): self._constructor_groups = tuple([ ConstructorGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._constructors), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._constructors)), owner=self) for group_ir in ir.constructor_groups ]) assert len(self._constructor_groups) <= 1 @@ -192,8 +193,9 @@ def __init__(self, ir): self._named_constructor_groups = tuple([ ConstructorGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._named_constructors), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._named_constructors)), owner=self) for group_ir in ir.named_constructor_groups ]) self._operations = tuple([ @@ -203,22 +205,23 @@ def __init__(self, ir): self._operation_groups = tuple([ OperationGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._operations), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._operations)), owner=self) for group_ir in ir.operation_groups ]) self._exposed_constructs = tuple(ir.exposed_constructs) self._legacy_window_aliases = tuple(ir.legacy_window_aliases) self._indexed_and_named_properties = None - indexed_and_named_property_operations = filter( - lambda x: x.is_indexed_or_named_property_operation, - self._operations) + indexed_and_named_property_operations = list( + filter(lambda x: x.is_indexed_or_named_property_operation, + self._operations)) if indexed_and_named_property_operations: self._indexed_and_named_properties = IndexedAndNamedProperties( indexed_and_named_property_operations, owner=self) self._stringifier = None - stringifier_operation_irs = filter(lambda x: x.is_stringifier, - ir.operations) + stringifier_operation_irs = list( + filter(lambda x: x.is_stringifier, ir.operations)) if stringifier_operation_irs: assert len(stringifier_operation_irs) == 1 op_ir = make_copy(stringifier_operation_irs[0]) @@ -231,8 +234,9 @@ def __init__(self, ir): attribute = None if operation.stringifier_attribute: attr_id = operation.stringifier_attribute - attributes = filter(lambda x: x.identifier == attr_id, - self._attributes) + attributes = list( + filter(lambda x: x.identifier == attr_id, + self._attributes)) assert len(attributes) == 1 attribute = attributes[0] self._stringifier = Stringifier(operation, attribute, owner=self) @@ -578,8 +582,9 @@ def __init__(self, ir, owner): self._operation_groups = tuple([ OperationGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._operations), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._operations)), owner=owner) for group_ir in ir.operation_groups ]) @@ -666,8 +671,9 @@ def __init__(self, ir, owner): self._operation_groups = tuple([ OperationGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._operations), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._operations)), owner=owner) for group_ir in ir.operation_groups ]) @@ -755,8 +761,9 @@ def __init__(self, ir, owner): self._operation_groups = tuple([ OperationGroup( group_ir, - filter(lambda x: x.identifier == group_ir.identifier, - self._operations), + list( + filter(lambda x: x.identifier == group_ir.identifier, + self._operations)), owner=owner) for group_ir in ir.operation_groups ]) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py index e9aeff4ab8..d80554d603 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/ir_builder.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import sys + from .argument import Argument from .ast_group import AstGroup from .attribute import Attribute @@ -30,6 +32,11 @@ from .typedef import Typedef +# TODO: Remove this once Python2 is obsoleted. +if sys.version_info.major != 2: + long = int + + def load_and_register_idl_definitions(filepaths, register_ir, create_ref_to_idl_def, idl_type_factory): """ @@ -160,7 +167,7 @@ def _build_namespace(self, node): child_nodes = list(node.GetChildren()) extended_attributes = self._take_extended_attributes(child_nodes) - members = map(self._build_interface_member, child_nodes) + members = list(map(self._build_interface_member, child_nodes)) attributes = [] constants = [] operations = [] @@ -302,7 +309,7 @@ def _build_dictionary(self, node): child_nodes = list(node.GetChildren()) inherited = self._take_inheritance(child_nodes) extended_attributes = self._take_extended_attributes(child_nodes) - own_members = map(self._build_dictionary_member, child_nodes) + own_members = list(map(self._build_dictionary_member, child_nodes)) return Dictionary.IR( identifier=Identifier(node.GetName()), @@ -336,7 +343,7 @@ def _build_callback_interface(self, node): child_nodes = list(node.GetChildren()) extended_attributes = self._take_extended_attributes(child_nodes) - members = map(self._build_interface_member, child_nodes) + members = list(map(self._build_interface_member, child_nodes)) constants = [] operations = [] for member in members: @@ -456,8 +463,8 @@ def build_extended_attribute(node): assert len(child_nodes) == 1 child = child_nodes[0] if child.GetClass() == 'Arguments': - arguments = map(build_extattr_argument, - child.GetChildren()) + arguments = list( + map(build_extattr_argument, child.GetChildren())) elif child.GetClass() == 'Call': assert len(child.GetChildren()) == 1 grand_child = child.GetChildren()[0] @@ -486,7 +493,9 @@ def build_extattr_argument(node): assert node.GetClass() == 'ExtAttributes' return ExtendedAttributes( - filter(None, map(build_extended_attribute, node.GetChildren()))) + list( + filter(None, map(build_extended_attribute, + node.GetChildren())))) def _build_inheritance(self, node): assert node.GetClass() == 'Inherit' @@ -506,7 +515,7 @@ def _build_is_variadic_argument(self, node): def _build_iterable(self, node): assert node.GetClass() == 'Iterable' - types = map(self._build_type, node.GetChildren()) + types = list(map(self._build_type, node.GetChildren())) assert len(types) == 1 or len(types) == 2 if len(types) == 1: # value iterator key_type, value_type = (None, types[0]) @@ -584,7 +593,7 @@ def _build_literal_constant(self, node): def _build_maplike(self, node, interface_identifier): assert node.GetClass() == 'Maplike' assert isinstance(interface_identifier, Identifier) - types = map(self._build_type, node.GetChildren()) + types = list(map(self._build_type, node.GetChildren())) assert len(types) == 2 key_type, value_type = types is_readonly = bool(node.GetProperty('READONLY')) @@ -676,7 +685,7 @@ def _build_maplike(self, node, interface_identifier): def _build_setlike(self, node, interface_identifier): assert node.GetClass() == 'Setlike' assert isinstance(interface_identifier, Identifier) - types = map(self._build_type, node.GetChildren()) + types = list(map(self._build_type, node.GetChildren())) assert len(types) == 1 value_type = types[0] is_readonly = bool(node.GetProperty('READONLY')) @@ -838,7 +847,7 @@ def build_promise_type(node, extended_attributes): def build_union_type(node, extended_attributes): return self._idl_type_factory.union_type( - member_types=map(self._build_type, node.GetChildren()), + member_types=list(map(self._build_type, node.GetChildren())), is_optional=is_optional, extended_attributes=extended_attributes, debug_info=self._build_debug_info(node)) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py index a7a2b11f3f..2f6b61300f 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/make_copy.py @@ -3,6 +3,13 @@ # found in the LICENSE file. +import sys + +# TODO: Remove this once Python2 is obsoleted. +if sys.version_info.major != 2: + long = int + basestring = str + def make_copy(obj, memo=None): """ Creates a copy of the given object, which should be an IR or part of IR. diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py index eeabef97cb..bd7e98907f 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/scripts/web_idl/namespace.py @@ -107,11 +107,13 @@ def __init__(self, ir): for operation_ir in ir.operations ]) self._operation_groups = tuple([ - OperationGroup( - operation_group_ir, - filter(lambda x: x.identifier == operation_group_ir.identifier, - self._operations), - owner=self) for operation_group_ir in ir.operation_groups + OperationGroup(operation_group_ir, + list( + filter( + lambda x: x.identifier == operation_group_ir + .identifier, self._operations)), + owner=self) + for operation_group_ir in ir.operation_groups ]) @property diff --git a/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl b/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl index 0add9c45a3..dc910f6d22 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl +++ b/src/3rdparty/chromium/third_party/blink/renderer/bindings/templates/dictionary_v8.cc.tmpl @@ -59,9 +59,9 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local v8_value, { DCHECK(executionContext); {% endif %}{# has_origin_trial_members #} {% endif %}{# members #} - {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %} + {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %} {% filter origin_trial_enabled(origin_trial_test, "executionContext") %} - {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %} + {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %} {% filter runtime_enabled(feature_name) %} {% for member in member_list %} v8::Local {{member.v8_value}}; @@ -147,9 +147,9 @@ bool toV8{{cpp_class}}(const {{cpp_class}}* impl, v8::Local dictiona DCHECK(executionContext); {% endif %}{# has_origin_trial_members #} {% endif %}{# members #} - {% for origin_trial_test, origin_trial_member_list in members | groupby('origin_trial_feature_name') %} + {% for origin_trial_test, origin_trial_member_list in members | stringifykeygroupby('origin_trial_feature_name') %} {% filter origin_trial_enabled(origin_trial_test, "executionContext") %} - {% for feature_name, member_list in origin_trial_member_list | groupby('runtime_enabled_feature_name') %} + {% for feature_name, member_list in origin_trial_member_list | stringifykeygroupby('runtime_enabled_feature_name') %} {% filter runtime_enabled(feature_name) %} {% for member in member_list %} v8::Local {{member.v8_value}}; diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py index 1799cd5a15..5f43ffabc2 100755 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py @@ -71,7 +71,7 @@ def is_empty(self): def enabled_longhands(self): include = lambda longhand: not longhand[ 'runtime_flag'] or self.is_enabled(longhand['runtime_flag']) - return filter(include, self._longhands) + return list(filter(include, self._longhands)) @property def index(self): @@ -87,8 +87,9 @@ def flags(self): def create_expansions(longhands): flags = collect_runtime_flags(longhands) - expansions = map(lambda mask: Expansion(longhands, flags, mask), - range(1 << len(flags))) + expansions = list( + map(lambda mask: Expansion(longhands, flags, mask), + range(1 << len(flags)))) assert len(expansions) > 0 # We generate 2^N expansions for N flags, so enforce some limit. assert len(flags) <= 4, 'Too many runtime flags for a single shorthand' @@ -114,14 +115,14 @@ def __init__(self, json5_file_paths, output_dir): self._longhand_dictionary = defaultdict(list) for property_ in json5_properties.shorthands: - property_['longhand_enum_keys'] = map(enum_key_for_css_property, - property_['longhands']) - property_['longhand_property_ids'] = map(id_for_css_property, - property_['longhands']) - - longhands = map( - lambda name: json5_properties.properties_by_name[name], - property_['longhands']) + property_['longhand_enum_keys'] = list( + map(enum_key_for_css_property, property_['longhands'])) + property_['longhand_property_ids'] = list( + map(id_for_css_property, property_['longhands'])) + + longhands = list( + map(lambda name: json5_properties.properties_by_name[name], + property_['longhands'])) property_['expansions'] = create_expansions(longhands) for longhand_enum_key in property_['longhand_enum_keys']: self._longhand_dictionary[longhand_enum_key].append(property_) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py index 75030ac577..f72aadee17 100755 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/core/css/properties/make_css_property_instances.py @@ -42,8 +42,8 @@ def __init__(self, json5_file_paths, output_dir): aliases = self._css_properties.aliases # Lists of PropertyClassData. - self._property_classes_by_id = map(self.get_class, properties) - self._alias_classes_by_id = map(self.get_class, aliases) + self._property_classes_by_id = list(map(self.get_class, properties)) + self._alias_classes_by_id = list(map(self.get_class, aliases)) # Sort by enum value. self._property_classes_by_id.sort(key=lambda t: t.enum_value) diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py index 5ee49056be..db72660d47 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/gperf.py @@ -95,7 +95,7 @@ def main(): open(args.output_file, 'wb').write( generate_gperf(gperf_path, - open(infile).read(), gperf_args)) + open(infile).read(), gperf_args).encode('utf-8')) if __name__ == '__main__': diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py index 28adc050f1..58113483e5 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_file.py @@ -66,7 +66,7 @@ def __init__(self, self._defaults = defaults self._valid_values = copy.deepcopy( valid_values if valid_values else {}) - self._parse(map(str.strip, lines)) + self._parse(list(map(str.strip, lines))) @classmethod def load_from_files(self, file_paths, defaults, valid_values, diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py index e46740a2e8..ab1981ad1e 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/in_generator.py @@ -32,10 +32,15 @@ import os.path import shlex import shutil +import sys import optparse from in_file import InFile +# TODO: Remove this once Python2 is obsoleted. +if sys.version_info.major != 2: + basestring = str + ######################################################### # This is now deprecated - use json5_generator.py instead diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py index cafe8d94a8..6925a4fa58 100755 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py @@ -138,7 +138,7 @@ def _write_features_to_pickle_file(self, platform_output_dir): except Exception: # If trouble unpickling, overwrite pass - with open(os.path.abspath(file_name), 'w') as pickle_file: + with open(os.path.abspath(file_name), 'wb') as pickle_file: pickle.dump(features_map, pickle_file) def _template_inputs(self): diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl index dc3f44c5b1..3eefcf9f0e 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl @@ -26,7 +26,7 @@ using {{namespace}}FunctionMap = HashMapGetExecutionContext())) { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl index 1b5297d52d..edecc81d9d 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl @@ -15,7 +15,7 @@ namespace blink { class Document; // Type checking. -{% for tag in tags|sort if not tag.multipleTagNames and not tag.noTypeHelpers %} +{% for tag in tags|sort(attribute='name') if not tag.multipleTagNames and not tag.noTypeHelpers %} class {{tag.interface}}; template <> inline bool IsElementOfType(const Node& node) { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl index 0244433af2..dcdbb02a56 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/macros.tmpl @@ -25,7 +25,7 @@ {% macro trie_leaf(index, object, return_macro, lowercase_data) %} -{% set name, value = object.items()[0] %} +{% set name, value = (object.items()|list)[0] %} {% if name|length %} if ( {%- for c in name -%} @@ -45,7 +45,7 @@ return {{ return_macro(value) }}; {% macro trie_switch(trie, index, return_macro, lowercase_data) %} -{% if trie|length == 1 and trie.values()[0] is string %} +{% if trie|length == 1 and (trie.values()|list)[0] is string %} {{ trie_leaf(index, trie, return_macro, lowercase_data) -}} {% else %} {% if lowercase_data %} diff --git a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl index cb05c6c431..bd5566b03e 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl +++ b/src/3rdparty/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl @@ -24,12 +24,12 @@ namespace {{cpp_namespace}} { {{symbol_export}}extern const WTF::AtomicString& {{namespace_prefix}}NamespaceURI; // Tags -{% for tag in tags|sort %} +{% for tag in tags|sort(attribute='name') %} {{symbol_export}}extern const blink::{{namespace}}QualifiedName& {{tag|symbol}}Tag; {% endfor %} // Attributes -{% for attr in attrs|sort %} +{% for attr in attrs|sort(attribute='name') %} {{symbol_export}}extern const blink::QualifiedName& {{attr|symbol}}Attr; {% endfor %} diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/fetch/body.cc b/src/3rdparty/chromium/third_party/blink/renderer/core/fetch/body.cc index 97d8301f46..8b24da08f5 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/fetch/body.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/fetch/body.cc @@ -113,8 +113,13 @@ class BodyFormDataConsumer final : public BodyConsumerBase { void DidFetchDataLoadedString(const String& string) override { auto* formData = MakeGarbageCollected(); - for (const auto& pair : URLSearchParams::Create(string)->Params()) + // URLSearchParams::Create() returns an on-heap object, but it can be + // garbage collected, so making it a persistent variable on the stack + // mitigates use-after-free scenarios. See crbug.com/1497997. + Persistent search_params = URLSearchParams::Create(string); + for (const auto& pair : search_params->Params()) { formData->append(pair.first, pair.second); + } DidFetchDataLoadedFormData(formData); } DISALLOW_COPY_AND_ASSIGN(BodyFormDataConsumer); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/BUILD.gn b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/BUILD.gn index 3db4233ba2..8c0d149465 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/BUILD.gn +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/BUILD.gn @@ -121,6 +121,8 @@ blink_core_sources("paint") { "list_item_painter.h", "list_marker_painter.cc", "list_marker_painter.h", + "media_record_id.cc", + "media_record_id.h", "multi_column_set_painter.cc", "multi_column_set_painter.h", "ng/ng_box_fragment_painter.cc", diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/DEPS b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/DEPS index a58190f203..377061397a 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/DEPS +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/DEPS @@ -4,6 +4,8 @@ include_rules = [ "+cc/layers/picture_layer.h", # For DCHECK. "+base/logging.h", + # Hash function access + "+base/hash/hash.h", ] specific_include_rules = { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.cc b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.cc index 18089bb7ac..9b745590ba 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.cc @@ -67,7 +67,7 @@ void ImageElementTiming::NotifyImageFinished( return; const auto& insertion_result = images_notified_.insert( - std::make_pair(&layout_object, cached_image), ImageInfo()); + MediaRecordId::GenerateHash(&layout_object, cached_image), ImageInfo()); if (insertion_result.is_new_entry) insertion_result.stored_value->value.load_time_ = base::TimeTicks::Now(); } @@ -95,7 +95,7 @@ void ImageElementTiming::NotifyImagePainted( if (!internal::IsExplicitlyRegisteredForTiming(layout_object)) return; - auto it = images_notified_.find(std::make_pair(layout_object, cached_image)); + auto it = images_notified_.find(MediaRecordId::GenerateHash(layout_object, cached_image)); // It is possible that the pair is not in |images_notified_|. See // https://crbug.com/1027948 if (it != images_notified_.end() && !it->value.is_painted_ && cached_image) { @@ -212,7 +212,7 @@ void ImageElementTiming::NotifyBackgroundImagePainted( ImageInfo& info = images_notified_ - .insert(std::make_pair(layout_object, cached_image), ImageInfo()) + .insert(MediaRecordId::GenerateHash(layout_object, cached_image), ImageInfo()) .stored_value->value; if (!info.is_painted_) { info.is_painted_ = true; @@ -240,7 +240,7 @@ void ImageElementTiming::ReportImagePaintSwapTime(WebSwapResult, void ImageElementTiming::NotifyImageRemoved(const LayoutObject* layout_object, const ImageResourceContent* image) { - images_notified_.erase(std::make_pair(layout_object, image)); + images_notified_.erase(MediaRecordId::GenerateHash(layout_object, image)); } void ImageElementTiming::Trace(Visitor* visitor) const { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.h b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.h index 0dbb052fe4..753ba37251 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.h +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_element_timing.h @@ -5,11 +5,10 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_IMAGE_ELEMENT_TIMING_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_IMAGE_ELEMENT_TIMING_H_ -#include - #include "third_party/blink/public/web/web_swap_result.h" #include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/core/paint/media_record_id.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" #include "third_party/blink/renderer/platform/supplementable.h" #include "third_party/blink/renderer/platform/wtf/functional.h" @@ -121,13 +120,12 @@ class CORE_EXPORT ImageElementTiming final base::TimeTicks load_time_; bool is_painted_ = false; }; - typedef std::pair RecordId; // Hashmap of pairs of elements, LayoutObjects (for the elements) and // ImageResourceContent (for the src) which correspond to either images or // background images whose paint has been observed. For background images, // only the |is_painted_| bit is used, as the timestamp needs to be tracked by // |background_image_timestamps_|. - WTF::HashMap images_notified_; + WTF::HashMap images_notified_; // Hashmap of background images which contain information about the load time // of the background image. diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc index b92407aedb..3c9f99034b 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc @@ -166,11 +166,11 @@ void ImagePaintTimingDetector::NotifyImageRemoved( const ImageResourceContent* cached_image) { if (!is_recording_) return; - RecordId record_id = std::make_pair(&object, cached_image); - records_manager_.RemoveImageFinishedRecord(record_id); - if (!records_manager_.IsRecordedVisibleImage(record_id)) + MediaRecordIdHash record_id_hash = MediaRecordId::GenerateHash(&object, cached_image); + records_manager_.RemoveImageFinishedRecord(record_id_hash); + if (!records_manager_.IsRecordedVisibleImage(record_id_hash)) return; - records_manager_.RemoveVisibleRecord(record_id); + records_manager_.RemoveVisibleRecord(record_id_hash); need_update_timing_at_frame_end_ = true; } @@ -224,9 +224,11 @@ void ImagePaintTimingDetector::RecordImage( if (records_manager_.IsRecordedInvisibleImage(object)) return; - RecordId record_id = std::make_pair(&object, &cached_image); + MediaRecordId record_id(&object, &cached_image); + MediaRecordIdHash record_id_hash = record_id.GetHash(); + bool is_recorded_visible_image = - records_manager_.IsRecordedVisibleImage(record_id); + records_manager_.IsRecordedVisibleImage(record_id_hash); if (int depth = IgnorePaintTimingScope::IgnoreDepth()) { // Record the largest loaded image that is hidden due to documentElement // being invisible but by no other reason (i.e. IgnoreDepth() needs to be @@ -242,9 +244,9 @@ void ImagePaintTimingDetector::RecordImage( } if (is_recorded_visible_image && - !records_manager_.IsVisibleImageLoaded(record_id) && + !records_manager_.IsVisibleImageLoaded(record_id_hash) && cached_image.IsLoaded()) { - records_manager_.OnImageLoaded(record_id, frame_index_, style_image); + records_manager_.OnImageLoaded(record_id_hash, frame_index_, style_image); need_update_timing_at_frame_end_ = true; if (base::Optional& visualizer = frame_view_->GetPaintTimingDetector().Visualizer()) { @@ -272,7 +274,7 @@ void ImagePaintTimingDetector::RecordImage( } else { records_manager_.RecordVisible(record_id, rect_size); if (cached_image.IsLoaded()) { - records_manager_.OnImageLoaded(record_id, frame_index_, style_image); + records_manager_.OnImageLoaded(record_id_hash, frame_index_, style_image); need_update_timing_at_frame_end_ = true; } } @@ -306,8 +308,7 @@ uint64_t ImagePaintTimingDetector::ComputeImageRectSize( void ImagePaintTimingDetector::NotifyImageFinished( const LayoutObject& object, const ImageResourceContent* cached_image) { - RecordId record_id = std::make_pair(&object, cached_image); - records_manager_.NotifyImageFinished(record_id); + records_manager_.NotifyImageFinished(MediaRecordId::GenerateHash(&object, cached_image)); } void ImagePaintTimingDetector::ReportLargestIgnoredImage() { @@ -318,13 +319,13 @@ void ImagePaintTimingDetector::ReportLargestIgnoredImage() { ImageRecordsManager::ImageRecordsManager(LocalFrameView* frame_view) : size_ordered_set_(&LargeImageFirst), frame_view_(frame_view) {} -void ImageRecordsManager::OnImageLoaded(const RecordId& record_id, +void ImageRecordsManager::OnImageLoaded(MediaRecordIdHash record_id_hash, unsigned current_frame_index, const StyleFetchedImage* style_image) { - base::WeakPtr record = FindVisibleRecord(record_id); + base::WeakPtr record = FindVisibleRecord(record_id_hash); DCHECK(record); if (!style_image) { - record->load_time = image_finished_times_.at(record_id); + record->load_time = image_finished_times_.at(record_id_hash); DCHECK(!record->load_time.is_null()); } else { Document* document = frame_view_->GetFrame().GetDocument(); @@ -348,10 +349,9 @@ void ImageRecordsManager::ReportLargestIgnoredImage( largest_ignored_image_.reset(); return; } - RecordId record_id = std::make_pair(node->GetLayoutObject(), - largest_ignored_image_->cached_image); + MediaRecordId record_id(node->GetLayoutObject(), largest_ignored_image_->cached_image); size_ordered_set_.insert(record); - visible_images_.insert(record_id, std::move(largest_ignored_image_)); + visible_images_.insert(record_id.GetHash(), std::move(largest_ignored_image_)); OnImageLoadedInternal(record, current_frame_index); } @@ -363,22 +363,22 @@ void ImageRecordsManager::OnImageLoadedInternal( } void ImageRecordsManager::MaybeUpdateLargestIgnoredImage( - const RecordId& record_id, + const MediaRecordId& record_id, const uint64_t& visual_size) { if (visual_size && (!largest_ignored_image_ || visual_size > largest_ignored_image_->first_size)) { largest_ignored_image_ = - CreateImageRecord(*record_id.first, record_id.second, visual_size); + CreateImageRecord(*record_id.GetLayoutObject(), record_id.GetImageResourceContent(), visual_size); largest_ignored_image_->load_time = base::TimeTicks::Now(); } } -void ImageRecordsManager::RecordVisible(const RecordId& record_id, +void ImageRecordsManager::RecordVisible(const MediaRecordId& record_id, const uint64_t& visual_size) { std::unique_ptr record = - CreateImageRecord(*record_id.first, record_id.second, visual_size); + CreateImageRecord(*record_id.GetLayoutObject(), record_id.GetImageResourceContent(), visual_size); size_ordered_set_.insert(record->AsWeakPtr()); - visible_images_.insert(record_id, std::move(record)); + visible_images_.insert(record_id.GetHash(), std::move(record)); } std::unique_ptr ImageRecordsManager::CreateImageRecord( diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.h b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.h index e1188dbf35..41bc9e9943 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.h +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/image_paint_timing_detector.h @@ -13,6 +13,7 @@ #include "third_party/blink/public/web/web_widget_client.h" #include "third_party/blink/renderer/core/dom/dom_node_ids.h" #include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" +#include "third_party/blink/renderer/core/paint/media_record_id.h" #include "third_party/blink/renderer/core/paint/paint_timing_detector.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" @@ -53,8 +54,6 @@ class ImageRecord : public base::SupportsWeakPtr { bool loaded = false; }; -typedef std::pair RecordId; - // |ImageRecordsManager| is the manager of all of the images that Largest Image // Paint cares about. Note that an image does not necessarily correspond to a // node; it can also be one of the background images attached to a node. @@ -80,13 +79,13 @@ class CORE_EXPORT ImageRecordsManager { invisible_images_.erase(&object); } - inline void RemoveImageFinishedRecord(const RecordId& record_id) { - image_finished_times_.erase(record_id); + inline void RemoveImageFinishedRecord(MediaRecordIdHash record_id_hash) { + image_finished_times_.erase(record_id_hash); } - inline void RemoveVisibleRecord(const RecordId& record_id) { + inline void RemoveVisibleRecord(MediaRecordIdHash record_id_hash) { base::WeakPtr record = - visible_images_.find(record_id)->value->AsWeakPtr(); + visible_images_.find(record_id_hash)->value->AsWeakPtr(); if (!record->paint_time.is_null()) { DCHECK_GT(record->first_size, 0u); if (record->first_size > largest_removed_image_size_) { @@ -100,7 +99,7 @@ class CORE_EXPORT ImageRecordsManager { } } size_ordered_set_.erase(record); - visible_images_.erase(record_id); + visible_images_.erase(record_id_hash); // Leave out |images_queued_for_paint_time_| intentionally because the null // record will be removed in |AssignPaintTimeToRegisteredQueuedRecords|. } @@ -108,29 +107,29 @@ class CORE_EXPORT ImageRecordsManager { inline void RecordInvisible(const LayoutObject& object) { invisible_images_.insert(&object); } - void RecordVisible(const RecordId& record_id, const uint64_t& visual_size); - bool IsRecordedVisibleImage(const RecordId& record_id) const { - return visible_images_.Contains(record_id); + void RecordVisible(const MediaRecordId& record_id, const uint64_t& visual_size); + bool IsRecordedVisibleImage(const MediaRecordIdHash record_id_hash) const { + return visible_images_.Contains(record_id_hash); } bool IsRecordedInvisibleImage(const LayoutObject& object) const { return invisible_images_.Contains(&object); } - void NotifyImageFinished(const RecordId& record_id) { + void NotifyImageFinished(MediaRecordIdHash record_id_hash) { // TODO(npm): Ideally NotifyImageFinished() would only be called when the // record has not yet been inserted in |image_finished_times_| but that's // not currently the case. If we plumb some information from // ImageResourceContent we may be able to ensure that this call does not // require the Contains() check, which would save time. - if (!image_finished_times_.Contains(record_id)) - image_finished_times_.insert(record_id, base::TimeTicks::Now()); + if (!image_finished_times_.Contains(record_id_hash)) + image_finished_times_.insert(record_id_hash, base::TimeTicks::Now()); } - inline bool IsVisibleImageLoaded(const RecordId& record_id) const { - DCHECK(visible_images_.Contains(record_id)); - return visible_images_.at(record_id)->loaded; + inline bool IsVisibleImageLoaded(MediaRecordIdHash record_id_hash) const { + DCHECK(visible_images_.Contains(record_id_hash)); + return visible_images_.at(record_id_hash)->loaded; } - void OnImageLoaded(const RecordId&, + void OnImageLoaded(MediaRecordIdHash, unsigned current_frame_index, const StyleFetchedImage*); void OnImageLoadedInternal(base::WeakPtr&, @@ -139,7 +138,7 @@ class CORE_EXPORT ImageRecordsManager { // Receives a candidate image painted under opacity 0 but without nested // opacity. May update |largest_ignored_image_| if the new candidate has a // larger size. - void MaybeUpdateLargestIgnoredImage(const RecordId&, + void MaybeUpdateLargestIgnoredImage(const MediaRecordId&, const uint64_t& visual_size); void ReportLargestIgnoredImage(unsigned current_frame_index); @@ -175,9 +174,9 @@ class CORE_EXPORT ImageRecordsManager { private: // Find the image record of an visible image. inline base::WeakPtr FindVisibleRecord( - const RecordId& record_id) const { - DCHECK(visible_images_.Contains(record_id)); - return visible_images_.find(record_id)->value->AsWeakPtr(); + const MediaRecordIdHash record_id_hash) const { + DCHECK(visible_images_.Contains(record_id_hash)); + return visible_images_.find(record_id_hash)->value->AsWeakPtr(); } std::unique_ptr CreateImageRecord( const LayoutObject& object, @@ -192,7 +191,7 @@ class CORE_EXPORT ImageRecordsManager { record->loaded = true; } - HashMap> visible_images_; + HashMap> visible_images_; HashSet invisible_images_; // This stores the image records, which are ordered by size. @@ -202,7 +201,7 @@ class CORE_EXPORT ImageRecordsManager { Deque> images_queued_for_paint_time_; // Map containing timestamps of when LayoutObject::ImageNotifyFinished is // first called. - HashMap image_finished_times_; + HashMap image_finished_times_; Member frame_view_; diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.cc b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.cc new file mode 100644 index 0000000000..5a0fc1e3c0 --- /dev/null +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.cc @@ -0,0 +1,27 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/paint/media_record_id.h" + +#include "base/hash/hash.h" + +namespace blink { + +MediaRecordId::MediaRecordId(const LayoutObject* layout, + const ImageResourceContent* content) + : layout_object_(layout), + image_resource_content_(content), + hash_(GenerateHash(layout, image_resource_content_)) {} + +// This hash is used as a key where previously MediaRecordId was used directly. +// That helps us avoid storing references to the GCed LayoutObject and +// MediaTiming, as that can be unsafe when using regular WTF containers. It also +// helps us avoid needlessly allocating MediaRecordId on the heap. +MediaRecordIdHash MediaRecordId::GenerateHash(const LayoutObject* layout, + const ImageResourceContent* content) { + return base::HashInts(reinterpret_cast(layout), + reinterpret_cast(content)); +} + +} // namespace blink diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.h b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.h new file mode 100644 index 0000000000..ae8df161ba --- /dev/null +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/paint/media_record_id.h @@ -0,0 +1,37 @@ +// Copyright 2023 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_MEDIA_RECORD_ID_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_MEDIA_RECORD_ID_H_ + +#include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" + +namespace blink { +class LayoutObject; +class ImageResourceContent; + +using MediaRecordIdHash = size_t; + +class MediaRecordId { + STACK_ALLOCATED(); + + public: + static MediaRecordIdHash CORE_EXPORT GenerateHash(const LayoutObject* layout, + const ImageResourceContent* content); + + MediaRecordId(const LayoutObject* layout, const ImageResourceContent* content); + + MediaRecordIdHash GetHash() const { return hash_; } + const LayoutObject* GetLayoutObject() const { return layout_object_; } + const ImageResourceContent* GetImageResourceContent() const { return image_resource_content_; } + + private: + const LayoutObject* const layout_object_; + const ImageResourceContent* const image_resource_content_; + const MediaRecordIdHash hash_; +}; + +} // namespace blink +#endif diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor.h b/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor.h index e501cf17c3..e4550ec500 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor.h +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor.h @@ -79,7 +79,12 @@ class XSLTProcessor final : public ScriptWrappable { void reset(); +#if LIBXML_VERSION >= 21200 + static void ParseErrorFunc(void* user_data, const xmlError*); +#else static void ParseErrorFunc(void* user_data, xmlError*); +#endif + static void GenericErrorFunc(void* user_data, const char* msg, ...); // Only for libXSLT callbacks diff --git a/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc b/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc index b3ce345f32..2174d1df1d 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc @@ -60,7 +60,11 @@ void XSLTProcessor::GenericErrorFunc(void*, const char*, ...) { // It would be nice to do something with this error message. } +#if LIBXML_VERSION >= 21200 +void XSLTProcessor::ParseErrorFunc(void* user_data, const xmlError* error) { +#else void XSLTProcessor::ParseErrorFunc(void* user_data, xmlError* error) { +#endif FrameConsole* console = static_cast(user_data); if (!console) return; diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc index ade14e0102..fe8c4cd277 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.cc @@ -86,35 +86,6 @@ static bool ContextLostRestoredEventsEnabled() { return RuntimeEnabledFeatures::Canvas2dContextLostRestoredEnabled(); } -// Drawing methods need to use this instead of SkAutoCanvasRestore in case -// overdraw detection substitutes the recording canvas (to discard overdrawn -// draw calls). -class CanvasRenderingContext2DAutoRestoreSkCanvas { - STACK_ALLOCATED(); - - public: - explicit CanvasRenderingContext2DAutoRestoreSkCanvas( - CanvasRenderingContext2D* context) - : context_(context), save_count_(0) { - DCHECK(context_); - cc::PaintCanvas* c = context_->GetOrCreatePaintCanvas(); - if (c) { - save_count_ = c->getSaveCount(); - } - } - - ~CanvasRenderingContext2DAutoRestoreSkCanvas() { - cc::PaintCanvas* c = context_->GetOrCreatePaintCanvas(); - if (c) - c->restoreToCount(save_count_); - context_->ValidateStateStack(); - } - - private: - CanvasRenderingContext2D* context_; - int save_count_; -}; - CanvasRenderingContext2D::CanvasRenderingContext2D( HTMLCanvasElement* canvas, const CanvasContextCreationAttributesCore& attrs) @@ -850,9 +821,11 @@ void CanvasRenderingContext2D::DrawTextInternal( // to 0, for example), so update style before grabbing the PaintCanvas. canvas()->GetDocument().UpdateStyleAndLayoutTreeForNode(canvas()); - cc::PaintCanvas* c = GetOrCreatePaintCanvas(); - if (!c) + // Abort if we don't have a paint canvas (e.g. the context was lost). + cc::PaintCanvas* paint_canvas = GetOrCreatePaintCanvas(); + if (!paint_canvas) { return; + } if (!std::isfinite(x) || !std::isfinite(y)) return; @@ -920,14 +893,13 @@ void CanvasRenderingContext2D::DrawTextInternal( if (paint_type == CanvasRenderingContext2DState::kStrokePaintType) InflateStrokeRect(bounds); - CanvasRenderingContext2DAutoRestoreSkCanvas state_restorer(this); if (use_max_width) { - c->save(); + paint_canvas->save(); // We draw when fontWidth is 0 so compositing operations (eg, a "copy" op) // still work. As the width of canvas is scaled, so text can be scaled to // match the given maxwidth, update text location so it appears on desired // place. - c->scale(clampTo(width / font_width), 1); + paint_canvas->scale(clampTo(width / font_width), 1); location.SetX(location.X() / clampTo(width / font_width)); } @@ -942,6 +914,16 @@ void CanvasRenderingContext2D::DrawTextInternal( [](const SkIRect& rect) // overdraw test lambda { return false; }, bounds, paint_type, CanvasRenderingContext2DState::kNoImage); + + if (use_max_width) { + // Cannot use `paint_canvas` in case recording canvas was substituted or + // destroyed during draw call. + cc::PaintCanvas* c = GetPaintCanvas(); + if (c) { + c->restore(); + } + } + ValidateStateStack(); } const Font& CanvasRenderingContext2D::AccessFont() { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h b/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h index ac10ae4389..b0d09f182a 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d.h @@ -236,8 +236,6 @@ class MODULES_EXPORT CanvasRenderingContext2D final void WillOverwriteCanvas() override; private: - friend class CanvasRenderingContext2DAutoRestoreSkCanvas; - void DispatchContextLostEvent(TimerBase*); void DispatchContextRestoredEvent(TimerBase*); void TryRestoreContextEvent(TimerBase*); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc index 7781c4083d..abd1bdd663 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc @@ -1110,14 +1110,18 @@ bool RTCPeerConnectionHandler::Initialize( const MediaConstraints& options, WebLocalFrame* frame) { DCHECK(task_runner_->RunsTasksInCurrentSequence()); - DCHECK(frame); - frame_ = frame; CHECK(!initialize_called_); initialize_called_ = true; // Prevent garbage collection of client_ during processing. auto* client_on_stack = client_; + if (!client_on_stack) { + return false; + } + + DCHECK(frame); + frame_ = frame; // TODO(crbug.com/787254): Evaluate the need for passing weak ptr since // PeerConnectionTracker is now leaky with base::LazyInstance. peer_connection_tracker_ = PeerConnectionTracker::GetInstance()->AsWeakPtr(); @@ -2523,10 +2527,13 @@ void RTCPeerConnectionHandler::OnIceCandidate(const String& sdp, int sdp_mline_index, int component, int address_family) { + DCHECK(task_runner_->RunsTasksInCurrentSequence()); // In order to ensure that the RTCPeerConnection is not garbage collected // from under the function, we keep a pointer to it on the stack. auto* client_on_stack = client_; - DCHECK(task_runner_->RunsTasksInCurrentSequence()); + if (!client_on_stack) { + return; + } TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceCandidateImpl"); // This line can cause garbage collection. auto* platform_candidate = MakeGarbageCollected( @@ -2547,7 +2554,9 @@ void RTCPeerConnectionHandler::OnIceCandidate(const String& sdp, NOTREACHED(); } } - if (!is_closed_) + + client_on_stack = client_; + if (!is_closed_ && client_on_stack) client_on_stack->DidGenerateICECandidate(platform_candidate); } diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/analyser_node.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/analyser_node.cc index cb281f5b72..9f515af5d9 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/analyser_node.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/analyser_node.cc @@ -51,9 +51,11 @@ AnalyserHandler::~AnalyserHandler() { } void AnalyserHandler::Process(uint32_t frames_to_process) { - AudioBus* output_bus = Output(0).Bus(); + DCHECK(Context()->IsAudioThread()); - if (!IsInitialized()) { + AudioBus* output_bus = Output(0).RenderingFanOutCount() > 0 ? Output(0).Bus() : nullptr; + + if (!IsInitialized() && output_bus) { output_bus->Zero(); return; } @@ -65,6 +67,11 @@ void AnalyserHandler::Process(uint32_t frames_to_process) { // Analyser reflects the current input. analyser_.WriteInput(input_bus.get(), frames_to_process); + // Subsequent steps require `output_bus` to be valid. + if (!output_bus) { + return; + } + if (!Input(0).IsConnected()) { // No inputs, so clear the output, and propagate the silence hint. output_bus->Zero(); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc index eccf002b6d..5f18c4cd12 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc @@ -102,11 +102,16 @@ void AudioWorkletHandler::Process(uint32_t frames_to_process) { // We also need to check if the global scope is valid before we request // the rendering in the AudioWorkletGlobalScope. if (processor_ && !processor_->hasErrorOccurred()) { - // If the input is not connected, inform the processor with nullptr. - for (unsigned i = 0; i < NumberOfInputs(); ++i) + // If the input or the output is not connected, inform the processor with + // nullptr. + for (unsigned i = 0; i < NumberOfInputs(); ++i) { inputs_[i] = Input(i).IsConnected() ? Input(i).Bus() : nullptr; - for (unsigned i = 0; i < NumberOfOutputs(); ++i) - outputs_[i] = WrapRefCounted(Output(i).Bus()); + } + for (unsigned i = 0; i < NumberOfOutputs(); ++i) { + outputs_[i] = Output(i).RenderingFanOutCount() > 0 + ? WrapRefCounted(Output(i).Bus()) + : nullptr; + } for (const auto& param_name : param_value_map_.Keys()) { auto* const param_handler = param_handler_map_.at(param_name); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_processor.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_processor.cc index e68b1c1b2f..84ab72b977 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_processor.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/audio_worklet_processor.cc @@ -343,6 +343,12 @@ void AudioWorkletProcessor::CopyArrayBuffersToPort( for (uint32_t bus_index = 0; bus_index < audio_port.size(); ++bus_index) { const scoped_refptr& audio_bus = audio_port[bus_index]; + + // nullptr indicates the output bus is not connected. Do not proceed. + if (!audio_bus) { + break; + } + for (uint32_t channel_index = 0; channel_index < audio_bus->NumberOfChannels(); ++channel_index) { const v8::ArrayBuffer::Contents& contents = diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc index 76aa9acccd..88e4228cae 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/deferred_task_handler.cc @@ -169,6 +169,16 @@ void DeferredTaskHandler::UpdateAutomaticPullNodes() { if (try_locker.Locked()) { CopyToVector(automatic_pull_handlers_, rendering_automatic_pull_handlers_); + + // In rare cases, it is possible for automatic pull nodes' output bus + // to become stale. Make sure update their rendering output counts. + // crbug.com/1505080. + for (auto& handler : rendering_automatic_pull_handlers_) { + for (unsigned i = 0; i < handler->NumberOfOutputs(); ++i) { + handler->Output(i).UpdateRenderingState(); + } + } + automatic_pull_handlers_need_updating_ = false; } } diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.cc index 3854a6bc7e..13b78c74ad 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/realtime_audio_destination_node.cc @@ -110,13 +110,21 @@ void RealtimeAudioDestinationHandler::SetChannelCount( uint32_t old_channel_count = this->ChannelCount(); AudioHandler::SetChannelCount(channel_count, exception_state); - // Stop, re-create and start the destination to apply the new channel count. - if (this->ChannelCount() != old_channel_count && - !exception_state.HadException()) { - StopPlatformDestination(); - CreatePlatformDestination(); - StartPlatformDestination(); + // After the context is closed, changing channel count will be ignored + // because it will trigger the recreation of the platform destination. This + // in turn can activate the audio rendering thread. + AudioContext* context = static_cast(Context()); + CHECK(context); + if (context->ContextState() == AudioContext::kClosed || + ChannelCount() == old_channel_count || + exception_state.HadException()) { + return; } + + // Stop, re-create and start the destination to apply the new channel count. + StopPlatformDestination(); + CreatePlatformDestination(); + StartPlatformDestination(); } void RealtimeAudioDestinationHandler::StartRendering() { diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webusb/usb_device.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webusb/usb_device.cc index 1ba2a231a0..41a6ff5cbe 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webusb/usb_device.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webusb/usb_device.cc @@ -6,8 +6,10 @@ #include #include +#include #include +#include "base/optional.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" @@ -42,6 +44,10 @@ namespace blink { namespace { const char kBufferTooBig[] = "The data buffer exceeded its maximum size."; +const char kPacketLengthsTooBig[] = + "The total packet length exceeded the maximum size."; +const char kBufferSizeMismatch[] = + "The data buffer size must match the total packet length."; const char kDetachedBuffer[] = "The data buffer has been detached."; const char kDeviceStateChangeInProgress[] = "An operation that changes the device state is in progress."; @@ -179,6 +185,20 @@ bool ConvertBufferSource(const ArrayBufferOrArrayBufferView& buffer_source, return true; } +// Returns the sum of `packet_lengths`, or nullopt if the sum would overflow. +base::Optional TotalPacketLength( + const Vector& packet_lengths) { + uint32_t total_bytes = 0; + for (const auto packet_length : packet_lengths) { + // Check for overflow. + if (std::numeric_limits::max() - total_bytes < packet_length) { + return base::nullopt; + } + total_bytes += packet_length; + } + return total_bytes; +} + } // namespace USBDevice::USBDevice(UsbDeviceInfoPtr device_info, @@ -549,6 +569,14 @@ ScriptPromise USBDevice::isochronousTransferIn( Vector packet_lengths) { auto* resolver = MakeGarbageCollected(script_state); ScriptPromise promise = resolver->Promise(); + + base::Optional total_bytes = TotalPacketLength(packet_lengths); + if (!total_bytes.has_value()) { + resolver->Reject(MakeGarbageCollected( + DOMExceptionCode::kDataError, kPacketLengthsTooBig)); + return promise; + } + if (EnsureEndpointAvailable(true /* in */, endpoint_number, resolver)) { device_requests_.insert(resolver); device_->IsochronousTransferIn( @@ -569,6 +597,20 @@ ScriptPromise USBDevice::isochronousTransferOut( if (!EnsureEndpointAvailable(false /* out */, endpoint_number, resolver)) return promise; + base::Optional total_bytes = TotalPacketLength(packet_lengths); + if (!total_bytes.has_value()) { + resolver->Reject(MakeGarbageCollected( + DOMExceptionCode::kDataError, kPacketLengthsTooBig)); + return promise; + } + + DOMArrayBuffer* array_buffer = data.GetAsArrayBuffer(); + if (total_bytes.value() != static_cast(array_buffer->ByteLengthAsSizeT())) { + resolver->Reject(MakeGarbageCollected( + DOMExceptionCode::kDataError, kBufferSizeMismatch)); + return promise; + } + Vector buffer; if (!ConvertBufferSource(data, &buffer, resolver)) return promise; diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc index 25818dcf2a..c34118e953 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/audio_delay_dsp_kernel.cc @@ -150,7 +150,7 @@ int AudioDelayDSPKernel::ProcessARateScalar(unsigned start, const float* delay_times = delay_times_.Data(); for (unsigned i = start; i < frames_to_process; ++i) { - double delay_time = delay_times[i]; + double delay_time = std::fmax(delay_times[i], 0); double desired_delay_frames = delay_time * sample_rate; double read_position = w_index + buffer_length - desired_delay_frames; diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc index 2843bd60b8..803f3e7244 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/arm/audio_delay_dsp_kernel_neon.cc @@ -60,6 +60,7 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int w_index = write_index_; const float32x4_t v_sample_rate = vdupq_n_f32(sample_rate); + const float32x4_t v_all_zeros = vdupq_n_f32(0); // The buffer length as a float and as an int so we don't need to constant // convert from one to the other. @@ -87,7 +88,8 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int k = 0; for (int n = 0; n < number_of_loops; ++n, k += 4) { - const float32x4_t v_delay_time = vld1q_f32(delay_times + k); + const float32x4_t v_delay_time = vmaxq_f32(vld1q_f32(delay_times + k), + v_all_zeros); const float32x4_t v_desired_delay_frames = vmulq_f32(v_delay_time, v_sample_rate); @@ -100,7 +102,8 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( WrapPositionVector(v_read_position, v_buffer_length_float); // Get indices into the buffer for the samples we need for interpolation. - const int32x4_t v_read_index1 = vcvtq_s32_f32(v_read_position); + const int32x4_t v_read_index1 = WrapIndexVector( + vcvtq_s32_f32(v_read_position), v_buffer_length_int); const int32x4_t v_read_index2 = WrapIndexVector( vaddq_s32(v_read_index1, vdupq_n_s32(1)), v_buffer_length_int); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc index fe2aef95ae..dd368ee4b0 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/audio/cpu/x86/audio_delay_dsp_kernel_sse2.cc @@ -56,10 +56,10 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( const float sample_rate = this->SampleRate(); const float* delay_times = delay_times_.Data(); - int w_index = write_index_; const __m128 v_sample_rate = _mm_set1_ps(sample_rate); + const __m128 v_all_zeros = _mm_setzero_ps(); // The buffer length as a float and as an int so we don't need to constant // convert from one to the other. @@ -82,7 +82,10 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( int k = 0; for (int n = 0; n < number_of_loops; ++n, k += 4) { - const __m128 v_delay_time = _mm_loadu_ps(delay_times + k); + // It's possible that `delay_time` contains negative values. Make sure + // they are greater than zero. + const __m128 v_delay_time = _mm_max_ps(_mm_loadu_ps(delay_times + k), + v_all_zeros); const __m128 v_desired_delay_frames = _mm_mul_ps(v_delay_time, v_sample_rate); @@ -95,7 +98,8 @@ std::tuple AudioDelayDSPKernel::ProcessARateVector( WrapPositionVector(v_read_position, v_buffer_length_float); // Get indices into the buffer for the samples we need for interpolation. - const __m128i v_read_index1 = _mm_cvttps_epi32(v_read_position); + const __m128i v_read_index1 = WrapIndexVector( + _mm_cvttps_epi32(v_read_position), v_buffer_length_int); const __m128i v_read_index2 = WrapIndexVector( _mm_add_epi32(v_read_index1, _mm_set1_epi32(1)), v_buffer_length_int); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc index 5622233970..3ad17ef41e 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/image-decoders/bmp/bmp_image_reader.cc @@ -723,22 +723,29 @@ bool BMPImageReader::ProcessColorTable() { const size_t header_end = header_offset_ + info_header_.size; size_t colors_in_palette = info_header_.clr_used; + CHECK_LE(colors_in_palette, 256u); // Enforced by ProcessInfoHeader(). size_t table_size_in_bytes = colors_in_palette * bytes_per_color; const size_t table_end = header_end + table_size_in_bytes; if (table_end < header_end) return parent_->SetFailed(); - // Some BMPs don't contain a complete palette. Avoid reading off the end. + // Some BMPs don't contain a complete palette. Truncate it instead of reading + // off the end of the palette. if (img_data_offset_ && (img_data_offset_ < table_end)) { - colors_in_palette = (img_data_offset_ - header_end) / bytes_per_color; + size_t colors_in_truncated_palette = + (img_data_offset_ - header_end) / bytes_per_color; + CHECK_LE(colors_in_truncated_palette, colors_in_palette); + colors_in_palette = colors_in_truncated_palette; table_size_in_bytes = colors_in_palette * bytes_per_color; } - // Read color table. + // If we don't have enough data to read in the whole palette yet, stop here. if ((decoded_offset_ > data_->size()) || ((data_->size() - decoded_offset_) < table_size_in_bytes)) return false; - color_table_.resize(info_header_.clr_used); + + // Read the color table. + color_table_.resize(colors_in_palette); for (size_t i = 0; i < colors_in_palette; ++i) { color_table_[i].rgb_blue = ReadUint8(0); @@ -746,12 +753,6 @@ bool BMPImageReader::ProcessColorTable() { color_table_[i].rgb_red = ReadUint8(2); decoded_offset_ += bytes_per_color; } - // Explicitly zero any colors past the end of a truncated palette. - for (size_t i = colors_in_palette; i < info_header_.clr_used; ++i) { - color_table_[i].rgb_blue = 0; - color_table_[i].rgb_green = 0; - color_table_[i].rgb_red = 0; - } // We've now decoded all the non-image data we care about. Skip anything // else before the actual raster data. @@ -827,8 +828,11 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessRLEData() { // the image. const uint8_t count = ReadUint8(0); const uint8_t code = ReadUint8(1); - if ((count || (code != 1)) && PastEndOfImage(0)) + const bool is_past_end_of_image = PastEndOfImage(0); + if ((count || (code != 1)) && is_past_end_of_image) { return kFailure; + } + // Decode. if (!count) { @@ -849,7 +853,9 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessRLEData() { (is_top_down_ ? (coord_.Y() < (parent_->Size().Height() - 1)) : (coord_.Y() > 0))) buffer_->SetHasAlpha(true); - ColorCorrectCurrentRow(); + if (!is_past_end_of_image) { + ColorCorrectCurrentRow(); + } // There's no need to move |coord_| here to trigger the caller // to call SetPixelsChanged(). If the only thing that's changed // is the alpha state, that will be properly written into the @@ -923,7 +929,7 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessRLEData() { for (wtf_size_t which = 0; coord_.X() < end_x;) { // Some images specify color values past the end of the // color table; set these pixels to black. - if (color_indexes[which] < info_header_.clr_used) + if (color_indexes[which] < color_table_.size()) SetI(color_indexes[which]); else SetRGBA(0, 0, 0, 255); @@ -997,7 +1003,7 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessNonRLEData( } } else { // See comments near the end of ProcessRLEData(). - if (color_index < info_header_.clr_used) + if (color_index < color_table_.size()) SetI(color_index); else SetRGBA(0, 0, 0, 255); @@ -1061,6 +1067,13 @@ void BMPImageReader::ColorCorrectCurrentRow() { const ColorProfileTransform* const transform = parent_->ColorTransform(); if (!transform) return; + int decoder_width = parent_->Size().Width(); + // Enforce 0 ≤ current row < bitmap height. + CHECK_GE(coord_.Y(), 0); + CHECK_LT(coord_.Y(), buffer_->Bitmap().height()); + // Enforce decoder width == bitmap width exactly. (The bitmap rowbytes might + // add a bit of padding, but we are only converting one row at a time.) + CHECK_EQ(decoder_width, buffer_->Bitmap().width()); ImageFrame::PixelData* const row = buffer_->GetAddr(0, coord_.Y()); const skcms_PixelFormat fmt = XformColorFormat(); const skcms_AlphaFormat alpha = @@ -1069,7 +1082,7 @@ void BMPImageReader::ColorCorrectCurrentRow() { : skcms_AlphaFormat_Unpremul; const bool success = skcms_Transform(row, fmt, alpha, transform->SrcProfile(), row, fmt, alpha, - transform->DstProfile(), parent_->Size().Width()); + transform->DstProfile(), decoder_width); DCHECK(success); buffer_->SetPixelsChanged(true); } diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc index a0f2c5e800..0542a9a7d4 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc @@ -115,7 +115,7 @@ void WebRtcAudioSink::OnData(const media::AudioBus& audio_bus, } void WebRtcAudioSink::OnSetFormat(const media::AudioParameters& params) { - DCHECK(params.IsValid()); + CHECK(params.IsValid()); SendLogMessage(base::StringPrintf("OnSetFormat([label=%s] {params=[%s]})", adapter_->label().c_str(), params.AsHumanReadableString().c_str())); diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_task_queue.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_task_queue.cc index 065986002f..8e89e7af82 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_task_queue.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/scheduler/worker/non_main_thread_task_queue.cc @@ -33,6 +33,10 @@ void NonMainThreadTaskQueue::OnTaskCompleted( base::sequence_manager::LazyNow* lazy_now) { // |non_main_thread_scheduler_| can be nullptr in tests. if (non_main_thread_scheduler_) { + // The last ref to `non_main_thread_scheduler_` might be released as part of + // this task's cleanup microtasks, make sure it lives through its own + // cleanup: crbug.com/1464113. + auto self_ref = WrapRefCounted(this); non_main_thread_scheduler_->OnTaskCompleted(this, task, task_timing, lazy_now); } diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc index e34b073723..c0f9268aa8 100644 --- a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc +++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator.cc @@ -162,7 +162,9 @@ static const unsigned char kAsciiLineBreakTable[][(kAsciiLineBreakTableLastChar }; // clang-format on -#if U_ICU_VERSION_MAJOR_NUM >= 58 +#if U_ICU_VERSION_MAJOR_NUM >= 74 +#define BA_LB_COUNT (U_LB_COUNT - 8) +#elif U_ICU_VERSION_MAJOR_NUM >= 58 #define BA_LB_COUNT (U_LB_COUNT - 3) #else #define BA_LB_COUNT U_LB_COUNT diff --git a/src/3rdparty/chromium/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py b/src/3rdparty/chromium/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py index fe8b5e5d61..01a2bd09e9 100755 --- a/src/3rdparty/chromium/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py +++ b/src/3rdparty/chromium/third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py @@ -36,6 +36,7 @@ 'base::CreateSequencedTaskRunner', 'base::DefaultTickClock', 'base::ElapsedTimer', + 'base::HashInts', 'base::JobDelegate', 'base::JobHandle', 'base::PostJob', diff --git a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc index 1789fa2785..0fb219311e 100644 --- a/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc +++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/snapshot/sanitized/module_snapshot_sanitized.cc @@ -97,9 +97,11 @@ ModuleSnapshotSanitized::AnnotationsSimpleMap() const { std::map annotations = snapshot_->AnnotationsSimpleMap(); if (allowed_annotations_) { - for (auto kv = annotations.begin(); kv != annotations.end(); ++kv) { - if (!KeyIsAllowed(kv->first, *allowed_annotations_)) { - annotations.erase(kv); + for (auto kv = annotations.begin(); kv != annotations.end();) { + if (KeyIsAllowed(kv->first, *allowed_annotations_)) { + ++kv; + } else { + kv = annotations.erase(kv); } } } diff --git a/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py b/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py index 5e3734d783..e3d46bd194 100644 --- a/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py +++ b/src/3rdparty/chromium/third_party/dawn/generator/generator_lib.py @@ -201,6 +201,10 @@ def _compute_python_dependencies(root_dir=None): paths = set() for path in module_paths: + # Builtin/namespaced modules may return None for the file path. + if not path: + continue + path = os.path.abspath(path) if not path.startswith(root_dir): diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn b/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn index cd488e88b6..ea1dc3d9a7 100644 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn +++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/BUILD.gn @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/python.gni") + import("//third_party/blink/public/public_features.gni") import("./all_devtools_files.gni") import("./all_devtools_modules.gni") diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/LICENSE b/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/LICENSE deleted file mode 100644 index 77a9719731..0000000000 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2012-2014 Chris Pettitt - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/README.md b/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/README.md deleted file mode 100644 index 19a09096f2..0000000000 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Rolling Dagre - -## What is dagre? -Dagre is a third-party graph layouting library, which is used by the graph visualizer of -Chrome `DevTools/web_audio`. It implements several research papers about layouting graph. -1. Size: The size of dagre.js 323 KB. The core of dagre.js is 83 KB. -2. Github repo: https://github.com/dagrejs/dagre - -## Why should we add Dagre as a module, instead of a folder under web_audio? -Dagre is used by both `DevTools/web_audio` and `DevTools/web_audio_worker`. Therefore, -it seems better to be a module that can be used as a dependency. For example, -`web_audio` constructs `dagre.graphlib.Graph` and sends to `web_audio_worker`, which is a Web Worker that runs `dagre.layout()`. - -## Updating Dagre -1. Download from https://github.com/dagrejs/dagre/blob/master/dist/dagre.js -2. Optionally add a comment "// clang-format off" at the beginning of `dagre.js`. diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/dagre.js b/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/dagre.js deleted file mode 100644 index ce56e951b2..0000000000 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/dagre_layout/dagre.js +++ /dev/null @@ -1,11500 +0,0 @@ -// clang-format off -/* eslint-disable */ -(function(f) { -if (typeof exports === 'object' && typeof module !== 'undefined') { - module.exports = f() -} else if (typeof define === 'function' && define.amd) { - define([], f) -} else { - var g; - if (typeof window !== 'undefined') { - g = window - } else if (typeof global !== 'undefined') { - g = global - } else if (typeof self !== 'undefined') { - g = self - } else { - g = this - } - g.dagre = f() -} -})(function() { -var define, module, exports; -return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c='function'==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error('Cannot find module \''+i+'\'');throw a.code='MODULE_NOT_FOUND',a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u='function'==typeof require&&require,i=0;i 0; --i) { - entry = buckets[i].dequeue(); - if (entry) { - results = results.concat(removeNode(g, buckets, zeroIdx, entry, true)); - break; - } - } - } - } - - return results; -} - -function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) { - var results = collectPredecessors ? [] : undefined; - - _.forEach(g.inEdges(entry.v), function(edge) { - var weight = g.edge(edge), - uEntry = g.node(edge.v); - - if (collectPredecessors) { - results.push({ v: edge.v, w: edge.w }); - } - - uEntry.out -= weight; - assignBucket(buckets, zeroIdx, uEntry); - }); - - _.forEach(g.outEdges(entry.v), function(edge) { - var weight = g.edge(edge), - w = edge.w, - wEntry = g.node(w); - wEntry['in'] -= weight; - assignBucket(buckets, zeroIdx, wEntry); - }); - - g.removeNode(entry.v); - - return results; -} - -function buildState(g, weightFn) { - var fasGraph = new Graph(), - maxIn = 0, - maxOut = 0; - - _.forEach(g.nodes(), function(v) { - fasGraph.setNode(v, { v: v, 'in': 0, out: 0 }); - }); - - // Aggregate weights on nodes, but also sum the weights across multi-edges - // into a single edge for the fasGraph. - _.forEach(g.edges(), function(e) { - var prevWeight = fasGraph.edge(e.v, e.w) || 0, - weight = weightFn(e), - edgeWeight = prevWeight + weight; - fasGraph.setEdge(e.v, e.w, edgeWeight); - maxOut = Math.max(maxOut, fasGraph.node(e.v).out += weight); - maxIn = Math.max(maxIn, fasGraph.node(e.w)['in'] += weight); - }); - - var buckets = _.range(maxOut + maxIn + 3).map(function() { return new List(); }); - var zeroIdx = maxIn + 1; - - _.forEach(fasGraph.nodes(), function(v) { - assignBucket(buckets, zeroIdx, fasGraph.node(v)); - }); - - return { graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx }; -} - -function assignBucket(buckets, zeroIdx, entry) { - if (!entry.out) { - buckets[0].enqueue(entry); - } else if (!entry['in']) { - buckets[buckets.length - 1].enqueue(entry); - } else { - buckets[entry.out - entry['in'] + zeroIdx].enqueue(entry); - } -} - -},{'./data/list':5,'./graphlib':7,'./lodash':10}],9:[function(require,module,exports){ -'use strict'; - -var _ = require('./lodash'), - acyclic = require('./acyclic'), - normalize = require('./normalize'), - rank = require('./rank'), - normalizeRanks = require('./util').normalizeRanks, - parentDummyChains = require('./parent-dummy-chains'), - removeEmptyRanks = require('./util').removeEmptyRanks, - nestingGraph = require('./nesting-graph'), - addBorderSegments = require('./add-border-segments'), - coordinateSystem = require('./coordinate-system'), - order = require('./order'), - position = require('./position'), - util = require('./util'), - Graph = require('./graphlib').Graph; - -module.exports = layout; - -function layout(g, opts) { - var time = opts && opts.debugTiming ? util.time : util.notime; - time('layout', function() { - var layoutGraph = time(' buildLayoutGraph', - function() { return buildLayoutGraph(g); }); - time(' runLayout', function() { runLayout(layoutGraph, time); }); - time(' updateInputGraph', function() { updateInputGraph(g, layoutGraph); }); - }); -} - -function runLayout(g, time) { - time(' makeSpaceForEdgeLabels', function() { makeSpaceForEdgeLabels(g); }); - time(' removeSelfEdges', function() { removeSelfEdges(g); }); - time(' acyclic', function() { acyclic.run(g); }); - time(' nestingGraph.run', function() { nestingGraph.run(g); }); - time(' rank', function() { rank(util.asNonCompoundGraph(g)); }); - time(' injectEdgeLabelProxies', function() { injectEdgeLabelProxies(g); }); - time(' removeEmptyRanks', function() { removeEmptyRanks(g); }); - time(' nestingGraph.cleanup', function() { nestingGraph.cleanup(g); }); - time(' normalizeRanks', function() { normalizeRanks(g); }); - time(' assignRankMinMax', function() { assignRankMinMax(g); }); - time(' removeEdgeLabelProxies', function() { removeEdgeLabelProxies(g); }); - time(' normalize.run', function() { normalize.run(g); }); - time(' parentDummyChains', function() { parentDummyChains(g); }); - time(' addBorderSegments', function() { addBorderSegments(g); }); - time(' order', function() { order(g); }); - time(' insertSelfEdges', function() { insertSelfEdges(g); }); - time(' adjustCoordinateSystem', function() { coordinateSystem.adjust(g); }); - time(' position', function() { position(g); }); - time(' positionSelfEdges', function() { positionSelfEdges(g); }); - time(' removeBorderNodes', function() { removeBorderNodes(g); }); - time(' normalize.undo', function() { normalize.undo(g); }); - time(' fixupEdgeLabelCoords', function() { fixupEdgeLabelCoords(g); }); - time(' undoCoordinateSystem', function() { coordinateSystem.undo(g); }); - time(' translateGraph', function() { translateGraph(g); }); - time(' assignNodeIntersects', function() { assignNodeIntersects(g); }); - time(' reversePoints', function() { reversePointsForReversedEdges(g); }); - time(' acyclic.undo', function() { acyclic.undo(g); }); -} - -/* - * Copies final layout information from the layout graph back to the input - * graph. This process only copies allowlisted attributes from the layout - * graph to the input graph, so it serves as a good place to determine what - * attributes can influence layout. - */ -function updateInputGraph(inputGraph, layoutGraph) { - _.forEach(inputGraph.nodes(), function(v) { - var inputLabel = inputGraph.node(v), - layoutLabel = layoutGraph.node(v); - - if (inputLabel) { - inputLabel.x = layoutLabel.x; - inputLabel.y = layoutLabel.y; - - if (layoutGraph.children(v).length) { - inputLabel.width = layoutLabel.width; - inputLabel.height = layoutLabel.height; - } - } - }); - - _.forEach(inputGraph.edges(), function(e) { - var inputLabel = inputGraph.edge(e), - layoutLabel = layoutGraph.edge(e); - - inputLabel.points = layoutLabel.points; - if (_.has(layoutLabel, 'x')) { - inputLabel.x = layoutLabel.x; - inputLabel.y = layoutLabel.y; - } - }); - - inputGraph.graph().width = layoutGraph.graph().width; - inputGraph.graph().height = layoutGraph.graph().height; -} - -var graphNumAttrs = ['nodesep', 'edgesep', 'ranksep', 'marginx', 'marginy'], - graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: 'tb' }, - graphAttrs = ['acyclicer', 'ranker', 'rankdir', 'align'], - nodeNumAttrs = ['width', 'height'], - nodeDefaults = { width: 0, height: 0 }, - edgeNumAttrs = ['minlen', 'weight', 'width', 'height', 'labeloffset'], - edgeDefaults = { - minlen: 1, weight: 1, width: 0, height: 0, - labeloffset: 10, labelpos: 'r' - }, - edgeAttrs = ['labelpos']; - -/* - * Constructs a new graph from the input graph, which can be used for layout. - * This process copies only allowlisted attributes from the input graph to the - * layout graph. Thus this function serves as a good place to determine what - * attributes can influence layout. - */ -function buildLayoutGraph(inputGraph) { - var g = new Graph({ multigraph: true, compound: true }), - graph = canonicalize(inputGraph.graph()); - - g.setGraph(_.merge({}, - graphDefaults, - selectNumberAttrs(graph, graphNumAttrs), - _.pick(graph, graphAttrs))); - - _.forEach(inputGraph.nodes(), function(v) { - var node = canonicalize(inputGraph.node(v)); - g.setNode(v, _.defaults(selectNumberAttrs(node, nodeNumAttrs), nodeDefaults)); - g.setParent(v, inputGraph.parent(v)); - }); - - _.forEach(inputGraph.edges(), function(e) { - var edge = canonicalize(inputGraph.edge(e)); - g.setEdge(e, _.merge({}, - edgeDefaults, - selectNumberAttrs(edge, edgeNumAttrs), - _.pick(edge, edgeAttrs))); - }); - - return g; -} - -/* - * This idea comes from the Gansner paper: to account for edge labels in our - * layout we split each rank in half by doubling minlen and halving ranksep. - * Then we can place labels at these mid-points between nodes. - * - * We also add some minimal padding to the width to push the label for the edge - * away from the edge itself a bit. - */ -function makeSpaceForEdgeLabels(g) { - var graph = g.graph(); - graph.ranksep /= 2; - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - edge.minlen *= 2; - if (edge.labelpos.toLowerCase() !== 'c') { - if (graph.rankdir === 'TB' || graph.rankdir === 'BT') { - edge.width += edge.labeloffset; - } else { - edge.height += edge.labeloffset; - } - } - }); -} - -/* - * Creates temporary dummy nodes that capture the rank in which each edge's - * label is going to, if it has one of non-zero width and height. We do this - * so that we can safely remove empty ranks while preserving balance for the - * label's position. - */ -function injectEdgeLabelProxies(g) { - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - if (edge.width && edge.height) { - var v = g.node(e.v), - w = g.node(e.w), - label = { rank: (w.rank - v.rank) / 2 + v.rank, e: e }; - util.addDummyNode(g, 'edge-proxy', label, '_ep'); - } - }); -} - -function assignRankMinMax(g) { - var maxRank = 0; - _.forEach(g.nodes(), function(v) { - var node = g.node(v); - if (node.borderTop) { - node.minRank = g.node(node.borderTop).rank; - node.maxRank = g.node(node.borderBottom).rank; - maxRank = _.max(maxRank, node.maxRank); - } - }); - g.graph().maxRank = maxRank; -} - -function removeEdgeLabelProxies(g) { - _.forEach(g.nodes(), function(v) { - var node = g.node(v); - if (node.dummy === 'edge-proxy') { - g.edge(node.e).labelRank = node.rank; - g.removeNode(v); - } - }); -} - -function translateGraph(g) { - var minX = Number.POSITIVE_INFINITY, - maxX = 0, - minY = Number.POSITIVE_INFINITY, - maxY = 0, - graphLabel = g.graph(), - marginX = graphLabel.marginx || 0, - marginY = graphLabel.marginy || 0; - - function getExtremes(attrs) { - var x = attrs.x, - y = attrs.y, - w = attrs.width, - h = attrs.height; - minX = Math.min(minX, x - w / 2); - maxX = Math.max(maxX, x + w / 2); - minY = Math.min(minY, y - h / 2); - maxY = Math.max(maxY, y + h / 2); - } - - _.forEach(g.nodes(), function(v) { getExtremes(g.node(v)); }); - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - if (_.has(edge, 'x')) { - getExtremes(edge); - } - }); - - minX -= marginX; - minY -= marginY; - - _.forEach(g.nodes(), function(v) { - var node = g.node(v); - node.x -= minX; - node.y -= minY; - }); - - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - _.forEach(edge.points, function(p) { - p.x -= minX; - p.y -= minY; - }); - if (_.has(edge, 'x')) { edge.x -= minX; } - if (_.has(edge, 'y')) { edge.y -= minY; } - }); - - graphLabel.width = maxX - minX + marginX; - graphLabel.height = maxY - minY + marginY; -} - -function assignNodeIntersects(g) { - _.forEach(g.edges(), function(e) { - var edge = g.edge(e), - nodeV = g.node(e.v), - nodeW = g.node(e.w), - p1, p2; - if (!edge.points) { - edge.points = []; - p1 = nodeW; - p2 = nodeV; - } else { - p1 = edge.points[0]; - p2 = edge.points[edge.points.length - 1]; - } - edge.points.unshift(util.intersectRect(nodeV, p1)); - edge.points.push(util.intersectRect(nodeW, p2)); - }); -} - -function fixupEdgeLabelCoords(g) { - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - if (_.has(edge, 'x')) { - if (edge.labelpos === 'l' || edge.labelpos === 'r') { - edge.width -= edge.labeloffset; - } - switch (edge.labelpos) { - case 'l': edge.x -= edge.width / 2 + edge.labeloffset; break; - case 'r': edge.x += edge.width / 2 + edge.labeloffset; break; - } - } - }); -} - -function reversePointsForReversedEdges(g) { - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - if (edge.reversed) { - edge.points.reverse(); - } - }); -} - -function removeBorderNodes(g) { - _.forEach(g.nodes(), function(v) { - if (g.children(v).length) { - var node = g.node(v), - t = g.node(node.borderTop), - b = g.node(node.borderBottom), - l = g.node(_.last(node.borderLeft)), - r = g.node(_.last(node.borderRight)); - - node.width = Math.abs(r.x - l.x); - node.height = Math.abs(b.y - t.y); - node.x = l.x + node.width / 2; - node.y = t.y + node.height / 2; - } - }); - - _.forEach(g.nodes(), function(v) { - if (g.node(v).dummy === 'border') { - g.removeNode(v); - } - }); -} - -function removeSelfEdges(g) { - _.forEach(g.edges(), function(e) { - if (e.v === e.w) { - var node = g.node(e.v); - if (!node.selfEdges) { - node.selfEdges = []; - } - node.selfEdges.push({ e: e, label: g.edge(e) }); - g.removeEdge(e); - } - }); -} - -function insertSelfEdges(g) { - var layers = util.buildLayerMatrix(g); - _.forEach(layers, function(layer) { - var orderShift = 0; - _.forEach(layer, function(v, i) { - var node = g.node(v); - node.order = i + orderShift; - _.forEach(node.selfEdges, function(selfEdge) { - util.addDummyNode(g, 'selfedge', { - width: selfEdge.label.width, - height: selfEdge.label.height, - rank: node.rank, - order: i + (++orderShift), - e: selfEdge.e, - label: selfEdge.label - }, '_se'); - }); - delete node.selfEdges; - }); - }); -} - -function positionSelfEdges(g) { - _.forEach(g.nodes(), function(v) { - var node = g.node(v); - if (node.dummy === 'selfedge') { - var selfNode = g.node(node.e.v), - x = selfNode.x + selfNode.width / 2, - y = selfNode.y, - dx = node.x - x, - dy = selfNode.height / 2; - g.setEdge(node.e, node.label); - g.removeNode(v); - node.label.points = [ - { x: x + 2 * dx / 3, y: y - dy }, - { x: x + 5 * dx / 6, y: y - dy }, - { x: x + dx , y: y }, - { x: x + 5 * dx / 6, y: y + dy }, - { x: x + 2 * dx / 3, y: y + dy } - ]; - node.label.x = node.x; - node.label.y = node.y; - } - }); -} - -function selectNumberAttrs(obj, attrs) { - return _.mapValues(_.pick(obj, attrs), Number); -} - -function canonicalize(attrs) { - var newAttrs = {}; - _.forEach(attrs, function(v, k) { - newAttrs[k.toLowerCase()] = v; - }); - return newAttrs; -} - -},{'./acyclic':2,'./add-border-segments':3,'./coordinate-system':4,'./graphlib':7,'./lodash':10,'./nesting-graph':11,'./normalize':12,'./order':17,'./parent-dummy-chains':22,'./position':24,'./rank':26,'./util':29}],10:[function(require,module,exports){ -/* global window */ - -var lodash; - -if (typeof require === 'function') { - try { - lodash = { - cloneDeep: require('lodash/cloneDeep'), - constant: require('lodash/constant'), - defaults: require('lodash/defaults'), - each: require('lodash/each'), - filter: require('lodash/filter'), - find: require('lodash/find'), - flatten: require('lodash/flatten'), - forEach: require('lodash/forEach'), - forIn: require('lodash/forIn'), - has: require('lodash/has'), - isUndefined: require('lodash/isUndefined'), - last: require('lodash/last'), - map: require('lodash/map'), - mapValues: require('lodash/mapValues'), - max: require('lodash/max'), - merge: require('lodash/merge'), - min: require('lodash/min'), - minBy: require('lodash/minBy'), - now: require('lodash/now'), - pick: require('lodash/pick'), - range: require('lodash/range'), - reduce: require('lodash/reduce'), - sortBy: require('lodash/sortBy'), - uniqueId: require('lodash/uniqueId'), - values: require('lodash/values'), - zipObject: require('lodash/zipObject'), - }; - } catch (e) {} -} - -if (!lodash) { - lodash = window._; -} - -module.exports = lodash; - -},{'lodash/cloneDeep':227,'lodash/constant':228,'lodash/defaults':229,'lodash/each':230,'lodash/filter':232,'lodash/find':233,'lodash/flatten':235,'lodash/forEach':236,'lodash/forIn':237,'lodash/has':239,'lodash/isUndefined':258,'lodash/last':261,'lodash/map':262,'lodash/mapValues':263,'lodash/max':264,'lodash/merge':266,'lodash/min':267,'lodash/minBy':268,'lodash/now':270,'lodash/pick':271,'lodash/range':273,'lodash/reduce':274,'lodash/sortBy':276,'lodash/uniqueId':286,'lodash/values':287,'lodash/zipObject':288}],11:[function(require,module,exports){ -var _ = require('./lodash'), - util = require('./util'); - -module.exports = { - run: run, - cleanup: cleanup -}; - -/* - * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs, - * adds appropriate edges to ensure that all cluster nodes are placed between - * these boundries, and ensures that the graph is connected. - * - * In addition we ensure, through the use of the minlen property, that nodes - * and subgraph border nodes to not end up on the same rank. - * - * Preconditions: - * - * 1. Input graph is a DAG - * 2. Nodes in the input graph has a minlen attribute - * - * Postconditions: - * - * 1. Input graph is connected. - * 2. Dummy nodes are added for the tops and bottoms of subgraphs. - * 3. The minlen attribute for nodes is adjusted to ensure nodes do not - * get placed on the same rank as subgraph border nodes. - * - * The nesting graph idea comes from Sander, "Layout of Compound Directed - * Graphs." - */ -function run(g) { - var root = util.addDummyNode(g, 'root', {}, '_root'); - var depths = treeDepths(g); - var height = _.max(_.values(depths)) - 1; // Note: depths is an Object not an array - var nodeSep = 2 * height + 1; - - g.graph().nestingRoot = root; - - // Multiply minlen by nodeSep to align nodes on non-border ranks. - _.forEach(g.edges(), function(e) { g.edge(e).minlen *= nodeSep; }); - - // Calculate a weight that is sufficient to keep subgraphs vertically compact - var weight = sumWeights(g) + 1; - - // Create border nodes and link them up - _.forEach(g.children(), function(child) { - dfs(g, root, nodeSep, weight, height, depths, child); - }); - - // Save the multiplier for node layers for later removal of empty border - // layers. - g.graph().nodeRankFactor = nodeSep; -} - -function dfs(g, root, nodeSep, weight, height, depths, v) { - var children = g.children(v); - if (!children.length) { - if (v !== root) { - g.setEdge(root, v, { weight: 0, minlen: nodeSep }); - } - return; - } - - var top = util.addBorderNode(g, '_bt'), - bottom = util.addBorderNode(g, '_bb'), - label = g.node(v); - - g.setParent(top, v); - label.borderTop = top; - g.setParent(bottom, v); - label.borderBottom = bottom; - - _.forEach(children, function(child) { - dfs(g, root, nodeSep, weight, height, depths, child); - - var childNode = g.node(child), - childTop = childNode.borderTop ? childNode.borderTop : child, - childBottom = childNode.borderBottom ? childNode.borderBottom : child, - thisWeight = childNode.borderTop ? weight : 2 * weight, - minlen = childTop !== childBottom ? 1 : height - depths[v] + 1; - - g.setEdge(top, childTop, { - weight: thisWeight, - minlen: minlen, - nestingEdge: true - }); - - g.setEdge(childBottom, bottom, { - weight: thisWeight, - minlen: minlen, - nestingEdge: true - }); - }); - - if (!g.parent(v)) { - g.setEdge(root, top, { weight: 0, minlen: height + depths[v] }); - } -} - -function treeDepths(g) { - var depths = {}; - function dfs(v, depth) { - var children = g.children(v); - if (children && children.length) { - _.forEach(children, function(child) { - dfs(child, depth + 1); - }); - } - depths[v] = depth; - } - _.forEach(g.children(), function(v) { dfs(v, 1); }); - return depths; -} - -function sumWeights(g) { - return _.reduce(g.edges(), function(acc, e) { - return acc + g.edge(e).weight; - }, 0); -} - -function cleanup(g) { - var graphLabel = g.graph(); - g.removeNode(graphLabel.nestingRoot); - delete graphLabel.nestingRoot; - _.forEach(g.edges(), function(e) { - var edge = g.edge(e); - if (edge.nestingEdge) { - g.removeEdge(e); - } - }); -} - -},{'./lodash':10,'./util':29}],12:[function(require,module,exports){ -'use strict'; - -var _ = require('./lodash'), - util = require('./util'); - -module.exports = { - run: run, - undo: undo -}; - -/* - * Breaks any long edges in the graph into short segments that span 1 layer - * each. This operation is undoable with the denormalize function. - * - * Pre-conditions: - * - * 1. The input graph is a DAG. - * 2. Each node in the graph has a "rank" property. - * - * Post-condition: - * - * 1. All edges in the graph have a length of 1. - * 2. Dummy nodes are added where edges have been split into segments. - * 3. The graph is augmented with a "dummyChains" attribute which contains - * the first dummy in each chain of dummy nodes produced. - */ -function run(g) { - g.graph().dummyChains = []; - _.forEach(g.edges(), function(edge) { normalizeEdge(g, edge); }); -} - -function normalizeEdge(g, e) { - var v = e.v, - vRank = g.node(v).rank, - w = e.w, - wRank = g.node(w).rank, - name = e.name, - edgeLabel = g.edge(e), - labelRank = edgeLabel.labelRank; - - if (wRank === vRank + 1) return; - - g.removeEdge(e); - - var dummy, attrs, i; - for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) { - edgeLabel.points = []; - attrs = { - width: 0, height: 0, - edgeLabel: edgeLabel, edgeObj: e, - rank: vRank - }; - dummy = util.addDummyNode(g, 'edge', attrs, '_d'); - if (vRank === labelRank) { - attrs.width = edgeLabel.width; - attrs.height = edgeLabel.height; - attrs.dummy = 'edge-label'; - attrs.labelpos = edgeLabel.labelpos; - } - g.setEdge(v, dummy, { weight: edgeLabel.weight }, name); - if (i === 0) { - g.graph().dummyChains.push(dummy); - } - v = dummy; - } - - g.setEdge(v, w, { weight: edgeLabel.weight }, name); -} - -function undo(g) { - _.forEach(g.graph().dummyChains, function(v) { - var node = g.node(v), - origLabel = node.edgeLabel, - w; - g.setEdge(node.edgeObj, origLabel); - while (node.dummy) { - w = g.successors(v)[0]; - g.removeNode(v); - origLabel.points.push({ x: node.x, y: node.y }); - if (node.dummy === 'edge-label') { - origLabel.x = node.x; - origLabel.y = node.y; - origLabel.width = node.width; - origLabel.height = node.height; - } - v = w; - node = g.node(v); - } - }); -} - -},{'./lodash':10,'./util':29}],13:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = addSubgraphConstraints; - -function addSubgraphConstraints(g, cg, vs) { - var prev = {}, - rootPrev; - - _.forEach(vs, function(v) { - var child = g.parent(v), - parent, - prevChild; - while (child) { - parent = g.parent(child); - if (parent) { - prevChild = prev[parent]; - prev[parent] = child; - } else { - prevChild = rootPrev; - rootPrev = child; - } - if (prevChild && prevChild !== child) { - cg.setEdge(prevChild, child); - return; - } - child = parent; - } - }); - - /* - function dfs(v) { - var children = v ? g.children(v) : g.children(); - if (children.length) { - var min = Number.POSITIVE_INFINITY, - subgraphs = []; - _.each(children, function(child) { - var childMin = dfs(child); - if (g.children(child).length) { - subgraphs.push({ v: child, order: childMin }); - } - min = Math.min(min, childMin); - }); - _.reduce(_.sortBy(subgraphs, "order"), function(prev, curr) { - cg.setEdge(prev.v, curr.v); - return curr; - }); - return min; - } - return g.node(v).order; - } - dfs(undefined); - */ -} - -},{'../lodash':10}],14:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = barycenter; - -function barycenter(g, movable) { - return _.map(movable, function(v) { - var inV = g.inEdges(v); - if (!inV.length) { - return { v: v }; - } else { - var result = _.reduce(inV, function(acc, e) { - var edge = g.edge(e), - nodeU = g.node(e.v); - return { - sum: acc.sum + (edge.weight * nodeU.order), - weight: acc.weight + edge.weight - }; - }, { sum: 0, weight: 0 }); - - return { - v: v, - barycenter: result.sum / result.weight, - weight: result.weight - }; - } - }); -} - - -},{'../lodash':10}],15:[function(require,module,exports){ -var _ = require('../lodash'), - Graph = require('../graphlib').Graph; - -module.exports = buildLayerGraph; - -/* - * Constructs a graph that can be used to sort a layer of nodes. The graph will - * contain all base and subgraph nodes from the request layer in their original - * hierarchy and any edges that are incident on these nodes and are of the type - * requested by the "relationship" parameter. - * - * Nodes from the requested rank that do not have parents are assigned a root - * node in the output graph, which is set in the root graph attribute. This - * makes it easy to walk the hierarchy of movable nodes during ordering. - * - * Pre-conditions: - * - * 1. Input graph is a DAG - * 2. Base nodes in the input graph have a rank attribute - * 3. Subgraph nodes in the input graph has minRank and maxRank attributes - * 4. Edges have an assigned weight - * - * Post-conditions: - * - * 1. Output graph has all nodes in the movable rank with preserved - * hierarchy. - * 2. Root nodes in the movable layer are made children of the node - * indicated by the root attribute of the graph. - * 3. Non-movable nodes incident on movable nodes, selected by the - * relationship parameter, are included in the graph (without hierarchy). - * 4. Edges incident on movable nodes, selected by the relationship - * parameter, are added to the output graph. - * 5. The weights for copied edges are aggregated as need, since the output - * graph is not a multi-graph. - */ -function buildLayerGraph(g, rank, relationship) { - var root = createRootNode(g), - result = new Graph({ compound: true }).setGraph({ root: root }) - .setDefaultNodeLabel(function(v) { return g.node(v); }); - - _.forEach(g.nodes(), function(v) { - var node = g.node(v), - parent = g.parent(v); - - if (node.rank === rank || node.minRank <= rank && rank <= node.maxRank) { - result.setNode(v); - result.setParent(v, parent || root); - - // This assumes we have only short edges! - _.forEach(g[relationship](v), function(e) { - var u = e.v === v ? e.w : e.v, - edge = result.edge(u, v), - weight = !_.isUndefined(edge) ? edge.weight : 0; - result.setEdge(u, v, { weight: g.edge(e).weight + weight }); - }); - - if (_.has(node, 'minRank')) { - result.setNode(v, { - borderLeft: node.borderLeft[rank], - borderRight: node.borderRight[rank] - }); - } - } - }); - - return result; -} - -function createRootNode(g) { - var v; - while (g.hasNode((v = _.uniqueId('_root')))); - return v; -} - -},{'../graphlib':7,'../lodash':10}],16:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'); - -module.exports = crossCount; - -/* - * A function that takes a layering (an array of layers, each with an array of - * ordererd nodes) and a graph and returns a weighted crossing count. - * - * Pre-conditions: - * - * 1. Input graph must be simple (not a multigraph), directed, and include - * only simple edges. - * 2. Edges in the input graph must have assigned weights. - * - * Post-conditions: - * - * 1. The graph and layering matrix are left unchanged. - * - * This algorithm is derived from Barth, et al., "Bilayer Cross Counting." - */ -function crossCount(g, layering) { - var cc = 0; - for (var i = 1; i < layering.length; ++i) { - cc += twoLayerCrossCount(g, layering[i-1], layering[i]); - } - return cc; -} - -function twoLayerCrossCount(g, northLayer, southLayer) { - // Sort all of the edges between the north and south layers by their position - // in the north layer and then the south. Map these edges to the position of - // their head in the south layer. - var southPos = _.zipObject(southLayer, - _.map(southLayer, function (v, i) { return i; })); - var southEntries = _.flatten(_.map(northLayer, function(v) { - return _.sortBy(_.map(g.outEdges(v), function(e) { - return { pos: southPos[e.w], weight: g.edge(e).weight }; - }), 'pos'); - }), true); - - // Build the accumulator tree - var firstIndex = 1; - while (firstIndex < southLayer.length) firstIndex <<= 1; - var treeSize = 2 * firstIndex - 1; - firstIndex -= 1; - var tree = _.map(new Array(treeSize), function() { return 0; }); - - // Calculate the weighted crossings - var cc = 0; - _.forEach(southEntries.forEach(function(entry) { - var index = entry.pos + firstIndex; - tree[index] += entry.weight; - var weightSum = 0; - while (index > 0) { - if (index % 2) { - weightSum += tree[index + 1]; - } - index = (index - 1) >> 1; - tree[index] += entry.weight; - } - cc += entry.weight * weightSum; - })); - - return cc; -} - -},{'../lodash':10}],17:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'), - initOrder = require('./init-order'), - crossCount = require('./cross-count'), - sortSubgraph = require('./sort-subgraph'), - buildLayerGraph = require('./build-layer-graph'), - addSubgraphConstraints = require('./add-subgraph-constraints'), - Graph = require('../graphlib').Graph, - util = require('../util'); - -module.exports = order; - -/* - * Applies heuristics to minimize edge crossings in the graph and sets the best - * order solution as an order attribute on each node. - * - * Pre-conditions: - * - * 1. Graph must be DAG - * 2. Graph nodes must be objects with a "rank" attribute - * 3. Graph edges must have the "weight" attribute - * - * Post-conditions: - * - * 1. Graph nodes will have an "order" attribute based on the results of the - * algorithm. - */ -function order(g) { - var maxRank = util.maxRank(g), - downLayerGraphs = buildLayerGraphs(g, _.range(1, maxRank + 1), 'inEdges'), - upLayerGraphs = buildLayerGraphs(g, _.range(maxRank - 1, -1, -1), 'outEdges'); - - var layering = initOrder(g); - assignOrder(g, layering); - - var bestCC = Number.POSITIVE_INFINITY, - best; - - for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) { - sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2); - - layering = util.buildLayerMatrix(g); - var cc = crossCount(g, layering); - if (cc < bestCC) { - lastBest = 0; - best = _.cloneDeep(layering); - bestCC = cc; - } - } - - assignOrder(g, best); -} - -function buildLayerGraphs(g, ranks, relationship) { - return _.map(ranks, function(rank) { - return buildLayerGraph(g, rank, relationship); - }); -} - -function sweepLayerGraphs(layerGraphs, biasRight) { - var cg = new Graph(); - _.forEach(layerGraphs, function(lg) { - var root = lg.graph().root; - var sorted = sortSubgraph(lg, root, cg, biasRight); - _.forEach(sorted.vs, function(v, i) { - lg.node(v).order = i; - }); - addSubgraphConstraints(lg, cg, sorted.vs); - }); -} - -function assignOrder(g, layering) { - _.forEach(layering, function(layer) { - _.forEach(layer, function(v, i) { - g.node(v).order = i; - }); - }); -} - -},{'../graphlib':7,'../lodash':10,'../util':29,'./add-subgraph-constraints':13,'./build-layer-graph':15,'./cross-count':16,'./init-order':18,'./sort-subgraph':20}],18:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'); - -module.exports = initOrder; - -/* - * Assigns an initial order value for each node by performing a DFS search - * starting from nodes in the first rank. Nodes are assigned an order in their - * rank as they are first visited. - * - * This approach comes from Gansner, et al., "A Technique for Drawing Directed - * Graphs." - * - * Returns a layering matrix with an array per layer and each layer sorted by - * the order of its nodes. - */ -function initOrder(g) { - var visited = {}, - simpleNodes = _.filter(g.nodes(), function(v) { - return !g.children(v).length; - }), - maxRank = _.max(_.map(simpleNodes, function(v) { return g.node(v).rank; })), - layers = _.map(_.range(maxRank + 1), function() { return []; }); - - function dfs(v) { - if (_.has(visited, v)) return; - visited[v] = true; - var node = g.node(v); - layers[node.rank].push(v); - _.forEach(g.successors(v), dfs); - } - - var orderedVs = _.sortBy(simpleNodes, function(v) { return g.node(v).rank; }); - _.forEach(orderedVs, dfs); - - return layers; -} - -},{'../lodash':10}],19:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'); - -module.exports = resolveConflicts; - -/* - * Given a list of entries of the form {v, barycenter, weight} and a - * constraint graph this function will resolve any conflicts between the - * constraint graph and the barycenters for the entries. If the barycenters for - * an entry would violate a constraint in the constraint graph then we coalesce - * the nodes in the conflict into a new node that respects the contraint and - * aggregates barycenter and weight information. - * - * This implementation is based on the description in Forster, "A Fast and - * Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it - * differs in some specific details. - * - * Pre-conditions: - * - * 1. Each entry has the form {v, barycenter, weight}, or if the node has - * no barycenter, then {v}. - * - * Returns: - * - * A new list of entries of the form {vs, i, barycenter, weight}. The list - * `vs` may either be a singleton or it may be an aggregation of nodes - * ordered such that they do not violate constraints from the constraint - * graph. The property `i` is the lowest original index of any of the - * elements in `vs`. - */ -function resolveConflicts(entries, cg) { - var mappedEntries = {}; - _.forEach(entries, function(entry, i) { - var tmp = mappedEntries[entry.v] = { - indegree: 0, - 'in': [], - out: [], - vs: [entry.v], - i: i - }; - if (!_.isUndefined(entry.barycenter)) { - tmp.barycenter = entry.barycenter; - tmp.weight = entry.weight; - } - }); - - _.forEach(cg.edges(), function(e) { - var entryV = mappedEntries[e.v], - entryW = mappedEntries[e.w]; - if (!_.isUndefined(entryV) && !_.isUndefined(entryW)) { - entryW.indegree++; - entryV.out.push(mappedEntries[e.w]); - } - }); - - var sourceSet = _.filter(mappedEntries, function(entry) { - return !entry.indegree; - }); - - return doResolveConflicts(sourceSet); -} - -function doResolveConflicts(sourceSet) { - var entries = []; - - function handleIn(vEntry) { - return function(uEntry) { - if (uEntry.merged) { - return; - } - if (_.isUndefined(uEntry.barycenter) || - _.isUndefined(vEntry.barycenter) || - uEntry.barycenter >= vEntry.barycenter) { - mergeEntries(vEntry, uEntry); - } - }; - } - - function handleOut(vEntry) { - return function(wEntry) { - wEntry['in'].push(vEntry); - if (--wEntry.indegree === 0) { - sourceSet.push(wEntry); - } - }; - } - - while (sourceSet.length) { - var entry = sourceSet.pop(); - entries.push(entry); - _.forEach(entry['in'].reverse(), handleIn(entry)); - _.forEach(entry.out, handleOut(entry)); - } - - return _.map(_.filter(entries, function(entry) { return !entry.merged; }), - function(entry) { - return _.pick(entry, ['vs', 'i', 'barycenter', 'weight']); - }); - -} - -function mergeEntries(target, source) { - var sum = 0, - weight = 0; - - if (target.weight) { - sum += target.barycenter * target.weight; - weight += target.weight; - } - - if (source.weight) { - sum += source.barycenter * source.weight; - weight += source.weight; - } - - target.vs = source.vs.concat(target.vs); - target.barycenter = sum / weight; - target.weight = weight; - target.i = Math.min(source.i, target.i); - source.merged = true; -} - -},{'../lodash':10}],20:[function(require,module,exports){ -var _ = require('../lodash'), - barycenter = require('./barycenter'), - resolveConflicts = require('./resolve-conflicts'), - sort = require('./sort'); - -module.exports = sortSubgraph; - -function sortSubgraph(g, v, cg, biasRight) { - var movable = g.children(v), - node = g.node(v), - bl = node ? node.borderLeft : undefined, - br = node ? node.borderRight: undefined, - subgraphs = {}; - - if (bl) { - movable = _.filter(movable, function(w) { - return w !== bl && w !== br; - }); - } - - var barycenters = barycenter(g, movable); - _.forEach(barycenters, function(entry) { - if (g.children(entry.v).length) { - var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight); - subgraphs[entry.v] = subgraphResult; - if (_.has(subgraphResult, 'barycenter')) { - mergeBarycenters(entry, subgraphResult); - } - } - }); - - var entries = resolveConflicts(barycenters, cg); - expandSubgraphs(entries, subgraphs); - - var result = sort(entries, biasRight); - - if (bl) { - result.vs = _.flatten([bl, result.vs, br], true); - if (g.predecessors(bl).length) { - var blPred = g.node(g.predecessors(bl)[0]), - brPred = g.node(g.predecessors(br)[0]); - if (!_.has(result, 'barycenter')) { - result.barycenter = 0; - result.weight = 0; - } - result.barycenter = (result.barycenter * result.weight + - blPred.order + brPred.order) / (result.weight + 2); - result.weight += 2; - } - } - - return result; -} - -function expandSubgraphs(entries, subgraphs) { - _.forEach(entries, function(entry) { - entry.vs = _.flatten(entry.vs.map(function(v) { - if (subgraphs[v]) { - return subgraphs[v].vs; - } - return v; - }), true); - }); -} - -function mergeBarycenters(target, other) { - if (!_.isUndefined(target.barycenter)) { - target.barycenter = (target.barycenter * target.weight + - other.barycenter * other.weight) / - (target.weight + other.weight); - target.weight += other.weight; - } else { - target.barycenter = other.barycenter; - target.weight = other.weight; - } -} - -},{'../lodash':10,'./barycenter':14,'./resolve-conflicts':19,'./sort':21}],21:[function(require,module,exports){ -var _ = require('../lodash'), - util = require('../util'); - -module.exports = sort; - -function sort(entries, biasRight) { - var parts = util.partition(entries, function(entry) { - return _.has(entry, 'barycenter'); - }); - var sortable = parts.lhs, - unsortable = _.sortBy(parts.rhs, function(entry) { return -entry.i; }), - vs = [], - sum = 0, - weight = 0, - vsIndex = 0; - - sortable.sort(compareWithBias(!!biasRight)); - - vsIndex = consumeUnsortable(vs, unsortable, vsIndex); - - _.forEach(sortable, function (entry) { - vsIndex += entry.vs.length; - vs.push(entry.vs); - sum += entry.barycenter * entry.weight; - weight += entry.weight; - vsIndex = consumeUnsortable(vs, unsortable, vsIndex); - }); - - var result = { vs: _.flatten(vs, true) }; - if (weight) { - result.barycenter = sum / weight; - result.weight = weight; - } - return result; -} - -function consumeUnsortable(vs, unsortable, index) { - var last; - while (unsortable.length && (last = _.last(unsortable)).i <= index) { - unsortable.pop(); - vs.push(last.vs); - index++; - } - return index; -} - -function compareWithBias(bias) { - return function(entryV, entryW) { - if (entryV.barycenter < entryW.barycenter) { - return -1; - } else if (entryV.barycenter > entryW.barycenter) { - return 1; - } - - return !bias ? entryV.i - entryW.i : entryW.i - entryV.i; - }; -} - -},{'../lodash':10,'../util':29}],22:[function(require,module,exports){ -var _ = require('./lodash'); - -module.exports = parentDummyChains; - -function parentDummyChains(g) { - var postorderNums = postorder(g); - - _.forEach(g.graph().dummyChains, function(v) { - var node = g.node(v), - edgeObj = node.edgeObj, - pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w), - path = pathData.path, - lca = pathData.lca, - pathIdx = 0, - pathV = path[pathIdx], - ascending = true; - - while (v !== edgeObj.w) { - node = g.node(v); - - if (ascending) { - while ((pathV = path[pathIdx]) !== lca && - g.node(pathV).maxRank < node.rank) { - pathIdx++; - } - - if (pathV === lca) { - ascending = false; - } - } - - if (!ascending) { - while (pathIdx < path.length - 1 && - g.node(pathV = path[pathIdx + 1]).minRank <= node.rank) { - pathIdx++; - } - pathV = path[pathIdx]; - } - - g.setParent(v, pathV); - v = g.successors(v)[0]; - } - }); -} - -// Find a path from v to w through the lowest common ancestor (LCA). Return the -// full path and the LCA. -function findPath(g, postorderNums, v, w) { - var vPath = [], - wPath = [], - low = Math.min(postorderNums[v].low, postorderNums[w].low), - lim = Math.max(postorderNums[v].lim, postorderNums[w].lim), - parent, - lca; - - // Traverse up from v to find the LCA - parent = v; - do { - parent = g.parent(parent); - vPath.push(parent); - } while (parent && - (postorderNums[parent].low > low || lim > postorderNums[parent].lim)); - lca = parent; - - // Traverse from w to LCA - parent = w; - while ((parent = g.parent(parent)) !== lca) { - wPath.push(parent); - } - - return { path: vPath.concat(wPath.reverse()), lca: lca }; -} - -function postorder(g) { - var result = {}, - lim = 0; - - function dfs(v) { - var low = lim; - _.forEach(g.children(v), dfs); - result[v] = { low: low, lim: lim++ }; - } - _.forEach(g.children(), dfs); - - return result; -} - -},{'./lodash':10}],23:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'), - Graph = require('../graphlib').Graph, - util = require('../util'); - -/* - * This module provides coordinate assignment based on Brandes and Köpf, "Fast - * and Simple Horizontal Coordinate Assignment." - */ - -module.exports = { - positionX: positionX, - findType1Conflicts: findType1Conflicts, - findType2Conflicts: findType2Conflicts, - addConflict: addConflict, - hasConflict: hasConflict, - verticalAlignment: verticalAlignment, - horizontalCompaction: horizontalCompaction, - alignCoordinates: alignCoordinates, - findSmallestWidthAlignment: findSmallestWidthAlignment, - balance: balance -}; - -/* - * Marks all edges in the graph with a type-1 conflict with the "type1Conflict" - * property. A type-1 conflict is one where a non-inner segment crosses an - * inner segment. An inner segment is an edge with both incident nodes marked - * with the "dummy" property. - * - * This algorithm scans layer by layer, starting with the second, for type-1 - * conflicts between the current layer and the previous layer. For each layer - * it scans the nodes from left to right until it reaches one that is incident - * on an inner segment. It then scans predecessors to determine if they have - * edges that cross that inner segment. At the end a final scan is done for all - * nodes on the current rank to see if they cross the last visited inner - * segment. - * - * This algorithm (safely) assumes that a dummy node will only be incident on a - * single node in the layers being scanned. - */ -function findType1Conflicts(g, layering) { - var conflicts = {}; - - function visitLayer(prevLayer, layer) { - var - // last visited node in the previous layer that is incident on an inner - // segment. - k0 = 0, - // Tracks the last node in this layer scanned for crossings with a type-1 - // segment. - scanPos = 0, - prevLayerLength = prevLayer.length, - lastNode = _.last(layer); - - _.forEach(layer, function(v, i) { - var w = findOtherInnerSegmentNode(g, v), - k1 = w ? g.node(w).order : prevLayerLength; - - if (w || v === lastNode) { - _.forEach(layer.slice(scanPos, i +1), function(scanNode) { - _.forEach(g.predecessors(scanNode), function(u) { - var uLabel = g.node(u), - uPos = uLabel.order; - if ((uPos < k0 || k1 < uPos) && - !(uLabel.dummy && g.node(scanNode).dummy)) { - addConflict(conflicts, u, scanNode); - } - }); - }); - scanPos = i + 1; - k0 = k1; - } - }); - - return layer; - } - - _.reduce(layering, visitLayer); - return conflicts; -} - -function findType2Conflicts(g, layering) { - var conflicts = {}; - - function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) { - var v; - _.forEach(_.range(southPos, southEnd), function(i) { - v = south[i]; - if (g.node(v).dummy) { - _.forEach(g.predecessors(v), function(u) { - var uNode = g.node(u); - if (uNode.dummy && - (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) { - addConflict(conflicts, u, v); - } - }); - } - }); - } - - - function visitLayer(north, south) { - var prevNorthPos = -1, - nextNorthPos, - southPos = 0; - - _.forEach(south, function(v, southLookahead) { - if (g.node(v).dummy === 'border') { - var predecessors = g.predecessors(v); - if (predecessors.length) { - nextNorthPos = g.node(predecessors[0]).order; - scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos); - southPos = southLookahead; - prevNorthPos = nextNorthPos; - } - } - scan(south, southPos, south.length, nextNorthPos, north.length); - }); - - return south; - } - - _.reduce(layering, visitLayer); - return conflicts; -} - -function findOtherInnerSegmentNode(g, v) { - if (g.node(v).dummy) { - return _.find(g.predecessors(v), function(u) { - return g.node(u).dummy; - }); - } -} - -function addConflict(conflicts, v, w) { - if (v > w) { - var tmp = v; - v = w; - w = tmp; - } - - var conflictsV = conflicts[v]; - if (!conflictsV) { - conflicts[v] = conflictsV = {}; - } - conflictsV[w] = true; -} - -function hasConflict(conflicts, v, w) { - if (v > w) { - var tmp = v; - v = w; - w = tmp; - } - return _.has(conflicts[v], w); -} - -/* - * Try to align nodes into vertical "blocks" where possible. This algorithm - * attempts to align a node with one of its median neighbors. If the edge - * connecting a neighbor is a type-1 conflict then we ignore that possibility. - * If a previous node has already formed a block with a node after the node - * we're trying to form a block with, we also ignore that possibility - our - * blocks would be split in that scenario. - */ -function verticalAlignment(g, layering, conflicts, neighborFn) { - var root = {}, - align = {}, - pos = {}; - - // We cache the position here based on the layering because the graph and - // layering may be out of sync. The layering matrix is manipulated to - // generate different extreme alignments. - _.forEach(layering, function(layer) { - _.forEach(layer, function(v, order) { - root[v] = v; - align[v] = v; - pos[v] = order; - }); - }); - - _.forEach(layering, function(layer) { - var prevIdx = -1; - _.forEach(layer, function(v) { - var ws = neighborFn(v); - if (ws.length) { - ws = _.sortBy(ws, function(w) { return pos[w]; }); - var mp = (ws.length - 1) / 2; - for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) { - var w = ws[i]; - if (align[v] === v && - prevIdx < pos[w] && - !hasConflict(conflicts, v, w)) { - align[w] = v; - align[v] = root[v] = root[w]; - prevIdx = pos[w]; - } - } - } - }); - }); - - return { root: root, align: align }; -} - -function horizontalCompaction(g, layering, root, align, reverseSep) { - // This portion of the algorithm differs from BK due to a number of problems. - // Instead of their algorithm we construct a new block graph and do two - // sweeps. The first sweep places blocks with the smallest possible - // coordinates. The second sweep removes unused space by moving blocks to the - // greatest coordinates without violating separation. - var xs = {}, - blockG = buildBlockGraph(g, layering, root, reverseSep), - borderType = reverseSep ? 'borderLeft' : 'borderRight'; - - function iterate(setXsFunc, nextNodesFunc) { - var stack = blockG.nodes(); - var elem = stack.pop(); - var visited = {}; - while (elem) { - if (visited[elem]) { - setXsFunc(elem); - } else { - visited[elem] = true; - stack.push(elem); - stack = stack.concat(nextNodesFunc(elem)); - } - - elem = stack.pop(); - } - } - - // First pass, assign smallest coordinates - function pass1(elem) { - xs[elem] = blockG.inEdges(elem).reduce(function(acc, e) { - return Math.max(acc, xs[e.v] + blockG.edge(e)); - }, 0); - } - - // Second pass, assign greatest coordinates - function pass2(elem) { - var min = blockG.outEdges(elem).reduce(function(acc, e) { - return Math.min(acc, xs[e.w] - blockG.edge(e)); - }, Number.POSITIVE_INFINITY); - - var node = g.node(elem); - if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) { - xs[elem] = Math.max(xs[elem], min); - } - } - - iterate(pass1, blockG.predecessors.bind(blockG)); - iterate(pass2, blockG.successors.bind(blockG)); - - // Assign x coordinates to all nodes - _.forEach(align, function(v) { - xs[v] = xs[root[v]]; - }); - - return xs; -} - - -function buildBlockGraph(g, layering, root, reverseSep) { - var blockGraph = new Graph(), - graphLabel = g.graph(), - sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep); - - _.forEach(layering, function(layer) { - var u; - _.forEach(layer, function(v) { - var vRoot = root[v]; - blockGraph.setNode(vRoot); - if (u) { - var uRoot = root[u], - prevMax = blockGraph.edge(uRoot, vRoot); - blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0)); - } - u = v; - }); - }); - - return blockGraph; -} - -/* - * Returns the alignment that has the smallest width of the given alignments. - */ -function findSmallestWidthAlignment(g, xss) { - return _.minBy(_.values(xss), function (xs) { - var max = Number.NEGATIVE_INFINITY; - var min = Number.POSITIVE_INFINITY; - - _.forIn(xs, function (x, v) { - var halfWidth = width(g, v) / 2; - - max = Math.max(x + halfWidth, max); - min = Math.min(x - halfWidth, min); - }); - - return max - min; - }); -} - -/* - * Align the coordinates of each of the layout alignments such that - * left-biased alignments have their minimum coordinate at the same point as - * the minimum coordinate of the smallest width alignment and right-biased - * alignments have their maximum coordinate at the same point as the maximum - * coordinate of the smallest width alignment. - */ -function alignCoordinates(xss, alignTo) { - var alignToVals = _.values(alignTo), - alignToMin = _.min(alignToVals), - alignToMax = _.max(alignToVals); - - _.forEach(['u', 'd'], function(vert) { - _.forEach(['l', 'r'], function(horiz) { - var alignment = vert + horiz, - xs = xss[alignment], - delta; - if (xs === alignTo) return; - - var xsVals = _.values(xs); - delta = horiz === 'l' ? alignToMin - _.min(xsVals) : alignToMax - _.max(xsVals); - - if (delta) { - xss[alignment] = _.mapValues(xs, function(x) { return x + delta; }); - } - }); - }); -} - -function balance(xss, align) { - return _.mapValues(xss.ul, function(ignore, v) { - if (align) { - return xss[align.toLowerCase()][v]; - } else { - var xs = _.sortBy(_.map(xss, v)); - return (xs[1] + xs[2]) / 2; - } - }); -} - -function positionX(g) { - var layering = util.buildLayerMatrix(g), - conflicts = _.merge(findType1Conflicts(g, layering), - findType2Conflicts(g, layering)); - - var xss = {}, - adjustedLayering; - _.forEach(['u', 'd'], function(vert) { - adjustedLayering = vert === 'u' ? layering : _.values(layering).reverse(); - _.forEach(['l', 'r'], function(horiz) { - if (horiz === 'r') { - adjustedLayering = _.map(adjustedLayering, function(inner) { - return _.values(inner).reverse(); - }); - } - - var neighborFn = (vert === 'u' ? g.predecessors : g.successors).bind(g); - var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn); - var xs = horizontalCompaction(g, adjustedLayering, - align.root, align.align, - horiz === 'r'); - if (horiz === 'r') { - xs = _.mapValues(xs, function(x) { return -x; }); - } - xss[vert + horiz] = xs; - }); - }); - - var smallestWidth = findSmallestWidthAlignment(g, xss); - alignCoordinates(xss, smallestWidth); - return balance(xss, g.graph().align); -} - -function sep(nodeSep, edgeSep, reverseSep) { - return function(g, v, w) { - var vLabel = g.node(v), - wLabel = g.node(w), - sum = 0, - delta; - - sum += vLabel.width / 2; - if (_.has(vLabel, 'labelpos')) { - switch (vLabel.labelpos.toLowerCase()) { - case 'l': delta = -vLabel.width / 2; break; - case 'r': delta = vLabel.width / 2; break; - } - } - if (delta) { - sum += reverseSep ? delta : -delta; - } - delta = 0; - - sum += (vLabel.dummy ? edgeSep : nodeSep) / 2; - sum += (wLabel.dummy ? edgeSep : nodeSep) / 2; - - sum += wLabel.width / 2; - if (_.has(wLabel, 'labelpos')) { - switch (wLabel.labelpos.toLowerCase()) { - case 'l': delta = wLabel.width / 2; break; - case 'r': delta = -wLabel.width / 2; break; - } - } - if (delta) { - sum += reverseSep ? delta : -delta; - } - delta = 0; - - return sum; - }; -} - -function width(g, v) { - return g.node(v).width; -} - -},{'../graphlib':7,'../lodash':10,'../util':29}],24:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'), - util = require('../util'), - positionX = require('./bk').positionX; - -module.exports = position; - -function position(g) { - g = util.asNonCompoundGraph(g); - - positionY(g); - _.forEach(positionX(g), function(x, v) { - g.node(v).x = x; - }); -} - -function positionY(g) { - var layering = util.buildLayerMatrix(g), - rankSep = g.graph().ranksep, - prevY = 0; - _.forEach(layering, function(layer) { - var maxHeight = _.max(_.map(layer, function(v) { return g.node(v).height; })); - _.forEach(layer, function(v) { - g.node(v).y = prevY + maxHeight / 2; - }); - prevY += maxHeight + rankSep; - }); -} - - -},{'../lodash':10,'../util':29,'./bk':23}],25:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'), - Graph = require('../graphlib').Graph, - slack = require('./util').slack; - -module.exports = feasibleTree; - -/* - * Constructs a spanning tree with tight edges and adjusted the input node's - * ranks to achieve this. A tight edge is one that is has a length that matches - * its "minlen" attribute. - * - * The basic structure for this function is derived from Gansner, et al., "A - * Technique for Drawing Directed Graphs." - * - * Pre-conditions: - * - * 1. Graph must be a DAG. - * 2. Graph must be connected. - * 3. Graph must have at least one node. - * 5. Graph nodes must have been previously assigned a "rank" property that - * respects the "minlen" property of incident edges. - * 6. Graph edges must have a "minlen" property. - * - * Post-conditions: - * - * - Graph nodes will have their rank adjusted to ensure that all edges are - * tight. - * - * Returns a tree (undirected graph) that is constructed using only "tight" - * edges. - */ -function feasibleTree(g) { - var t = new Graph({ directed: false }); - - // Choose arbitrary node from which to start our tree - var start = g.nodes()[0], - size = g.nodeCount(); - t.setNode(start, {}); - - var edge, delta; - while (tightTree(t, g) < size) { - edge = findMinSlackEdge(t, g); - delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); - shiftRanks(t, g, delta); - } - - return t; -} - -/* - * Finds a maximal tree of tight edges and returns the number of nodes in the - * tree. - */ -function tightTree(t, g) { - function dfs(v) { - _.forEach(g.nodeEdges(v), function(e) { - var edgeV = e.v, - w = (v === edgeV) ? e.w : edgeV; - if (!t.hasNode(w) && !slack(g, e)) { - t.setNode(w, {}); - t.setEdge(v, w, {}); - dfs(w); - } - }); - } - - _.forEach(t.nodes(), dfs); - return t.nodeCount(); -} - -/* - * Finds the edge with the smallest slack that is incident on tree and returns - * it. - */ -function findMinSlackEdge(t, g) { - return _.minBy(g.edges(), function(e) { - if (t.hasNode(e.v) !== t.hasNode(e.w)) { - return slack(g, e); - } - }); -} - -function shiftRanks(t, g, delta) { - _.forEach(t.nodes(), function(v) { - g.node(v).rank += delta; - }); -} - -},{'../graphlib':7,'../lodash':10,'./util':28}],26:[function(require,module,exports){ -'use strict'; - -var rankUtil = require('./util'), - longestPath = rankUtil.longestPath, - feasibleTree = require('./feasible-tree'), - networkSimplex = require('./network-simplex'); - -module.exports = rank; - -/* - * Assigns a rank to each node in the input graph that respects the "minlen" - * constraint specified on edges between nodes. - * - * This basic structure is derived from Gansner, et al., "A Technique for - * Drawing Directed Graphs." - * - * Pre-conditions: - * - * 1. Graph must be a connected DAG - * 2. Graph nodes must be objects - * 3. Graph edges must have "weight" and "minlen" attributes - * - * Post-conditions: - * - * 1. Graph nodes will have a "rank" attribute based on the results of the - * algorithm. Ranks can start at any index (including negative), we'll - * fix them up later. - */ -function rank(g) { - switch(g.graph().ranker) { - case 'network-simplex': networkSimplexRanker(g); break; - case 'tight-tree': tightTreeRanker(g); break; - case 'longest-path': longestPathRanker(g); break; - default: networkSimplexRanker(g); - } -} - -// A fast and simple ranker, but results are far from optimal. -var longestPathRanker = longestPath; - -function tightTreeRanker(g) { - longestPath(g); - feasibleTree(g); -} - -function networkSimplexRanker(g) { - networkSimplex(g); -} - -},{'./feasible-tree':25,'./network-simplex':27,'./util':28}],27:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'), - feasibleTree = require('./feasible-tree'), - slack = require('./util').slack, - initRank = require('./util').longestPath, - preorder = require('../graphlib').alg.preorder, - postorder = require('../graphlib').alg.postorder, - simplify = require('../util').simplify; - -module.exports = networkSimplex; - -// Expose some internals for testing purposes -networkSimplex.initLowLimValues = initLowLimValues; -networkSimplex.initCutValues = initCutValues; -networkSimplex.calcCutValue = calcCutValue; -networkSimplex.leaveEdge = leaveEdge; -networkSimplex.enterEdge = enterEdge; -networkSimplex.exchangeEdges = exchangeEdges; - -/* - * The network simplex algorithm assigns ranks to each node in the input graph - * and iteratively improves the ranking to reduce the length of edges. - * - * Preconditions: - * - * 1. The input graph must be a DAG. - * 2. All nodes in the graph must have an object value. - * 3. All edges in the graph must have "minlen" and "weight" attributes. - * - * Postconditions: - * - * 1. All nodes in the graph will have an assigned "rank" attribute that has - * been optimized by the network simplex algorithm. Ranks start at 0. - * - * - * A rough sketch of the algorithm is as follows: - * - * 1. Assign initial ranks to each node. We use the longest path algorithm, - * which assigns ranks to the lowest position possible. In general this - * leads to very wide bottom ranks and unnecessarily long edges. - * 2. Construct a feasible tight tree. A tight tree is one such that all - * edges in the tree have no slack (difference between length of edge - * and minlen for the edge). This by itself greatly improves the assigned - * rankings by shorting edges. - * 3. Iteratively find edges that have negative cut values. Generally a - * negative cut value indicates that the edge could be removed and a new - * tree edge could be added to produce a more compact graph. - * - * Much of the algorithms here are derived from Gansner, et al., "A Technique - * for Drawing Directed Graphs." The structure of the file roughly follows the - * structure of the overall algorithm. - */ -function networkSimplex(g) { - g = simplify(g); - initRank(g); - var t = feasibleTree(g); - initLowLimValues(t); - initCutValues(t, g); - - var e, f; - while ((e = leaveEdge(t))) { - f = enterEdge(t, g, e); - exchangeEdges(t, g, e, f); - } -} - -/* - * Initializes cut values for all edges in the tree. - */ -function initCutValues(t, g) { - var vs = postorder(t, t.nodes()); - vs = vs.slice(0, vs.length - 1); - _.forEach(vs, function(v) { - assignCutValue(t, g, v); - }); -} - -function assignCutValue(t, g, child) { - var childLab = t.node(child), - parent = childLab.parent; - t.edge(child, parent).cutvalue = calcCutValue(t, g, child); -} - -/* - * Given the tight tree, its graph, and a child in the graph calculate and - * return the cut value for the edge between the child and its parent. - */ -function calcCutValue(t, g, child) { - var childLab = t.node(child), - parent = childLab.parent, - // True if the child is on the tail end of the edge in the directed graph - childIsTail = true, - // The graph's view of the tree edge we're inspecting - graphEdge = g.edge(child, parent), - // The accumulated cut value for the edge between this node and its parent - cutValue = 0; - - if (!graphEdge) { - childIsTail = false; - graphEdge = g.edge(parent, child); - } - - cutValue = graphEdge.weight; - - _.forEach(g.nodeEdges(child), function(e) { - var isOutEdge = e.v === child, - other = isOutEdge ? e.w : e.v; - - if (other !== parent) { - var pointsToHead = isOutEdge === childIsTail, - otherWeight = g.edge(e).weight; - - cutValue += pointsToHead ? otherWeight : -otherWeight; - if (isTreeEdge(t, child, other)) { - var otherCutValue = t.edge(child, other).cutvalue; - cutValue += pointsToHead ? -otherCutValue : otherCutValue; - } - } - }); - - return cutValue; -} - -function initLowLimValues(tree, root) { - if (arguments.length < 2) { - root = tree.nodes()[0]; - } - dfsAssignLowLim(tree, {}, 1, root); -} - -function dfsAssignLowLim(tree, visited, nextLim, v, parent) { - var low = nextLim, - label = tree.node(v); - - visited[v] = true; - _.forEach(tree.neighbors(v), function(w) { - if (!_.has(visited, w)) { - nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v); - } - }); - - label.low = low; - label.lim = nextLim++; - if (parent) { - label.parent = parent; - } else { - // TODO should be able to remove this when we incrementally update low lim - delete label.parent; - } - - return nextLim; -} - -function leaveEdge(tree) { - return _.find(tree.edges(), function(e) { - return tree.edge(e).cutvalue < 0; - }); -} - -function enterEdge(t, g, edge) { - var v = edge.v, - w = edge.w; - - // For the rest of this function we assume that v is the tail and w is the - // head, so if we don't have this edge in the graph we should flip it to - // match the correct orientation. - if (!g.hasEdge(v, w)) { - v = edge.w; - w = edge.v; - } - - var vLabel = t.node(v), - wLabel = t.node(w), - tailLabel = vLabel, - flip = false; - - // If the root is in the tail of the edge then we need to flip the logic that - // checks for the head and tail nodes in the candidates function below. - if (vLabel.lim > wLabel.lim) { - tailLabel = wLabel; - flip = true; - } - - var candidates = _.filter(g.edges(), function(edge) { - return flip === isDescendant(t, t.node(edge.v), tailLabel) && - flip !== isDescendant(t, t.node(edge.w), tailLabel); - }); - - return _.minBy(candidates, function(edge) { return slack(g, edge); }); -} - -function exchangeEdges(t, g, e, f) { - var v = e.v, - w = e.w; - t.removeEdge(v, w); - t.setEdge(f.v, f.w, {}); - initLowLimValues(t); - initCutValues(t, g); - updateRanks(t, g); -} - -function updateRanks(t, g) { - var root = _.find(t.nodes(), function(v) { return !g.node(v).parent; }), - vs = preorder(t, root); - vs = vs.slice(1); - _.forEach(vs, function(v) { - var parent = t.node(v).parent, - edge = g.edge(v, parent), - flipped = false; - - if (!edge) { - edge = g.edge(parent, v); - flipped = true; - } - - g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen); - }); -} - -/* - * Returns true if the edge is in the tree. - */ -function isTreeEdge(tree, u, v) { - return tree.hasEdge(u, v); -} - -/* - * Returns true if the specified node is descendant of the root node per the - * assigned low and lim attributes in the tree. - */ -function isDescendant(tree, vLabel, rootLabel) { - return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim; -} - -},{'../graphlib':7,'../lodash':10,'../util':29,'./feasible-tree':25,'./util':28}],28:[function(require,module,exports){ -'use strict'; - -var _ = require('../lodash'); - -module.exports = { - longestPath: longestPath, - slack: slack -}; - -/* - * Initializes ranks for the input graph using the longest path algorithm. This - * algorithm scales well and is fast in practice, it yields rather poor - * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom - * ranks wide and leaving edges longer than necessary. However, due to its - * speed, this algorithm is good for getting an initial ranking that can be fed - * into other algorithms. - * - * This algorithm does not normalize layers because it will be used by other - * algorithms in most cases. If using this algorithm directly, be sure to - * run normalize at the end. - * - * Pre-conditions: - * - * 1. Input graph is a DAG. - * 2. Input graph node labels can be assigned properties. - * - * Post-conditions: - * - * 1. Each node will be assign an (unnormalized) "rank" property. - */ -function longestPath(g) { - var visited = {}; - - function dfs(v) { - var label = g.node(v); - if (_.has(visited, v)) { - return label.rank; - } - visited[v] = true; - - var rank = _.min(_.map(g.outEdges(v), function(e) { - return dfs(e.w) - g.edge(e).minlen; - })); - - if (rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3 - rank === undefined || // return value of _.map([]) for Lodash 4 - rank === null) { // return value of _.map([null]) - rank = 0; - } - - return (label.rank = rank); - } - - _.forEach(g.sources(), dfs); -} - -/* - * Returns the amount of slack for the given edge. The slack is defined as the - * difference between the length of the edge and its minimum length. - */ -function slack(g, e) { - return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen; -} - -},{'../lodash':10}],29:[function(require,module,exports){ -'use strict'; - -var _ = require('./lodash'), - Graph = require('./graphlib').Graph; - -module.exports = { - addDummyNode: addDummyNode, - simplify: simplify, - asNonCompoundGraph: asNonCompoundGraph, - successorWeights: successorWeights, - predecessorWeights: predecessorWeights, - intersectRect: intersectRect, - buildLayerMatrix: buildLayerMatrix, - normalizeRanks: normalizeRanks, - removeEmptyRanks: removeEmptyRanks, - addBorderNode: addBorderNode, - maxRank: maxRank, - partition: partition, - time: time, - notime: notime -}; - -/* - * Adds a dummy node to the graph and return v. - */ -function addDummyNode(g, type, attrs, name) { - var v; - do { - v = _.uniqueId(name); - } while (g.hasNode(v)); - - attrs.dummy = type; - g.setNode(v, attrs); - return v; -} - -/* - * Returns a new graph with only simple edges. Handles aggregation of data - * associated with multi-edges. - */ -function simplify(g) { - var simplified = new Graph().setGraph(g.graph()); - _.forEach(g.nodes(), function(v) { simplified.setNode(v, g.node(v)); }); - _.forEach(g.edges(), function(e) { - var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 }, - label = g.edge(e); - simplified.setEdge(e.v, e.w, { - weight: simpleLabel.weight + label.weight, - minlen: Math.max(simpleLabel.minlen, label.minlen) - }); - }); - return simplified; -} - -function asNonCompoundGraph(g) { - var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph()); - _.forEach(g.nodes(), function(v) { - if (!g.children(v).length) { - simplified.setNode(v, g.node(v)); - } - }); - _.forEach(g.edges(), function(e) { - simplified.setEdge(e, g.edge(e)); - }); - return simplified; -} - -function successorWeights(g) { - var weightMap = _.map(g.nodes(), function(v) { - var sucs = {}; - _.forEach(g.outEdges(v), function(e) { - sucs[e.w] = (sucs[e.w] || 0) + g.edge(e).weight; - }); - return sucs; - }); - return _.zipObject(g.nodes(), weightMap); -} - -function predecessorWeights(g) { - var weightMap = _.map(g.nodes(), function(v) { - var preds = {}; - _.forEach(g.inEdges(v), function(e) { - preds[e.v] = (preds[e.v] || 0) + g.edge(e).weight; - }); - return preds; - }); - return _.zipObject(g.nodes(), weightMap); -} - -/* - * Finds where a line starting at point ({x, y}) would intersect a rectangle - * ({x, y, width, height}) if it were pointing at the rectangle's center. - */ -function intersectRect(rect, point) { - var x = rect.x; - var y = rect.y; - - // Rectangle intersection algorithm from: - // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes - var dx = point.x - x; - var dy = point.y - y; - var w = rect.width / 2; - var h = rect.height / 2; - - if (!dx && !dy) { - throw new Error('Not possible to find intersection inside of the rectangle'); - } - - var sx, sy; - if (Math.abs(dy) * w > Math.abs(dx) * h) { - // Intersection is top or bottom of rect. - if (dy < 0) { - h = -h; - } - sx = h * dx / dy; - sy = h; - } else { - // Intersection is left or right of rect. - if (dx < 0) { - w = -w; - } - sx = w; - sy = w * dy / dx; - } - - return { x: x + sx, y: y + sy }; -} - -/* - * Given a DAG with each node assigned "rank" and "order" properties, this - * function will produce a matrix with the ids of each node. - */ -function buildLayerMatrix(g) { - var layering = _.map(_.range(maxRank(g) + 1), function() { return []; }); - _.forEach(g.nodes(), function(v) { - var node = g.node(v), - rank = node.rank; - if (!_.isUndefined(rank)) { - layering[rank][node.order] = v; - } - }); - return layering; -} - -/* - * Adjusts the ranks for all nodes in the graph such that all nodes v have - * rank(v) >= 0 and at least one node w has rank(w) = 0. - */ -function normalizeRanks(g) { - var min = _.min(_.map(g.nodes(), function(v) { return g.node(v).rank; })); - _.forEach(g.nodes(), function(v) { - var node = g.node(v); - if (_.has(node, 'rank')) { - node.rank -= min; - } - }); -} - -function removeEmptyRanks(g) { - // Ranks may not start at 0, so we need to offset them - var offset = _.min(_.map(g.nodes(), function(v) { return g.node(v).rank; })); - - var layers = []; - _.forEach(g.nodes(), function(v) { - var rank = g.node(v).rank - offset; - if (!layers[rank]) { - layers[rank] = []; - } - layers[rank].push(v); - }); - - var delta = 0, - nodeRankFactor = g.graph().nodeRankFactor; - _.forEach(layers, function(vs, i) { - if (_.isUndefined(vs) && i % nodeRankFactor !== 0) { - --delta; - } else if (delta) { - _.forEach(vs, function(v) { g.node(v).rank += delta; }); - } - }); -} - -function addBorderNode(g, prefix, rank, order) { - var node = { - width: 0, - height: 0 - }; - if (arguments.length >= 4) { - node.rank = rank; - node.order = order; - } - return addDummyNode(g, 'border', node, prefix); -} - -function maxRank(g) { - return _.max(_.map(g.nodes(), function(v) { - var rank = g.node(v).rank; - if (!_.isUndefined(rank)) { - return rank; - } - })); -} - -/* - * Partition a collection into two groups: `lhs` and `rhs`. If the supplied - * function returns true for an entry it goes into `lhs`. Otherwise it goes - * into `rhs. - */ -function partition(collection, fn) { - var result = { lhs: [], rhs: [] }; - _.forEach(collection, function(value) { - if (fn(value)) { - result.lhs.push(value); - } else { - result.rhs.push(value); - } - }); - return result; -} - -/* - * Returns a new function that wraps `fn` with a timer. The wrapper logs the - * time it takes to execute the function. - */ -function time(name, fn) { - var start = _.now(); - try { - return fn(); - } finally { - console.log(name + ' time: ' + (_.now() - start) + 'ms'); - } -} - -function notime(name, fn) { - return fn(); -} - -},{'./graphlib':7,'./lodash':10}],30:[function(require,module,exports){ -module.exports = '0.8.4'; - -},{}],31:[function(require,module,exports){ -/** - * Copyright (c) 2014, Chris Pettitt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -var lib = require('./lib'); - -module.exports = { - Graph: lib.Graph, - json: require('./lib/json'), - alg: require('./lib/alg'), - version: lib.version -}; - -},{'./lib':47,'./lib/alg':38,'./lib/json':48}],32:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = components; - -function components(g) { - var visited = {}, - cmpts = [], - cmpt; - - function dfs(v) { - if (_.has(visited, v)) return; - visited[v] = true; - cmpt.push(v); - _.each(g.successors(v), dfs); - _.each(g.predecessors(v), dfs); - } - - _.each(g.nodes(), function(v) { - cmpt = []; - dfs(v); - if (cmpt.length) { - cmpts.push(cmpt); - } - }); - - return cmpts; -} - -},{'../lodash':49}],33:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = dfs; - -/* - * A helper that preforms a pre- or post-order traversal on the input graph - * and returns the nodes in the order they were visited. If the graph is - * undirected then this algorithm will navigate using neighbors. If the graph - * is directed then this algorithm will navigate using successors. - * - * Order must be one of "pre" or "post". - */ -function dfs(g, vs, order) { - if (!_.isArray(vs)) { - vs = [vs]; - } - - var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g); - - var acc = [], - visited = {}; - _.each(vs, function(v) { - if (!g.hasNode(v)) { - throw new Error('Graph does not have node: ' + v); - } - - doDfs(g, v, order === 'post', visited, navigation, acc); - }); - return acc; -} - -function doDfs(g, v, postorder, visited, navigation, acc) { - if (!_.has(visited, v)) { - visited[v] = true; - - if (!postorder) { acc.push(v); } - _.each(navigation(v), function(w) { - doDfs(g, w, postorder, visited, navigation, acc); - }); - if (postorder) { acc.push(v); } - } -} - -},{'../lodash':49}],34:[function(require,module,exports){ -var dijkstra = require('./dijkstra'), - _ = require('../lodash'); - -module.exports = dijkstraAll; - -function dijkstraAll(g, weightFunc, edgeFunc) { - return _.transform(g.nodes(), function(acc, v) { - acc[v] = dijkstra(g, v, weightFunc, edgeFunc); - }, {}); -} - -},{'../lodash':49,'./dijkstra':35}],35:[function(require,module,exports){ -var _ = require('../lodash'), - PriorityQueue = require('../data/priority-queue'); - -module.exports = dijkstra; - -var DEFAULT_WEIGHT_FUNC = _.constant(1); - -function dijkstra(g, source, weightFn, edgeFn) { - return runDijkstra(g, String(source), - weightFn || DEFAULT_WEIGHT_FUNC, - edgeFn || function(v) { return g.outEdges(v); }); -} - -function runDijkstra(g, source, weightFn, edgeFn) { - var results = {}, - pq = new PriorityQueue(), - v, vEntry; - - var updateNeighbors = function(edge) { - var w = edge.v !== v ? edge.v : edge.w, - wEntry = results[w], - weight = weightFn(edge), - distance = vEntry.distance + weight; - - if (weight < 0) { - throw new Error('dijkstra does not allow negative edge weights. ' + - 'Bad edge: ' + edge + ' Weight: ' + weight); - } - - if (distance < wEntry.distance) { - wEntry.distance = distance; - wEntry.predecessor = v; - pq.decrease(w, distance); - } - }; - - g.nodes().forEach(function(v) { - var distance = v === source ? 0 : Number.POSITIVE_INFINITY; - results[v] = { distance: distance }; - pq.add(v, distance); - }); - - while (pq.size() > 0) { - v = pq.removeMin(); - vEntry = results[v]; - if (vEntry.distance === Number.POSITIVE_INFINITY) { - break; - } - - edgeFn(v).forEach(updateNeighbors); - } - - return results; -} - -},{'../data/priority-queue':45,'../lodash':49}],36:[function(require,module,exports){ -var _ = require('../lodash'), - tarjan = require('./tarjan'); - -module.exports = findCycles; - -function findCycles(g) { - return _.filter(tarjan(g), function(cmpt) { - return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0])); - }); -} - -},{'../lodash':49,'./tarjan':43}],37:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = floydWarshall; - -var DEFAULT_WEIGHT_FUNC = _.constant(1); - -function floydWarshall(g, weightFn, edgeFn) { - return runFloydWarshall(g, - weightFn || DEFAULT_WEIGHT_FUNC, - edgeFn || function(v) { return g.outEdges(v); }); -} - -function runFloydWarshall(g, weightFn, edgeFn) { - var results = {}, - nodes = g.nodes(); - - nodes.forEach(function(v) { - results[v] = {}; - results[v][v] = { distance: 0 }; - nodes.forEach(function(w) { - if (v !== w) { - results[v][w] = { distance: Number.POSITIVE_INFINITY }; - } - }); - edgeFn(v).forEach(function(edge) { - var w = edge.v === v ? edge.w : edge.v, - d = weightFn(edge); - results[v][w] = { distance: d, predecessor: v }; - }); - }); - - nodes.forEach(function(k) { - var rowK = results[k]; - nodes.forEach(function(i) { - var rowI = results[i]; - nodes.forEach(function(j) { - var ik = rowI[k]; - var kj = rowK[j]; - var ij = rowI[j]; - var altDistance = ik.distance + kj.distance; - if (altDistance < ij.distance) { - ij.distance = altDistance; - ij.predecessor = kj.predecessor; - } - }); - }); - }); - - return results; -} - -},{'../lodash':49}],38:[function(require,module,exports){ -module.exports = { - components: require('./components'), - dijkstra: require('./dijkstra'), - dijkstraAll: require('./dijkstra-all'), - findCycles: require('./find-cycles'), - floydWarshall: require('./floyd-warshall'), - isAcyclic: require('./is-acyclic'), - postorder: require('./postorder'), - preorder: require('./preorder'), - prim: require('./prim'), - tarjan: require('./tarjan'), - topsort: require('./topsort') -}; - -},{'./components':32,'./dijkstra':35,'./dijkstra-all':34,'./find-cycles':36,'./floyd-warshall':37,'./is-acyclic':39,'./postorder':40,'./preorder':41,'./prim':42,'./tarjan':43,'./topsort':44}],39:[function(require,module,exports){ -var topsort = require('./topsort'); - -module.exports = isAcyclic; - -function isAcyclic(g) { - try { - topsort(g); - } catch (e) { - if (e instanceof topsort.CycleException) { - return false; - } - throw e; - } - return true; -} - -},{'./topsort':44}],40:[function(require,module,exports){ -var dfs = require('./dfs'); - -module.exports = postorder; - -function postorder(g, vs) { - return dfs(g, vs, 'post'); -} - -},{'./dfs':33}],41:[function(require,module,exports){ -var dfs = require('./dfs'); - -module.exports = preorder; - -function preorder(g, vs) { - return dfs(g, vs, 'pre'); -} - -},{'./dfs':33}],42:[function(require,module,exports){ -var _ = require('../lodash'), - Graph = require('../graph'), - PriorityQueue = require('../data/priority-queue'); - -module.exports = prim; - -function prim(g, weightFunc) { - var result = new Graph(), - parents = {}, - pq = new PriorityQueue(), - v; - - function updateNeighbors(edge) { - var w = edge.v === v ? edge.w : edge.v, - pri = pq.priority(w); - if (pri !== undefined) { - var edgeWeight = weightFunc(edge); - if (edgeWeight < pri) { - parents[w] = v; - pq.decrease(w, edgeWeight); - } - } - } - - if (g.nodeCount() === 0) { - return result; - } - - _.each(g.nodes(), function(v) { - pq.add(v, Number.POSITIVE_INFINITY); - result.setNode(v); - }); - - // Start from an arbitrary node - pq.decrease(g.nodes()[0], 0); - - var init = false; - while (pq.size() > 0) { - v = pq.removeMin(); - if (_.has(parents, v)) { - result.setEdge(v, parents[v]); - } else if (init) { - throw new Error('Input graph is not connected: ' + g); - } else { - init = true; - } - - g.nodeEdges(v).forEach(updateNeighbors); - } - - return result; -} - -},{'../data/priority-queue':45,'../graph':46,'../lodash':49}],43:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = tarjan; - -function tarjan(g) { - var index = 0, - stack = [], - visited = {}, // node id -> { onStack, lowlink, index } - results = []; - - function dfs(v) { - var entry = visited[v] = { - onStack: true, - lowlink: index, - index: index++ - }; - stack.push(v); - - g.successors(v).forEach(function(w) { - if (!_.has(visited, w)) { - dfs(w); - entry.lowlink = Math.min(entry.lowlink, visited[w].lowlink); - } else if (visited[w].onStack) { - entry.lowlink = Math.min(entry.lowlink, visited[w].index); - } - }); - - if (entry.lowlink === entry.index) { - var cmpt = [], - w; - do { - w = stack.pop(); - visited[w].onStack = false; - cmpt.push(w); - } while (v !== w); - results.push(cmpt); - } - } - - g.nodes().forEach(function(v) { - if (!_.has(visited, v)) { - dfs(v); - } - }); - - return results; -} - -},{'../lodash':49}],44:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = topsort; -topsort.CycleException = CycleException; - -function topsort(g) { - var visited = {}, - stack = {}, - results = []; - - function visit(node) { - if (_.has(stack, node)) { - throw new CycleException(); - } - - if (!_.has(visited, node)) { - stack[node] = true; - visited[node] = true; - _.each(g.predecessors(node), visit); - delete stack[node]; - results.push(node); - } - } - - _.each(g.sinks(), visit); - - if (_.size(visited) !== g.nodeCount()) { - throw new CycleException(); - } - - return results; -} - -function CycleException() {} -CycleException.prototype = new Error(); // must be an instance of Error to pass testing -},{'../lodash':49}],45:[function(require,module,exports){ -var _ = require('../lodash'); - -module.exports = PriorityQueue; - -/** - * A min-priority queue data structure. This algorithm is derived from Cormen, - * et al., "Introduction to Algorithms". The basic idea of a min-priority - * queue is that you can efficiently (in O(1) time) get the smallest key in - * the queue. Adding and removing elements takes O(log n) time. A key can - * have its priority decreased in O(log n) time. - */ -function PriorityQueue() { - this._arr = []; - this._keyIndices = {}; -} - -/** - * Returns the number of elements in the queue. Takes `O(1)` time. - */ -PriorityQueue.prototype.size = function() { - return this._arr.length; -}; - -/** - * Returns the keys that are in the queue. Takes `O(n)` time. - */ -PriorityQueue.prototype.keys = function() { - return this._arr.map(function(x) { return x.key; }); -}; - -/** - * Returns `true` if **key** is in the queue and `false` if not. - */ -PriorityQueue.prototype.has = function(key) { - return _.has(this._keyIndices, key); -}; - -/** - * Returns the priority for **key**. If **key** is not present in the queue - * then this function returns `undefined`. Takes `O(1)` time. - * - * @param {Object} key - */ -PriorityQueue.prototype.priority = function(key) { - var index = this._keyIndices[key]; - if (index !== undefined) { - return this._arr[index].priority; - } -}; - -/** - * Returns the key for the minimum element in this queue. If the queue is - * empty this function throws an Error. Takes `O(1)` time. - */ -PriorityQueue.prototype.min = function() { - if (this.size() === 0) { - throw new Error('Queue underflow'); - } - return this._arr[0].key; -}; - -/** - * Inserts a new key into the priority queue. If the key already exists in - * the queue this function returns `false`; otherwise it will return `true`. - * Takes `O(n)` time. - * - * @param {Object} key the key to add - * @param {Number} priority the initial priority for the key - */ -PriorityQueue.prototype.add = function(key, priority) { - var keyIndices = this._keyIndices; - key = String(key); - if (!_.has(keyIndices, key)) { - var arr = this._arr; - var index = arr.length; - keyIndices[key] = index; - arr.push({key: key, priority: priority}); - this._decrease(index); - return true; - } - return false; -}; - -/** - * Removes and returns the smallest key in the queue. Takes `O(log n)` time. - */ -PriorityQueue.prototype.removeMin = function() { - this._swap(0, this._arr.length - 1); - var min = this._arr.pop(); - delete this._keyIndices[min.key]; - this._heapify(0); - return min.key; -}; - -/** - * Decreases the priority for **key** to **priority**. If the new priority is - * greater than the previous priority, this function will throw an Error. - * - * @param {Object} key the key for which to raise priority - * @param {Number} priority the new priority for the key - */ -PriorityQueue.prototype.decrease = function(key, priority) { - var index = this._keyIndices[key]; - if (priority > this._arr[index].priority) { - throw new Error('New priority is greater than current priority. ' + - 'Key: ' + key + ' Old: ' + this._arr[index].priority + ' New: ' + priority); - } - this._arr[index].priority = priority; - this._decrease(index); -}; - -PriorityQueue.prototype._heapify = function(i) { - var arr = this._arr; - var l = 2 * i, - r = l + 1, - largest = i; - if (l < arr.length) { - largest = arr[l].priority < arr[largest].priority ? l : largest; - if (r < arr.length) { - largest = arr[r].priority < arr[largest].priority ? r : largest; - } - if (largest !== i) { - this._swap(i, largest); - this._heapify(largest); - } - } -}; - -PriorityQueue.prototype._decrease = function(index) { - var arr = this._arr; - var priority = arr[index].priority; - var parent; - while (index !== 0) { - parent = index >> 1; - if (arr[parent].priority < priority) { - break; - } - this._swap(index, parent); - index = parent; - } -}; - -PriorityQueue.prototype._swap = function(i, j) { - var arr = this._arr; - var keyIndices = this._keyIndices; - var origArrI = arr[i]; - var origArrJ = arr[j]; - arr[i] = origArrJ; - arr[j] = origArrI; - keyIndices[origArrJ.key] = i; - keyIndices[origArrI.key] = j; -}; - -},{'../lodash':49}],46:[function(require,module,exports){ -'use strict'; - -var _ = require('./lodash'); - -module.exports = Graph; - -var DEFAULT_EDGE_NAME = '\x00', - GRAPH_NODE = '\x00', - EDGE_KEY_DELIM = '\x01'; - -// Implementation notes: -// -// * Node id query functions should return string ids for the nodes -// * Edge id query functions should return an "edgeObj", edge object, that is -// composed of enough information to uniquely identify an edge: {v, w, name}. -// * Internally we use an "edgeId", a stringified form of the edgeObj, to -// reference edges. This is because we need a performant way to look these -// edges up and, object properties, which have string keys, are the closest -// we're going to get to a performant hashtable in JavaScript. - -function Graph(opts) { - this._isDirected = _.has(opts, 'directed') ? opts.directed : true; - this._isMultigraph = _.has(opts, 'multigraph') ? opts.multigraph : false; - this._isCompound = _.has(opts, 'compound') ? opts.compound : false; - - // Label for the graph itself - this._label = undefined; - - // Defaults to be set when creating a new node - this._defaultNodeLabelFn = _.constant(undefined); - - // Defaults to be set when creating a new edge - this._defaultEdgeLabelFn = _.constant(undefined); - - // v -> label - this._nodes = {}; - - if (this._isCompound) { - // v -> parent - this._parent = {}; - - // v -> children - this._children = {}; - this._children[GRAPH_NODE] = {}; - } - - // v -> edgeObj - this._in = {}; - - // u -> v -> Number - this._preds = {}; - - // v -> edgeObj - this._out = {}; - - // v -> w -> Number - this._sucs = {}; - - // e -> edgeObj - this._edgeObjs = {}; - - // e -> label - this._edgeLabels = {}; -} - -/* Number of nodes in the graph. Should only be changed by the implementation. */ -Graph.prototype._nodeCount = 0; - -/* Number of edges in the graph. Should only be changed by the implementation. */ -Graph.prototype._edgeCount = 0; - - -/* === Graph functions ========= */ - -Graph.prototype.isDirected = function() { - return this._isDirected; -}; - -Graph.prototype.isMultigraph = function() { - return this._isMultigraph; -}; - -Graph.prototype.isCompound = function() { - return this._isCompound; -}; - -Graph.prototype.setGraph = function(label) { - this._label = label; - return this; -}; - -Graph.prototype.graph = function() { - return this._label; -}; - - -/* === Node functions ========== */ - -Graph.prototype.setDefaultNodeLabel = function(newDefault) { - if (!_.isFunction(newDefault)) { - newDefault = _.constant(newDefault); - } - this._defaultNodeLabelFn = newDefault; - return this; -}; - -Graph.prototype.nodeCount = function() { - return this._nodeCount; -}; - -Graph.prototype.nodes = function() { - return _.keys(this._nodes); -}; - -Graph.prototype.sources = function() { - var self = this; - return _.filter(this.nodes(), function(v) { - return _.isEmpty(self._in[v]); - }); -}; - -Graph.prototype.sinks = function() { - var self = this; - return _.filter(this.nodes(), function(v) { - return _.isEmpty(self._out[v]); - }); -}; - -Graph.prototype.setNodes = function(vs, value) { - var args = arguments; - var self = this; - _.each(vs, function(v) { - if (args.length > 1) { - self.setNode(v, value); - } else { - self.setNode(v); - } - }); - return this; -}; - -Graph.prototype.setNode = function(v, value) { - if (_.has(this._nodes, v)) { - if (arguments.length > 1) { - this._nodes[v] = value; - } - return this; - } - - this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v); - if (this._isCompound) { - this._parent[v] = GRAPH_NODE; - this._children[v] = {}; - this._children[GRAPH_NODE][v] = true; - } - this._in[v] = {}; - this._preds[v] = {}; - this._out[v] = {}; - this._sucs[v] = {}; - ++this._nodeCount; - return this; -}; - -Graph.prototype.node = function(v) { - return this._nodes[v]; -}; - -Graph.prototype.hasNode = function(v) { - return _.has(this._nodes, v); -}; - -Graph.prototype.removeNode = function(v) { - var self = this; - if (_.has(this._nodes, v)) { - var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); }; - delete this._nodes[v]; - if (this._isCompound) { - this._removeFromParentsChildList(v); - delete this._parent[v]; - _.each(this.children(v), function(child) { - self.setParent(child); - }); - delete this._children[v]; - } - _.each(_.keys(this._in[v]), removeEdge); - delete this._in[v]; - delete this._preds[v]; - _.each(_.keys(this._out[v]), removeEdge); - delete this._out[v]; - delete this._sucs[v]; - --this._nodeCount; - } - return this; -}; - -Graph.prototype.setParent = function(v, parent) { - if (!this._isCompound) { - throw new Error('Cannot set parent in a non-compound graph'); - } - - if (_.isUndefined(parent)) { - parent = GRAPH_NODE; - } else { - // Coerce parent to string - parent += ''; - for (var ancestor = parent; - !_.isUndefined(ancestor); - ancestor = this.parent(ancestor)) { - if (ancestor === v) { - throw new Error('Setting ' + parent+ ' as parent of ' + v + - ' would create a cycle'); - } - } - - this.setNode(parent); - } - - this.setNode(v); - this._removeFromParentsChildList(v); - this._parent[v] = parent; - this._children[parent][v] = true; - return this; -}; - -Graph.prototype._removeFromParentsChildList = function(v) { - delete this._children[this._parent[v]][v]; -}; - -Graph.prototype.parent = function(v) { - if (this._isCompound) { - var parent = this._parent[v]; - if (parent !== GRAPH_NODE) { - return parent; - } - } -}; - -Graph.prototype.children = function(v) { - if (_.isUndefined(v)) { - v = GRAPH_NODE; - } - - if (this._isCompound) { - var children = this._children[v]; - if (children) { - return _.keys(children); - } - } else if (v === GRAPH_NODE) { - return this.nodes(); - } else if (this.hasNode(v)) { - return []; - } -}; - -Graph.prototype.predecessors = function(v) { - var predsV = this._preds[v]; - if (predsV) { - return _.keys(predsV); - } -}; - -Graph.prototype.successors = function(v) { - var sucsV = this._sucs[v]; - if (sucsV) { - return _.keys(sucsV); - } -}; - -Graph.prototype.neighbors = function(v) { - var preds = this.predecessors(v); - if (preds) { - return _.union(preds, this.successors(v)); - } -}; - -Graph.prototype.isLeaf = function (v) { - var neighbors; - if (this.isDirected()) { - neighbors = this.successors(v); - } else { - neighbors = this.neighbors(v); - } - return neighbors.length === 0; -}; - -Graph.prototype.filterNodes = function(filter) { - var copy = new this.constructor({ - directed: this._isDirected, - multigraph: this._isMultigraph, - compound: this._isCompound - }); - - copy.setGraph(this.graph()); - - var self = this; - _.each(this._nodes, function(value, v) { - if (filter(v)) { - copy.setNode(v, value); - } - }); - - _.each(this._edgeObjs, function(e) { - if (copy.hasNode(e.v) && copy.hasNode(e.w)) { - copy.setEdge(e, self.edge(e)); - } - }); - - var parents = {}; - function findParent(v) { - var parent = self.parent(v); - if (parent === undefined || copy.hasNode(parent)) { - parents[v] = parent; - return parent; - } else if (parent in parents) { - return parents[parent]; - } else { - return findParent(parent); - } - } - - if (this._isCompound) { - _.each(copy.nodes(), function(v) { - copy.setParent(v, findParent(v)); - }); - } - - return copy; -}; - -/* === Edge functions ========== */ - -Graph.prototype.setDefaultEdgeLabel = function(newDefault) { - if (!_.isFunction(newDefault)) { - newDefault = _.constant(newDefault); - } - this._defaultEdgeLabelFn = newDefault; - return this; -}; - -Graph.prototype.edgeCount = function() { - return this._edgeCount; -}; - -Graph.prototype.edges = function() { - return _.values(this._edgeObjs); -}; - -Graph.prototype.setPath = function(vs, value) { - var self = this, - args = arguments; - _.reduce(vs, function(v, w) { - if (args.length > 1) { - self.setEdge(v, w, value); - } else { - self.setEdge(v, w); - } - return w; - }); - return this; -}; - -/* - * setEdge(v, w, [value, [name]]) - * setEdge({ v, w, [name] }, [value]) - */ -Graph.prototype.setEdge = function() { - var v, w, name, value, - valueSpecified = false, - arg0 = arguments[0]; - - if (typeof arg0 === 'object' && arg0 !== null && 'v' in arg0) { - v = arg0.v; - w = arg0.w; - name = arg0.name; - if (arguments.length === 2) { - value = arguments[1]; - valueSpecified = true; - } - } else { - v = arg0; - w = arguments[1]; - name = arguments[3]; - if (arguments.length > 2) { - value = arguments[2]; - valueSpecified = true; - } - } - - v = '' + v; - w = '' + w; - if (!_.isUndefined(name)) { - name = '' + name; - } - - var e = edgeArgsToId(this._isDirected, v, w, name); - if (_.has(this._edgeLabels, e)) { - if (valueSpecified) { - this._edgeLabels[e] = value; - } - return this; - } - - if (!_.isUndefined(name) && !this._isMultigraph) { - throw new Error('Cannot set a named edge when isMultigraph = false'); - } - - // It didn't exist, so we need to create it. - // First ensure the nodes exist. - this.setNode(v); - this.setNode(w); - - this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name); - - var edgeObj = edgeArgsToObj(this._isDirected, v, w, name); - // Ensure we add undirected edges in a consistent way. - v = edgeObj.v; - w = edgeObj.w; - - Object.freeze(edgeObj); - this._edgeObjs[e] = edgeObj; - incrementOrInitEntry(this._preds[w], v); - incrementOrInitEntry(this._sucs[v], w); - this._in[w][e] = edgeObj; - this._out[v][e] = edgeObj; - this._edgeCount++; - return this; -}; - -Graph.prototype.edge = function(v, w, name) { - var e = (arguments.length === 1 - ? edgeObjToId(this._isDirected, arguments[0]) - : edgeArgsToId(this._isDirected, v, w, name)); - return this._edgeLabels[e]; -}; - -Graph.prototype.hasEdge = function(v, w, name) { - var e = (arguments.length === 1 - ? edgeObjToId(this._isDirected, arguments[0]) - : edgeArgsToId(this._isDirected, v, w, name)); - return _.has(this._edgeLabels, e); -}; - -Graph.prototype.removeEdge = function(v, w, name) { - var e = (arguments.length === 1 - ? edgeObjToId(this._isDirected, arguments[0]) - : edgeArgsToId(this._isDirected, v, w, name)), - edge = this._edgeObjs[e]; - if (edge) { - v = edge.v; - w = edge.w; - delete this._edgeLabels[e]; - delete this._edgeObjs[e]; - decrementOrRemoveEntry(this._preds[w], v); - decrementOrRemoveEntry(this._sucs[v], w); - delete this._in[w][e]; - delete this._out[v][e]; - this._edgeCount--; - } - return this; -}; - -Graph.prototype.inEdges = function(v, u) { - var inV = this._in[v]; - if (inV) { - var edges = _.values(inV); - if (!u) { - return edges; - } - return _.filter(edges, function(edge) { return edge.v === u; }); - } -}; - -Graph.prototype.outEdges = function(v, w) { - var outV = this._out[v]; - if (outV) { - var edges = _.values(outV); - if (!w) { - return edges; - } - return _.filter(edges, function(edge) { return edge.w === w; }); - } -}; - -Graph.prototype.nodeEdges = function(v, w) { - var inEdges = this.inEdges(v, w); - if (inEdges) { - return inEdges.concat(this.outEdges(v, w)); - } -}; - -function incrementOrInitEntry(map, k) { - if (map[k]) { - map[k]++; - } else { - map[k] = 1; - } -} - -function decrementOrRemoveEntry(map, k) { - if (!--map[k]) { delete map[k]; } -} - -function edgeArgsToId(isDirected, v_, w_, name) { - var v = '' + v_; - var w = '' + w_; - if (!isDirected && v > w) { - var tmp = v; - v = w; - w = tmp; - } - return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + - (_.isUndefined(name) ? DEFAULT_EDGE_NAME : name); -} - -function edgeArgsToObj(isDirected, v_, w_, name) { - var v = '' + v_; - var w = '' + w_; - if (!isDirected && v > w) { - var tmp = v; - v = w; - w = tmp; - } - var edgeObj = { v: v, w: w }; - if (name) { - edgeObj.name = name; - } - return edgeObj; -} - -function edgeObjToId(isDirected, edgeObj) { - return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name); -} - -},{'./lodash':49}],47:[function(require,module,exports){ -// Includes only the "core" of graphlib -module.exports = { - Graph: require('./graph'), - version: require('./version') -}; - -},{'./graph':46,'./version':50}],48:[function(require,module,exports){ -var _ = require('./lodash'), - Graph = require('./graph'); - -module.exports = { - write: write, - read: read -}; - -function write(g) { - var json = { - options: { - directed: g.isDirected(), - multigraph: g.isMultigraph(), - compound: g.isCompound() - }, - nodes: writeNodes(g), - edges: writeEdges(g) - }; - if (!_.isUndefined(g.graph())) { - json.value = _.clone(g.graph()); - } - return json; -} - -function writeNodes(g) { - return _.map(g.nodes(), function(v) { - var nodeValue = g.node(v), - parent = g.parent(v), - node = { v: v }; - if (!_.isUndefined(nodeValue)) { - node.value = nodeValue; - } - if (!_.isUndefined(parent)) { - node.parent = parent; - } - return node; - }); -} - -function writeEdges(g) { - return _.map(g.edges(), function(e) { - var edgeValue = g.edge(e), - edge = { v: e.v, w: e.w }; - if (!_.isUndefined(e.name)) { - edge.name = e.name; - } - if (!_.isUndefined(edgeValue)) { - edge.value = edgeValue; - } - return edge; - }); -} - -function read(json) { - var g = new Graph(json.options).setGraph(json.value); - _.each(json.nodes, function(entry) { - g.setNode(entry.v, entry.value); - if (entry.parent) { - g.setParent(entry.v, entry.parent); - } - }); - _.each(json.edges, function(entry) { - g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value); - }); - return g; -} - -},{'./graph':46,'./lodash':49}],49:[function(require,module,exports){ -/* global window */ - -var lodash; - -if (typeof require === 'function') { - try { - lodash = { - clone: require('lodash/clone'), - constant: require('lodash/constant'), - each: require('lodash/each'), - filter: require('lodash/filter'), - has: require('lodash/has'), - isArray: require('lodash/isArray'), - isEmpty: require('lodash/isEmpty'), - isFunction: require('lodash/isFunction'), - isUndefined: require('lodash/isUndefined'), - keys: require('lodash/keys'), - map: require('lodash/map'), - reduce: require('lodash/reduce'), - size: require('lodash/size'), - transform: require('lodash/transform'), - union: require('lodash/union'), - values: require('lodash/values') - }; - } catch (e) {} -} - -if (!lodash) { - lodash = window._; -} - -module.exports = lodash; - -},{'lodash/clone':226,'lodash/constant':228,'lodash/each':230,'lodash/filter':232,'lodash/has':239,'lodash/isArray':243,'lodash/isEmpty':247,'lodash/isFunction':248,'lodash/isUndefined':258,'lodash/keys':259,'lodash/map':262,'lodash/reduce':274,'lodash/size':275,'lodash/transform':284,'lodash/union':285,'lodash/values':287}],50:[function(require,module,exports){ -module.exports = '2.1.7'; - -},{}],51:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var DataView = getNative(root, 'DataView'); - -module.exports = DataView; - -},{'./_getNative':163,'./_root':208}],52:[function(require,module,exports){ -var hashClear = require('./_hashClear'), - hashDelete = require('./_hashDelete'), - hashGet = require('./_hashGet'), - hashHas = require('./_hashHas'), - hashSet = require('./_hashSet'); - -/** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; - -module.exports = Hash; - -},{'./_hashClear':172,'./_hashDelete':173,'./_hashGet':174,'./_hashHas':175,'./_hashSet':176}],53:[function(require,module,exports){ -var listCacheClear = require('./_listCacheClear'), - listCacheDelete = require('./_listCacheDelete'), - listCacheGet = require('./_listCacheGet'), - listCacheHas = require('./_listCacheHas'), - listCacheSet = require('./_listCacheSet'); - -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - -module.exports = ListCache; - -},{'./_listCacheClear':188,'./_listCacheDelete':189,'./_listCacheGet':190,'./_listCacheHas':191,'./_listCacheSet':192}],54:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var Map = getNative(root, 'Map'); - -module.exports = Map; - -},{'./_getNative':163,'./_root':208}],55:[function(require,module,exports){ -var mapCacheClear = require('./_mapCacheClear'), - mapCacheDelete = require('./_mapCacheDelete'), - mapCacheGet = require('./_mapCacheGet'), - mapCacheHas = require('./_mapCacheHas'), - mapCacheSet = require('./_mapCacheSet'); - -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - -module.exports = MapCache; - -},{'./_mapCacheClear':193,'./_mapCacheDelete':194,'./_mapCacheGet':195,'./_mapCacheHas':196,'./_mapCacheSet':197}],56:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var Promise = getNative(root, 'Promise'); - -module.exports = Promise; - -},{'./_getNative':163,'./_root':208}],57:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var Set = getNative(root, 'Set'); - -module.exports = Set; - -},{'./_getNative':163,'./_root':208}],58:[function(require,module,exports){ -var MapCache = require('./_MapCache'), - setCacheAdd = require('./_setCacheAdd'), - setCacheHas = require('./_setCacheHas'); - -/** - * - * Creates an array cache object to store unique values. - * - * @private - * @constructor - * @param {Array} [values] The values to cache. - */ -function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; - - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); - } -} - -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; - -module.exports = SetCache; - -},{'./_MapCache':55,'./_setCacheAdd':210,'./_setCacheHas':211}],59:[function(require,module,exports){ -var ListCache = require('./_ListCache'), - stackClear = require('./_stackClear'), - stackDelete = require('./_stackDelete'), - stackGet = require('./_stackGet'), - stackHas = require('./_stackHas'), - stackSet = require('./_stackSet'); - -/** - * Creates a stack cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; -} - -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; - -module.exports = Stack; - -},{'./_ListCache':53,'./_stackClear':215,'./_stackDelete':216,'./_stackGet':217,'./_stackHas':218,'./_stackSet':219}],60:[function(require,module,exports){ -var root = require('./_root'); - -/** Built-in value references. */ -var Symbol = root.Symbol; - -module.exports = Symbol; - -},{'./_root':208}],61:[function(require,module,exports){ -var root = require('./_root'); - -/** Built-in value references. */ -var Uint8Array = root.Uint8Array; - -module.exports = Uint8Array; - -},{'./_root':208}],62:[function(require,module,exports){ -var getNative = require('./_getNative'), - root = require('./_root'); - -/* Built-in method references that are verified to be native. */ -var WeakMap = getNative(root, 'WeakMap'); - -module.exports = WeakMap; - -},{'./_getNative':163,'./_root':208}],63:[function(require,module,exports){ -/** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ -function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); -} - -module.exports = apply; - -},{}],64:[function(require,module,exports){ -/** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ -function arrayEach(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; -} - -module.exports = arrayEach; - -},{}],65:[function(require,module,exports){ -/** - * A specialized version of `_.filter` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ -function arrayFilter(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; -} - -module.exports = arrayFilter; - -},{}],66:[function(require,module,exports){ -var baseIndexOf = require('./_baseIndexOf'); - -/** - * A specialized version of `_.includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -function arrayIncludes(array, value) { - var length = array == null ? 0 : array.length; - return !!length && baseIndexOf(array, value, 0) > -1; -} - -module.exports = arrayIncludes; - -},{'./_baseIndexOf':95}],67:[function(require,module,exports){ -/** - * This function is like `arrayIncludes` except that it accepts a comparator. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -function arrayIncludesWith(array, value, comparator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (comparator(value, array[index])) { - return true; - } - } - return false; -} - -module.exports = arrayIncludesWith; - -},{}],68:[function(require,module,exports){ -var baseTimes = require('./_baseTimes'), - isArguments = require('./isArguments'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isIndex = require('./_isIndex'), - isTypedArray = require('./isTypedArray'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - var isArr = isArray(value), - isArg = !isArr && isArguments(value), - isBuff = !isArr && !isArg && isBuffer(value), - isType = !isArr && !isArg && !isBuff && isTypedArray(value), - skipIndexes = isArr || isArg || isBuff || isType, - result = skipIndexes ? baseTimes(value.length, String) : [], - length = result.length; - - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || - // Node.js 0.10 has enumerable non-index properties on buffers. - (isBuff && (key == 'offset' || key == 'parent')) || - // PhantomJS 2 has enumerable non-index properties on typed arrays. - (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || - // Skip index properties. - isIndex(key, length) - ))) { - result.push(key); - } - } - return result; -} - -module.exports = arrayLikeKeys; - -},{'./_baseTimes':125,'./_isIndex':181,'./isArguments':242,'./isArray':243,'./isBuffer':246,'./isTypedArray':257}],69:[function(require,module,exports){ -/** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} - -module.exports = arrayMap; - -},{}],70:[function(require,module,exports){ -/** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ -function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; - - while (++index < length) { - array[offset + index] = values[index]; - } - return array; -} - -module.exports = arrayPush; - -},{}],71:[function(require,module,exports){ -/** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ -function arrayReduce(array, iteratee, accumulator, initAccum) { - var index = -1, - length = array == null ? 0 : array.length; - - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; -} - -module.exports = arrayReduce; - -},{}],72:[function(require,module,exports){ -/** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. - */ -function arraySome(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - -module.exports = arraySome; - -},{}],73:[function(require,module,exports){ -var baseProperty = require('./_baseProperty'); - -/** - * Gets the size of an ASCII `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ -var asciiSize = baseProperty('length'); - -module.exports = asciiSize; - -},{'./_baseProperty':117}],74:[function(require,module,exports){ -var baseAssignValue = require('./_baseAssignValue'), - eq = require('./eq'); - -/** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignMergeValue(object, key, value) { - if ((value !== undefined && !eq(object[key], value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } -} - -module.exports = assignMergeValue; - -},{'./_baseAssignValue':79,'./eq':231}],75:[function(require,module,exports){ -var baseAssignValue = require('./_baseAssignValue'), - eq = require('./eq'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || - (value === undefined && !(key in object))) { - baseAssignValue(object, key, value); - } -} - -module.exports = assignValue; - -},{'./_baseAssignValue':79,'./eq':231}],76:[function(require,module,exports){ -var eq = require('./eq'); - -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} - -module.exports = assocIndexOf; - -},{'./eq':231}],77:[function(require,module,exports){ -var copyObject = require('./_copyObject'), - keys = require('./keys'); - -/** - * The base implementation of `_.assign` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ -function baseAssign(object, source) { - return object && copyObject(source, keys(source), object); -} - -module.exports = baseAssign; - -},{'./_copyObject':143,'./keys':259}],78:[function(require,module,exports){ -var copyObject = require('./_copyObject'), - keysIn = require('./keysIn'); - -/** - * The base implementation of `_.assignIn` without support for multiple sources - * or `customizer` functions. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ -function baseAssignIn(object, source) { - return object && copyObject(source, keysIn(source), object); -} - -module.exports = baseAssignIn; - -},{'./_copyObject':143,'./keysIn':260}],79:[function(require,module,exports){ -var defineProperty = require('./_defineProperty'); - -/** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function baseAssignValue(object, key, value) { - if (key == '__proto__' && defineProperty) { - defineProperty(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } -} - -module.exports = baseAssignValue; - -},{'./_defineProperty':153}],80:[function(require,module,exports){ -var Stack = require('./_Stack'), - arrayEach = require('./_arrayEach'), - assignValue = require('./_assignValue'), - baseAssign = require('./_baseAssign'), - baseAssignIn = require('./_baseAssignIn'), - cloneBuffer = require('./_cloneBuffer'), - copyArray = require('./_copyArray'), - copySymbols = require('./_copySymbols'), - copySymbolsIn = require('./_copySymbolsIn'), - getAllKeys = require('./_getAllKeys'), - getAllKeysIn = require('./_getAllKeysIn'), - getTag = require('./_getTag'), - initCloneArray = require('./_initCloneArray'), - initCloneByTag = require('./_initCloneByTag'), - initCloneObject = require('./_initCloneObject'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isMap = require('./isMap'), - isObject = require('./isObject'), - isSet = require('./isSet'), - keys = require('./keys'); - -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1, - CLONE_FLAT_FLAG = 2, - CLONE_SYMBOLS_FLAG = 4; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** Used to identify `toStringTag` values supported by `_.clone`. */ -var cloneableTags = {}; -cloneableTags[argsTag] = cloneableTags[arrayTag] = -cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = -cloneableTags[boolTag] = cloneableTags[dateTag] = -cloneableTags[float32Tag] = cloneableTags[float64Tag] = -cloneableTags[int8Tag] = cloneableTags[int16Tag] = -cloneableTags[int32Tag] = cloneableTags[mapTag] = -cloneableTags[numberTag] = cloneableTags[objectTag] = -cloneableTags[regexpTag] = cloneableTags[setTag] = -cloneableTags[stringTag] = cloneableTags[symbolTag] = -cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = -cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; -cloneableTags[errorTag] = cloneableTags[funcTag] = -cloneableTags[weakMapTag] = false; - -/** - * The base implementation of `_.clone` and `_.cloneDeep` which tracks - * traversed objects. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} bitmask The bitmask flags. - * 1 - Deep clone - * 2 - Flatten inherited properties - * 4 - Clone symbols - * @param {Function} [customizer] The function to customize cloning. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The parent object of `value`. - * @param {Object} [stack] Tracks traversed objects and their clone counterparts. - * @returns {*} Returns the cloned value. - */ -function baseClone(value, bitmask, customizer, key, object, stack) { - var result, - isDeep = bitmask & CLONE_DEEP_FLAG, - isFlat = bitmask & CLONE_FLAT_FLAG, - isFull = bitmask & CLONE_SYMBOLS_FLAG; - - if (customizer) { - result = object ? customizer(value, key, object, stack) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return copyArray(value, result); - } - } else { - var tag = getTag(value), - isFunc = tag == funcTag || tag == genTag; - - if (isBuffer(value)) { - return cloneBuffer(value, isDeep); - } - if (tag == objectTag || tag == argsTag || (isFunc && !object)) { - result = (isFlat || isFunc) ? {} : initCloneObject(value); - if (!isDeep) { - return isFlat - ? copySymbolsIn(value, baseAssignIn(result, value)) - : copySymbols(value, baseAssign(result, value)); - } - } else { - if (!cloneableTags[tag]) { - return object ? value : {}; - } - result = initCloneByTag(value, tag, isDeep); - } - } - // Check for circular references and return its corresponding clone. - stack || (stack = new Stack); - var stacked = stack.get(value); - if (stacked) { - return stacked; - } - stack.set(value, result); - - if (isSet(value)) { - value.forEach(function(subValue) { - result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); - }); - - return result; - } - - if (isMap(value)) { - value.forEach(function(subValue, key) { - result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - - return result; - } - - var keysFunc = isFull - ? (isFlat ? getAllKeysIn : getAllKeys) - : (isFlat ? keysIn : keys); - - var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function(subValue, key) { - if (props) { - key = subValue; - subValue = value[key]; - } - // Recursively populate clone (susceptible to call stack limits). - assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; -} - -module.exports = baseClone; - -},{'./_Stack':59,'./_arrayEach':64,'./_assignValue':75,'./_baseAssign':77,'./_baseAssignIn':78,'./_cloneBuffer':135,'./_copyArray':142,'./_copySymbols':144,'./_copySymbolsIn':145,'./_getAllKeys':159,'./_getAllKeysIn':160,'./_getTag':168,'./_initCloneArray':177,'./_initCloneByTag':178,'./_initCloneObject':179,'./isArray':243,'./isBuffer':246,'./isMap':250,'./isObject':251,'./isSet':254,'./keys':259}],81:[function(require,module,exports){ -var isObject = require('./isObject'); - -/** Built-in value references. */ -var objectCreate = Object.create; - -/** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} proto The object to inherit from. - * @returns {Object} Returns the new object. - */ -var baseCreate = (function() { - function object() {} - return function(proto) { - if (!isObject(proto)) { - return {}; - } - if (objectCreate) { - return objectCreate(proto); - } - object.prototype = proto; - var result = new object; - object.prototype = undefined; - return result; - }; -}()); - -module.exports = baseCreate; - -},{'./isObject':251}],82:[function(require,module,exports){ -var baseForOwn = require('./_baseForOwn'), - createBaseEach = require('./_createBaseEach'); - -/** - * The base implementation of `_.forEach` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ -var baseEach = createBaseEach(baseForOwn); - -module.exports = baseEach; - -},{'./_baseForOwn':88,'./_createBaseEach':148}],83:[function(require,module,exports){ -var isSymbol = require('./isSymbol'); - -/** - * The base implementation of methods like `_.max` and `_.min` which accepts a - * `comparator` to determine the extremum value. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per iteration. - * @param {Function} comparator The comparator used to compare values. - * @returns {*} Returns the extremum value. - */ -function baseExtremum(array, iteratee, comparator) { - var index = -1, - length = array.length; - - while (++index < length) { - var value = array[index], - current = iteratee(value); - - if (current != null && (computed === undefined - ? (current === current && !isSymbol(current)) - : comparator(current, computed) - )) { - var computed = current, - result = value; - } - } - return result; -} - -module.exports = baseExtremum; - -},{'./isSymbol':256}],84:[function(require,module,exports){ -var baseEach = require('./_baseEach'); - -/** - * The base implementation of `_.filter` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ -function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function(value, index, collection) { - if (predicate(value, index, collection)) { - result.push(value); - } - }); - return result; -} - -module.exports = baseFilter; - -},{'./_baseEach':82}],85:[function(require,module,exports){ -/** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} - -module.exports = baseFindIndex; - -},{}],86:[function(require,module,exports){ -var arrayPush = require('./_arrayPush'), - isFlattenable = require('./_isFlattenable'); - -/** - * The base implementation of `_.flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ -function baseFlatten(array, depth, predicate, isStrict, result) { - var index = -1, - length = array.length; - - predicate || (predicate = isFlattenable); - result || (result = []); - - while (++index < length) { - var value = array[index]; - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; -} - -module.exports = baseFlatten; - -},{'./_arrayPush':70,'./_isFlattenable':180}],87:[function(require,module,exports){ -var createBaseFor = require('./_createBaseFor'); - -/** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseFor = createBaseFor(); - -module.exports = baseFor; - -},{'./_createBaseFor':149}],88:[function(require,module,exports){ -var baseFor = require('./_baseFor'), - keys = require('./keys'); - -/** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); -} - -module.exports = baseForOwn; - -},{'./_baseFor':87,'./keys':259}],89:[function(require,module,exports){ -var castPath = require('./_castPath'), - toKey = require('./_toKey'); - -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = castPath(path, object); - - var index = 0, - length = path.length; - - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; -} - -module.exports = baseGet; - -},{'./_castPath':133,'./_toKey':223}],90:[function(require,module,exports){ -var arrayPush = require('./_arrayPush'), - isArray = require('./isArray'); - -/** - * The base implementation of `getAllKeys` and `getAllKeysIn` which uses - * `keysFunc` and `symbolsFunc` to get the enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Function} keysFunc The function to get the keys of `object`. - * @param {Function} symbolsFunc The function to get the symbols of `object`. - * @returns {Array} Returns the array of property names and symbols. - */ -function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); -} - -module.exports = baseGetAllKeys; - -},{'./_arrayPush':70,'./isArray':243}],91:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - getRawTag = require('./_getRawTag'), - objectToString = require('./_objectToString'); - -/** `Object#toString` result references. */ -var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; - -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - -/** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag && symToStringTag in Object(value)) - ? getRawTag(value) - : objectToString(value); -} - -module.exports = baseGetTag; - -},{'./_Symbol':60,'./_getRawTag':165,'./_objectToString':205}],92:[function(require,module,exports){ -/** - * The base implementation of `_.gt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - */ -function baseGt(value, other) { - return value > other; -} - -module.exports = baseGt; - -},{}],93:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHas(object, key) { - return object != null && hasOwnProperty.call(object, key); -} - -module.exports = baseHas; - -},{}],94:[function(require,module,exports){ -/** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHasIn(object, key) { - return object != null && key in Object(object); -} - -module.exports = baseHasIn; - -},{}],95:[function(require,module,exports){ -var baseFindIndex = require('./_baseFindIndex'), - baseIsNaN = require('./_baseIsNaN'), - strictIndexOf = require('./_strictIndexOf'); - -/** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseIndexOf(array, value, fromIndex) { - return value === value - ? strictIndexOf(array, value, fromIndex) - : baseFindIndex(array, baseIsNaN, fromIndex); -} - -module.exports = baseIndexOf; - -},{'./_baseFindIndex':85,'./_baseIsNaN':101,'./_strictIndexOf':220}],96:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]'; - -/** - * The base implementation of `_.isArguments`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - */ -function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; -} - -module.exports = baseIsArguments; - -},{'./_baseGetTag':91,'./isObjectLike':252}],97:[function(require,module,exports){ -var baseIsEqualDeep = require('./_baseIsEqualDeep'), - isObjectLike = require('./isObjectLike'); - -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); -} - -module.exports = baseIsEqual; - -},{'./_baseIsEqualDeep':98,'./isObjectLike':252}],98:[function(require,module,exports){ -var Stack = require('./_Stack'), - equalArrays = require('./_equalArrays'), - equalByTag = require('./_equalByTag'), - equalObjects = require('./_equalObjects'), - getTag = require('./_getTag'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isTypedArray = require('./isTypedArray'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - objectTag = '[object Object]'; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = objIsArr ? arrayTag : getTag(object), - othTag = othIsArr ? arrayTag : getTag(other); - - objTag = objTag == argsTag ? objectTag : objTag; - othTag = othTag == argsTag ? objectTag : othTag; - - var objIsObj = objTag == objectTag, - othIsObj = othTag == objectTag, - isSameTag = objTag == othTag; - - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; - } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) - : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; - - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); -} - -module.exports = baseIsEqualDeep; - -},{'./_Stack':59,'./_equalArrays':154,'./_equalByTag':155,'./_equalObjects':156,'./_getTag':168,'./isArray':243,'./isBuffer':246,'./isTypedArray':257}],99:[function(require,module,exports){ -var getTag = require('./_getTag'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]'; - -/** - * The base implementation of `_.isMap` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - */ -function baseIsMap(value) { - return isObjectLike(value) && getTag(value) == mapTag; -} - -module.exports = baseIsMap; - -},{'./_getTag':168,'./isObjectLike':252}],100:[function(require,module,exports){ -var Stack = require('./_Stack'), - baseIsEqual = require('./_baseIsEqual'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; - - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; - - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack; - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) - : result - )) { - return false; - } - } - } - return true; -} - -module.exports = baseIsMatch; - -},{'./_Stack':59,'./_baseIsEqual':97}],101:[function(require,module,exports){ -/** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ -function baseIsNaN(value) { - return value !== value; -} - -module.exports = baseIsNaN; - -},{}],102:[function(require,module,exports){ -var isFunction = require('./isFunction'), - isMasked = require('./_isMasked'), - isObject = require('./isObject'), - toSource = require('./_toSource'); - -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} - -module.exports = baseIsNative; - -},{'./_isMasked':185,'./_toSource':224,'./isFunction':248,'./isObject':251}],103:[function(require,module,exports){ -var getTag = require('./_getTag'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var setTag = '[object Set]'; - -/** - * The base implementation of `_.isSet` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - */ -function baseIsSet(value) { - return isObjectLike(value) && getTag(value) == setTag; -} - -module.exports = baseIsSet; - -},{'./_getTag':168,'./isObjectLike':252}],104:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isLength = require('./isLength'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = -typedArrayTags[errorTag] = typedArrayTags[funcTag] = -typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = -typedArrayTags[setTag] = typedArrayTags[stringTag] = -typedArrayTags[weakMapTag] = false; - -/** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ -function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; -} - -module.exports = baseIsTypedArray; - -},{'./_baseGetTag':91,'./isLength':249,'./isObjectLike':252}],105:[function(require,module,exports){ -var baseMatches = require('./_baseMatches'), - baseMatchesProperty = require('./_baseMatchesProperty'), - identity = require('./identity'), - isArray = require('./isArray'), - property = require('./property'); - -/** - * The base implementation of `_.iteratee`. - * - * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. - */ -function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); - } - return property(value); -} - -module.exports = baseIteratee; - -},{'./_baseMatches':110,'./_baseMatchesProperty':111,'./identity':241,'./isArray':243,'./property':272}],106:[function(require,module,exports){ -var isPrototype = require('./_isPrototype'), - nativeKeys = require('./_nativeKeys'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} - -module.exports = baseKeys; - -},{'./_isPrototype':186,'./_nativeKeys':202}],107:[function(require,module,exports){ -var isObject = require('./isObject'), - isPrototype = require('./_isPrototype'), - nativeKeysIn = require('./_nativeKeysIn'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeysIn(object) { - if (!isObject(object)) { - return nativeKeysIn(object); - } - var isProto = isPrototype(object), - result = []; - - for (var key in object) { - if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; -} - -module.exports = baseKeysIn; - -},{'./_isPrototype':186,'./_nativeKeysIn':203,'./isObject':251}],108:[function(require,module,exports){ -/** - * The base implementation of `_.lt` which doesn't coerce arguments. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - */ -function baseLt(value, other) { - return value < other; -} - -module.exports = baseLt; - -},{}],109:[function(require,module,exports){ -var baseEach = require('./_baseEach'), - isArrayLike = require('./isArrayLike'); - -/** - * The base implementation of `_.map` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function baseMap(collection, iteratee) { - var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; - - baseEach(collection, function(value, key, collection) { - result[++index] = iteratee(value, key, collection); - }); - return result; -} - -module.exports = baseMap; - -},{'./_baseEach':82,'./isArrayLike':244}],110:[function(require,module,exports){ -var baseIsMatch = require('./_baseIsMatch'), - getMatchData = require('./_getMatchData'), - matchesStrictComparable = require('./_matchesStrictComparable'); - -/** - * The base implementation of `_.matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - */ -function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; -} - -module.exports = baseMatches; - -},{'./_baseIsMatch':100,'./_getMatchData':162,'./_matchesStrictComparable':199}],111:[function(require,module,exports){ -var baseIsEqual = require('./_baseIsEqual'), - get = require('./get'), - hasIn = require('./hasIn'), - isKey = require('./_isKey'), - isStrictComparable = require('./_isStrictComparable'), - matchesStrictComparable = require('./_matchesStrictComparable'), - toKey = require('./_toKey'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(toKey(path), srcValue); - } - return function(object) { - var objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); - }; -} - -module.exports = baseMatchesProperty; - -},{'./_baseIsEqual':97,'./_isKey':183,'./_isStrictComparable':187,'./_matchesStrictComparable':199,'./_toKey':223,'./get':238,'./hasIn':240}],112:[function(require,module,exports){ -var Stack = require('./_Stack'), - assignMergeValue = require('./_assignMergeValue'), - baseFor = require('./_baseFor'), - baseMergeDeep = require('./_baseMergeDeep'), - isObject = require('./isObject'), - keysIn = require('./keysIn'), - safeGet = require('./_safeGet'); - -/** - * The base implementation of `_.merge` without support for multiple sources. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {number} srcIndex The index of `source`. - * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ -function baseMerge(object, source, srcIndex, customizer, stack) { - if (object === source) { - return; - } - baseFor(source, function(srcValue, key) { - if (isObject(srcValue)) { - stack || (stack = new Stack); - baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); - } - else { - var newValue = customizer - ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) - : undefined; - - if (newValue === undefined) { - newValue = srcValue; - } - assignMergeValue(object, key, newValue); - } - }, keysIn); -} - -module.exports = baseMerge; - -},{'./_Stack':59,'./_assignMergeValue':74,'./_baseFor':87,'./_baseMergeDeep':113,'./_safeGet':209,'./isObject':251,'./keysIn':260}],113:[function(require,module,exports){ -var assignMergeValue = require('./_assignMergeValue'), - cloneBuffer = require('./_cloneBuffer'), - cloneTypedArray = require('./_cloneTypedArray'), - copyArray = require('./_copyArray'), - initCloneObject = require('./_initCloneObject'), - isArguments = require('./isArguments'), - isArray = require('./isArray'), - isArrayLikeObject = require('./isArrayLikeObject'), - isBuffer = require('./isBuffer'), - isFunction = require('./isFunction'), - isObject = require('./isObject'), - isPlainObject = require('./isPlainObject'), - isTypedArray = require('./isTypedArray'), - safeGet = require('./_safeGet'), - toPlainObject = require('./toPlainObject'); - -/** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {number} srcIndex The index of `source`. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - */ -function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = safeGet(object, key), - srcValue = safeGet(source, key), - stacked = stack.get(srcValue); - - if (stacked) { - assignMergeValue(object, key, stacked); - return; - } - var newValue = customizer - ? customizer(objValue, srcValue, (key + ''), object, source, stack) - : undefined; - - var isCommon = newValue === undefined; - - if (isCommon) { - var isArr = isArray(srcValue), - isBuff = !isArr && isBuffer(srcValue), - isTyped = !isArr && !isBuff && isTypedArray(srcValue); - - newValue = srcValue; - if (isArr || isBuff || isTyped) { - if (isArray(objValue)) { - newValue = objValue; - } - else if (isArrayLikeObject(objValue)) { - newValue = copyArray(objValue); - } - else if (isBuff) { - isCommon = false; - newValue = cloneBuffer(srcValue, true); - } - else if (isTyped) { - isCommon = false; - newValue = cloneTypedArray(srcValue, true); - } - else { - newValue = []; - } - } - else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = objValue; - if (isArguments(objValue)) { - newValue = toPlainObject(objValue); - } - else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { - newValue = initCloneObject(srcValue); - } - } - else { - isCommon = false; - } - } - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, newValue); - mergeFunc(newValue, srcValue, srcIndex, customizer, stack); - stack['delete'](srcValue); - } - assignMergeValue(object, key, newValue); -} - -module.exports = baseMergeDeep; - -},{'./_assignMergeValue':74,'./_cloneBuffer':135,'./_cloneTypedArray':139,'./_copyArray':142,'./_initCloneObject':179,'./_safeGet':209,'./isArguments':242,'./isArray':243,'./isArrayLikeObject':245,'./isBuffer':246,'./isFunction':248,'./isObject':251,'./isPlainObject':253,'./isTypedArray':257,'./toPlainObject':282}],114:[function(require,module,exports){ -var arrayMap = require('./_arrayMap'), - baseIteratee = require('./_baseIteratee'), - baseMap = require('./_baseMap'), - baseSortBy = require('./_baseSortBy'), - baseUnary = require('./_baseUnary'), - compareMultiple = require('./_compareMultiple'), - identity = require('./identity'); - -/** - * The base implementation of `_.orderBy` without param guards. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. - */ -function baseOrderBy(collection, iteratees, orders) { - var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee)); - - var result = baseMap(collection, function(value, key, collection) { - var criteria = arrayMap(iteratees, function(iteratee) { - return iteratee(value); - }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); -} - -module.exports = baseOrderBy; - -},{'./_arrayMap':69,'./_baseIteratee':105,'./_baseMap':109,'./_baseSortBy':124,'./_baseUnary':127,'./_compareMultiple':141,'./identity':241}],115:[function(require,module,exports){ -var basePickBy = require('./_basePickBy'), - hasIn = require('./hasIn'); - -/** - * The base implementation of `_.pick` without support for individual - * property identifiers. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @returns {Object} Returns the new object. - */ -function basePick(object, paths) { - return basePickBy(object, paths, function(value, path) { - return hasIn(object, path); - }); -} - -module.exports = basePick; - -},{'./_basePickBy':116,'./hasIn':240}],116:[function(require,module,exports){ -var baseGet = require('./_baseGet'), - baseSet = require('./_baseSet'), - castPath = require('./_castPath'); - -/** - * The base implementation of `_.pickBy` without support for iteratee shorthands. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - */ -function basePickBy(object, paths, predicate) { - var index = -1, - length = paths.length, - result = {}; - - while (++index < length) { - var path = paths[index], - value = baseGet(object, path); - - if (predicate(value, path)) { - baseSet(result, castPath(path, object), value); - } - } - return result; -} - -module.exports = basePickBy; - -},{'./_baseGet':89,'./_baseSet':122,'./_castPath':133}],117:[function(require,module,exports){ -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; -} - -module.exports = baseProperty; - -},{}],118:[function(require,module,exports){ -var baseGet = require('./_baseGet'); - -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ -function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; -} - -module.exports = basePropertyDeep; - -},{'./_baseGet':89}],119:[function(require,module,exports){ -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil = Math.ceil, - nativeMax = Math.max; - -/** - * The base implementation of `_.range` and `_.rangeRight` which doesn't - * coerce arguments. - * - * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. - */ -function baseRange(start, end, step, fromRight) { - var index = -1, - length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), - result = Array(length); - - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; - } - return result; -} - -module.exports = baseRange; - -},{}],120:[function(require,module,exports){ -/** - * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using `eachFunc`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of - * `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. - */ -function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function(value, index, collection) { - accumulator = initAccum - ? (initAccum = false, value) - : iteratee(accumulator, value, index, collection); - }); - return accumulator; -} - -module.exports = baseReduce; - -},{}],121:[function(require,module,exports){ -var identity = require('./identity'), - overRest = require('./_overRest'), - setToString = require('./_setToString'); - -/** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ -function baseRest(func, start) { - return setToString(overRest(func, start, identity), func + ''); -} - -module.exports = baseRest; - -},{'./_overRest':207,'./_setToString':213,'./identity':241}],122:[function(require,module,exports){ -var assignValue = require('./_assignValue'), - castPath = require('./_castPath'), - isIndex = require('./_isIndex'), - isObject = require('./isObject'), - toKey = require('./_toKey'); - -/** - * The base implementation of `_.set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ -function baseSet(object, path, value, customizer) { - if (!isObject(object)) { - return object; - } - path = castPath(path, object); - - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; - - while (nested != null && ++index < length) { - var key = toKey(path[index]), - newValue = value; - - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = isObject(objValue) - ? objValue - : (isIndex(path[index + 1]) ? [] : {}); - } - } - assignValue(nested, key, newValue); - nested = nested[key]; - } - return object; -} - -module.exports = baseSet; - -},{'./_assignValue':75,'./_castPath':133,'./_isIndex':181,'./_toKey':223,'./isObject':251}],123:[function(require,module,exports){ -var constant = require('./constant'), - defineProperty = require('./_defineProperty'), - identity = require('./identity'); - -/** - * The base implementation of `setToString` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ -var baseSetToString = !defineProperty ? identity : function(func, string) { - return defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant(string), - 'writable': true - }); -}; - -module.exports = baseSetToString; - -},{'./_defineProperty':153,'./constant':228,'./identity':241}],124:[function(require,module,exports){ -/** - * The base implementation of `_.sortBy` which uses `comparer` to define the - * sort order of `array` and replaces criteria objects with their corresponding - * values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ -function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; -} - -module.exports = baseSortBy; - -},{}],125:[function(require,module,exports){ -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} - -module.exports = baseTimes; - -},{}],126:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - arrayMap = require('./_arrayMap'), - isArray = require('./isArray'), - isSymbol = require('./isSymbol'); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isArray(value)) { - // Recursively convert values (susceptible to call stack limits). - return arrayMap(value, baseToString) + ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -module.exports = baseToString; - -},{'./_Symbol':60,'./_arrayMap':69,'./isArray':243,'./isSymbol':256}],127:[function(require,module,exports){ -/** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ -function baseUnary(func) { - return function(value) { - return func(value); - }; -} - -module.exports = baseUnary; - -},{}],128:[function(require,module,exports){ -var SetCache = require('./_SetCache'), - arrayIncludes = require('./_arrayIncludes'), - arrayIncludesWith = require('./_arrayIncludesWith'), - cacheHas = require('./_cacheHas'), - createSet = require('./_createSet'), - setToArray = require('./_setToArray'); - -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** - * The base implementation of `_.uniqBy` without support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new duplicate free array. - */ -function baseUniq(array, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - length = array.length, - isCommon = true, - result = [], - seen = result; - - if (comparator) { - isCommon = false; - includes = arrayIncludesWith; - } - else if (length >= LARGE_ARRAY_SIZE) { - var set = iteratee ? null : createSet(array); - if (set) { - return setToArray(set); - } - isCommon = false; - includes = cacheHas; - seen = new SetCache; - } - else { - seen = iteratee ? [] : result; - } - outer: - while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - value = (comparator || value !== 0) ? value : 0; - if (isCommon && computed === computed) { - var seenIndex = seen.length; - while (seenIndex--) { - if (seen[seenIndex] === computed) { - continue outer; - } - } - if (iteratee) { - seen.push(computed); - } - result.push(value); - } - else if (!includes(seen, computed, comparator)) { - if (seen !== result) { - seen.push(computed); - } - result.push(value); - } - } - return result; -} - -module.exports = baseUniq; - -},{'./_SetCache':58,'./_arrayIncludes':66,'./_arrayIncludesWith':67,'./_cacheHas':131,'./_createSet':152,'./_setToArray':212}],129:[function(require,module,exports){ -var arrayMap = require('./_arrayMap'); - -/** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. - * - * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. - */ -function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); -} - -module.exports = baseValues; - -},{'./_arrayMap':69}],130:[function(require,module,exports){ -/** - * This base implementation of `_.zipObject` which assigns values using `assignFunc`. - * - * @private - * @param {Array} props The property identifiers. - * @param {Array} values The property values. - * @param {Function} assignFunc The function to assign values. - * @returns {Object} Returns the new object. - */ -function baseZipObject(props, values, assignFunc) { - var index = -1, - length = props.length, - valsLength = values.length, - result = {}; - - while (++index < length) { - var value = index < valsLength ? values[index] : undefined; - assignFunc(result, props[index], value); - } - return result; -} - -module.exports = baseZipObject; - -},{}],131:[function(require,module,exports){ -/** - * Checks if a `cache` value for `key` exists. - * - * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function cacheHas(cache, key) { - return cache.has(key); -} - -module.exports = cacheHas; - -},{}],132:[function(require,module,exports){ -var identity = require('./identity'); - -/** - * Casts `value` to `identity` if it's not a function. - * - * @private - * @param {*} value The value to inspect. - * @returns {Function} Returns cast function. - */ -function castFunction(value) { - return typeof value == 'function' ? value : identity; -} - -module.exports = castFunction; - -},{'./identity':241}],133:[function(require,module,exports){ -var isArray = require('./isArray'), - isKey = require('./_isKey'), - stringToPath = require('./_stringToPath'), - toString = require('./toString'); - -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ -function castPath(value, object) { - if (isArray(value)) { - return value; - } - return isKey(value, object) ? [value] : stringToPath(toString(value)); -} - -module.exports = castPath; - -},{'./_isKey':183,'./_stringToPath':222,'./isArray':243,'./toString':283}],134:[function(require,module,exports){ -var Uint8Array = require('./_Uint8Array'); - -/** - * Creates a clone of `arrayBuffer`. - * - * @private - * @param {ArrayBuffer} arrayBuffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. - */ -function cloneArrayBuffer(arrayBuffer) { - var result = new arrayBuffer.constructor(arrayBuffer.byteLength); - new Uint8Array(result).set(new Uint8Array(arrayBuffer)); - return result; -} - -module.exports = cloneArrayBuffer; - -},{'./_Uint8Array':61}],135:[function(require,module,exports){ -var root = require('./_root'); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined, - allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; - -/** - * Creates a clone of `buffer`. - * - * @private - * @param {Buffer} buffer The buffer to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Buffer} Returns the cloned buffer. - */ -function cloneBuffer(buffer, isDeep) { - if (isDeep) { - return buffer.slice(); - } - var length = buffer.length, - result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); - - buffer.copy(result); - return result; -} - -module.exports = cloneBuffer; - -},{'./_root':208}],136:[function(require,module,exports){ -var cloneArrayBuffer = require('./_cloneArrayBuffer'); - -/** - * Creates a clone of `dataView`. - * - * @private - * @param {Object} dataView The data view to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned data view. - */ -function cloneDataView(dataView, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; - return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); -} - -module.exports = cloneDataView; - -},{'./_cloneArrayBuffer':134}],137:[function(require,module,exports){ -/** Used to match `RegExp` flags from their coerced string values. */ -var reFlags = /\w*$/; - -/** - * Creates a clone of `regexp`. - * - * @private - * @param {Object} regexp The regexp to clone. - * @returns {Object} Returns the cloned regexp. - */ -function cloneRegExp(regexp) { - var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); - result.lastIndex = regexp.lastIndex; - return result; -} - -module.exports = cloneRegExp; - -},{}],138:[function(require,module,exports){ -var Symbol = require('./_Symbol'); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; - -/** - * Creates a clone of the `symbol` object. - * - * @private - * @param {Object} symbol The symbol object to clone. - * @returns {Object} Returns the cloned symbol object. - */ -function cloneSymbol(symbol) { - return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; -} - -module.exports = cloneSymbol; - -},{'./_Symbol':60}],139:[function(require,module,exports){ -var cloneArrayBuffer = require('./_cloneArrayBuffer'); - -/** - * Creates a clone of `typedArray`. - * - * @private - * @param {Object} typedArray The typed array to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned typed array. - */ -function cloneTypedArray(typedArray, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; - return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); -} - -module.exports = cloneTypedArray; - -},{'./_cloneArrayBuffer':134}],140:[function(require,module,exports){ -var isSymbol = require('./isSymbol'); - -/** - * Compares values to sort them in ascending order. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. - */ -function compareAscending(value, other) { - if (value !== other) { - var valIsDefined = value !== undefined, - valIsNull = value === null, - valIsReflexive = value === value, - valIsSymbol = isSymbol(value); - - var othIsDefined = other !== undefined, - othIsNull = other === null, - othIsReflexive = other === other, - othIsSymbol = isSymbol(other); - - if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || - (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || - (valIsNull && othIsDefined && othIsReflexive) || - (!valIsDefined && othIsReflexive) || - !valIsReflexive) { - return 1; - } - if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || - (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || - (othIsNull && valIsDefined && valIsReflexive) || - (!othIsDefined && valIsReflexive) || - !othIsReflexive) { - return -1; - } - } - return 0; -} - -module.exports = compareAscending; - -},{'./isSymbol':256}],141:[function(require,module,exports){ -var compareAscending = require('./_compareAscending'); - -/** - * Used by `_.orderBy` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, - * specify an order of "desc" for descending or "asc" for ascending sort order - * of corresponding values. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {boolean[]|string[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. - */ -function compareMultiple(object, other, orders) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length, - ordersLength = orders.length; - - while (++index < length) { - var result = compareAscending(objCriteria[index], othCriteria[index]); - if (result) { - if (index >= ordersLength) { - return result; - } - var order = orders[index]; - return result * (order == 'desc' ? -1 : 1); - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; -} - -module.exports = compareMultiple; - -},{'./_compareAscending':140}],142:[function(require,module,exports){ -/** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ -function copyArray(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; -} - -module.exports = copyArray; - -},{}],143:[function(require,module,exports){ -var assignValue = require('./_assignValue'), - baseAssignValue = require('./_baseAssignValue'); - -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - - var newValue = customizer - ? customizer(object[key], source[key], key, object, source) - : undefined; - - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - baseAssignValue(object, key, newValue); - } else { - assignValue(object, key, newValue); - } - } - return object; -} - -module.exports = copyObject; - -},{'./_assignValue':75,'./_baseAssignValue':79}],144:[function(require,module,exports){ -var copyObject = require('./_copyObject'), - getSymbols = require('./_getSymbols'); - -/** - * Copies own symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ -function copySymbols(source, object) { - return copyObject(source, getSymbols(source), object); -} - -module.exports = copySymbols; - -},{'./_copyObject':143,'./_getSymbols':166}],145:[function(require,module,exports){ -var copyObject = require('./_copyObject'), - getSymbolsIn = require('./_getSymbolsIn'); - -/** - * Copies own and inherited symbols of `source` to `object`. - * - * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. - */ -function copySymbolsIn(source, object) { - return copyObject(source, getSymbolsIn(source), object); -} - -module.exports = copySymbolsIn; - -},{'./_copyObject':143,'./_getSymbolsIn':167}],146:[function(require,module,exports){ -var root = require('./_root'); - -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; - -module.exports = coreJsData; - -},{'./_root':208}],147:[function(require,module,exports){ -var baseRest = require('./_baseRest'), - isIterateeCall = require('./_isIterateeCall'); - -/** - * Creates a function like `_.assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ -function createAssigner(assigner) { - return baseRest(function(object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; - - customizer = (assigner.length > 3 && typeof customizer == 'function') - ? (length--, customizer) - : undefined; - - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); -} - -module.exports = createAssigner; - -},{'./_baseRest':121,'./_isIterateeCall':182}],148:[function(require,module,exports){ -var isArrayLike = require('./isArrayLike'); - -/** - * Creates a `baseEach` or `baseEachRight` function. - * - * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return eachFunc(collection, iteratee); - } - var length = collection.length, - index = fromRight ? length : -1, - iterable = Object(collection); - - while ((fromRight ? index-- : ++index < length)) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; -} - -module.exports = createBaseEach; - -},{'./isArrayLike':244}],149:[function(require,module,exports){ -/** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; -} - -module.exports = createBaseFor; - -},{}],150:[function(require,module,exports){ -var baseIteratee = require('./_baseIteratee'), - isArrayLike = require('./isArrayLike'), - keys = require('./keys'); - -/** - * Creates a `_.find` or `_.findLast` function. - * - * @private - * @param {Function} findIndexFunc The function to find the collection index. - * @returns {Function} Returns the new find function. - */ -function createFind(findIndexFunc) { - return function(collection, predicate, fromIndex) { - var iterable = Object(collection); - if (!isArrayLike(collection)) { - var iteratee = baseIteratee(predicate, 3); - collection = keys(collection); - predicate = function(key) { return iteratee(iterable[key], key, iterable); }; - } - var index = findIndexFunc(collection, predicate, fromIndex); - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; - }; -} - -module.exports = createFind; - -},{'./_baseIteratee':105,'./isArrayLike':244,'./keys':259}],151:[function(require,module,exports){ -var baseRange = require('./_baseRange'), - isIterateeCall = require('./_isIterateeCall'), - toFinite = require('./toFinite'); - -/** - * Creates a `_.range` or `_.rangeRight` function. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new range function. - */ -function createRange(fromRight) { - return function(start, end, step) { - if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { - end = step = undefined; - } - // Ensure the sign of `-0` is preserved. - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); - return baseRange(start, end, step, fromRight); - }; -} - -module.exports = createRange; - -},{'./_baseRange':119,'./_isIterateeCall':182,'./toFinite':279}],152:[function(require,module,exports){ -var Set = require('./_Set'), - noop = require('./noop'), - setToArray = require('./_setToArray'); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** - * Creates a set object of `values`. - * - * @private - * @param {Array} values The values to add to the set. - * @returns {Object} Returns the new set. - */ -var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { - return new Set(values); -}; - -module.exports = createSet; - -},{'./_Set':57,'./_setToArray':212,'./noop':269}],153:[function(require,module,exports){ -var getNative = require('./_getNative'); - -var defineProperty = (function() { - try { - var func = getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} -}()); - -module.exports = defineProperty; - -},{'./_getNative':163}],154:[function(require,module,exports){ -var SetCache = require('./_SetCache'), - arraySome = require('./_arraySome'), - cacheHas = require('./_cacheHas'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - arrLength = array.length, - othLength = other.length; - - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; - - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!cacheHas(seen, othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, bitmask, customizer, stack) - )) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; -} - -module.exports = equalArrays; - -},{'./_SetCache':58,'./_arraySome':72,'./_cacheHas':131}],155:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - Uint8Array = require('./_Uint8Array'), - eq = require('./eq'), - equalArrays = require('./_equalArrays'), - mapToArray = require('./_mapToArray'), - setToArray = require('./_setToArray'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1, - COMPARE_UNORDERED_FLAG = 2; - -/** `Object#toString` result references. */ -var boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - mapTag = '[object Map]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]'; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; - -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; - - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag: - return object.name == other.name && object.message == other.message; - - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); - - case mapTag: - var convert = mapToArray; - - case setTag: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); - stack['delete'](object); - return result; - - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; -} - -module.exports = equalByTag; - -},{'./_Symbol':60,'./_Uint8Array':61,'./_equalArrays':154,'./_mapToArray':198,'./_setToArray':212,'./eq':231}],156:[function(require,module,exports){ -var getAllKeys = require('./_getAllKeys'); - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG, - objProps = getAllKeys(object), - objLength = objProps.length, - othProps = getAllKeys(other), - othLength = othProps.length; - - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); - - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; - - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } - } - stack['delete'](object); - stack['delete'](other); - return result; -} - -module.exports = equalObjects; - -},{'./_getAllKeys':159}],157:[function(require,module,exports){ -var flatten = require('./flatten'), - overRest = require('./_overRest'), - setToString = require('./_setToString'); - -/** - * A specialized version of `baseRest` which flattens the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ -function flatRest(func) { - return setToString(overRest(func, undefined, flatten), func + ''); -} - -module.exports = flatRest; - -},{'./_overRest':207,'./_setToString':213,'./flatten':235}],158:[function(require,module,exports){ -(function (global){ -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -module.exports = freeGlobal; - -}).call(this,typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {}) -},{}],159:[function(require,module,exports){ -var baseGetAllKeys = require('./_baseGetAllKeys'), - getSymbols = require('./_getSymbols'), - keys = require('./keys'); - -/** - * Creates an array of own enumerable property names and symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ -function getAllKeys(object) { - return baseGetAllKeys(object, keys, getSymbols); -} - -module.exports = getAllKeys; - -},{'./_baseGetAllKeys':90,'./_getSymbols':166,'./keys':259}],160:[function(require,module,exports){ -var baseGetAllKeys = require('./_baseGetAllKeys'), - getSymbolsIn = require('./_getSymbolsIn'), - keysIn = require('./keysIn'); - -/** - * Creates an array of own and inherited enumerable property names and - * symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. - */ -function getAllKeysIn(object) { - return baseGetAllKeys(object, keysIn, getSymbolsIn); -} - -module.exports = getAllKeysIn; - -},{'./_baseGetAllKeys':90,'./_getSymbolsIn':167,'./keysIn':260}],161:[function(require,module,exports){ -var isKeyable = require('./_isKeyable'); - -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; -} - -module.exports = getMapData; - -},{'./_isKeyable':184}],162:[function(require,module,exports){ -var isStrictComparable = require('./_isStrictComparable'), - keys = require('./keys'); - -/** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ -function getMatchData(object) { - var result = keys(object), - length = result.length; - - while (length--) { - var key = result[length], - value = object[key]; - - result[length] = [key, value, isStrictComparable(value)]; - } - return result; -} - -module.exports = getMatchData; - -},{'./_isStrictComparable':187,'./keys':259}],163:[function(require,module,exports){ -var baseIsNative = require('./_baseIsNative'), - getValue = require('./_getValue'); - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; -} - -module.exports = getNative; - -},{'./_baseIsNative':102,'./_getValue':169}],164:[function(require,module,exports){ -var overArg = require('./_overArg'); - -/** Built-in value references. */ -var getPrototype = overArg(Object.getPrototypeOf, Object); - -module.exports = getPrototype; - -},{'./_overArg':206}],165:[function(require,module,exports){ -var Symbol = require('./_Symbol'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; - -/** Built-in value references. */ -var symToStringTag = Symbol ? Symbol.toStringTag : undefined; - -/** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ -function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; - - try { - value[symToStringTag] = undefined; - var unmasked = true; - } catch (e) {} - - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; -} - -module.exports = getRawTag; - -},{'./_Symbol':60}],166:[function(require,module,exports){ -var arrayFilter = require('./_arrayFilter'), - stubArray = require('./stubArray'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetSymbols = Object.getOwnPropertySymbols; - -/** - * Creates an array of the own enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ -var getSymbols = !nativeGetSymbols ? stubArray : function(object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); -}; - -module.exports = getSymbols; - -},{'./_arrayFilter':65,'./stubArray':277}],167:[function(require,module,exports){ -var arrayPush = require('./_arrayPush'), - getPrototype = require('./_getPrototype'), - getSymbols = require('./_getSymbols'), - stubArray = require('./stubArray'); - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetSymbols = Object.getOwnPropertySymbols; - -/** - * Creates an array of the own and inherited enumerable symbols of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. - */ -var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { - var result = []; - while (object) { - arrayPush(result, getSymbols(object)); - object = getPrototype(object); - } - return result; -}; - -module.exports = getSymbolsIn; - -},{'./_arrayPush':70,'./_getPrototype':164,'./_getSymbols':166,'./stubArray':277}],168:[function(require,module,exports){ -var DataView = require('./_DataView'), - Map = require('./_Map'), - Promise = require('./_Promise'), - Set = require('./_Set'), - WeakMap = require('./_WeakMap'), - baseGetTag = require('./_baseGetTag'), - toSource = require('./_toSource'); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - setTag = '[object Set]', - weakMapTag = '[object WeakMap]'; - -var dataViewTag = '[object DataView]'; - -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -var getTag = baseGetTag; - -// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = baseGetTag(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; - - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; - }; -} - -module.exports = getTag; - -},{'./_DataView':51,'./_Map':54,'./_Promise':56,'./_Set':57,'./_WeakMap':62,'./_baseGetTag':91,'./_toSource':224}],169:[function(require,module,exports){ -/** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ -function getValue(object, key) { - return object == null ? undefined : object[key]; -} - -module.exports = getValue; - -},{}],170:[function(require,module,exports){ -var castPath = require('./_castPath'), - isArguments = require('./isArguments'), - isArray = require('./isArray'), - isIndex = require('./_isIndex'), - isLength = require('./isLength'), - toKey = require('./_toKey'); - -/** - * Checks if `path` exists on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - */ -function hasPath(object, path, hasFunc) { - path = castPath(path, object); - - var index = -1, - length = path.length, - result = false; - - while (++index < length) { - var key = toKey(path[index]); - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; - } - if (result || ++index != length) { - return result; - } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && isIndex(key, length) && - (isArray(object) || isArguments(object)); -} - -module.exports = hasPath; - -},{'./_castPath':133,'./_isIndex':181,'./_toKey':223,'./isArguments':242,'./isArray':243,'./isLength':249}],171:[function(require,module,exports){ -/** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -var rsZWJ = '\\u200d'; - -/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ -var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); - -/** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ -function hasUnicode(string) { - return reHasUnicode.test(string); -} - -module.exports = hasUnicode; - -},{}],172:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; -} - -module.exports = hashClear; - -},{'./_nativeCreate':201}],173:[function(require,module,exports){ -/** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; -} - -module.exports = hashDelete; - -},{}],174:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; -} - -module.exports = hashGet; - -},{'./_nativeCreate':201}],175:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); -} - -module.exports = hashHas; - -},{'./_nativeCreate':201}],176:[function(require,module,exports){ -var nativeCreate = require('./_nativeCreate'); - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ -function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; -} - -module.exports = hashSet; - -},{'./_nativeCreate':201}],177:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Initializes an array clone. - * - * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. - */ -function initCloneArray(array) { - var length = array.length, - result = new array.constructor(length); - - // Add properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { - result.index = array.index; - result.input = array.input; - } - return result; -} - -module.exports = initCloneArray; - -},{}],178:[function(require,module,exports){ -var cloneArrayBuffer = require('./_cloneArrayBuffer'), - cloneDataView = require('./_cloneDataView'), - cloneRegExp = require('./_cloneRegExp'), - cloneSymbol = require('./_cloneSymbol'), - cloneTypedArray = require('./_cloneTypedArray'); - -/** `Object#toString` result references. */ -var boolTag = '[object Boolean]', - dateTag = '[object Date]', - mapTag = '[object Map]', - numberTag = '[object Number]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. - * - * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. - */ -function initCloneByTag(object, tag, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag: - return cloneArrayBuffer(object); - - case boolTag: - case dateTag: - return new Ctor(+object); - - case dataViewTag: - return cloneDataView(object, isDeep); - - case float32Tag: case float64Tag: - case int8Tag: case int16Tag: case int32Tag: - case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: - return cloneTypedArray(object, isDeep); - - case mapTag: - return new Ctor; - - case numberTag: - case stringTag: - return new Ctor(object); - - case regexpTag: - return cloneRegExp(object); - - case setTag: - return new Ctor; - - case symbolTag: - return cloneSymbol(object); - } -} - -module.exports = initCloneByTag; - -},{'./_cloneArrayBuffer':134,'./_cloneDataView':136,'./_cloneRegExp':137,'./_cloneSymbol':138,'./_cloneTypedArray':139}],179:[function(require,module,exports){ -var baseCreate = require('./_baseCreate'), - getPrototype = require('./_getPrototype'), - isPrototype = require('./_isPrototype'); - -/** - * Initializes an object clone. - * - * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. - */ -function initCloneObject(object) { - return (typeof object.constructor == 'function' && !isPrototype(object)) - ? baseCreate(getPrototype(object)) - : {}; -} - -module.exports = initCloneObject; - -},{'./_baseCreate':81,'./_getPrototype':164,'./_isPrototype':186}],180:[function(require,module,exports){ -var Symbol = require('./_Symbol'), - isArguments = require('./isArguments'), - isArray = require('./isArray'); - -/** Built-in value references. */ -var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; - -/** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ -function isFlattenable(value) { - return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]); -} - -module.exports = isFlattenable; - -},{'./_Symbol':60,'./isArguments':242,'./isArray':243}],181:[function(require,module,exports){ -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - var type = typeof value; - length = length == null ? MAX_SAFE_INTEGER : length; - - return !!length && - (type == 'number' || - (type != 'symbol' && reIsUint.test(value))) && - (value > -1 && value % 1 == 0 && value < length); -} - -module.exports = isIndex; - -},{}],182:[function(require,module,exports){ -var eq = require('./eq'), - isArrayLike = require('./isArrayLike'), - isIndex = require('./_isIndex'), - isObject = require('./isObject'); - -/** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index; - if (type == 'number' - ? (isArrayLike(object) && isIndex(index, object.length)) - : (type == 'string' && index in object) - ) { - return eq(object[index], value); - } - return false; -} - -module.exports = isIterateeCall; - -},{'./_isIndex':181,'./eq':231,'./isArrayLike':244,'./isObject':251}],183:[function(require,module,exports){ -var isArray = require('./isArray'), - isSymbol = require('./isSymbol'); - -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/; - -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); -} - -module.exports = isKey; - -},{'./isArray':243,'./isSymbol':256}],184:[function(require,module,exports){ -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); -} - -module.exports = isKeyable; - -},{}],185:[function(require,module,exports){ -var coreJsData = require('./_coreJsData'); - -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); - -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); -} - -module.exports = isMasked; - -},{'./_coreJsData':146}],186:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - - return value === proto; -} - -module.exports = isPrototype; - -},{}],187:[function(require,module,exports){ -var isObject = require('./isObject'); - -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} - -module.exports = isStrictComparable; - -},{'./isObject':251}],188:[function(require,module,exports){ -/** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ -function listCacheClear() { - this.__data__ = []; - this.size = 0; -} - -module.exports = listCacheClear; - -},{}],189:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - -/** Used for built-in method references. */ -var arrayProto = Array.prototype; - -/** Built-in value references. */ -var splice = arrayProto.splice; - -/** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - --this.size; - return true; -} - -module.exports = listCacheDelete; - -},{'./_assocIndexOf':76}],190:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - -/** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; -} - -module.exports = listCacheGet; - -},{'./_assocIndexOf':76}],191:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - -/** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; -} - -module.exports = listCacheHas; - -},{'./_assocIndexOf':76}],192:[function(require,module,exports){ -var assocIndexOf = require('./_assocIndexOf'); - -/** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; -} - -module.exports = listCacheSet; - -},{'./_assocIndexOf':76}],193:[function(require,module,exports){ -var Hash = require('./_Hash'), - ListCache = require('./_ListCache'), - Map = require('./_Map'); - -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapCacheClear() { - this.size = 0; - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; -} - -module.exports = mapCacheClear; - -},{'./_Hash':52,'./_ListCache':53,'./_Map':54}],194:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapCacheDelete(key) { - var result = getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; -} - -module.exports = mapCacheDelete; - -},{'./_getMapData':161}],195:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); -} - -module.exports = mapCacheGet; - -},{'./_getMapData':161}],196:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); -} - -module.exports = mapCacheHas; - -},{'./_getMapData':161}],197:[function(require,module,exports){ -var getMapData = require('./_getMapData'); - -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - var data = getMapData(this, key), - size = data.size; - - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; -} - -module.exports = mapCacheSet; - -},{'./_getMapData':161}],198:[function(require,module,exports){ -/** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; -} - -module.exports = mapToArray; - -},{}],199:[function(require,module,exports){ -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; -} - -module.exports = matchesStrictComparable; - -},{}],200:[function(require,module,exports){ -var memoize = require('./memoize'); - -/** Used as the maximum memoize cache size. */ -var MAX_MEMOIZE_SIZE = 500; - -/** - * A specialized version of `_.memoize` which clears the memoized function's - * cache when it exceeds `MAX_MEMOIZE_SIZE`. - * - * @private - * @param {Function} func The function to have its output memoized. - * @returns {Function} Returns the new memoized function. - */ -function memoizeCapped(func) { - var result = memoize(func, function(key) { - if (cache.size === MAX_MEMOIZE_SIZE) { - cache.clear(); - } - return key; - }); - - var cache = result.cache; - return result; -} - -module.exports = memoizeCapped; - -},{'./memoize':265}],201:[function(require,module,exports){ -var getNative = require('./_getNative'); - -/* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); - -module.exports = nativeCreate; - -},{'./_getNative':163}],202:[function(require,module,exports){ -var overArg = require('./_overArg'); - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); - -module.exports = nativeKeys; - -},{'./_overArg':206}],203:[function(require,module,exports){ -/** - * This function is like - * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * except that it includes inherited enumerable properties. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function nativeKeysIn(object) { - var result = []; - if (object != null) { - for (var key in Object(object)) { - result.push(key); - } - } - return result; -} - -module.exports = nativeKeysIn; - -},{}],204:[function(require,module,exports){ -var freeGlobal = require('./_freeGlobal'); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports && freeGlobal.process; - -/** Used to access faster Node.js helpers. */ -var nodeUtil = (function() { - try { - // Use `util.types` for Node.js 10+. - var types = freeModule && freeModule.require && freeModule.require('util').types; - - if (types) { - return types; - } - - // Legacy `process.binding('util')` for Node.js < 10. - return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} -}()); - -module.exports = nodeUtil; - -},{'./_freeGlobal':158}],205:[function(require,module,exports){ -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; - -/** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ -function objectToString(value) { - return nativeObjectToString.call(value); -} - -module.exports = objectToString; - -},{}],206:[function(require,module,exports){ -/** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -module.exports = overArg; - -},{}],207:[function(require,module,exports){ -var apply = require('./_apply'); - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * A specialized version of `baseRest` which transforms the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @param {Function} transform The rest array transform. - * @returns {Function} Returns the new function. - */ -function overRest(func, start, transform) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); - - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = transform(array); - return apply(func, this, otherArgs); - }; -} - -module.exports = overRest; - -},{'./_apply':63}],208:[function(require,module,exports){ -var freeGlobal = require('./_freeGlobal'); - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -module.exports = root; - -},{'./_freeGlobal':158}],209:[function(require,module,exports){ -/** - * Gets the value at `key`, unless `key` is "__proto__". - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ -function safeGet(object, key) { - return key == '__proto__' - ? undefined - : object[key]; -} - -module.exports = safeGet; - -},{}],210:[function(require,module,exports){ -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** - * Adds `value` to the array cache. - * - * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; -} - -module.exports = setCacheAdd; - -},{}],211:[function(require,module,exports){ -/** - * Checks if `value` is in the array cache. - * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ -function setCacheHas(value) { - return this.__data__.has(value); -} - -module.exports = setCacheHas; - -},{}],212:[function(require,module,exports){ -/** - * Converts `set` to an array of its values. - * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. - */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function(value) { - result[++index] = value; - }); - return result; -} - -module.exports = setToArray; - -},{}],213:[function(require,module,exports){ -var baseSetToString = require('./_baseSetToString'), - shortOut = require('./_shortOut'); - -/** - * Sets the `toString` method of `func` to return `string`. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ -var setToString = shortOut(baseSetToString); - -module.exports = setToString; - -},{'./_baseSetToString':123,'./_shortOut':214}],214:[function(require,module,exports){ -/** Used to detect hot functions by number of calls within a span of milliseconds. */ -var HOT_COUNT = 800, - HOT_SPAN = 16; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeNow = Date.now; - -/** - * Creates a function that'll short out and invoke `identity` instead - * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` - * milliseconds. - * - * @private - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new shortable function. - */ -function shortOut(func) { - var count = 0, - lastCalled = 0; - - return function() { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); - - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return arguments[0]; - } - } else { - count = 0; - } - return func.apply(undefined, arguments); - }; -} - -module.exports = shortOut; - -},{}],215:[function(require,module,exports){ -var ListCache = require('./_ListCache'); - -/** - * Removes all key-value entries from the stack. - * - * @private - * @name clear - * @memberOf Stack - */ -function stackClear() { - this.__data__ = new ListCache; - this.size = 0; -} - -module.exports = stackClear; - -},{'./_ListCache':53}],216:[function(require,module,exports){ -/** - * Removes `key` and its value from the stack. - * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); - - this.size = data.size; - return result; -} - -module.exports = stackDelete; - -},{}],217:[function(require,module,exports){ -/** - * Gets the stack value for `key`. - * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function stackGet(key) { - return this.__data__.get(key); -} - -module.exports = stackGet; - -},{}],218:[function(require,module,exports){ -/** - * Checks if a stack value for `key` exists. - * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function stackHas(key) { - return this.__data__.has(key); -} - -module.exports = stackHas; - -},{}],219:[function(require,module,exports){ -var ListCache = require('./_ListCache'), - Map = require('./_Map'), - MapCache = require('./_MapCache'); - -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. - */ -function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); - } - data.set(key, value); - this.size = data.size; - return this; -} - -module.exports = stackSet; - -},{'./_ListCache':53,'./_Map':54,'./_MapCache':55}],220:[function(require,module,exports){ -/** - * A specialized version of `_.indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; -} - -module.exports = strictIndexOf; - -},{}],221:[function(require,module,exports){ -var asciiSize = require('./_asciiSize'), - hasUnicode = require('./_hasUnicode'), - unicodeSize = require('./_unicodeSize'); - -/** - * Gets the number of symbols in `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the string size. - */ -function stringSize(string) { - return hasUnicode(string) - ? unicodeSize(string) - : asciiSize(string); -} - -module.exports = stringSize; - -},{'./_asciiSize':73,'./_hasUnicode':171,'./_unicodeSize':225}],222:[function(require,module,exports){ -var memoizeCapped = require('./_memoizeCapped'); - -/** Used to match property names within property paths. */ -var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; - -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; - -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ -var stringToPath = memoizeCapped(function(string) { - var result = []; - if (string.charCodeAt(0) === 46 /* . */) { - result.push(''); - } - string.replace(rePropName, function(match, number, quote, subString) { - result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; -}); - -module.exports = stringToPath; - -},{'./_memoizeCapped':200}],223:[function(require,module,exports){ -var isSymbol = require('./isSymbol'); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -module.exports = toKey; - -},{'./isSymbol':256}],224:[function(require,module,exports){ -/** Used for built-in method references. */ -var funcProto = Function.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to convert. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} - } - return ''; -} - -module.exports = toSource; - -},{}],225:[function(require,module,exports){ -/** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f', - reComboHalfMarksRange = '\\ufe20-\\ufe2f', - rsComboSymbolsRange = '\\u20d0-\\u20ff', - rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, - rsVarRange = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -var rsAstral = '[' + rsAstralRange + ']', - rsCombo = '[' + rsComboRange + ']', - rsFitz = '\\ud83c[\\udffb-\\udfff]', - rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', - rsNonAstral = '[^' + rsAstralRange + ']', - rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', - rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', - rsZWJ = '\\u200d'; - -/** Used to compose unicode regexes. */ -var reOptMod = rsModifier + '?', - rsOptVar = '[' + rsVarRange + ']?', - rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsSeq = rsOptVar + reOptMod + rsOptJoin, - rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - -/** - * Gets the size of a Unicode `string`. - * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ -function unicodeSize(string) { - var result = reUnicode.lastIndex = 0; - while (reUnicode.test(string)) { - ++result; - } - return result; -} - -module.exports = unicodeSize; - -},{}],226:[function(require,module,exports){ -var baseClone = require('./_baseClone'); - -/** Used to compose bitmasks for cloning. */ -var CLONE_SYMBOLS_FLAG = 4; - -/** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @see _.cloneDeep - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true - */ -function clone(value) { - return baseClone(value, CLONE_SYMBOLS_FLAG); -} - -module.exports = clone; - -},{'./_baseClone':80}],227:[function(require,module,exports){ -var baseClone = require('./_baseClone'); - -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1, - CLONE_SYMBOLS_FLAG = 4; - -/** - * This method is like `_.clone` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @see _.clone - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; - * - * var deep = _.cloneDeep(objects); - * console.log(deep[0] === objects[0]); - * // => false - */ -function cloneDeep(value) { - return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); -} - -module.exports = cloneDeep; - -},{'./_baseClone':80}],228:[function(require,module,exports){ -/** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new constant function. - * @example - * - * var objects = _.times(2, _.constant({ 'a': 1 })); - * - * console.log(objects); - * // => [{ 'a': 1 }, { 'a': 1 }] - * - * console.log(objects[0] === objects[1]); - * // => true - */ -function constant(value) { - return function() { - return value; - }; -} - -module.exports = constant; - -},{}],229:[function(require,module,exports){ -var baseRest = require('./_baseRest'), - eq = require('./eq'), - isIterateeCall = require('./_isIterateeCall'), - keysIn = require('./keysIn'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Assigns own and inherited enumerable string keyed properties of source - * objects to the destination object for all destination properties that - * resolve to `undefined`. Source objects are applied from left to right. - * Once a property is set, additional values of the same property are ignored. - * - * **Note:** This method mutates `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaultsDeep - * @example - * - * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ -var defaults = baseRest(function(object, sources) { - object = Object(object); - - var index = -1; - var length = sources.length; - var guard = length > 2 ? sources[2] : undefined; - - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - length = 1; - } - - while (++index < length) { - var source = sources[index]; - var props = keysIn(source); - var propsIndex = -1; - var propsLength = props.length; - - while (++propsIndex < propsLength) { - var key = props[propsIndex]; - var value = object[key]; - - if (value === undefined || - (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { - object[key] = source[key]; - } - } - } - - return object; -}); - -module.exports = defaults; - -},{'./_baseRest':121,'./_isIterateeCall':182,'./eq':231,'./keysIn':260}],230:[function(require,module,exports){ -module.exports = require('./forEach'); - -},{'./forEach':236}],231:[function(require,module,exports){ -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} - -module.exports = eq; - -},{}],232:[function(require,module,exports){ -var arrayFilter = require('./_arrayFilter'), - baseFilter = require('./_baseFilter'), - baseIteratee = require('./_baseIteratee'), - isArray = require('./isArray'); - -/** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * **Note:** Unlike `_.remove`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.reject - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * _.filter(users, function(o) { return !o.active; }); - * // => objects for ['fred'] - * - * // The `_.matches` iteratee shorthand. - * _.filter(users, { 'age': 36, 'active': true }); - * // => objects for ['barney'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, ['active', false]); - * // => objects for ['fred'] - * - * // The `_.property` iteratee shorthand. - * _.filter(users, 'active'); - * // => objects for ['barney'] - */ -function filter(collection, predicate) { - var func = isArray(collection) ? arrayFilter : baseFilter; - return func(collection, baseIteratee(predicate, 3)); -} - -module.exports = filter; - -},{'./_arrayFilter':65,'./_baseFilter':84,'./_baseIteratee':105,'./isArray':243}],233:[function(require,module,exports){ -var createFind = require('./_createFind'), - findIndex = require('./findIndex'); - -/** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.find(users, function(o) { return o.age < 40; }); - * // => object for 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.find(users, { 'age': 1, 'active': true }); - * // => object for 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.find(users, ['active', false]); - * // => object for 'fred' - * - * // The `_.property` iteratee shorthand. - * _.find(users, 'active'); - * // => object for 'barney' - */ -var find = createFind(findIndex); - -module.exports = find; - -},{'./_createFind':150,'./findIndex':234}],234:[function(require,module,exports){ -var baseFindIndex = require('./_baseFindIndex'), - baseIteratee = require('./_baseIteratee'), - toInteger = require('./toInteger'); - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; - -/** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. - * - * @static - * @memberOf _ - * @since 1.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(o) { return o.user == 'barney'; }); - * // => 0 - * - * // The `_.matches` iteratee shorthand. - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findIndex(users, ['active', false]); - * // => 0 - * - * // The `_.property` iteratee shorthand. - * _.findIndex(users, 'active'); - * // => 2 - */ -function findIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax(length + index, 0); - } - return baseFindIndex(array, baseIteratee(predicate, 3), index); -} - -module.exports = findIndex; - -},{'./_baseFindIndex':85,'./_baseIteratee':105,'./toInteger':280}],235:[function(require,module,exports){ -var baseFlatten = require('./_baseFlatten'); - -/** - * Flattens `array` a single level deep. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, [3, [4]], 5]]); - * // => [1, 2, [3, [4]], 5] - */ -function flatten(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, 1) : []; -} - -module.exports = flatten; - -},{'./_baseFlatten':86}],236:[function(require,module,exports){ -var arrayEach = require('./_arrayEach'), - baseEach = require('./_baseEach'), - castFunction = require('./_castFunction'), - isArray = require('./isArray'); - -/** - * Iterates over elements of `collection` and invokes `iteratee` for each element. - * The iteratee is invoked with three arguments: (value, index|key, collection). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" - * property are iterated like arrays. To avoid this behavior use `_.forIn` - * or `_.forOwn` for object iteration. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias each - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEachRight - * @example - * - * _.forEach([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `1` then `2`. - * - * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). - */ -function forEach(collection, iteratee) { - var func = isArray(collection) ? arrayEach : baseEach; - return func(collection, castFunction(iteratee)); -} - -module.exports = forEach; - -},{'./_arrayEach':64,'./_baseEach':82,'./_castFunction':132,'./isArray':243}],237:[function(require,module,exports){ -var baseFor = require('./_baseFor'), - castFunction = require('./_castFunction'), - keysIn = require('./keysIn'); - -/** - * Iterates over own and inherited enumerable string keyed properties of an - * object and invokes `iteratee` for each property. The iteratee is invoked - * with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forInRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forIn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). - */ -function forIn(object, iteratee) { - return object == null - ? object - : baseFor(object, castFunction(iteratee), keysIn); -} - -module.exports = forIn; - -},{'./_baseFor':87,'./_castFunction':132,'./keysIn':260}],238:[function(require,module,exports){ -var baseGet = require('./_baseGet'); - -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ -function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; -} - -module.exports = get; - -},{'./_baseGet':89}],239:[function(require,module,exports){ -var baseHas = require('./_baseHas'), - hasPath = require('./_hasPath'); - -/** - * Checks if `path` is a direct property of `object`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = { 'a': { 'b': 2 } }; - * var other = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b'); - * // => true - * - * _.has(object, ['a', 'b']); - * // => true - * - * _.has(other, 'a'); - * // => false - */ -function has(object, path) { - return object != null && hasPath(object, path, baseHas); -} - -module.exports = has; - -},{'./_baseHas':93,'./_hasPath':170}],240:[function(require,module,exports){ -var baseHasIn = require('./_baseHasIn'), - hasPath = require('./_hasPath'); - -/** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false - */ -function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); -} - -module.exports = hasIn; - -},{'./_baseHasIn':94,'./_hasPath':170}],241:[function(require,module,exports){ -/** - * This method returns the first argument it receives. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'a': 1 }; - * - * console.log(_.identity(object) === object); - * // => true - */ -function identity(value) { - return value; -} - -module.exports = identity; - -},{}],242:[function(require,module,exports){ -var baseIsArguments = require('./_baseIsArguments'), - isObjectLike = require('./isObjectLike'); - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Built-in value references. */ -var propertyIsEnumerable = objectProto.propertyIsEnumerable; - -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); -}; - -module.exports = isArguments; - -},{'./_baseIsArguments':96,'./isObjectLike':252}],243:[function(require,module,exports){ -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; - -module.exports = isArray; - -},{}],244:[function(require,module,exports){ -var isFunction = require('./isFunction'), - isLength = require('./isLength'); - -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} - -module.exports = isArrayLike; - -},{'./isFunction':248,'./isLength':249}],245:[function(require,module,exports){ -var isArrayLike = require('./isArrayLike'), - isObjectLike = require('./isObjectLike'); - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} - -module.exports = isArrayLikeObject; - -},{'./isArrayLike':244,'./isObjectLike':252}],246:[function(require,module,exports){ -var root = require('./_root'), - stubFalse = require('./stubFalse'); - -/** Detect free variable `exports`. */ -var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; - -/** - * Checks if `value` is a buffer. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * _.isBuffer(new Buffer(2)); - * // => true - * - * _.isBuffer(new Uint8Array(2)); - * // => false - */ -var isBuffer = nativeIsBuffer || stubFalse; - -module.exports = isBuffer; - -},{'./_root':208,'./stubFalse':278}],247:[function(require,module,exports){ -var baseKeys = require('./_baseKeys'), - getTag = require('./_getTag'), - isArguments = require('./isArguments'), - isArray = require('./isArray'), - isArrayLike = require('./isArrayLike'), - isBuffer = require('./isBuffer'), - isPrototype = require('./_isPrototype'), - isTypedArray = require('./isTypedArray'); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]', - setTag = '[object Set]'; - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Checks if `value` is an empty object, collection, map, or set. - * - * Objects are considered empty if they have no own enumerable string keyed - * properties. - * - * Array-like values such as `arguments` objects, arrays, buffers, strings, or - * jQuery-like collections are considered empty if they have a `length` of `0`. - * Similarly, maps and sets are considered empty if they have a `size` of `0`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({ 'a': 1 }); - * // => false - */ -function isEmpty(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && - (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || - isBuffer(value) || isTypedArray(value) || isArguments(value))) { - return !value.length; - } - var tag = getTag(value); - if (tag == mapTag || tag == setTag) { - return !value.size; - } - if (isPrototype(value)) { - return !baseKeys(value).length; - } - for (var key in value) { - if (hasOwnProperty.call(value, key)) { - return false; - } - } - return true; -} - -module.exports = isEmpty; - -},{'./_baseKeys':106,'./_getTag':168,'./_isPrototype':186,'./isArguments':242,'./isArray':243,'./isArrayLike':244,'./isBuffer':246,'./isTypedArray':257}],248:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isObject = require('./isObject'); - -/** `Object#toString` result references. */ -var asyncTag = '[object AsyncFunction]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - proxyTag = '[object Proxy]'; - -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - if (!isObject(value)) { - return false; - } - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; -} - -module.exports = isFunction; - -},{'./_baseGetTag':91,'./isObject':251}],249:[function(require,module,exports){ -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; - -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; -} - -module.exports = isLength; - -},{}],250:[function(require,module,exports){ -var baseIsMap = require('./_baseIsMap'), - baseUnary = require('./_baseUnary'), - nodeUtil = require('./_nodeUtil'); - -/* Node.js helper references. */ -var nodeIsMap = nodeUtil && nodeUtil.isMap; - -/** - * Checks if `value` is classified as a `Map` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - * @example - * - * _.isMap(new Map); - * // => true - * - * _.isMap(new WeakMap); - * // => false - */ -var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; - -module.exports = isMap; - -},{'./_baseIsMap':99,'./_baseUnary':127,'./_nodeUtil':204}],251:[function(require,module,exports){ -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return value != null && (type == 'object' || type == 'function'); -} - -module.exports = isObject; - -},{}],252:[function(require,module,exports){ -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return value != null && typeof value == 'object'; -} - -module.exports = isObjectLike; - -},{}],253:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - getPrototype = require('./_getPrototype'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var objectTag = '[object Object]'; - -/** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto = Object.prototype; - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** Used to infer the `Object` constructor. */ -var objectCtorString = funcToString.call(Object); - -/** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @static - * @memberOf _ - * @since 0.8.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ -function isPlainObject(value) { - if (!isObjectLike(value) || baseGetTag(value) != objectTag) { - return false; - } - var proto = getPrototype(value); - if (proto === null) { - return true; - } - var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; - return typeof Ctor == 'function' && Ctor instanceof Ctor && - funcToString.call(Ctor) == objectCtorString; -} - -module.exports = isPlainObject; - -},{'./_baseGetTag':91,'./_getPrototype':164,'./isObjectLike':252}],254:[function(require,module,exports){ -var baseIsSet = require('./_baseIsSet'), - baseUnary = require('./_baseUnary'), - nodeUtil = require('./_nodeUtil'); - -/* Node.js helper references. */ -var nodeIsSet = nodeUtil && nodeUtil.isSet; - -/** - * Checks if `value` is classified as a `Set` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - * @example - * - * _.isSet(new Set); - * // => true - * - * _.isSet(new WeakSet); - * // => false - */ -var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; - -module.exports = isSet; - -},{'./_baseIsSet':103,'./_baseUnary':127,'./_nodeUtil':204}],255:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isArray = require('./isArray'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var stringTag = '[object String]'; - -/** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ -function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); -} - -module.exports = isString; - -},{'./_baseGetTag':91,'./isArray':243,'./isObjectLike':252}],256:[function(require,module,exports){ -var baseGetTag = require('./_baseGetTag'), - isObjectLike = require('./isObjectLike'); - -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && baseGetTag(value) == symbolTag); -} - -module.exports = isSymbol; - -},{'./_baseGetTag':91,'./isObjectLike':252}],257:[function(require,module,exports){ -var baseIsTypedArray = require('./_baseIsTypedArray'), - baseUnary = require('./_baseUnary'), - nodeUtil = require('./_nodeUtil'); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; - -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - -module.exports = isTypedArray; - -},{'./_baseIsTypedArray':104,'./_baseUnary':127,'./_nodeUtil':204}],258:[function(require,module,exports){ -/** - * Checks if `value` is `undefined`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - * - * _.isUndefined(null); - * // => false - */ -function isUndefined(value) { - return value === undefined; -} - -module.exports = isUndefined; - -},{}],259:[function(require,module,exports){ -var arrayLikeKeys = require('./_arrayLikeKeys'), - baseKeys = require('./_baseKeys'), - isArrayLike = require('./isArrayLike'); - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} - -module.exports = keys; - -},{'./_arrayLikeKeys':68,'./_baseKeys':106,'./isArrayLike':244}],260:[function(require,module,exports){ -var arrayLikeKeys = require('./_arrayLikeKeys'), - baseKeysIn = require('./_baseKeysIn'), - isArrayLike = require('./isArrayLike'); - -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -function keysIn(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); -} - -module.exports = keysIn; - -},{'./_arrayLikeKeys':68,'./_baseKeysIn':107,'./isArrayLike':244}],261:[function(require,module,exports){ -/** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - */ -function last(array) { - var length = array == null ? 0 : array.length; - return length ? array[length - 1] : undefined; -} - -module.exports = last; - -},{}],262:[function(require,module,exports){ -var arrayMap = require('./_arrayMap'), - baseIteratee = require('./_baseIteratee'), - baseMap = require('./_baseMap'), - isArray = require('./isArray'); - -/** - * Creates an array of values by running each element in `collection` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, - * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, - * `template`, `trim`, `trimEnd`, `trimStart`, and `words` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n; - * } - * - * _.map([4, 8], square); - * // => [16, 64] - * - * _.map({ 'a': 4, 'b': 8 }, square); - * // => [16, 64] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; - * - * // The `_.property` iteratee shorthand. - * _.map(users, 'user'); - * // => ['barney', 'fred'] - */ -function map(collection, iteratee) { - var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, baseIteratee(iteratee, 3)); -} - -module.exports = map; - -},{'./_arrayMap':69,'./_baseIteratee':105,'./_baseMap':109,'./isArray':243}],263:[function(require,module,exports){ -var baseAssignValue = require('./_baseAssignValue'), - baseForOwn = require('./_baseForOwn'), - baseIteratee = require('./_baseIteratee'); - -/** - * Creates an object with the same keys as `object` and values generated - * by running each own enumerable string keyed property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, key, object). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapKeys - * @example - * - * var users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * }; - * - * _.mapValues(users, function(o) { return o.age; }); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - * - * // The `_.property` iteratee shorthand. - * _.mapValues(users, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) - */ -function mapValues(object, iteratee) { - var result = {}; - iteratee = baseIteratee(iteratee, 3); - - baseForOwn(object, function(value, key, object) { - baseAssignValue(result, key, iteratee(value, key, object)); - }); - return result; -} - -module.exports = mapValues; - -},{'./_baseAssignValue':79,'./_baseForOwn':88,'./_baseIteratee':105}],264:[function(require,module,exports){ -var baseExtremum = require('./_baseExtremum'), - baseGt = require('./_baseGt'), - identity = require('./identity'); - -/** - * Computes the maximum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the maximum value. - * @example - * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * _.max([]); - * // => undefined - */ -function max(array) { - return (array && array.length) - ? baseExtremum(array, identity, baseGt) - : undefined; -} - -module.exports = max; - -},{'./_baseExtremum':83,'./_baseGt':92,'./identity':241}],265:[function(require,module,exports){ -var MapCache = require('./_MapCache'); - -/** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `clear`, `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; - */ -function memoize(func, resolver) { - if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; - - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result) || cache; - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; -} - -// Expose `MapCache`. -memoize.Cache = MapCache; - -module.exports = memoize; - -},{'./_MapCache':55}],266:[function(require,module,exports){ -var baseMerge = require('./_baseMerge'), - createAssigner = require('./_createAssigner'); - -/** - * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @example - * - * var object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * }; - * - * var other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * }; - * - * _.merge(object, other); - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } - */ -var merge = createAssigner(function(object, source, srcIndex) { - baseMerge(object, source, srcIndex); -}); - -module.exports = merge; - -},{'./_baseMerge':112,'./_createAssigner':147}],267:[function(require,module,exports){ -var baseExtremum = require('./_baseExtremum'), - baseLt = require('./_baseLt'), - identity = require('./identity'); - -/** - * Computes the minimum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the minimum value. - * @example - * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * _.min([]); - * // => undefined - */ -function min(array) { - return (array && array.length) - ? baseExtremum(array, identity, baseLt) - : undefined; -} - -module.exports = min; - -},{'./_baseExtremum':83,'./_baseLt':108,'./identity':241}],268:[function(require,module,exports){ -var baseExtremum = require('./_baseExtremum'), - baseIteratee = require('./_baseIteratee'), - baseLt = require('./_baseLt'); - -/** - * This method is like `_.min` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the minimum value. - * @example - * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; - * - * _.minBy(objects, function(o) { return o.n; }); - * // => { 'n': 1 } - * - * // The `_.property` iteratee shorthand. - * _.minBy(objects, 'n'); - * // => { 'n': 1 } - */ -function minBy(array, iteratee) { - return (array && array.length) - ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt) - : undefined; -} - -module.exports = minBy; - -},{'./_baseExtremum':83,'./_baseIteratee':105,'./_baseLt':108}],269:[function(require,module,exports){ -/** - * This method returns `undefined`. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Util - * @example - * - * _.times(2, _.noop); - * // => [undefined, undefined] - */ -function noop() { - // No operation performed. -} - -module.exports = noop; - -},{}],270:[function(require,module,exports){ -var root = require('./_root'); - -/** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. - */ -var now = function() { - return root.Date.now(); -}; - -module.exports = now; - -},{'./_root':208}],271:[function(require,module,exports){ -var basePick = require('./_basePick'), - flatRest = require('./_flatRest'); - -/** - * Creates an object composed of the picked `object` properties. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. - * @example - * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } - */ -var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, paths); -}); - -module.exports = pick; - -},{'./_basePick':115,'./_flatRest':157}],272:[function(require,module,exports){ -var baseProperty = require('./_baseProperty'), - basePropertyDeep = require('./_basePropertyDeep'), - isKey = require('./_isKey'), - toKey = require('./_toKey'); - -/** - * Creates a function that returns the value at `path` of a given object. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - * @example - * - * var objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ]; - * - * _.map(objects, _.property('a.b')); - * // => [2, 1] - * - * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); - * // => [1, 2] - */ -function property(path) { - return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); -} - -module.exports = property; - -},{'./_baseProperty':117,'./_basePropertyDeep':118,'./_isKey':183,'./_toKey':223}],273:[function(require,module,exports){ -var createRange = require('./_createRange'); - -/** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. A step of `-1` is used if a negative - * `start` is specified without an `end` or `step`. If `end` is not specified, - * it's set to `start` with `start` then set to `0`. - * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see _.inRange, _.rangeRight - * @example - * - * _.range(4); - * // => [0, 1, 2, 3] - * - * _.range(-4); - * // => [0, -1, -2, -3] - * - * _.range(1, 5); - * // => [1, 2, 3, 4] - * - * _.range(0, 20, 5); - * // => [0, 5, 10, 15] - * - * _.range(0, -4, -1); - * // => [0, -1, -2, -3] - * - * _.range(1, 4, 0); - * // => [1, 1, 1] - * - * _.range(0); - * // => [] - */ -var range = createRange(); - -module.exports = range; - -},{'./_createRange':151}],274:[function(require,module,exports){ -var arrayReduce = require('./_arrayReduce'), - baseEach = require('./_baseEach'), - baseIteratee = require('./_baseIteratee'), - baseReduce = require('./_baseReduce'), - isArray = require('./isArray'); - -/** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` thru `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not given, the first element of `collection` is used as the initial - * value. The iteratee is invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. - * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, - * and `sortBy` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduceRight - * @example - * - * _.reduce([1, 2], function(sum, n) { - * return sum + n; - * }, 0); - * // => 3 - * - * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * return result; - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) - */ -function reduce(collection, iteratee, accumulator) { - var func = isArray(collection) ? arrayReduce : baseReduce, - initAccum = arguments.length < 3; - - return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach); -} - -module.exports = reduce; - -},{'./_arrayReduce':71,'./_baseEach':82,'./_baseIteratee':105,'./_baseReduce':120,'./isArray':243}],275:[function(require,module,exports){ -var baseKeys = require('./_baseKeys'), - getTag = require('./_getTag'), - isArrayLike = require('./isArrayLike'), - isString = require('./isString'), - stringSize = require('./_stringSize'); - -/** `Object#toString` result references. */ -var mapTag = '[object Map]', - setTag = '[object Set]'; - -/** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable string keyed properties for objects. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the collection size. - * @example - * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 - * - * _.size('pebbles'); - * // => 7 - */ -function size(collection) { - if (collection == null) { - return 0; - } - if (isArrayLike(collection)) { - return isString(collection) ? stringSize(collection) : collection.length; - } - var tag = getTag(collection); - if (tag == mapTag || tag == setTag) { - return collection.size; - } - return baseKeys(collection).length; -} - -module.exports = size; - -},{'./_baseKeys':106,'./_getTag':168,'./_stringSize':221,'./isArrayLike':244,'./isString':255}],276:[function(require,module,exports){ -var baseFlatten = require('./_baseFlatten'), - baseOrderBy = require('./_baseOrderBy'), - baseRest = require('./_baseRest'), - isIterateeCall = require('./_isIterateeCall'); - -/** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection thru each iteratee. This method - * performs a stable sort, that is, it preserves the original sort order of - * equal elements. The iteratees are invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to sort by. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - * - * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] - */ -var sortBy = baseRest(function(collection, iteratees) { - if (collection == null) { - return []; - } - var length = iteratees.length; - if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { - iteratees = []; - } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { - iteratees = [iteratees[0]]; - } - return baseOrderBy(collection, baseFlatten(iteratees, 1), []); -}); - -module.exports = sortBy; - -},{'./_baseFlatten':86,'./_baseOrderBy':114,'./_baseRest':121,'./_isIterateeCall':182}],277:[function(require,module,exports){ -/** - * This method returns a new empty array. - * - * @static - * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {Array} Returns the new empty array. - * @example - * - * var arrays = _.times(2, _.stubArray); - * - * console.log(arrays); - * // => [[], []] - * - * console.log(arrays[0] === arrays[1]); - * // => false - */ -function stubArray() { - return []; -} - -module.exports = stubArray; - -},{}],278:[function(require,module,exports){ -/** - * This method returns `false`. - * - * @static - * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {boolean} Returns `false`. - * @example - * - * _.times(2, _.stubFalse); - * // => [false, false] - */ -function stubFalse() { - return false; -} - -module.exports = stubFalse; - -},{}],279:[function(require,module,exports){ -var toNumber = require('./toNumber'); - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0, - MAX_INTEGER = 1.7976931348623157e+308; - -/** - * Converts `value` to a finite number. - * - * @static - * @memberOf _ - * @since 4.12.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted number. - * @example - * - * _.toFinite(3.2); - * // => 3.2 - * - * _.toFinite(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toFinite(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toFinite('3.2'); - * // => 3.2 - */ -function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY || value === -INFINITY) { - var sign = (value < 0 ? -1 : 1); - return sign * MAX_INTEGER; - } - return value === value ? value : 0; -} - -module.exports = toFinite; - -},{'./toNumber':281}],280:[function(require,module,exports){ -var toFinite = require('./toFinite'); - -/** - * Converts `value` to an integer. - * - * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toInteger(3.2); - * // => 3 - * - * _.toInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toInteger(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toInteger('3.2'); - * // => 3 - */ -function toInteger(value) { - var result = toFinite(value), - remainder = result % 1; - - return result === result ? (remainder ? result - remainder : result) : 0; -} - -module.exports = toInteger; - -},{'./toFinite':279}],281:[function(require,module,exports){ -var isObject = require('./isObject'), - isSymbol = require('./isSymbol'); - -/** Used as references for various `Number` constants. */ -var NAN = 0 / 0; - -/** Used to match leading and trailing whitespace. */ -var reTrim = /^\s+|\s+$/g; - -/** Used to detect bad signed hexadecimal string values. */ -var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - -/** Used to detect binary string values. */ -var reIsBinary = /^0b[01]+$/i; - -/** Used to detect octal string values. */ -var reIsOctal = /^0o[0-7]+$/i; - -/** Built-in method references without a dependency on `root`. */ -var freeParseInt = parseInt; - -/** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3.2'); - * // => 3.2 - */ -function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - if (isObject(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject(other) ? (other + '') : other; - } - if (typeof value != 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); -} - -module.exports = toNumber; - -},{'./isObject':251,'./isSymbol':256}],282:[function(require,module,exports){ -var copyObject = require('./_copyObject'), - keysIn = require('./keysIn'); - -/** - * Converts `value` to a plain object flattening inherited enumerable string - * keyed properties of `value` to own properties of the plain object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. - * @example - * - * function Foo() { - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.assign({ 'a': 1 }, new Foo); - * // => { 'a': 1, 'b': 2 } - * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } - */ -function toPlainObject(value) { - return copyObject(value, keysIn(value)); -} - -module.exports = toPlainObject; - -},{'./_copyObject':143,'./keysIn':260}],283:[function(require,module,exports){ -var baseToString = require('./_baseToString'); - -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - return value == null ? '' : baseToString(value); -} - -module.exports = toString; - -},{'./_baseToString':126}],284:[function(require,module,exports){ -var arrayEach = require('./_arrayEach'), - baseCreate = require('./_baseCreate'), - baseForOwn = require('./_baseForOwn'), - baseIteratee = require('./_baseIteratee'), - getPrototype = require('./_getPrototype'), - isArray = require('./isArray'), - isBuffer = require('./isBuffer'), - isFunction = require('./isFunction'), - isObject = require('./isObject'), - isTypedArray = require('./isTypedArray'); - -/** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable string keyed properties thru `iteratee`, with each invocation - * potentially mutating the `accumulator` object. If `accumulator` is not - * provided, a new object with the same `[[Prototype]]` will be used. The - * iteratee is invoked with four arguments: (accumulator, value, key, object). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @returns {*} Returns the accumulated value. - * @example - * - * _.transform([2, 3, 4], function(result, n) { - * result.push(n *= n); - * return n % 2 == 0; - * }, []); - * // => [4, 9] - * - * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } - */ -function transform(object, iteratee, accumulator) { - var isArr = isArray(object), - isArrLike = isArr || isBuffer(object) || isTypedArray(object); - - iteratee = baseIteratee(iteratee, 4); - if (accumulator == null) { - var Ctor = object && object.constructor; - if (isArrLike) { - accumulator = isArr ? new Ctor : []; - } - else if (isObject(object)) { - accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; - } - else { - accumulator = {}; - } - } - (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); - return accumulator; -} - -module.exports = transform; - -},{'./_arrayEach':64,'./_baseCreate':81,'./_baseForOwn':88,'./_baseIteratee':105,'./_getPrototype':164,'./isArray':243,'./isBuffer':246,'./isFunction':248,'./isObject':251,'./isTypedArray':257}],285:[function(require,module,exports){ -var baseFlatten = require('./_baseFlatten'), - baseRest = require('./_baseRest'), - baseUniq = require('./_baseUniq'), - isArrayLikeObject = require('./isArrayLikeObject'); - -/** - * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of combined values. - * @example - * - * _.union([2], [1, 2]); - * // => [2, 1] - */ -var union = baseRest(function(arrays) { - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); -}); - -module.exports = union; - -},{'./_baseFlatten':86,'./_baseRest':121,'./_baseUniq':128,'./isArrayLikeObject':245}],286:[function(require,module,exports){ -var toString = require('./toString'); - -/** Used to generate unique IDs. */ -var idCounter = 0; - -/** - * Generates a unique ID. If `prefix` is given, the ID is appended to it. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {string} [prefix=''] The value to prefix the ID with. - * @returns {string} Returns the unique ID. - * @example - * - * _.uniqueId('contact_'); - * // => 'contact_104' - * - * _.uniqueId(); - * // => '105' - */ -function uniqueId(prefix) { - var id = ++idCounter; - return toString(prefix) + id; -} - -module.exports = uniqueId; - -},{'./toString':283}],287:[function(require,module,exports){ -var baseValues = require('./_baseValues'), - keys = require('./keys'); - -/** - * Creates an array of the own enumerable string keyed property values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.values(new Foo); - * // => [1, 2] (iteration order is not guaranteed) - * - * _.values('hi'); - * // => ['h', 'i'] - */ -function values(object) { - return object == null ? [] : baseValues(object, keys(object)); -} - -module.exports = values; - -},{'./_baseValues':129,'./keys':259}],288:[function(require,module,exports){ -var assignValue = require('./_assignValue'), - baseZipObject = require('./_baseZipObject'); - -/** - * This method is like `_.fromPairs` except that it accepts two arrays, - * one of property identifiers and one of corresponding values. - * - * @static - * @memberOf _ - * @since 0.4.0 - * @category Array - * @param {Array} [props=[]] The property identifiers. - * @param {Array} [values=[]] The property values. - * @returns {Object} Returns the new object. - * @example - * - * _.zipObject(['a', 'b'], [1, 2]); - * // => { 'a': 1, 'b': 2 } - */ -function zipObject(props, values) { - return baseZipObject(props || [], values || [], assignValue); -} - -module.exports = zipObject; - -},{'./_assignValue':75,'./_baseZipObject':130}]},{},[1])(1) -}); diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py index d6666e8b74..5cb98e6781 100644 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py +++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_inspector_overlay.py @@ -39,13 +39,24 @@ def check_size(filename, data, max_size): def rollup(input_path, output_path, filename, max_size, rollup_plugin): target = join(input_path, filename) - rollup_process = subprocess.Popen( - [devtools_paths.node_path(), - devtools_paths.rollup_path()] + - ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] + - ['--plugin', rollup_plugin], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + if sys.version_info[0] < 3: + rollup_process = subprocess.Popen( + [devtools_paths.node_path(), + devtools_paths.rollup_path()] + + ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] + + ['--plugin', rollup_plugin], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + else: + rollup_process = subprocess.Popen( + [devtools_paths.node_path(), + devtools_paths.rollup_path()] + + ['--format', 'iife', '-n', 'InspectorOverlay'] + ['--input', target] + + ['--plugin', rollup_plugin], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True) + out, error = rollup_process.communicate() if not out: raise Exception("rollup failed: " + error) diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py index fa8e73d34a..414d59ec56 100644 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py +++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/build_release_applications.py @@ -10,14 +10,17 @@ and the application loader into a single script. """ -from cStringIO import StringIO +import sys +if sys.version_info.major == 3: + from io import StringIO # for Python 3 +else: + from cStringIO import StringIO # for Python 2 from os import path from os.path import join import copy import os import re import shutil -import sys import subprocess from modular_build import read_file, write_file, bail_error @@ -37,6 +40,9 @@ finally: sys.path = original_sys_path +if sys.version_info.major == 3: + unicode = str + FRONT_END_DIRECTORY = path.join(os.path.dirname(path.abspath(__file__)), '..', '..', 'front_end') @@ -145,8 +151,11 @@ def _write_module_resources(self, resource_names, output): resource_content = read_file(path.join(self.application_dir, resource_name)) if not (resource_name.endswith('.html') or resource_name.endswith('md')): - resource_content += resource_source_url(resource_name).encode( - 'utf-8') + if sys.version_info[0] < 3: + resource_content += resource_source_url(resource_name).encode( + 'utf-8') + else: + resource_content += resource_source_url(resource_name) resource_content = resource_content.replace('\\', '\\\\') resource_content = resource_content.replace('\n', '\\n') resource_content = resource_content.replace('"', '\\"') @@ -173,7 +182,9 @@ def _concatenate_autostart_modules(self, output): def _concatenate_application_script(self, output): output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors()) if self.descriptors.extends: - output.write('Root.applicationDescriptor.modules.push(...%s);' % json.dumps(self.descriptors.application.values())) + output.write( + 'Root.applicationDescriptor.modules.push(...%s);' % + json.dumps(list(self.descriptors.application.values()))) else: output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json()) diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py index be510c48d7..c6a59c9029 100644 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py +++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/generate_devtools_grd.py @@ -123,7 +123,7 @@ def main(argv): try: os.makedirs(path.join(output_directory, 'Images')) - except OSError, e: + except OSError as e: if e.errno != errno.EEXIST: raise e @@ -147,7 +147,7 @@ def main(argv): shutil.copy(path.join(dirname, filename), path.join(output_directory, 'Images')) add_file_to_grd(doc, path.join('Images', filename)) - with open(parsed_args.output_filename, 'w') as output_file: + with open(parsed_args.output_filename, 'wb') as output_file: output_file.write(doc.toxml(encoding='UTF-8')) diff --git a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py index 0ba695d381..bb1da2f9f8 100644 --- a/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py +++ b/src/3rdparty/chromium/third_party/devtools-frontend/src/scripts/build/modular_build.py @@ -7,6 +7,8 @@ Utilities for the modular DevTools build. """ +from __future__ import print_function + import collections from os import path import os @@ -40,7 +42,7 @@ def load_and_parse_json(filename): try: return json.loads(read_file(filename)) except: - print 'ERROR: Failed to parse %s' % filename + print('ERROR: Failed to parse %s' % filename) raise class Descriptors: @@ -57,7 +59,7 @@ def __init__(self, application_name, application_dir, def application_json(self): result = dict() - result['modules'] = self.application.values() + result['modules'] = list(self.application.values()) return json.dumps(result) def all_compiled_files(self): diff --git a/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h b/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h index 6298f5ed19..ca7e2dffc1 100644 --- a/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h +++ b/src/3rdparty/chromium/third_party/ffmpeg/libavcodec/x86/mathops.h @@ -35,12 +35,20 @@ static av_always_inline av_const int MULL(int a, int b, unsigned shift) { int rt, dummy; + if (__builtin_constant_p(shift)) __asm__ ( "imull %3 \n\t" "shrdl %4, %%edx, %%eax \n\t" :"=a"(rt), "=d"(dummy) - :"a"(a), "rm"(b), "ci"((uint8_t)shift) + :"a"(a), "rm"(b), "i"(shift & 0x1F) ); + else + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) + :"a"(a), "rm"(b), "c"((uint8_t)shift) + ); return rt; } @@ -113,19 +121,31 @@ __asm__ volatile(\ // avoid +32 for shift optimization (gcc should do that ...) #define NEG_SSR32 NEG_SSR32 static inline int32_t NEG_SSR32( int32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("sarl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; } #define NEG_USR32 NEG_USR32 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("shrl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; } diff --git a/src/3rdparty/chromium/third_party/jinja2/tests.py b/src/3rdparty/chromium/third_party/jinja2/tests.py index 0adc3d4dbc..d3e56108cf 100644 --- a/src/3rdparty/chromium/third_party/jinja2/tests.py +++ b/src/3rdparty/chromium/third_party/jinja2/tests.py @@ -10,7 +10,11 @@ """ import operator import re -from collections import Mapping +import sys +if sys.version_info[0] > 2: + from collections.abc import Mapping +else: + from collections import Mapping from jinja2.runtime import Undefined from jinja2._compat import text_type, string_types, integer_types import decimal diff --git a/src/3rdparty/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c b/src/3rdparty/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c index aeed719d1f..369adbdcba 100644 --- a/src/3rdparty/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c +++ b/src/3rdparty/chromium/third_party/libvpx/source/libvpx/vp8/encoder/onyx_if.c @@ -1445,6 +1445,11 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) { last_h = cpi->oxcf.Height; prev_number_of_layers = cpi->oxcf.number_of_layers; + if (cpi->initial_width) { + // TODO(https://crbug.com/1486441): Allow changing thread counts; the + // allocation is done once in vp8_create_compressor(). + oxcf->multi_threaded = cpi->oxcf.multi_threaded; + } cpi->oxcf = *oxcf; switch (cpi->oxcf.Mode) { diff --git a/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8l_dec.c b/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8l_dec.c index 93615d4ed2..0d38314db8 100644 --- a/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8l_dec.c +++ b/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8l_dec.c @@ -253,11 +253,11 @@ static int ReadHuffmanCodeLengths( int symbol; int max_symbol; int prev_code_len = DEFAULT_CODE_LENGTH; - HuffmanCode table[1 << LENGTHS_TABLE_BITS]; + HuffmanTables tables; - if (!VP8LBuildHuffmanTable(table, LENGTHS_TABLE_BITS, - code_length_code_lengths, - NUM_CODE_LENGTH_CODES)) { + if (!VP8LHuffmanTablesAllocate(1 << LENGTHS_TABLE_BITS, &tables) || + !VP8LBuildHuffmanTable(&tables, LENGTHS_TABLE_BITS, + code_length_code_lengths, NUM_CODE_LENGTH_CODES)) { goto End; } @@ -277,7 +277,7 @@ static int ReadHuffmanCodeLengths( int code_len; if (max_symbol-- == 0) break; VP8LFillBitWindow(br); - p = &table[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK]; + p = &tables.curr_segment->start[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK]; VP8LSetBitPos(br, br->bit_pos_ + p->bits); code_len = p->value; if (code_len < kCodeLengthLiterals) { @@ -300,6 +300,7 @@ static int ReadHuffmanCodeLengths( ok = 1; End: + VP8LHuffmanTablesDeallocate(&tables); if (!ok) dec->status_ = VP8_STATUS_BITSTREAM_ERROR; return ok; } @@ -307,7 +308,8 @@ static int ReadHuffmanCodeLengths( // 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman // tree. static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec, - int* const code_lengths, HuffmanCode* const table) { + int* const code_lengths, + HuffmanTables* const table) { int ok = 0; int size = 0; VP8LBitReader* const br = &dec->br_; @@ -362,8 +364,7 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, VP8LMetadata* const hdr = &dec->hdr_; uint32_t* huffman_image = NULL; HTreeGroup* htree_groups = NULL; - HuffmanCode* huffman_tables = NULL; - HuffmanCode* huffman_table = NULL; + HuffmanTables* huffman_tables = &hdr->huffman_tables_; int num_htree_groups = 1; int num_htree_groups_max = 1; int max_alphabet_size = 0; @@ -372,6 +373,10 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, int* mapping = NULL; int ok = 0; + // Check the table has been 0 initialized (through InitMetadata). + assert(huffman_tables->root.start == NULL); + assert(huffman_tables->curr_segment == NULL); + if (allow_recursion && VP8LReadBits(br, 1)) { // use meta Huffman codes. const int huffman_precision = VP8LReadBits(br, 3) + 2; @@ -434,16 +439,15 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, code_lengths = (int*)WebPSafeCalloc((uint64_t)max_alphabet_size, sizeof(*code_lengths)); - huffman_tables = (HuffmanCode*)WebPSafeMalloc(num_htree_groups * table_size, - sizeof(*huffman_tables)); htree_groups = VP8LHtreeGroupsNew(num_htree_groups); - if (htree_groups == NULL || code_lengths == NULL || huffman_tables == NULL) { + if (htree_groups == NULL || code_lengths == NULL || + !VP8LHuffmanTablesAllocate(num_htree_groups * table_size, + huffman_tables)) { dec->status_ = VP8_STATUS_OUT_OF_MEMORY; goto Error; } - huffman_table = huffman_tables; for (i = 0; i < num_htree_groups_max; ++i) { // If the index "i" is unused in the Huffman image, just make sure the // coefficients are valid but do not store them. @@ -468,19 +472,20 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, int max_bits = 0; for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) { int alphabet_size = kAlphabetSize[j]; - htrees[j] = huffman_table; if (j == 0 && color_cache_bits > 0) { alphabet_size += (1 << color_cache_bits); } - size = ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_table); + size = + ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_tables); + htrees[j] = huffman_tables->curr_segment->curr_table; if (size == 0) { goto Error; } if (is_trivial_literal && kLiteralMap[j] == 1) { - is_trivial_literal = (huffman_table->bits == 0); + is_trivial_literal = (htrees[j]->bits == 0); } - total_size += huffman_table->bits; - huffman_table += size; + total_size += htrees[j]->bits; + huffman_tables->curr_segment->curr_table += size; if (j <= ALPHA) { int local_max_bits = code_lengths[0]; int k; @@ -515,14 +520,13 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, hdr->huffman_image_ = huffman_image; hdr->num_htree_groups_ = num_htree_groups; hdr->htree_groups_ = htree_groups; - hdr->huffman_tables_ = huffman_tables; Error: WebPSafeFree(code_lengths); WebPSafeFree(mapping); if (!ok) { WebPSafeFree(huffman_image); - WebPSafeFree(huffman_tables); + VP8LHuffmanTablesDeallocate(huffman_tables); VP8LHtreeGroupsFree(htree_groups); } return ok; @@ -1354,7 +1358,7 @@ static void ClearMetadata(VP8LMetadata* const hdr) { assert(hdr != NULL); WebPSafeFree(hdr->huffman_image_); - WebPSafeFree(hdr->huffman_tables_); + VP8LHuffmanTablesDeallocate(&hdr->huffman_tables_); VP8LHtreeGroupsFree(hdr->htree_groups_); VP8LColorCacheClear(&hdr->color_cache_); VP8LColorCacheClear(&hdr->saved_color_cache_); @@ -1670,7 +1674,7 @@ int VP8LDecodeImage(VP8LDecoder* const dec) { // Sanity checks. if (dec == NULL) return 0; - assert(dec->hdr_.huffman_tables_ != NULL); + assert(dec->hdr_.huffman_tables_.root.start != NULL); assert(dec->hdr_.htree_groups_ != NULL); assert(dec->hdr_.num_htree_groups_ > 0); diff --git a/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8li_dec.h b/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8li_dec.h index 72b2e86120..32540a4b88 100644 --- a/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8li_dec.h +++ b/src/3rdparty/chromium/third_party/libwebp/src/dec/vp8li_dec.h @@ -51,7 +51,7 @@ typedef struct { uint32_t* huffman_image_; int num_htree_groups_; HTreeGroup* htree_groups_; - HuffmanCode* huffman_tables_; + HuffmanTables huffman_tables_; } VP8LMetadata; typedef struct VP8LDecoder VP8LDecoder; diff --git a/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.c b/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.c index 0cba0fbb7d..9efd6283ac 100644 --- a/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.c +++ b/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.c @@ -177,21 +177,24 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, if (num_open < 0) { return 0; } - if (root_table == NULL) continue; for (; count[len] > 0; --count[len]) { HuffmanCode code; if ((key & mask) != low) { - table += table_size; + if (root_table != NULL) table += table_size; table_bits = NextTableBitSize(count, len, root_bits); table_size = 1 << table_bits; total_size += table_size; low = key & mask; - root_table[low].bits = (uint8_t)(table_bits + root_bits); - root_table[low].value = (uint16_t)((table - root_table) - low); + if (root_table != NULL) { + root_table[low].bits = (uint8_t)(table_bits + root_bits); + root_table[low].value = (uint16_t)((table - root_table) - low); + } + } + if (root_table != NULL) { + code.bits = (uint8_t)(len - root_bits); + code.value = (uint16_t)sorted[symbol++]; + ReplicateValue(&table[key >> root_bits], step, table_size, code); } - code.bits = (uint8_t)(len - root_bits); - code.value = (uint16_t)sorted[symbol++]; - ReplicateValue(&table[key >> root_bits], step, table_size, code); key = GetNextKey(key, len); } } @@ -211,25 +214,83 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, ((1 << MAX_CACHE_BITS) + NUM_LITERAL_CODES + NUM_LENGTH_CODES) // Cut-off value for switching between heap and stack allocation. #define SORTED_SIZE_CUTOFF 512 -int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits, +int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, const int code_lengths[], int code_lengths_size) { - int total_size; + const int total_size = + BuildHuffmanTable(NULL, root_bits, code_lengths, code_lengths_size, NULL); assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE); - if (root_table == NULL) { - total_size = BuildHuffmanTable(NULL, root_bits, - code_lengths, code_lengths_size, NULL); - } else if (code_lengths_size <= SORTED_SIZE_CUTOFF) { + if (total_size == 0 || root_table == NULL) return total_size; + + if (root_table->curr_segment->curr_table + total_size >= + root_table->curr_segment->start + root_table->curr_segment->size) { + // If 'root_table' does not have enough memory, allocate a new segment. + // The available part of root_table->curr_segment is left unused because we + // need a contiguous buffer. + const int segment_size = root_table->curr_segment->size; + struct HuffmanTablesSegment* next = + (HuffmanTablesSegment*)WebPSafeMalloc(1, sizeof(*next)); + if (next == NULL) return 0; + // Fill the new segment. + // We need at least 'total_size' but if that value is small, it is better to + // allocate a big chunk to prevent more allocations later. 'segment_size' is + // therefore chosen (any other arbitrary value could be chosen). + next->size = total_size > segment_size ? total_size : segment_size; + next->start = + (HuffmanCode*)WebPSafeMalloc(next->size, sizeof(*next->start)); + if (next->start == NULL) { + WebPSafeFree(next); + return 0; + } + next->curr_table = next->start; + next->next = NULL; + // Point to the new segment. + root_table->curr_segment->next = next; + root_table->curr_segment = next; + } + if (code_lengths_size <= SORTED_SIZE_CUTOFF) { // use local stack-allocated array. uint16_t sorted[SORTED_SIZE_CUTOFF]; - total_size = BuildHuffmanTable(root_table, root_bits, - code_lengths, code_lengths_size, sorted); - } else { // rare case. Use heap allocation. + BuildHuffmanTable(root_table->curr_segment->curr_table, root_bits, + code_lengths, code_lengths_size, sorted); + } else { // rare case. Use heap allocation. uint16_t* const sorted = (uint16_t*)WebPSafeMalloc(code_lengths_size, sizeof(*sorted)); if (sorted == NULL) return 0; - total_size = BuildHuffmanTable(root_table, root_bits, - code_lengths, code_lengths_size, sorted); + BuildHuffmanTable(root_table->curr_segment->curr_table, root_bits, + code_lengths, code_lengths_size, sorted); WebPSafeFree(sorted); } return total_size; } + +int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables) { + // Have 'segment' point to the first segment for now, 'root'. + HuffmanTablesSegment* const root = &huffman_tables->root; + huffman_tables->curr_segment = root; + // Allocate root. + root->start = (HuffmanCode*)WebPSafeMalloc(size, sizeof(*root->start)); + if (root->start == NULL) return 0; + root->curr_table = root->start; + root->next = NULL; + root->size = size; + return 1; +} + +void VP8LHuffmanTablesDeallocate(HuffmanTables* const huffman_tables) { + HuffmanTablesSegment *current, *next; + if (huffman_tables == NULL) return; + // Free the root node. + current = &huffman_tables->root; + next = current->next; + WebPSafeFree(current->start); + current->start = NULL; + current->next = NULL; + current = next; + // Free the following nodes. + while (current != NULL) { + next = current->next; + WebPSafeFree(current->start); + WebPSafeFree(current); + current = next; + } +} diff --git a/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.h b/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.h index 13b7ad1ac4..98415c5328 100644 --- a/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.h +++ b/src/3rdparty/chromium/third_party/libwebp/src/utils/huffman_utils.h @@ -43,6 +43,29 @@ typedef struct { // or non-literal symbol otherwise } HuffmanCode32; +// Contiguous memory segment of HuffmanCodes. +typedef struct HuffmanTablesSegment { + HuffmanCode* start; + // Pointer to where we are writing into the segment. Starts at 'start' and + // cannot go beyond 'start' + 'size'. + HuffmanCode* curr_table; + // Pointer to the next segment in the chain. + struct HuffmanTablesSegment* next; + int size; +} HuffmanTablesSegment; + +// Chained memory segments of HuffmanCodes. +typedef struct HuffmanTables { + HuffmanTablesSegment root; + // Currently processed segment. At first, this is 'root'. + HuffmanTablesSegment* curr_segment; +} HuffmanTables; + +// Allocates a HuffmanTables with 'size' contiguous HuffmanCodes. Returns 0 on +// memory allocation error, 1 otherwise. +int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables); +void VP8LHuffmanTablesDeallocate(HuffmanTables* const huffman_tables); + #define HUFFMAN_PACKED_BITS 6 #define HUFFMAN_PACKED_TABLE_SIZE (1u << HUFFMAN_PACKED_BITS) @@ -78,9 +101,7 @@ void VP8LHtreeGroupsFree(HTreeGroup* const htree_groups); // the huffman table. // Returns built table size or 0 in case of error (invalid tree or // memory error). -// If root_table is NULL, it returns 0 if a lookup cannot be built, something -// > 0 otherwise (but not the table size). -int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits, +int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, const int code_lengths[], int code_lengths_size); #ifdef __cplusplus diff --git a/src/3rdparty/chromium/third_party/pdfium/fpdfsdk/pwl/cpwl_combo_box.h b/src/3rdparty/chromium/third_party/pdfium/fpdfsdk/pwl/cpwl_combo_box.h index 67c49d2545..cf1a8750c1 100644 --- a/src/3rdparty/chromium/third_party/pdfium/fpdfsdk/pwl/cpwl_combo_box.h +++ b/src/3rdparty/chromium/third_party/pdfium/fpdfsdk/pwl/cpwl_combo_box.h @@ -95,7 +95,7 @@ class CPWL_ComboBox final : public CPWL_Wnd { void CreateListBox(const CreateParams& cp); // Returns |true| iff this instance is still allocated. - [[nodiscard]] bool SetPopup(bool bPopup); + bool SetPopup(bool bPopup); UnownedPtr m_pEdit; UnownedPtr m_pButton; diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h index 28c8271fd6..3957e0cdf7 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h @@ -120,6 +120,21 @@ AslrMask(uintptr_t bits) { return AslrAddress(0x20000000ULL); } + #elif defined(OS_LINUX) + + // Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on + // page size and number of levels of translation pages used. We use + // 39-bit as base as all setups should support this, lowered to 38-bit + // as ASLROffset() could cause a carry. + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t + ASLRMask() { + return AslrMask(38); + } + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t + ASLROffset() { + return AslrAddress(0x1000000000ULL); + } + #else // ARM64 on Linux has 39-bit user space. Use 38 bits since kASLROffset diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc index 91d00d2fbc..597d5f84cb 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc @@ -255,5 +255,13 @@ uint32_t GetAllocPageErrorCode() { return s_allocPageErrorCode; } +#if defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + +namespace internal { +PageCharacteristics page_characteristics; +} + +#endif // defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + } // namespace base } // namespace pdfium diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h index fdc65ac47b..6f2a38bbac 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h @@ -24,6 +24,31 @@ // elimination. #define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) +// This should work for all POSIX (if needed), but currently all other +// supported OS/architecture combinations use either hard-coded values +// (such as x86) or have means to determine these values without needing +// atomics (such as macOS on arm64). + +// Page allocator constants are run-time constant +#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) + +#include +#include + +namespace pdfium::base::internal { + +// Holds the current page size and shift, where size = 1 << shift +// Use PageAllocationGranularity(), PageAllocationGranularityShift() +// to initialize and retrieve these values safely. +struct PageCharacteristics { + std::atomic size; + std::atomic shift; +}; +extern PageCharacteristics page_characteristics; + +} // namespace base::internal + #else // When defined, page size constants are fixed at compile time. When not @@ -37,11 +62,13 @@ #endif namespace pdfium { -namespace { -#if !defined(OS_APPLE) +namespace base { +// Forward declaration, implementation below +PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t +PageAllocationGranularity(); -constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { +PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() { #if defined(OS_WIN) || defined(ARCH_CPU_PPC64) // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page // sizes. Since 64kB is the de facto standard on the platform and binaries @@ -50,21 +77,37 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { return 16; // 64kB #elif defined(_MIPS_ARCH_LOONGSON) return 14; // 16kB +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) + // page sizes. Retrieve from or initialize cache. + int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed); + if (UNLIKELY(shift == 0)) { + shift = __builtin_ctz((int)base::PageAllocationGranularity()); + base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed); + } + return shift; +#elif defined(OS_APPLE) + return vm_page_shift; #else return 12; // 4kB #endif } -#endif - -} // namespace - -namespace base { - PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t PageAllocationGranularity() { #if defined(OS_APPLE) + // This is literally equivalent to |1 << PageAllocationGranularityShift()| + // below, but was separated out for OS_APPLE to avoid << on a non-constexpr. return vm_page_size; +#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or + // initialize cache. + int size = internal::page_characteristics.size.load(std::memory_order_relaxed); + if (UNLIKELY(size == 0)) { + size = getpagesize(); + internal::page_characteristics.size.store(size, std::memory_order_relaxed); + } + return size; #else return 1ULL << PageAllocationGranularityShift(); #endif diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc index 2e5e87fa7e..89b9f6217a 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc @@ -486,7 +486,7 @@ static size_t PartitionPurgePage(internal::PartitionPage* page, bool discard) { #if defined(PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR) constexpr size_t kMaxSlotCount = (PartitionPageSize() * kMaxPartitionPagesPerSlotSpan) / SystemPageSize(); -#elif defined(OS_APPLE) +#elif defined(OS_APPLE) || (defined(OS_LINUX) && defined(ARCH_CPU_ARM64)) // It's better for slot_usage to be stack-allocated and fixed-size, which // demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is // always SystemPageSize() << 2, so regardless of what the run time page size diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h index 71d63ba414..a6d8362674 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h @@ -50,10 +50,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PartitionPageShift() { return 18; // 256 KiB } -#elif defined(OS_APPLE) +#elif defined(OS_APPLE) || \ + (defined(OS_LINUX) && defined(ARCH_CPU_ARM64)) PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PartitionPageShift() { - return vm_page_shift + 2; + return PageAllocationGranularityShift() + 2; } #else PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int diff --git a/src/3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/circular_queue.h b/src/3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/circular_queue.h index 18ca770261..ec46e69f81 100644 --- a/src/3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/circular_queue.h +++ b/src/3rdparty/chromium/third_party/perfetto/include/perfetto/ext/base/circular_queue.h @@ -67,19 +67,14 @@ class CircularQueue { ignore_result(generation); } - T* operator->() { + T* operator->() const { #if PERFETTO_DCHECK_IS_ON() PERFETTO_DCHECK(generation_ == queue_->generation()); #endif return queue_->Get(pos_); } - const T* operator->() const { - return const_cast::Iterator*>(this)->operator->(); - } - - T& operator*() { return *(operator->()); } - const T& operator*() const { return *(operator->()); } + T& operator*() const { return *(operator->()); } value_type& operator[](difference_type i) { return *(*this + i); } diff --git a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/metadata.h b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/metadata.h index 4796ae4edc..30e534b216 100644 --- a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/metadata.h +++ b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/metadata.h @@ -59,8 +59,10 @@ namespace metadata { F(kMulti, "multi") // clang-format +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) // Ignore GCC warning about a missing argument for a variadic macro parameter. #pragma GCC system_header +#endif #define PERFETTO_TP_META_TYPE_ENUM(varname, ...) varname enum class KeyType : size_t { diff --git a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/stats.h b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/stats.h index 7f14803244..30b56c6254 100644 --- a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/stats.h +++ b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/storage/stats.h @@ -189,7 +189,9 @@ enum Source { }; // Ignore GCC warning about a missing argument for a variadic macro parameter. +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) #pragma GCC system_header +#endif // Declares an enum of literals (one for each stat). The enum values of each // literal corresponds to the string index in the arrays below. diff --git a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/tables/macros_internal.h b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/tables/macros_internal.h index 875efd62e0..1ca5068cc3 100644 --- a/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/tables/macros_internal.h +++ b/src/3rdparty/chromium/third_party/perfetto/src/trace_processor/tables/macros_internal.h @@ -140,7 +140,9 @@ class MacroTable : public Table { } // namespace macros_internal // Ignore GCC warning about a missing argument for a variadic macro parameter. +#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC) #pragma GCC system_header +#endif // Basic helper macros. #define PERFETTO_TP_NOOP(...) diff --git a/src/3rdparty/chromium/third_party/skia/src/core/SkPath.cpp b/src/3rdparty/chromium/third_party/skia/src/core/SkPath.cpp index 00da5e02a5..11d2107de0 100644 --- a/src/3rdparty/chromium/third_party/skia/src/core/SkPath.cpp +++ b/src/3rdparty/chromium/third_party/skia/src/core/SkPath.cpp @@ -27,6 +27,7 @@ #include "src/pathops/SkPathOpsPoint.h" #include +#include #include struct SkPath_Storage_Equivalent { @@ -3345,40 +3346,50 @@ static PathInfo validate_verbs(const uint8_t vbs[], int verbCount) { bool needMove = true; bool invalid = false; - for (int i = 0; i < verbCount; ++i) { - switch ((SkPathVerb)vbs[i]) { - case SkPathVerb::kMove: - needMove = false; - info.points += 1; - break; - case SkPathVerb::kLine: - invalid |= needMove; - info.segmentMask |= kLine_SkPathSegmentMask; - info.points += 1; - break; - case SkPathVerb::kQuad: - invalid |= needMove; - info.segmentMask |= kQuad_SkPathSegmentMask; - info.points += 2; - break; - case SkPathVerb::kConic: - invalid |= needMove; - info.segmentMask |= kConic_SkPathSegmentMask; - info.points += 2; - info.weights += 1; - break; - case SkPathVerb::kCubic: - invalid |= needMove; - info.segmentMask |= kCubic_SkPathSegmentMask; - info.points += 3; - break; - case SkPathVerb::kClose: - invalid |= needMove; - needMove = true; - break; - default: - invalid = true; - break; + + if (verbCount >= (INT_MAX / 3)) { + // A path with an extremely high number of quad, conic or cubic verbs could cause + // `info.points` to overflow. To prevent against this, we reject extremely large paths. This + // check is conservative and assumes the worst case (in particular, it assumes that every + // verb consumes 3 points, which would only happen for a path composed entirely of cubics). + // This limits us to 700 million verbs, which is large enough for any reasonable use case. + invalid = true; + } else { + for (int i = 0; i < verbCount; ++i) { + switch ((SkPathVerb)vbs[i]) { + case SkPathVerb::kMove: + needMove = false; + info.points += 1; + break; + case SkPathVerb::kLine: + invalid |= needMove; + info.segmentMask |= kLine_SkPathSegmentMask; + info.points += 1; + break; + case SkPathVerb::kQuad: + invalid |= needMove; + info.segmentMask |= kQuad_SkPathSegmentMask; + info.points += 2; + break; + case SkPathVerb::kConic: + invalid |= needMove; + info.segmentMask |= kConic_SkPathSegmentMask; + info.points += 2; + info.weights += 1; + break; + case SkPathVerb::kCubic: + invalid |= needMove; + info.segmentMask |= kCubic_SkPathSegmentMask; + info.points += 3; + break; + case SkPathVerb::kClose: + invalid |= needMove; + needMove = true; + break; + default: + invalid = true; + break; + } } } info.valid = !invalid; diff --git a/src/3rdparty/chromium/third_party/skia/src/gpu/ops/GrDrawVerticesOp.cpp b/src/3rdparty/chromium/third_party/skia/src/gpu/ops/GrDrawVerticesOp.cpp index 0a80e67432..e50293b4df 100644 --- a/src/3rdparty/chromium/third_party/skia/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/3rdparty/chromium/third_party/skia/src/gpu/ops/GrDrawVerticesOp.cpp @@ -757,7 +757,11 @@ GrOp::CombineResult DrawVerticesOp::onCombineIfPossible(GrOp* t, GrRecordingCont return CombineResult::kCannotCombine; } - if (fVertexCount + that->fVertexCount > SkTo(UINT16_MAX)) { + if (fVertexCount > INT32_MAX - that->fVertexCount) { + return CombineResult::kCannotCombine; + } + + if (fVertexCount > SkTo(UINT16_MAX) - that->fVertexCount) { return CombineResult::kCannotCombine; } diff --git a/src/3rdparty/chromium/third_party/sqlite/src/amalgamation/sqlite3.c b/src/3rdparty/chromium/third_party/sqlite/src/amalgamation/sqlite3.c index d7766b7d7e..a0feb5d200 100644 --- a/src/3rdparty/chromium/third_party/sqlite/src/amalgamation/sqlite3.c +++ b/src/3rdparty/chromium/third_party/sqlite/src/amalgamation/sqlite3.c @@ -18804,6 +18804,7 @@ struct NameContext { int nRef; /* Number of names resolved by this context */ int nNcErr; /* Number of errors encountered while resolving names */ int ncFlags; /* Zero or more NC_* flags defined below */ + int nNestedSelect; /* Number of nested selects using this NC */ Select *pWinSelect; /* SELECT statement for any window functions */ }; @@ -104749,11 +104750,12 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ while( pNC2 && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 ){ - pExpr->op2++; + pExpr->op2 += (1 + pNC2->nNestedSelect); pNC2 = pNC2->pNext; } assert( pDef!=0 || IN_RENAME_OBJECT ); if( pNC2 && pDef ){ + pExpr->op2 += pNC2->nNestedSelect; assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg ); testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); @@ -105314,6 +105316,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ /* Recursively resolve names in all subqueries in the FROM clause */ + if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ @@ -105338,6 +105341,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ } } } + if( pOuterNC ) pOuterNC->nNestedSelect--; /* Set up the local name-context to pass to sqlite3ResolveExprNames() to ** resolve the result-set expression list. @@ -218678,15 +218682,19 @@ static int sessionReadRecord( } } if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ - sqlite3_int64 v = sessionGetI64(aVal); - if( eType==SQLITE_INTEGER ){ - sqlite3VdbeMemSetInt64(apOut[i], v); + if( (pIn->nData-pIn->iNext)<8 ){ + rc = SQLITE_CORRUPT_BKPT; }else{ - double d; - memcpy(&d, &v, 8); - sqlite3VdbeMemSetDouble(apOut[i], d); + sqlite3_int64 v = sessionGetI64(aVal); + if( eType==SQLITE_INTEGER ){ + sqlite3VdbeMemSetInt64(apOut[i], v); + }else{ + double d; + memcpy(&d, &v, 8); + sqlite3VdbeMemSetDouble(apOut[i], d); + } + pIn->iNext += 8; } - pIn->iNext += 8; } } } diff --git a/src/3rdparty/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c b/src/3rdparty/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c index 0819ea6a61..5c72a44dd6 100644 --- a/src/3rdparty/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c +++ b/src/3rdparty/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c @@ -18817,6 +18817,7 @@ struct NameContext { int nRef; /* Number of names resolved by this context */ int nNcErr; /* Number of errors encountered while resolving names */ int ncFlags; /* Zero or more NC_* flags defined below */ + int nNestedSelect; /* Number of nested selects using this NC */ Select *pWinSelect; /* SELECT statement for any window functions */ }; @@ -104762,11 +104763,12 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ while( pNC2 && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 ){ - pExpr->op2++; + pExpr->op2 += (1 + pNC2->nNestedSelect); pNC2 = pNC2->pNext; } assert( pDef!=0 || IN_RENAME_OBJECT ); if( pNC2 && pDef ){ + pExpr->op2 += pNC2->nNestedSelect; assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg ); testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); @@ -105327,6 +105329,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ /* Recursively resolve names in all subqueries in the FROM clause */ + if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ @@ -105351,6 +105354,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ } } } + if( pOuterNC ) pOuterNC->nNestedSelect--; /* Set up the local name-context to pass to sqlite3ResolveExprNames() to ** resolve the result-set expression list. diff --git a/src/3rdparty/chromium/third_party/sqlite/src/src/resolve.c b/src/3rdparty/chromium/third_party/sqlite/src/src/resolve.c index 4b36ecca34..c5228a7f09 100644 --- a/src/3rdparty/chromium/third_party/sqlite/src/src/resolve.c +++ b/src/3rdparty/chromium/third_party/sqlite/src/src/resolve.c @@ -1211,11 +1211,12 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ while( pNC2 && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 ){ - pExpr->op2++; + pExpr->op2 += (1 + pNC2->nNestedSelect); pNC2 = pNC2->pNext; } assert( pDef!=0 || IN_RENAME_OBJECT ); if( pNC2 && pDef ){ + pExpr->op2 += pNC2->nNestedSelect; assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg ); testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); @@ -1776,6 +1777,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ /* Recursively resolve names in all subqueries in the FROM clause */ + if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ @@ -1800,7 +1802,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ } } } - + if( pOuterNC ) pOuterNC->nNestedSelect--; + /* Set up the local name-context to pass to sqlite3ResolveExprNames() to ** resolve the result-set expression list. */ diff --git a/src/3rdparty/chromium/third_party/sqlite/src/src/sqliteInt.h b/src/3rdparty/chromium/third_party/sqlite/src/src/sqliteInt.h index 2614f4be45..07bc4def10 100644 --- a/src/3rdparty/chromium/third_party/sqlite/src/src/sqliteInt.h +++ b/src/3rdparty/chromium/third_party/sqlite/src/src/sqliteInt.h @@ -3321,6 +3321,7 @@ struct NameContext { int nRef; /* Number of names resolved by this context */ int nNcErr; /* Number of errors encountered while resolving names */ int ncFlags; /* Zero or more NC_* flags defined below */ + int nNestedSelect; /* Number of nested selects using this NC */ Select *pWinSelect; /* SELECT statement for any window functions */ }; diff --git a/src/3rdparty/chromium/third_party/webrtc/modules/pacing/packet_router.cc b/src/3rdparty/chromium/third_party/webrtc/modules/pacing/packet_router.cc index 5317f510c9..f70fe988a5 100644 --- a/src/3rdparty/chromium/third_party/webrtc/modules/pacing/packet_router.cc +++ b/src/3rdparty/chromium/third_party/webrtc/modules/pacing/packet_router.cc @@ -91,7 +91,10 @@ void PacketRouter::AddSendRtpModuleToMap(RtpRtcpInterface* rtp_module, void PacketRouter::RemoveSendRtpModuleFromMap(uint32_t ssrc) { auto kv = send_modules_map_.find(ssrc); - RTC_DCHECK(kv != send_modules_map_.end()); + if (kv == send_modules_map_.end()) { + RTC_LOG(LS_ERROR) << "No send module found for ssrc " << ssrc; + return; + } send_modules_list_.remove(kv->second); send_modules_map_.erase(kv); } diff --git a/src/3rdparty/chromium/third_party/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc b/src/3rdparty/chromium/third_party/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc index 15e059e85c..9ad4aa97c3 100644 --- a/src/3rdparty/chromium/third_party/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc +++ b/src/3rdparty/chromium/third_party/webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc @@ -94,8 +94,8 @@ size_t RefIndicesLength(const RTPVideoHeaderVP9& hdr) { if (!hdr.inter_pic_predicted || !hdr.flexible_mode) return 0; - RTC_DCHECK_GT(hdr.num_ref_pics, 0U); - RTC_DCHECK_LE(hdr.num_ref_pics, kMaxVp9RefPics); + RTC_CHECK_GT(hdr.num_ref_pics, 0U); + RTC_CHECK_LE(hdr.num_ref_pics, kMaxVp9RefPics); return hdr.num_ref_pics; } @@ -123,9 +123,9 @@ size_t SsDataLength(const RTPVideoHeaderVP9& hdr) { if (!hdr.ss_data_available) return 0; - RTC_DCHECK_GT(hdr.num_spatial_layers, 0U); - RTC_DCHECK_LE(hdr.num_spatial_layers, kMaxVp9NumberOfSpatialLayers); - RTC_DCHECK_LE(hdr.gof.num_frames_in_gof, kMaxVp9FramesInGof); + RTC_CHECK_GT(hdr.num_spatial_layers, 0U); + RTC_CHECK_LE(hdr.num_spatial_layers, kMaxVp9NumberOfSpatialLayers); + RTC_CHECK_LE(hdr.gof.num_frames_in_gof, kMaxVp9FramesInGof); size_t length = 1; // V if (hdr.spatial_layer_resolution_present) { length += 4 * hdr.num_spatial_layers; // Y @@ -136,7 +136,7 @@ size_t SsDataLength(const RTPVideoHeaderVP9& hdr) { // N_G length += hdr.gof.num_frames_in_gof; // T, U, R for (size_t i = 0; i < hdr.gof.num_frames_in_gof; ++i) { - RTC_DCHECK_LE(hdr.gof.num_ref_pics[i], kMaxVp9RefPics); + RTC_CHECK_LE(hdr.gof.num_ref_pics[i], kMaxVp9RefPics); length += hdr.gof.num_ref_pics[i]; // R times } return length; @@ -248,9 +248,9 @@ bool WriteRefIndices(const RTPVideoHeaderVP9& vp9, // +-+-+-+-+-+-+-+-+ -| -| // bool WriteSsData(const RTPVideoHeaderVP9& vp9, rtc::BitBufferWriter* writer) { - RTC_DCHECK_GT(vp9.num_spatial_layers, 0U); - RTC_DCHECK_LE(vp9.num_spatial_layers, kMaxVp9NumberOfSpatialLayers); - RTC_DCHECK_LE(vp9.gof.num_frames_in_gof, kMaxVp9FramesInGof); + RTC_CHECK_GT(vp9.num_spatial_layers, 0U); + RTC_CHECK_LE(vp9.num_spatial_layers, kMaxVp9NumberOfSpatialLayers); + RTC_CHECK_LE(vp9.gof.num_frames_in_gof, kMaxVp9FramesInGof); bool g_bit = vp9.gof.num_frames_in_gof > 0; RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.num_spatial_layers - 1, 3)); @@ -288,6 +288,8 @@ bool WriteSsData(const RTPVideoHeaderVP9& vp9, rtc::BitBufferWriter* writer) { // current API to invoke SVC is not flexible enough. RTPVideoHeaderVP9 RemoveInactiveSpatialLayers( const RTPVideoHeaderVP9& original_header) { + RTC_CHECK_LE(original_header.num_spatial_layers, + kMaxVp9NumberOfSpatialLayers); RTPVideoHeaderVP9 hdr(original_header); if (original_header.first_active_layer == 0) return hdr; @@ -314,7 +316,7 @@ RtpPacketizerVp9::RtpPacketizerVp9(rtc::ArrayView payload, header_size_(PayloadDescriptorLengthMinusSsData(hdr_)), first_packet_extra_header_size_(SsDataLength(hdr_)), remaining_payload_(payload) { - RTC_DCHECK_EQ(hdr_.first_active_layer, 0); + RTC_CHECK_EQ(hdr_.first_active_layer, 0); limits.max_payload_len -= header_size_; limits.first_packet_reduction_len += first_packet_extra_header_size_; @@ -357,8 +359,8 @@ bool RtpPacketizerVp9::NextPacket(RtpPacketToSend* packet) { // Ensure end_of_picture is always set on top spatial layer when it is not // dropped. - RTC_DCHECK(hdr_.spatial_idx < hdr_.num_spatial_layers - 1 || - hdr_.end_of_picture); + RTC_CHECK(hdr_.spatial_idx < hdr_.num_spatial_layers - 1 || + hdr_.end_of_picture); packet->SetMarker(layer_end && hdr_.end_of_picture); return true; diff --git a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/file_wrapper.h b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/file_wrapper.h index 42c463cb15..7c2532c6f4 100644 --- a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/file_wrapper.h +++ b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/file_wrapper.h @@ -11,6 +11,7 @@ #ifndef RTC_BASE_SYSTEM_FILE_WRAPPER_H_ #define RTC_BASE_SYSTEM_FILE_WRAPPER_H_ +#include #include #include diff --git a/src/3rdparty/chromium/third_party/zlib/contrib/minizip/README.chromium b/src/3rdparty/chromium/third_party/zlib/contrib/minizip/README.chromium index 1ad489a678..23d5428fb9 100644 --- a/src/3rdparty/chromium/third_party/zlib/contrib/minizip/README.chromium +++ b/src/3rdparty/chromium/third_party/zlib/contrib/minizip/README.chromium @@ -13,3 +13,6 @@ Local Modifications: - Add parsing of the 'Info-ZIP Unicode Path Extra Field' as described in https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT section 4.6.9. (see crrev.com/1002476) + +- Check for overly long filename, comment, or extra field in + zipOpenNewFileInZip4_64 (crbug.com/1470539). diff --git a/src/3rdparty/chromium/third_party/zlib/contrib/minizip/zip.c b/src/3rdparty/chromium/third_party/zlib/contrib/minizip/zip.c index 65c0c72518..cccdc65396 100644 --- a/src/3rdparty/chromium/third_party/zlib/contrib/minizip/zip.c +++ b/src/3rdparty/chromium/third_party/zlib/contrib/minizip/zip.c @@ -1083,6 +1083,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, return ZIP_PARAMERROR; #endif + // The filename and comment length must fit in 16 bits. + if ((filename!=NULL) && (strlen(filename)>0xffff)) + return ZIP_PARAMERROR; + if ((comment!=NULL) && (strlen(comment)>0xffff)) + return ZIP_PARAMERROR; + // The extra field length must fit in 16 bits. If the member also requires + // a Zip64 extra block, that will also need to fit within that 16-bit + // length, but that will be checked for later. + if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) + return ZIP_PARAMERROR; + zi = (zip64_internal*)file; if (zi->in_opened_file_inzip == 1) diff --git a/src/3rdparty/chromium/tools/generate_stubs/generate_stubs.py b/src/3rdparty/chromium/tools/generate_stubs/generate_stubs.py index ed3b89c290..0e2e72e0be 100755 --- a/src/3rdparty/chromium/tools/generate_stubs/generate_stubs.py +++ b/src/3rdparty/chromium/tools/generate_stubs/generate_stubs.py @@ -68,12 +68,12 @@ def __str__(self): # From that, all preceding characters are considered the return value. # Trailing characters should have a substring matching the form (.*). That # is considered the arguments. -SIGNATURE_REGEX = re.compile('(?P.+?)' - '(?P[_a-zA-Z][_a-zA-Z0-9]+)\s*' - '\((?P.*?)\)') +SIGNATURE_REGEX = re.compile(r'(?P.+?)' + r'(?P[_a-zA-Z][_a-zA-Z0-9]+)\s*' + r'\((?P.*?)\)') # Used for generating C++ identifiers. -INVALID_C_IDENT_CHARS = re.compile('[^_a-zA-Z0-9]') +INVALID_C_IDENT_CHARS = re.compile(r'[^_a-zA-Z0-9]') # Constants defining the supported file types options. FILE_TYPE_WIN_X86 = 'windows_lib' @@ -662,7 +662,7 @@ def StubFunction(cls, signature): return_prefix = 'return ' # Generate the argument list. - arguments = [re.split('[\*& ]', arg)[-1].strip() for arg in + arguments = [re.split(r'[\*& ]', arg)[-1].strip() for arg in signature['params']] # Remove square brackets from arrays, otherwise we will end with a # compilation failure. diff --git a/src/3rdparty/chromium/tools/grit/grit/util.py b/src/3rdparty/chromium/tools/grit/grit/util.py index 528d766ad6..6e8cdb0ebf 100644 --- a/src/3rdparty/chromium/tools/grit/grit/util.py +++ b/src/3rdparty/chromium/tools/grit/grit/util.py @@ -211,7 +211,7 @@ def ReadFile(filename, encoding): mode = 'rb' encoding = None else: - mode = 'rU' + mode = 'r' with io.open(abs(filename), mode, encoding=encoding) as f: return f.read() diff --git a/src/3rdparty/chromium/tools/metrics/histograms/enums.xml b/src/3rdparty/chromium/tools/metrics/histograms/enums.xml index df6704bbed..eb13c15eec 100644 --- a/src/3rdparty/chromium/tools/metrics/histograms/enums.xml +++ b/src/3rdparty/chromium/tools/metrics/histograms/enums.xml @@ -38011,6 +38011,10 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> + + + + diff --git a/src/3rdparty/chromium/tools/metrics/structured/model.py b/src/3rdparty/chromium/tools/metrics/structured/model.py index 2d90bf20c6..befea2eda7 100644 --- a/src/3rdparty/chromium/tools/metrics/structured/model.py +++ b/src/3rdparty/chromium/tools/metrics/structured/model.py @@ -26,7 +26,7 @@ 'metric', attributes=[ ('name', unicode, r'^[A-Za-z0-9_.]+$'), - ('kind', unicode, r'^(?i)(|hashed-string|int)$'), + ('kind', unicode, r'(?i)^(|hashed-string|int)$'), ], alphabetization=[ (_OBSOLETE_TYPE.tag, lambda _: 1), diff --git a/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py b/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py index f9f61d90a5..44e46fae8c 100755 --- a/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py +++ b/src/3rdparty/chromium/tools/metrics/ukm/gen_builders.py @@ -48,9 +48,10 @@ def ReadFilteredData(path): data = ukm_model.UKM_XML_TYPE.Parse(ukm_file.read()) event_tag = ukm_model._EVENT_TYPE.tag metric_tag = ukm_model._METRIC_TYPE.tag - data[event_tag] = filter(ukm_model.IsNotObsolete, data[event_tag]) + data[event_tag] = list(filter(ukm_model.IsNotObsolete, data[event_tag])) for event in data[event_tag]: - event[metric_tag] = filter(ukm_model.IsNotObsolete, event[metric_tag]) + event[metric_tag] = list( + filter(ukm_model.IsNotObsolete, event[metric_tag])) return data diff --git a/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py b/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py index ec24dd5736..57decab3cc 100644 --- a/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py +++ b/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py @@ -42,7 +42,7 @@ _STATISTICS_TYPE = models.ObjectNodeType( 'statistics', attributes=[ - ('export', str, r'^(?i)(|true|false)$'), + ('export', str, r'(?i)^(|true|false)$'), ], children=[ models.ChildType(_QUANTILES_TYPE.tag, _QUANTILES_TYPE, multiple=False), @@ -94,7 +94,7 @@ 'event', attributes=[ ('name', str, r'^[A-Za-z0-9.]+$'), - ('singular', str, r'^(?i)(|true|false)$'), + ('singular', str, r'(?i)^(|true|false)$'), ], alphabetization=[ (_OBSOLETE_TYPE.tag, _KEEP_ORDER), diff --git a/src/3rdparty/chromium/ui/base/resource/data_pack.cc b/src/3rdparty/chromium/ui/base/resource/data_pack.cc index 09513e6aed..4e522c9ad7 100644 --- a/src/3rdparty/chromium/ui/base/resource/data_pack.cc +++ b/src/3rdparty/chromium/ui/base/resource/data_pack.cc @@ -400,7 +400,16 @@ bool DataPack::LoadImpl(std::unique_ptr data_source) { } } - // 3) Verify the aliases are within the appropriate bounds. + // 3) Verify the entries are ordered correctly. + for (size_t i = 0; i < resource_count_; ++i) { + if (resource_table_[i].file_offset > resource_table_[i + 1].file_offset) { + LOG(ERROR) << "Data pack file corruption: " + << "Entry #" << i + 1 << " before Entry #" << i << "."; + return false; + } + } + + // 4) Verify the aliases are within the appropriate bounds. for (size_t i = 0; i < alias_count_; ++i) { if (alias_table_[i].entry_index >= resource_count_) { LOG(ERROR) << "Data pack file corruption: " @@ -461,6 +470,14 @@ bool DataPack::GetStringPiece(uint16_t resource_id, << "file modified?"; return false; } + if (target->file_offset > next_entry->file_offset) { + size_t entry_index = target - resource_table_; + size_t next_index = next_entry - resource_table_; + LOG(ERROR) << "Entry #" << next_index << " in data pack is before Entry #" + << entry_index << ". This should have been caught when loading. " + << "Was the file modified?"; + return false; + } MaybePrintResourceId(resource_id); size_t length = next_entry->file_offset - target->file_offset; diff --git a/src/3rdparty/chromium/ui/base/resource/data_pack_literal.cc b/src/3rdparty/chromium/ui/base/resource/data_pack_literal.cc index f6669ed824..70e225b6e8 100644 --- a/src/3rdparty/chromium/ui/base/resource/data_pack_literal.cc +++ b/src/3rdparty/chromium/ui/base/resource/data_pack_literal.cc @@ -91,6 +91,18 @@ const char kSampleCorruptPakContents[] = { const size_t kSampleCorruptPakSize = sizeof(kSampleCorruptPakContents); +const uint8_t kSampleMisorderedPakContents[] = { + 0x05, 0x00, 0x00, 0x00, // version + 0x01, 0x00, 0x00, 0x00, // encoding + padding + 0x02, 0x00, 0x00, 0x00, // num_resources, num_aliases + 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, // index entry 6 (wrong order) + 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, // index entry 4 + 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, // extra entry for the size of last + 't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '4', + 't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'i', 'd', ' ', '6'}; + +const size_t kSampleMisorderedPakSize = sizeof(kSampleMisorderedPakContents); + const char kSamplePakContents2x[] = { 0x04, 0x00, 0x00, 0x00, // header(version 0x01, 0x00, 0x00, 0x00, // no. entries diff --git a/src/3rdparty/chromium/ui/base/resource/data_pack_literal.h b/src/3rdparty/chromium/ui/base/resource/data_pack_literal.h index 83a8dc04c1..a7fcf2bf85 100644 --- a/src/3rdparty/chromium/ui/base/resource/data_pack_literal.h +++ b/src/3rdparty/chromium/ui/base/resource/data_pack_literal.h @@ -19,6 +19,8 @@ extern const char kEmptyPakContents[]; extern const size_t kEmptyPakSize; extern const char kSampleCorruptPakContents[]; extern const size_t kSampleCorruptPakSize; +extern const uint8_t kSampleMisorderedPakContents[]; +extern const size_t kSampleMisorderedPakSize; } // namespace ui diff --git a/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py b/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py index 8d800636c9..04fa18e93d 100755 --- a/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py +++ b/src/3rdparty/chromium/ui/ozone/generate_constructor_list.py @@ -45,12 +45,15 @@ } // namespace ui """ +try: + from StringIO import StringIO # for Python 2 +except ImportError: + from io import StringIO # for Python 3 import optparse import os import collections import re import sys -import string def GetTypedefName(typename): @@ -68,7 +71,7 @@ def GetConstructorName(typename, platform): This is just "Create" + typename + platform. """ - return 'Create' + typename + string.capitalize(platform) + return 'Create' + typename + platform.capitalize() def GenerateConstructorList(out, namespace, export, typenames, platforms, @@ -163,12 +166,14 @@ def main(argv): sys.exit(1) # Write to standard output or file specified by --output_cc. - out_cc = sys.stdout + out_cc = getattr(sys.stdout, 'buffer', sys.stdout) if options.output_cc: out_cc = open(options.output_cc, 'wb') - GenerateConstructorList(out_cc, options.namespace, options.export, + out_cc_str = StringIO() + GenerateConstructorList(out_cc_str, options.namespace, options.export, typenames, platforms, includes, usings) + out_cc.write(out_cc_str.getvalue().encode('utf-8')) if options.output_cc: out_cc.close() diff --git a/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py b/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py index d47c398259..2702b68b9b 100755 --- a/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py +++ b/src/3rdparty/chromium/ui/ozone/generate_ozone_platform_list.py @@ -49,12 +49,15 @@ """ +try: + from StringIO import StringIO # for Python 2 +except ImportError: + from io import StringIO # for Python 3 import optparse import os import collections import re import sys -import string def GetConstantName(name): @@ -63,7 +66,7 @@ def GetConstantName(name): We just capitalize the platform name and prepend "CreateOzonePlatform". """ - return 'kPlatform' + string.capitalize(name) + return 'kPlatform' + name.capitalize() def GeneratePlatformListText(out, platforms): @@ -149,9 +152,9 @@ def main(argv): platforms.insert(0, options.default) # Write to standard output or file specified by --output_{cc,h}. - out_cc = sys.stdout - out_h = sys.stdout - out_txt = sys.stdout + out_cc = getattr(sys.stdout, 'buffer', sys.stdout) + out_h = getattr(sys.stdout, 'buffer', sys.stdout) + out_txt = getattr(sys.stdout, 'buffer', sys.stdout) if options.output_cc: out_cc = open(options.output_cc, 'wb') if options.output_h: @@ -159,9 +162,16 @@ def main(argv): if options.output_txt: out_txt = open(options.output_txt, 'wb') - GeneratePlatformListText(out_txt, platforms) - GeneratePlatformListHeader(out_h, platforms) - GeneratePlatformListSource(out_cc, platforms) + out_txt_str = StringIO() + out_h_str = StringIO() + out_cc_str = StringIO() + + GeneratePlatformListText(out_txt_str, platforms) + out_txt.write(out_txt_str.getvalue().encode('utf-8')) + GeneratePlatformListHeader(out_h_str, platforms) + out_h.write(out_h_str.getvalue().encode('utf-8')) + GeneratePlatformListSource(out_cc_str, platforms) + out_cc.write(out_cc_str.getvalue().encode('utf-8')) if options.output_cc: out_cc.close() diff --git a/src/3rdparty/chromium/v8/include/v8-version.h b/src/3rdparty/chromium/v8/include/v8-version.h index f2a24d6b25..40d548592f 100644 --- a/src/3rdparty/chromium/v8/include/v8-version.h +++ b/src/3rdparty/chromium/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 8 #define V8_MINOR_VERSION 7 #define V8_BUILD_NUMBER 220 -#define V8_PATCH_LEVEL 39 +#define V8_PATCH_LEVEL 41 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/src/3rdparty/chromium/v8/src/builtins/promise-any.tq b/src/3rdparty/chromium/v8/src/builtins/promise-any.tq index 561ed622ae..360d7642b7 100644 --- a/src/3rdparty/chromium/v8/src/builtins/promise-any.tq +++ b/src/3rdparty/chromium/v8/src/builtins/promise-any.tq @@ -106,9 +106,10 @@ PromiseAnyRejectElementClosure( const index = identityHash - 1; // 6. Let errors be F.[[Errors]]. - let errors = *ContextSlot( + let errorsRef:&FixedArray = ContextSlot( context, PromiseAnyRejectElementContextSlots::kPromiseAnyRejectElementErrorsSlot); + let errors = *errorsRef; // 7. Let promiseCapability be F.[[Capability]]. @@ -134,10 +135,7 @@ PromiseAnyRejectElementClosure( IntPtrMax(SmiUntag(remainingElementsCount) - 1, index + 1); if (newCapacity > errors.length_intptr) deferred { errors = ExtractFixedArray(errors, 0, errors.length_intptr, newCapacity); - *ContextSlot( - context, - PromiseAnyRejectElementContextSlots:: - kPromiseAnyRejectElementErrorsSlot) = errors; + *errorsRef = errors; } errors.objects[index] = value; @@ -155,6 +153,10 @@ PromiseAnyRejectElementClosure( // b. Set error.[[AggregateErrors]] to errors. const error = ConstructAggregateError(errors); + + // After this point, errors escapes to user code. Clear the slot. + *errorsRef = kEmptyFixedArray; + // c. Return ? Call(promiseCapability.[[Reject]], undefined, « error »). const capability = *ContextSlot( context, diff --git a/src/3rdparty/chromium/v8/src/codegen/arm/register-arm.h b/src/3rdparty/chromium/v8/src/codegen/arm/register-arm.h index 6cb6c602c2..8deddc5804 100644 --- a/src/3rdparty/chromium/v8/src/codegen/arm/register-arm.h +++ b/src/3rdparty/chromium/v8/src/codegen/arm/register-arm.h @@ -119,6 +119,12 @@ GENERAL_REGISTERS(DECLARE_REGISTER) #undef DECLARE_REGISTER constexpr Register no_reg = Register::no_reg(); +// ARM calling convention +constexpr Register arg_reg_1 = r0; +constexpr Register arg_reg_2 = r1; +constexpr Register arg_reg_3 = r2; +constexpr Register arg_reg_4 = r3; + constexpr bool kPadArguments = false; constexpr bool kSimpleFPAliasing = false; constexpr bool kSimdMaskRegisters = false; diff --git a/src/3rdparty/chromium/v8/src/codegen/arm64/register-arm64.h b/src/3rdparty/chromium/v8/src/codegen/arm64/register-arm64.h index fbbb0a18da..06026a065b 100644 --- a/src/3rdparty/chromium/v8/src/codegen/arm64/register-arm64.h +++ b/src/3rdparty/chromium/v8/src/codegen/arm64/register-arm64.h @@ -482,6 +482,12 @@ ALIAS_REGISTER(VRegister, fp_scratch2, d31); #undef ALIAS_REGISTER +// Arm64 calling convention +constexpr Register arg_reg_1 = x0; +constexpr Register arg_reg_2 = x1; +constexpr Register arg_reg_3 = x2; +constexpr Register arg_reg_4 = x3; + // AreAliased returns true if any of the named registers overlap. Arguments set // to NoReg are ignored. The system stack pointer may be specified. V8_EXPORT_PRIVATE bool AreAliased( diff --git a/src/3rdparty/chromium/v8/src/codegen/compiler.cc b/src/3rdparty/chromium/v8/src/codegen/compiler.cc index f09658ebdf..f963b0d926 100644 --- a/src/3rdparty/chromium/v8/src/codegen/compiler.cc +++ b/src/3rdparty/chromium/v8/src/codegen/compiler.cc @@ -543,11 +543,11 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info, shared_info->set_is_asm_wasm_broken(true); } - shared_info->set_bytecode_array(*compilation_info->bytecode_array()); - Handle feedback_metadata = FeedbackMetadata::New( isolate, compilation_info->feedback_vector_spec()); shared_info->set_feedback_metadata(*feedback_metadata); + + shared_info->set_bytecode_array(*compilation_info->bytecode_array()); } else { DCHECK(compilation_info->has_asm_wasm_data()); // We should only have asm/wasm data when finalizing on the main thread. diff --git a/src/3rdparty/chromium/v8/src/codegen/mips64/register-mips64.h b/src/3rdparty/chromium/v8/src/codegen/mips64/register-mips64.h index d7b45eda38..05aba9fcbd 100644 --- a/src/3rdparty/chromium/v8/src/codegen/mips64/register-mips64.h +++ b/src/3rdparty/chromium/v8/src/codegen/mips64/register-mips64.h @@ -362,6 +362,12 @@ DEFINE_REGISTER_NAMES(FPURegister, DOUBLE_REGISTERS) DEFINE_REGISTER_NAMES(MSARegister, SIMD128_REGISTERS) // Give alias names to registers for calling conventions. + +constexpr Register arg_reg_1 = a0; +constexpr Register arg_reg_2 = a1; +constexpr Register arg_reg_3 = a2; +constexpr Register arg_reg_4 = a3; + constexpr Register kReturnRegister0 = v0; constexpr Register kReturnRegister1 = v1; constexpr Register kReturnRegister2 = a0; diff --git a/src/3rdparty/chromium/v8/src/codegen/ppc/register-ppc.h b/src/3rdparty/chromium/v8/src/codegen/ppc/register-ppc.h index eded9622c4..352b951920 100644 --- a/src/3rdparty/chromium/v8/src/codegen/ppc/register-ppc.h +++ b/src/3rdparty/chromium/v8/src/codegen/ppc/register-ppc.h @@ -209,6 +209,12 @@ constexpr Register kConstantPoolRegister = r28; // Constant pool. constexpr Register kRootRegister = r29; // Roots array pointer. constexpr Register cp = r30; // JavaScript context pointer. +// PPC64 calling convention +constexpr Register arg_reg_1 = r3; +constexpr Register arg_reg_2 = r4; +constexpr Register arg_reg_3 = r5; +constexpr Register arg_reg_4 = r6; + constexpr bool kPadArguments = false; constexpr bool kSimpleFPAliasing = true; constexpr bool kSimdMaskRegisters = false; diff --git a/src/3rdparty/chromium/v8/src/codegen/s390/register-s390.h b/src/3rdparty/chromium/v8/src/codegen/s390/register-s390.h index 009248a65c..6904802d01 100644 --- a/src/3rdparty/chromium/v8/src/codegen/s390/register-s390.h +++ b/src/3rdparty/chromium/v8/src/codegen/s390/register-s390.h @@ -167,6 +167,12 @@ constexpr Register no_reg = Register::no_reg(); constexpr Register kRootRegister = r10; // Roots array pointer. constexpr Register cp = r13; // JavaScript context pointer. +// s390x calling convention +constexpr Register arg_reg_1 = r2; +constexpr Register arg_reg_2 = r3; +constexpr Register arg_reg_3 = r4; +constexpr Register arg_reg_4 = r5; + constexpr bool kPadArguments = false; constexpr bool kSimpleFPAliasing = true; constexpr bool kSimdMaskRegisters = false; diff --git a/src/3rdparty/chromium/v8/src/compiler/js-native-context-specialization.cc b/src/3rdparty/chromium/v8/src/compiler/js-native-context-specialization.cc index 2a4524f386..01e3a404cb 100644 --- a/src/3rdparty/chromium/v8/src/compiler/js-native-context-specialization.cc +++ b/src/3rdparty/chromium/v8/src/compiler/js-native-context-specialization.cc @@ -3102,15 +3102,21 @@ JSNativeContextSpecialization::BuildElementAccess( // the (potential) backing store growth would normalize and thus // the elements kind of the {receiver} would change to slow mode. // - // For PACKED_*_ELEMENTS the {index} must be within the range + // For JSArray PACKED_*_ELEMENTS the {index} must be within the range // [0,length+1[ to be valid. In case {index} equals {length}, // the {receiver} will be extended, but kept packed. + // + // Non-JSArray PACKED_*_ELEMENTS always grow by adding holes because they + // lack the magical length property, which requires a map transition. + // So we can assume that this did not happen if we did not see this map. Node* limit = IsHoleyElementsKind(elements_kind) ? graph()->NewNode(simplified()->NumberAdd(), elements_length, jsgraph()->Constant(JSObject::kMaxGap)) - : graph()->NewNode(simplified()->NumberAdd(), length, - jsgraph()->OneConstant()); + : receiver_is_jsarray + ? graph()->NewNode(simplified()->NumberAdd(), length, + jsgraph()->OneConstant()) + : elements_length; index = effect = graph()->NewNode( simplified()->CheckBounds( FeedbackSource(), CheckBoundsFlag::kConvertStringAndMinusZero), diff --git a/src/3rdparty/chromium/v8/src/execution/isolate.cc b/src/3rdparty/chromium/v8/src/execution/isolate.cc index c1c3bd1b24..99b851ef96 100644 --- a/src/3rdparty/chromium/v8/src/execution/isolate.cc +++ b/src/3rdparty/chromium/v8/src/execution/isolate.cc @@ -944,7 +944,13 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle promise, builder->AppendPromiseCombinatorFrame(function, combinator, FrameArray::kIsPromiseAll, context); - // Now peak into the Promise.all() resolve element context to + if (context->IsNativeContext()) { + // NativeContext is used as a marker that the closure was already + // called. We can't access the reject element context any more. + return; + } + + // Now peek into the Promise.all() resolve element context to // find the promise capability that's being resolved when all // the concurrent promises resolve. int const index = @@ -963,7 +969,13 @@ void CaptureAsyncStackTrace(Isolate* isolate, Handle promise, builder->AppendPromiseCombinatorFrame(function, combinator, FrameArray::kIsPromiseAny, context); - // Now peak into the Promise.any() reject element context to + if (context->IsNativeContext()) { + // NativeContext is used as a marker that the closure was already + // called. We can't access the reject element context any more. + return; + } + + // Now peek into the Promise.any() reject element context to // find the promise capability that's being resolved when any of // the concurrent promises resolve. int const index = PromiseBuiltins::kPromiseAnyRejectElementCapabilitySlot; diff --git a/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.cc b/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.cc index 78b586e265..5580b24308 100644 --- a/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.cc +++ b/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.cc @@ -670,11 +670,13 @@ Handle RegExpMacroAssemblerARM::GetCode(Handle source) { __ mov(r0, Operand(stack_limit)); __ ldr(r0, MemOperand(r0)); __ sub(r0, sp, r0, SetCC); + Operand extra_space_for_variables(num_registers_ * kPointerSize); + // Handle it if the stack pointer is already below the stack limit. __ b(ls, &stack_limit_hit); // Check if there is room for the variable number of registers above // the stack limit. - __ cmp(r0, Operand(num_registers_ * kPointerSize)); + __ cmp(r0, extra_space_for_variables); __ b(hs, &stack_ok); // Exit with OutOfMemory exception. There is not enough space on the stack // for our working registers. @@ -682,7 +684,7 @@ Handle RegExpMacroAssemblerARM::GetCode(Handle source) { __ jmp(&return_r0); __ bind(&stack_limit_hit); - CallCheckStackGuardState(); + CallCheckStackGuardState(extra_space_for_variables); __ cmp(r0, Operand::Zero()); // If returned value is non-zero, we exit with the returned value as result. __ b(ne, &return_r0); @@ -1048,16 +1050,18 @@ void RegExpMacroAssemblerARM::WriteStackPointerToRegister(int reg) { // Private methods: -void RegExpMacroAssemblerARM::CallCheckStackGuardState() { +void RegExpMacroAssemblerARM::CallCheckStackGuardState(Operand extra_space) { DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); DCHECK(!masm_->options().isolate_independent_code); - __ PrepareCallCFunction(3); + __ PrepareCallCFunction(4); + // Extra space for variables to consider in stack check. + __ mov(arg_reg_4, extra_space); // RegExp code frame pointer. - __ mov(r2, frame_pointer()); + __ mov(arg_reg_3, frame_pointer()); // Code of self. - __ mov(r1, Operand(masm_->CodeObject())); + __ mov(arg_reg_2, Operand(masm_->CodeObject())); // We need to make room for the return address on the stack. int stack_alignment = base::OS::ActivationFrameAlignment(); @@ -1101,7 +1105,8 @@ static T* frame_entry_address(Address re_frame, int frame_offset) { int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame) { + Address re_frame, + uintptr_t extra_space) { Code re_code = Code::cast(Object(raw_code)); return NativeRegExpMacroAssembler::CheckStackGuardState( frame_entry(re_frame, kIsolate), @@ -1110,7 +1115,8 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address, return_address, re_code, frame_entry_address
(re_frame, kInputString), frame_entry_address(re_frame, kInputStart), - frame_entry_address(re_frame, kInputEnd)); + frame_entry_address(re_frame, kInputEnd), + extra_space); } diff --git a/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.h b/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.h index 910e5c4607..114120755f 100644 --- a/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.h +++ b/src/3rdparty/chromium/v8/src/regexp/arm/regexp-macro-assembler-arm.h @@ -89,7 +89,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM // returning. // {raw_code} is an Address because this is called via ExternalReference. static int CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame); + Address re_frame, uintptr_t extra_space); private: // Offsets from frame_pointer() of function parameters and stored registers. @@ -134,7 +134,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM // Generate a call to CheckStackGuardState. - void CallCheckStackGuardState(); + void CallCheckStackGuardState( + Operand extra_space_for_variables = Operand::Zero()); // The ebp-relative location of a regexp register. MemOperand register_location(int register_index); diff --git a/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.cc b/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.cc index ac33f8631f..aaab0c5234 100644 --- a/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.cc +++ b/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.cc @@ -781,13 +781,14 @@ Handle RegExpMacroAssemblerARM64::GetCode(Handle source) { __ Mov(x10, stack_limit); __ Ldr(x10, MemOperand(x10)); __ Subs(x10, sp, x10); + Operand extra_space_for_variables(num_wreg_to_allocate * kWRegSize); // Handle it if the stack pointer is already below the stack limit. __ B(ls, &stack_limit_hit); // Check if there is room for the variable number of registers above // the stack limit. - __ Cmp(x10, num_wreg_to_allocate * kWRegSize); + __ Cmp(x10, extra_space_for_variables); __ B(hs, &stack_ok); // Exit with OutOfMemory exception. There is not enough space on the stack @@ -796,7 +797,7 @@ Handle RegExpMacroAssemblerARM64::GetCode(Handle source) { __ B(&return_w0); __ Bind(&stack_limit_hit); - CallCheckStackGuardState(x10); + CallCheckStackGuardState(x10, extra_space_for_variables); // If returned value is non-zero, we exit with the returned value as result. __ Cbnz(w0, &return_w0); @@ -1332,13 +1333,14 @@ static T* frame_entry_address(Address re_frame, int frame_offset) { int RegExpMacroAssemblerARM64::CheckStackGuardState( Address* return_address, Address raw_code, Address re_frame, - int start_index, const byte** input_start, const byte** input_end) { + int start_index, const byte** input_start, const byte** input_end, + uintptr_t extra_space) { Code re_code = Code::cast(Object(raw_code)); return NativeRegExpMacroAssembler::CheckStackGuardState( frame_entry(re_frame, kIsolate), start_index, static_cast(frame_entry(re_frame, kDirectCall)), return_address, re_code, frame_entry_address
(re_frame, kInput), - input_start, input_end); + input_start, input_end, extra_space); } @@ -1357,7 +1359,8 @@ void RegExpMacroAssemblerARM64::CheckPosition(int cp_offset, // Private methods: -void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) { +void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch, + Operand extra_space) { DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); DCHECK(!masm_->options().isolate_independent_code); @@ -1372,6 +1375,7 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) { __ Claim(xreg_to_claim); + __ Mov(x6, extra_space); // CheckStackGuardState needs the end and start addresses of the input string. __ Poke(input_end(), 2 * kSystemPointerSize); __ Add(x5, sp, 2 * kSystemPointerSize); diff --git a/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.h b/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.h index aeb49aa9ff..e4c4b0ac34 100644 --- a/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.h +++ b/src/3rdparty/chromium/v8/src/regexp/arm64/regexp-macro-assembler-arm64.h @@ -97,7 +97,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM64 static int CheckStackGuardState(Address* return_address, Address raw_code, Address re_frame, int start_offset, const byte** input_start, - const byte** input_end); + const byte** input_end, + uintptr_t extra_space); private: // Above the frame pointer - Stored registers and stack passed parameters. @@ -145,7 +146,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerARM64 void CheckStackLimit(); // Generate a call to CheckStackGuardState. - void CallCheckStackGuardState(Register scratch); + void CallCheckStackGuardState(Register scratch, + Operand extra_space = Operand(0)); // Location of a 32 bit position register. MemOperand register_location(int register_index); diff --git a/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.cc b/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.cc index 2135e977a7..d5fbd96067 100644 --- a/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.cc +++ b/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.cc @@ -700,11 +700,13 @@ Handle RegExpMacroAssemblerIA32::GetCode(Handle source) { ExternalReference::address_of_jslimit(isolate()); __ mov(ecx, esp); __ sub(ecx, StaticVariable(stack_limit)); + Immediate extra_space_for_variables(num_registers_ * kSystemPointerSize); + // Handle it if the stack pointer is already below the stack limit. __ j(below_equal, &stack_limit_hit); // Check if there is room for the variable number of registers above // the stack limit. - __ cmp(ecx, num_registers_ * kSystemPointerSize); + __ cmp(ecx, extra_space_for_variables); __ j(above_equal, &stack_ok); // Exit with OutOfMemory exception. There is not enough space on the stack // for our working registers. @@ -712,7 +714,7 @@ Handle RegExpMacroAssemblerIA32::GetCode(Handle source) { __ jmp(&return_eax); __ bind(&stack_limit_hit); - CallCheckStackGuardState(ebx); + CallCheckStackGuardState(ebx, extra_space_for_variables); __ or_(eax, eax); // If returned value is non-zero, we exit with the returned value as result. __ j(not_zero, &return_eax); @@ -1080,9 +1082,12 @@ void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) { // Private methods: -void RegExpMacroAssemblerIA32::CallCheckStackGuardState(Register scratch) { - static const int num_arguments = 3; +void RegExpMacroAssemblerIA32::CallCheckStackGuardState(Register scratch, + Immediate extra_space) { + static const int num_arguments = 4; __ PrepareCallCFunction(num_arguments, scratch); + // Extra space for variables. + __ mov(Operand(esp, 3 * kSystemPointerSize), extra_space); // RegExp code frame pointer. __ mov(Operand(esp, 2 * kSystemPointerSize), ebp); // Code of self. @@ -1113,7 +1118,8 @@ static T* frame_entry_address(Address re_frame, int frame_offset) { int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame) { + Address re_frame, + uintptr_t extra_space) { Code re_code = Code::cast(Object(raw_code)); return NativeRegExpMacroAssembler::CheckStackGuardState( frame_entry(re_frame, kIsolate), @@ -1122,7 +1128,8 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address, return_address, re_code, frame_entry_address
(re_frame, kInputString), frame_entry_address(re_frame, kInputStart), - frame_entry_address(re_frame, kInputEnd)); + frame_entry_address(re_frame, kInputEnd), + extra_space); } diff --git a/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.h b/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.h index a30bff29a1..620e7fb298 100644 --- a/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.h +++ b/src/3rdparty/chromium/v8/src/regexp/ia32/regexp-macro-assembler-ia32.h @@ -88,7 +88,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIA32 // returning. // {raw_code} is an Address because this is called via ExternalReference. static int CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame); + Address re_frame, uintptr_t extra_space); private: Operand StaticVariable(const ExternalReference& ext); @@ -133,7 +133,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerIA32 void CheckStackLimit(); // Generate a call to CheckStackGuardState. - void CallCheckStackGuardState(Register scratch); + void CallCheckStackGuardState(Register scratch, + Immediate extra_space = Immediate(0)); // The ebp-relative location of a regexp register. Operand register_location(int register_index); diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.cc b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.cc index cf4346309e..009027c103 100644 --- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.cc +++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.cc @@ -168,14 +168,15 @@ bool NativeRegExpMacroAssembler::CanReadUnaligned() { int NativeRegExpMacroAssembler::CheckStackGuardState( Isolate* isolate, int start_index, RegExp::CallOrigin call_origin, Address* return_address, Code re_code, Address* subject, - const byte** input_start, const byte** input_end) { + const byte** input_start, const byte** input_end, + uintptr_t gap) { DisallowHeapAllocation no_gc; Address old_pc = PointerAuthentication::AuthenticatePC(return_address, 0); DCHECK_LE(re_code.raw_instruction_start(), old_pc); DCHECK_LE(old_pc, re_code.raw_instruction_end()); StackLimitCheck check(isolate); - bool js_has_overflowed = check.JsHasOverflowed(); + bool js_has_overflowed = check.JsHasOverflowed(gap); if (call_origin == RegExp::CallOrigin::kFromJs) { // Direct calls from JavaScript can be interrupted in two ways: diff --git a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h index 52465610cb..da233d3c73 100644 --- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h +++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h @@ -261,7 +261,7 @@ class NativeRegExpMacroAssembler: public RegExpMacroAssembler { RegExp::CallOrigin call_origin, Address* return_address, Code re_code, Address* subject, const byte** input_start, - const byte** input_end); + const byte** input_end, uintptr_t gap); // Byte map of one byte characters with a 0xff if the character is a word // character (digit, letter or underscore) and 0x00 otherwise. diff --git a/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.cc b/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.cc index da0397689f..6ae1114f24 100644 --- a/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.cc +++ b/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.cc @@ -736,11 +736,13 @@ Handle RegExpMacroAssemblerX64::GetCode(Handle source) { __ movq(rcx, rsp); __ Move(kScratchRegister, stack_limit); __ subq(rcx, Operand(kScratchRegister, 0)); + Immediate extra_space_for_variables(num_registers_ * kSystemPointerSize); + // Handle it if the stack pointer is already below the stack limit. __ j(below_equal, &stack_limit_hit); // Check if there is room for the variable number of registers above // the stack limit. - __ cmpq(rcx, Immediate(num_registers_ * kSystemPointerSize)); + __ cmpq(rcx, extra_space_for_variables); __ j(above_equal, &stack_ok); // Exit with OutOfMemory exception. There is not enough space on the stack // for our working registers. @@ -749,7 +751,8 @@ Handle RegExpMacroAssemblerX64::GetCode(Handle source) { __ bind(&stack_limit_hit); __ Move(code_object_pointer(), masm_.CodeObject()); - CallCheckStackGuardState(); // Preserves no registers beside rbp and rsp. + // CallCheckStackGuardState preserves no registers beside rbp and rsp. + CallCheckStackGuardState(extra_space_for_variables); __ testq(rax, rax); // If returned value is non-zero, we exit with the returned value as result. __ j(not_zero, &return_rax); @@ -1147,27 +1150,31 @@ void RegExpMacroAssemblerX64::WriteStackPointerToRegister(int reg) { // Private methods: -void RegExpMacroAssemblerX64::CallCheckStackGuardState() { +void RegExpMacroAssemblerX64::CallCheckStackGuardState(Immediate extra_space) { // This function call preserves no register values. Caller should // store anything volatile in a C call or overwritten by this function. - static const int num_arguments = 3; + static const int num_arguments = 4; __ PrepareCallCFunction(num_arguments); #ifdef V8_TARGET_OS_WIN - // Second argument: Code of self. (Do this before overwriting r8). - __ movq(rdx, code_object_pointer()); + // Fourth argument: Extra space for variables. + __ movq(arg_reg_4, extra_space); + // Second argument: Code of self. (Do this before overwriting r8 (arg_reg_3)). + __ movq(arg_reg_2, code_object_pointer()); // Third argument: RegExp code frame pointer. - __ movq(r8, rbp); + __ movq(arg_reg_3, rbp); // First argument: Next address on the stack (will be address of // return address). - __ leaq(rcx, Operand(rsp, -kSystemPointerSize)); + __ leaq(arg_reg_1, Operand(rsp, -kSystemPointerSize)); #else + // Fourth argument: Extra space for variables. + __ movq(arg_reg_4, extra_space); // Third argument: RegExp code frame pointer. - __ movq(rdx, rbp); + __ movq(arg_reg_3, rbp); // Second argument: Code of self. - __ movq(rsi, code_object_pointer()); + __ movq(arg_reg_2, code_object_pointer()); // First argument: Next address on the stack (will be address of // return address). - __ leaq(rdi, Operand(rsp, -kSystemPointerSize)); + __ leaq(arg_reg_1, Operand(rsp, -kSystemPointerSize)); #endif ExternalReference stack_check = ExternalReference::re_check_stack_guard_state(isolate()); @@ -1189,7 +1196,8 @@ static T* frame_entry_address(Address re_frame, int frame_offset) { int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame) { + Address re_frame, + uintptr_t extra_space) { Code re_code = Code::cast(Object(raw_code)); return NativeRegExpMacroAssembler::CheckStackGuardState( frame_entry(re_frame, kIsolate), @@ -1198,7 +1206,8 @@ int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address, return_address, re_code, frame_entry_address
(re_frame, kInputString), frame_entry_address(re_frame, kInputStart), - frame_entry_address(re_frame, kInputEnd)); + frame_entry_address(re_frame, kInputEnd), + extra_space); } diff --git a/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.h b/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.h index ea4d45edba..6e5dcd18c2 100644 --- a/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.h +++ b/src/3rdparty/chromium/v8/src/regexp/x64/regexp-macro-assembler-x64.h @@ -82,7 +82,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerX64 // returning. // {raw_code} is an Address because this is called via ExternalReference. static int CheckStackGuardState(Address* return_address, Address raw_code, - Address re_frame); + Address re_frame, uintptr_t extra_space); private: // Offsets from rbp of function parameters and stored registers. @@ -166,7 +166,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerX64 void CheckStackLimit(); // Generate a call to CheckStackGuardState. - void CallCheckStackGuardState(); + void CallCheckStackGuardState(Immediate extra_space = Immediate(0)); // The rbp-relative location of a regexp register. Operand register_location(int register_index); diff --git a/src/3rdparty/chromium/v8/src/runtime/runtime-object.cc b/src/3rdparty/chromium/v8/src/runtime/runtime-object.cc index bd5d23dce4..075bc0c665 100644 --- a/src/3rdparty/chromium/v8/src/runtime/runtime-object.cc +++ b/src/3rdparty/chromium/v8/src/runtime/runtime-object.cc @@ -92,170 +92,10 @@ MaybeHandle Runtime::HasProperty(Isolate* isolate, : ReadOnlyRoots(isolate).false_value_handle(); } -namespace { - -void GeneralizeAllTransitionsToFieldAsMutable(Isolate* isolate, Handle map, - Handle name) { - InternalIndex descriptor(map->NumberOfOwnDescriptors()); - - Handle target_maps[kPropertyAttributesCombinationsCount]; - int target_maps_count = 0; - - // Collect all outgoing field transitions. - { - DisallowHeapAllocation no_gc; - TransitionsAccessor transitions(isolate, *map, &no_gc); - transitions.ForEachTransitionTo( - *name, - [&](Map target) { - DCHECK_EQ(descriptor, target.LastAdded()); - DCHECK_EQ(*name, target.GetLastDescriptorName(isolate)); - PropertyDetails details = target.GetLastDescriptorDetails(isolate); - // Currently, we track constness only for fields. - if (details.kind() == kData && - details.constness() == PropertyConstness::kConst) { - target_maps[target_maps_count++] = handle(target, isolate); - } - DCHECK_IMPLIES(details.kind() == kAccessor, - details.constness() == PropertyConstness::kConst); - }, - &no_gc); - CHECK_LE(target_maps_count, kPropertyAttributesCombinationsCount); - } - - for (int i = 0; i < target_maps_count; i++) { - Handle target = target_maps[i]; - PropertyDetails details = - target->instance_descriptors(isolate) - .GetDetails(descriptor); - Handle field_type( - target->instance_descriptors(isolate) - .GetFieldType(descriptor), - isolate); - Map::GeneralizeField(isolate, target, descriptor, - PropertyConstness::kMutable, details.representation(), - field_type); - DCHECK_EQ(PropertyConstness::kMutable, - target->instance_descriptors(isolate) - .GetDetails(descriptor) - .constness()); - } -} - -bool DeleteObjectPropertyFast(Isolate* isolate, Handle receiver, - Handle raw_key) { - // This implements a special case for fast property deletion: when the - // last property in an object is deleted, then instead of normalizing - // the properties, we can undo the last map transition, with a few - // prerequisites: - // (1) The receiver must be a regular object and the key a unique name. - Handle receiver_map(receiver->map(), isolate); - if (receiver_map->IsSpecialReceiverMap()) return false; - DCHECK(receiver_map->IsJSObjectMap()); - - if (!raw_key->IsUniqueName()) return false; - Handle key = Handle::cast(raw_key); - // (2) The property to be deleted must be the last property. - int nof = receiver_map->NumberOfOwnDescriptors(); - if (nof == 0) return false; - InternalIndex descriptor(nof - 1); - Handle descriptors(receiver_map->instance_descriptors(), - isolate); - if (descriptors->GetKey(descriptor) != *key) return false; - // (3) The property to be deleted must be deletable. - PropertyDetails details = descriptors->GetDetails(descriptor); - if (!details.IsConfigurable()) return false; - // (4) The map must have a back pointer. - Handle backpointer(receiver_map->GetBackPointer(), isolate); - if (!backpointer->IsMap()) return false; - Handle parent_map = Handle::cast(backpointer); - // (5) The last transition must have been caused by adding a property - // (and not any kind of special transition). - if (parent_map->NumberOfOwnDescriptors() != nof - 1) return false; - - // Preconditions successful. No more bailouts after this point. - - // Zap the property to avoid keeping objects alive. Zapping is not necessary - // for properties stored in the descriptor array. - if (details.location() == kField) { - DisallowHeapAllocation no_allocation; - - // Invalidate slots manually later in case we delete an in-object tagged - // property. In this case we might later store an untagged value in the - // recorded slot. - isolate->heap()->NotifyObjectLayoutChange(*receiver, no_allocation, - InvalidateRecordedSlots::kNo); - FieldIndex index = - FieldIndex::ForPropertyIndex(*receiver_map, details.field_index()); - // Special case deleting the last out-of object property. - if (!index.is_inobject() && index.outobject_array_index() == 0) { - DCHECK(!parent_map->HasOutOfObjectProperties()); - // Clear out the properties backing store. - receiver->SetProperties(ReadOnlyRoots(isolate).empty_fixed_array()); - } else { - Object filler = ReadOnlyRoots(isolate).one_pointer_filler_map(); - JSObject::cast(*receiver).RawFastPropertyAtPut(index, filler); - // We must clear any recorded slot for the deleted property, because - // subsequent object modifications might put a raw double there. - // Slot clearing is the reason why this entire function cannot currently - // be implemented in the DeleteProperty stub. - if (index.is_inobject() && !receiver_map->IsUnboxedDoubleField(index)) { - // We need to clear the recorded slot in this case because in-object - // slack tracking might not be finished. This ensures that we don't - // have recorded slots in free space. - isolate->heap()->ClearRecordedSlot(*receiver, - receiver->RawField(index.offset())); - MemoryChunk* chunk = MemoryChunk::FromHeapObject(*receiver); - chunk->InvalidateRecordedSlots(*receiver); - } - } - } - // If the {receiver_map} was marked stable before, then there could be - // optimized code that depends on the assumption that no object that - // reached this {receiver_map} transitions away from it without triggering - // the "deoptimize dependent code" mechanism. - receiver_map->NotifyLeafMapLayoutChange(isolate); - // Finally, perform the map rollback. - receiver->synchronized_set_map(*parent_map); -#if VERIFY_HEAP - receiver->HeapObjectVerify(isolate); - receiver->property_array().PropertyArrayVerify(isolate); -#endif - - // If the {descriptor} was "const" so far, we need to update the - // {receiver_map} here, otherwise we could get the constants wrong, i.e. - // - // o.x = 1; - // [change o.x's attributes or reconfigure property kind] - // delete o.x; - // o.x = 2; - // - // could trick V8 into thinking that `o.x` is still 1 even after the second - // assignment. - - // Step 1: Migrate object to an up-to-date shape. - if (parent_map->is_deprecated()) { - JSObject::MigrateInstance(isolate, Handle::cast(receiver)); - parent_map = handle(receiver->map(), isolate); - } - - // Step 2: Mark outgoing transitions from the up-to-date version of the - // parent_map to same property name of any kind or attributes as mutable. - // Also migrate object to the up-to-date map to make the object shapes - // converge sooner. - GeneralizeAllTransitionsToFieldAsMutable(isolate, parent_map, key); - - return true; -} - -} // namespace - Maybe Runtime::DeleteObjectProperty(Isolate* isolate, Handle receiver, Handle key, LanguageMode language_mode) { - if (DeleteObjectPropertyFast(isolate, receiver, key)) return Just(true); - bool success = false; LookupIterator::Key lookup_key(isolate, key, &success); if (!success) return Nothing(); diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri index e7f869a15f..a9df3d2432 100644 --- a/src/buildtools/config/support.pri +++ b/src/buildtools/config/support.pri @@ -21,7 +21,7 @@ defineReplace(qtwebengine_checkWebEngineCoreError) { !qtwebengine_checkForGperf(QtWebEngine):return(false) !qtwebengine_checkForBison(QtWebEngine):return(false) !qtwebengine_checkForFlex(QtWebEngine):return(false) - !qtwebengine_checkForPython2(QtWebEngine):return(false) + !qtwebengine_checkForPython(QtWebEngine):return(false) !qtwebengine_checkForNodejs(QtWebEngine):return(false) !qtwebengine_checkForSanitizer(QtWebEngine):return(false) linux:!qtwebengine_checkForPkgCfg(QtWebEngine):return(false) @@ -51,7 +51,7 @@ defineReplace(qtwebengine_checkPdfError) { !qtwebengine_checkForGperf(QtPdf):return(false) !qtwebengine_checkForBison(QtPdf):return(false) !qtwebengine_checkForFlex(QtPdf):return(false) - !qtwebengine_checkForPython2(QtPdf):return(false) + !qtwebengine_checkForPython(QtPdf):return(false) !qtwebengine_checkForSanitizer(QtPdf):return(false) linux:!qtwebengine_checkForPkgCfg(QtPdf):return(false) linux:!qtwebengine_checkForHostPkgCfg(QtPdf):return(false) @@ -143,10 +143,10 @@ defineTest(qtwebengine_checkForFlex) { return(true) } -defineTest(qtwebengine_checkForPython2) { +defineTest(qtwebengine_checkForPython) { module = $$1 - !qtConfig(webengine-python2) { - qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build $${module}.") + !qtConfig(webengine-python) { + qtwebengine_skipBuild("Python version 2 (2.7.5 or later) or Python version 3 (3.6 or later) is required to build $${module}.") return(false) } return(true) diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index 88d1790c17..5e5d9d725e 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -10,7 +10,8 @@ "options": { "build-qtwebengine-core": "boolean", "build-qtpdf": "boolean", - "webengine-jumbo-build": { "type": "optionalString", "name": "merge_limit"} + "webengine-jumbo-build": { "type": "optionalString", "name": "merge_limit"}, + "webengine-python-version": { "type": "optionalString", "name": "python_override", "values": ["python2", "python3"] } } }, "libraries": { @@ -212,6 +213,27 @@ { "type": "pkgConfig", "args": "libavcodec libavformat libavutil" } ] }, + "webengine-ffmpeg-support": { + "label": "compatible ffmpeg", + "type": "compile", + "test": { + "head": [ + "#include ", + "extern \"C\" {", + "#include ", + "}" + ], + "main": [ + "#if LIBAVFORMAT_VERSION_MAJOR >= 59", + "AVStream stream;", + "auto first_dts = av_stream_get_first_dts(&stream);", + "#endif" + ] + }, + "sources": [ + { "type": "pkgConfig", "args": "libavformat" } + ] + }, "webengine-opus": { "label": "opus", "sources": [ @@ -295,7 +317,7 @@ "label": "system ninja", "type": "detectNinja" }, - "webengine-python2": { + "webengine-python": { "label": "python2", "type": "detectPython2", "log": "location" @@ -374,7 +396,7 @@ && features.webengine-gperf && features.webengine-bison && features.webengine-flex - && features.webengine-python2 + && features.webengine-python && features.webengine-nodejs && (!config.sanitizer || features.webengine-sanitizer) && (!config.linux || features.pkg-config) @@ -400,7 +422,7 @@ && features.webengine-gperf && features.webengine-bison && features.webengine-flex - && features.webengine-python2 + && features.webengine-python && (!config.sanitizer || features.webengine-sanitizer) && (!config.linux || features.pkg-config) && (!config.linux || features.webengine-host-pkg-config) @@ -423,12 +445,12 @@ "autoDetect": "features.private_tests", "output": [ "privateFeature" ] }, - "webengine-python2": { + "webengine-python": { "label": "python2", - "condition": "tests.webengine-python2", + "condition": "tests.webengine-python", "output": [ "privateFeature", - { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python2.location" } + { "type": "varAssign", "name": "QMAKE_PYTHON2", "value": "tests.webengine-python.location" } ] }, "webengine-gperf": { @@ -758,6 +780,11 @@ "type": "warning", "condition": "config.ios && config.simulator && config.device && features.build-qtpdf", "message": "Building fat libray with device and simulator architectures will disable NEON." + }, + { + "type": "fatal", + "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support", + "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg." } ], "summary": [ diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 0a444a277e..e15bd05f39 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -763,6 +763,15 @@ static void LaunchURL(const GURL& url, protocolHandlerRegistry->IsHandledProtocol(url.scheme())) return; +#if BUILDFLAG(ENABLE_EXTENSIONS) + if (guest_view::GuestViewBase::IsGuest(webContents)) { + // Use parent / top level contents delegate for launching URLs from guest views. + webContents = guest_view::GuestViewBase::GetTopLevelWebContents(webContents); + if (!webContents) + return; + } +#endif //BUILDFLAG(ENABLE_EXTENSIONS) + WebContentsDelegateQt *contentsDelegate = static_cast(webContents->GetDelegate()); contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture); } diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 6b450b98c5..9f75beb850 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -126,6 +126,10 @@ \note \QWE cannot be built for the 32-bit mode of \macos (using the \c macx-clang-32 \c mkspec). + \note Universal debug or debug-and-release builds of \QWE on \macos are not supported in Qt 5 + due to memory constraints of the build toolchain. Use the configure options \c -force-debug-info + and \c -separate-debug-info for a build that can be used with a debugger. + \section1 Using Earlier Qt Versions to Build \QWE Building \QWE with earlier Qt versions (down to the last LTS From a08a39dc46a9377d093ac08049f6609c8a6c2568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=88=90=E5=88=9A?= Date: Wed, 28 Aug 2024 10:54:23 +0800 Subject: [PATCH 2/2] feat: add support loong64 riscv64 --- debian/changelog | 6 + debian/control | 28 +- debian/patches/Port-for-loongarch64.patch | 48731 ++++++++++++++++ debian/patches/add-riscv64-support.patch | 44231 ++++++++++++++ .../fix-regexp-loongarch64-stack-check.patch | 50 + debian/rules | 15 + 6 files changed, 93047 insertions(+), 14 deletions(-) create mode 100644 debian/patches/Port-for-loongarch64.patch create mode 100644 debian/patches/add-riscv64-support.patch create mode 100644 debian/patches/fix-regexp-loongarch64-stack-check.patch diff --git a/debian/changelog b/debian/changelog index 4aa25e4db2..ef265c6b7e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +qtwebengine-opensource-src (5.15.17+dfsg-3deepin1) unstable; urgency=medium + + * add support loong64 riscv64. + + -- LiChengGang Wed, 28 Aug 2024 10:52:43 +0800 + qtwebengine-opensource-src (5.15.17+dfsg-3) unstable; urgency=medium * Upload to unstable. diff --git a/debian/control b/debian/control index af2afb65f1..296e1f8592 100644 --- a/debian/control +++ b/debian/control @@ -95,7 +95,7 @@ Vcs-Git: https://salsa.debian.org/qt-kde-team/qt/qtwebengine.git Homepage: https://doc.qt.io/qt-5/qtwebengine-index.html Package: qtwebengine5-dev -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Section: libdevel Depends: libqt5webchannel5-dev, @@ -116,7 +116,7 @@ Description: Web content engine library for Qt - development files using QtWebEngine library. Package: qtwebengine5-private-dev -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Section: libdevel Depends: qtwebengine5-dev (= ${binary:Version}), ${misc:Depends} @@ -128,7 +128,7 @@ Description: Web content engine library for Qt - private development files Qt 5 applications using QtWebEngine library. Package: qtpdf5-dev -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Section: libdevel Depends: libqt5pdf5 (= ${binary:Version}), @@ -143,7 +143,7 @@ Description: Qt 5 PDF library - development files using Qt PDF library. Package: libqt5webengine5 -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: libqt5webengine-data (= ${source:Version}), ${misc:Depends}, @@ -156,7 +156,7 @@ Description: Web content engine library for Qt This package contains the QtWebEngine library. Package: libqt5webenginecore5 -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Provides: qtwebengine-abi-5-15-17 Depends: libqt5webengine-data (= ${source:Version}), @@ -173,7 +173,7 @@ Description: Web content engine library for Qt - Core This package contains the core QtWebEngine library. Package: libqt5webenginewidgets5 -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: libqt5webengine-data (= ${source:Version}), ${misc:Depends}, @@ -186,7 +186,7 @@ Description: Web content engine library for Qt - Widget This package contains the widget QtWebEngine library. Package: libqt5pdf5 -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF library @@ -195,7 +195,7 @@ Description: Qt 5 PDF library This package contains the Qt PDF library. Package: libqt5pdfwidgets5 -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF Widgets library @@ -215,7 +215,7 @@ Description: Web content engine library for Qt - Data This package contains the arch independent parts of QtWebEngine libraries. Package: qt5-image-formats-plugin-pdf -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: ${misc:Depends}, ${shlibs:Depends} Description: Qt 5 PDF image format plugin @@ -225,7 +225,7 @@ Description: Qt 5 PDF image format plugin to view PDF files (the first page of PDF will be shown). Package: qml-module-qtwebengine -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: qml-module-qtquick2, ${misc:Depends}, ${shlibs:Depends} Pre-Depends: ${misc:Pre-Depends} @@ -236,7 +236,7 @@ Description: Qt WebEngine QML module This package contains the WebEngine QML module for QtDeclarative. Package: qml-module-qtquick-pdf -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: qml-module-qtgraphicaleffects (>= 5.12), qml-module-qtquick-controls2 (>= 5.14), @@ -253,7 +253,7 @@ Description: Qt Quick PDF QML module This package contains the Qt Quick PDF QML module. Package: qtwebengine5-dev-tools -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: foreign Section: devel Depends: qtchooser, ${misc:Depends}, ${shlibs:Depends} @@ -266,7 +266,7 @@ Description: Qt WebEngine tools in Qt WebEngine. Package: qtwebengine5-examples -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: libjs-jquery, libjs-marked, @@ -291,7 +291,7 @@ Description: Qt WebEngine - Examples This package contains the WebEngine examples. Package: qtpdf5-examples -Architecture: amd64 arm64 armhf i386 mips64el +Architecture: amd64 arm64 armhf i386 mips64el loong64 riscv64 Multi-Arch: same Depends: qml-module-qtquick-pdf (= ${binary:Version}), ${misc:Depends}, diff --git a/debian/patches/Port-for-loongarch64.patch b/debian/patches/Port-for-loongarch64.patch new file mode 100644 index 0000000000..31b5efa2f3 --- /dev/null +++ b/debian/patches/Port-for-loongarch64.patch @@ -0,0 +1,48731 @@ +From da5633efd7cc01759b9d77efb6c12100dbf12944 Mon Sep 17 00:00:00 2001 +From: Mu Tao +From: lichenggang +Date: Mon, 28 Aug 2024 08:44:28 +0800 +Subject: [PATCH] Port for loongarch64 + + +Signed-off-by: lichenggang + +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/configure.pri ++++ qtwebengine-opensource-src-5.15.17+dfsg/configure.pri +@@ -157,6 +157,7 @@ defineTest(qtConfTest_detectArch) { + contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) + contains(QT_ARCH, "mips"): return(true) + contains(QT_ARCH, "mips64"): return(true) ++ contains(QT_ARCH, "loongarch64"): return(true) + qtLog("Architecture not supported.") + return(false) + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/configure.pri.orig +@@ -0,0 +1,569 @@ ++include(src/buildtools/config/support.pri) ++include(src/buildtools/config/functions.pri) ++ ++# this must be done outside any function ++QTWEBENGINE_SOURCE_TREE = $$PWD ++ ++equals(QMAKE_HOST.os, Windows): EXE_SUFFIX = .exe ++ ++defineTest(isPythonVersionSupported) { ++ python = $$system_quote($$system_path($$1)) ++ python_version = $$system('$$python -c "import sys; print(sys.version_info[0:3])"') ++ python_version ~= s/[()]//g ++ python_version = $$split(python_version, ',') ++ python_major_version = $$first(python_version) ++ python_minor_version = $$member(python_version, 1) ++ python_patch_version = $$member(python_version, 2) ++ greaterThan(python_major_version, 2): greaterThan(python_minor_version, 7): return(true) ++ greaterThan(python_major_version, 1): greaterThan(python_minor_version, 6): greaterThan(python_patch_version, 4): return(true) ++ qtLog("Unsupported python version: $${python_major_version}.$${python_minor_version}.$${python_patch_version}.") ++ return(false) ++} ++ ++defineTest(qtConfTest_detectJumboBuild) { ++ mergeLimit = $$eval(config.input.merge_limit) ++ mergeLimit = $$find(mergeLimit, "\\d") ++ isEmpty(mergeLimit) { ++ win32: mergeLimit = 0 ++ else: mergeLimit = 8 ++ } ++ qtLog("Setting jumbo build merge batch limit to $${mergeLimit}.") ++ $${1}.merge_limit = $$mergeLimit ++ export($${1}.merge_limit) ++ $${1}.cache += merge_limit ++ export($${1}.cache) ++ ++ return(true) ++} ++ ++defineTest(qtConfReport_skipBuildWarning) { ++ $${1}() ++ !isEmpty(skipBuildReason):qtConfAddWarning($${skipBuildReason}) ++} ++ ++defineTest(qtConfReport_jumboBuild) { ++ mergeLimit = $$eval(cache.webengine-jumbo-build.merge_limit) ++ isEmpty(mergeLimit)|!greaterThan(mergeLimit,0) { ++ mergeLimit = "no" ++ } ++ qtConfReportPadded($${1}, $$mergeLimit) ++} ++ ++defineTest(qtConfTest_detectPython2) { ++ pythonOverride = $$eval(config.input.python_override) ++ !isEmpty(pythonOverride) { ++ python = $$qtConfFindInPath("$$pythonOverride$$EXE_SUFFIX") ++ isEmpty(python) { ++ qtLog("User selected '$$pythonOverride$$EXE_SUFFIX' was not found in PATH. Giving up.") ++ return(false) ++ } ++ } ++ ++ win32 { ++ # the default name of the python 2 executable on windows is just ++ # python, so try that first ++ isEmpty(python):python = $$qtConfFindInPath("python$$EXE_SUFFIX") ++ isEmpty(python):python = $$qtConfFindInPath("python2$$EXE_SUFFIX") ++ isEmpty(python):python = $$qtConfFindInPath("python3$$EXE_SUFFIX") ++ } else { ++ isEmpty(python):python = $$qtConfFindInPath("python2$$EXE_SUFFIX") ++ isEmpty(python):python = $$qtConfFindInPath("python3$$EXE_SUFFIX") ++ isEmpty(python):python = $$qtConfFindInPath("python$$EXE_SUFFIX") ++ } ++ ++ isEmpty(python) { ++ qtLog("Python not found in PATH. Giving up.") ++ return(false) ++ } ++ !isPythonVersionSupported($$python) { ++ qtLog("A suitable Python executable could not be located.") ++ return(false) ++ } ++ ++ # Make tests.python.location available in configure.json. ++ $${1}.location = $$clean_path($$python) ++ export($${1}.location) ++ $${1}.cache += location ++ export($${1}.cache) ++ ++ return(true) ++} ++ ++defineReplace(qtConfFindGnuTool) { ++ equals(QMAKE_HOST.os, Windows) { ++ gnuwin32bindir = $$absolute_path($$QTWEBENGINE_SOURCE_TREE/../gnuwin32/bin) ++ gnuwin32toolpath = "$$gnuwin32bindir/$${1}" ++ exists($$gnuwin32toolpath): \ ++ return($$gnuwin32toolpath) ++ } ++ return($$qtConfFindInPath($$1)) ++} ++ ++defineTest(qtConfTest_detectGperf) { ++ gperf = $$qtConfFindGnuTool("gperf$$EXE_SUFFIX") ++ isEmpty(gperf) { ++ qtLog("Required gperf could not be found.") ++ return(false) ++ } ++ qtLog("Found gperf from path: $$gperf") ++ return(true) ++} ++ ++defineTest(qtConfTest_detectBison) { ++ bison = $$qtConfFindGnuTool("bison$$EXE_SUFFIX") ++ isEmpty(bison) { ++ qtLog("Required bison could not be found.") ++ return(false) ++ } ++ qtLog("Found bison from path: $$bison") ++ return(true) ++} ++ ++defineTest(qtwebengine_platformError) { ++ platformError = $$1 ++ export(platformError) ++} ++ ++defineTest(qtConfTest_detectPlatform) { ++ QT_FOR_CONFIG += gui-private ++ ++ linux:qtwebengine_isLinuxPlatformSupported() { ++ $${1}.platform = "linux" ++ } ++ win32:qtwebengine_isWindowsPlatformSupported() { ++ $${1}.platform = "windows" ++ } ++ macos:qtwebengine_isMacOsPlatformSupported() { ++ $${1}.platform = "macos" ++ } ++ ios:qtwebengine_isMacOsPlatformSupported() { ++ $${1}.platform = "ios" ++ } ++ ++ !isEmpty(platformError) { ++ qtLog("Platform not supported.") ++ $${1}.platformSupport = $$platformError ++ export($${1}.platformSupport) ++ $${1}.cache += platformSupport ++ export($${1}.cache) ++ return(false) ++ } ++ export($${1}.platformSupport) ++ return(true) ++} ++ ++defineTest(qtConfTest_detectArch) { ++ contains(QT_ARCH, "i386")|contains(QT_ARCH, "x86_64"): return(true) ++ contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) ++ contains(QT_ARCH, "mips"): return(true) ++ contains(QT_ARCH, "mips64"): return(true) ++ qtLog("Architecture not supported.") ++ return(false) ++} ++ ++defineTest(qtConfTest_detectFlex) { ++ flex = $$qtConfFindGnuTool("flex$$EXE_SUFFIX") ++ isEmpty(flex) { ++ qtLog("Required flex could not be found.") ++ return(false) ++ } ++ qtLog("Found flex from path: $$flex") ++ return(true) ++} ++ ++defineTest(qtConfTest_detectNinja) { ++ ninja = $$qtConfFindInPath("ninja$$EXE_SUFFIX") ++ !isEmpty(ninja) { ++ qtLog("Found ninja from path: $$ninja") ++ qtRunLoggedCommand("$$ninja --version", version)|return(false) ++ contains(version, "1\.([7-9]|1[0-9])\..*"): return(true) ++ qtLog("Ninja version too old") ++ } ++ qtLog("Building own ninja") ++ return(false) ++} ++ ++defineTest(qtConfTest_detectGn) { ++ gn = $$qtConfFindInPath("gn$$EXE_SUFFIX") ++ !isEmpty(gn) { ++ qtRunLoggedCommand("$$gn --version", version)|return(false) ++ #accept all for now ++ contains(version, ".*"): return(true) ++ qtLog("Gn version too old") ++ } ++ qtLog("Building own gn") ++ return(false) ++} ++ ++defineTest(qtConfTest_detectNodeJS) { ++ nodejs = $$qtConfFindInPath("nodejs$$EXE_SUFFIX") ++ isEmpty(nodejs) { ++ qtLog("'nodejs$$EXE_SUFFIX' not found in PATH. Checking for 'node$$EXE_SUFFIX'.") ++ nodejs = $$qtConfFindInPath("node$$EXE_SUFFIX") ++ isEmpty(nodejs) { ++ qtLog("'node$$EXE_SUFFIX' not found in PATH. Giving up.") ++ return(false) ++ } ++ } ++ nodejs = $$system_quote($$system_path($$nodejs)) ++ !qtRunLoggedCommand("$$nodejs --version", version) { ++ qtLog("'$$nodejs' didn't run.") ++ return(false) ++ } ++ # at least version 10 ++ version10 = false ++ contains(version, "v([1-9][0-9])\..*"): version10 = true ++ ++ $${1}.version10 = $$version10 ++ export($${1}.version10) ++ $${1}.cache += version10 ++ export($${1}.cache) ++ return(true) ++} ++ ++defineTest(qtConfTest_detectEmbedded) { ++ lessThan(QT_MINOR_VERSION, 9) { ++ cross_compile: return(true) ++ return(false) ++ } ++ $$qtConfEvaluate("features.cross_compile"): return(true) ++ return(false) ++} ++ ++defineTest(qtConfTest_detectHostPkgConfig) { ++ PKG_CONFIG = $$qtConfPkgConfig(true) ++ isEmpty(PKG_CONFIG) { ++ qtLog("Could not find host pkg-config") ++ return(false) ++ } ++ qtLog("Found host pkg-config: $$PKG_CONFIG") ++ $${1}.path = $$PKG_CONFIG ++ export($${1}.path) ++ $${1}.cache += path ++ export($${1}.cache) ++ return(true) ++} ++ ++defineTest(qtConfTest_isSanitizerSupported) { ++ sanitizer_combo_supported = true ++ ++ sanitize_address { ++ asan_supported = false ++ linux-clang-libc++:isSanitizerSupportedOnLinux() { ++ asan_supported = true ++ } else:macos:isSanitizerSupportedOnMacOS() { ++ asan_supported = true ++ } ++ !$$asan_supported { ++ sanitizer_combo_supported = false ++ qtLog("An address sanitizer-enabled Qt WebEngine build can only be built on Linux or macOS using Clang and libc++.") ++ } ++ } ++ ++ sanitize_memory { ++ sanitizer_combo_supported = false ++ qtLog("A memory sanitizer-enabled Qt WebEngine build is not supported.") ++ } ++ ++ sanitize_undefined { ++ ubsan_supported = false ++ CONFIG(release, debug|release):!debug_and_release { ++ linux-clang-libc++:isSanitizerSupportedOnLinux() { ++ ubsan_supported = true ++ } else:macos:isSanitizerSupportedOnMacOS() { ++ ubsan_supported = true ++ } ++ } ++ !$$ubsan_supported { ++ sanitizer_combo_supported = false ++ qtLog("An undefined behavior sanitizer-enabled Qt WebEngine build can only be built on Linux or macOS using Clang and libc++ in release mode.") ++ } ++ } ++ ++ sanitize_thread { ++ tsan_supported = false ++ linux-clang-libc++:isSanitizerSupportedOnLinux() { ++ tsan_supported = true ++ } ++ !$$tsan_supported { ++ sanitizer_combo_supported = false ++ qtLog("A thread sanitizer-enabled Qt WebEngine build can only be built on Linux using Clang and libc++.") ++ } ++ } ++ ++ $$sanitizer_combo_supported: return(true) ++ return(false) ++} ++ ++defineTest(isSanitizerSupportedOnLinux) { ++ isSanitizerLinuxClangVersionSupported(): return(true) ++ return(false) ++} ++ ++defineTest(isSanitizerSupportedOnMacOS) { ++ isEmpty(QMAKE_APPLE_CLANG_MAJOR_VERSION) { ++ QTWEBENGINE_CLANG_IS_APPLE = false ++ } else { ++ QTWEBENGINE_CLANG_IS_APPLE = true ++ } ++ ++ $$QTWEBENGINE_CLANG_IS_APPLE:isSanitizerMacOSAppleClangVersionSupported(): return(true) ++ else:isSanitizerMacOSClangVersionSupported(): return(true) ++ return(false) ++} ++ ++defineTest(isSanitizerMacOSAppleClangVersionSupported) { ++ # Clang sanitizer suppression attributes work from Apple Clang version 7.3.0+. ++ greaterThan(QMAKE_APPLE_CLANG_MAJOR_VERSION, 7): return(true) ++ greaterThan(QMAKE_APPLE_CLANG_MINOR_VERSION, 2): return(true) ++ ++ qtLog("Using Apple Clang version $${QMAKE_APPLE_CLANG_MAJOR_VERSION}.$${QMAKE_APPLE_CLANG_MINOR_VERSION}.$${QMAKE_APPLE_CLANG_PATCH_VERSION}, but at least Apple Clang version 7.3.0 is required to build a sanitizer-enabled Qt WebEngine.") ++ return(false) ++} ++ ++defineTest(isSanitizerMacOSClangVersionSupported) { ++ # Clang sanitizer suppression attributes work from non-apple Clang version 3.7+. ++ greaterThan(QMAKE_CLANG_MAJOR_VERSION, 3): return(true) ++ greaterThan(QMAKE_CLANG_MINOR_VERSION, 6): return(true) ++ ++ qtLog("Using Clang version $${QMAKE_CLANG_MAJOR_VERSION}.$${QMAKE_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.") ++ return(false) ++} ++ ++defineTest(isSanitizerLinuxClangVersionSupported) { ++ # Clang sanitizer suppression attributes work from Clang version 3.7+. ++ greaterThan(QMAKE_CLANG_MAJOR_VERSION, 3): return(true) ++ greaterThan(QMAKE_CLANG_MINOR_VERSION, 6): return(true) ++ ++ qtLog("Using Clang version $${QMAKE_CLANG_MAJOR_VERSION}.$${QMAKE_CLANG_MINOR_VERSION}, but at least Clang version 3.7 is required to build a sanitizer-enabled Qt WebEngine.") ++ return(false) ++} ++ ++defineReplace(qtConfFunc_isTestsInBuildParts) { ++ contains(QT_BUILD_PARTS, tests): return(true) ++ return(false) ++} ++ ++defineReplace(webEngineGetMacOSVersion) { ++ value = $$system("sw_vers -productVersion 2>/dev/null") ++ return($$value) ++} ++ ++defineReplace(webEngineGetMacOSSDKVersion) { ++ value = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null") ++ return($$value) ++} ++ ++defineReplace(webEngineGetMacOSClangVerboseVersion) { ++ output = $$system("$$QMAKE_CXX --version 2>/dev/null", lines) ++ value = $$first(output) ++ return($$value) ++} ++ ++defineTest(qtConfReport_macosToolchainVersion) { ++ arg = $$2 ++ contains(arg, "macosVersion"): report_message = $$webEngineGetMacOSVersion() ++ contains(arg, "xcodeVersion"): report_message = "$$QMAKE_XCODE_VERSION" ++ contains(arg, "clangVersion"): report_message = $$webEngineGetMacOSClangVerboseVersion() ++ contains(arg, "sdkVersion"): report_message = $$webEngineGetMacOSSDKVersion() ++ contains(arg, "deploymentTarget"): report_message = "$$QMAKE_MACOSX_DEPLOYMENT_TARGET" ++ !isEmpty(report_message): qtConfReportPadded($$1, $$report_message) ++} ++ ++defineTest(qtConfTest_isWindowsHostCompiler64) { ++ win_host_arch = $$(VSCMD_ARG_HOST_ARCH) ++ isEmpty(win_host_arch): return(true) ++ contains(win_host_arch,"x64"): return(true) ++ qtLog("Required 64-bit cross-building or native toolchain was not detected.") ++ return(false) ++} ++ ++# Fixme QTBUG-71772 ++defineTest(qtConfTest_hasThumbFlag) { ++ FLAG = $$qtwebengine_extractCFlag("-mthumb") ++ !isEmpty(FLAG): return(true) ++ FLAG = $$qtwebengine_extractCFlag("-marm") ++ !isEmpty(FLAG): return(false) ++ ++ MARCH = $$qtwebengine_extractCFlag("-march=.*") ++ MARMV = $$replace(MARCH, "armv",) ++ !isEmpty(MARMV) { ++ MARMV = $$split(MARMV,) ++ MARMV = $$member(MARMV, 0) ++ } ++ if (isEmpty(MARMV) | lessThan(MARMV, 7)): return(false) ++ # no flag assume mthumb ++ return(true) ++} ++ ++defineTest(qtConfTest_detectSubmodule) { ++ isEmpty(QTWEBENGINE_ROOT) { ++ # topLevel build , add poor man's workaround ++ QTWEBENGINE_ROOT=$$PWD/../../../qtwebengine ++ } ++ !exists($$QTWEBENGINE_ROOT/src/3rdparty/chromium):return(false) ++ return(true) ++} ++ ++defineTest(qtConfTest_detectNoWhitespace) { ++ WSPC = $$find(OUT_PWD, \\s) ++ !isEmpty(WSPC):return(false) ++ return(true) ++} ++ ++defineTest(qtwebengine_confCheckWebEngineCoreError) { ++ QT_FOR_CONFIG += buildtools-private gui-private ++ return($$qtwebengine_checkWebEngineCoreError()) ++} ++ ++defineTest(qtwebengine_confCheckPdfError) { ++ QT_FOR_CONFIG += buildtools-private gui-private ++ return($$qtwebengine_checkPdfError()) ++} ++ ++defineTest(qtwebengine_isLinuxPlatformSupported) { ++ !gcc|intel_icc { ++ qtwebengine_platformError("requires clang or GCC.") ++ return(false) ++ } ++ gcc:!clang:!qtwebengine_isGCCVersionSupported(): return(false) ++ gcc:!qtConfig(c++14) { ++ qtwebengine_platformError("requires c++14 support.") ++ return(false) ++ } ++ return(true) ++} ++ ++defineTest(qtwebengine_isWindowsPlatformSupported) { ++ winrt { ++ qtwebengine_platformError("for WinRT is not supported.") ++ return(false) ++ } ++ qtwebengine_isBuildingOnWin32() { ++ qtwebengine_platformError("must be built on a 64-bit machine.") ++ return(false) ++ } ++ !msvc|intel_icl { ++ qtwebengine_platformError("requires MSVC or Clang (MSVC mode).") ++ return(false) ++ } ++ !qtwebengine_isMinWinSDKVersion(10, 19041): { ++ qtwebengine_platformError("requires a Windows SDK version 10.0.19041 or newer.") ++ return(false) ++ } ++ return(true) ++} ++ ++defineTest(qtwebengine_isMacOsPlatformSupported) { ++ !qtwebengine_isMinXcodeVersion(10, 0, 0) { ++ qtwebengine_platformError("requires at least version 10.0.0, but using Xcode version $${QMAKE_XCODE_VERSION}.") ++ return(false) ++ } ++ !clang|intel_icc { ++ qtwebengine_platformError("requires Clang.") ++ return(false) ++ } ++ # We require macOS 10.13 (darwin version 17.0.0) or newer. ++ darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0) ++ lessThan(darwin_major_version, 17) { ++ qtwebengine_platformError("requires macOS version 10.13 or newer.") ++ return(false) ++ } ++ !qtwebengine_isMinOSXSDKVersion(10, 13): { ++ qtwebengine_platformError("requires a macOS SDK version of 10.13 or newer. Current version is $${WEBENGINE_OSX_SDK_PRODUCT_VERSION}.") ++ return(false) ++ } ++ CONFIG(debug, debug|release):isUniversal(){ ++ qtwebengine_platformError("Universal builds can not be done with debug configuration due to large binary size.") ++ return(false) ++ } ++ return(true) ++} ++ ++defineTest(qtwebengine_isGCCVersionSupported) { ++ # Keep in sync with src/webengine/doc/src/qtwebengine-platform-notes.qdoc ++ lessThan(QMAKE_GCC_MAJOR_VERSION, 5) { ++ qtwebengine_platformError("requires at least gcc version 5, but using gcc version $${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}.") ++ return(false) ++ } ++ ++ equals(QMAKE_GCC_MAJOR_VERSION, 5): equals(QMAKE_GCC_MINOR_VERSION, 4): equals(QMAKE_GCC_PATCH_VERSION, 0) { ++ qtwebengine_platformError("gcc version 5.4.0 is blacklisted due to internal compiler errors.") ++ return(false) ++ } ++ ++ return(true) ++} ++ ++defineTest(qtwebengine_isBuildingOnWin32) { ++ # The check below is ugly, but necessary, as it seems to be the only reliable way to detect if the host ++ # architecture is 32 bit. QMAKE_HOST.arch does not work as it returns the architecture that the toolchain ++ # is building for, not the system's actual architecture. ++ PROGRAM_FILES_X86 = $$(ProgramW6432) ++ isEmpty(PROGRAM_FILES_X86): return(true) ++ return(false) ++} ++ ++defineTest(qtwebengine_isMinOSXSDKVersion) { ++ requested_major = $$1 ++ requested_minor = $$2 ++ requested_patch = $$3 ++ isEmpty(requested_patch): requested_patch = 0 ++ WEBENGINE_OSX_SDK_PRODUCT_VERSION = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null") ++ export(WEBENGINE_OSX_SDK_PRODUCT_VERSION) ++ isEmpty(WEBENGINE_OSX_SDK_PRODUCT_VERSION) { ++ qtwebengine_platformError("requires SDK product version, but could not resolve it for \'$$QMAKE_MAC_SDK\'.") ++ return(false) ++ } ++ major_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 0, 0) ++ minor_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 1, 1) ++ patch_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 2, 2) ++ isEmpty(patch_version): patch_version = 0 ++ ++ greaterThan(major_version, $$requested_major):return(true) ++ equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true) ++ equals(major_version, $$requested_major):equals(minor_version, $$requested_minor):!lessThan(patch_version, $$requested_patch):return(true) ++ ++ return(false) ++} ++ ++defineTest(qtwebengine_isMinXcodeVersion) { ++ requested_major = $$1 ++ requested_minor = $$2 ++ requested_patch = $$3 ++ isEmpty(requested_minor): requested_minor = 0 ++ isEmpty(requested_patch): requested_patch = 0 ++ target_var = QMAKE_XCODE_VERSION ++ major_version = $$section($$target_var, ., 0, 0) ++ minor_version = $$section($$target_var, ., 1, 1) ++ patch_version = $$section($$target_var, ., 2, 2) ++ isEmpty(minor_version): minor_version = 0 ++ isEmpty(patch_version): patch_version = 0 ++ ++ greaterThan(major_version, $$requested_major):return(true) ++ equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true) ++ equals(major_version, $$requested_major):equals(minor_version, $$requested_minor):!lessThan(patch_version, $$requested_patch):return(true) ++ ++ return(false) ++} ++ ++defineTest(qtwebengine_isMinWinSDKVersion) { ++ requested_major = $$1 ++ requested_minor = $$2 ++ WIN_SDK_VERSION = $$(WindowsSDKVersion) ++ ++ isEmpty(WIN_SDK_VERSION)|equals(WIN_SDK_VERSION, "\\") { ++ qtwebengine_platformError("requires Windows SDK version, but could not detect it (\'WindowsSDKVersion\' environment variable is not set).") ++ return(false) ++ } ++ ++ # major.0.minor ++ major_version = $$section(WIN_SDK_VERSION, ., 0, 0) ++ minor_version = $$section(WIN_SDK_VERSION, ., 2, 2) ++ ++ greaterThan(major_version, $$requested_major):return(true) ++ equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true) ++ equals(major_version, $$requested_major):equals(minor_version, $$requested_minor)::return(true) ++ ++ return(false) ++} +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/configure.pri.rej +@@ -0,0 +1,10 @@ ++--- configure.pri +++++ configure.pri ++@@ -123,6 +123,7 @@ defineTest(qtConfTest_detectArch) { ++ contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) ++ contains(QT_ARCH, "mips"): return(true) ++ contains(QT_ARCH, "mips64"): return(true) +++ contains(QT_ARCH, "loongarch64"): return(true) ++ qtLog("Architecture not supported.") ++ return(false) ++ } +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/mkspecs/features/functions.prf ++++ qtwebengine-opensource-src-5.15.17+dfsg/mkspecs/features/functions.prf +@@ -112,6 +112,7 @@ defineReplace(gnArch) { + contains(qtArch, "mips"): return(mipsel) + contains(qtArch, "mips64"): return(mips64el) + contains(qtArch, "mips64el"): return(mips64el) ++ contains(qtArch, "loongarch64"): return(loongarch64) + return(unknown) + } + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/mkspecs/features/functions.prf.rej +@@ -0,0 +1,10 @@ ++--- mkspecs/features/functions.prf +++++ mkspecs/features/functions.prf ++@@ -112,6 +112,7 @@ defineReplace(gnArch) { ++ contains(qtArch, "mips"): return(mipsel) ++ contains(qtArch, "mips64"): return(mips64el) ++ contains(qtArch, "mips64el"): return(mips64el) +++ contains(qtArch, "loongarch64"): return(loongarch64) ++ return(unknown) ++ } ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h +@@ -73,7 +73,7 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEX + // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice + // here. + return 16; // 64kB +-#elif defined(_MIPS_ARCH_LOONGSON) ++#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) + return 14; // 16kB + #elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h.orig +@@ -0,0 +1,157 @@ ++// Copyright (c) 2018 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ ++#define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ ++ ++#include ++ ++#include "base/compiler_specific.h" ++#include "build/build_config.h" ++ ++#if defined(OS_APPLE) ++ ++#include ++ ++// Although page allocator constants are not constexpr, they are run-time ++// constant. Because the underlying variables they access, such as vm_page_size, ++// are not marked const, the compiler normally has no way to know that they ++// don’t change and must obtain their values whenever it can't prove that they ++// haven't been modified, even if they had already been obtained previously. ++// Attaching __attribute__((const)) to these declarations allows these redundant ++// accesses to be omitted under optimization such as common subexpression ++// elimination. ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) ++ ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++// This should work for all POSIX (if needed), but currently all other ++// supported OS/architecture combinations use either hard-coded values ++// (such as x86) or have means to determine these values without needing ++// atomics (such as macOS on arm64). ++ ++// Page allocator constants are run-time constant ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) ++ ++#include ++#include ++ ++namespace base::internal { ++ ++// Holds the current page size and shift, where size = 1 << shift ++// Use PageAllocationGranularity(), PageAllocationGranularityShift() ++// to initialize and retrieve these values safely. ++struct PageCharacteristics { ++ std::atomic size; ++ std::atomic shift; ++}; ++extern PageCharacteristics page_characteristics; ++ ++} // namespace base::internal ++ ++#else ++ ++// When defined, page size constants are fixed at compile time. When not ++// defined, they may vary at run time. ++#define PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR 1 ++ ++// Use this macro to declare a function as constexpr or not based on whether ++// PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR is defined. ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR constexpr ++ ++#endif ++ ++namespace base { ++// Forward declaration, implementation below ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularity(); ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() { ++#if defined(OS_WIN) || defined(ARCH_CPU_PPC64) ++ // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page ++ // sizes. Since 64kB is the de facto standard on the platform and binaries ++ // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice ++ // here. ++ return 16; // 64kB ++#elif defined(_MIPS_ARCH_LOONGSON) ++ return 14; // 16kB ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++ // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) ++ // page sizes. Retrieve from or initialize cache. ++ int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed); ++ if (UNLIKELY(shift == 0)) { ++ shift = __builtin_ctz((int)base::PageAllocationGranularity()); ++ base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed); ++ } ++ return shift; ++#elif defined(OS_APPLE) ++ return vm_page_shift; ++#else ++ return 12; // 4kB ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularity() { ++#if defined(OS_APPLE) ++ // This is literally equivalent to |1 << PageAllocationGranularityShift()| ++ // below, but was separated out for OS_APPLE to avoid << on a non-constexpr. ++ return vm_page_size; ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++ // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or ++ // initialize cache. ++ int size = internal::page_characteristics.size.load(std::memory_order_relaxed); ++ if (UNLIKELY(size == 0)) { ++ size = getpagesize(); ++ internal::page_characteristics.size.store(size, std::memory_order_relaxed); ++ } ++ return size; ++#else ++ return 1ULL << PageAllocationGranularityShift(); ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularityOffsetMask() { ++ return PageAllocationGranularity() - 1; ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularityBaseMask() { ++ return ~PageAllocationGranularityOffsetMask(); ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageSize() { ++#if defined(OS_WIN) ++ return 4096; ++#else ++ return PageAllocationGranularity(); ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageOffsetMask() { ++ return SystemPageSize() - 1; ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageBaseMask() { ++ return ~SystemPageOffsetMask(); ++} ++ ++static constexpr size_t kPageMetadataShift = 5; // 32 bytes per partition page. ++static constexpr size_t kPageMetadataSize = 1 << kPageMetadataShift; ++ ++// See DecommitSystemPages(), this is not guaranteed to be synchronous on all ++// platforms. ++static constexpr bool kDecommittedPagesAreAlwaysZeroed = ++#if defined(OS_APPLE) ++ false; ++#else ++ true; ++#endif ++ ++} // namespace base ++ ++#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h +++++ src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h ++@@ -47,7 +47,7 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { ++ // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice ++ // here. ++ return 16; // 64kB ++-#elif defined(_MIPS_ARCH_LOONGSON) +++#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) ++ return 14; // 16kB ++ #else ++ return 12; // 4kB +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h +@@ -47,7 +47,7 @@ static_assert(sizeof(void*) != 8, ""); + // other constant values, we pack _all_ `PartitionRoot::Alloc` sizes perfectly + // up against the end of a system page. + +-#if defined(_MIPS_ARCH_LOONGSON) ++#if defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int + PartitionPageShift() { + return 16; // 64 KiB +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h +++++ src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h ++@@ -47,7 +47,7 @@ static_assert(sizeof(void*) != 8, ""); ++ // other constant values, we pack _all_ `PartitionRoot::Alloc` sizes perfectly ++ // up against the end of a system page. ++ ++-#if defined(_MIPS_ARCH_LOONGSON) +++#if defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) ++ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int ++ PartitionPageShift() { ++ return 16; // 64 KiB +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h +@@ -29,6 +29,8 @@ + // Don't bother doing using .word here since r2 is the lowest supported mips64 + // that Chromium supports. + #define YIELD_PROCESSOR __asm__ __volatile__("pause") ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++#define YIELD_PROCESSOR __asm__ __volatile__("nop") + #elif defined(ARCH_CPU_PPC64_FAMILY) + #define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31") + #elif defined(ARCH_CPU_S390_FAMILY) +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h +++++ src/3rdparty/chromium/base/allocator/partition_allocator/yield_processor.h ++@@ -29,6 +29,8 @@ ++ // Don't bother doing using .word here since r2 is the lowest supported mips64 ++ // that Chromium supports. ++ #define YIELD_PROCESSOR __asm__ __volatile__("pause") +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) +++#define YIELD_PROCESSOR __asm__ __volatile__("nop") ++ #elif defined(ARCH_CPU_PPC64_FAMILY) ++ #define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31") ++ #elif defined(ARCH_CPU_S390_FAMILY) +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/base/process/launch_posix.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/process/launch_posix.cc +@@ -704,7 +704,7 @@ NOINLINE pid_t CloneAndLongjmpInChild(un + alignas(16) char stack_buf[PTHREAD_STACK_MIN]; + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \ +- defined(ARCH_CPU_PPC64_FAMILY) ++ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) + // The stack grows downward. + void* stack = stack_buf + sizeof(stack_buf); + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/process/launch_posix.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/base/process/launch_posix.cc +++++ src/3rdparty/chromium/base/process/launch_posix.cc ++@@ -704,7 +704,7 @@ NOINLINE pid_t CloneAndLongjmpInChild(unsigned long flags, ++ alignas(16) char stack_buf[PTHREAD_STACK_MIN]; ++ #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \ ++- defined(ARCH_CPU_PPC64_FAMILY) +++ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // The stack grows downward. ++ void* stack = stack_buf + sizeof(stack_buf); ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h +@@ -110,7 +110,8 @@ int main(int argc, char** argv) { + defined(__riscv) || defined(__e2k__) || \ + defined(__or1k__) || defined(__arc__) || \ + defined(__microblaze__) || defined(__XTENSA__) || \ +- defined(__EMSCRIPTEN__) || defined(__wasm32__) ++ defined(__EMSCRIPTEN__) || defined(__wasm32__) || \ ++ defined(__loongarch__) + #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 + #elif defined(__mc68000__) || \ + defined(__pnacl__) || defined(__native_client__) +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h +++++ src/3rdparty/chromium/base/third_party/double_conversion/double-conversion/utils.h ++@@ -110,7 +110,8 @@ int main(int argc, char** argv) { ++ defined(__riscv) || defined(__e2k__) || \ ++ defined(__or1k__) || defined(__arc__) || \ ++ defined(__microblaze__) || defined(__XTENSA__) || \ ++- defined(__EMSCRIPTEN__) || defined(__wasm32__) +++ defined(__EMSCRIPTEN__) || defined(__wasm32__) || \ +++ defined(__loongarch__) ++ #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 ++ #elif defined(__mc68000__) || \ ++ defined(__pnacl__) || defined(__native_client__) +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/build/build_config.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/build/build_config.h +@@ -22,13 +22,14 @@ + // Processor: + // ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 / + // ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 / +-// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 ++// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_LOONGARCH64 + // Processor family: + // ARCH_CPU_ARM_FAMILY: ARMEL or ARM64 + // ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS + // ARCH_CPU_PPC64_FAMILY: PPC64 + // ARCH_CPU_S390_FAMILY: S390 or S390X + // ARCH_CPU_X86_FAMILY: X86 or X86_64 ++// ARCH_CPU_LOONGARCH_FAMILY: LOONGARCH64 + // Processor features: + // ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS + // ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN +@@ -193,6 +194,15 @@ + #define ARCH_CPU_32_BITS 1 + #define ARCH_CPU_BIG_ENDIAN 1 + #endif ++#elif defined(__loongarch__) ++#if defined(__loongarch_lp64) ++#define ARCH_CPU_LOONGARCH_FAMILY 1 ++#define ARCH_CPU_LOONGARCH64 1 ++#define ARCH_CPU_64_BITS 1 ++#define ARCH_CPU_LITTLE_ENDIAN 1 ++#else ++#error Only lp64 been supported on loongarch architecture! ++#endif + #else + #error Please add support for your architecture in build/build_config.h + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/build/build_config.h.rej +@@ -0,0 +1,34 @@ ++--- src/3rdparty/chromium/build/build_config.h +++++ src/3rdparty/chromium/build/build_config.h ++@@ -22,13 +22,14 @@ ++ // Processor: ++ // ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 / ++ // ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 / ++-// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 +++// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_LOONGARCH64 ++ // Processor family: ++ // ARCH_CPU_ARM_FAMILY: ARMEL or ARM64 ++ // ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS ++ // ARCH_CPU_PPC64_FAMILY: PPC64 ++ // ARCH_CPU_S390_FAMILY: S390 or S390X ++ // ARCH_CPU_X86_FAMILY: X86 or X86_64 +++// ARCH_CPU_LOONGARCH_FAMILY: LOONGARCH64 ++ // Processor features: ++ // ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS ++ // ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN ++@@ -193,6 +194,15 @@ ++ #define ARCH_CPU_32_BITS 1 ++ #define ARCH_CPU_BIG_ENDIAN 1 ++ #endif +++#elif defined(__loongarch__) +++#if defined(__loongarch_lp64) +++#define ARCH_CPU_LOONGARCH_FAMILY 1 +++#define ARCH_CPU_LOONGARCH64 1 +++#define ARCH_CPU_64_BITS 1 +++#define ARCH_CPU_LITTLE_ENDIAN 1 +++#else +++#error Only lp64 been supported on loongarch architecture! +++#endif ++ #else ++ #error Please add support for your architecture in build/build_config.h ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn +@@ -298,3 +298,99 @@ gcc_toolchain("mips64") { + is_clang = false + } + } ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn.orig +@@ -0,0 +1,372 @@ ++# Copyright 2013 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++import("//build/config/sysroot.gni") ++import("//build/toolchain/gcc_toolchain.gni") ++ ++clang_toolchain("clang_ppc64") { ++ enable_linker_map = true ++ toolchain_args = { ++ current_cpu = "ppc64" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_arm") { ++ toolprefix = "arm-linux-gnueabihf-" ++ toolchain_args = { ++ current_cpu = "arm" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_arm64") { ++ toolprefix = "aarch64-linux-gnu-" ++ toolchain_args = { ++ current_cpu = "arm64" ++ current_os = "linux" ++ } ++} ++ ++gcc_toolchain("arm64") { ++ toolprefix = "aarch64-linux-gnu-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = "${toolprefix}g++" ++ ++ ar = "${toolprefix}ar" ++ ld = cxx ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ++ toolchain_args = { ++ current_cpu = "arm64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++gcc_toolchain("arm") { ++ toolprefix = "arm-linux-gnueabihf-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = "${toolprefix}g++" ++ ++ ar = "${toolprefix}ar" ++ ld = cxx ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ++ toolchain_args = { ++ current_cpu = "arm" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_x86") { ++ # Output linker map files for binary size analysis. ++ enable_linker_map = true ++ ++ toolchain_args = { ++ current_cpu = "x86" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x86_v8_arm") { ++ toolchain_args = { ++ current_cpu = "x86" ++ v8_current_cpu = "arm" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x86_v8_mipsel") { ++ toolchain_args = { ++ current_cpu = "x86" ++ v8_current_cpu = "mipsel" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x86_v8_mips") { ++ toolchain_args = { ++ current_cpu = "x86" ++ v8_current_cpu = "mips" ++ current_os = "linux" ++ } ++} ++ ++gcc_toolchain("x86") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ # Output linker map files for binary size analysis. ++ enable_linker_map = true ++ ++ toolchain_args = { ++ current_cpu = "x86" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_x64") { ++ # Output linker map files for binary size analysis. ++ enable_linker_map = true ++ ++ toolchain_args = { ++ current_cpu = "x64" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x64_v8_arm64") { ++ toolchain_args = { ++ current_cpu = "x64" ++ v8_current_cpu = "arm64" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x64_v8_mips64el") { ++ toolchain_args = { ++ current_cpu = "x64" ++ v8_current_cpu = "mips64el" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_x64_v8_mips64") { ++ toolchain_args = { ++ current_cpu = "x64" ++ v8_current_cpu = "mips64" ++ current_os = "linux" ++ } ++} ++ ++gcc_toolchain("x64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ # Output linker map files for binary size analysis. ++ enable_linker_map = true ++ ++ toolchain_args = { ++ current_cpu = "x64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_mipsel") { ++ toolchain_args = { ++ current_cpu = "mipsel" ++ current_os = "linux" ++ } ++} ++ ++clang_toolchain("clang_mips64el") { ++ toolchain_args = { ++ current_cpu = "mips64el" ++ current_os = "linux" ++ } ++} ++ ++gcc_toolchain("mipsel") { ++ toolprefix = "mipsel-linux-gnu-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = " ${toolprefix}g++" ++ ar = "${toolprefix}ar" ++ ld = cxx ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ++ toolchain_args = { ++ cc_wrapper = "" ++ current_cpu = "mipsel" ++ current_os = "linux" ++ is_clang = false ++ use_goma = false ++ } ++} ++ ++gcc_toolchain("mips64el") { ++ toolprefix = "mips64el-linux-gnuabi64-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = "${toolprefix}g++" ++ ar = "${toolprefix}ar" ++ ld = cxx ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ++ toolchain_args = { ++ cc_wrapper = "" ++ current_cpu = "mips64el" ++ current_os = "linux" ++ is_clang = false ++ use_goma = false ++ } ++} ++ ++clang_toolchain("clang_s390x") { ++ toolchain_args = { ++ current_cpu = "s390x" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("s390x") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "s390x" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++gcc_toolchain("ppc64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "ppc64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++gcc_toolchain("mips") { ++ toolprefix = "mips-linux-gnu-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = "${toolprefix}g++" ++ ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ar = "${toolprefix}ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "mips" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++gcc_toolchain("mips64") { ++ toolprefix = "mips64-linux-gnuabi64-" ++ ++ cc = "${toolprefix}gcc" ++ cxx = "${toolprefix}g++" ++ ++ readelf = "${toolprefix}readelf" ++ nm = "${toolprefix}nm" ++ ar = "${toolprefix}ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "mips64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ ++clang_toolchain("clang_loongarch64") { ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = true ++ } ++} ++ ++gcc_toolchain("loongarch64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "loongarch64" ++ current_os = "linux" ++ is_clang = false ++ } ++} +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/features.gni ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/features.gni +@@ -11,7 +11,8 @@ import("//build/config/nacl/config.gni") + use_seccomp_bpf = (is_linux || is_chromeos || is_android) && + (current_cpu == "x86" || current_cpu == "x64" || + current_cpu == "arm" || current_cpu == "arm64" || +- current_cpu == "mipsel" || current_cpu == "mips64el") ++ current_cpu == "mipsel" || current_cpu == "mips64el" || ++ current_cpu == "loongarch64") + + use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/features.gni.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/sandbox/features.gni +++++ src/3rdparty/chromium/sandbox/features.gni ++@@ -11,7 +11,8 @@ import("//build/config/nacl/config.gni") ++ use_seccomp_bpf = (is_linux || is_chromeos || is_android) && ++ (current_cpu == "x86" || current_cpu == "x64" || ++ current_cpu == "arm" || current_cpu == "arm64" || ++- current_cpu == "mipsel" || current_cpu == "mips64el") +++ current_cpu == "mipsel" || current_cpu == "mips64el" || +++ current_cpu == "loongarch64") ++ ++ use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h +@@ -49,6 +49,34 @@ + #define MAX_PUBLIC_SYSCALL __NR_syscalls + #define MAX_SYSCALL MAX_PUBLIC_SYSCALL + ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ + #else + #error "Unsupported architecture" + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h.orig +@@ -0,0 +1,84 @@ ++// Copyright 2015 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_ ++#define SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_ ++ ++#include "build/build_config.h" ++ ++#if defined(__x86_64__) ++ ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL 1024u ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__i386__) ++ ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL 1024u ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__)) ++ ++// ARM EABI includes "ARM private" system calls starting at |__ARM_NR_BASE|, ++// and a "ghost syscall private to the kernel", cmpxchg, ++// at |__ARM_NR_BASE+0x00fff0|. ++// See in the Linux kernel. ++ ++// __NR_SYSCALL_BASE is 0 in thumb and ARM EABI. ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + 1024u) ++// __ARM_NR_BASE is __NR_SYSCALL_BASE + 0xf0000u ++#define MIN_PRIVATE_SYSCALL 0xf0000u ++#define MAX_PRIVATE_SYSCALL (MIN_PRIVATE_SYSCALL + 16u) ++#define MIN_GHOST_SYSCALL (MIN_PRIVATE_SYSCALL + 0xfff0u) ++#define MAX_SYSCALL (MIN_GHOST_SYSCALL + 4u) ++ ++#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS) ++ ++#include // for __NR_O32_Linux and __NR_Linux_syscalls ++#define MIN_SYSCALL __NR_O32_Linux ++#define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_Linux_syscalls) ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS) ++ ++#include // for __NR_64_Linux and __NR_64_Linux_syscalls ++#define MIN_SYSCALL __NR_64_Linux ++#define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_64_Linux_syscalls) ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__aarch64__) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#elif defined(__loongarch64) ++ ++#include ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL __NR_syscalls ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ ++#else ++#error "Unsupported architecture" ++#endif ++ ++#endif // SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h +@@ -346,6 +346,52 @@ struct regs_struct { + #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] + #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] + #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] ++ ++#elif defined(__loongarch64) ++struct regs_struct // TODO:MT ++{ ++ uint64_t regs[32]; ++ uint64_t orig_a0; ++ uint64_t csr_era; ++ uint64_t csr_badv; ++ uint64_t reserved[10]; ++}; ++ ++#define SECCOMP_ARCH AUDIT_ARCH_LOONGARCH64 ++ ++#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) ++ ++#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 4) ++#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 11) ++#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__pc ++#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 4) ++#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 5) ++#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 6) ++#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 7) ++#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 8) ++#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 9) ++ ++#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) ++#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) ++#define SECCOMP_IP_MSB_IDX \ ++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) ++#define SECCOMP_IP_LSB_IDX \ ++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) ++#define SECCOMP_ARG_MSB_IDX(nr) \ ++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) ++#define SECCOMP_ARG_LSB_IDX(nr) \ ++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) ++ ++#define SECCOMP_PT_RESULT(_regs) (_regs).regs[4] ++#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[11] ++#define SECCOMP_PT_IP(_regs) (_regs).csr_era ++#define SECCOMP_PT_PARM1(_regs) (_regs).regs[4] ++#define SECCOMP_PT_PARM2(_regs) (_regs).regs[5] ++#define SECCOMP_PT_PARM3(_regs) (_regs).regs[6] ++#define SECCOMP_PT_PARM4(_regs) (_regs).regs[7] ++#define SECCOMP_PT_PARM5(_regs) (_regs).regs[8] ++#define SECCOMP_PT_PARM6(_regs) (_regs).regs[9] ++ + #else + #error Unsupported target platform + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h.rej +@@ -0,0 +1,55 @@ ++--- src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h +++++ src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h ++@@ -346,6 +346,52 @@ struct regs_struct { ++ #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] ++ #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] ++ #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] +++ +++#elif defined(__loongarch64) +++struct regs_struct // TODO:MT +++{ +++ uint64_t regs[32]; +++ uint64_t orig_a0; +++ uint64_t csr_era; +++ uint64_t csr_badv; +++ uint64_t reserved[10]; +++}; +++ +++#define SECCOMP_ARCH AUDIT_ARCH_LOONGARCH64 +++ +++#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) +++ +++#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 4) +++#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 11) +++#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__pc +++#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 4) +++#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 5) +++#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 6) +++#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 7) +++#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 8) +++#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 9) +++ +++#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) +++#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) +++#define SECCOMP_IP_MSB_IDX \ +++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) +++#define SECCOMP_IP_LSB_IDX \ +++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) +++#define SECCOMP_ARG_MSB_IDX(nr) \ +++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) +++#define SECCOMP_ARG_LSB_IDX(nr) \ +++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) +++ +++#define SECCOMP_PT_RESULT(_regs) (_regs).regs[4] +++#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[11] +++#define SECCOMP_PT_IP(_regs) (_regs).csr_era +++#define SECCOMP_PT_PARM1(_regs) (_regs).regs[4] +++#define SECCOMP_PT_PARM2(_regs) (_regs).regs[5] +++#define SECCOMP_PT_PARM3(_regs) (_regs).regs[6] +++#define SECCOMP_PT_PARM4(_regs) (_regs).regs[7] +++#define SECCOMP_PT_PARM5(_regs) (_regs).regs[8] +++#define SECCOMP_PT_PARM6(_regs) (_regs).regs[9] +++ ++ #else ++ #error Unsupported target platform ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +@@ -181,7 +181,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de + return RestrictFcntlCommands(); + #endif + +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + // fork() is never used as a system call (clone() is used instead), but we + // have seen it in fallback code on Android. + if (sysno == __NR_fork) { +@@ -231,7 +231,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de + } + + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + if (sysno == __NR_mmap) + return RestrictMmapFlags(); + #endif +@@ -249,7 +249,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de + return RestrictPrctl(); + + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + if (sysno == __NR_socketpair) { + // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. + static_assert(AF_UNIX == PF_UNIX, +@@ -269,12 +269,14 @@ ResultExpr EvaluateSyscallImpl(int fs_de + return RestrictKillTarget(current_pid, sysno); + } + ++#if !defined(__loongarch64) + // The fstatat syscalls are file system syscalls, which will be denied below + // with fs_denied_errno. However some allowed fstat syscalls are rewritten by + // libc implementations to fstatat syscalls, and we need to rewrite them back. + if (sysno == __NR_fstatat_default) { + return RewriteFstatatSIGSYS(fs_denied_errno); + } ++#endif + + // The statx syscall is a filesystem syscall, which will be denied below with + // fs_denied_errno. However, on some platforms, glibc will default to statx +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc.orig +@@ -0,0 +1,361 @@ ++// Copyright (c) 2013 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "base/check_op.h" ++#include "base/clang_profiling_buildflags.h" ++#include "build/build_config.h" ++#include "sandbox/linux/bpf_dsl/bpf_dsl.h" ++#include "sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.h" ++#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" ++#include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" ++#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" ++#include "sandbox/linux/services/syscall_wrappers.h" ++#include "sandbox/linux/system_headers/linux_stat.h" ++#include "sandbox/linux/system_headers/linux_syscalls.h" ++ ++#if !defined(SO_PEEK_OFF) ++#define SO_PEEK_OFF 42 ++#endif ++ ++// Changing this implementation will have an effect on *all* policies. ++// Currently this means: Renderer/Worker, GPU, Flash and NaCl. ++ ++using sandbox::bpf_dsl::Allow; ++using sandbox::bpf_dsl::Arg; ++using sandbox::bpf_dsl::Error; ++using sandbox::bpf_dsl::If; ++using sandbox::bpf_dsl::ResultExpr; ++ ++namespace sandbox { ++ ++namespace { ++ ++bool IsBaselinePolicyAllowed(int sysno) { ++ return SyscallSets::IsAllowedAddressSpaceAccess(sysno) || ++ SyscallSets::IsAllowedBasicScheduler(sysno) || ++ SyscallSets::IsAllowedEpoll(sysno) || ++ SyscallSets::IsAllowedFileSystemAccessViaFd(sysno) || ++ SyscallSets::IsAllowedFutex(sysno) || ++ SyscallSets::IsAllowedGeneralIo(sysno) || ++ SyscallSets::IsAllowedGetOrModifySocket(sysno) || ++ SyscallSets::IsAllowedGettime(sysno) || ++ SyscallSets::IsAllowedProcessStartOrDeath(sysno) || ++ SyscallSets::IsAllowedSignalHandling(sysno) || ++ SyscallSets::IsGetSimpleId(sysno) || ++ SyscallSets::IsKernelInternalApi(sysno) || ++#if defined(__arm__) ++ SyscallSets::IsArmPrivate(sysno) || ++#endif ++#if defined(__mips__) ++ SyscallSets::IsMipsPrivate(sysno) || ++#endif ++ SyscallSets::IsAllowedOperationOnFd(sysno); ++} ++ ++// System calls that will trigger the crashing SIGSYS handler. ++bool IsBaselinePolicyWatched(int sysno) { ++ return SyscallSets::IsAdminOperation(sysno) || ++ SyscallSets::IsAdvancedScheduler(sysno) || ++ SyscallSets::IsAdvancedTimer(sysno) || ++ SyscallSets::IsAsyncIo(sysno) || ++ SyscallSets::IsDebug(sysno) || ++ SyscallSets::IsEventFd(sysno) || ++ SyscallSets::IsExtendedAttributes(sysno) || ++ SyscallSets::IsFaNotify(sysno) || ++ SyscallSets::IsFsControl(sysno) || ++ SyscallSets::IsGlobalFSViewChange(sysno) || ++ SyscallSets::IsGlobalProcessEnvironment(sysno) || ++ SyscallSets::IsGlobalSystemStatus(sysno) || ++ SyscallSets::IsInotify(sysno) || ++ SyscallSets::IsKernelModule(sysno) || ++ SyscallSets::IsKeyManagement(sysno) || ++ SyscallSets::IsKill(sysno) || ++ SyscallSets::IsMessageQueue(sysno) || ++ SyscallSets::IsMisc(sysno) || ++#if defined(__x86_64__) ++ SyscallSets::IsNetworkSocketInformation(sysno) || ++#endif ++ SyscallSets::IsNuma(sysno) || ++ SyscallSets::IsPrctl(sysno) || ++ SyscallSets::IsProcessGroupOrSession(sysno) || ++#if defined(__i386__) || \ ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ SyscallSets::IsSocketCall(sysno) || ++#endif ++#if defined(__arm__) ++ SyscallSets::IsArmPciConfig(sysno) || ++#endif ++#if defined(__mips__) ++ SyscallSets::IsMipsMisc(sysno) || ++#endif ++ SyscallSets::IsTimer(sysno); ++} ++ ++// |fs_denied_errno| is the errno return for denied filesystem access. ++ResultExpr EvaluateSyscallImpl(int fs_denied_errno, ++ pid_t current_pid, ++ int sysno) { ++#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ ++ defined(MEMORY_SANITIZER) ++ // TCGETS is required by the sanitizers on failure. ++ if (sysno == __NR_ioctl) { ++ return RestrictIoctl(); ++ } ++ ++ if (sysno == __NR_sched_getaffinity) { ++ return Allow(); ++ } ++ ++ // Used when RSS limiting is enabled in sanitizers. ++ if (sysno == __NR_getrusage) { ++ return RestrictGetrusage(); ++ } ++ ++ if (sysno == __NR_sigaltstack) { ++ // Required for better stack overflow detection in ASan. Disallowed in ++ // non-ASan builds. ++ return Allow(); ++ } ++#endif // defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || ++ // defined(MEMORY_SANITIZER) ++ ++#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX) ++ if (SyscallSets::IsPrctl(sysno)) { ++ return Allow(); ++ } ++ ++ if (sysno == __NR_ftruncate) { ++ return Allow(); ++ } ++#endif ++ ++ if (IsBaselinePolicyAllowed(sysno)) { ++ return Allow(); ++ } ++ ++#if defined(OS_ANDROID) ++ // Needed for thread creation. ++ if (sysno == __NR_sigaltstack) ++ return Allow(); ++#endif ++ ++#if defined(__NR_rseq) && !defined(OS_ANDROID) ++ // See https://crbug.com/1104160. Rseq can only be disabled right before an ++ // execve, because glibc registers it with the kernel and so far it's unclear ++ // whether shared libraries (which, during initialization, may observe that ++ // rseq is already registered) should have to deal with deregistration. ++ if (sysno == __NR_rseq) ++ return Allow(); ++#endif ++ ++ if (SyscallSets::IsClockApi(sysno)) { ++ return RestrictClockID(); ++ } ++ ++ if (sysno == __NR_clone) { ++ return RestrictCloneToThreadsAndEPERMFork(); ++ } ++ ++ // clone3 takes a pointer argument which we cannot examine, so return ENOSYS ++ // to force the libc to use clone. See https://crbug.com/1213452. ++ if (sysno == __NR_clone3) { ++ return Error(ENOSYS); ++ } ++ ++ if (sysno == __NR_fcntl) ++ return RestrictFcntlCommands(); ++ ++#if defined(__i386__) || defined(__arm__) || \ ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ if (sysno == __NR_fcntl64) ++ return RestrictFcntlCommands(); ++#endif ++ ++#if !defined(__aarch64__) ++ // fork() is never used as a system call (clone() is used instead), but we ++ // have seen it in fallback code on Android. ++ if (sysno == __NR_fork) { ++ return Error(EPERM); ++ } ++#endif ++ ++#if defined(__NR_vfork) ++ // vfork() is almost never used as a system call, but some libc versions (e.g. ++ // older versions of bionic) might use it in a posix_spawn() implementation, ++ // which is used by system(); ++ if (sysno == __NR_vfork) { ++ return Error(EPERM); ++ } ++#endif ++ ++ if (sysno == __NR_futex) ++ return RestrictFutex(); ++ ++ if (sysno == __NR_set_robust_list) ++ return Error(EPERM); ++ ++ if (sysno == __NR_getpriority || sysno ==__NR_setpriority) ++ return RestrictGetSetpriority(current_pid); ++ ++ if (sysno == __NR_getrandom) { ++ return RestrictGetRandom(); ++ } ++ ++ if (sysno == __NR_madvise) { ++ // Only allow MADV_DONTNEED, MADV_RANDOM, MADV_NORMAL and MADV_FREE. ++ const Arg advice(2); ++ return If(AnyOf(advice == MADV_DONTNEED, ++ advice == MADV_RANDOM, ++ advice == MADV_NORMAL ++#if defined(MADV_FREE) ++ // MADV_FREE was introduced in Linux 4.5 and started being ++ // defined in glibc 2.24. ++ , advice == MADV_FREE ++#endif ++ ), Allow()).Else(Error(EPERM)); ++ } ++ ++#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++ defined(__aarch64__) ++ if (sysno == __NR_mmap) ++ return RestrictMmapFlags(); ++#endif ++ ++#if defined(__i386__) || defined(__arm__) || \ ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ if (sysno == __NR_mmap2) ++ return RestrictMmapFlags(); ++#endif ++ ++ if (sysno == __NR_mprotect) ++ return RestrictMprotectFlags(); ++ ++ if (sysno == __NR_prctl) ++ return RestrictPrctl(); ++ ++#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++ defined(__aarch64__) ++ if (sysno == __NR_socketpair) { ++ // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. ++ static_assert(AF_UNIX == PF_UNIX, ++ "af_unix and pf_unix should not be different"); ++ const Arg domain(0); ++ return If(domain == AF_UNIX, Allow()).Else(CrashSIGSYS()); ++ } ++#endif ++ ++ // On Android, for https://crbug.com/701137. ++ // On Desktop, for https://crbug.com/741984. ++ if (sysno == __NR_mincore) { ++ return Allow(); ++ } ++ ++ if (SyscallSets::IsKill(sysno)) { ++ return RestrictKillTarget(current_pid, sysno); ++ } ++ ++ // The fstatat syscalls are file system syscalls, which will be denied below ++ // with fs_denied_errno. However some allowed fstat syscalls are rewritten by ++ // libc implementations to fstatat syscalls, and we need to rewrite them back. ++ if (sysno == __NR_fstatat_default) { ++ return RewriteFstatatSIGSYS(fs_denied_errno); ++ } ++ ++ // The statx syscall is a filesystem syscall, which will be denied below with ++ // fs_denied_errno. However, on some platforms, glibc will default to statx ++ // for normal stat-family calls. Unfortunately there's no way to rewrite statx ++ // to something safe using a signal handler. Returning ENOSYS will cause glibc ++ // to fallback to old stat paths. ++ if (sysno == __NR_statx) { ++ const Arg mask(3); ++ return If(mask == STATX_BASIC_STATS, Error(ENOSYS)) ++ .Else(Error(fs_denied_errno)); ++ } ++ ++ if (SyscallSets::IsFileSystem(sysno) || ++ SyscallSets::IsCurrentDirectory(sysno)) { ++ return Error(fs_denied_errno); ++ } ++ ++ if (SyscallSets::IsSeccomp(sysno)) ++ return Error(EPERM); ++ ++ if (SyscallSets::IsAnySystemV(sysno)) { ++ return Error(EPERM); ++ } ++ ++ if (SyscallSets::IsUmask(sysno) || ++ SyscallSets::IsDeniedFileSystemAccessViaFd(sysno) || ++ SyscallSets::IsDeniedGetOrModifySocket(sysno) || ++ SyscallSets::IsProcessPrivilegeChange(sysno)) { ++ return Error(EPERM); ++ } ++ ++#if defined(__i386__) || \ ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ if (SyscallSets::IsSocketCall(sysno)) ++ return RestrictSocketcallCommand(); ++#endif ++ ++#if !defined(__i386__) ++ if (sysno == __NR_getsockopt || sysno ==__NR_setsockopt) { ++ // Used by Mojo EDK to catch a message pipe being sent over itself. ++ const Arg level(1); ++ const Arg optname(2); ++ return If(AllOf(level == SOL_SOCKET, optname == SO_PEEK_OFF), Allow()) ++ .Else(CrashSIGSYS()); ++ } ++#endif ++ ++ if (IsBaselinePolicyWatched(sysno)) { ++ // Previously unseen syscalls. TODO(jln): some of these should ++ // be denied gracefully right away. ++ return CrashSIGSYS(); ++ } ++ ++ // In any other case crash the program with our SIGSYS handler. ++ return CrashSIGSYS(); ++} ++ ++} // namespace. ++ ++BaselinePolicy::BaselinePolicy() : BaselinePolicy(EPERM) { ++ // Allocate crash keys set by Seccomp signal handlers. ++ AllocateCrashKeys(); ++} ++ ++BaselinePolicy::BaselinePolicy(int fs_denied_errno) ++ : fs_denied_errno_(fs_denied_errno), policy_pid_(sys_getpid()) { ++} ++ ++BaselinePolicy::~BaselinePolicy() { ++ // Make sure that this policy is created, used and destroyed by a single ++ // process. ++ DCHECK_EQ(sys_getpid(), policy_pid_); ++} ++ ++ResultExpr BaselinePolicy::EvaluateSyscall(int sysno) const { ++ // Sanity check that we're only called with valid syscall numbers. ++ DCHECK(SandboxBPF::IsValidSyscallNumber(sysno)); ++ // Make sure that this policy is used in the creating process. ++ if (1 == sysno) { ++ DCHECK_EQ(sys_getpid(), policy_pid_); ++ } ++ return EvaluateSyscallImpl(fs_denied_errno_, policy_pid_, sysno); ++} ++ ++ResultExpr BaselinePolicy::InvalidSyscall() const { ++ return CrashSIGSYS(); ++} ++ ++} // namespace sandbox. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc.rej +@@ -0,0 +1,44 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc ++@@ -181,7 +181,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, ++ return RestrictFcntlCommands(); ++ #endif ++ ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ // fork() is never used as a system call (clone() is used instead), but we ++ // have seen it in fallback code on Android. ++ if (sysno == __NR_fork) { ++@@ -231,7 +231,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, ++ } ++ ++ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ if (sysno == __NR_mmap) ++ return RestrictMmapFlags(); ++ #endif ++@@ -249,7 +249,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, ++ return RestrictPrctl(); ++ ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ if (sysno == __NR_socketpair) { ++ // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. ++ static_assert(AF_UNIX == PF_UNIX, ++@@ -269,12 +269,14 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, ++ return RestrictKillTarget(current_pid, sysno); ++ } ++ +++#if !defined(__loongarch64) ++ // The fstatat syscalls are file system syscalls, which will be denied below ++ // with fs_denied_errno. However some allowed fstat syscalls are rewritten by ++ // libc implementations to fstatat syscalls, and we need to rewrite them back. ++ if (sysno == __NR_fstatat_default) { ++ return RewriteFstatatSIGSYS(fs_denied_errno); ++ } +++#endif ++ ++ // The statx syscall is a filesystem syscall, which will be denied below with ++ // fs_denied_errno. However, on some platforms, glibc will default to statx +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc +@@ -359,6 +359,7 @@ intptr_t SIGSYSSchedHandler(const struct + + intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, + void* fs_denied_errno) { ++#if !defined(__loongarch64) + if (args.nr == __NR_fstatat_default) { + if (*reinterpret_cast(args.args[1]) == '\0' && + args.args[3] == static_cast(AT_EMPTY_PATH)) { +@@ -367,6 +368,7 @@ intptr_t SIGSYSFstatatHandler(const stru + } + return -reinterpret_cast(fs_denied_errno); + } ++#endif + + CrashSIGSYS_Handler(args, fs_denied_errno); + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc.rej +@@ -0,0 +1,18 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc ++@@ -359,6 +359,7 @@ intptr_t SIGSYSSchedHandler(const struct arch_seccomp_data& args, ++ ++ intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, ++ void* fs_denied_errno) { +++#if !defined(__loongarch64) ++ if (args.nr == __NR_fstatat_default) { ++ if (*reinterpret_cast(args.args[1]) == '\0' && ++ args.args[3] == static_cast(AT_EMPTY_PATH)) { ++@@ -367,6 +368,7 @@ intptr_t SIGSYSFstatatHandler(const struct arch_seccomp_data& args, ++ } ++ return -reinterpret_cast(fs_denied_errno); ++ } +++#endif ++ ++ CrashSIGSYS_Handler(args, fs_denied_errno); ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +@@ -37,7 +37,8 @@ + #include + #include + #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(__arm__) && \ +- !defined(__aarch64__) && !defined(PTRACE_GET_THREAD_AREA) ++ !defined(__aarch64__) && !defined(__loongarch__) && \ ++ !defined(PTRACE_GET_THREAD_AREA) + // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance + // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. + // asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ++@@ -37,7 +37,8 @@ ++ #include ++ #include ++ #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(__arm__) && \ ++- !defined(__aarch64__) && !defined(PTRACE_GET_THREAD_AREA) +++ !defined(__aarch64__) && !defined(__loongarch__) && \ +++ !defined(PTRACE_GET_THREAD_AREA) ++ // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance ++ // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. ++ // asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +@@ -86,7 +86,7 @@ bool SyscallSets::IsUmask(int sysno) { + // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. + bool SyscallSets::IsFileSystem(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_access: // EPERM not a valid errno. + case __NR_chmod: + case __NR_chown: +@@ -174,11 +174,16 @@ bool SyscallSets::IsFileSystem(int sysno + + bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { + switch (sysno) { ++#if !defined(__loongarch64) + case __NR_fstat: ++#endif + #if defined(__i386__) || defined(__arm__) || \ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR_fstat64: + #endif ++#if defined(__loongarch64) ++ case __NR_statx: ++#endif + return true; + // TODO(jln): these should be denied gracefully as well (moved below). + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) +@@ -202,7 +207,7 @@ bool SyscallSets::IsAllowedFileSystemAcc + case __NR_oldfstat: + #endif + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_sync_file_range: // EPERM not a valid errno. + #elif defined(__arm__) + case __NR_arm_sync_file_range: // EPERM not a valid errno. +@@ -226,7 +231,7 @@ bool SyscallSets::IsDeniedFileSystemAcce + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR_ftruncate64: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_getdents: // EPERM not a valid errno. + #endif + case __NR_getdents64: // EPERM not a valid errno. +@@ -305,7 +310,7 @@ bool SyscallSets::IsProcessPrivilegeChan + bool SyscallSets::IsProcessGroupOrSession(int sysno) { + switch (sysno) { + case __NR_setpgid: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_getpgrp: + #endif + case __NR_setsid: +@@ -334,7 +339,7 @@ bool SyscallSets::IsAllowedSignalHandlin + case __NR_rt_sigsuspend: + case __NR_rt_tgsigqueueinfo: + case __NR_sigaltstack: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_signalfd: + #endif + case __NR_signalfd4: +@@ -358,12 +363,12 @@ bool SyscallSets::IsAllowedOperationOnFd + switch (sysno) { + case __NR_close: + case __NR_dup: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_dup2: + #endif + case __NR_dup3: + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_shutdown: + #endif + return true; +@@ -402,7 +407,7 @@ bool SyscallSets::IsAllowedProcessStartO + return true; + case __NR_clone: // Should be parameter-restricted. + case __NR_setns: // Privileged. +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_fork: + #endif + #if defined(__i386__) || defined(__x86_64__) +@@ -413,7 +418,7 @@ bool SyscallSets::IsAllowedProcessStartO + #endif + case __NR_set_tid_address: + case __NR_unshare: +-#if !defined(__mips__) && !defined(__aarch64__) ++#if !defined(__mips__) && !defined(__aarch64__) && !defined(__loongarch__) + case __NR_vfork: + #endif + default: +@@ -434,7 +439,7 @@ bool SyscallSets::IsAllowedFutex(int sys + + bool SyscallSets::IsAllowedEpoll(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_epoll_create: + case __NR_epoll_wait: + #endif +@@ -455,7 +460,7 @@ bool SyscallSets::IsAllowedEpoll(int sys + + bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_pipe: + #endif + case __NR_pipe2: +@@ -472,7 +477,7 @@ bool SyscallSets::IsAllowedGetOrModifySo + bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { + switch (sysno) { + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_accept: + case __NR_accept4: + case __NR_bind: +@@ -501,7 +506,8 @@ bool SyscallSets::IsSocketCall(int sysno + } + #endif + +-#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) ++#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++ defined(__loongarch__) + bool SyscallSets::IsNetworkSocketInformation(int sysno) { + switch (sysno) { + case __NR_getpeername: +@@ -526,7 +532,7 @@ bool SyscallSets::IsAllowedAddressSpaceA + case __NR_mincore: + case __NR_mlockall: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_mmap: + #endif + #if defined(__i386__) || defined(__arm__) || \ +@@ -559,7 +565,7 @@ bool SyscallSets::IsAllowedGeneralIo(int + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR__llseek: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_poll: + #endif + case __NR_ppoll: +@@ -572,7 +578,7 @@ bool SyscallSets::IsAllowedGeneralIo(int + case __NR_recv: + #endif + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_recvfrom: // Could specify source. + case __NR_recvmsg: // Could specify source. + #endif +@@ -587,7 +593,7 @@ bool SyscallSets::IsAllowedGeneralIo(int + case __NR_send: + #endif + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_sendmsg: // Could specify destination. + case __NR_sendto: // Could specify destination. + #endif +@@ -637,7 +643,7 @@ bool SyscallSets::IsSeccomp(int sysno) { + bool SyscallSets::IsAllowedBasicScheduler(int sysno) { + switch (sysno) { + case __NR_sched_yield: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_pause: + #endif + case __NR_nanosleep: +@@ -721,7 +727,7 @@ bool SyscallSets::IsNuma(int sysno) { + case __NR_getcpu: + case __NR_mbind: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_migrate_pages: + #endif + case __NR_move_pages: +@@ -750,7 +756,7 @@ bool SyscallSets::IsGlobalProcessEnviron + switch (sysno) { + case __NR_acct: // Privileged. + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) +@@ -785,7 +791,7 @@ bool SyscallSets::IsDebug(int sysno) { + + bool SyscallSets::IsGlobalSystemStatus(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR__sysctl: + case __NR_sysfs: + #endif +@@ -803,7 +809,7 @@ bool SyscallSets::IsGlobalSystemStatus(i + + bool SyscallSets::IsEventFd(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_eventfd: + #endif + case __NR_eventfd2: +@@ -839,7 +845,8 @@ bool SyscallSets::IsKeyManagement(int sy + } + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + bool SyscallSets::IsSystemVSemaphores(int sysno) { + switch (sysno) { + case __NR_semctl: +@@ -855,7 +862,8 @@ bool SyscallSets::IsSystemVSemaphores(in + + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + // These give a lot of ambient authority and bypass the setuid sandbox. + bool SyscallSets::IsSystemVSharedMemory(int sysno) { + switch (sysno) { +@@ -871,7 +879,8 @@ bool SyscallSets::IsSystemVSharedMemory( + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + bool SyscallSets::IsSystemVMessageQueue(int sysno) { + switch (sysno) { + case __NR_msgctl: +@@ -902,7 +911,8 @@ bool SyscallSets::IsSystemVIpc(int sysno + + bool SyscallSets::IsAnySystemV(int sysno) { + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || + IsSystemVSharedMemory(sysno); + #elif defined(__i386__) || \ +@@ -935,7 +945,7 @@ bool SyscallSets::IsAdvancedScheduler(in + bool SyscallSets::IsInotify(int sysno) { + switch (sysno) { + case __NR_inotify_add_watch: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_inotify_init: + #endif + case __NR_inotify_init1: +@@ -1066,7 +1076,7 @@ bool SyscallSets::IsMisc(int sysno) { + #if defined(__x86_64__) + case __NR_tuxcall: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_vserver: + #endif + return true; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc.rej +@@ -0,0 +1,272 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc ++@@ -86,7 +86,7 @@ bool SyscallSets::IsUmask(int sysno) { ++ // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. ++ bool SyscallSets::IsFileSystem(int sysno) { ++ switch (sysno) { ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_access: // EPERM not a valid errno. ++ case __NR_chmod: ++ case __NR_chown: ++@@ -174,10 +174,15 @@ bool SyscallSets::IsFileSystem(int sysno) { ++ ++ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { ++ switch (sysno) { +++#if !defined(__loongarch64) ++ case __NR_fstat: +++#endif ++ #if defined(__i386__) || defined(__arm__) || \ ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ case __NR_fstat64: +++#endif +++#if defined(__loongarch64) +++ case __NR_statx: ++ #endif ++ return true; ++ // TODO(jln): these should be denied gracefully as well (moved below). ++@@ -202,7 +207,7 @@ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { ++ case __NR_oldfstat: ++ #endif ++ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_sync_file_range: // EPERM not a valid errno. ++ #elif defined(__arm__) ++ case __NR_arm_sync_file_range: // EPERM not a valid errno. ++@@ -226,7 +231,7 @@ bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ case __NR_ftruncate64: ++ #endif ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_getdents: // EPERM not a valid errno. ++ #endif ++ case __NR_getdents64: // EPERM not a valid errno. ++@@ -305,7 +310,7 @@ bool SyscallSets::IsProcessPrivilegeChange(int sysno) { ++ bool SyscallSets::IsProcessGroupOrSession(int sysno) { ++ switch (sysno) { ++ case __NR_setpgid: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_getpgrp: ++ #endif ++ case __NR_setsid: ++@@ -334,7 +339,7 @@ bool SyscallSets::IsAllowedSignalHandling(int sysno) { ++ case __NR_rt_sigsuspend: ++ case __NR_rt_tgsigqueueinfo: ++ case __NR_sigaltstack: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_signalfd: ++ #endif ++ case __NR_signalfd4: ++@@ -358,12 +363,12 @@ bool SyscallSets::IsAllowedOperationOnFd(int sysno) { ++ switch (sysno) { ++ case __NR_close: ++ case __NR_dup: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_dup2: ++ #endif ++ case __NR_dup3: ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_shutdown: ++ #endif ++ return true; ++@@ -402,7 +407,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { ++ return true; ++ case __NR_clone: // Should be parameter-restricted. ++ case __NR_setns: // Privileged. ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_fork: ++ #endif ++ #if defined(__i386__) || defined(__x86_64__) ++@@ -413,7 +418,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) { ++ #endif ++ case __NR_set_tid_address: ++ case __NR_unshare: ++-#if !defined(__mips__) && !defined(__aarch64__) +++#if !defined(__mips__) && !defined(__aarch64__) && !defined(__loongarch__) ++ case __NR_vfork: ++ #endif ++ default: ++@@ -434,7 +439,7 @@ bool SyscallSets::IsAllowedFutex(int sysno) { ++ ++ bool SyscallSets::IsAllowedEpoll(int sysno) { ++ switch (sysno) { ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_epoll_create: ++ case __NR_epoll_wait: ++ #endif ++@@ -455,7 +460,7 @@ bool SyscallSets::IsAllowedEpoll(int sysno) { ++ ++ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { ++ switch (sysno) { ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_pipe: ++ #endif ++ case __NR_pipe2: ++@@ -472,7 +477,7 @@ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { ++ bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { ++ switch (sysno) { ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_accept: ++ case __NR_accept4: ++ case __NR_bind: ++@@ -501,7 +506,8 @@ bool SyscallSets::IsSocketCall(int sysno) { ++ } ++ #endif ++ ++-#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) +++#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +++ defined(__loongarch__) ++ bool SyscallSets::IsNetworkSocketInformation(int sysno) { ++ switch (sysno) { ++ case __NR_getpeername: ++@@ -526,7 +532,7 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { ++ case __NR_mincore: ++ case __NR_mlockall: ++ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_mmap: ++ #endif ++ #if defined(__i386__) || defined(__arm__) || \ ++@@ -559,7 +565,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ case __NR__llseek: ++ #endif ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_poll: ++ #endif ++ case __NR_ppoll: ++@@ -572,7 +578,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { ++ case __NR_recv: ++ #endif ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_recvfrom: // Could specify source. ++ case __NR_recvmsg: // Could specify source. ++ #endif ++@@ -587,7 +593,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) { ++ case __NR_send: ++ #endif ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_sendmsg: // Could specify destination. ++ case __NR_sendto: // Could specify destination. ++ #endif ++@@ -637,7 +643,7 @@ bool SyscallSets::IsSeccomp(int sysno) { ++ bool SyscallSets::IsAllowedBasicScheduler(int sysno) { ++ switch (sysno) { ++ case __NR_sched_yield: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_pause: ++ #endif ++ case __NR_nanosleep: ++@@ -721,7 +727,7 @@ bool SyscallSets::IsNuma(int sysno) { ++ case __NR_getcpu: ++ case __NR_mbind: ++ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_migrate_pages: ++ #endif ++ case __NR_move_pages: ++@@ -750,7 +756,7 @@ bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { ++ switch (sysno) { ++ case __NR_acct: // Privileged. ++ #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ case __NR_getrlimit: ++ #endif ++ #if defined(__i386__) || defined(__arm__) ++@@ -785,7 +791,7 @@ bool SyscallSets::IsDebug(int sysno) { ++ ++ bool SyscallSets::IsGlobalSystemStatus(int sysno) { ++ switch (sysno) { ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR__sysctl: ++ case __NR_sysfs: ++ #endif ++@@ -803,7 +809,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) { ++ ++ bool SyscallSets::IsEventFd(int sysno) { ++ switch (sysno) { ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_eventfd: ++ #endif ++ case __NR_eventfd2: ++@@ -839,7 +845,8 @@ bool SyscallSets::IsKeyManagement(int sysno) { ++ } ++ ++ #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ bool SyscallSets::IsSystemVSemaphores(int sysno) { ++ switch (sysno) { ++ case __NR_semctl: ++@@ -855,7 +862,8 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) { ++ ++ #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ ++ defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ // These give a lot of ambient authority and bypass the setuid sandbox. ++ bool SyscallSets::IsSystemVSharedMemory(int sysno) { ++ switch (sysno) { ++@@ -871,7 +879,8 @@ bool SyscallSets::IsSystemVSharedMemory(int sysno) { ++ #endif ++ ++ #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ bool SyscallSets::IsSystemVMessageQueue(int sysno) { ++ switch (sysno) { ++ case __NR_msgctl: ++@@ -902,7 +911,8 @@ bool SyscallSets::IsSystemVIpc(int sysno) { ++ ++ bool SyscallSets::IsAnySystemV(int sysno) { ++ #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || ++ IsSystemVSharedMemory(sysno); ++ #elif defined(__i386__) || \ ++@@ -935,7 +945,7 @@ bool SyscallSets::IsAdvancedScheduler(int sysno) { ++ bool SyscallSets::IsInotify(int sysno) { ++ switch (sysno) { ++ case __NR_inotify_add_watch: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_inotify_init: ++ #endif ++ case __NR_inotify_init1: ++@@ -1066,7 +1076,7 @@ bool SyscallSets::IsMisc(int sysno) { ++ #if defined(__x86_64__) ++ case __NR_tuxcall: ++ #endif ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_vserver: ++ #endif ++ return true; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h +@@ -49,7 +49,7 @@ class SANDBOX_EXPORT SyscallSets { + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch__) + static bool IsNetworkSocketInformation(int sysno); + #endif + +@@ -72,18 +72,21 @@ class SANDBOX_EXPORT SyscallSets { + static bool IsAsyncIo(int sysno); + static bool IsKeyManagement(int sysno); + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + static bool IsSystemVSemaphores(int sysno); + #endif + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + // These give a lot of ambient authority and bypass the setuid sandbox. + static bool IsSystemVSharedMemory(int sysno); + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__loongarch64) + static bool IsSystemVMessageQueue(int sysno); + #endif + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h.rej +@@ -0,0 +1,36 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h ++@@ -49,7 +49,7 @@ class SANDBOX_EXPORT SyscallSets { ++ #endif ++ ++ #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch__) ++ static bool IsNetworkSocketInformation(int sysno); ++ #endif ++ ++@@ -72,18 +72,21 @@ class SANDBOX_EXPORT SyscallSets { ++ static bool IsAsyncIo(int sysno); ++ static bool IsKeyManagement(int sysno); ++ #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ static bool IsSystemVSemaphores(int sysno); ++ #endif ++ #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ ++ defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ // These give a lot of ambient authority and bypass the setuid sandbox. ++ static bool IsSystemVSharedMemory(int sysno); ++ #endif ++ ++ #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ ++- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) +++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ +++ defined(__loongarch64) ++ static bool IsSystemVMessageQueue(int sysno); ++ #endif ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc +@@ -18,7 +18,7 @@ namespace sandbox { + namespace { + + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ +- defined(ARCH_CPU_MIPS_FAMILY) ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) + // Number that's not currently used by any Linux kernel ABIs. + const int kInvalidSyscallNumber = 0x351d3; + #else +@@ -312,6 +312,25 @@ asm(// We need to be able to tell the ke + "2:ret\n" + ".cfi_endproc\n" + ".size SyscallAsm, .-SyscallAsm\n" ++#elif defined(__loongarch64) ++ ".text\n" ++ ".global SyscallAsm\n" ++ ".type SyscallAsm, %function\n" ++ "SyscallAsm:\n" ++ "bge $a0, $zero, 1f\n" ++ "la.pcrel $a0, 2f\n" ++ "b 2f\n" ++ "1:ld.d $a5, $a6, 40\n" ++ "ld.d $a4, $a6, 32\n" ++ "ld.d $a3, $a6, 24\n" ++ "ld.d $a2, $a6, 16\n" ++ "ld.d $a1, $a6, 8\n" ++ "move $a7, $a0\n" ++ "ld.d $a0, $a6, 0\n" ++ // Enter the kernel ++ "syscall 0\n" ++ "2:jirl $zero, $ra, 0\n" ++ ".size SyscallAsm, .-SyscallAsm\n" + #endif + ); // asm + +@@ -429,6 +448,18 @@ intptr_t Syscall::Call(int nr, + ret = inout; + } + ++#elif defined(__loongarch64) ++ intptr_t ret; ++ { ++ register intptr_t inout __asm__("$r4") = nr; ++ register const intptr_t* data __asm__("$r10") = args; ++ asm volatile("bl SyscallAsm\n" ++ : "=r"(inout) ++ : "0"(inout), "r"(data) ++ : "memory", "$r5", "$r6", "$r7", "$r8", "$r9", "$r11", "$r1"); ++ ret = inout; ++ } ++ + #else + #error "Unimplemented architecture" + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc.rej +@@ -0,0 +1,56 @@ ++--- src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc +++++ src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc ++@@ -18,7 +18,7 @@ namespace sandbox { ++ namespace { ++ ++ #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ ++- defined(ARCH_CPU_MIPS_FAMILY) +++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // Number that's not currently used by any Linux kernel ABIs. ++ const int kInvalidSyscallNumber = 0x351d3; ++ #else ++@@ -312,6 +312,25 @@ asm(// We need to be able to tell the kernel exactly where we made a ++ "2:ret\n" ++ ".cfi_endproc\n" ++ ".size SyscallAsm, .-SyscallAsm\n" +++#elif defined(__loongarch64) +++ ".text\n" +++ ".global SyscallAsm\n" +++ ".type SyscallAsm, %function\n" +++ "SyscallAsm:\n" +++ "bge $a0, $zero, 1f\n" +++ "la.pcrel $a0, 2f\n" +++ "b 2f\n" +++ "1:ld.d $a5, $a6, 40\n" +++ "ld.d $a4, $a6, 32\n" +++ "ld.d $a3, $a6, 24\n" +++ "ld.d $a2, $a6, 16\n" +++ "ld.d $a1, $a6, 8\n" +++ "move $a7, $a0\n" +++ "ld.d $a0, $a6, 0\n" +++ // Enter the kernel +++ "syscall 0\n" +++ "2:jirl $zero, $ra, 0\n" +++ ".size SyscallAsm, .-SyscallAsm\n" ++ #endif ++ ); // asm ++ ++@@ -429,6 +448,18 @@ intptr_t Syscall::Call(int nr, ++ ret = inout; ++ } ++ +++#elif defined(__loongarch64) +++ intptr_t ret; +++ { +++ register intptr_t inout __asm__("$r4") = nr; +++ register const intptr_t* data __asm__("$r10") = args; +++ asm volatile("bl SyscallAsm\n" +++ : "=r"(inout) +++ : "0"(inout), "r"(data) +++ : "memory", "$r5", "$r6", "$r7", "$r8", "$r9", "$r11", "$r1"); +++ ret = inout; +++ } +++ ++ #else ++ #error "Unimplemented architecture" ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/services/credentials.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/services/credentials.cc +@@ -81,7 +81,7 @@ bool ChrootToSafeEmptyDir() { + pid_t pid = -1; + alignas(16) char stack_buf[PTHREAD_STACK_MIN]; + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ +- defined(ARCH_CPU_MIPS_FAMILY) ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) + // The stack grows downward. + void* stack = stack_buf + sizeof(stack_buf); + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/services/credentials.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/sandbox/linux/services/credentials.cc +++++ src/3rdparty/chromium/sandbox/linux/services/credentials.cc ++@@ -81,7 +81,7 @@ bool ChrootToSafeEmptyDir() { ++ pid_t pid = -1; ++ alignas(16) char stack_buf[PTHREAD_STACK_MIN]; ++ #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ ++- defined(ARCH_CPU_MIPS_FAMILY) +++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // The stack grows downward. ++ void* stack = stack_buf + sizeof(stack_buf); ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc +@@ -61,7 +61,7 @@ long sys_clone(unsigned long flags, + #if defined(ARCH_CPU_X86_64) + return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls); + #elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \ +- defined(ARCH_CPU_MIPS_FAMILY) ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) + // CONFIG_CLONE_BACKWARDS defined. + return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid); + #endif +@@ -264,11 +264,61 @@ int sys_sigaction(int signum, + + #endif // !defined(OS_NACL_NONSFI) + ++ ++#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++void statx_to_stat(struct kernel_stat* to, struct kernel_statx* from) { ++ memset(to, 0, sizeof(struct kernel_stat)); ++ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) | ++ ((from->stx_dev_minor & ~0xff) << 12)); ++ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) | ++ ((from->stx_rdev_minor & ~0xff) << 12)); ++ to->st_ino = from->stx_ino; ++ to->st_mode = from->stx_mode; ++ to->st_nlink = from->stx_nlink; ++ to->st_uid = from->stx_uid; ++ to->st_gid = from->stx_gid; ++ to->st_atime_ = from->stx_atime.tv_sec; ++ to->st_atime_nsec_ = from->stx_atime.tv_nsec; ++ to->st_mtime_ = from->stx_mtime.tv_sec; ++ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; ++ to->st_ctime_ = from->stx_ctime.tv_sec; ++ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; ++ to->st_size = from->stx_size; ++ to->st_blocks = from->stx_blocks; ++ to->st_blksize = from->stx_blksize; ++} ++ ++int sys_statx(int fd, ++ const char* path, ++ int flags, ++ unsigned int mask, ++ struct kernel_statx* statx_buf) { ++#if defined(__NR_statx) ++ int res; ++ res = syscall(__NR_statx, fd, path, flags, mask, statx_buf); ++ if (res == 0) ++ MSAN_UNPOISON(stat_buf, sizeof(*stat_buf)); ++ return res; ++#else // defined(__NR_statx) ++ RAW_CHECK(false); ++ return (int)-ENOSYS; ++#endif ++} ++#endif // defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++ + int sys_stat(const char* path, struct kernel_stat* stat_buf) { + int res; + #if !defined(__NR_stat) ++#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++ kernel_statx statx_buf; ++ res = sys_statx(AT_FDCWD, path, AT_STATX_SYNC_AS_STAT, STATX_BASIC_STATS, ++ &statx_buf); ++ if (res == 0) ++ statx_to_stat(stat_buf, &statx_buf); ++#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) + res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, 0); +-#else ++#endif ++#else // !defined(__NR_stat) + res = syscall(__NR_stat, path, stat_buf); + #endif + if (res == 0) +@@ -279,8 +329,17 @@ int sys_stat(const char* path, struct ke + int sys_lstat(const char* path, struct kernel_stat* stat_buf) { + int res; + #if !defined(__NR_lstat) +- res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); +-#else ++#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++ kernel_statx statx_buf; ++ int flag = 0; ++ flag = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW; ++ res = sys_statx(AT_FDCWD, path, flag, STATX_BASIC_STATS, &statx_buf); ++ if (res == 0) ++ statx_to_stat(stat_buf, &statx_buf); ++#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++ res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); ++#endif ++#else // !defined(__NR_lstat) + res = syscall(__NR_lstat, path, stat_buf); + #endif + if (res == 0) +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc.rej +@@ -0,0 +1,94 @@ ++--- src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc +++++ src/3rdparty/chromium/sandbox/linux/services/syscall_wrappers.cc ++@@ -61,7 +61,7 @@ long sys_clone(unsigned long flags, ++ #if defined(ARCH_CPU_X86_64) ++ return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls); ++ #elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \ ++- defined(ARCH_CPU_MIPS_FAMILY) +++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // CONFIG_CLONE_BACKWARDS defined. ++ return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid); ++ #endif ++@@ -264,11 +264,61 @@ int sys_sigaction(int signum, ++ ++ #endif // !defined(OS_NACL_NONSFI) ++ +++ +++#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++void statx_to_stat(struct kernel_stat* to, struct kernel_statx* from) { +++ memset(to, 0, sizeof(struct kernel_stat)); +++ to->st_dev = ((from->stx_dev_minor & 0xff) | (from->stx_dev_major << 8) | +++ ((from->stx_dev_minor & ~0xff) << 12)); +++ to->st_rdev = ((from->stx_rdev_minor & 0xff) | (from->stx_rdev_major << 8) | +++ ((from->stx_rdev_minor & ~0xff) << 12)); +++ to->st_ino = from->stx_ino; +++ to->st_mode = from->stx_mode; +++ to->st_nlink = from->stx_nlink; +++ to->st_uid = from->stx_uid; +++ to->st_gid = from->stx_gid; +++ to->st_atime_ = from->stx_atime.tv_sec; +++ to->st_atime_nsec_ = from->stx_atime.tv_nsec; +++ to->st_mtime_ = from->stx_mtime.tv_sec; +++ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; +++ to->st_ctime_ = from->stx_ctime.tv_sec; +++ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; +++ to->st_size = from->stx_size; +++ to->st_blocks = from->stx_blocks; +++ to->st_blksize = from->stx_blksize; +++} +++ +++int sys_statx(int fd, +++ const char* path, +++ int flags, +++ unsigned int mask, +++ struct kernel_statx* statx_buf) { +++#if defined(__NR_statx) +++ int res; +++ res = syscall(__NR_statx, fd, path, flags, mask, statx_buf); +++ if (res == 0) +++ MSAN_UNPOISON(stat_buf, sizeof(*stat_buf)); +++ return res; +++#else // defined(__NR_statx) +++ RAW_CHECK(false); +++ return (int)-ENOSYS; +++#endif +++} +++#endif // defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++ ++ int sys_stat(const char* path, struct kernel_stat* stat_buf) { ++ int res; ++ #if !defined(__NR_stat) +++#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++ kernel_statx statx_buf; +++ res = sys_statx(AT_FDCWD, path, AT_STATX_SYNC_AS_STAT, STATX_BASIC_STATS, +++ &statx_buf); +++ if (res == 0) +++ statx_to_stat(stat_buf, &statx_buf); +++#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++ res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, 0); ++-#else +++#endif +++#else // !defined(__NR_stat) ++ res = syscall(__NR_stat, path, stat_buf); ++ #endif ++ if (res == 0) ++@@ -279,8 +329,17 @@ int sys_stat(const char* path, struct kernel_stat* stat_buf) { ++ int sys_lstat(const char* path, struct kernel_stat* stat_buf) { ++ int res; ++ #if !defined(__NR_lstat) ++- res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); ++-#else +++#if defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++ kernel_statx statx_buf; +++ int flag = 0; +++ flag = AT_NO_AUTOMOUNT | AT_SYMLINK_NOFOLLOW; +++ res = sys_statx(AT_FDCWD, path, flag, STATX_BASIC_STATS, &statx_buf); +++ if (res == 0) +++ statx_to_stat(stat_buf, &statx_buf); +++#else // defined(__NR_statx) && defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++ res = syscall(__NR_newfstatat, AT_FDCWD, path, stat_buf, AT_SYMLINK_NOFOLLOW); +++#endif +++#else // !defined(__NR_lstat) ++ res = syscall(__NR_lstat, path, stat_buf); ++ #endif ++ if (res == 0) +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc +@@ -128,43 +128,45 @@ bool BrokerProcess::IsSyscallBrokerable( + // and are default disabled in Android. So, we should refuse to broker them + // to be consistent with the platform's restrictions. + switch (sysno) { +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_access: + #endif + case __NR_faccessat: + return !fast_check || allowed_command_set_.test(COMMAND_ACCESS); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_mkdir: + #endif + case __NR_mkdirat: + return !fast_check || allowed_command_set_.test(COMMAND_MKDIR); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_open: + #endif + case __NR_openat: + return !fast_check || allowed_command_set_.test(COMMAND_OPEN); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_readlink: + #endif + case __NR_readlinkat: + return !fast_check || allowed_command_set_.test(COMMAND_READLINK); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_rename: + #endif ++#if !defined(__loongarch64) + case __NR_renameat: ++#endif + case __NR_renameat2: + return !fast_check || allowed_command_set_.test(COMMAND_RENAME); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_rmdir: + return !fast_check || allowed_command_set_.test(COMMAND_RMDIR); + #endif + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_stat: + case __NR_lstat: + #endif +@@ -189,7 +191,7 @@ bool BrokerProcess::IsSyscallBrokerable( + return !fast_check || allowed_command_set_.test(COMMAND_STAT); + #endif + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) + case __NR_unlink: + return !fast_check || allowed_command_set_.test(COMMAND_UNLINK); + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc.rej +@@ -0,0 +1,64 @@ ++--- src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc +++++ src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc ++@@ -128,43 +128,45 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { ++ // and are default disabled in Android. So, we should refuse to broker them ++ // to be consistent with the platform's restrictions. ++ switch (sysno) { ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_access: ++ #endif ++ case __NR_faccessat: ++ return !fast_check || allowed_command_set_.test(COMMAND_ACCESS); ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_mkdir: ++ #endif ++ case __NR_mkdirat: ++ return !fast_check || allowed_command_set_.test(COMMAND_MKDIR); ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_open: ++ #endif ++ case __NR_openat: ++ return !fast_check || allowed_command_set_.test(COMMAND_OPEN); ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_readlink: ++ #endif ++ case __NR_readlinkat: ++ return !fast_check || allowed_command_set_.test(COMMAND_READLINK); ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_rename: ++ #endif +++#if !defined(__loongarch64) ++ case __NR_renameat: +++#endif ++ case __NR_renameat2: ++ return !fast_check || allowed_command_set_.test(COMMAND_RENAME); ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_rmdir: ++ return !fast_check || allowed_command_set_.test(COMMAND_RMDIR); ++ #endif ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_stat: ++ case __NR_lstat: ++ #endif ++@@ -189,7 +191,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const { ++ return !fast_check || allowed_command_set_.test(COMMAND_STAT); ++ #endif ++ ++-#if !defined(__aarch64__) && !defined(OS_ANDROID) +++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__loongarch64) ++ case __NR_unlink: ++ return !fast_check || allowed_command_set_.test(COMMAND_UNLINK); ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h +@@ -42,6 +42,10 @@ + #define EM_AARCH64 183 + #endif + ++#ifndef EM_LOONGARCH ++#define EM_LOONGARCH 258 ++#endif ++ + #ifndef __AUDIT_ARCH_64BIT + #define __AUDIT_ARCH_64BIT 0x80000000 + #endif +@@ -74,6 +78,10 @@ + #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) + #endif + ++#ifndef AUDIT_ARCH_LOONGARCH64 ++#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) ++#endif ++ + // For prctl.h + #ifndef PR_SET_SECCOMP + #define PR_SET_SECCOMP 22 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h.rej +@@ -0,0 +1,24 @@ ++--- src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h +++++ src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h ++@@ -42,6 +42,10 @@ ++ #define EM_AARCH64 183 ++ #endif ++ +++#ifndef EM_LOONGARCH +++#define EM_LOONGARCH 258 +++#endif +++ ++ #ifndef __AUDIT_ARCH_64BIT ++ #define __AUDIT_ARCH_64BIT 0x80000000 ++ #endif ++@@ -74,6 +78,10 @@ ++ #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) ++ #endif ++ +++#ifndef AUDIT_ARCH_LOONGARCH64 +++#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) +++#endif +++ ++ // For prctl.h ++ #ifndef PR_SET_SECCOMP ++ #define PR_SET_SECCOMP 22 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h +@@ -13,7 +13,7 @@ + // (not undefined, but defined different values and in different memory + // layouts). So, fill the gap here. + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__loongarch64) + + #define LINUX_SIGHUP 1 + #define LINUX_SIGINT 2 +@@ -127,6 +127,13 @@ struct LinuxSigSet { + struct LinuxSigSet { + unsigned long sig[_NSIG_WORDS]; + }; ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++#if !defined(_NSIG_WORDS) ++#define _NSIG_WORDS 1 ++#endif ++struct LinuxSigSet { ++ unsigned long sig[_NSIG_WORDS]; ++}; + #else + typedef uint64_t LinuxSigSet; + #endif +@@ -142,7 +149,9 @@ struct LinuxSigAction { + struct LinuxSigAction { + void (*kernel_handler)(int); + uint32_t sa_flags; ++#if !defined(ARCH_CPU_LOONGARCH_FAMILY) || defined(SA_RESTORER) + void (*sa_restorer)(void); ++#endif + LinuxSigSet sa_mask; + }; + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h.rej +@@ -0,0 +1,35 @@ ++--- src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h +++++ src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h ++@@ -13,7 +13,7 @@ ++ // (not undefined, but defined different values and in different memory ++ // layouts). So, fill the gap here. ++ #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ ++- defined(__aarch64__) +++ defined(__aarch64__) || defined(__loongarch64) ++ ++ #define LINUX_SIGHUP 1 ++ #define LINUX_SIGINT 2 ++@@ -127,6 +127,13 @@ struct LinuxSigSet { ++ struct LinuxSigSet { ++ unsigned long sig[_NSIG_WORDS]; ++ }; +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++#if !defined(_NSIG_WORDS) +++#define _NSIG_WORDS 1 +++#endif +++struct LinuxSigSet { +++ unsigned long sig[_NSIG_WORDS]; +++}; ++ #else ++ typedef uint64_t LinuxSigSet; ++ #endif ++@@ -142,7 +149,9 @@ struct LinuxSigAction { ++ struct LinuxSigAction { ++ void (*kernel_handler)(int); ++ uint32_t sa_flags; +++#if !defined(ARCH_CPU_LOONGARCH_FAMILY) || defined(SA_RESTORER) ++ void (*sa_restorer)(void); +++#endif ++ LinuxSigSet sa_mask; ++ }; ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h +@@ -173,6 +173,57 @@ struct kernel_stat { + unsigned int __unused4; + unsigned int __unused5; + }; ++#elif defined(__loongarch64) ++struct kernel_stat { ++ unsigned long st_dev; ++ unsigned long st_ino; ++ unsigned int st_mode; ++ unsigned int st_nlink; ++ unsigned int st_uid; ++ unsigned int st_gid; ++ unsigned long st_rdev; ++ unsigned long __pad1; ++ long st_size; ++ int st_blksize; ++ int __pad2; ++ long st_blocks; ++ long st_atime_; ++ unsigned long st_atime_nsec_; ++ long st_mtime_; ++ unsigned long st_mtime_nsec_; ++ long st_ctime_; ++ unsigned long st_ctime_nsec_; ++ unsigned int __unused4; ++ unsigned int __unused5; ++}; ++struct kernel_statx_timestamp { ++ long tv_sec; ++ unsigned int tv_nsec; ++ int __reserved; ++}; ++struct kernel_statx { ++ unsigned int stx_mask; ++ unsigned int stx_blksize; ++ unsigned long stx_attributes; ++ unsigned int stx_nlink; ++ unsigned int stx_uid; ++ unsigned int stx_gid; ++ unsigned short stx_mode; ++ unsigned short __spare0[1]; ++ unsigned long stx_ino; ++ unsigned long stx_size; ++ unsigned long stx_blocks; ++ unsigned long stx_attributes_mask; ++ struct kernel_statx_timestamp stx_atime; ++ struct kernel_statx_timestamp stx_btime; ++ struct kernel_statx_timestamp stx_ctime; ++ struct kernel_statx_timestamp stx_mtime; ++ unsigned int stx_rdev_major; ++ unsigned int stx_rdev_minor; ++ unsigned int stx_dev_major; ++ unsigned int stx_dev_minor; ++ unsigned long __spare2[14]; ++}; + #endif + + #if !defined(AT_EMPTY_PATH) +@@ -207,6 +258,20 @@ using default_stat_struct = struct kerne + #define __NR_fstatat_default __NR_newfstatat + #define __NR_fstat_default __NR_fstat + ++#elif defined(__NR_statx) // loongarch64 ++ ++namespace sandbox { ++using default_stat_struct = struct kernel_statx; ++} // namespace sandbox ++ ++#define AT_STATX_SYNC_TYPE 0x6000 ++#define AT_STATX_SYNC_AS_STAT 0x0000 ++#define AT_STATX_FORCE_SYNC 0x2000 ++#define AT_STATX_DONT_SYNC 0x4000 ++#define STATX_ALL 0x00000fffU ++ ++#define __NR_statx_default __NR_statx ++ + #else + #error "one of fstatat64 and newfstatat must be defined" + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h.orig +@@ -0,0 +1,196 @@ ++// Copyright 2021 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_STAT_H_ ++#define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_STAT_H_ ++ ++#include ++ ++#include "build/build_config.h" ++#include "sandbox/linux/system_headers/linux_syscalls.h" ++ ++#if defined(ARCH_CPU_MIPS_FAMILY) ++#if defined(ARCH_CPU_64_BITS) ++struct kernel_stat { ++#else ++struct kernel_stat64 { ++#endif ++ unsigned st_dev; ++ unsigned __pad0[3]; ++ unsigned long long st_ino; ++ unsigned st_mode; ++ unsigned st_nlink; ++ unsigned st_uid; ++ unsigned st_gid; ++ unsigned st_rdev; ++ unsigned __pad1[3]; ++ long long st_size; ++ unsigned st_atime_; ++ unsigned st_atime_nsec_; ++ unsigned st_mtime_; ++ unsigned st_mtime_nsec_; ++ unsigned st_ctime_; ++ unsigned st_ctime_nsec_; ++ unsigned st_blksize; ++ unsigned __pad2; ++ unsigned long long st_blocks; ++}; ++#else ++struct kernel_stat64 { ++ unsigned long long st_dev; ++ unsigned char __pad0[4]; ++ unsigned __st_ino; ++ unsigned st_mode; ++ unsigned st_nlink; ++ unsigned st_uid; ++ unsigned st_gid; ++ unsigned long long st_rdev; ++ unsigned char __pad3[4]; ++ long long st_size; ++ unsigned st_blksize; ++ unsigned long long st_blocks; ++ unsigned st_atime_; ++ unsigned st_atime_nsec_; ++ unsigned st_mtime_; ++ unsigned st_mtime_nsec_; ++ unsigned st_ctime_; ++ unsigned st_ctime_nsec_; ++ unsigned long long st_ino; ++}; ++#endif ++ ++#if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) ++struct kernel_stat { ++ /* The kernel headers suggest that st_dev and st_rdev should be 32bit ++ * quantities encoding 12bit major and 20bit minor numbers in an interleaved ++ * format. In reality, we do not see useful data in the top bits. So, ++ * we'll leave the padding in here, until we find a better solution. ++ */ ++ unsigned short st_dev; ++ short pad1; ++ unsigned st_ino; ++ unsigned short st_mode; ++ unsigned short st_nlink; ++ unsigned short st_uid; ++ unsigned short st_gid; ++ unsigned short st_rdev; ++ short pad2; ++ unsigned st_size; ++ unsigned st_blksize; ++ unsigned st_blocks; ++ unsigned st_atime_; ++ unsigned st_atime_nsec_; ++ unsigned st_mtime_; ++ unsigned st_mtime_nsec_; ++ unsigned st_ctime_; ++ unsigned st_ctime_nsec_; ++ unsigned __unused4; ++ unsigned __unused5; ++}; ++#elif defined(__x86_64__) ++struct kernel_stat { ++ uint64_t st_dev; ++ uint64_t st_ino; ++ uint64_t st_nlink; ++ unsigned st_mode; ++ unsigned st_uid; ++ unsigned st_gid; ++ unsigned __pad0; ++ uint64_t st_rdev; ++ int64_t st_size; ++ int64_t st_blksize; ++ int64_t st_blocks; ++ uint64_t st_atime_; ++ uint64_t st_atime_nsec_; ++ uint64_t st_mtime_; ++ uint64_t st_mtime_nsec_; ++ uint64_t st_ctime_; ++ uint64_t st_ctime_nsec_; ++ int64_t __unused4[3]; ++}; ++#elif (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++struct kernel_stat { ++ unsigned st_dev; ++ int st_pad1[3]; ++ unsigned st_ino; ++ unsigned st_mode; ++ unsigned st_nlink; ++ unsigned st_uid; ++ unsigned st_gid; ++ unsigned st_rdev; ++ int st_pad2[2]; ++ long st_size; ++ int st_pad3; ++ long st_atime_; ++ long st_atime_nsec_; ++ long st_mtime_; ++ long st_mtime_nsec_; ++ long st_ctime_; ++ long st_ctime_nsec_; ++ int st_blksize; ++ int st_blocks; ++ int st_pad4[14]; ++}; ++#elif defined(__aarch64__) ++struct kernel_stat { ++ unsigned long st_dev; ++ unsigned long st_ino; ++ unsigned int st_mode; ++ unsigned int st_nlink; ++ unsigned int st_uid; ++ unsigned int st_gid; ++ unsigned long st_rdev; ++ unsigned long __pad1; ++ long st_size; ++ int st_blksize; ++ int __pad2; ++ long st_blocks; ++ long st_atime_; ++ unsigned long st_atime_nsec_; ++ long st_mtime_; ++ unsigned long st_mtime_nsec_; ++ long st_ctime_; ++ unsigned long st_ctime_nsec_; ++ unsigned int __unused4; ++ unsigned int __unused5; ++}; ++#endif ++ ++#if !defined(AT_EMPTY_PATH) ++#define AT_EMPTY_PATH 0x1000 ++#endif ++ ++#if !defined(STATX_BASIC_STATS) ++#define STATX_BASIC_STATS 0x000007ffU ++#endif ++ ++// On 32-bit systems, we default to the 64-bit stat struct like libc ++// implementations do. Otherwise we default to the normal stat struct which is ++// already 64-bit. ++// These defines make it easy to call the right syscall to fill out a 64-bit ++// stat struct, which is the default in libc implementations but requires ++// different syscall names on 32 and 64-bit platforms. ++#if defined(__NR_fstatat64) ++ ++namespace sandbox { ++using default_stat_struct = struct kernel_stat64; ++} // namespace sandbox ++ ++#define __NR_fstatat_default __NR_fstatat64 ++#define __NR_fstat_default __NR_fstat64 ++ ++#elif defined(__NR_newfstatat) ++ ++namespace sandbox { ++using default_stat_struct = struct kernel_stat; ++} // namespace sandbox ++ ++#define __NR_fstatat_default __NR_newfstatat ++#define __NR_fstat_default __NR_fstat ++ ++#else ++#error "one of fstatat64 and newfstatat must be defined" ++#endif ++ ++#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_STAT_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h.rej +@@ -0,0 +1,81 @@ ++--- src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h +++++ src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h ++@@ -173,6 +173,57 @@ struct kernel_stat { ++ unsigned int __unused4; ++ unsigned int __unused5; ++ }; +++#elif defined(__loongarch64) +++struct kernel_stat { +++ unsigned long st_dev; +++ unsigned long st_ino; +++ unsigned int st_mode; +++ unsigned int st_nlink; +++ unsigned int st_uid; +++ unsigned int st_gid; +++ unsigned long st_rdev; +++ unsigned long __pad1; +++ long st_size; +++ int st_blksize; +++ int __pad2; +++ long st_blocks; +++ long st_atime_; +++ unsigned long st_atime_nsec_; +++ long st_mtime_; +++ unsigned long st_mtime_nsec_; +++ long st_ctime_; +++ unsigned long st_ctime_nsec_; +++ unsigned int __unused4; +++ unsigned int __unused5; +++}; +++struct kernel_statx_timestamp { +++ long tv_sec; +++ unsigned int tv_nsec; +++ int __reserved; +++}; +++struct kernel_statx { +++ unsigned int stx_mask; +++ unsigned int stx_blksize; +++ unsigned long stx_attributes; +++ unsigned int stx_nlink; +++ unsigned int stx_uid; +++ unsigned int stx_gid; +++ unsigned short stx_mode; +++ unsigned short __spare0[1]; +++ unsigned long stx_ino; +++ unsigned long stx_size; +++ unsigned long stx_blocks; +++ unsigned long stx_attributes_mask; +++ struct kernel_statx_timestamp stx_atime; +++ struct kernel_statx_timestamp stx_btime; +++ struct kernel_statx_timestamp stx_ctime; +++ struct kernel_statx_timestamp stx_mtime; +++ unsigned int stx_rdev_major; +++ unsigned int stx_rdev_minor; +++ unsigned int stx_dev_major; +++ unsigned int stx_dev_minor; +++ unsigned long __spare2[14]; +++}; ++ #endif ++ ++ #if !defined(AT_EMPTY_PATH) ++@@ -207,6 +258,20 @@ using default_stat_struct = struct kernel_stat; ++ #define __NR_fstatat_default __NR_newfstatat ++ #define __NR_fstat_default __NR_fstat ++ +++#elif defined(__NR_statx) // loongarch64 +++ +++namespace sandbox { +++using default_stat_struct = struct kernel_statx; +++} // namespace sandbox +++ +++#define AT_STATX_SYNC_TYPE 0x6000 +++#define AT_STATX_SYNC_AS_STAT 0x0000 +++#define AT_STATX_FORCE_SYNC 0x2000 +++#define AT_STATX_DONT_SYNC 0x4000 +++#define STATX_ALL 0x00000fffU +++ +++#define __NR_statx_default __NR_statx +++ ++ #else ++ #error "one of fstatat64 and newfstatat must be defined" ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h +@@ -31,6 +31,10 @@ + #include "sandbox/linux/system_headers/mips64_linux_syscalls.h" + #endif + ++#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) ++#include "sandbox/linux/system_headers/loongarch64_linux_syscalls.h" ++#endif ++ + #if defined(__aarch64__) + #include "sandbox/linux/system_headers/arm64_linux_syscalls.h" + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h.rej +@@ -0,0 +1,13 @@ ++--- src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h +++++ src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h ++@@ -31,6 +31,10 @@ ++ #include "sandbox/linux/system_headers/mips64_linux_syscalls.h" ++ #endif ++ +++#if defined(ARCH_CPU_LOONGARCH_FAMILY) && defined(ARCH_CPU_64_BITS) +++#include "sandbox/linux/system_headers/loongarch64_linux_syscalls.h" +++#endif +++ ++ #if defined(__aarch64__) ++ #include "sandbox/linux/system_headers/arm64_linux_syscalls.h" ++ #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/linux/system_headers/loongarch64_linux_syscalls.h +@@ -0,0 +1,851 @@ ++// Copyright 2021 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ ++#define SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ ++ ++#if !defined(__loongarch__) ++#error "Including header on wrong architecture" ++#endif ++#include ++#if !defined(__NR_io_setup) ++#define __NR_io_setup 0 ++#endif ++#if !defined(__NR_io_destroy) ++#define __NR_io_destroy 1 ++#endif ++#if !defined(__NR_io_submit) ++#define __NR_io_submit 2 ++#endif ++#if !defined(__NR_io_cancel) ++#define __NR_io_cancel 3 ++#endif ++#if !defined(__NR_io_getevents) ++#define __NR_io_getevents 4 ++#endif ++#if !defined(__NR_setxattr) ++#define __NR_setxattr 5 ++#endif ++#if !defined(__NR_lsetxattr) ++#define __NR_lsetxattr 6 ++#endif ++#if !defined(__NR_fsetxattr) ++#define __NR_fsetxattr 7 ++#endif ++#if !defined(__NR_getxattr) ++#define __NR_getxattr 8 ++#endif ++#if !defined(__NR_lgetxattr) ++#define __NR_lgetxattr 9 ++#endif ++#if !defined(__NR_fgetxattr) ++#define __NR_fgetxattr 10 ++#endif ++#if !defined(__NR_listxattr) ++#define __NR_listxattr 11 ++#endif ++#if !defined(__NR_llistxattr) ++#define __NR_llistxattr 12 ++#endif ++#if !defined(__NR_flistxattr) ++#define __NR_flistxattr 13 ++#endif ++#if !defined(__NR_removexattr) ++#define __NR_removexattr 14 ++#endif ++#if !defined(__NR_lremovexattr) ++#define __NR_lremovexattr 15 ++#endif ++#if !defined(__NR_fremovexattr) ++#define __NR_fremovexattr 16 ++#endif ++#if !defined(__NR_getcwd) ++#define __NR_getcwd 17 ++#endif ++#if !defined(__NR_lookup_dcookie) ++#define __NR_lookup_dcookie 18 ++#endif ++#if !defined(__NR_eventfd2) ++#define __NR_eventfd2 19 ++#endif ++#if !defined(__NR_epoll_create1) ++#define __NR_epoll_create1 20 ++#endif ++#if !defined(__NR_epoll_ctl) ++#define __NR_epoll_ctl 21 ++#endif ++#if !defined(__NR_epoll_pwait) ++#define __NR_epoll_pwait 22 ++#endif ++#if !defined(__NR_dup) ++#define __NR_dup 23 ++#endif ++#if !defined(__NR_dup3) ++#define __NR_dup3 24 ++#endif ++#if !defined(__NR_fcntl) ++#define __NR_fcntl 25 ++#endif ++#if !defined(__NR_inotify_init1) ++#define __NR_inotify_init1 26 ++#endif ++#if !defined(__NR_inotify_add_watch) ++#define __NR_inotify_add_watch 27 ++#endif ++#if !defined(__NR_inotify_rm_watch) ++#define __NR_inotify_rm_watch 28 ++#endif ++#if !defined(__NR_ioctl) ++#define __NR_ioctl 29 ++#endif ++#if !defined(__NR_ioprio_set) ++#define __NR_ioprio_set 30 ++#endif ++#if !defined(__NR_ioprio_get) ++#define __NR_ioprio_get 31 ++#endif ++#if !defined(__NR_flock) ++#define __NR_flock 32 ++#endif ++#if !defined(__NR_mknodat) ++#define __NR_mknodat 33 ++#endif ++#if !defined(__NR_mkdirat) ++#define __NR_mkdirat 34 ++#endif ++#if !defined(__NR_unlinkat) ++#define __NR_unlinkat 35 ++#endif ++#if !defined(__NR_symlinkat) ++#define __NR_symlinkat 36 ++#endif ++#if !defined(__NR_linkat) ++#define __NR_linkat 37 ++#endif ++#if !defined(__NR_renameat) ++#define __NR_renameat 38 ++#endif ++#if !defined(__NR_umount2) ++#define __NR_umount2 39 ++#endif ++#if !defined(__NR_mount) ++#define __NR_mount 40 ++#endif ++#if !defined(__NR_pivot_root) ++#define __NR_pivot_root 41 ++#endif ++#if !defined(__NR_nfsservctl) ++#define __NR_nfsservctl 42 ++#endif ++#if !defined(__NR_statfs) ++#define __NR_statfs 43 ++#endif ++#if !defined(__NR_fstatfs) ++#define __NR_fstatfs 44 ++#endif ++#if !defined(__NR_truncate) ++#define __NR_truncate 45 ++#endif ++#if !defined(__NR_ftruncate) ++#define __NR_ftruncate 46 ++#endif ++#if !defined(__NR_fallocate) ++#define __NR_fallocate 47 ++#endif ++#if !defined(__NR_faccessat) ++#define __NR_faccessat 48 ++#endif ++#if !defined(__NR_chdir) ++#define __NR_chdir 49 ++#endif ++#if !defined(__NR_fchdir) ++#define __NR_fchdir 50 ++#endif ++#if !defined(__NR_chroot) ++#define __NR_chroot 51 ++#endif ++#if !defined(__NR_fchmod) ++#define __NR_fchmod 52 ++#endif ++#if !defined(__NR_fchmodat) ++#define __NR_fchmodat 53 ++#endif ++#if !defined(__NR_fchownat) ++#define __NR_fchownat 54 ++#endif ++#if !defined(__NR_fchown) ++#define __NR_fchown 55 ++#endif ++#if !defined(__NR_openat) ++#define __NR_openat 56 ++#endif ++#if !defined(__NR_close) ++#define __NR_close 57 ++#endif ++#if !defined(__NR_vhangup) ++#define __NR_vhangup 58 ++#endif ++#if !defined(__NR_pipe2) ++#define __NR_pipe2 59 ++#endif ++#if !defined(__NR_quotactl) ++#define __NR_quotactl 60 ++#endif ++#if !defined(__NR_getdents64) ++#define __NR_getdents64 61 ++#endif ++#if !defined(__NR_lseek) ++#define __NR_lseek 62 ++#endif ++#if !defined(__NR_read) ++#define __NR_read 63 ++#endif ++#if !defined(__NR_write) ++#define __NR_write 64 ++#endif ++#if !defined(__NR_readv) ++#define __NR_readv 65 ++#endif ++#if !defined(__NR_writev) ++#define __NR_writev 66 ++#endif ++#if !defined(__NR_pread64) ++#define __NR_pread64 67 ++#endif ++#if !defined(__NR_pwrite64) ++#define __NR_pwrite64 68 ++#endif ++#if !defined(__NR_preadv) ++#define __NR_preadv 69 ++#endif ++#if !defined(__NR_pwritev) ++#define __NR_pwritev 70 ++#endif ++#if !defined(__NR_sendfile) ++#define __NR_sendfile 71 ++#endif ++#if !defined(__NR_pselect6) ++#define __NR_pselect6 72 ++#endif ++#if !defined(__NR_ppoll) ++#define __NR_ppoll 73 ++#endif ++#if !defined(__NR_signalfd4) ++#define __NR_signalfd4 74 ++#endif ++#if !defined(__NR_vmsplice) ++#define __NR_vmsplice 75 ++#endif ++#if !defined(__NR_splice) ++#define __NR_splice 76 ++#endif ++#if !defined(__NR_tee) ++#define __NR_tee 77 ++#endif ++#if !defined(__NR_readlinkat) ++#define __NR_readlinkat 78 ++#endif ++#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) ++#if !defined(__NR_newfstatat) ++#define __NR_newfstatat 79 ++#endif ++#if !defined(__NR_fstat) ++#define __NR_fstat 80 ++#endif ++#endif ++#if !defined(__NR_sync) ++#define __NR_sync 81 ++#endif ++#if !defined(__NR_fsync) ++#define __NR_fsync 82 ++#endif ++#if !defined(__NR_fdatasync) ++#define __NR_fdatasync 83 ++#endif ++#if !defined(__NR_sync_file_range) ++#define __NR_sync_file_range 84 ++#endif ++#if !defined(__NR_timerfd_create) ++#define __NR_timerfd_create 85 ++#endif ++#if !defined(__NR_timerfd_settime) ++#define __NR_timerfd_settime 86 ++#endif ++#if !defined(__NR_timerfd_gettime) ++#define __NR_timerfd_gettime 87 ++#endif ++#if !defined(__NR_utimensat) ++#define __NR_utimensat 88 ++#endif ++#if !defined(__NR_acct) ++#define __NR_acct 89 ++#endif ++#if !defined(__NR_capget) ++#define __NR_capget 90 ++#endif ++#if !defined(__NR_capset) ++#define __NR_capset 91 ++#endif ++#if !defined(__NR_personality) ++#define __NR_personality 92 ++#endif ++#if !defined(__NR_exit) ++#define __NR_exit 93 ++#endif ++#if !defined(__NR_exit_group) ++#define __NR_exit_group 94 ++#endif ++#if !defined(__NR_waitid) ++#define __NR_waitid 95 ++#endif ++#if !defined(__NR_set_tid_address) ++#define __NR_set_tid_address 96 ++#endif ++#if !defined(__NR_unshare) ++#define __NR_unshare 97 ++#endif ++#if !defined(__NR_futex) ++#define __NR_futex 98 ++#endif ++#if !defined(__NR_set_robust_list) ++#define __NR_set_robust_list 99 ++#endif ++#if !defined(__NR_get_robust_list) ++#define __NR_get_robust_list 100 ++#endif ++#if !defined(__NR_nanosleep) ++#define __NR_nanosleep 101 ++#endif ++#if !defined(__NR_getitimer) ++#define __NR_getitimer 102 ++#endif ++#if !defined(__NR_setitimer) ++#define __NR_setitimer 103 ++#endif ++#if !defined(__NR_kexec_load) ++#define __NR_kexec_load 104 ++#endif ++#if !defined(__NR_init_module) ++#define __NR_init_module 105 ++#endif ++#if !defined(__NR_delete_module) ++#define __NR_delete_module 106 ++#endif ++#if !defined(__NR_timer_create) ++#define __NR_timer_create 107 ++#endif ++#if !defined(__NR_timer_gettime) ++#define __NR_timer_gettime 108 ++#endif ++#if !defined(__NR_timer_getoverrun) ++#define __NR_timer_getoverrun 109 ++#endif ++#if !defined(__NR_timer_settime) ++#define __NR_timer_settime 110 ++#endif ++#if !defined(__NR_timer_delete) ++#define __NR_timer_delete 111 ++#endif ++#if !defined(__NR_clock_settime) ++#define __NR_clock_settime 112 ++#endif ++#if !defined(__NR_clock_gettime) ++#define __NR_clock_gettime 113 ++#endif ++#if !defined(__NR_clock_getres) ++#define __NR_clock_getres 114 ++#endif ++#if !defined(__NR_clock_nanosleep) ++#define __NR_clock_nanosleep 115 ++#endif ++#if !defined(__NR_syslog) ++#define __NR_syslog 116 ++#endif ++#if !defined(__NR_ptrace) ++#define __NR_ptrace 117 ++#endif ++#if !defined(__NR_sched_setparam) ++#define __NR_sched_setparam 118 ++#endif ++#if !defined(__NR_sched_setscheduler) ++#define __NR_sched_setscheduler 119 ++#endif ++#if !defined(__NR_sched_getscheduler) ++#define __NR_sched_getscheduler 120 ++#endif ++#if !defined(__NR_sched_getparam) ++#define __NR_sched_getparam 121 ++#endif ++#if !defined(__NR_sched_setaffinity) ++#define __NR_sched_setaffinity 122 ++#endif ++#if !defined(__NR_sched_getaffinity) ++#define __NR_sched_getaffinity 123 ++#endif ++#if !defined(__NR_sched_yield) ++#define __NR_sched_yield 124 ++#endif ++#if !defined(__NR_sched_get_priority_max) ++#define __NR_sched_get_priority_max 125 ++#endif ++#if !defined(__NR_sched_get_priority_min) ++#define __NR_sched_get_priority_min 126 ++#endif ++#if !defined(__NR_sched_rr_get_interval) ++#define __NR_sched_rr_get_interval 127 ++#endif ++#if !defined(__NR_restart_syscall) ++#define __NR_restart_syscall 128 ++#endif ++#if !defined(__NR_kill) ++#define __NR_kill 129 ++#endif ++#if !defined(__NR_tkill) ++#define __NR_tkill 130 ++#endif ++#if !defined(__NR_tgkill) ++#define __NR_tgkill 131 ++#endif ++#if !defined(__NR_sigaltstack) ++#define __NR_sigaltstack 132 ++#endif ++#if !defined(__NR_rt_sigsuspend) ++#define __NR_rt_sigsuspend 133 ++#endif ++#if !defined(__NR_rt_sigaction) ++#define __NR_rt_sigaction 134 ++#endif ++#if !defined(__NR_rt_sigprocmask) ++#define __NR_rt_sigprocmask 135 ++#endif ++#if !defined(__NR_rt_sigpending) ++#define __NR_rt_sigpending 136 ++#endif ++#if !defined(__NR_rt_sigtimedwait) ++#define __NR_rt_sigtimedwait 137 ++#endif ++#if !defined(__NR_rt_sigqueueinfo) ++#define __NR_rt_sigqueueinfo 138 ++#endif ++#if !defined(__NR_rt_sigreturn) ++#define __NR_rt_sigreturn 139 ++#endif ++#if !defined(__NR_setpriority) ++#define __NR_setpriority 140 ++#endif ++#if !defined(__NR_getpriority) ++#define __NR_getpriority 141 ++#endif ++#if !defined(__NR_reboot) ++#define __NR_reboot 142 ++#endif ++#if !defined(__NR_setregid) ++#define __NR_setregid 143 ++#endif ++#if !defined(__NR_setgid) ++#define __NR_setgid 144 ++#endif ++#if !defined(__NR_setreuid) ++#define __NR_setreuid 145 ++#endif ++#if !defined(__NR_setuid) ++#define __NR_setuid 146 ++#endif ++#if !defined(__NR_setresuid) ++#define __NR_setresuid 147 ++#endif ++#if !defined(__NR_getresuid) ++#define __NR_getresuid 148 ++#endif ++#if !defined(__NR_setresgid) ++#define __NR_setresgid 149 ++#endif ++#if !defined(__NR_getresgid) ++#define __NR_getresgid 150 ++#endif ++#if !defined(__NR_setfsuid) ++#define __NR_setfsuid 151 ++#endif ++#if !defined(__NR_setfsgid) ++#define __NR_setfsgid 152 ++#endif ++#if !defined(__NR_times) ++#define __NR_times 153 ++#endif ++#if !defined(__NR_setpgid) ++#define __NR_setpgid 154 ++#endif ++#if !defined(__NR_getpgid) ++#define __NR_getpgid 155 ++#endif ++#if !defined(__NR_getsid) ++#define __NR_getsid 156 ++#endif ++#if !defined(__NR_setsid) ++#define __NR_setsid 157 ++#endif ++#if !defined(__NR_getgroups) ++#define __NR_getgroups 158 ++#endif ++#if !defined(__NR_setgroups) ++#define __NR_setgroups 159 ++#endif ++#if !defined(__NR_uname) ++#define __NR_uname 160 ++#endif ++#if !defined(__NR_sethostname) ++#define __NR_sethostname 161 ++#endif ++#if !defined(__NR_setdomainname) ++#define __NR_setdomainname 162 ++#endif ++#if !defined(__NR_getrlimit) ++#define __NR_getrlimit 163 ++#endif ++#if !defined(__NR_setrlimit) ++#define __NR_setrlimit 164 ++#endif ++#if !defined(__NR_getrusage) ++#define __NR_getrusage 165 ++#endif ++#if !defined(__NR_umask) ++#define __NR_umask 166 ++#endif ++#if !defined(__NR_prctl) ++#define __NR_prctl 167 ++#endif ++#if !defined(__NR_getcpu) ++#define __NR_getcpu 168 ++#endif ++#if !defined(__NR_gettimeofday) ++#define __NR_gettimeofday 169 ++#endif ++#if !defined(__NR_settimeofday) ++#define __NR_settimeofday 170 ++#endif ++#if !defined(__NR_adjtimex) ++#define __NR_adjtimex 171 ++#endif ++#if !defined(__NR_getpid) ++#define __NR_getpid 172 ++#endif ++#if !defined(__NR_getppid) ++#define __NR_getppid 173 ++#endif ++#if !defined(__NR_getuid) ++#define __NR_getuid 174 ++#endif ++#if !defined(__NR_geteuid) ++#define __NR_geteuid 175 ++#endif ++#if !defined(__NR_getgid) ++#define __NR_getgid 176 ++#endif ++#if !defined(__NR_getegid) ++#define __NR_getegid 177 ++#endif ++#if !defined(__NR_gettid) ++#define __NR_gettid 178 ++#endif ++#if !defined(__NR_sysinfo) ++#define __NR_sysinfo 179 ++#endif ++#if !defined(__NR_mq_open) ++#define __NR_mq_open 180 ++#endif ++#if !defined(__NR_mq_unlink) ++#define __NR_mq_unlink 181 ++#endif ++#if !defined(__NR_mq_timedsend) ++#define __NR_mq_timedsend 182 ++#endif ++#if !defined(__NR_mq_timedreceive) ++#define __NR_mq_timedreceive 183 ++#endif ++#if !defined(__NR_mq_notify) ++#define __NR_mq_notify 184 ++#endif ++#if !defined(__NR_mq_getsetattr) ++#define __NR_mq_getsetattr 185 ++#endif ++#if !defined(__NR_msgget) ++#define __NR_msgget 186 ++#endif ++#if !defined(__NR_msgctl) ++#define __NR_msgctl 187 ++#endif ++#if !defined(__NR_msgrcv) ++#define __NR_msgrcv 188 ++#endif ++#if !defined(__NR_msgsnd) ++#define __NR_msgsnd 189 ++#endif ++#if !defined(__NR_semget) ++#define __NR_semget 190 ++#endif ++#if !defined(__NR_semctl) ++#define __NR_semctl 191 ++#endif ++#if !defined(__NR_semtimedop) ++#define __NR_semtimedop 192 ++#endif ++#if !defined(__NR_semop) ++#define __NR_semop 193 ++#endif ++#if !defined(__NR_shmget) ++#define __NR_shmget 194 ++#endif ++#if !defined(__NR_shmctl) ++#define __NR_shmctl 195 ++#endif ++#if !defined(__NR_shmat) ++#define __NR_shmat 196 ++#endif ++#if !defined(__NR_shmdt) ++#define __NR_shmdt 197 ++#endif ++#if !defined(__NR_socket) ++#define __NR_socket 198 ++#endif ++#if !defined(__NR_socketpair) ++#define __NR_socketpair 199 ++#endif ++#if !defined(__NR_bind) ++#define __NR_bind 200 ++#endif ++#if !defined(__NR_listen) ++#define __NR_listen 201 ++#endif ++#if !defined(__NR_accept) ++#define __NR_accept 202 ++#endif ++#if !defined(__NR_connect) ++#define __NR_connect 203 ++#endif ++#if !defined(__NR_getsockname) ++#define __NR_getsockname 204 ++#endif ++#if !defined(__NR_getpeername) ++#define __NR_getpeername 205 ++#endif ++#if !defined(__NR_sendto) ++#define __NR_sendto 206 ++#endif ++#if !defined(__NR_recvfrom) ++#define __NR_recvfrom 207 ++#endif ++#if !defined(__NR_setsockopt) ++#define __NR_setsockopt 208 ++#endif ++#if !defined(__NR_getsockopt) ++#define __NR_getsockopt 209 ++#endif ++#if !defined(__NR_shutdown) ++#define __NR_shutdown 210 ++#endif ++#if !defined(__NR_sendmsg) ++#define __NR_sendmsg 211 ++#endif ++#if !defined(__NR_recvmsg) ++#define __NR_recvmsg 212 ++#endif ++#if !defined(__NR_readahead) ++#define __NR_readahead 213 ++#endif ++#if !defined(__NR_brk) ++#define __NR_brk 214 ++#endif ++#if !defined(__NR_munmap) ++#define __NR_munmap 215 ++#endif ++#if !defined(__NR_mremap) ++#define __NR_mremap 216 ++#endif ++#if !defined(__NR_add_key) ++#define __NR_add_key 217 ++#endif ++#if !defined(__NR_request_key) ++#define __NR_request_key 218 ++#endif ++#if !defined(__NR_keyctl) ++#define __NR_keyctl 219 ++#endif ++#if !defined(__NR_clone) ++#define __NR_clone 220 ++#endif ++#if !defined(__NR_execve) ++#define __NR_execve 221 ++#endif ++#if !defined(__NR_mmap) ++#define __NR_mmap 222 ++#endif ++#if !defined(__NR_fadvise64) ++#define __NR_fadvise64 223 ++#endif ++#if !defined(__NR_swapon) ++#define __NR_swapon 224 ++#endif ++#if !defined(__NR_swapoff) ++#define __NR_swapoff 225 ++#endif ++#if !defined(__NR_mprotect) ++#define __NR_mprotect 226 ++#endif ++#if !defined(__NR_msync) ++#define __NR_msync 227 ++#endif ++#if !defined(__NR_mlock) ++#define __NR_mlock 228 ++#endif ++#if !defined(__NR_munlock) ++#define __NR_munlock 229 ++#endif ++#if !defined(__NR_mlockall) ++#define __NR_mlockall 230 ++#endif ++#if !defined(__NR_munlockall) ++#define __NR_munlockall 231 ++#endif ++#if !defined(__NR_mincore) ++#define __NR_mincore 232 ++#endif ++#if !defined(__NR_madvise) ++#define __NR_madvise 233 ++#endif ++#if !defined(__NR_remap_file_pages) ++#define __NR_remap_file_pages 234 ++#endif ++#if !defined(__NR_mbind) ++#define __NR_mbind 235 ++#endif ++#if !defined(__NR_get_mempolicy) ++#define __NR_get_mempolicy 236 ++#endif ++#if !defined(__NR_set_mempolicy) ++#define __NR_set_mempolicy 237 ++#endif ++#if !defined(__NR_migrate_pages) ++#define __NR_migrate_pages 238 ++#endif ++#if !defined(__NR_move_pages) ++#define __NR_move_pages 239 ++#endif ++#if !defined(__NR_rt_tgsigqueueinfo) ++#define __NR_rt_tgsigqueueinfo 240 ++#endif ++#if !defined(__NR_perf_event_open) ++#define __NR_perf_event_open 241 ++#endif ++#if !defined(__NR_accept4) ++#define __NR_accept4 242 ++#endif ++#if !defined(__NR_recvmmsg) ++#define __NR_recvmmsg 243 ++#endif ++#if !defined(__NR_wait4) ++#define __NR_wait4 260 ++#endif ++#if !defined(__NR_prlimit64) ++#define __NR_prlimit64 261 ++#endif ++#if !defined(__NR_fanotify_init) ++#define __NR_fanotify_init 262 ++#endif ++#if !defined(__NR_fanotify_mark) ++#define __NR_fanotify_mark 263 ++#endif ++#if !defined(__NR_name_to_handle_at) ++#define __NR_name_to_handle_at 264 ++#endif ++#if !defined(__NR_open_by_handle_at) ++#define __NR_open_by_handle_at 265 ++#endif ++#if !defined(__NR_clock_adjtime) ++#define __NR_clock_adjtime 266 ++#endif ++#if !defined(__NR_syncfs) ++#define __NR_syncfs 267 ++#endif ++#if !defined(__NR_setns) ++#define __NR_setns 268 ++#endif ++#if !defined(__NR_sendmmsg) ++#define __NR_sendmmsg 269 ++#endif ++#if !defined(__NR_process_vm_readv) ++#define __NR_process_vm_readv 270 ++#endif ++#if !defined(__NR_process_vm_writev) ++#define __NR_process_vm_writev 271 ++#endif ++#if !defined(__NR_kcmp) ++#define __NR_kcmp 272 ++#endif ++#if !defined(__NR_finit_module) ++#define __NR_finit_module 273 ++#endif ++#if !defined(__NR_sched_setattr) ++#define __NR_sched_setattr 274 ++#endif ++#if !defined(__NR_sched_getattr) ++#define __NR_sched_getattr 275 ++#endif ++#if !defined(__NR_renameat2) ++#define __NR_renameat2 276 ++#endif ++#if !defined(__NR_seccomp) ++#define __NR_seccomp 277 ++#endif ++#if !defined(__NR_getrandom) ++#define __NR_getrandom 278 ++#endif ++#if !defined(__NR_memfd_create) ++#define __NR_memfd_create 279 ++#endif ++#if !defined(__NR_bpf) ++#define __NR_bfp 280 ++#endif ++#if !defined(__NR_execveat) ++#define __NR_execveat 281 ++#endif ++#if !defined(__NR_userfaultfd) ++#define __NR_userfaultfd 282 ++#endif ++#if !defined(__NR_membarrier) ++#define __NR_membarrier 283 ++#endif ++#if !defined(__NR_mlock2) ++#define __NR_mlock2 284 ++#endif ++#if !defined(__NR_copy_file_range) ++#define __NR_copy_file_range 285 ++#endif ++#if !defined(__NR_preadv2) ++#define __NR_preadv2 286 ++#endif ++#if !defined(__NR_pwritev2) ++#define __NR_pwritev2 287 ++#endif ++#if !defined(__NR_pkey_mprotect) ++#define __NR_pkey_mprotect 288 ++#endif ++#if !defined(__NR_pkey_alloc) ++#define __NR_pkey_alloc 289 ++#endif ++#if !defined(__NR_pkey_free) ++#define __NR_pkey_free 290 ++#endif ++#if !defined(__NR_statx) ++#define __NR_statx 291 ++#endif ++#if !defined(__NR_io_pgetevents) ++#define __NR_io_pgetevents 292 ++#endif ++#if !defined(__NR_rseq) ++#define __NR_rseq 293 ++#endif ++#if !defined(__NR_clone3) ++#define __NR_clone3 435 ++#endif ++#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LOONGARCH64_LINUX_SYSCALLS_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc +@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::Eval + case __NR_sched_setscheduler: + case __NR_sysinfo: + case __NR_uname: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_readlink: + case __NR_stat: + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc +++++ src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc ++@@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const { ++ case __NR_sched_setscheduler: ++ case __NR_sysinfo: ++ case __NR_uname: ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_readlink: ++ case __NR_stat: ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc +@@ -70,7 +70,7 @@ ResultExpr GpuProcessPolicy::EvaluateSys + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR_ftruncate64: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__loongarch64) + case __NR_getdents: + #endif + case __NR_getdents64: +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc +++++ src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc ++@@ -70,7 +70,7 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const { ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) ++ case __NR_ftruncate64: ++ #endif ++-#if !defined(__aarch64__) +++#if !defined(__aarch64__) && !defined(__loongarch64) ++ case __NR_getdents: ++ #endif ++ case __NR_getdents64: +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/skia/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/skia/BUILD.gn +@@ -821,6 +821,8 @@ skia_source_set("skia_opts") { + sources = skia_opts.none_sources + } else if (current_cpu == "s390x") { + sources = skia_opts.none_sources ++ } else if (current_cpu == "loongarch64") { ++ sources = skia_opts.none_sources + } else { + assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp") + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/skia/BUILD.gn.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/skia/BUILD.gn +++++ src/3rdparty/chromium/skia/BUILD.gn ++@@ -821,6 +821,8 @@ skia_source_set("skia_opts") { ++ sources = skia_opts.none_sources ++ } else if (current_cpu == "s390x") { ++ sources = skia_opts.none_sources +++ } else if (current_cpu == "loongarch64") { +++ sources = skia_opts.none_sources ++ } else { ++ assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp") ++ } +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +@@ -66,6 +66,8 @@ void* GetProgramCounter(void* vuc) { + #elif defined(__x86_64__) + if (16 < ABSL_ARRAYSIZE(context->uc_mcontext.gregs)) + return reinterpret_cast(context->uc_mcontext.gregs[16]); ++#elif defined(__loongarch__) ++ return reinterpret_cast(context->uc_mcontext.__pc); + #else + #error "Undefined Architecture." + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc +++++ src/3rdparty/chromium/third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc ++@@ -66,6 +66,8 @@ void* GetProgramCounter(void* vuc) { ++ #elif defined(__x86_64__) ++ if (16 < ABSL_ARRAYSIZE(context->uc_mcontext.gregs)) ++ return reinterpret_cast(context->uc_mcontext.gregs[16]); +++#elif defined(__loongarch__) +++ return reinterpret_cast(context->uc_mcontext.__pc); ++ #else ++ #error "Undefined Architecture." ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/angle/gni/angle.gni ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/angle/gni/angle.gni +@@ -54,7 +54,7 @@ angle_data_dir = "angledata" + declare_args() { + if (current_cpu == "arm64" || current_cpu == "x64" || + current_cpu == "mips64el" || current_cpu == "s390x" || +- current_cpu == "ppc64") { ++ current_cpu == "ppc64" || current_cpu == "loongarch64") { + angle_64bit_current_cpu = true + } else if (current_cpu == "arm" || current_cpu == "x86" || + current_cpu == "mipsel" || current_cpu == "s390" || +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/angle/gni/angle.gni.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/angle/gni/angle.gni +++++ src/3rdparty/chromium/third_party/angle/gni/angle.gni ++@@ -54,7 +54,7 @@ angle_data_dir = "angledata" ++ declare_args() { ++ if (current_cpu == "arm64" || current_cpu == "x64" || ++ current_cpu == "mips64el" || current_cpu == "s390x" || ++- current_cpu == "ppc64") { +++ current_cpu == "ppc64" || current_cpu == "loongarch64") { ++ angle_64bit_current_cpu = true ++ } else if (current_cpu == "arm" || current_cpu == "x86" || ++ current_cpu == "mipsel" || current_cpu == "s390" || +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn +@@ -36,6 +36,8 @@ if (current_cpu == "x86" || current_cpu + sources = [ "SaveRegisters_mips.S" ] + } else if (current_cpu == "mips64el") { + sources = [ "SaveRegisters_mips64.S" ] ++ } else if (current_cpu == "loongarch64") { ++ sources = [ "SaveRegisters_loongarch64.S" ] + } else if (current_cpu == "ppc64") { + sources = [ "SaveRegisters_ppc64.S" ] + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn +++++ src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn ++@@ -36,6 +36,8 @@ if (current_cpu == "x86" || current_cpu == "x64") { ++ sources = [ "SaveRegisters_mips.S" ] ++ } else if (current_cpu == "mips64el") { ++ sources = [ "SaveRegisters_mips64.S" ] +++ } else if (current_cpu == "loongarch64") { +++ sources = [ "SaveRegisters_loongarch64.S" ] ++ } else if (current_cpu == "ppc64") { ++ sources = [ "SaveRegisters_ppc64.S" ] ++ } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_loongarch64.S +@@ -0,0 +1,41 @@ ++// Copyright 2014 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++/* ++ * typedef void (*PushAllRegistersCallback)(ThreadState*, intptr_t*); ++ * extern "C" void PushAllRegisters(ThreadState*, PushAllRegistersCallback) ++ */ ++ ++.type PushAllRegisters, %function ++.global PushAllRegisters ++.hidden PushAllRegisters ++PushAllRegisters: ++ // Push all callee-saves registers to get them ++ // on the stack for conservative stack scanning. ++ // Reserve space for callee-saved registers and return address. ++ addi.d $sp,$sp,-80 ++ // Save the callee-saved registers and the return address. ++ st.d $s0, $sp, 0 ++ st.d $s1, $sp, 8 ++ st.d $s2, $sp, 16 ++ st.d $s3, $sp, 24 ++ st.d $s4, $sp, 32 ++ st.d $s5, $sp, 40 ++ st.d $s6, $sp, 48 ++ st.d $s7, $sp, 56 ++ st.d $ra, $sp, 64 ++ // Note: the callee-saved floating point registers do not need to be ++ // copied to the stack, because fp registers never hold heap pointers ++ // and so do not need to be kept visible to the garbage collector. ++ // Pass the first argument untouched in a0 and the ++ // stack pointer to the callback. ++ ori $t7, $a1, 0 ++ ori $a1, $sp, 0 ++ jirl $ra, $t7, 0 ++ // Restore return address, adjust stack and return. ++ // Note: the copied registers do not need to be reloaded here, ++ // because they were preserved by the called routine. ++ ld.d $ra, $sp, 64 ++ addi.d $sp, $sp, 80 ++ jirl $r0, $ra, 0 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h +@@ -114,6 +114,9 @@ extern "C" { + #define OPENSSL_32_BIT + #elif defined(__myriad2__) + #define OPENSSL_32_BIT ++#elif defined(__loongarch__) && defined(__loongarch_lp64) ++#define OPENSSL_64_BIT ++#define OPENSSL_LOONGARCH64 + #else + // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, + // little-endian architectures. Functions will not produce the correct answer +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h +++++ src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h ++@@ -114,6 +114,9 @@ extern "C" { ++ #define OPENSSL_32_BIT ++ #elif defined(__myriad2__) ++ #define OPENSSL_32_BIT +++#elif defined(__loongarch__) && defined(__loongarch_lp64) +++#define OPENSSL_64_BIT +++#define OPENSSL_LOONGARCH64 ++ #else ++ // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, ++ // little-endian architectures. Functions will not produce the correct answer +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h +@@ -44,6 +44,8 @@ typedef MDRawContextARM RawContextCPU; + typedef MDRawContextARM64_Old RawContextCPU; + #elif defined(__mips__) + typedef MDRawContextMIPS RawContextCPU; ++#elif defined(__loongarch64) ++typedef MDRawContextLOONG64 RawContextCPU; + #else + #error "This code has not been ported to your platform yet." + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h ++@@ -44,6 +44,8 @@ typedef MDRawContextARM RawContextCPU; ++ typedef MDRawContextARM64_Old RawContextCPU; ++ #elif defined(__mips__) ++ typedef MDRawContextMIPS RawContextCPU; +++#elif defined(__loongarch64) +++typedef MDRawContextLOONG64 RawContextCPU; ++ #else ++ #error "This code has not been ported to your platform yet." ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc +@@ -279,6 +279,11 @@ void ThreadInfo::GetGeneralPurposeRegist + *gp_regs = mcontext.gregs; + if (size) + *size = sizeof(mcontext.gregs); ++#elif defined(__loongarch64) ++ if (gp_regs) ++ *gp_regs = &_gpregs; ++ if (size) ++ *size = sizeof(_gpregs); + #else + if (gp_regs) + *gp_regs = ®s; +@@ -294,6 +299,11 @@ void ThreadInfo::GetFloatingPointRegiste + *fp_regs = &mcontext.fpregs; + if (size) + *size = sizeof(mcontext.fpregs); ++#elif defined(__loongarch64) ++ if (fp_regs) ++ *fp_regs = &_fpregs; ++ if (size) ++ *size = sizeof(_fpregs); + #else + if (fp_regs) + *fp_regs = &fpregs; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc.rej +@@ -0,0 +1,26 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc ++@@ -279,6 +279,11 @@ void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) { ++ *gp_regs = mcontext.gregs; ++ if (size) ++ *size = sizeof(mcontext.gregs); +++#elif defined(__loongarch64) +++ if (gp_regs) +++ *gp_regs = &_gpregs; +++ if (size) +++ *size = sizeof(_gpregs); ++ #else ++ if (gp_regs) ++ *gp_regs = ®s; ++@@ -294,6 +299,11 @@ void ThreadInfo::GetFloatingPointRegisters(void** fp_regs, size_t* size) { ++ *fp_regs = &mcontext.fpregs; ++ if (size) ++ *size = sizeof(mcontext.fpregs); +++#elif defined(__loongarch64) +++ if (fp_regs) +++ *fp_regs = &_fpregs; +++ if (size) +++ *size = sizeof(_fpregs); ++ #else ++ if (fp_regs) ++ *fp_regs = &fpregs; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h +@@ -32,6 +32,9 @@ + + #include + #include ++#if defined(__loongarch64) ++#include ++#endif + + #include "client/linux/dump_writer_common/raw_context_cpu.h" + #include "common/memory_allocator.h" +@@ -71,6 +74,14 @@ struct ThreadInfo { + #elif defined(__mips__) + // Use the structure defined in . + mcontext_t mcontext; ++#elif defined(__loongarch64) ++ // Use the structure defined in . ++ struct user_pt_regs _gpregs; ++ int32_t uc_mctxflags; ++ int32_t fp_lp64_width; // 0: unknown, 1: fp, 2: lsx, 4: lasx ++ struct user_lasx_state _fpregs; ++ uint64_t fcc; ++ uint32_t fcsr; + #endif + + // Returns the instruction pointer (platform-dependent impl.). +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h.rej +@@ -0,0 +1,27 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h ++@@ -32,6 +32,9 @@ ++ ++ #include ++ #include +++#if defined(__loongarch64) +++#include +++#endif ++ ++ #include "client/linux/dump_writer_common/raw_context_cpu.h" ++ #include "common/memory_allocator.h" ++@@ -71,6 +74,14 @@ struct ThreadInfo { ++ #elif defined(__mips__) ++ // Use the structure defined in . ++ mcontext_t mcontext; +++#elif defined(__loongarch64) +++ // Use the structure defined in . +++ struct user_pt_regs _gpregs; +++ int32_t uc_mctxflags; +++ int32_t fp_lp64_width; // 0: unknown, 1: fp, 2: lsx, 4: lasx +++ struct user_lasx_state _fpregs; +++ uint64_t fcc; +++ uint32_t fcsr; ++ #endif ++ ++ // Returns the instruction pointer (platform-dependent impl.). +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc +@@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int + memcpy(&g_crash_context_.float_state, fp_ptr, + sizeof(g_crash_context_.float_state)); + } +-#elif !defined(__ARM_EABI__) && !defined(__mips__) ++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + // FP state is not part of user ABI on ARM Linux. + // In case of MIPS Linux FP state is already part of ucontext_t + // and 'float_state' is not a member of CrashContext. +@@ -471,6 +471,8 @@ bool ExceptionHandler::HandleSignal(int + sizeof(g_crash_context_.float_state)); + } + #endif ++// TODO:MT loongarch64 floating-point registers ++ + g_crash_context_.tid = syscall(__NR_gettid); + if (crash_handler_ != NULL) { + if (crash_handler_(&g_crash_context_, sizeof(g_crash_context_), +@@ -701,11 +703,13 @@ bool ExceptionHandler::WriteMinidump() { + } + #endif + +-#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && \ ++ !defined(__loongarch64) + // FPU state is not part of ARM EABI ucontext_t. + memcpy(&context.float_state, context.context.uc_mcontext.fpregs, + sizeof(context.float_state)); + #endif ++// TODO:MT loongarch64 floating-point registers + context.tid = sys_gettid(); + + // Add an exception stream to the minidump for better reporting. +@@ -726,6 +730,9 @@ bool ExceptionHandler::WriteMinidump() { + #elif defined(__mips__) + context.siginfo.si_addr = + reinterpret_cast(context.context.uc_mcontext.pc); ++#elif defined(__loongarch64) ++ context.siginfo.si_addr = ++ reinterpret_cast(context.context.uc_mcontext.__pc); + #else + #error "This code has not been ported to your platform yet." + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc.rej +@@ -0,0 +1,45 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc ++@@ -461,7 +461,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { ++ memcpy(&g_crash_context_.float_state, fp_ptr, ++ sizeof(g_crash_context_.float_state)); ++ } ++-#elif !defined(__ARM_EABI__) && !defined(__mips__) +++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ // FP state is not part of user ABI on ARM Linux. ++ // In case of MIPS Linux FP state is already part of ucontext_t ++ // and 'float_state' is not a member of CrashContext. ++@@ -471,6 +471,8 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { ++ sizeof(g_crash_context_.float_state)); ++ } ++ #endif +++// TODO:MT loongarch64 floating-point registers +++ ++ g_crash_context_.tid = syscall(__NR_gettid); ++ if (crash_handler_ != NULL) { ++ if (crash_handler_(&g_crash_context_, sizeof(g_crash_context_), ++@@ -701,11 +703,13 @@ bool ExceptionHandler::WriteMinidump() { ++ } ++ #endif ++ ++-#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && \ +++ !defined(__loongarch64) ++ // FPU state is not part of ARM EABI ucontext_t. ++ memcpy(&context.float_state, context.context.uc_mcontext.fpregs, ++ sizeof(context.float_state)); ++ #endif +++// TODO:MT loongarch64 floating-point registers ++ context.tid = sys_gettid(); ++ ++ // Add an exception stream to the minidump for better reporting. ++@@ -726,6 +730,9 @@ bool ExceptionHandler::WriteMinidump() { ++ #elif defined(__mips__) ++ context.siginfo.si_addr = ++ reinterpret_cast(context.context.uc_mcontext.pc); +++#elif defined(__loongarch64) +++ context.siginfo.si_addr = +++ reinterpret_cast(context.context.uc_mcontext.__pc); ++ #else ++ #error "This code has not been ported to your platform yet." ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h +@@ -192,7 +192,7 @@ class ExceptionHandler { + siginfo_t siginfo; + pid_t tid; // the crashing thread. + ucontext_t context; +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + // #ifdef this out because FP state is not part of user ABI for Linux ARM. + // In case of MIPS Linux FP state is already part of ucontext_t so + // 'float_state' is not required. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h ++@@ -192,7 +192,7 @@ class ExceptionHandler { ++ siginfo_t siginfo; ++ pid_t tid; // the crashing thread. ++ ucontext_t context; ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ // #ifdef this out because FP state is not part of user ABI for Linux ARM. ++ // In case of MIPS Linux FP state is already part of ucontext_t so ++ // 'float_state' is not required. +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc +@@ -138,7 +138,7 @@ class MicrodumpWriter { + const MicrodumpExtraInfo& microdump_extra_info, + LinuxDumper* dumper) + : ucontext_(context ? &context->context : NULL), +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + float_state_(context ? &context->float_state : NULL), + #endif + dumper_(dumper), +@@ -337,6 +337,8 @@ class MicrodumpWriter { + # else + # error "This mips ABI is currently not supported (n32)" + #endif ++#elif defined(__loongarch64) ++ const char kArch[] = "loongarch64"; + #else + #error "This code has not been ported to your platform yet" + #endif +@@ -409,7 +411,7 @@ class MicrodumpWriter { + void DumpCPUState() { + RawContextCPU cpu; + my_memset(&cpu, 0, sizeof(RawContextCPU)); +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); + #else + UContextReader::FillCPUContext(&cpu, ucontext_); +@@ -605,7 +607,7 @@ class MicrodumpWriter { + void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } + + const ucontext_t* const ucontext_; +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + const google_breakpad::fpstate_t* const float_state_; + #endif + LinuxDumper* dumper_; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc.rej +@@ -0,0 +1,38 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc ++@@ -138,7 +138,7 @@ class MicrodumpWriter { ++ const MicrodumpExtraInfo& microdump_extra_info, ++ LinuxDumper* dumper) ++ : ucontext_(context ? &context->context : NULL), ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ float_state_(context ? &context->float_state : NULL), ++ #endif ++ dumper_(dumper), ++@@ -337,6 +337,8 @@ class MicrodumpWriter { ++ # else ++ # error "This mips ABI is currently not supported (n32)" ++ #endif +++#elif defined(__loongarch64) +++ const char kArch[] = "loongarch64"; ++ #else ++ #error "This code has not been ported to your platform yet" ++ #endif ++@@ -409,7 +411,7 @@ class MicrodumpWriter { ++ void DumpCPUState() { ++ RawContextCPU cpu; ++ my_memset(&cpu, 0, sizeof(RawContextCPU)); ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); ++ #else ++ UContextReader::FillCPUContext(&cpu, ucontext_); ++@@ -605,7 +607,7 @@ class MicrodumpWriter { ++ void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } ++ ++ const ucontext_t* const ucontext_; ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ const google_breakpad::fpstate_t* const float_state_; ++ #endif ++ LinuxDumper* dumper_; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc +@@ -38,7 +38,7 @@ + #include + #include + #include +-#if defined(__mips__) && defined(__ANDROID__) ++#if defined(__mips__) && defined(__ANDROID__) || defined(__loongarch64) + // To get register definitions. + #include + #endif +@@ -112,6 +112,9 @@ bool LinuxCoreDumper::GetThreadInfoByInd + #elif defined(__mips__) + stack_pointer = + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); ++#elif defined(__loongarch64) ++ stack_pointer = ++ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); + #else + #error "This code hasn't been ported to your platform yet." + #endif +@@ -208,7 +211,13 @@ bool LinuxCoreDumper::EnumerateThreads() + info.mcontext.mdlo = status->pr_reg[EF_LO]; + info.mcontext.mdhi = status->pr_reg[EF_HI]; + info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; +-#else // __mips__ ++#elif defined(__loongarch64) ++ // TODO:MT ++ for (int i = LOONGARCH_EF_R0; i <= LOONGARCH_EF_R31; ++i) ++ info._gpregs.regs[i-LOONGARCH_EF_R0] = status->pr_reg[i]; ++ info._gpregs.csr_era = status->pr_reg[LOONGARCH_EF_CSR_ERA]; ++ info._gpregs.csr_badv = status->pr_reg[LOONGARCH_EF_CSR_BADV]; ++#else + memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); + #endif // __mips__ + if (first_thread) { +@@ -263,6 +272,7 @@ bool LinuxCoreDumper::EnumerateThreads() + break; + } + #if defined(__i386) || defined(__x86_64) ++ // TODO:MT FPU + case NT_FPREGSET: { + if (thread_infos_.empty()) + return false; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc.rej +@@ -0,0 +1,44 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc ++@@ -38,7 +38,7 @@ ++ #include ++ #include ++ #include ++-#if defined(__mips__) && defined(__ANDROID__) +++#if defined(__mips__) && defined(__ANDROID__) || defined(__loongarch64) ++ // To get register definitions. ++ #include ++ #endif ++@@ -112,6 +112,9 @@ bool LinuxCoreDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { ++ #elif defined(__mips__) ++ stack_pointer = ++ reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); +++#elif defined(__loongarch64) +++ stack_pointer = +++ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); ++ #else ++ #error "This code hasn't been ported to your platform yet." ++ #endif ++@@ -208,7 +211,13 @@ bool LinuxCoreDumper::EnumerateThreads() { ++ info.mcontext.mdlo = status->pr_reg[EF_LO]; ++ info.mcontext.mdhi = status->pr_reg[EF_HI]; ++ info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; ++-#else // __mips__ +++#elif defined(__loongarch64) +++ // TODO:MT +++ for (int i = LOONGARCH_EF_R0; i <= LOONGARCH_EF_R31; ++i) +++ info._gpregs.regs[i-LOONGARCH_EF_R0] = status->pr_reg[i]; +++ info._gpregs.csr_era = status->pr_reg[LOONGARCH_EF_CSR_ERA]; +++ info._gpregs.csr_badv = status->pr_reg[LOONGARCH_EF_CSR_BADV]; +++#else ++ memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); ++ #endif // __mips__ ++ if (first_thread) { ++@@ -263,6 +272,7 @@ bool LinuxCoreDumper::EnumerateThreads() { ++ break; ++ } ++ #if defined(__i386) || defined(__x86_64) +++ // TODO:MT FPU ++ case NT_FPREGSET: { ++ if (thread_infos_.empty()) ++ return false; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h +@@ -63,6 +63,7 @@ namespace google_breakpad { + (defined(__mips__) && _MIPS_SIM == _ABIO32) + typedef Elf32_auxv_t elf_aux_entry; + #elif defined(__x86_64) || defined(__aarch64__) || \ ++ defined(__loongarch64) || \ + (defined(__mips__) && _MIPS_SIM != _ABIO32) + typedef Elf64_auxv_t elf_aux_entry; + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h.rej +@@ -0,0 +1,10 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h ++@@ -63,6 +63,7 @@ namespace google_breakpad { ++ (defined(__mips__) && _MIPS_SIM == _ABIO32) ++ typedef Elf32_auxv_t elf_aux_entry; ++ #elif defined(__x86_64) || defined(__aarch64__) || \ +++ defined(__loongarch64) || \ ++ (defined(__mips__) && _MIPS_SIM != _ABIO32) ++ typedef Elf64_auxv_t elf_aux_entry; ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +@@ -162,6 +162,24 @@ bool LinuxPtraceDumper::ReadRegisterSet( + if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { + return false; + } ++ ++// TODO:MT ++#if defined(__loongarch64) ++ info->fp_lp64_width = 1; ++// user_fp_state *_fp_state = (struct user_fp_state*)io.iov_base; ++// info->fcc = _fp_state->fcc; ++// info->fcsr = _fp_state->fcsr; ++// ++// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LASX, (void*)&io) == -1) { ++// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LSX, (void*)&io) == -1) { ++// } else { ++// info->fp_lp64_width = 2; ++// } ++// } else { ++// info->fp_lp64_width = 4; ++// } ++#endif // defined(__loongarch64) ++ + return true; + #else + return false; +@@ -298,6 +316,9 @@ bool LinuxPtraceDumper::GetThreadInfoByI + #elif defined(__mips__) + stack_pointer = + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); ++#elif defined(__loongarch64) ++ stack_pointer = ++ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); + #else + #error "This code hasn't been ported to your platform yet." + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc.rej +@@ -0,0 +1,37 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc ++@@ -162,6 +162,24 @@ bool LinuxPtraceDumper::ReadRegisterSet(ThreadInfo* info, pid_t tid) ++ if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { ++ return false; ++ } +++ +++// TODO:MT +++#if defined(__loongarch64) +++ info->fp_lp64_width = 1; +++// user_fp_state *_fp_state = (struct user_fp_state*)io.iov_base; +++// info->fcc = _fp_state->fcc; +++// info->fcsr = _fp_state->fcsr; +++// +++// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LASX, (void*)&io) == -1) { +++// if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_LOONGARCH_LSX, (void*)&io) == -1) { +++// } else { +++// info->fp_lp64_width = 2; +++// } +++// } else { +++// info->fp_lp64_width = 4; +++// } +++#endif // defined(__loongarch64) +++ ++ return true; ++ #else ++ return false; ++@@ -298,6 +316,9 @@ bool LinuxPtraceDumper::GetThreadInfoByIndex(size_t index, ThreadInfo* info) { ++ #elif defined(__mips__) ++ stack_pointer = ++ reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); +++#elif defined(__loongarch64) +++ stack_pointer = +++ reinterpret_cast(info->_gpregs.regs[MD_CONTEXT_LOONG64_REG_SP]); ++ #else ++ #error "This code hasn't been ported to your platform yet." ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc +@@ -136,7 +136,7 @@ class MinidumpWriter { + : fd_(minidump_fd), + path_(minidump_path), + ucontext_(context ? &context->context : NULL), +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + float_state_(context ? &context->float_state : NULL), + #endif + dumper_(dumper), +@@ -468,7 +468,7 @@ class MinidumpWriter { + if (!cpu.Allocate()) + return false; + my_memset(cpu.get(), 0, sizeof(RawContextCPU)); +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); + #else + UContextReader::FillCPUContext(cpu.get(), ucontext_); +@@ -1205,6 +1205,68 @@ class MinidumpWriter { + + return true; + } ++#elif defined(__loongarch64) ++ bool WriteCPUInformation(MDRawSystemInfo* sys_info) { ++ // TODO:MT ++ struct CpuInfoEntry { ++ const char* info_name; ++ int value; ++ bool found; ++ } cpu_info_table[] = { ++ { "processor", -1, false }, ++ }; ++ ++ // processor_architecture should always be set, do this first ++ sys_info->processor_architecture = MD_CPU_ARCHITECTURE_LOONG64; ++ ++ const int fd = sys_open("/proc/cpuinfo", O_RDONLY, 0); ++ if (fd < 0) ++ return false; ++ ++ { ++ PageAllocator allocator; ++ ProcCpuInfoReader* const reader = new(allocator) ProcCpuInfoReader(fd); ++ const char* field; ++ while (reader->GetNextField(&field)) { ++ bool is_first_entry = true; ++ for (CpuInfoEntry& entry : cpu_info_table) { ++ if (!is_first_entry && entry.found) { ++ // except for the 'processor' field, ignore repeated values. ++ continue; ++ } ++ is_first_entry = false; ++ if (!my_strcmp(field, entry.info_name)) { ++ size_t value_len; ++ const char* value = reader->GetValueAndLen(&value_len); ++ if (value_len == 0) ++ continue; ++ ++ uintptr_t val; ++ if (my_read_decimal_ptr(&val, value) == value) ++ continue; ++ ++ entry.value = static_cast(val); ++ entry.found = true; ++ } ++ } ++ } ++ sys_close(fd); ++ } ++ // make sure we got everything we wanted ++ for (const CpuInfoEntry& entry : cpu_info_table) { ++ if (!entry.found) { ++ return false; ++ } ++ } ++ // cpu_info_table[0] holds the last cpu id listed in /proc/cpuinfo, ++ // assuming this is the highest id, change it to the number of CPUs ++ // by adding one. ++ cpu_info_table[0].value++; ++ ++ sys_info->number_of_processors = cpu_info_table[0].value; ++ ++ return true; ++ } + #else + # error "Unsupported CPU" + #endif +@@ -1333,7 +1395,7 @@ class MinidumpWriter { + const char* path_; // Path to the file where the minidum should be written. + + const ucontext_t* const ucontext_; // also from the signal handler +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + const google_breakpad::fpstate_t* const float_state_; // ditto + #endif + LinuxDumper* dumper_; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc.rej +@@ -0,0 +1,98 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc ++@@ -136,7 +136,7 @@ class MinidumpWriter { ++ : fd_(minidump_fd), ++ path_(minidump_path), ++ ucontext_(context ? &context->context : NULL), ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ float_state_(context ? &context->float_state : NULL), ++ #endif ++ dumper_(dumper), ++@@ -468,7 +468,7 @@ class MinidumpWriter { ++ if (!cpu.Allocate()) ++ return false; ++ my_memset(cpu.get(), 0, sizeof(RawContextCPU)); ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); ++ #else ++ UContextReader::FillCPUContext(cpu.get(), ucontext_); ++@@ -1205,6 +1205,68 @@ class MinidumpWriter { ++ ++ return true; ++ } +++#elif defined(__loongarch64) +++ bool WriteCPUInformation(MDRawSystemInfo* sys_info) { +++ // TODO:MT +++ struct CpuInfoEntry { +++ const char* info_name; +++ int value; +++ bool found; +++ } cpu_info_table[] = { +++ { "processor", -1, false }, +++ }; +++ +++ // processor_architecture should always be set, do this first +++ sys_info->processor_architecture = MD_CPU_ARCHITECTURE_LOONG64; +++ +++ const int fd = sys_open("/proc/cpuinfo", O_RDONLY, 0); +++ if (fd < 0) +++ return false; +++ +++ { +++ PageAllocator allocator; +++ ProcCpuInfoReader* const reader = new(allocator) ProcCpuInfoReader(fd); +++ const char* field; +++ while (reader->GetNextField(&field)) { +++ bool is_first_entry = true; +++ for (CpuInfoEntry& entry : cpu_info_table) { +++ if (!is_first_entry && entry.found) { +++ // except for the 'processor' field, ignore repeated values. +++ continue; +++ } +++ is_first_entry = false; +++ if (!my_strcmp(field, entry.info_name)) { +++ size_t value_len; +++ const char* value = reader->GetValueAndLen(&value_len); +++ if (value_len == 0) +++ continue; +++ +++ uintptr_t val; +++ if (my_read_decimal_ptr(&val, value) == value) +++ continue; +++ +++ entry.value = static_cast(val); +++ entry.found = true; +++ } +++ } +++ } +++ sys_close(fd); +++ } +++ // make sure we got everything we wanted +++ for (const CpuInfoEntry& entry : cpu_info_table) { +++ if (!entry.found) { +++ return false; +++ } +++ } +++ // cpu_info_table[0] holds the last cpu id listed in /proc/cpuinfo, +++ // assuming this is the highest id, change it to the number of CPUs +++ // by adding one. +++ cpu_info_table[0].value++; +++ +++ sys_info->number_of_processors = cpu_info_table[0].value; +++ +++ return true; +++ } ++ #else ++ # error "Unsupported CPU" ++ #endif ++@@ -1333,7 +1395,7 @@ class MinidumpWriter { ++ const char* path_; // Path to the file where the minidum should be written. ++ ++ const ucontext_t* const ucontext_; // also from the signal handler ++-#if !defined(__ARM_EABI__) && !defined(__mips__) +++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ const google_breakpad::fpstate_t* const float_state_; // ditto ++ #endif ++ LinuxDumper* dumper_; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h +@@ -48,7 +48,7 @@ class ExceptionHandler; + + #if defined(__aarch64__) + typedef struct fpsimd_context fpstate_t; +-#elif !defined(__ARM_EABI__) && !defined(__mips__) ++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) + typedef std::remove_pointer::type fpstate_t; + #endif + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h ++@@ -48,7 +48,7 @@ class ExceptionHandler; ++ ++ #if defined(__aarch64__) ++ typedef struct fpsimd_context fpstate_t; ++-#elif !defined(__ARM_EABI__) && !defined(__mips__) +++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__loongarch64) ++ typedef std::remove_pointer::type fpstate_t; ++ #endif ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc +@@ -65,6 +65,7 @@ bool MemoryMappedFile::Map(const char* p + } + + #if defined(__x86_64__) || defined(__aarch64__) || \ ++ defined(__loongarch64) || \ + (defined(__mips__) && _MIPS_SIM == _ABI64) + + struct kernel_stat st; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc.rej +@@ -0,0 +1,10 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc ++@@ -65,6 +65,7 @@ bool MemoryMappedFile::Map(const char* path, size_t offset) { ++ } ++ ++ #if defined(__x86_64__) || defined(__aarch64__) || \ +++ defined(__loongarch64) || \ ++ (defined(__mips__) && _MIPS_SIM == _ABI64) ++ ++ struct kernel_stat st; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_loong64.h +@@ -0,0 +1,60 @@ ++#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ ++#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ ++ ++#define MD_CONTEXT_LOONG64_GPR_COUNT 32 ++#define MD_CONTEXT_LOONG64_FPRVR_COUNT 32 ++ ++#define FPR_LP64_WIDTH 1 ++#define LSX_LP64_WIDTH 2 ++#define LASX_LP64_WIDTH 4 ++ ++union user_fpr_vr_regs_union { ++ uint64_t fpregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * FPR_LP64_WIDTH]; ++ uint64_t lsxregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * LSX_LP64_WIDTH]; ++ uint64_t lasxregs[MD_CONTEXT_LOONG64_FPRVR_COUNT * LASX_LP64_WIDTH]; ++}; ++typedef union user_fpr_vr_regs_union MDFPRVRSaveAreaLOONG64; ++ ++typedef struct { ++ uint32_t context_flags; ++ ++ uint32_t flags; ++ uint64_t gregs[MD_CONTEXT_LOONG64_GPR_COUNT]; ++ uint64_t pc; // exception return address(ERA) ++ uint64_t badvaddr; // bad virtual address(BADV) ++ uint64_t reserved[11]; ++ ++ MDFPRVRSaveAreaLOONG64 fprvr_save; ++ uint64_t fcc; // condition flag register ++ uint32_t fcsr; // floating-point control and status register ++ ++ // TODO:MT add lbt registers ++} MDRawContextLOONG64; ++ ++/* Indices into __gregs for registers with a dedicated or conventional ++ * purpose. ++ * ++ * 32 64-bit integer registers, r0..r31. ++ * Note the following fixed uses: ++ * r1 is the return address. ++ * r3 is the stack pointer. ++ * r22 is the frame pointer. ++ */ ++enum MDLOONG64RegisterNumbers { ++ MD_CONTEXT_LOONG64_REG_RA = 1, ++ MD_CONTEXT_LOONG64_REG_SP = 3, ++ MD_CONTEXT_LOONG64_REG_FP = 22 ++}; ++ ++ ++ /* For (MDRawContextLOONG64).context_flags. These values indicate the type of ++ * context stored in the structure. MD_CONTEXT_LOONG64 is Breakpad-defined. Its ++ * value was chosen to avoid likely conflicts with MD_CONTEXT_* for other ++ * CPUs. */ ++#define MD_CONTEXT_LOONG64 0x08000000 ++#define MD_CONTEXT_LOONG64_GPR (MD_CONTEXT_LOONG64 | 0x00000001) ++#define MD_CONTEXT_LOONG64_FPR (MD_CONTEXT_LOONG64 | 0x00000002) ++#define MD_CONTEXT_LOONG64_LSX (MD_CONTEXT_LOONG64 | 0x00000004) ++#define MD_CONTEXT_LOONG64_LASX (MD_CONTEXT_LOONG64 | 0x00000008) ++ ++#endif // GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_LOONG64_H__ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h +@@ -115,6 +115,7 @@ typedef struct { + #include "minidump_cpu_amd64.h" + #include "minidump_cpu_arm.h" + #include "minidump_cpu_arm64.h" ++#include "minidump_cpu_loong64.h" + #include "minidump_cpu_mips.h" + #include "minidump_cpu_ppc.h" + #include "minidump_cpu_ppc64.h" +@@ -660,6 +661,7 @@ typedef enum { + MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */ + MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */ + MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */ ++ MD_CPU_ARCHITECTURE_LOONG64 = 0x8007, /* Breakpad-defined value for LOONG64 */ + MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */ + } MDCPUArchitecture; + +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h.rej +@@ -0,0 +1,18 @@ ++--- src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h +++++ src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h ++@@ -115,6 +115,7 @@ typedef struct { ++ #include "minidump_cpu_amd64.h" ++ #include "minidump_cpu_arm.h" ++ #include "minidump_cpu_arm64.h" +++#include "minidump_cpu_loong64.h" ++ #include "minidump_cpu_mips.h" ++ #include "minidump_cpu_ppc.h" ++ #include "minidump_cpu_ppc64.h" ++@@ -660,6 +661,7 @@ typedef enum { ++ MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */ ++ MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */ ++ MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */ +++ MD_CPU_ARCHITECTURE_LOONG64 = 0x8007, /* Breakpad-defined value for LOONG64 */ ++ MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */ ++ } MDCPUArchitecture; ++ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc +@@ -398,6 +398,129 @@ bool GetThreadArea64(pid_t tid, + return true; + } + ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.regs[2]; ++ return true; ++} ++ ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.regs[2]; ++ return true; ++} ++ ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.regs[2]; ++ return true; ++} ++ + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc.orig +@@ -0,0 +1,667 @@ ++// Copyright 2017 The Crashpad Authors. All rights reserved. ++// ++// 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 "util/linux/ptracer.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "base/logging.h" ++#include "build/build_config.h" ++#include "util/misc/from_pointer_cast.h" ++ ++#if defined(ARCH_CPU_X86_FAMILY) ++#include ++#endif ++ ++namespace crashpad { ++ ++namespace { ++ ++#if defined(ARCH_CPU_X86_FAMILY) ++ ++template ++bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) { ++ iovec iov; ++ iov.iov_base = dest; ++ iov.iov_len = sizeof(*dest); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(set), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(*dest)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(*dest); ++ return false; ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return GetRegisterSet(tid, NT_PRXFPREG, &context->f32.fxsave, can_log); ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.fxsave, can_log); ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ size_t index = (context.t32.xgs & 0xffff) >> 3; ++ user_desc desc; ++ if (ptrace( ++ PTRACE_GET_THREAD_AREA, tid, reinterpret_cast(index), &desc) != ++ 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ ++ *address = desc.base_addr; ++ return true; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.fs_base; ++ return true; ++} ++ ++#elif defined(ARCH_CPU_ARM_FAMILY) ++ ++#if defined(ARCH_CPU_ARMEL) ++// PTRACE_GETREGSET, introduced in Linux 2.6.34 (2225a122ae26), requires kernel ++// support enabled by HAVE_ARCH_TRACEHOOK. This has been set for x86 (including ++// x86_64) since Linux 2.6.28 (99bbc4b1e677a), but for ARM only since ++// Linux 3.5.0 (0693bf68148c4). Older Linux kernels support PTRACE_GETREGS, ++// PTRACE_GETFPREGS, and PTRACE_GETVFPREGS instead, which don't allow checking ++// the size of data copied. ++// ++// Fortunately, 64-bit ARM support only appeared in Linux 3.7.0, so if ++// PTRACE_GETREGSET fails on ARM with EIO, indicating that the request is not ++// supported, the kernel must be old enough that 64-bit ARM isn’t supported ++// either. ++// ++// TODO(mark): Once helpers to interpret the kernel version are available, add ++// a DCHECK to ensure that the kernel is older than 3.5. ++ ++bool GetGeneralPurposeRegistersLegacy(pid_t tid, ++ ThreadContext* context, ++ bool can_log) { ++ if (ptrace(PTRACE_GETREGS, tid, nullptr, &context->t32) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegistersLegacy(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ if (ptrace(PTRACE_GETFPREGS, tid, nullptr, &context->f32.fpregs) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ context->f32.have_fpregs = true; ++ ++ if (ptrace(PTRACE_GETVFPREGS, tid, nullptr, &context->f32.vfp) != 0) { ++ switch (errno) { ++ case EINVAL: ++ // These registers are optional on 32-bit ARM cpus ++ break; ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ } else { ++ context->f32.have_vfp = true; ++ } ++ return true; ++} ++#endif // ARCH_CPU_ARMEL ++ ++// Normally, the Linux kernel will copy out register sets according to the size ++// of the struct that contains them. Tracing a 32-bit ARM process running in ++// compatibility mode on a 64-bit ARM cpu will only copy data for the number of ++// registers times the size of the register, which won't include any possible ++// trailing padding in the struct. These are the sizes of the register data, not ++// including any possible padding. ++constexpr size_t kArmVfpSize = 32 * 8 + 4; ++ ++// Target is 32-bit ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ context->f32.have_fpregs = false; ++ context->f32.have_vfp = false; ++ ++ iovec iov; ++ iov.iov_base = &context->f32.fpregs; ++ iov.iov_len = sizeof(context->f32.fpregs); ++ if (ptrace( ++ PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != ++ 0) { ++ switch (errno) { ++#if defined(ARCH_CPU_ARMEL) ++ case EIO: ++ return GetFloatingPointRegistersLegacy(tid, context, can_log); ++#endif // ARCH_CPU_ARMEL ++ case EINVAL: ++ // A 32-bit process running on a 64-bit CPU doesn't have this register ++ // set. It should have a VFP register set instead. ++ break; ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ } else { ++ if (iov.iov_len != sizeof(context->f32.fpregs)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f32.fpregs); ++ return false; ++ } ++ context->f32.have_fpregs = true; ++ } ++ ++ iov.iov_base = &context->f32.vfp; ++ iov.iov_len = sizeof(context->f32.vfp); ++ if (ptrace( ++ PTRACE_GETREGSET, tid, reinterpret_cast(NT_ARM_VFP), &iov) != ++ 0) { ++ switch (errno) { ++ case EINVAL: ++ // VFP may not be present on 32-bit ARM cpus. ++ break; ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ } else { ++ if (iov.iov_len != kArmVfpSize && iov.iov_len != sizeof(context->f32.vfp)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f32.vfp); ++ return false; ++ } ++ context->f32.have_vfp = true; ++ } ++ ++ if (!(context->f32.have_fpregs || context->f32.have_vfp)) { ++ LOG_IF(ERROR, can_log) << "Unable to collect registers"; ++ return false; ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace( ++ PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != ++ 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++#if defined(ARCH_CPU_ARMEL) ++ void* result; ++ if (ptrace(PTRACE_GET_THREAD_AREA, tid, nullptr, &result) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ *address = FromPointerCast(result); ++ return true; ++#else ++ // TODO(jperaza): it doesn't look like there is a way for a 64-bit ARM process ++ // to get the thread area for a 32-bit ARM process with ptrace. ++ LOG_IF(WARNING, can_log) ++ << "64-bit ARM cannot trace TLS area for a 32-bit process"; ++ return false; ++#endif // ARCH_CPU_ARMEL ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = address; ++ iov.iov_len = sizeof(*address); ++ if (ptrace( ++ PTRACE_GETREGSET, tid, reinterpret_cast(NT_ARM_TLS), &iov) != ++ 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != 8) { ++ LOG_IF(ERROR, can_log) << "address size mismatch"; ++ return false; ++ } ++ return true; ++} ++#elif defined(ARCH_CPU_MIPS_FAMILY) ++// PTRACE_GETREGSET, introduced in Linux 2.6.34 (2225a122ae26), requires kernel ++// support enabled by HAVE_ARCH_TRACEHOOK. This has been set for x86 (including ++// x86_64) since Linux 2.6.28 (99bbc4b1e677a), but for MIPS only since ++// Linux 3.13 (c0ff3c53d4f99). Older Linux kernels support PTRACE_GETREGS, ++// and PTRACE_GETFPREGS instead, which don't allow checking the size of data ++// copied. Also, PTRACE_GETREGS assumes register size of 64 bits even for 32 bit ++// MIPS CPU (contrary to PTRACE_GETREGSET behavior), so we need buffer ++// structure here. ++ ++bool GetGeneralPurposeRegistersLegacy(pid_t tid, ++ ThreadContext* context, ++ bool can_log) { ++ ThreadContext context_buffer; ++ if (ptrace(PTRACE_GETREGS, tid, nullptr, &context_buffer.t64) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++// Bitness of target process can't be determined through ptrace here, so we ++// assume target process has the same as current process, making cross-bit ++// ptrace unsupported on MIPS for kernels older than 3.13 ++#if defined(ARCH_CPU_MIPSEL) ++#define THREAD_CONTEXT_FIELD t32 ++#elif defined(ARCH_CPU_MIPS64EL) ++#define THREAD_CONTEXT_FIELD t64 ++#endif ++ for (size_t reg = 0; reg < 32; ++reg) { ++ context->THREAD_CONTEXT_FIELD.regs[reg] = context_buffer.t64.regs[reg]; ++ } ++ context->THREAD_CONTEXT_FIELD.lo = context_buffer.t64.lo; ++ context->THREAD_CONTEXT_FIELD.hi = context_buffer.t64.hi; ++ context->THREAD_CONTEXT_FIELD.cp0_epc = context_buffer.t64.cp0_epc; ++ context->THREAD_CONTEXT_FIELD.cp0_badvaddr = context_buffer.t64.cp0_badvaddr; ++ context->THREAD_CONTEXT_FIELD.cp0_status = context_buffer.t64.cp0_status; ++ context->THREAD_CONTEXT_FIELD.cp0_cause = context_buffer.t64.cp0_cause; ++#undef THREAD_CONTEXT_FIELD ++ return true; ++} ++ ++bool GetFloatingPointRegistersLegacy(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ if (ptrace(PTRACE_GETFPREGS, tid, nullptr, &context->f32.fpregs) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = &context->f32.fpregs; ++ iov.iov_len = sizeof(context->f32.fpregs); ++ if (ptrace(PTRACE_GETFPREGS, tid, nullptr, &context->f32.fpregs) != 0) { ++ switch (errno) { ++ case EINVAL: ++ // fp may not be present ++ break; ++ case EIO: ++ return GetFloatingPointRegistersLegacy(tid, context, can_log); ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = &context->f64.fpregs; ++ iov.iov_len = sizeof(context->f64.fpregs); ++ if (ptrace(PTRACE_GETFPREGS, tid, nullptr, &context->f64.fpregs) != 0) { ++ switch (errno) { ++ case EINVAL: ++ // fp may not be present ++ break; ++ case EIO: ++ return GetFloatingPointRegistersLegacy(tid, context, can_log); ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ } ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++#if defined(ARCH_CPU_MIPSEL) ++ void* result; ++ if (ptrace(PTRACE_GET_THREAD_AREA, tid, nullptr, &result) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ *address = FromPointerCast(result); ++ return true; ++#else ++ return false; ++#endif ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ void* result; ++#if defined(ARCH_CPU_MIPSEL) ++ if (ptrace(PTRACE_GET_THREAD_AREA_3264, tid, nullptr, &result) != 0) { ++#else ++ if (ptrace(PTRACE_GET_THREAD_AREA, tid, nullptr, &result) != 0) { ++#endif ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ *address = FromPointerCast(result); ++ return true; ++} ++ ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.regs[2]; ++ return true; ++} ++ ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRFPREG), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(context->f64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << iov.iov_len ++ << " != " << sizeof(context->f64); ++ return false; ++ } ++ ++ return true; ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.regs[2]; ++ return true; ++} ++ ++#else ++#error Port. ++#endif // ARCH_CPU_X86_FAMILY ++ ++size_t GetGeneralPurposeRegistersAndLength(pid_t tid, ++ ThreadContext* context, ++ bool can_log) { ++ iovec iov; ++ iov.iov_base = context; ++ iov.iov_len = sizeof(*context); ++ if (ptrace( ++ PTRACE_GETREGSET, tid, reinterpret_cast(NT_PRSTATUS), &iov) != ++ 0) { ++ switch (errno) { ++#if defined(ARCH_CPU_ARMEL) || defined(ARCH_CPU_MIPS_FAMILY) ++ case EIO: ++ return GetGeneralPurposeRegistersLegacy(tid, context, can_log) ++ ? sizeof(context->t32) ++ : 0; ++#endif // ARCH_CPU_ARMEL ++ default: ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return 0; ++ } ++ } ++ return iov.iov_len; ++} ++ ++bool GetGeneralPurposeRegisters32(pid_t tid, ++ ThreadContext* context, ++ bool can_log) { ++ size_t length = GetGeneralPurposeRegistersAndLength(tid, context, can_log); ++ if (length != sizeof(context->t32)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << length ++ << " != " << sizeof(context->t32); ++ return false; ++ } ++ return true; ++} ++ ++bool GetGeneralPurposeRegisters64(pid_t tid, ++ ThreadContext* context, ++ bool can_log) { ++ size_t length = GetGeneralPurposeRegistersAndLength(tid, context, can_log); ++ if (length != sizeof(context->t64)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size " << length ++ << " != " << sizeof(context->t64); ++ return false; ++ } ++ return true; ++} ++ ++} // namespace ++ ++Ptracer::Ptracer(bool can_log) ++ : is_64_bit_(false), can_log_(can_log), initialized_() {} ++ ++Ptracer::Ptracer(bool is_64_bit, bool can_log) ++ : is_64_bit_(is_64_bit), can_log_(can_log), initialized_() { ++ INITIALIZATION_STATE_SET_INITIALIZING(initialized_); ++ INITIALIZATION_STATE_SET_VALID(initialized_); ++} ++ ++Ptracer::~Ptracer() {} ++ ++bool Ptracer::Initialize(pid_t pid) { ++ INITIALIZATION_STATE_SET_INITIALIZING(initialized_); ++ ++ ThreadContext context; ++ size_t length = GetGeneralPurposeRegistersAndLength(pid, &context, can_log_); ++ if (length == sizeof(context.t64)) { ++ is_64_bit_ = true; ++ } else if (length == sizeof(context.t32)) { ++ is_64_bit_ = false; ++ } else { ++ LOG_IF(ERROR, can_log_) ++ << "Unexpected registers size " << length ++ << " != " << sizeof(context.t64) << ", " << sizeof(context.t32); ++ return false; ++ } ++ ++ INITIALIZATION_STATE_SET_VALID(initialized_); ++ return true; ++} ++ ++bool Ptracer::Is64Bit() { ++ INITIALIZATION_STATE_DCHECK_VALID(initialized_); ++ return is_64_bit_; ++} ++ ++bool Ptracer::GetThreadInfo(pid_t tid, ThreadInfo* info) { ++ INITIALIZATION_STATE_DCHECK_VALID(initialized_); ++ ++ if (is_64_bit_) { ++ return GetGeneralPurposeRegisters64(tid, &info->thread_context, can_log_) && ++ GetFloatingPointRegisters64(tid, &info->float_context, can_log_) && ++ GetThreadArea64(tid, ++ info->thread_context, ++ &info->thread_specific_data_address, ++ can_log_); ++ } ++ ++ return GetGeneralPurposeRegisters32(tid, &info->thread_context, can_log_) && ++ GetFloatingPointRegisters32(tid, &info->float_context, can_log_) && ++ GetThreadArea32(tid, ++ info->thread_context, ++ &info->thread_specific_data_address, ++ can_log_); ++} ++ ++ssize_t Ptracer::ReadUpTo(pid_t pid, ++ LinuxVMAddress address, ++ size_t size, ++ char* buffer) { ++ size_t bytes_read = 0; ++ while (size > 0) { ++ errno = 0; ++ ++ if (size >= sizeof(long)) { ++ *reinterpret_cast(buffer) = ++ ptrace(PTRACE_PEEKDATA, pid, address, nullptr); ++ ++ if (errno == EIO) { ++ ssize_t last_bytes = ReadLastBytes(pid, address, size, buffer); ++ return last_bytes >= 0 ? bytes_read + last_bytes : -1; ++ } ++ ++ if (errno != 0) { ++ PLOG_IF(ERROR, can_log_) << "ptrace"; ++ return -1; ++ } ++ ++ size -= sizeof(long); ++ buffer += sizeof(long); ++ address += sizeof(long); ++ bytes_read += sizeof(long); ++ } else { ++ long word = ptrace(PTRACE_PEEKDATA, pid, address, nullptr); ++ ++ if (errno == 0) { ++ memcpy(buffer, reinterpret_cast(&word), size); ++ return bytes_read + size; ++ } ++ ++ if (errno == EIO) { ++ ssize_t last_bytes = ReadLastBytes(pid, address, size, buffer); ++ return last_bytes >= 0 ? bytes_read + last_bytes : -1; ++ } ++ ++ PLOG_IF(ERROR, can_log_); ++ return -1; ++ } ++ } ++ ++ return bytes_read; ++} ++ ++// Handles an EIO by reading at most size bytes from address into buffer if ++// address was within a word of a possible page boundary, by aligning to read ++// the last word of the page and extracting the desired bytes. ++ssize_t Ptracer::ReadLastBytes(pid_t pid, ++ LinuxVMAddress address, ++ size_t size, ++ char* buffer) { ++ LinuxVMAddress aligned = ((address + 4095) & ~4095) - sizeof(long); ++ if (aligned >= address || aligned == address - sizeof(long)) { ++ PLOG_IF(ERROR, can_log_) << "ptrace"; ++ return -1; ++ } ++ DCHECK_GT(aligned, address - sizeof(long)); ++ ++ errno = 0; ++ long word = ptrace(PTRACE_PEEKDATA, pid, aligned, nullptr); ++ if (errno != 0) { ++ PLOG_IF(ERROR, can_log_) << "ptrace"; ++ return -1; ++ } ++ ++ size_t bytes_read = address - aligned; ++ size_t last_bytes = std::min(sizeof(long) - bytes_read, size); ++ memcpy(buffer, reinterpret_cast(&word) + bytes_read, last_bytes); ++ return last_bytes; ++} ++ ++} // namespace crashpad +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h +@@ -79,6 +79,8 @@ union ThreadContext { + uint32_t cp0_status; + uint32_t cp0_cause; + uint32_t padding1_; ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // nothing + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -132,12 +134,20 @@ union ThreadContext { + uint64_t cp0_badvaddr; + uint64_t cp0_status; + uint64_t cp0_cause; ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // Reflects user_regs_struct in sys/user.h ++ uint64_t regs[32]; ++ uint64_t orig_a0; ++ uint64_t csr_era; ++ uint64_t csr_badv; ++ uint64_t reserved[10]; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY + } t64; + +-#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) ++#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) || \ ++ defined(ARCH_CPU_LOONGARCH_FAMILY) + using NativeThreadContext = user_regs_struct; + #elif defined(ARCH_CPU_ARMEL) + using NativeThreadContext = user_regs; +@@ -145,7 +155,7 @@ union ThreadContext { + // No appropriate NativeThreadsContext type available for MIPS + #else + #error Port. +-#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 ++#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 || ARCH_CPU_LOONGARCH_FAMILY + + #if !defined(ARCH_CPU_MIPS_FAMILY) + #if defined(ARCH_CPU_32_BITS) +@@ -218,6 +228,8 @@ union FloatContext { + } fpregs[32]; + uint32_t fpcsr; + uint32_t fpu_id; ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++ // nothing + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -252,6 +264,10 @@ union FloatContext { + double fpregs[32]; + uint32_t fpcsr; + uint32_t fpu_id; ++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) ++ uint64_t fvregs[32*4]; ++ uint64_t fcc; ++ uint32_t fcsr; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -278,8 +294,8 @@ union FloatContext { + #endif + #elif defined(ARCH_CPU_ARM64) + static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch"); +-#elif defined(ARCH_CPU_MIPS_FAMILY) +-// No appropriate floating point context native type for available MIPS. ++#elif defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) ++// No appropriate floating point context native type for available MIPS and LOONGARCH. + #else + #error Port. + #endif // ARCH_CPU_X86 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h.rej +@@ -0,0 +1,73 @@ ++--- src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h +++++ src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h ++@@ -79,6 +79,8 @@ union ThreadContext { ++ uint32_t cp0_status; ++ uint32_t cp0_cause; ++ uint32_t padding1_; +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) +++ // nothing ++ #else ++ #error Port. ++ #endif // ARCH_CPU_X86_FAMILY ++@@ -132,12 +134,20 @@ union ThreadContext { ++ uint64_t cp0_badvaddr; ++ uint64_t cp0_status; ++ uint64_t cp0_cause; +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) +++ // Reflects user_regs_struct in sys/user.h +++ uint64_t regs[32]; +++ uint64_t orig_a0; +++ uint64_t csr_era; +++ uint64_t csr_badv; +++ uint64_t reserved[10]; ++ #else ++ #error Port. ++ #endif // ARCH_CPU_X86_FAMILY ++ } t64; ++ ++-#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) +++#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64) || \ +++ defined(ARCH_CPU_LOONGARCH_FAMILY) ++ using NativeThreadContext = user_regs_struct; ++ #elif defined(ARCH_CPU_ARMEL) ++ using NativeThreadContext = user_regs; ++@@ -145,7 +155,7 @@ union ThreadContext { ++ // No appropriate NativeThreadsContext type available for MIPS ++ #else ++ #error Port. ++-#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 +++#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 || ARCH_CPU_LOONGARCH_FAMILY ++ ++ #if !defined(ARCH_CPU_MIPS_FAMILY) ++ #if defined(ARCH_CPU_32_BITS) ++@@ -218,6 +228,8 @@ union FloatContext { ++ } fpregs[32]; ++ uint32_t fpcsr; ++ uint32_t fpu_id; +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) +++ // nothing ++ #else ++ #error Port. ++ #endif // ARCH_CPU_X86_FAMILY ++@@ -252,6 +264,10 @@ union FloatContext { ++ double fpregs[32]; ++ uint32_t fpcsr; ++ uint32_t fpu_id; +++#elif defined(ARCH_CPU_LOONGARCH_FAMILY) +++ uint64_t fvregs[32*4]; +++ uint64_t fcc; +++ uint32_t fcsr; ++ #else ++ #error Port. ++ #endif // ARCH_CPU_X86_FAMILY ++@@ -278,8 +294,8 @@ union FloatContext { ++ #endif ++ #elif defined(ARCH_CPU_ARM64) ++ static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch"); ++-#elif defined(ARCH_CPU_MIPS_FAMILY) ++-// No appropriate floating point context native type for available MIPS. +++#elif defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_LOONGARCH_FAMILY) +++// No appropriate floating point context native type for available MIPS and LOONGARCH. ++ #else ++ #error Port. ++ #endif // ARCH_CPU_X86 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/dav1d/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/dav1d/BUILD.gn +@@ -18,8 +18,12 @@ if (is_win) { + "Only Linux X64 MSAN is supported") + platform_config_root = "config/linux-noasm/$current_cpu" + } else { +- # Linux configuration files seem to work on Mac, so just reuse them. +- platform_config_root = "config/linux/$current_cpu" ++ if (current_cpu == "loongarch64") { ++ platform_config_root = "config/linux-noasm/$current_cpu" ++ } else { ++ # Linux configuration files seem to work on Mac, so just reuse them. ++ platform_config_root = "config/linux/$current_cpu" ++ } + } + + # Clang LTO doesn't respect stack alignment and clang-cl doesn't support setting +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/dav1d/BUILD.gn.rej +@@ -0,0 +1,17 @@ ++--- src/3rdparty/chromium/third_party/dav1d/BUILD.gn +++++ src/3rdparty/chromium/third_party/dav1d/BUILD.gn ++@@ -18,8 +18,12 @@ if (is_win) { ++ "Only Linux X64 MSAN is supported") ++ platform_config_root = "config/linux-noasm/$current_cpu" ++ } else { ++- # Linux configuration files seem to work on Mac, so just reuse them. ++- platform_config_root = "config/linux/$current_cpu" +++ if (current_cpu == "loongarch64") { +++ platform_config_root = "config/linux-noasm/$current_cpu" +++ } else { +++ # Linux configuration files seem to work on Mac, so just reuse them. +++ platform_config_root = "config/linux/$current_cpu" +++ } ++ } ++ ++ # Clang LTO doesn't respect stack alignment and clang-cl doesn't support setting +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/dav1d/config/linux-noasm/loongarch64/config.h +@@ -0,0 +1,38 @@ ++/* ++ * Autogenerated by the Meson build system. ++ * Do not edit, your changes will be lost. ++ */ ++ ++#pragma once ++ ++#define ARCH_LOONGARCH 1 ++ ++#define ARCH_AARCH64 0 ++ ++#define ARCH_ARM 0 ++ ++#define ARCH_PPC64LE 0 ++ ++#define ARCH_X86 0 ++ ++#define ARCH_X86_32 0 ++ ++#define ARCH_X86_64 0 ++ ++#define CONFIG_16BPC 1 ++ ++#define CONFIG_8BPC 1 ++ ++// #define CONFIG_LOG 1 -- Logging is controlled by Chromium ++ ++#define ENDIANNESS_BIG 0 ++ ++#define HAVE_ASM 0 ++ ++#define HAVE_CLOCK_GETTIME 1 ++ ++#define HAVE_DLSYM 1 ++ ++#define HAVE_POSIX_MEMALIGN 1 ++ ++#define HAVE_UNISTD_H 1 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/config.h +@@ -0,0 +1,2626 @@ ++/* Automatically generated by configure - do not modify! */ ++#ifndef FFMPEG_CONFIG_H ++#define FFMPEG_CONFIG_H ++/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/home/loongson/mt/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.15+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=loongarch64 --enable-pic --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */ ++#define FFMPEG_LICENSE "LGPL version 2.1 or later" ++#define CONFIG_THIS_YEAR 2020 ++#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" ++#define AVCONV_DATADIR "/usr/local/share/ffmpeg" ++#define CC_IDENT "gcc 13 (Debian 13.2.0-9)" ++#define av_restrict restrict ++#define EXTERN_PREFIX "" ++#define EXTERN_ASM ++#define BUILDSUF "" ++#define SLIBSUF ".so" ++#define HAVE_MMX2 HAVE_MMXEXT ++#define SWS_MAX_FILTER_SIZE 256 ++#define ARCH_AARCH64 0 ++#define ARCH_ALPHA 0 ++#define ARCH_ARM 0 ++#define ARCH_AVR32 0 ++#define ARCH_AVR32_AP 0 ++#define ARCH_AVR32_UC 0 ++#define ARCH_BFIN 0 ++#define ARCH_IA64 0 ++#define ARCH_LOONGARCH64 1 ++#define ARCH_M68K 0 ++#define ARCH_MIPS 0 ++#define ARCH_MIPS64 0 ++#define ARCH_PARISC 0 ++#define ARCH_PPC 0 ++#define ARCH_PPC64 0 ++#define ARCH_S390 0 ++#define ARCH_SH4 0 ++#define ARCH_SPARC 0 ++#define ARCH_SPARC64 0 ++#define ARCH_TILEGX 0 ++#define ARCH_TILEPRO 0 ++#define ARCH_TOMI 0 ++#define ARCH_X86 0 ++#define ARCH_X86_32 0 ++#define ARCH_X86_64 0 ++#define HAVE_ARMV5TE 0 ++#define HAVE_ARMV6 0 ++#define HAVE_ARMV6T2 0 ++#define HAVE_ARMV8 0 ++#define HAVE_NEON 0 ++#define HAVE_VFP 0 ++#define HAVE_VFPV3 0 ++#define HAVE_SETEND 0 ++#define HAVE_ALTIVEC 0 ++#define HAVE_DCBZL 0 ++#define HAVE_LDBRX 0 ++#define HAVE_POWER8 0 ++#define HAVE_PPC4XX 0 ++#define HAVE_VSX 0 ++#define HAVE_AESNI 0 ++#define HAVE_AMD3DNOW 0 ++#define HAVE_AMD3DNOWEXT 0 ++#define HAVE_AVX 0 ++#define HAVE_AVX2 0 ++#define HAVE_AVX512 0 ++#define HAVE_FMA3 0 ++#define HAVE_FMA4 0 ++#define HAVE_MMX 0 ++#define HAVE_MMXEXT 0 ++#define HAVE_SSE 0 ++#define HAVE_SSE2 0 ++#define HAVE_SSE3 0 ++#define HAVE_SSE4 0 ++#define HAVE_SSE42 0 ++#define HAVE_SSSE3 0 ++#define HAVE_XOP 0 ++#define HAVE_CPUNOP 0 ++#define HAVE_I686 0 ++#define HAVE_MIPSFPU 0 ++#define HAVE_MIPS32R2 0 ++#define HAVE_MIPS32R5 0 ++#define HAVE_MIPS64R2 0 ++#define HAVE_MIPS32R6 0 ++#define HAVE_MIPS64R6 0 ++#define HAVE_MIPSDSP 0 ++#define HAVE_MIPSDSPR2 0 ++#define HAVE_MSA 0 ++#define HAVE_MSA2 0 ++#define HAVE_LOONGSON2 0 ++#define HAVE_LOONGSON3 0 ++#define HAVE_MMI 0 ++#define HAVE_ARMV5TE_EXTERNAL 0 ++#define HAVE_ARMV6_EXTERNAL 0 ++#define HAVE_ARMV6T2_EXTERNAL 0 ++#define HAVE_ARMV8_EXTERNAL 0 ++#define HAVE_NEON_EXTERNAL 0 ++#define HAVE_VFP_EXTERNAL 0 ++#define HAVE_VFPV3_EXTERNAL 0 ++#define HAVE_SETEND_EXTERNAL 0 ++#define HAVE_ALTIVEC_EXTERNAL 0 ++#define HAVE_DCBZL_EXTERNAL 0 ++#define HAVE_LDBRX_EXTERNAL 0 ++#define HAVE_POWER8_EXTERNAL 0 ++#define HAVE_PPC4XX_EXTERNAL 0 ++#define HAVE_VSX_EXTERNAL 0 ++#define HAVE_AESNI_EXTERNAL 0 ++#define HAVE_AMD3DNOW_EXTERNAL 0 ++#define HAVE_AMD3DNOWEXT_EXTERNAL 0 ++#define HAVE_AVX_EXTERNAL 0 ++#define HAVE_AVX2_EXTERNAL 0 ++#define HAVE_AVX512_EXTERNAL 0 ++#define HAVE_FMA3_EXTERNAL 0 ++#define HAVE_FMA4_EXTERNAL 0 ++#define HAVE_MMX_EXTERNAL 0 ++#define HAVE_MMXEXT_EXTERNAL 0 ++#define HAVE_SSE_EXTERNAL 0 ++#define HAVE_SSE2_EXTERNAL 0 ++#define HAVE_SSE3_EXTERNAL 0 ++#define HAVE_SSE4_EXTERNAL 0 ++#define HAVE_SSE42_EXTERNAL 0 ++#define HAVE_SSSE3_EXTERNAL 0 ++#define HAVE_XOP_EXTERNAL 0 ++#define HAVE_CPUNOP_EXTERNAL 0 ++#define HAVE_I686_EXTERNAL 0 ++#define HAVE_MIPSFPU_EXTERNAL 0 ++#define HAVE_MIPS32R2_EXTERNAL 0 ++#define HAVE_MIPS32R5_EXTERNAL 0 ++#define HAVE_MIPS64R2_EXTERNAL 0 ++#define HAVE_MIPS32R6_EXTERNAL 0 ++#define HAVE_MIPS64R6_EXTERNAL 0 ++#define HAVE_MIPSDSP_EXTERNAL 0 ++#define HAVE_MIPSDSPR2_EXTERNAL 0 ++#define HAVE_MSA_EXTERNAL 0 ++#define HAVE_MSA2_EXTERNAL 0 ++#define HAVE_LOONGSON2_EXTERNAL 0 ++#define HAVE_LOONGSON3_EXTERNAL 0 ++#define HAVE_MMI_EXTERNAL 0 ++#define HAVE_ARMV5TE_INLINE 0 ++#define HAVE_ARMV6_INLINE 0 ++#define HAVE_ARMV6T2_INLINE 0 ++#define HAVE_ARMV8_INLINE 0 ++#define HAVE_NEON_INLINE 0 ++#define HAVE_VFP_INLINE 0 ++#define HAVE_VFPV3_INLINE 0 ++#define HAVE_SETEND_INLINE 0 ++#define HAVE_ALTIVEC_INLINE 0 ++#define HAVE_DCBZL_INLINE 0 ++#define HAVE_LDBRX_INLINE 0 ++#define HAVE_POWER8_INLINE 0 ++#define HAVE_PPC4XX_INLINE 0 ++#define HAVE_VSX_INLINE 0 ++#define HAVE_AESNI_INLINE 0 ++#define HAVE_AMD3DNOW_INLINE 0 ++#define HAVE_AMD3DNOWEXT_INLINE 0 ++#define HAVE_AVX_INLINE 0 ++#define HAVE_AVX2_INLINE 0 ++#define HAVE_AVX512_INLINE 0 ++#define HAVE_FMA3_INLINE 0 ++#define HAVE_FMA4_INLINE 0 ++#define HAVE_MMX_INLINE 0 ++#define HAVE_MMXEXT_INLINE 0 ++#define HAVE_SSE_INLINE 0 ++#define HAVE_SSE2_INLINE 0 ++#define HAVE_SSE3_INLINE 0 ++#define HAVE_SSE4_INLINE 0 ++#define HAVE_SSE42_INLINE 0 ++#define HAVE_SSSE3_INLINE 0 ++#define HAVE_XOP_INLINE 0 ++#define HAVE_CPUNOP_INLINE 0 ++#define HAVE_I686_INLINE 0 ++#define HAVE_MIPSFPU_INLINE 0 ++#define HAVE_MIPS32R2_INLINE 0 ++#define HAVE_MIPS32R5_INLINE 0 ++#define HAVE_MIPS64R2_INLINE 0 ++#define HAVE_MIPS32R6_INLINE 0 ++#define HAVE_MIPS64R6_INLINE 0 ++#define HAVE_MIPSDSP_INLINE 0 ++#define HAVE_MIPSDSPR2_INLINE 0 ++#define HAVE_MSA_INLINE 0 ++#define HAVE_MSA2_INLINE 0 ++#define HAVE_LOONGSON2_INLINE 0 ++#define HAVE_LOONGSON3_INLINE 0 ++#define HAVE_MMI_INLINE 0 ++#define HAVE_ALIGNED_STACK 1 ++#define HAVE_FAST_64BIT 1 ++#define HAVE_FAST_CLZ 1 ++#define HAVE_FAST_CMOV 0 ++#define HAVE_LOCAL_ALIGNED 0 ++#define HAVE_SIMD_ALIGN_16 0 ++#define HAVE_SIMD_ALIGN_32 0 ++#define HAVE_SIMD_ALIGN_64 0 ++#define HAVE_ATOMIC_CAS_PTR 0 ++#define HAVE_MACHINE_RW_BARRIER 0 ++#define HAVE_MEMORYBARRIER 0 ++#define HAVE_MM_EMPTY 0 ++#define HAVE_RDTSC 0 ++#define HAVE_SEM_TIMEDWAIT 1 ++#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 ++#define HAVE_CABS 0 ++#define HAVE_CEXP 0 ++#define HAVE_INLINE_ASM 1 ++#define HAVE_SYMVER 0 ++#define HAVE_X86ASM 0 ++#define HAVE_BIGENDIAN 0 ++#define HAVE_FAST_UNALIGNED 1 ++#define HAVE_ARPA_INET_H 0 ++#define HAVE_ASM_TYPES_H 1 ++#define HAVE_CDIO_PARANOIA_H 0 ++#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 ++#define HAVE_CUDA_H 0 ++#define HAVE_DISPATCH_DISPATCH_H 0 ++#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 ++#define HAVE_DEV_IC_BT8XX_H 0 ++#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 ++#define HAVE_DIRECT_H 0 ++#define HAVE_DIRENT_H 1 ++#define HAVE_DXGIDEBUG_H 0 ++#define HAVE_DXVA_H 0 ++#define HAVE_ES2_GL_H 0 ++#define HAVE_GSM_H 0 ++#define HAVE_IO_H 0 ++#define HAVE_LINUX_PERF_EVENT_H 1 ++#define HAVE_MACHINE_IOCTL_BT848_H 0 ++#define HAVE_MACHINE_IOCTL_METEOR_H 0 ++#define HAVE_MALLOC_H 1 ++#define HAVE_OPENCV2_CORE_CORE_C_H 0 ++#define HAVE_OPENGL_GL3_H 0 ++#define HAVE_POLL_H 1 ++#define HAVE_SYS_PARAM_H 1 ++#define HAVE_SYS_RESOURCE_H 1 ++#define HAVE_SYS_SELECT_H 1 ++#define HAVE_SYS_SOUNDCARD_H 1 ++#define HAVE_SYS_TIME_H 1 ++#define HAVE_SYS_UN_H 1 ++#define HAVE_SYS_VIDEOIO_H 0 ++#define HAVE_TERMIOS_H 1 ++#define HAVE_UDPLITE_H 0 ++#define HAVE_UNISTD_H 1 ++#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ ++#define HAVE_WINDOWS_H 0 ++#define HAVE_WINSOCK2_H 0 ++#define HAVE_INTRINSICS_NEON 0 ++#define HAVE_ATANF 1 ++#define HAVE_ATAN2F 1 ++#define HAVE_CBRT 1 ++#define HAVE_CBRTF 1 ++#define HAVE_COPYSIGN 1 ++#define HAVE_COSF 1 ++#define HAVE_ERF 1 ++#define HAVE_EXP2 1 ++#define HAVE_EXP2F 1 ++#define HAVE_EXPF 1 ++#define HAVE_HYPOT 1 ++#define HAVE_ISFINITE 1 ++#define HAVE_ISINF 1 ++#define HAVE_ISNAN 1 ++#define HAVE_LDEXPF 1 ++#define HAVE_LLRINT 1 ++#define HAVE_LLRINTF 1 ++#define HAVE_LOG2 1 ++#define HAVE_LOG2F 1 ++#define HAVE_LOG10F 1 ++#define HAVE_LRINT 1 ++#define HAVE_LRINTF 1 ++#define HAVE_POWF 1 ++#define HAVE_RINT 1 ++#define HAVE_ROUND 1 ++#define HAVE_ROUNDF 1 ++#define HAVE_SINF 1 ++#define HAVE_TRUNC 1 ++#define HAVE_TRUNCF 1 ++#define HAVE_DOS_PATHS 0 ++#define HAVE_LIBC_MSVCRT 0 ++#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 ++#define HAVE_SECTION_DATA_REL_RO 1 ++#define HAVE_THREADS 1 ++#define HAVE_UWP 0 ++#define HAVE_WINRT 0 ++#define HAVE_ACCESS 1 ++#define HAVE_ALIGNED_MALLOC 0 ++#define HAVE_ARC4RANDOM 0 ++#define HAVE_CLOCK_GETTIME 1 ++#define HAVE_CLOSESOCKET 0 ++#define HAVE_COMMANDLINETOARGVW 0 ++#define HAVE_FCNTL 1 ++#define HAVE_GETADDRINFO 0 ++#define HAVE_GETHRTIME 0 ++#define HAVE_GETOPT 1 ++#define HAVE_GETMODULEHANDLE 0 ++#define HAVE_GETPROCESSAFFINITYMASK 0 ++#define HAVE_GETPROCESSMEMORYINFO 0 ++#define HAVE_GETPROCESSTIMES 0 ++#define HAVE_GETRUSAGE 1 ++#define HAVE_GETSTDHANDLE 0 ++#define HAVE_GETSYSTEMTIMEASFILETIME 0 ++#define HAVE_GETTIMEOFDAY 1 ++#define HAVE_GLOB 1 ++#define HAVE_GLXGETPROCADDRESS 0 ++#define HAVE_GMTIME_R 1 ++#define HAVE_INET_ATON 0 ++#define HAVE_ISATTY 1 ++#define HAVE_KBHIT 0 ++#define HAVE_LOCALTIME_R 1 ++#define HAVE_LSTAT 1 ++#define HAVE_LZO1X_999_COMPRESS 0 ++#define HAVE_MACH_ABSOLUTE_TIME 0 ++#define HAVE_MAPVIEWOFFILE 0 ++#define HAVE_MEMALIGN 1 ++#define HAVE_MKSTEMP 1 ++#define HAVE_MMAP 1 ++#define HAVE_MPROTECT 1 ++#define HAVE_NANOSLEEP 1 ++#define HAVE_PEEKNAMEDPIPE 0 ++#define HAVE_POSIX_MEMALIGN 1 ++#define HAVE_PTHREAD_CANCEL 1 ++#define HAVE_SCHED_GETAFFINITY 1 ++#define HAVE_SECITEMIMPORT 0 ++#define HAVE_SETCONSOLETEXTATTRIBUTE 0 ++#define HAVE_SETCONSOLECTRLHANDLER 0 ++#define HAVE_SETDLLDIRECTORY 0 ++#define HAVE_SETMODE 0 ++#define HAVE_SETRLIMIT 1 ++#define HAVE_SLEEP 0 ++#define HAVE_STRERROR_R 1 ++#define HAVE_SYSCONF 1 ++#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ ++#define HAVE_USLEEP 1 ++#define HAVE_UTGETOSTYPEFROMSTRING 0 ++#define HAVE_VIRTUALALLOC 0 ++#define HAVE_WGLGETPROCADDRESS 0 ++#define HAVE_BCRYPT 0 ++#define HAVE_VAAPI_DRM 0 ++#define HAVE_VAAPI_X11 0 ++#define HAVE_VDPAU_X11 0 ++#define HAVE_PTHREADS 1 ++#define HAVE_OS2THREADS 0 ++#define HAVE_W32THREADS 0 ++#define HAVE_AS_ARCH_DIRECTIVE 0 ++#define HAVE_AS_DN_DIRECTIVE 0 ++#define HAVE_AS_FPU_DIRECTIVE 0 ++#define HAVE_AS_FUNC 0 ++#define HAVE_AS_OBJECT_ARCH 0 ++#define HAVE_ASM_MOD_Q 0 ++#define HAVE_BLOCKS_EXTENSION 0 ++#define HAVE_EBP_AVAILABLE 0 ++#define HAVE_EBX_AVAILABLE 0 ++#define HAVE_GNU_AS 0 ++#define HAVE_GNU_WINDRES 0 ++#define HAVE_IBM_ASM 0 ++#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 ++#define HAVE_INLINE_ASM_LABELS 1 ++#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 ++#define HAVE_PRAGMA_DEPRECATED 1 ++#define HAVE_RSYNC_CONTIMEOUT 1 ++#define HAVE_SYMVER_ASM_LABEL 0 ++#define HAVE_SYMVER_GNU_ASM 1 ++#define HAVE_VFP_ARGS 0 ++#define HAVE_XFORM_ASM 0 ++#define HAVE_XMM_CLOBBERS 0 ++#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 ++#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 ++#define HAVE_SOCKLEN_T 0 ++#define HAVE_STRUCT_ADDRINFO 0 ++#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 ++#define HAVE_STRUCT_IP_MREQ_SOURCE 0 ++#define HAVE_STRUCT_IPV6_MREQ 0 ++#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 ++#define HAVE_STRUCT_POLLFD 0 ++#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 ++#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 ++#define HAVE_STRUCT_SOCKADDR_IN6 0 ++#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 ++#define HAVE_STRUCT_SOCKADDR_STORAGE 0 ++#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 ++#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 ++#define HAVE_LIBDRM_GETFB2 0 ++#define HAVE_MAKEINFO 0 ++#define HAVE_MAKEINFO_HTML 0 ++#define HAVE_OPENCL_D3D11 0 ++#define HAVE_OPENCL_DRM_ARM 0 ++#define HAVE_OPENCL_DRM_BEIGNET 0 ++#define HAVE_OPENCL_DXVA2 0 ++#define HAVE_OPENCL_VAAPI_BEIGNET 0 ++#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 ++#define HAVE_PERL 1 ++#define HAVE_POD2MAN 1 ++#define HAVE_TEXI2HTML 0 ++#define CONFIG_DOC 0 ++#define CONFIG_HTMLPAGES 0 ++#define CONFIG_MANPAGES 0 ++#define CONFIG_PODPAGES 0 ++#define CONFIG_TXTPAGES 0 ++#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 ++#define CONFIG_AVIO_READING_EXAMPLE 1 ++#define CONFIG_DECODE_AUDIO_EXAMPLE 1 ++#define CONFIG_DECODE_VIDEO_EXAMPLE 1 ++#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 ++#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 ++#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 ++#define CONFIG_EXTRACT_MVS_EXAMPLE 1 ++#define CONFIG_FILTER_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 ++#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 ++#define CONFIG_HW_DECODE_EXAMPLE 1 ++#define CONFIG_METADATA_EXAMPLE 1 ++#define CONFIG_MUXING_EXAMPLE 0 ++#define CONFIG_QSVDEC_EXAMPLE 0 ++#define CONFIG_REMUXING_EXAMPLE 1 ++#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 ++#define CONFIG_SCALING_VIDEO_EXAMPLE 0 ++#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 ++#define CONFIG_TRANSCODING_EXAMPLE 0 ++#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 ++#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 ++#define CONFIG_AVISYNTH 0 ++#define CONFIG_FREI0R 0 ++#define CONFIG_LIBCDIO 0 ++#define CONFIG_LIBDAVS2 0 ++#define CONFIG_LIBRUBBERBAND 0 ++#define CONFIG_LIBVIDSTAB 0 ++#define CONFIG_LIBX264 0 ++#define CONFIG_LIBX265 0 ++#define CONFIG_LIBXAVS 0 ++#define CONFIG_LIBXAVS2 0 ++#define CONFIG_LIBXVID 0 ++#define CONFIG_DECKLINK 0 ++#define CONFIG_LIBFDK_AAC 0 ++#define CONFIG_OPENSSL 0 ++#define CONFIG_LIBTLS 0 ++#define CONFIG_GMP 0 ++#define CONFIG_LIBARIBB24 0 ++#define CONFIG_LIBLENSFUN 0 ++#define CONFIG_LIBOPENCORE_AMRNB 0 ++#define CONFIG_LIBOPENCORE_AMRWB 0 ++#define CONFIG_LIBVO_AMRWBENC 0 ++#define CONFIG_MBEDTLS 0 ++#define CONFIG_RKMPP 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_CHROMAPRINT 0 ++#define CONFIG_GCRYPT 0 ++#define CONFIG_GNUTLS 0 ++#define CONFIG_JNI 0 ++#define CONFIG_LADSPA 0 ++#define CONFIG_LIBAOM 0 ++#define CONFIG_LIBASS 0 ++#define CONFIG_LIBBLURAY 0 ++#define CONFIG_LIBBS2B 0 ++#define CONFIG_LIBCACA 0 ++#define CONFIG_LIBCELT 0 ++#define CONFIG_LIBCODEC2 0 ++#define CONFIG_LIBDAV1D 0 ++#define CONFIG_LIBDC1394 0 ++#define CONFIG_LIBDRM 0 ++#define CONFIG_LIBFLITE 0 ++#define CONFIG_LIBFONTCONFIG 0 ++#define CONFIG_LIBFREETYPE 0 ++#define CONFIG_LIBFRIBIDI 0 ++#define CONFIG_LIBGLSLANG 0 ++#define CONFIG_LIBGME 0 ++#define CONFIG_LIBGSM 0 ++#define CONFIG_LIBIEC61883 0 ++#define CONFIG_LIBILBC 0 ++#define CONFIG_LIBJACK 0 ++#define CONFIG_LIBKLVANC 0 ++#define CONFIG_LIBKVAZAAR 0 ++#define CONFIG_LIBMODPLUG 0 ++#define CONFIG_LIBMP3LAME 0 ++#define CONFIG_LIBMYSOFA 0 ++#define CONFIG_LIBOPENCV 0 ++#define CONFIG_LIBOPENH264 0 ++#define CONFIG_LIBOPENJPEG 0 ++#define CONFIG_LIBOPENMPT 0 ++#define CONFIG_LIBOPENVINO 0 ++#define CONFIG_LIBOPUS 1 ++#define CONFIG_LIBPULSE 0 ++#define CONFIG_LIBRABBITMQ 0 ++#define CONFIG_LIBRAV1E 0 ++#define CONFIG_LIBRSVG 0 ++#define CONFIG_LIBRTMP 0 ++#define CONFIG_LIBSHINE 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_LIBSNAPPY 0 ++#define CONFIG_LIBSOXR 0 ++#define CONFIG_LIBSPEEX 0 ++#define CONFIG_LIBSRT 0 ++#define CONFIG_LIBSSH 0 ++#define CONFIG_LIBSVTAV1 0 ++#define CONFIG_LIBTENSORFLOW 0 ++#define CONFIG_LIBTESSERACT 0 ++#define CONFIG_LIBTHEORA 0 ++#define CONFIG_LIBTWOLAME 0 ++#define CONFIG_LIBV4L2 0 ++#define CONFIG_LIBVMAF 0 ++#define CONFIG_LIBVORBIS 0 ++#define CONFIG_LIBVPX 0 ++#define CONFIG_LIBWAVPACK 0 ++#define CONFIG_LIBWEBP 0 ++#define CONFIG_LIBXML2 0 ++#define CONFIG_LIBZIMG 0 ++#define CONFIG_LIBZMQ 0 ++#define CONFIG_LIBZVBI 0 ++#define CONFIG_LV2 0 ++#define CONFIG_MEDIACODEC 0 ++#define CONFIG_OPENAL 0 ++#define CONFIG_OPENGL 0 ++#define CONFIG_POCKETSPHINX 0 ++#define CONFIG_VAPOURSYNTH 0 ++#define CONFIG_ALSA 0 ++#define CONFIG_APPKIT 0 ++#define CONFIG_AVFOUNDATION 0 ++#define CONFIG_BZLIB 0 ++#define CONFIG_COREIMAGE 0 ++#define CONFIG_ICONV 0 ++#define CONFIG_LIBXCB 0 ++#define CONFIG_LIBXCB_SHM 0 ++#define CONFIG_LIBXCB_SHAPE 0 ++#define CONFIG_LIBXCB_XFIXES 0 ++#define CONFIG_LZMA 0 ++#define CONFIG_MEDIAFOUNDATION 0 ++#define CONFIG_SCHANNEL 0 ++#define CONFIG_SDL2 0 ++#define CONFIG_SECURETRANSPORT 0 ++#define CONFIG_SNDIO 0 ++#define CONFIG_XLIB 0 ++#define CONFIG_ZLIB 0 ++#define CONFIG_CUDA_NVCC 0 ++#define CONFIG_CUDA_SDK 0 ++#define CONFIG_LIBNPP 0 ++#define CONFIG_LIBMFX 0 ++#define CONFIG_MMAL 0 ++#define CONFIG_OMX 0 ++#define CONFIG_OPENCL 0 ++#define CONFIG_VULKAN 0 ++#define CONFIG_AMF 0 ++#define CONFIG_AUDIOTOOLBOX 0 ++#define CONFIG_CRYSTALHD 0 ++#define CONFIG_CUDA 0 ++#define CONFIG_CUDA_LLVM 0 ++#define CONFIG_CUVID 0 ++#define CONFIG_D3D11VA 0 ++#define CONFIG_DXVA2 0 ++#define CONFIG_FFNVCODEC 0 ++#define CONFIG_NVDEC 0 ++#define CONFIG_NVENC 0 ++#define CONFIG_VAAPI 0 ++#define CONFIG_VDPAU 0 ++#define CONFIG_VIDEOTOOLBOX 0 ++#define CONFIG_V4L2_M2M 0 ++#define CONFIG_XVMC 0 ++#define CONFIG_FTRAPV 0 ++#define CONFIG_GRAY 0 ++#define CONFIG_HARDCODED_TABLES 0 ++#define CONFIG_OMX_RPI 0 ++#define CONFIG_RUNTIME_CPUDETECT 1 ++#define CONFIG_SAFE_BITSTREAM_READER 1 ++#define CONFIG_SHARED 0 ++#define CONFIG_SMALL 0 ++#define CONFIG_STATIC 1 ++#define CONFIG_SWSCALE_ALPHA 1 ++#define CONFIG_GPL 0 ++#define CONFIG_NONFREE 0 ++#define CONFIG_VERSION3 0 ++#define CONFIG_AVDEVICE 0 ++#define CONFIG_AVFILTER 0 ++#define CONFIG_SWSCALE 0 ++#define CONFIG_POSTPROC 0 ++#define CONFIG_AVFORMAT 1 ++#define CONFIG_AVCODEC 1 ++#define CONFIG_SWRESAMPLE 0 ++#define CONFIG_AVRESAMPLE 0 ++#define CONFIG_AVUTIL 1 ++#define CONFIG_FFPLAY 0 ++#define CONFIG_FFPROBE 0 ++#define CONFIG_FFMPEG 0 ++#define CONFIG_DCT 1 ++#define CONFIG_DWT 0 ++#define CONFIG_ERROR_RESILIENCE 0 ++#define CONFIG_FAAN 0 ++#define CONFIG_FAST_UNALIGNED 1 ++#define CONFIG_FFT 1 ++#define CONFIG_LSP 0 ++#define CONFIG_LZO 0 ++#define CONFIG_MDCT 1 ++#define CONFIG_PIXELUTILS 0 ++#define CONFIG_NETWORK 0 ++#define CONFIG_RDFT 1 ++#define CONFIG_AUTODETECT 0 ++#define CONFIG_FONTCONFIG 0 ++#define CONFIG_LARGE_TESTS 1 ++#define CONFIG_LINUX_PERF 0 ++#define CONFIG_MEMORY_POISONING 0 ++#define CONFIG_NEON_CLOBBER_TEST 0 ++#define CONFIG_OSSFUZZ 0 ++#define CONFIG_PIC 1 ++#define CONFIG_THUMB 0 ++#define CONFIG_VALGRIND_BACKTRACE 0 ++#define CONFIG_XMM_CLOBBER_TEST 0 ++#define CONFIG_BSFS 1 ++#define CONFIG_DECODERS 1 ++#define CONFIG_ENCODERS 0 ++#define CONFIG_HWACCELS 0 ++#define CONFIG_PARSERS 1 ++#define CONFIG_INDEVS 0 ++#define CONFIG_OUTDEVS 0 ++#define CONFIG_FILTERS 0 ++#define CONFIG_DEMUXERS 1 ++#define CONFIG_MUXERS 0 ++#define CONFIG_PROTOCOLS 0 ++#define CONFIG_AANDCTTABLES 0 ++#define CONFIG_AC3DSP 0 ++#define CONFIG_ADTS_HEADER 1 ++#define CONFIG_ATSC_A53 1 ++#define CONFIG_AUDIO_FRAME_QUEUE 0 ++#define CONFIG_AUDIODSP 0 ++#define CONFIG_BLOCKDSP 0 ++#define CONFIG_BSWAPDSP 0 ++#define CONFIG_CABAC 1 ++#define CONFIG_CBS 0 ++#define CONFIG_CBS_AV1 0 ++#define CONFIG_CBS_H264 0 ++#define CONFIG_CBS_H265 0 ++#define CONFIG_CBS_JPEG 0 ++#define CONFIG_CBS_MPEG2 0 ++#define CONFIG_CBS_VP9 0 ++#define CONFIG_DIRAC_PARSE 1 ++#define CONFIG_DNN 0 ++#define CONFIG_DVPROFILE 0 ++#define CONFIG_EXIF 0 ++#define CONFIG_FAANDCT 0 ++#define CONFIG_FAANIDCT 0 ++#define CONFIG_FDCTDSP 0 ++#define CONFIG_FLACDSP 1 ++#define CONFIG_FMTCONVERT 0 ++#define CONFIG_FRAME_THREAD_ENCODER 0 ++#define CONFIG_G722DSP 0 ++#define CONFIG_GOLOMB 1 ++#define CONFIG_GPLV3 0 ++#define CONFIG_H263DSP 0 ++#define CONFIG_H264CHROMA 1 ++#define CONFIG_H264DSP 1 ++#define CONFIG_H264PARSE 1 ++#define CONFIG_H264PRED 1 ++#define CONFIG_H264QPEL 1 ++#define CONFIG_HEVCPARSE 0 ++#define CONFIG_HPELDSP 1 ++#define CONFIG_HUFFMAN 0 ++#define CONFIG_HUFFYUVDSP 0 ++#define CONFIG_HUFFYUVENCDSP 0 ++#define CONFIG_IDCTDSP 0 ++#define CONFIG_IIRFILTER 0 ++#define CONFIG_MDCT15 1 ++#define CONFIG_INTRAX8 0 ++#define CONFIG_ISO_MEDIA 1 ++#define CONFIG_IVIDSP 0 ++#define CONFIG_JPEGTABLES 0 ++#define CONFIG_LGPLV3 0 ++#define CONFIG_LIBX262 0 ++#define CONFIG_LLAUDDSP 0 ++#define CONFIG_LLVIDDSP 0 ++#define CONFIG_LLVIDENCDSP 0 ++#define CONFIG_LPC 0 ++#define CONFIG_LZF 0 ++#define CONFIG_ME_CMP 0 ++#define CONFIG_MPEG_ER 0 ++#define CONFIG_MPEGAUDIO 1 ++#define CONFIG_MPEGAUDIODSP 1 ++#define CONFIG_MPEGAUDIOHEADER 1 ++#define CONFIG_MPEGVIDEO 0 ++#define CONFIG_MPEGVIDEOENC 0 ++#define CONFIG_MSS34DSP 0 ++#define CONFIG_PIXBLOCKDSP 0 ++#define CONFIG_QPELDSP 0 ++#define CONFIG_QSV 0 ++#define CONFIG_QSVDEC 0 ++#define CONFIG_QSVENC 0 ++#define CONFIG_QSVVPP 0 ++#define CONFIG_RANGECODER 0 ++#define CONFIG_RIFFDEC 1 ++#define CONFIG_RIFFENC 0 ++#define CONFIG_RTPDEC 0 ++#define CONFIG_RTPENC_CHAIN 0 ++#define CONFIG_RV34DSP 0 ++#define CONFIG_SCENE_SAD 0 ++#define CONFIG_SINEWIN 1 ++#define CONFIG_SNAPPY 0 ++#define CONFIG_SRTP 0 ++#define CONFIG_STARTCODE 1 ++#define CONFIG_TEXTUREDSP 0 ++#define CONFIG_TEXTUREDSPENC 0 ++#define CONFIG_TPELDSP 0 ++#define CONFIG_VAAPI_1 0 ++#define CONFIG_VAAPI_ENCODE 0 ++#define CONFIG_VC1DSP 0 ++#define CONFIG_VIDEODSP 1 ++#define CONFIG_VP3DSP 1 ++#define CONFIG_VP56DSP 0 ++#define CONFIG_VP8DSP 1 ++#define CONFIG_WMA_FREQS 0 ++#define CONFIG_WMV2DSP 0 ++#define CONFIG_AAC_ADTSTOASC_BSF 0 ++#define CONFIG_AV1_FRAME_MERGE_BSF 0 ++#define CONFIG_AV1_FRAME_SPLIT_BSF 0 ++#define CONFIG_AV1_METADATA_BSF 0 ++#define CONFIG_CHOMP_BSF 0 ++#define CONFIG_DUMP_EXTRADATA_BSF 0 ++#define CONFIG_DCA_CORE_BSF 0 ++#define CONFIG_EAC3_CORE_BSF 0 ++#define CONFIG_EXTRACT_EXTRADATA_BSF 0 ++#define CONFIG_FILTER_UNITS_BSF 0 ++#define CONFIG_H264_METADATA_BSF 0 ++#define CONFIG_H264_MP4TOANNEXB_BSF 0 ++#define CONFIG_H264_REDUNDANT_PPS_BSF 0 ++#define CONFIG_HAPQA_EXTRACT_BSF 0 ++#define CONFIG_HEVC_METADATA_BSF 0 ++#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 ++#define CONFIG_IMX_DUMP_HEADER_BSF 0 ++#define CONFIG_MJPEG2JPEG_BSF 0 ++#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 ++#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 ++#define CONFIG_MPEG2_METADATA_BSF 0 ++#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 ++#define CONFIG_MOV2TEXTSUB_BSF 0 ++#define CONFIG_NOISE_BSF 0 ++#define CONFIG_NULL_BSF 1 ++#define CONFIG_OPUS_METADATA_BSF 0 ++#define CONFIG_PCM_RECHUNK_BSF 0 ++#define CONFIG_PRORES_METADATA_BSF 0 ++#define CONFIG_REMOVE_EXTRADATA_BSF 0 ++#define CONFIG_TEXT2MOVSUB_BSF 0 ++#define CONFIG_TRACE_HEADERS_BSF 0 ++#define CONFIG_TRUEHD_CORE_BSF 0 ++#define CONFIG_VP9_METADATA_BSF 0 ++#define CONFIG_VP9_RAW_REORDER_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 ++#define CONFIG_AASC_DECODER 0 ++#define CONFIG_AIC_DECODER 0 ++#define CONFIG_ALIAS_PIX_DECODER 0 ++#define CONFIG_AGM_DECODER 0 ++#define CONFIG_AMV_DECODER 0 ++#define CONFIG_ANM_DECODER 0 ++#define CONFIG_ANSI_DECODER 0 ++#define CONFIG_APNG_DECODER 0 ++#define CONFIG_ARBC_DECODER 0 ++#define CONFIG_ASV1_DECODER 0 ++#define CONFIG_ASV2_DECODER 0 ++#define CONFIG_AURA_DECODER 0 ++#define CONFIG_AURA2_DECODER 0 ++#define CONFIG_AVRP_DECODER 0 ++#define CONFIG_AVRN_DECODER 0 ++#define CONFIG_AVS_DECODER 0 ++#define CONFIG_AVUI_DECODER 0 ++#define CONFIG_AYUV_DECODER 0 ++#define CONFIG_BETHSOFTVID_DECODER 0 ++#define CONFIG_BFI_DECODER 0 ++#define CONFIG_BINK_DECODER 0 ++#define CONFIG_BITPACKED_DECODER 0 ++#define CONFIG_BMP_DECODER 0 ++#define CONFIG_BMV_VIDEO_DECODER 0 ++#define CONFIG_BRENDER_PIX_DECODER 0 ++#define CONFIG_C93_DECODER 0 ++#define CONFIG_CAVS_DECODER 0 ++#define CONFIG_CDGRAPHICS_DECODER 0 ++#define CONFIG_CDTOONS_DECODER 0 ++#define CONFIG_CDXL_DECODER 0 ++#define CONFIG_CFHD_DECODER 0 ++#define CONFIG_CINEPAK_DECODER 0 ++#define CONFIG_CLEARVIDEO_DECODER 0 ++#define CONFIG_CLJR_DECODER 0 ++#define CONFIG_CLLC_DECODER 0 ++#define CONFIG_COMFORTNOISE_DECODER 0 ++#define CONFIG_CPIA_DECODER 0 ++#define CONFIG_CSCD_DECODER 0 ++#define CONFIG_CYUV_DECODER 0 ++#define CONFIG_DDS_DECODER 0 ++#define CONFIG_DFA_DECODER 0 ++#define CONFIG_DIRAC_DECODER 0 ++#define CONFIG_DNXHD_DECODER 0 ++#define CONFIG_DPX_DECODER 0 ++#define CONFIG_DSICINVIDEO_DECODER 0 ++#define CONFIG_DVAUDIO_DECODER 0 ++#define CONFIG_DVVIDEO_DECODER 0 ++#define CONFIG_DXA_DECODER 0 ++#define CONFIG_DXTORY_DECODER 0 ++#define CONFIG_DXV_DECODER 0 ++#define CONFIG_EACMV_DECODER 0 ++#define CONFIG_EAMAD_DECODER 0 ++#define CONFIG_EATGQ_DECODER 0 ++#define CONFIG_EATGV_DECODER 0 ++#define CONFIG_EATQI_DECODER 0 ++#define CONFIG_EIGHTBPS_DECODER 0 ++#define CONFIG_EIGHTSVX_EXP_DECODER 0 ++#define CONFIG_EIGHTSVX_FIB_DECODER 0 ++#define CONFIG_ESCAPE124_DECODER 0 ++#define CONFIG_ESCAPE130_DECODER 0 ++#define CONFIG_EXR_DECODER 0 ++#define CONFIG_FFV1_DECODER 0 ++#define CONFIG_FFVHUFF_DECODER 0 ++#define CONFIG_FIC_DECODER 0 ++#define CONFIG_FITS_DECODER 0 ++#define CONFIG_FLASHSV_DECODER 0 ++#define CONFIG_FLASHSV2_DECODER 0 ++#define CONFIG_FLIC_DECODER 0 ++#define CONFIG_FLV_DECODER 0 ++#define CONFIG_FMVC_DECODER 0 ++#define CONFIG_FOURXM_DECODER 0 ++#define CONFIG_FRAPS_DECODER 0 ++#define CONFIG_FRWU_DECODER 0 ++#define CONFIG_G2M_DECODER 0 ++#define CONFIG_GDV_DECODER 0 ++#define CONFIG_GIF_DECODER 0 ++#define CONFIG_H261_DECODER 0 ++#define CONFIG_H263_DECODER 0 ++#define CONFIG_H263I_DECODER 0 ++#define CONFIG_H263P_DECODER 0 ++#define CONFIG_H263_V4L2M2M_DECODER 0 ++#define CONFIG_H264_DECODER 1 ++#define CONFIG_H264_CRYSTALHD_DECODER 0 ++#define CONFIG_H264_V4L2M2M_DECODER 0 ++#define CONFIG_H264_MEDIACODEC_DECODER 0 ++#define CONFIG_H264_MMAL_DECODER 0 ++#define CONFIG_H264_QSV_DECODER 0 ++#define CONFIG_H264_RKMPP_DECODER 0 ++#define CONFIG_HAP_DECODER 0 ++#define CONFIG_HEVC_DECODER 0 ++#define CONFIG_HEVC_QSV_DECODER 0 ++#define CONFIG_HEVC_RKMPP_DECODER 0 ++#define CONFIG_HEVC_V4L2M2M_DECODER 0 ++#define CONFIG_HNM4_VIDEO_DECODER 0 ++#define CONFIG_HQ_HQA_DECODER 0 ++#define CONFIG_HQX_DECODER 0 ++#define CONFIG_HUFFYUV_DECODER 0 ++#define CONFIG_HYMT_DECODER 0 ++#define CONFIG_IDCIN_DECODER 0 ++#define CONFIG_IFF_ILBM_DECODER 0 ++#define CONFIG_IMM4_DECODER 0 ++#define CONFIG_IMM5_DECODER 0 ++#define CONFIG_INDEO2_DECODER 0 ++#define CONFIG_INDEO3_DECODER 0 ++#define CONFIG_INDEO4_DECODER 0 ++#define CONFIG_INDEO5_DECODER 0 ++#define CONFIG_INTERPLAY_VIDEO_DECODER 0 ++#define CONFIG_JPEG2000_DECODER 0 ++#define CONFIG_JPEGLS_DECODER 0 ++#define CONFIG_JV_DECODER 0 ++#define CONFIG_KGV1_DECODER 0 ++#define CONFIG_KMVC_DECODER 0 ++#define CONFIG_LAGARITH_DECODER 0 ++#define CONFIG_LOCO_DECODER 0 ++#define CONFIG_LSCR_DECODER 0 ++#define CONFIG_M101_DECODER 0 ++#define CONFIG_MAGICYUV_DECODER 0 ++#define CONFIG_MDEC_DECODER 0 ++#define CONFIG_MIMIC_DECODER 0 ++#define CONFIG_MJPEG_DECODER 0 ++#define CONFIG_MJPEGB_DECODER 0 ++#define CONFIG_MMVIDEO_DECODER 0 ++#define CONFIG_MOTIONPIXELS_DECODER 0 ++#define CONFIG_MPEG1VIDEO_DECODER 0 ++#define CONFIG_MPEG2VIDEO_DECODER 0 ++#define CONFIG_MPEG4_DECODER 0 ++#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG4_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG4_MMAL_DECODER 0 ++#define CONFIG_MPEGVIDEO_DECODER 0 ++#define CONFIG_MPEG1_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_MMAL_DECODER 0 ++#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG2_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_QSV_DECODER 0 ++#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 ++#define CONFIG_MSA1_DECODER 0 ++#define CONFIG_MSCC_DECODER 0 ++#define CONFIG_MSMPEG4V1_DECODER 0 ++#define CONFIG_MSMPEG4V2_DECODER 0 ++#define CONFIG_MSMPEG4V3_DECODER 0 ++#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MSRLE_DECODER 0 ++#define CONFIG_MSS1_DECODER 0 ++#define CONFIG_MSS2_DECODER 0 ++#define CONFIG_MSVIDEO1_DECODER 0 ++#define CONFIG_MSZH_DECODER 0 ++#define CONFIG_MTS2_DECODER 0 ++#define CONFIG_MV30_DECODER 0 ++#define CONFIG_MVC1_DECODER 0 ++#define CONFIG_MVC2_DECODER 0 ++#define CONFIG_MVDV_DECODER 0 ++#define CONFIG_MVHA_DECODER 0 ++#define CONFIG_MWSC_DECODER 0 ++#define CONFIG_MXPEG_DECODER 0 ++#define CONFIG_NOTCHLC_DECODER 0 ++#define CONFIG_NUV_DECODER 0 ++#define CONFIG_PAF_VIDEO_DECODER 0 ++#define CONFIG_PAM_DECODER 0 ++#define CONFIG_PBM_DECODER 0 ++#define CONFIG_PCX_DECODER 0 ++#define CONFIG_PFM_DECODER 0 ++#define CONFIG_PGM_DECODER 0 ++#define CONFIG_PGMYUV_DECODER 0 ++#define CONFIG_PGX_DECODER 0 ++#define CONFIG_PICTOR_DECODER 0 ++#define CONFIG_PIXLET_DECODER 0 ++#define CONFIG_PNG_DECODER 0 ++#define CONFIG_PPM_DECODER 0 ++#define CONFIG_PRORES_DECODER 0 ++#define CONFIG_PROSUMER_DECODER 0 ++#define CONFIG_PSD_DECODER 0 ++#define CONFIG_PTX_DECODER 0 ++#define CONFIG_QDRAW_DECODER 0 ++#define CONFIG_QPEG_DECODER 0 ++#define CONFIG_QTRLE_DECODER 0 ++#define CONFIG_R10K_DECODER 0 ++#define CONFIG_R210_DECODER 0 ++#define CONFIG_RASC_DECODER 0 ++#define CONFIG_RAWVIDEO_DECODER 0 ++#define CONFIG_RL2_DECODER 0 ++#define CONFIG_ROQ_DECODER 0 ++#define CONFIG_RPZA_DECODER 0 ++#define CONFIG_RSCC_DECODER 0 ++#define CONFIG_RV10_DECODER 0 ++#define CONFIG_RV20_DECODER 0 ++#define CONFIG_RV30_DECODER 0 ++#define CONFIG_RV40_DECODER 0 ++#define CONFIG_S302M_DECODER 0 ++#define CONFIG_SANM_DECODER 0 ++#define CONFIG_SCPR_DECODER 0 ++#define CONFIG_SCREENPRESSO_DECODER 0 ++#define CONFIG_SGI_DECODER 0 ++#define CONFIG_SGIRLE_DECODER 0 ++#define CONFIG_SHEERVIDEO_DECODER 0 ++#define CONFIG_SMACKER_DECODER 0 ++#define CONFIG_SMC_DECODER 0 ++#define CONFIG_SMVJPEG_DECODER 0 ++#define CONFIG_SNOW_DECODER 0 ++#define CONFIG_SP5X_DECODER 0 ++#define CONFIG_SPEEDHQ_DECODER 0 ++#define CONFIG_SRGC_DECODER 0 ++#define CONFIG_SUNRAST_DECODER 0 ++#define CONFIG_SVQ1_DECODER 0 ++#define CONFIG_SVQ3_DECODER 0 ++#define CONFIG_TARGA_DECODER 0 ++#define CONFIG_TARGA_Y216_DECODER 0 ++#define CONFIG_TDSC_DECODER 0 ++#define CONFIG_THEORA_DECODER 1 ++#define CONFIG_THP_DECODER 0 ++#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 ++#define CONFIG_TIFF_DECODER 0 ++#define CONFIG_TMV_DECODER 0 ++#define CONFIG_TRUEMOTION1_DECODER 0 ++#define CONFIG_TRUEMOTION2_DECODER 0 ++#define CONFIG_TRUEMOTION2RT_DECODER 0 ++#define CONFIG_TSCC_DECODER 0 ++#define CONFIG_TSCC2_DECODER 0 ++#define CONFIG_TXD_DECODER 0 ++#define CONFIG_ULTI_DECODER 0 ++#define CONFIG_UTVIDEO_DECODER 0 ++#define CONFIG_V210_DECODER 0 ++#define CONFIG_V210X_DECODER 0 ++#define CONFIG_V308_DECODER 0 ++#define CONFIG_V408_DECODER 0 ++#define CONFIG_V410_DECODER 0 ++#define CONFIG_VB_DECODER 0 ++#define CONFIG_VBLE_DECODER 0 ++#define CONFIG_VC1_DECODER 0 ++#define CONFIG_VC1_CRYSTALHD_DECODER 0 ++#define CONFIG_VC1IMAGE_DECODER 0 ++#define CONFIG_VC1_MMAL_DECODER 0 ++#define CONFIG_VC1_QSV_DECODER 0 ++#define CONFIG_VC1_V4L2M2M_DECODER 0 ++#define CONFIG_VCR1_DECODER 0 ++#define CONFIG_VMDVIDEO_DECODER 0 ++#define CONFIG_VMNC_DECODER 0 ++#define CONFIG_VP3_DECODER 1 ++#define CONFIG_VP4_DECODER 0 ++#define CONFIG_VP5_DECODER 0 ++#define CONFIG_VP6_DECODER 0 ++#define CONFIG_VP6A_DECODER 0 ++#define CONFIG_VP6F_DECODER 0 ++#define CONFIG_VP7_DECODER 0 ++#define CONFIG_VP8_DECODER 1 ++#define CONFIG_VP8_RKMPP_DECODER 0 ++#define CONFIG_VP8_V4L2M2M_DECODER 0 ++#define CONFIG_VP9_DECODER 0 ++#define CONFIG_VP9_RKMPP_DECODER 0 ++#define CONFIG_VP9_V4L2M2M_DECODER 0 ++#define CONFIG_VQA_DECODER 0 ++#define CONFIG_WEBP_DECODER 0 ++#define CONFIG_WCMV_DECODER 0 ++#define CONFIG_WRAPPED_AVFRAME_DECODER 0 ++#define CONFIG_WMV1_DECODER 0 ++#define CONFIG_WMV2_DECODER 0 ++#define CONFIG_WMV3_DECODER 0 ++#define CONFIG_WMV3_CRYSTALHD_DECODER 0 ++#define CONFIG_WMV3IMAGE_DECODER 0 ++#define CONFIG_WNV1_DECODER 0 ++#define CONFIG_XAN_WC3_DECODER 0 ++#define CONFIG_XAN_WC4_DECODER 0 ++#define CONFIG_XBM_DECODER 0 ++#define CONFIG_XFACE_DECODER 0 ++#define CONFIG_XL_DECODER 0 ++#define CONFIG_XPM_DECODER 0 ++#define CONFIG_XWD_DECODER 0 ++#define CONFIG_Y41P_DECODER 0 ++#define CONFIG_YLC_DECODER 0 ++#define CONFIG_YOP_DECODER 0 ++#define CONFIG_YUV4_DECODER 0 ++#define CONFIG_ZERO12V_DECODER 0 ++#define CONFIG_ZEROCODEC_DECODER 0 ++#define CONFIG_ZLIB_DECODER 0 ++#define CONFIG_ZMBV_DECODER 0 ++#define CONFIG_AAC_DECODER 1 ++#define CONFIG_AAC_FIXED_DECODER 0 ++#define CONFIG_AAC_LATM_DECODER 0 ++#define CONFIG_AC3_DECODER 0 ++#define CONFIG_AC3_FIXED_DECODER 0 ++#define CONFIG_ACELP_KELVIN_DECODER 0 ++#define CONFIG_ALAC_DECODER 0 ++#define CONFIG_ALS_DECODER 0 ++#define CONFIG_AMRNB_DECODER 0 ++#define CONFIG_AMRWB_DECODER 0 ++#define CONFIG_APE_DECODER 0 ++#define CONFIG_APTX_DECODER 0 ++#define CONFIG_APTX_HD_DECODER 0 ++#define CONFIG_ATRAC1_DECODER 0 ++#define CONFIG_ATRAC3_DECODER 0 ++#define CONFIG_ATRAC3AL_DECODER 0 ++#define CONFIG_ATRAC3P_DECODER 0 ++#define CONFIG_ATRAC3PAL_DECODER 0 ++#define CONFIG_ATRAC9_DECODER 0 ++#define CONFIG_BINKAUDIO_DCT_DECODER 0 ++#define CONFIG_BINKAUDIO_RDFT_DECODER 0 ++#define CONFIG_BMV_AUDIO_DECODER 0 ++#define CONFIG_COOK_DECODER 0 ++#define CONFIG_DCA_DECODER 0 ++#define CONFIG_DOLBY_E_DECODER 0 ++#define CONFIG_DSD_LSBF_DECODER 0 ++#define CONFIG_DSD_MSBF_DECODER 0 ++#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 ++#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 ++#define CONFIG_DSICINAUDIO_DECODER 0 ++#define CONFIG_DSS_SP_DECODER 0 ++#define CONFIG_DST_DECODER 0 ++#define CONFIG_EAC3_DECODER 0 ++#define CONFIG_EVRC_DECODER 0 ++#define CONFIG_FFWAVESYNTH_DECODER 0 ++#define CONFIG_FLAC_DECODER 1 ++#define CONFIG_G723_1_DECODER 0 ++#define CONFIG_G729_DECODER 0 ++#define CONFIG_GSM_DECODER 0 ++#define CONFIG_GSM_MS_DECODER 0 ++#define CONFIG_HCA_DECODER 0 ++#define CONFIG_HCOM_DECODER 0 ++#define CONFIG_IAC_DECODER 0 ++#define CONFIG_ILBC_DECODER 0 ++#define CONFIG_IMC_DECODER 0 ++#define CONFIG_INTERPLAY_ACM_DECODER 0 ++#define CONFIG_MACE3_DECODER 0 ++#define CONFIG_MACE6_DECODER 0 ++#define CONFIG_METASOUND_DECODER 0 ++#define CONFIG_MLP_DECODER 0 ++#define CONFIG_MP1_DECODER 0 ++#define CONFIG_MP1FLOAT_DECODER 0 ++#define CONFIG_MP2_DECODER 0 ++#define CONFIG_MP2FLOAT_DECODER 0 ++#define CONFIG_MP3FLOAT_DECODER 0 ++#define CONFIG_MP3_DECODER 1 ++#define CONFIG_MP3ADUFLOAT_DECODER 0 ++#define CONFIG_MP3ADU_DECODER 0 ++#define CONFIG_MP3ON4FLOAT_DECODER 0 ++#define CONFIG_MP3ON4_DECODER 0 ++#define CONFIG_MPC7_DECODER 0 ++#define CONFIG_MPC8_DECODER 0 ++#define CONFIG_NELLYMOSER_DECODER 0 ++#define CONFIG_ON2AVC_DECODER 0 ++#define CONFIG_OPUS_DECODER 0 ++#define CONFIG_PAF_AUDIO_DECODER 0 ++#define CONFIG_QCELP_DECODER 0 ++#define CONFIG_QDM2_DECODER 0 ++#define CONFIG_QDMC_DECODER 0 ++#define CONFIG_RA_144_DECODER 0 ++#define CONFIG_RA_288_DECODER 0 ++#define CONFIG_RALF_DECODER 0 ++#define CONFIG_SBC_DECODER 0 ++#define CONFIG_SHORTEN_DECODER 0 ++#define CONFIG_SIPR_DECODER 0 ++#define CONFIG_SIREN_DECODER 0 ++#define CONFIG_SMACKAUD_DECODER 0 ++#define CONFIG_SONIC_DECODER 0 ++#define CONFIG_TAK_DECODER 0 ++#define CONFIG_TRUEHD_DECODER 0 ++#define CONFIG_TRUESPEECH_DECODER 0 ++#define CONFIG_TTA_DECODER 0 ++#define CONFIG_TWINVQ_DECODER 0 ++#define CONFIG_VMDAUDIO_DECODER 0 ++#define CONFIG_VORBIS_DECODER 1 ++#define CONFIG_WAVPACK_DECODER 0 ++#define CONFIG_WMALOSSLESS_DECODER 0 ++#define CONFIG_WMAPRO_DECODER 0 ++#define CONFIG_WMAV1_DECODER 0 ++#define CONFIG_WMAV2_DECODER 0 ++#define CONFIG_WMAVOICE_DECODER 0 ++#define CONFIG_WS_SND1_DECODER 0 ++#define CONFIG_XMA1_DECODER 0 ++#define CONFIG_XMA2_DECODER 0 ++#define CONFIG_PCM_ALAW_DECODER 1 ++#define CONFIG_PCM_BLURAY_DECODER 0 ++#define CONFIG_PCM_DVD_DECODER 0 ++#define CONFIG_PCM_F16LE_DECODER 0 ++#define CONFIG_PCM_F24LE_DECODER 0 ++#define CONFIG_PCM_F32BE_DECODER 0 ++#define CONFIG_PCM_F32LE_DECODER 1 ++#define CONFIG_PCM_F64BE_DECODER 0 ++#define CONFIG_PCM_F64LE_DECODER 0 ++#define CONFIG_PCM_LXF_DECODER 0 ++#define CONFIG_PCM_MULAW_DECODER 1 ++#define CONFIG_PCM_S8_DECODER 0 ++#define CONFIG_PCM_S8_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16BE_DECODER 1 ++#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16LE_DECODER 1 ++#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S24BE_DECODER 1 ++#define CONFIG_PCM_S24DAUD_DECODER 0 ++#define CONFIG_PCM_S24LE_DECODER 1 ++#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S32BE_DECODER 0 ++#define CONFIG_PCM_S32LE_DECODER 1 ++#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S64BE_DECODER 0 ++#define CONFIG_PCM_S64LE_DECODER 0 ++#define CONFIG_PCM_U8_DECODER 1 ++#define CONFIG_PCM_U16BE_DECODER 0 ++#define CONFIG_PCM_U16LE_DECODER 0 ++#define CONFIG_PCM_U24BE_DECODER 0 ++#define CONFIG_PCM_U24LE_DECODER 0 ++#define CONFIG_PCM_U32BE_DECODER 0 ++#define CONFIG_PCM_U32LE_DECODER 0 ++#define CONFIG_PCM_VIDC_DECODER 0 ++#define CONFIG_DERF_DPCM_DECODER 0 ++#define CONFIG_GREMLIN_DPCM_DECODER 0 ++#define CONFIG_INTERPLAY_DPCM_DECODER 0 ++#define CONFIG_ROQ_DPCM_DECODER 0 ++#define CONFIG_SDX2_DPCM_DECODER 0 ++#define CONFIG_SOL_DPCM_DECODER 0 ++#define CONFIG_XAN_DPCM_DECODER 0 ++#define CONFIG_ADPCM_4XM_DECODER 0 ++#define CONFIG_ADPCM_ADX_DECODER 0 ++#define CONFIG_ADPCM_AFC_DECODER 0 ++#define CONFIG_ADPCM_AGM_DECODER 0 ++#define CONFIG_ADPCM_AICA_DECODER 0 ++#define CONFIG_ADPCM_ARGO_DECODER 0 ++#define CONFIG_ADPCM_CT_DECODER 0 ++#define CONFIG_ADPCM_DTK_DECODER 0 ++#define CONFIG_ADPCM_EA_DECODER 0 ++#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 ++#define CONFIG_ADPCM_EA_R1_DECODER 0 ++#define CONFIG_ADPCM_EA_R2_DECODER 0 ++#define CONFIG_ADPCM_EA_R3_DECODER 0 ++#define CONFIG_ADPCM_EA_XAS_DECODER 0 ++#define CONFIG_ADPCM_G722_DECODER 0 ++#define CONFIG_ADPCM_G726_DECODER 0 ++#define CONFIG_ADPCM_G726LE_DECODER 0 ++#define CONFIG_ADPCM_IMA_AMV_DECODER 0 ++#define CONFIG_ADPCM_IMA_ALP_DECODER 0 ++#define CONFIG_ADPCM_IMA_APC_DECODER 0 ++#define CONFIG_ADPCM_IMA_APM_DECODER 0 ++#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 ++#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK3_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK4_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_ISS_DECODER 0 ++#define CONFIG_ADPCM_IMA_MTF_DECODER 0 ++#define CONFIG_ADPCM_IMA_OKI_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_DECODER 0 ++#define CONFIG_ADPCM_IMA_RAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_SSI_DECODER 0 ++#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 ++#define CONFIG_ADPCM_IMA_WAV_DECODER 0 ++#define CONFIG_ADPCM_IMA_WS_DECODER 0 ++#define CONFIG_ADPCM_MS_DECODER 0 ++#define CONFIG_ADPCM_MTAF_DECODER 0 ++#define CONFIG_ADPCM_PSX_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_2_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_3_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_4_DECODER 0 ++#define CONFIG_ADPCM_SWF_DECODER 0 ++#define CONFIG_ADPCM_THP_DECODER 0 ++#define CONFIG_ADPCM_THP_LE_DECODER 0 ++#define CONFIG_ADPCM_VIMA_DECODER 0 ++#define CONFIG_ADPCM_XA_DECODER 0 ++#define CONFIG_ADPCM_YAMAHA_DECODER 0 ++#define CONFIG_ADPCM_ZORK_DECODER 0 ++#define CONFIG_SSA_DECODER 0 ++#define CONFIG_ASS_DECODER 0 ++#define CONFIG_CCAPTION_DECODER 0 ++#define CONFIG_DVBSUB_DECODER 0 ++#define CONFIG_DVDSUB_DECODER 0 ++#define CONFIG_JACOSUB_DECODER 0 ++#define CONFIG_MICRODVD_DECODER 0 ++#define CONFIG_MOVTEXT_DECODER 0 ++#define CONFIG_MPL2_DECODER 0 ++#define CONFIG_PGSSUB_DECODER 0 ++#define CONFIG_PJS_DECODER 0 ++#define CONFIG_REALTEXT_DECODER 0 ++#define CONFIG_SAMI_DECODER 0 ++#define CONFIG_SRT_DECODER 0 ++#define CONFIG_STL_DECODER 0 ++#define CONFIG_SUBRIP_DECODER 0 ++#define CONFIG_SUBVIEWER_DECODER 0 ++#define CONFIG_SUBVIEWER1_DECODER 0 ++#define CONFIG_TEXT_DECODER 0 ++#define CONFIG_VPLAYER_DECODER 0 ++#define CONFIG_WEBVTT_DECODER 0 ++#define CONFIG_XSUB_DECODER 0 ++#define CONFIG_AAC_AT_DECODER 0 ++#define CONFIG_AC3_AT_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 ++#define CONFIG_ALAC_AT_DECODER 0 ++#define CONFIG_AMR_NB_AT_DECODER 0 ++#define CONFIG_EAC3_AT_DECODER 0 ++#define CONFIG_GSM_MS_AT_DECODER 0 ++#define CONFIG_ILBC_AT_DECODER 0 ++#define CONFIG_MP1_AT_DECODER 0 ++#define CONFIG_MP2_AT_DECODER 0 ++#define CONFIG_MP3_AT_DECODER 0 ++#define CONFIG_PCM_ALAW_AT_DECODER 0 ++#define CONFIG_PCM_MULAW_AT_DECODER 0 ++#define CONFIG_QDMC_AT_DECODER 0 ++#define CONFIG_QDM2_AT_DECODER 0 ++#define CONFIG_LIBARIBB24_DECODER 0 ++#define CONFIG_LIBCELT_DECODER 0 ++#define CONFIG_LIBCODEC2_DECODER 0 ++#define CONFIG_LIBDAV1D_DECODER 0 ++#define CONFIG_LIBDAVS2_DECODER 0 ++#define CONFIG_LIBFDK_AAC_DECODER 0 ++#define CONFIG_LIBGSM_DECODER 0 ++#define CONFIG_LIBGSM_MS_DECODER 0 ++#define CONFIG_LIBILBC_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 ++#define CONFIG_LIBOPENJPEG_DECODER 0 ++#define CONFIG_LIBOPUS_DECODER 1 ++#define CONFIG_LIBRSVG_DECODER 0 ++#define CONFIG_LIBSPEEX_DECODER 0 ++#define CONFIG_LIBVORBIS_DECODER 0 ++#define CONFIG_LIBVPX_VP8_DECODER 0 ++#define CONFIG_LIBVPX_VP9_DECODER 0 ++#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 ++#define CONFIG_BINTEXT_DECODER 0 ++#define CONFIG_XBIN_DECODER 0 ++#define CONFIG_IDF_DECODER 0 ++#define CONFIG_LIBAOM_AV1_DECODER 0 ++#define CONFIG_LIBOPENH264_DECODER 0 ++#define CONFIG_H264_CUVID_DECODER 0 ++#define CONFIG_HEVC_CUVID_DECODER 0 ++#define CONFIG_HEVC_MEDIACODEC_DECODER 0 ++#define CONFIG_MJPEG_CUVID_DECODER 0 ++#define CONFIG_MJPEG_QSV_DECODER 0 ++#define CONFIG_MPEG1_CUVID_DECODER 0 ++#define CONFIG_MPEG2_CUVID_DECODER 0 ++#define CONFIG_MPEG4_CUVID_DECODER 0 ++#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 ++#define CONFIG_VC1_CUVID_DECODER 0 ++#define CONFIG_VP8_CUVID_DECODER 0 ++#define CONFIG_VP8_MEDIACODEC_DECODER 0 ++#define CONFIG_VP8_QSV_DECODER 0 ++#define CONFIG_VP9_CUVID_DECODER 0 ++#define CONFIG_VP9_MEDIACODEC_DECODER 0 ++#define CONFIG_VP9_QSV_DECODER 0 ++#define CONFIG_A64MULTI_ENCODER 0 ++#define CONFIG_A64MULTI5_ENCODER 0 ++#define CONFIG_ALIAS_PIX_ENCODER 0 ++#define CONFIG_AMV_ENCODER 0 ++#define CONFIG_APNG_ENCODER 0 ++#define CONFIG_ASV1_ENCODER 0 ++#define CONFIG_ASV2_ENCODER 0 ++#define CONFIG_AVRP_ENCODER 0 ++#define CONFIG_AVUI_ENCODER 0 ++#define CONFIG_AYUV_ENCODER 0 ++#define CONFIG_BMP_ENCODER 0 ++#define CONFIG_CFHD_ENCODER 0 ++#define CONFIG_CINEPAK_ENCODER 0 ++#define CONFIG_CLJR_ENCODER 0 ++#define CONFIG_COMFORTNOISE_ENCODER 0 ++#define CONFIG_DNXHD_ENCODER 0 ++#define CONFIG_DPX_ENCODER 0 ++#define CONFIG_DVVIDEO_ENCODER 0 ++#define CONFIG_FFV1_ENCODER 0 ++#define CONFIG_FFVHUFF_ENCODER 0 ++#define CONFIG_FITS_ENCODER 0 ++#define CONFIG_FLASHSV_ENCODER 0 ++#define CONFIG_FLASHSV2_ENCODER 0 ++#define CONFIG_FLV_ENCODER 0 ++#define CONFIG_GIF_ENCODER 0 ++#define CONFIG_H261_ENCODER 0 ++#define CONFIG_H263_ENCODER 0 ++#define CONFIG_H263P_ENCODER 0 ++#define CONFIG_HAP_ENCODER 0 ++#define CONFIG_HUFFYUV_ENCODER 0 ++#define CONFIG_JPEG2000_ENCODER 0 ++#define CONFIG_JPEGLS_ENCODER 0 ++#define CONFIG_LJPEG_ENCODER 0 ++#define CONFIG_MAGICYUV_ENCODER 0 ++#define CONFIG_MJPEG_ENCODER 0 ++#define CONFIG_MPEG1VIDEO_ENCODER 0 ++#define CONFIG_MPEG2VIDEO_ENCODER 0 ++#define CONFIG_MPEG4_ENCODER 0 ++#define CONFIG_MSMPEG4V2_ENCODER 0 ++#define CONFIG_MSMPEG4V3_ENCODER 0 ++#define CONFIG_MSVIDEO1_ENCODER 0 ++#define CONFIG_PAM_ENCODER 0 ++#define CONFIG_PBM_ENCODER 0 ++#define CONFIG_PCX_ENCODER 0 ++#define CONFIG_PGM_ENCODER 0 ++#define CONFIG_PGMYUV_ENCODER 0 ++#define CONFIG_PNG_ENCODER 0 ++#define CONFIG_PPM_ENCODER 0 ++#define CONFIG_PRORES_ENCODER 0 ++#define CONFIG_PRORES_AW_ENCODER 0 ++#define CONFIG_PRORES_KS_ENCODER 0 ++#define CONFIG_QTRLE_ENCODER 0 ++#define CONFIG_R10K_ENCODER 0 ++#define CONFIG_R210_ENCODER 0 ++#define CONFIG_RAWVIDEO_ENCODER 0 ++#define CONFIG_ROQ_ENCODER 0 ++#define CONFIG_RPZA_ENCODER 0 ++#define CONFIG_RV10_ENCODER 0 ++#define CONFIG_RV20_ENCODER 0 ++#define CONFIG_S302M_ENCODER 0 ++#define CONFIG_SGI_ENCODER 0 ++#define CONFIG_SNOW_ENCODER 0 ++#define CONFIG_SUNRAST_ENCODER 0 ++#define CONFIG_SVQ1_ENCODER 0 ++#define CONFIG_TARGA_ENCODER 0 ++#define CONFIG_TIFF_ENCODER 0 ++#define CONFIG_UTVIDEO_ENCODER 0 ++#define CONFIG_V210_ENCODER 0 ++#define CONFIG_V308_ENCODER 0 ++#define CONFIG_V408_ENCODER 0 ++#define CONFIG_V410_ENCODER 0 ++#define CONFIG_VC2_ENCODER 0 ++#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 ++#define CONFIG_WMV1_ENCODER 0 ++#define CONFIG_WMV2_ENCODER 0 ++#define CONFIG_XBM_ENCODER 0 ++#define CONFIG_XFACE_ENCODER 0 ++#define CONFIG_XWD_ENCODER 0 ++#define CONFIG_Y41P_ENCODER 0 ++#define CONFIG_YUV4_ENCODER 0 ++#define CONFIG_ZLIB_ENCODER 0 ++#define CONFIG_ZMBV_ENCODER 0 ++#define CONFIG_AAC_ENCODER 0 ++#define CONFIG_AC3_ENCODER 0 ++#define CONFIG_AC3_FIXED_ENCODER 0 ++#define CONFIG_ALAC_ENCODER 0 ++#define CONFIG_APTX_ENCODER 0 ++#define CONFIG_APTX_HD_ENCODER 0 ++#define CONFIG_DCA_ENCODER 0 ++#define CONFIG_EAC3_ENCODER 0 ++#define CONFIG_FLAC_ENCODER 0 ++#define CONFIG_G723_1_ENCODER 0 ++#define CONFIG_MLP_ENCODER 0 ++#define CONFIG_MP2_ENCODER 0 ++#define CONFIG_MP2FIXED_ENCODER 0 ++#define CONFIG_NELLYMOSER_ENCODER 0 ++#define CONFIG_OPUS_ENCODER 0 ++#define CONFIG_RA_144_ENCODER 0 ++#define CONFIG_SBC_ENCODER 0 ++#define CONFIG_SONIC_ENCODER 0 ++#define CONFIG_SONIC_LS_ENCODER 0 ++#define CONFIG_TRUEHD_ENCODER 0 ++#define CONFIG_TTA_ENCODER 0 ++#define CONFIG_VORBIS_ENCODER 0 ++#define CONFIG_WAVPACK_ENCODER 0 ++#define CONFIG_WMAV1_ENCODER 0 ++#define CONFIG_WMAV2_ENCODER 0 ++#define CONFIG_PCM_ALAW_ENCODER 0 ++#define CONFIG_PCM_DVD_ENCODER 0 ++#define CONFIG_PCM_F32BE_ENCODER 0 ++#define CONFIG_PCM_F32LE_ENCODER 0 ++#define CONFIG_PCM_F64BE_ENCODER 0 ++#define CONFIG_PCM_F64LE_ENCODER 0 ++#define CONFIG_PCM_MULAW_ENCODER 0 ++#define CONFIG_PCM_S8_ENCODER 0 ++#define CONFIG_PCM_S8_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16BE_ENCODER 0 ++#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16LE_ENCODER 0 ++#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S24BE_ENCODER 0 ++#define CONFIG_PCM_S24DAUD_ENCODER 0 ++#define CONFIG_PCM_S24LE_ENCODER 0 ++#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S32BE_ENCODER 0 ++#define CONFIG_PCM_S32LE_ENCODER 0 ++#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S64BE_ENCODER 0 ++#define CONFIG_PCM_S64LE_ENCODER 0 ++#define CONFIG_PCM_U8_ENCODER 0 ++#define CONFIG_PCM_U16BE_ENCODER 0 ++#define CONFIG_PCM_U16LE_ENCODER 0 ++#define CONFIG_PCM_U24BE_ENCODER 0 ++#define CONFIG_PCM_U24LE_ENCODER 0 ++#define CONFIG_PCM_U32BE_ENCODER 0 ++#define CONFIG_PCM_U32LE_ENCODER 0 ++#define CONFIG_PCM_VIDC_ENCODER 0 ++#define CONFIG_ROQ_DPCM_ENCODER 0 ++#define CONFIG_ADPCM_ADX_ENCODER 0 ++#define CONFIG_ADPCM_ARGO_ENCODER 0 ++#define CONFIG_ADPCM_G722_ENCODER 0 ++#define CONFIG_ADPCM_G726_ENCODER 0 ++#define CONFIG_ADPCM_G726LE_ENCODER 0 ++#define CONFIG_ADPCM_IMA_APM_ENCODER 0 ++#define CONFIG_ADPCM_IMA_QT_ENCODER 0 ++#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 ++#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 ++#define CONFIG_ADPCM_MS_ENCODER 0 ++#define CONFIG_ADPCM_SWF_ENCODER 0 ++#define CONFIG_ADPCM_YAMAHA_ENCODER 0 ++#define CONFIG_SSA_ENCODER 0 ++#define CONFIG_ASS_ENCODER 0 ++#define CONFIG_DVBSUB_ENCODER 0 ++#define CONFIG_DVDSUB_ENCODER 0 ++#define CONFIG_MOVTEXT_ENCODER 0 ++#define CONFIG_SRT_ENCODER 0 ++#define CONFIG_SUBRIP_ENCODER 0 ++#define CONFIG_TEXT_ENCODER 0 ++#define CONFIG_WEBVTT_ENCODER 0 ++#define CONFIG_XSUB_ENCODER 0 ++#define CONFIG_AAC_AT_ENCODER 0 ++#define CONFIG_ALAC_AT_ENCODER 0 ++#define CONFIG_ILBC_AT_ENCODER 0 ++#define CONFIG_PCM_ALAW_AT_ENCODER 0 ++#define CONFIG_PCM_MULAW_AT_ENCODER 0 ++#define CONFIG_LIBAOM_AV1_ENCODER 0 ++#define CONFIG_LIBCODEC2_ENCODER 0 ++#define CONFIG_LIBFDK_AAC_ENCODER 0 ++#define CONFIG_LIBGSM_ENCODER 0 ++#define CONFIG_LIBGSM_MS_ENCODER 0 ++#define CONFIG_LIBILBC_ENCODER 0 ++#define CONFIG_LIBMP3LAME_ENCODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 ++#define CONFIG_LIBOPENJPEG_ENCODER 0 ++#define CONFIG_LIBOPUS_ENCODER 0 ++#define CONFIG_LIBRAV1E_ENCODER 0 ++#define CONFIG_LIBSHINE_ENCODER 0 ++#define CONFIG_LIBSPEEX_ENCODER 0 ++#define CONFIG_LIBSVTAV1_ENCODER 0 ++#define CONFIG_LIBTHEORA_ENCODER 0 ++#define CONFIG_LIBTWOLAME_ENCODER 0 ++#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 ++#define CONFIG_LIBVORBIS_ENCODER 0 ++#define CONFIG_LIBVPX_VP8_ENCODER 0 ++#define CONFIG_LIBVPX_VP9_ENCODER 0 ++#define CONFIG_LIBWAVPACK_ENCODER 0 ++#define CONFIG_LIBWEBP_ANIM_ENCODER 0 ++#define CONFIG_LIBWEBP_ENCODER 0 ++#define CONFIG_LIBX262_ENCODER 0 ++#define CONFIG_LIBX264_ENCODER 0 ++#define CONFIG_LIBX264RGB_ENCODER 0 ++#define CONFIG_LIBX265_ENCODER 0 ++#define CONFIG_LIBXAVS_ENCODER 0 ++#define CONFIG_LIBXAVS2_ENCODER 0 ++#define CONFIG_LIBXVID_ENCODER 0 ++#define CONFIG_AAC_MF_ENCODER 0 ++#define CONFIG_AC3_MF_ENCODER 0 ++#define CONFIG_H263_V4L2M2M_ENCODER 0 ++#define CONFIG_LIBOPENH264_ENCODER 0 ++#define CONFIG_H264_AMF_ENCODER 0 ++#define CONFIG_H264_MF_ENCODER 0 ++#define CONFIG_H264_NVENC_ENCODER 0 ++#define CONFIG_H264_OMX_ENCODER 0 ++#define CONFIG_H264_QSV_ENCODER 0 ++#define CONFIG_H264_V4L2M2M_ENCODER 0 ++#define CONFIG_H264_VAAPI_ENCODER 0 ++#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_NVENC_ENCODER 0 ++#define CONFIG_NVENC_H264_ENCODER 0 ++#define CONFIG_NVENC_HEVC_ENCODER 0 ++#define CONFIG_HEVC_AMF_ENCODER 0 ++#define CONFIG_HEVC_MF_ENCODER 0 ++#define CONFIG_HEVC_NVENC_ENCODER 0 ++#define CONFIG_HEVC_QSV_ENCODER 0 ++#define CONFIG_HEVC_V4L2M2M_ENCODER 0 ++#define CONFIG_HEVC_VAAPI_ENCODER 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_LIBKVAZAAR_ENCODER 0 ++#define CONFIG_MJPEG_QSV_ENCODER 0 ++#define CONFIG_MJPEG_VAAPI_ENCODER 0 ++#define CONFIG_MP3_MF_ENCODER 0 ++#define CONFIG_MPEG2_QSV_ENCODER 0 ++#define CONFIG_MPEG2_VAAPI_ENCODER 0 ++#define CONFIG_MPEG4_OMX_ENCODER 0 ++#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_VAAPI_ENCODER 0 ++#define CONFIG_VP9_VAAPI_ENCODER 0 ++#define CONFIG_VP9_QSV_ENCODER 0 ++#define CONFIG_H263_VAAPI_HWACCEL 0 ++#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_H264_D3D11VA_HWACCEL 0 ++#define CONFIG_H264_D3D11VA2_HWACCEL 0 ++#define CONFIG_H264_DXVA2_HWACCEL 0 ++#define CONFIG_H264_NVDEC_HWACCEL 0 ++#define CONFIG_H264_VAAPI_HWACCEL 0 ++#define CONFIG_H264_VDPAU_HWACCEL 0 ++#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 ++#define CONFIG_HEVC_DXVA2_HWACCEL 0 ++#define CONFIG_HEVC_NVDEC_HWACCEL 0 ++#define CONFIG_HEVC_VAAPI_HWACCEL 0 ++#define CONFIG_HEVC_VDPAU_HWACCEL 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MJPEG_NVDEC_HWACCEL 0 ++#define CONFIG_MJPEG_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG1_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG1_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG1_XVMC_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 ++#define CONFIG_MPEG2_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG2_DXVA2_HWACCEL 0 ++#define CONFIG_MPEG2_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG2_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG2_XVMC_HWACCEL 0 ++#define CONFIG_MPEG4_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG4_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG4_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA2_HWACCEL 0 ++#define CONFIG_VC1_DXVA2_HWACCEL 0 ++#define CONFIG_VC1_NVDEC_HWACCEL 0 ++#define CONFIG_VC1_VAAPI_HWACCEL 0 ++#define CONFIG_VC1_VDPAU_HWACCEL 0 ++#define CONFIG_VP8_NVDEC_HWACCEL 0 ++#define CONFIG_VP8_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA2_HWACCEL 0 ++#define CONFIG_VP9_DXVA2_HWACCEL 0 ++#define CONFIG_VP9_NVDEC_HWACCEL 0 ++#define CONFIG_VP9_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_VDPAU_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 ++#define CONFIG_WMV3_DXVA2_HWACCEL 0 ++#define CONFIG_WMV3_NVDEC_HWACCEL 0 ++#define CONFIG_WMV3_VAAPI_HWACCEL 0 ++#define CONFIG_WMV3_VDPAU_HWACCEL 0 ++#define CONFIG_AAC_PARSER 1 ++#define CONFIG_AAC_LATM_PARSER 0 ++#define CONFIG_AC3_PARSER 0 ++#define CONFIG_ADX_PARSER 0 ++#define CONFIG_AV1_PARSER 0 ++#define CONFIG_AVS2_PARSER 0 ++#define CONFIG_BMP_PARSER 0 ++#define CONFIG_CAVSVIDEO_PARSER 0 ++#define CONFIG_COOK_PARSER 0 ++#define CONFIG_DCA_PARSER 0 ++#define CONFIG_DIRAC_PARSER 0 ++#define CONFIG_DNXHD_PARSER 0 ++#define CONFIG_DPX_PARSER 0 ++#define CONFIG_DVAUDIO_PARSER 0 ++#define CONFIG_DVBSUB_PARSER 0 ++#define CONFIG_DVDSUB_PARSER 0 ++#define CONFIG_DVD_NAV_PARSER 0 ++#define CONFIG_FLAC_PARSER 1 ++#define CONFIG_G723_1_PARSER 0 ++#define CONFIG_G729_PARSER 0 ++#define CONFIG_GIF_PARSER 0 ++#define CONFIG_GSM_PARSER 0 ++#define CONFIG_H261_PARSER 0 ++#define CONFIG_H263_PARSER 0 ++#define CONFIG_H264_PARSER 1 ++#define CONFIG_HEVC_PARSER 0 ++#define CONFIG_JPEG2000_PARSER 0 ++#define CONFIG_MJPEG_PARSER 0 ++#define CONFIG_MLP_PARSER 0 ++#define CONFIG_MPEG4VIDEO_PARSER 0 ++#define CONFIG_MPEGAUDIO_PARSER 1 ++#define CONFIG_MPEGVIDEO_PARSER 0 ++#define CONFIG_OPUS_PARSER 1 ++#define CONFIG_PNG_PARSER 0 ++#define CONFIG_PNM_PARSER 0 ++#define CONFIG_RV30_PARSER 0 ++#define CONFIG_RV40_PARSER 0 ++#define CONFIG_SBC_PARSER 0 ++#define CONFIG_SIPR_PARSER 0 ++#define CONFIG_TAK_PARSER 0 ++#define CONFIG_VC1_PARSER 0 ++#define CONFIG_VORBIS_PARSER 1 ++#define CONFIG_VP3_PARSER 1 ++#define CONFIG_VP8_PARSER 1 ++#define CONFIG_VP9_PARSER 1 ++#define CONFIG_WEBP_PARSER 0 ++#define CONFIG_XMA_PARSER 0 ++#define CONFIG_ALSA_INDEV 0 ++#define CONFIG_ANDROID_CAMERA_INDEV 0 ++#define CONFIG_AVFOUNDATION_INDEV 0 ++#define CONFIG_BKTR_INDEV 0 ++#define CONFIG_DECKLINK_INDEV 0 ++#define CONFIG_DSHOW_INDEV 0 ++#define CONFIG_FBDEV_INDEV 0 ++#define CONFIG_GDIGRAB_INDEV 0 ++#define CONFIG_IEC61883_INDEV 0 ++#define CONFIG_JACK_INDEV 0 ++#define CONFIG_KMSGRAB_INDEV 0 ++#define CONFIG_LAVFI_INDEV 0 ++#define CONFIG_OPENAL_INDEV 0 ++#define CONFIG_OSS_INDEV 0 ++#define CONFIG_PULSE_INDEV 0 ++#define CONFIG_SNDIO_INDEV 0 ++#define CONFIG_V4L2_INDEV 0 ++#define CONFIG_VFWCAP_INDEV 0 ++#define CONFIG_XCBGRAB_INDEV 0 ++#define CONFIG_LIBCDIO_INDEV 0 ++#define CONFIG_LIBDC1394_INDEV 0 ++#define CONFIG_ALSA_OUTDEV 0 ++#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 ++#define CONFIG_CACA_OUTDEV 0 ++#define CONFIG_DECKLINK_OUTDEV 0 ++#define CONFIG_FBDEV_OUTDEV 0 ++#define CONFIG_OPENGL_OUTDEV 0 ++#define CONFIG_OSS_OUTDEV 0 ++#define CONFIG_PULSE_OUTDEV 0 ++#define CONFIG_SDL2_OUTDEV 0 ++#define CONFIG_SNDIO_OUTDEV 0 ++#define CONFIG_V4L2_OUTDEV 0 ++#define CONFIG_XV_OUTDEV 0 ++#define CONFIG_ABENCH_FILTER 0 ++#define CONFIG_ACOMPRESSOR_FILTER 0 ++#define CONFIG_ACONTRAST_FILTER 0 ++#define CONFIG_ACOPY_FILTER 0 ++#define CONFIG_ACUE_FILTER 0 ++#define CONFIG_ACROSSFADE_FILTER 0 ++#define CONFIG_ACROSSOVER_FILTER 0 ++#define CONFIG_ACRUSHER_FILTER 0 ++#define CONFIG_ADECLICK_FILTER 0 ++#define CONFIG_ADECLIP_FILTER 0 ++#define CONFIG_ADELAY_FILTER 0 ++#define CONFIG_ADERIVATIVE_FILTER 0 ++#define CONFIG_AECHO_FILTER 0 ++#define CONFIG_AEMPHASIS_FILTER 0 ++#define CONFIG_AEVAL_FILTER 0 ++#define CONFIG_AFADE_FILTER 0 ++#define CONFIG_AFFTDN_FILTER 0 ++#define CONFIG_AFFTFILT_FILTER 0 ++#define CONFIG_AFIR_FILTER 0 ++#define CONFIG_AFORMAT_FILTER 0 ++#define CONFIG_AGATE_FILTER 0 ++#define CONFIG_AIIR_FILTER 0 ++#define CONFIG_AINTEGRAL_FILTER 0 ++#define CONFIG_AINTERLEAVE_FILTER 0 ++#define CONFIG_ALIMITER_FILTER 0 ++#define CONFIG_ALLPASS_FILTER 0 ++#define CONFIG_ALOOP_FILTER 0 ++#define CONFIG_AMERGE_FILTER 0 ++#define CONFIG_AMETADATA_FILTER 0 ++#define CONFIG_AMIX_FILTER 0 ++#define CONFIG_AMULTIPLY_FILTER 0 ++#define CONFIG_ANEQUALIZER_FILTER 0 ++#define CONFIG_ANLMDN_FILTER 0 ++#define CONFIG_ANLMS_FILTER 0 ++#define CONFIG_ANULL_FILTER 0 ++#define CONFIG_APAD_FILTER 0 ++#define CONFIG_APERMS_FILTER 0 ++#define CONFIG_APHASER_FILTER 0 ++#define CONFIG_APULSATOR_FILTER 0 ++#define CONFIG_AREALTIME_FILTER 0 ++#define CONFIG_ARESAMPLE_FILTER 0 ++#define CONFIG_AREVERSE_FILTER 0 ++#define CONFIG_ARNNDN_FILTER 0 ++#define CONFIG_ASELECT_FILTER 0 ++#define CONFIG_ASENDCMD_FILTER 0 ++#define CONFIG_ASETNSAMPLES_FILTER 0 ++#define CONFIG_ASETPTS_FILTER 0 ++#define CONFIG_ASETRATE_FILTER 0 ++#define CONFIG_ASETTB_FILTER 0 ++#define CONFIG_ASHOWINFO_FILTER 0 ++#define CONFIG_ASIDEDATA_FILTER 0 ++#define CONFIG_ASOFTCLIP_FILTER 0 ++#define CONFIG_ASPLIT_FILTER 0 ++#define CONFIG_ASR_FILTER 0 ++#define CONFIG_ASTATS_FILTER 0 ++#define CONFIG_ASTREAMSELECT_FILTER 0 ++#define CONFIG_ASUBBOOST_FILTER 0 ++#define CONFIG_ATEMPO_FILTER 0 ++#define CONFIG_ATRIM_FILTER 0 ++#define CONFIG_AXCORRELATE_FILTER 0 ++#define CONFIG_AZMQ_FILTER 0 ++#define CONFIG_BANDPASS_FILTER 0 ++#define CONFIG_BANDREJECT_FILTER 0 ++#define CONFIG_BASS_FILTER 0 ++#define CONFIG_BIQUAD_FILTER 0 ++#define CONFIG_BS2B_FILTER 0 ++#define CONFIG_CHROMABER_VULKAN_FILTER 0 ++#define CONFIG_CHANNELMAP_FILTER 0 ++#define CONFIG_CHANNELSPLIT_FILTER 0 ++#define CONFIG_CHORUS_FILTER 0 ++#define CONFIG_COMPAND_FILTER 0 ++#define CONFIG_COMPENSATIONDELAY_FILTER 0 ++#define CONFIG_CROSSFEED_FILTER 0 ++#define CONFIG_CRYSTALIZER_FILTER 0 ++#define CONFIG_DCSHIFT_FILTER 0 ++#define CONFIG_DEESSER_FILTER 0 ++#define CONFIG_DRMETER_FILTER 0 ++#define CONFIG_DYNAUDNORM_FILTER 0 ++#define CONFIG_EARWAX_FILTER 0 ++#define CONFIG_EBUR128_FILTER 0 ++#define CONFIG_EQUALIZER_FILTER 0 ++#define CONFIG_EXTRASTEREO_FILTER 0 ++#define CONFIG_FIREQUALIZER_FILTER 0 ++#define CONFIG_FLANGER_FILTER 0 ++#define CONFIG_HAAS_FILTER 0 ++#define CONFIG_HDCD_FILTER 0 ++#define CONFIG_HEADPHONE_FILTER 0 ++#define CONFIG_HIGHPASS_FILTER 0 ++#define CONFIG_HIGHSHELF_FILTER 0 ++#define CONFIG_JOIN_FILTER 0 ++#define CONFIG_LADSPA_FILTER 0 ++#define CONFIG_LOUDNORM_FILTER 0 ++#define CONFIG_LOWPASS_FILTER 0 ++#define CONFIG_LOWSHELF_FILTER 0 ++#define CONFIG_LV2_FILTER 0 ++#define CONFIG_MCOMPAND_FILTER 0 ++#define CONFIG_PAN_FILTER 0 ++#define CONFIG_REPLAYGAIN_FILTER 0 ++#define CONFIG_RESAMPLE_FILTER 0 ++#define CONFIG_RUBBERBAND_FILTER 0 ++#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 ++#define CONFIG_SIDECHAINGATE_FILTER 0 ++#define CONFIG_SILENCEDETECT_FILTER 0 ++#define CONFIG_SILENCEREMOVE_FILTER 0 ++#define CONFIG_SOFALIZER_FILTER 0 ++#define CONFIG_STEREOTOOLS_FILTER 0 ++#define CONFIG_STEREOWIDEN_FILTER 0 ++#define CONFIG_SUPEREQUALIZER_FILTER 0 ++#define CONFIG_SURROUND_FILTER 0 ++#define CONFIG_TREBLE_FILTER 0 ++#define CONFIG_TREMOLO_FILTER 0 ++#define CONFIG_VIBRATO_FILTER 0 ++#define CONFIG_VOLUME_FILTER 0 ++#define CONFIG_VOLUMEDETECT_FILTER 0 ++#define CONFIG_AEVALSRC_FILTER 0 ++#define CONFIG_AFIRSRC_FILTER 0 ++#define CONFIG_ANOISESRC_FILTER 0 ++#define CONFIG_ANULLSRC_FILTER 0 ++#define CONFIG_FLITE_FILTER 0 ++#define CONFIG_HILBERT_FILTER 0 ++#define CONFIG_SINC_FILTER 0 ++#define CONFIG_SINE_FILTER 0 ++#define CONFIG_ANULLSINK_FILTER 0 ++#define CONFIG_ADDROI_FILTER 0 ++#define CONFIG_ALPHAEXTRACT_FILTER 0 ++#define CONFIG_ALPHAMERGE_FILTER 0 ++#define CONFIG_AMPLIFY_FILTER 0 ++#define CONFIG_ASS_FILTER 0 ++#define CONFIG_ATADENOISE_FILTER 0 ++#define CONFIG_AVGBLUR_FILTER 0 ++#define CONFIG_AVGBLUR_OPENCL_FILTER 0 ++#define CONFIG_AVGBLUR_VULKAN_FILTER 0 ++#define CONFIG_BBOX_FILTER 0 ++#define CONFIG_BENCH_FILTER 0 ++#define CONFIG_BILATERAL_FILTER 0 ++#define CONFIG_BITPLANENOISE_FILTER 0 ++#define CONFIG_BLACKDETECT_FILTER 0 ++#define CONFIG_BLACKFRAME_FILTER 0 ++#define CONFIG_BLEND_FILTER 0 ++#define CONFIG_BM3D_FILTER 0 ++#define CONFIG_BOXBLUR_FILTER 0 ++#define CONFIG_BOXBLUR_OPENCL_FILTER 0 ++#define CONFIG_BWDIF_FILTER 0 ++#define CONFIG_CAS_FILTER 0 ++#define CONFIG_CHROMAHOLD_FILTER 0 ++#define CONFIG_CHROMAKEY_FILTER 0 ++#define CONFIG_CHROMANR_FILTER 0 ++#define CONFIG_CHROMASHIFT_FILTER 0 ++#define CONFIG_CIESCOPE_FILTER 0 ++#define CONFIG_CODECVIEW_FILTER 0 ++#define CONFIG_COLORBALANCE_FILTER 0 ++#define CONFIG_COLORCHANNELMIXER_FILTER 0 ++#define CONFIG_COLORKEY_FILTER 0 ++#define CONFIG_COLORKEY_OPENCL_FILTER 0 ++#define CONFIG_COLORHOLD_FILTER 0 ++#define CONFIG_COLORLEVELS_FILTER 0 ++#define CONFIG_COLORMATRIX_FILTER 0 ++#define CONFIG_COLORSPACE_FILTER 0 ++#define CONFIG_CONVOLUTION_FILTER 0 ++#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 ++#define CONFIG_CONVOLVE_FILTER 0 ++#define CONFIG_COPY_FILTER 0 ++#define CONFIG_COREIMAGE_FILTER 0 ++#define CONFIG_COVER_RECT_FILTER 0 ++#define CONFIG_CROP_FILTER 0 ++#define CONFIG_CROPDETECT_FILTER 0 ++#define CONFIG_CUE_FILTER 0 ++#define CONFIG_CURVES_FILTER 0 ++#define CONFIG_DATASCOPE_FILTER 0 ++#define CONFIG_DBLUR_FILTER 0 ++#define CONFIG_DCTDNOIZ_FILTER 0 ++#define CONFIG_DEBAND_FILTER 0 ++#define CONFIG_DEBLOCK_FILTER 0 ++#define CONFIG_DECIMATE_FILTER 0 ++#define CONFIG_DECONVOLVE_FILTER 0 ++#define CONFIG_DEDOT_FILTER 0 ++#define CONFIG_DEFLATE_FILTER 0 ++#define CONFIG_DEFLICKER_FILTER 0 ++#define CONFIG_DEINTERLACE_QSV_FILTER 0 ++#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 ++#define CONFIG_DEJUDDER_FILTER 0 ++#define CONFIG_DELOGO_FILTER 0 ++#define CONFIG_DENOISE_VAAPI_FILTER 0 ++#define CONFIG_DERAIN_FILTER 0 ++#define CONFIG_DESHAKE_FILTER 0 ++#define CONFIG_DESHAKE_OPENCL_FILTER 0 ++#define CONFIG_DESPILL_FILTER 0 ++#define CONFIG_DETELECINE_FILTER 0 ++#define CONFIG_DILATION_FILTER 0 ++#define CONFIG_DILATION_OPENCL_FILTER 0 ++#define CONFIG_DISPLACE_FILTER 0 ++#define CONFIG_DNN_PROCESSING_FILTER 0 ++#define CONFIG_DOUBLEWEAVE_FILTER 0 ++#define CONFIG_DRAWBOX_FILTER 0 ++#define CONFIG_DRAWGRAPH_FILTER 0 ++#define CONFIG_DRAWGRID_FILTER 0 ++#define CONFIG_DRAWTEXT_FILTER 0 ++#define CONFIG_EDGEDETECT_FILTER 0 ++#define CONFIG_ELBG_FILTER 0 ++#define CONFIG_ENTROPY_FILTER 0 ++#define CONFIG_EQ_FILTER 0 ++#define CONFIG_EROSION_FILTER 0 ++#define CONFIG_EROSION_OPENCL_FILTER 0 ++#define CONFIG_EXTRACTPLANES_FILTER 0 ++#define CONFIG_FADE_FILTER 0 ++#define CONFIG_FFTDNOIZ_FILTER 0 ++#define CONFIG_FFTFILT_FILTER 0 ++#define CONFIG_FIELD_FILTER 0 ++#define CONFIG_FIELDHINT_FILTER 0 ++#define CONFIG_FIELDMATCH_FILTER 0 ++#define CONFIG_FIELDORDER_FILTER 0 ++#define CONFIG_FILLBORDERS_FILTER 0 ++#define CONFIG_FIND_RECT_FILTER 0 ++#define CONFIG_FLOODFILL_FILTER 0 ++#define CONFIG_FORMAT_FILTER 0 ++#define CONFIG_FPS_FILTER 0 ++#define CONFIG_FRAMEPACK_FILTER 0 ++#define CONFIG_FRAMERATE_FILTER 0 ++#define CONFIG_FRAMESTEP_FILTER 0 ++#define CONFIG_FREEZEDETECT_FILTER 0 ++#define CONFIG_FREEZEFRAMES_FILTER 0 ++#define CONFIG_FREI0R_FILTER 0 ++#define CONFIG_FSPP_FILTER 0 ++#define CONFIG_GBLUR_FILTER 0 ++#define CONFIG_GEQ_FILTER 0 ++#define CONFIG_GRADFUN_FILTER 0 ++#define CONFIG_GRAPHMONITOR_FILTER 0 ++#define CONFIG_GREYEDGE_FILTER 0 ++#define CONFIG_HALDCLUT_FILTER 0 ++#define CONFIG_HFLIP_FILTER 0 ++#define CONFIG_HISTEQ_FILTER 0 ++#define CONFIG_HISTOGRAM_FILTER 0 ++#define CONFIG_HQDN3D_FILTER 0 ++#define CONFIG_HQX_FILTER 0 ++#define CONFIG_HSTACK_FILTER 0 ++#define CONFIG_HUE_FILTER 0 ++#define CONFIG_HWDOWNLOAD_FILTER 0 ++#define CONFIG_HWMAP_FILTER 0 ++#define CONFIG_HWUPLOAD_FILTER 0 ++#define CONFIG_HWUPLOAD_CUDA_FILTER 0 ++#define CONFIG_HYSTERESIS_FILTER 0 ++#define CONFIG_IDET_FILTER 0 ++#define CONFIG_IL_FILTER 0 ++#define CONFIG_INFLATE_FILTER 0 ++#define CONFIG_INTERLACE_FILTER 0 ++#define CONFIG_INTERLEAVE_FILTER 0 ++#define CONFIG_KERNDEINT_FILTER 0 ++#define CONFIG_LAGFUN_FILTER 0 ++#define CONFIG_LENSCORRECTION_FILTER 0 ++#define CONFIG_LENSFUN_FILTER 0 ++#define CONFIG_LIBVMAF_FILTER 0 ++#define CONFIG_LIMITER_FILTER 0 ++#define CONFIG_LOOP_FILTER 0 ++#define CONFIG_LUMAKEY_FILTER 0 ++#define CONFIG_LUT_FILTER 0 ++#define CONFIG_LUT1D_FILTER 0 ++#define CONFIG_LUT2_FILTER 0 ++#define CONFIG_LUT3D_FILTER 0 ++#define CONFIG_LUTRGB_FILTER 0 ++#define CONFIG_LUTYUV_FILTER 0 ++#define CONFIG_MASKEDCLAMP_FILTER 0 ++#define CONFIG_MASKEDMAX_FILTER 0 ++#define CONFIG_MASKEDMERGE_FILTER 0 ++#define CONFIG_MASKEDMIN_FILTER 0 ++#define CONFIG_MASKEDTHRESHOLD_FILTER 0 ++#define CONFIG_MASKFUN_FILTER 0 ++#define CONFIG_MCDEINT_FILTER 0 ++#define CONFIG_MEDIAN_FILTER 0 ++#define CONFIG_MERGEPLANES_FILTER 0 ++#define CONFIG_MESTIMATE_FILTER 0 ++#define CONFIG_METADATA_FILTER 0 ++#define CONFIG_MIDEQUALIZER_FILTER 0 ++#define CONFIG_MINTERPOLATE_FILTER 0 ++#define CONFIG_MIX_FILTER 0 ++#define CONFIG_MPDECIMATE_FILTER 0 ++#define CONFIG_NEGATE_FILTER 0 ++#define CONFIG_NLMEANS_FILTER 0 ++#define CONFIG_NLMEANS_OPENCL_FILTER 0 ++#define CONFIG_NNEDI_FILTER 0 ++#define CONFIG_NOFORMAT_FILTER 0 ++#define CONFIG_NOISE_FILTER 0 ++#define CONFIG_NORMALIZE_FILTER 0 ++#define CONFIG_NULL_FILTER 0 ++#define CONFIG_OCR_FILTER 0 ++#define CONFIG_OCV_FILTER 0 ++#define CONFIG_OSCILLOSCOPE_FILTER 0 ++#define CONFIG_OVERLAY_FILTER 0 ++#define CONFIG_OVERLAY_OPENCL_FILTER 0 ++#define CONFIG_OVERLAY_QSV_FILTER 0 ++#define CONFIG_OVERLAY_VULKAN_FILTER 0 ++#define CONFIG_OVERLAY_CUDA_FILTER 0 ++#define CONFIG_OWDENOISE_FILTER 0 ++#define CONFIG_PAD_FILTER 0 ++#define CONFIG_PAD_OPENCL_FILTER 0 ++#define CONFIG_PALETTEGEN_FILTER 0 ++#define CONFIG_PALETTEUSE_FILTER 0 ++#define CONFIG_PERMS_FILTER 0 ++#define CONFIG_PERSPECTIVE_FILTER 0 ++#define CONFIG_PHASE_FILTER 0 ++#define CONFIG_PHOTOSENSITIVITY_FILTER 0 ++#define CONFIG_PIXDESCTEST_FILTER 0 ++#define CONFIG_PIXSCOPE_FILTER 0 ++#define CONFIG_PP_FILTER 0 ++#define CONFIG_PP7_FILTER 0 ++#define CONFIG_PREMULTIPLY_FILTER 0 ++#define CONFIG_PREWITT_FILTER 0 ++#define CONFIG_PREWITT_OPENCL_FILTER 0 ++#define CONFIG_PROCAMP_VAAPI_FILTER 0 ++#define CONFIG_PROGRAM_OPENCL_FILTER 0 ++#define CONFIG_PSEUDOCOLOR_FILTER 0 ++#define CONFIG_PSNR_FILTER 0 ++#define CONFIG_PULLUP_FILTER 0 ++#define CONFIG_QP_FILTER 0 ++#define CONFIG_RANDOM_FILTER 0 ++#define CONFIG_READEIA608_FILTER 0 ++#define CONFIG_READVITC_FILTER 0 ++#define CONFIG_REALTIME_FILTER 0 ++#define CONFIG_REMAP_FILTER 0 ++#define CONFIG_REMOVEGRAIN_FILTER 0 ++#define CONFIG_REMOVELOGO_FILTER 0 ++#define CONFIG_REPEATFIELDS_FILTER 0 ++#define CONFIG_REVERSE_FILTER 0 ++#define CONFIG_RGBASHIFT_FILTER 0 ++#define CONFIG_ROBERTS_FILTER 0 ++#define CONFIG_ROBERTS_OPENCL_FILTER 0 ++#define CONFIG_ROTATE_FILTER 0 ++#define CONFIG_SAB_FILTER 0 ++#define CONFIG_SCALE_FILTER 0 ++#define CONFIG_SCALE_CUDA_FILTER 0 ++#define CONFIG_SCALE_NPP_FILTER 0 ++#define CONFIG_SCALE_QSV_FILTER 0 ++#define CONFIG_SCALE_VAAPI_FILTER 0 ++#define CONFIG_SCALE_VULKAN_FILTER 0 ++#define CONFIG_SCALE2REF_FILTER 0 ++#define CONFIG_SCDET_FILTER 0 ++#define CONFIG_SCROLL_FILTER 0 ++#define CONFIG_SELECT_FILTER 0 ++#define CONFIG_SELECTIVECOLOR_FILTER 0 ++#define CONFIG_SENDCMD_FILTER 0 ++#define CONFIG_SEPARATEFIELDS_FILTER 0 ++#define CONFIG_SETDAR_FILTER 0 ++#define CONFIG_SETFIELD_FILTER 0 ++#define CONFIG_SETPARAMS_FILTER 0 ++#define CONFIG_SETPTS_FILTER 0 ++#define CONFIG_SETRANGE_FILTER 0 ++#define CONFIG_SETSAR_FILTER 0 ++#define CONFIG_SETTB_FILTER 0 ++#define CONFIG_SHARPNESS_VAAPI_FILTER 0 ++#define CONFIG_SHOWINFO_FILTER 0 ++#define CONFIG_SHOWPALETTE_FILTER 0 ++#define CONFIG_SHUFFLEFRAMES_FILTER 0 ++#define CONFIG_SHUFFLEPLANES_FILTER 0 ++#define CONFIG_SIDEDATA_FILTER 0 ++#define CONFIG_SIGNALSTATS_FILTER 0 ++#define CONFIG_SIGNATURE_FILTER 0 ++#define CONFIG_SMARTBLUR_FILTER 0 ++#define CONFIG_SOBEL_FILTER 0 ++#define CONFIG_SOBEL_OPENCL_FILTER 0 ++#define CONFIG_SPLIT_FILTER 0 ++#define CONFIG_SPP_FILTER 0 ++#define CONFIG_SR_FILTER 0 ++#define CONFIG_SSIM_FILTER 0 ++#define CONFIG_STEREO3D_FILTER 0 ++#define CONFIG_STREAMSELECT_FILTER 0 ++#define CONFIG_SUBTITLES_FILTER 0 ++#define CONFIG_SUPER2XSAI_FILTER 0 ++#define CONFIG_SWAPRECT_FILTER 0 ++#define CONFIG_SWAPUV_FILTER 0 ++#define CONFIG_TBLEND_FILTER 0 ++#define CONFIG_TELECINE_FILTER 0 ++#define CONFIG_THISTOGRAM_FILTER 0 ++#define CONFIG_THRESHOLD_FILTER 0 ++#define CONFIG_THUMBNAIL_FILTER 0 ++#define CONFIG_THUMBNAIL_CUDA_FILTER 0 ++#define CONFIG_TILE_FILTER 0 ++#define CONFIG_TINTERLACE_FILTER 0 ++#define CONFIG_TLUT2_FILTER 0 ++#define CONFIG_TMEDIAN_FILTER 0 ++#define CONFIG_TMIX_FILTER 0 ++#define CONFIG_TONEMAP_FILTER 0 ++#define CONFIG_TONEMAP_OPENCL_FILTER 0 ++#define CONFIG_TONEMAP_VAAPI_FILTER 0 ++#define CONFIG_TPAD_FILTER 0 ++#define CONFIG_TRANSPOSE_FILTER 0 ++#define CONFIG_TRANSPOSE_NPP_FILTER 0 ++#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 ++#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 ++#define CONFIG_TRIM_FILTER 0 ++#define CONFIG_UNPREMULTIPLY_FILTER 0 ++#define CONFIG_UNSHARP_FILTER 0 ++#define CONFIG_UNSHARP_OPENCL_FILTER 0 ++#define CONFIG_UNTILE_FILTER 0 ++#define CONFIG_USPP_FILTER 0 ++#define CONFIG_V360_FILTER 0 ++#define CONFIG_VAGUEDENOISER_FILTER 0 ++#define CONFIG_VECTORSCOPE_FILTER 0 ++#define CONFIG_VFLIP_FILTER 0 ++#define CONFIG_VFRDET_FILTER 0 ++#define CONFIG_VIBRANCE_FILTER 0 ++#define CONFIG_VIDSTABDETECT_FILTER 0 ++#define CONFIG_VIDSTABTRANSFORM_FILTER 0 ++#define CONFIG_VIGNETTE_FILTER 0 ++#define CONFIG_VMAFMOTION_FILTER 0 ++#define CONFIG_VPP_QSV_FILTER 0 ++#define CONFIG_VSTACK_FILTER 0 ++#define CONFIG_W3FDIF_FILTER 0 ++#define CONFIG_WAVEFORM_FILTER 0 ++#define CONFIG_WEAVE_FILTER 0 ++#define CONFIG_XBR_FILTER 0 ++#define CONFIG_XFADE_FILTER 0 ++#define CONFIG_XFADE_OPENCL_FILTER 0 ++#define CONFIG_XMEDIAN_FILTER 0 ++#define CONFIG_XSTACK_FILTER 0 ++#define CONFIG_YADIF_FILTER 0 ++#define CONFIG_YADIF_CUDA_FILTER 0 ++#define CONFIG_YAEPBLUR_FILTER 0 ++#define CONFIG_ZMQ_FILTER 0 ++#define CONFIG_ZOOMPAN_FILTER 0 ++#define CONFIG_ZSCALE_FILTER 0 ++#define CONFIG_ALLRGB_FILTER 0 ++#define CONFIG_ALLYUV_FILTER 0 ++#define CONFIG_CELLAUTO_FILTER 0 ++#define CONFIG_COLOR_FILTER 0 ++#define CONFIG_COREIMAGESRC_FILTER 0 ++#define CONFIG_FREI0R_SRC_FILTER 0 ++#define CONFIG_GRADIENTS_FILTER 0 ++#define CONFIG_HALDCLUTSRC_FILTER 0 ++#define CONFIG_LIFE_FILTER 0 ++#define CONFIG_MANDELBROT_FILTER 0 ++#define CONFIG_MPTESTSRC_FILTER 0 ++#define CONFIG_NULLSRC_FILTER 0 ++#define CONFIG_OPENCLSRC_FILTER 0 ++#define CONFIG_PAL75BARS_FILTER 0 ++#define CONFIG_PAL100BARS_FILTER 0 ++#define CONFIG_RGBTESTSRC_FILTER 0 ++#define CONFIG_SIERPINSKI_FILTER 0 ++#define CONFIG_SMPTEBARS_FILTER 0 ++#define CONFIG_SMPTEHDBARS_FILTER 0 ++#define CONFIG_TESTSRC_FILTER 0 ++#define CONFIG_TESTSRC2_FILTER 0 ++#define CONFIG_YUVTESTSRC_FILTER 0 ++#define CONFIG_NULLSINK_FILTER 0 ++#define CONFIG_ABITSCOPE_FILTER 0 ++#define CONFIG_ADRAWGRAPH_FILTER 0 ++#define CONFIG_AGRAPHMONITOR_FILTER 0 ++#define CONFIG_AHISTOGRAM_FILTER 0 ++#define CONFIG_APHASEMETER_FILTER 0 ++#define CONFIG_AVECTORSCOPE_FILTER 0 ++#define CONFIG_CONCAT_FILTER 0 ++#define CONFIG_SHOWCQT_FILTER 0 ++#define CONFIG_SHOWFREQS_FILTER 0 ++#define CONFIG_SHOWSPATIAL_FILTER 0 ++#define CONFIG_SHOWSPECTRUM_FILTER 0 ++#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 ++#define CONFIG_SHOWVOLUME_FILTER 0 ++#define CONFIG_SHOWWAVES_FILTER 0 ++#define CONFIG_SHOWWAVESPIC_FILTER 0 ++#define CONFIG_SPECTRUMSYNTH_FILTER 0 ++#define CONFIG_AMOVIE_FILTER 0 ++#define CONFIG_MOVIE_FILTER 0 ++#define CONFIG_AFIFO_FILTER 0 ++#define CONFIG_FIFO_FILTER 0 ++#define CONFIG_AA_DEMUXER 0 ++#define CONFIG_AAC_DEMUXER 1 ++#define CONFIG_AC3_DEMUXER 0 ++#define CONFIG_ACM_DEMUXER 0 ++#define CONFIG_ACT_DEMUXER 0 ++#define CONFIG_ADF_DEMUXER 0 ++#define CONFIG_ADP_DEMUXER 0 ++#define CONFIG_ADS_DEMUXER 0 ++#define CONFIG_ADX_DEMUXER 0 ++#define CONFIG_AEA_DEMUXER 0 ++#define CONFIG_AFC_DEMUXER 0 ++#define CONFIG_AIFF_DEMUXER 0 ++#define CONFIG_AIX_DEMUXER 0 ++#define CONFIG_ALP_DEMUXER 0 ++#define CONFIG_AMR_DEMUXER 0 ++#define CONFIG_AMRNB_DEMUXER 0 ++#define CONFIG_AMRWB_DEMUXER 0 ++#define CONFIG_ANM_DEMUXER 0 ++#define CONFIG_APC_DEMUXER 0 ++#define CONFIG_APE_DEMUXER 0 ++#define CONFIG_APM_DEMUXER 0 ++#define CONFIG_APNG_DEMUXER 0 ++#define CONFIG_APTX_DEMUXER 0 ++#define CONFIG_APTX_HD_DEMUXER 0 ++#define CONFIG_AQTITLE_DEMUXER 0 ++#define CONFIG_ARGO_ASF_DEMUXER 0 ++#define CONFIG_ASF_DEMUXER 0 ++#define CONFIG_ASF_O_DEMUXER 0 ++#define CONFIG_ASS_DEMUXER 0 ++#define CONFIG_AST_DEMUXER 0 ++#define CONFIG_AU_DEMUXER 0 ++#define CONFIG_AV1_DEMUXER 0 ++#define CONFIG_AVI_DEMUXER 0 ++#define CONFIG_AVISYNTH_DEMUXER 0 ++#define CONFIG_AVR_DEMUXER 0 ++#define CONFIG_AVS_DEMUXER 0 ++#define CONFIG_AVS2_DEMUXER 0 ++#define CONFIG_BETHSOFTVID_DEMUXER 0 ++#define CONFIG_BFI_DEMUXER 0 ++#define CONFIG_BINTEXT_DEMUXER 0 ++#define CONFIG_BINK_DEMUXER 0 ++#define CONFIG_BIT_DEMUXER 0 ++#define CONFIG_BMV_DEMUXER 0 ++#define CONFIG_BFSTM_DEMUXER 0 ++#define CONFIG_BRSTM_DEMUXER 0 ++#define CONFIG_BOA_DEMUXER 0 ++#define CONFIG_C93_DEMUXER 0 ++#define CONFIG_CAF_DEMUXER 0 ++#define CONFIG_CAVSVIDEO_DEMUXER 0 ++#define CONFIG_CDG_DEMUXER 0 ++#define CONFIG_CDXL_DEMUXER 0 ++#define CONFIG_CINE_DEMUXER 0 ++#define CONFIG_CODEC2_DEMUXER 0 ++#define CONFIG_CODEC2RAW_DEMUXER 0 ++#define CONFIG_CONCAT_DEMUXER 0 ++#define CONFIG_DASH_DEMUXER 0 ++#define CONFIG_DATA_DEMUXER 0 ++#define CONFIG_DAUD_DEMUXER 0 ++#define CONFIG_DCSTR_DEMUXER 0 ++#define CONFIG_DERF_DEMUXER 0 ++#define CONFIG_DFA_DEMUXER 0 ++#define CONFIG_DHAV_DEMUXER 0 ++#define CONFIG_DIRAC_DEMUXER 0 ++#define CONFIG_DNXHD_DEMUXER 0 ++#define CONFIG_DSF_DEMUXER 0 ++#define CONFIG_DSICIN_DEMUXER 0 ++#define CONFIG_DSS_DEMUXER 0 ++#define CONFIG_DTS_DEMUXER 0 ++#define CONFIG_DTSHD_DEMUXER 0 ++#define CONFIG_DV_DEMUXER 0 ++#define CONFIG_DVBSUB_DEMUXER 0 ++#define CONFIG_DVBTXT_DEMUXER 0 ++#define CONFIG_DXA_DEMUXER 0 ++#define CONFIG_EA_DEMUXER 0 ++#define CONFIG_EA_CDATA_DEMUXER 0 ++#define CONFIG_EAC3_DEMUXER 0 ++#define CONFIG_EPAF_DEMUXER 0 ++#define CONFIG_FFMETADATA_DEMUXER 0 ++#define CONFIG_FILMSTRIP_DEMUXER 0 ++#define CONFIG_FITS_DEMUXER 0 ++#define CONFIG_FLAC_DEMUXER 1 ++#define CONFIG_FLIC_DEMUXER 0 ++#define CONFIG_FLV_DEMUXER 0 ++#define CONFIG_LIVE_FLV_DEMUXER 0 ++#define CONFIG_FOURXM_DEMUXER 0 ++#define CONFIG_FRM_DEMUXER 0 ++#define CONFIG_FSB_DEMUXER 0 ++#define CONFIG_FWSE_DEMUXER 0 ++#define CONFIG_G722_DEMUXER 0 ++#define CONFIG_G723_1_DEMUXER 0 ++#define CONFIG_G726_DEMUXER 0 ++#define CONFIG_G726LE_DEMUXER 0 ++#define CONFIG_G729_DEMUXER 0 ++#define CONFIG_GDV_DEMUXER 0 ++#define CONFIG_GENH_DEMUXER 0 ++#define CONFIG_GIF_DEMUXER 0 ++#define CONFIG_GSM_DEMUXER 0 ++#define CONFIG_GXF_DEMUXER 0 ++#define CONFIG_H261_DEMUXER 0 ++#define CONFIG_H263_DEMUXER 0 ++#define CONFIG_H264_DEMUXER 0 ++#define CONFIG_HCA_DEMUXER 0 ++#define CONFIG_HCOM_DEMUXER 0 ++#define CONFIG_HEVC_DEMUXER 0 ++#define CONFIG_HLS_DEMUXER 0 ++#define CONFIG_HNM_DEMUXER 0 ++#define CONFIG_ICO_DEMUXER 0 ++#define CONFIG_IDCIN_DEMUXER 0 ++#define CONFIG_IDF_DEMUXER 0 ++#define CONFIG_IFF_DEMUXER 0 ++#define CONFIG_IFV_DEMUXER 0 ++#define CONFIG_ILBC_DEMUXER 0 ++#define CONFIG_IMAGE2_DEMUXER 0 ++#define CONFIG_IMAGE2PIPE_DEMUXER 0 ++#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 ++#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 ++#define CONFIG_INGENIENT_DEMUXER 0 ++#define CONFIG_IPMOVIE_DEMUXER 0 ++#define CONFIG_IRCAM_DEMUXER 0 ++#define CONFIG_ISS_DEMUXER 0 ++#define CONFIG_IV8_DEMUXER 0 ++#define CONFIG_IVF_DEMUXER 0 ++#define CONFIG_IVR_DEMUXER 0 ++#define CONFIG_JACOSUB_DEMUXER 0 ++#define CONFIG_JV_DEMUXER 0 ++#define CONFIG_KUX_DEMUXER 0 ++#define CONFIG_KVAG_DEMUXER 0 ++#define CONFIG_LMLM4_DEMUXER 0 ++#define CONFIG_LOAS_DEMUXER 0 ++#define CONFIG_LRC_DEMUXER 0 ++#define CONFIG_LVF_DEMUXER 0 ++#define CONFIG_LXF_DEMUXER 0 ++#define CONFIG_M4V_DEMUXER 0 ++#define CONFIG_MCC_DEMUXER 0 ++#define CONFIG_MATROSKA_DEMUXER 1 ++#define CONFIG_MGSTS_DEMUXER 0 ++#define CONFIG_MICRODVD_DEMUXER 0 ++#define CONFIG_MJPEG_DEMUXER 0 ++#define CONFIG_MJPEG_2000_DEMUXER 0 ++#define CONFIG_MLP_DEMUXER 0 ++#define CONFIG_MLV_DEMUXER 0 ++#define CONFIG_MM_DEMUXER 0 ++#define CONFIG_MMF_DEMUXER 0 ++#define CONFIG_MOV_DEMUXER 1 ++#define CONFIG_MP3_DEMUXER 1 ++#define CONFIG_MPC_DEMUXER 0 ++#define CONFIG_MPC8_DEMUXER 0 ++#define CONFIG_MPEGPS_DEMUXER 0 ++#define CONFIG_MPEGTS_DEMUXER 0 ++#define CONFIG_MPEGTSRAW_DEMUXER 0 ++#define CONFIG_MPEGVIDEO_DEMUXER 0 ++#define CONFIG_MPJPEG_DEMUXER 0 ++#define CONFIG_MPL2_DEMUXER 0 ++#define CONFIG_MPSUB_DEMUXER 0 ++#define CONFIG_MSF_DEMUXER 0 ++#define CONFIG_MSNWC_TCP_DEMUXER 0 ++#define CONFIG_MTAF_DEMUXER 0 ++#define CONFIG_MTV_DEMUXER 0 ++#define CONFIG_MUSX_DEMUXER 0 ++#define CONFIG_MV_DEMUXER 0 ++#define CONFIG_MVI_DEMUXER 0 ++#define CONFIG_MXF_DEMUXER 0 ++#define CONFIG_MXG_DEMUXER 0 ++#define CONFIG_NC_DEMUXER 0 ++#define CONFIG_NISTSPHERE_DEMUXER 0 ++#define CONFIG_NSP_DEMUXER 0 ++#define CONFIG_NSV_DEMUXER 0 ++#define CONFIG_NUT_DEMUXER 0 ++#define CONFIG_NUV_DEMUXER 0 ++#define CONFIG_OBU_DEMUXER 0 ++#define CONFIG_OGG_DEMUXER 1 ++#define CONFIG_OMA_DEMUXER 0 ++#define CONFIG_PAF_DEMUXER 0 ++#define CONFIG_PCM_ALAW_DEMUXER 0 ++#define CONFIG_PCM_MULAW_DEMUXER 0 ++#define CONFIG_PCM_VIDC_DEMUXER 0 ++#define CONFIG_PCM_F64BE_DEMUXER 0 ++#define CONFIG_PCM_F64LE_DEMUXER 0 ++#define CONFIG_PCM_F32BE_DEMUXER 0 ++#define CONFIG_PCM_F32LE_DEMUXER 0 ++#define CONFIG_PCM_S32BE_DEMUXER 0 ++#define CONFIG_PCM_S32LE_DEMUXER 0 ++#define CONFIG_PCM_S24BE_DEMUXER 0 ++#define CONFIG_PCM_S24LE_DEMUXER 0 ++#define CONFIG_PCM_S16BE_DEMUXER 0 ++#define CONFIG_PCM_S16LE_DEMUXER 0 ++#define CONFIG_PCM_S8_DEMUXER 0 ++#define CONFIG_PCM_U32BE_DEMUXER 0 ++#define CONFIG_PCM_U32LE_DEMUXER 0 ++#define CONFIG_PCM_U24BE_DEMUXER 0 ++#define CONFIG_PCM_U24LE_DEMUXER 0 ++#define CONFIG_PCM_U16BE_DEMUXER 0 ++#define CONFIG_PCM_U16LE_DEMUXER 0 ++#define CONFIG_PCM_U8_DEMUXER 0 ++#define CONFIG_PJS_DEMUXER 0 ++#define CONFIG_PMP_DEMUXER 0 ++#define CONFIG_PP_BNK_DEMUXER 0 ++#define CONFIG_PVA_DEMUXER 0 ++#define CONFIG_PVF_DEMUXER 0 ++#define CONFIG_QCP_DEMUXER 0 ++#define CONFIG_R3D_DEMUXER 0 ++#define CONFIG_RAWVIDEO_DEMUXER 0 ++#define CONFIG_REALTEXT_DEMUXER 0 ++#define CONFIG_REDSPARK_DEMUXER 0 ++#define CONFIG_RL2_DEMUXER 0 ++#define CONFIG_RM_DEMUXER 0 ++#define CONFIG_ROQ_DEMUXER 0 ++#define CONFIG_RPL_DEMUXER 0 ++#define CONFIG_RSD_DEMUXER 0 ++#define CONFIG_RSO_DEMUXER 0 ++#define CONFIG_RTP_DEMUXER 0 ++#define CONFIG_RTSP_DEMUXER 0 ++#define CONFIG_S337M_DEMUXER 0 ++#define CONFIG_SAMI_DEMUXER 0 ++#define CONFIG_SAP_DEMUXER 0 ++#define CONFIG_SBC_DEMUXER 0 ++#define CONFIG_SBG_DEMUXER 0 ++#define CONFIG_SCC_DEMUXER 0 ++#define CONFIG_SDP_DEMUXER 0 ++#define CONFIG_SDR2_DEMUXER 0 ++#define CONFIG_SDS_DEMUXER 0 ++#define CONFIG_SDX_DEMUXER 0 ++#define CONFIG_SEGAFILM_DEMUXER 0 ++#define CONFIG_SER_DEMUXER 0 ++#define CONFIG_SHORTEN_DEMUXER 0 ++#define CONFIG_SIFF_DEMUXER 0 ++#define CONFIG_SLN_DEMUXER 0 ++#define CONFIG_SMACKER_DEMUXER 0 ++#define CONFIG_SMJPEG_DEMUXER 0 ++#define CONFIG_SMUSH_DEMUXER 0 ++#define CONFIG_SOL_DEMUXER 0 ++#define CONFIG_SOX_DEMUXER 0 ++#define CONFIG_SPDIF_DEMUXER 0 ++#define CONFIG_SRT_DEMUXER 0 ++#define CONFIG_STR_DEMUXER 0 ++#define CONFIG_STL_DEMUXER 0 ++#define CONFIG_SUBVIEWER1_DEMUXER 0 ++#define CONFIG_SUBVIEWER_DEMUXER 0 ++#define CONFIG_SUP_DEMUXER 0 ++#define CONFIG_SVAG_DEMUXER 0 ++#define CONFIG_SWF_DEMUXER 0 ++#define CONFIG_TAK_DEMUXER 0 ++#define CONFIG_TEDCAPTIONS_DEMUXER 0 ++#define CONFIG_THP_DEMUXER 0 ++#define CONFIG_THREEDOSTR_DEMUXER 0 ++#define CONFIG_TIERTEXSEQ_DEMUXER 0 ++#define CONFIG_TMV_DEMUXER 0 ++#define CONFIG_TRUEHD_DEMUXER 0 ++#define CONFIG_TTA_DEMUXER 0 ++#define CONFIG_TXD_DEMUXER 0 ++#define CONFIG_TTY_DEMUXER 0 ++#define CONFIG_TY_DEMUXER 0 ++#define CONFIG_V210_DEMUXER 0 ++#define CONFIG_V210X_DEMUXER 0 ++#define CONFIG_VAG_DEMUXER 0 ++#define CONFIG_VC1_DEMUXER 0 ++#define CONFIG_VC1T_DEMUXER 0 ++#define CONFIG_VIVIDAS_DEMUXER 0 ++#define CONFIG_VIVO_DEMUXER 0 ++#define CONFIG_VMD_DEMUXER 0 ++#define CONFIG_VOBSUB_DEMUXER 0 ++#define CONFIG_VOC_DEMUXER 0 ++#define CONFIG_VPK_DEMUXER 0 ++#define CONFIG_VPLAYER_DEMUXER 0 ++#define CONFIG_VQF_DEMUXER 0 ++#define CONFIG_W64_DEMUXER 0 ++#define CONFIG_WAV_DEMUXER 1 ++#define CONFIG_WC3_DEMUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 ++#define CONFIG_WEBVTT_DEMUXER 0 ++#define CONFIG_WSAUD_DEMUXER 0 ++#define CONFIG_WSD_DEMUXER 0 ++#define CONFIG_WSVQA_DEMUXER 0 ++#define CONFIG_WTV_DEMUXER 0 ++#define CONFIG_WVE_DEMUXER 0 ++#define CONFIG_WV_DEMUXER 0 ++#define CONFIG_XA_DEMUXER 0 ++#define CONFIG_XBIN_DEMUXER 0 ++#define CONFIG_XMV_DEMUXER 0 ++#define CONFIG_XVAG_DEMUXER 0 ++#define CONFIG_XWMA_DEMUXER 0 ++#define CONFIG_YOP_DEMUXER 0 ++#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 ++#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 ++#define CONFIG_LIBGME_DEMUXER 0 ++#define CONFIG_LIBMODPLUG_DEMUXER 0 ++#define CONFIG_LIBOPENMPT_DEMUXER 0 ++#define CONFIG_VAPOURSYNTH_DEMUXER 0 ++#define CONFIG_A64_MUXER 0 ++#define CONFIG_AC3_MUXER 0 ++#define CONFIG_ADTS_MUXER 0 ++#define CONFIG_ADX_MUXER 0 ++#define CONFIG_AIFF_MUXER 0 ++#define CONFIG_AMR_MUXER 0 ++#define CONFIG_APM_MUXER 0 ++#define CONFIG_APNG_MUXER 0 ++#define CONFIG_APTX_MUXER 0 ++#define CONFIG_APTX_HD_MUXER 0 ++#define CONFIG_ARGO_ASF_MUXER 0 ++#define CONFIG_ASF_MUXER 0 ++#define CONFIG_ASS_MUXER 0 ++#define CONFIG_AST_MUXER 0 ++#define CONFIG_ASF_STREAM_MUXER 0 ++#define CONFIG_AU_MUXER 0 ++#define CONFIG_AVI_MUXER 0 ++#define CONFIG_AVM2_MUXER 0 ++#define CONFIG_AVS2_MUXER 0 ++#define CONFIG_BIT_MUXER 0 ++#define CONFIG_CAF_MUXER 0 ++#define CONFIG_CAVSVIDEO_MUXER 0 ++#define CONFIG_CODEC2_MUXER 0 ++#define CONFIG_CODEC2RAW_MUXER 0 ++#define CONFIG_CRC_MUXER 0 ++#define CONFIG_DASH_MUXER 0 ++#define CONFIG_DATA_MUXER 0 ++#define CONFIG_DAUD_MUXER 0 ++#define CONFIG_DIRAC_MUXER 0 ++#define CONFIG_DNXHD_MUXER 0 ++#define CONFIG_DTS_MUXER 0 ++#define CONFIG_DV_MUXER 0 ++#define CONFIG_EAC3_MUXER 0 ++#define CONFIG_F4V_MUXER 0 ++#define CONFIG_FFMETADATA_MUXER 0 ++#define CONFIG_FIFO_MUXER 0 ++#define CONFIG_FIFO_TEST_MUXER 0 ++#define CONFIG_FILMSTRIP_MUXER 0 ++#define CONFIG_FITS_MUXER 0 ++#define CONFIG_FLAC_MUXER 0 ++#define CONFIG_FLV_MUXER 0 ++#define CONFIG_FRAMECRC_MUXER 0 ++#define CONFIG_FRAMEHASH_MUXER 0 ++#define CONFIG_FRAMEMD5_MUXER 0 ++#define CONFIG_G722_MUXER 0 ++#define CONFIG_G723_1_MUXER 0 ++#define CONFIG_G726_MUXER 0 ++#define CONFIG_G726LE_MUXER 0 ++#define CONFIG_GIF_MUXER 0 ++#define CONFIG_GSM_MUXER 0 ++#define CONFIG_GXF_MUXER 0 ++#define CONFIG_H261_MUXER 0 ++#define CONFIG_H263_MUXER 0 ++#define CONFIG_H264_MUXER 0 ++#define CONFIG_HASH_MUXER 0 ++#define CONFIG_HDS_MUXER 0 ++#define CONFIG_HEVC_MUXER 0 ++#define CONFIG_HLS_MUXER 0 ++#define CONFIG_ICO_MUXER 0 ++#define CONFIG_ILBC_MUXER 0 ++#define CONFIG_IMAGE2_MUXER 0 ++#define CONFIG_IMAGE2PIPE_MUXER 0 ++#define CONFIG_IPOD_MUXER 0 ++#define CONFIG_IRCAM_MUXER 0 ++#define CONFIG_ISMV_MUXER 0 ++#define CONFIG_IVF_MUXER 0 ++#define CONFIG_JACOSUB_MUXER 0 ++#define CONFIG_KVAG_MUXER 0 ++#define CONFIG_LATM_MUXER 0 ++#define CONFIG_LRC_MUXER 0 ++#define CONFIG_M4V_MUXER 0 ++#define CONFIG_MD5_MUXER 0 ++#define CONFIG_MATROSKA_MUXER 0 ++#define CONFIG_MATROSKA_AUDIO_MUXER 0 ++#define CONFIG_MICRODVD_MUXER 0 ++#define CONFIG_MJPEG_MUXER 0 ++#define CONFIG_MLP_MUXER 0 ++#define CONFIG_MMF_MUXER 0 ++#define CONFIG_MOV_MUXER 0 ++#define CONFIG_MP2_MUXER 0 ++#define CONFIG_MP3_MUXER 0 ++#define CONFIG_MP4_MUXER 0 ++#define CONFIG_MPEG1SYSTEM_MUXER 0 ++#define CONFIG_MPEG1VCD_MUXER 0 ++#define CONFIG_MPEG1VIDEO_MUXER 0 ++#define CONFIG_MPEG2DVD_MUXER 0 ++#define CONFIG_MPEG2SVCD_MUXER 0 ++#define CONFIG_MPEG2VIDEO_MUXER 0 ++#define CONFIG_MPEG2VOB_MUXER 0 ++#define CONFIG_MPEGTS_MUXER 0 ++#define CONFIG_MPJPEG_MUXER 0 ++#define CONFIG_MXF_MUXER 0 ++#define CONFIG_MXF_D10_MUXER 0 ++#define CONFIG_MXF_OPATOM_MUXER 0 ++#define CONFIG_NULL_MUXER 0 ++#define CONFIG_NUT_MUXER 0 ++#define CONFIG_OGA_MUXER 0 ++#define CONFIG_OGG_MUXER 0 ++#define CONFIG_OGV_MUXER 0 ++#define CONFIG_OMA_MUXER 0 ++#define CONFIG_OPUS_MUXER 0 ++#define CONFIG_PCM_ALAW_MUXER 0 ++#define CONFIG_PCM_MULAW_MUXER 0 ++#define CONFIG_PCM_VIDC_MUXER 0 ++#define CONFIG_PCM_F64BE_MUXER 0 ++#define CONFIG_PCM_F64LE_MUXER 0 ++#define CONFIG_PCM_F32BE_MUXER 0 ++#define CONFIG_PCM_F32LE_MUXER 0 ++#define CONFIG_PCM_S32BE_MUXER 0 ++#define CONFIG_PCM_S32LE_MUXER 0 ++#define CONFIG_PCM_S24BE_MUXER 0 ++#define CONFIG_PCM_S24LE_MUXER 0 ++#define CONFIG_PCM_S16BE_MUXER 0 ++#define CONFIG_PCM_S16LE_MUXER 0 ++#define CONFIG_PCM_S8_MUXER 0 ++#define CONFIG_PCM_U32BE_MUXER 0 ++#define CONFIG_PCM_U32LE_MUXER 0 ++#define CONFIG_PCM_U24BE_MUXER 0 ++#define CONFIG_PCM_U24LE_MUXER 0 ++#define CONFIG_PCM_U16BE_MUXER 0 ++#define CONFIG_PCM_U16LE_MUXER 0 ++#define CONFIG_PCM_U8_MUXER 0 ++#define CONFIG_PSP_MUXER 0 ++#define CONFIG_RAWVIDEO_MUXER 0 ++#define CONFIG_RM_MUXER 0 ++#define CONFIG_ROQ_MUXER 0 ++#define CONFIG_RSO_MUXER 0 ++#define CONFIG_RTP_MUXER 0 ++#define CONFIG_RTP_MPEGTS_MUXER 0 ++#define CONFIG_RTSP_MUXER 0 ++#define CONFIG_SAP_MUXER 0 ++#define CONFIG_SBC_MUXER 0 ++#define CONFIG_SCC_MUXER 0 ++#define CONFIG_SEGAFILM_MUXER 0 ++#define CONFIG_SEGMENT_MUXER 0 ++#define CONFIG_STREAM_SEGMENT_MUXER 0 ++#define CONFIG_SINGLEJPEG_MUXER 0 ++#define CONFIG_SMJPEG_MUXER 0 ++#define CONFIG_SMOOTHSTREAMING_MUXER 0 ++#define CONFIG_SOX_MUXER 0 ++#define CONFIG_SPX_MUXER 0 ++#define CONFIG_SPDIF_MUXER 0 ++#define CONFIG_SRT_MUXER 0 ++#define CONFIG_STREAMHASH_MUXER 0 ++#define CONFIG_SUP_MUXER 0 ++#define CONFIG_SWF_MUXER 0 ++#define CONFIG_TEE_MUXER 0 ++#define CONFIG_TG2_MUXER 0 ++#define CONFIG_TGP_MUXER 0 ++#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 ++#define CONFIG_TRUEHD_MUXER 0 ++#define CONFIG_TTA_MUXER 0 ++#define CONFIG_UNCODEDFRAMECRC_MUXER 0 ++#define CONFIG_VC1_MUXER 0 ++#define CONFIG_VC1T_MUXER 0 ++#define CONFIG_VOC_MUXER 0 ++#define CONFIG_W64_MUXER 0 ++#define CONFIG_WAV_MUXER 0 ++#define CONFIG_WEBM_MUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 ++#define CONFIG_WEBM_CHUNK_MUXER 0 ++#define CONFIG_WEBP_MUXER 0 ++#define CONFIG_WEBVTT_MUXER 0 ++#define CONFIG_WTV_MUXER 0 ++#define CONFIG_WV_MUXER 0 ++#define CONFIG_YUV4MPEGPIPE_MUXER 0 ++#define CONFIG_CHROMAPRINT_MUXER 0 ++#define CONFIG_ASYNC_PROTOCOL 0 ++#define CONFIG_BLURAY_PROTOCOL 0 ++#define CONFIG_CACHE_PROTOCOL 0 ++#define CONFIG_CONCAT_PROTOCOL 0 ++#define CONFIG_CRYPTO_PROTOCOL 0 ++#define CONFIG_DATA_PROTOCOL 0 ++#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 ++#define CONFIG_FFRTMPHTTP_PROTOCOL 0 ++#define CONFIG_FILE_PROTOCOL 0 ++#define CONFIG_FTP_PROTOCOL 0 ++#define CONFIG_GOPHER_PROTOCOL 0 ++#define CONFIG_HLS_PROTOCOL 0 ++#define CONFIG_HTTP_PROTOCOL 0 ++#define CONFIG_HTTPPROXY_PROTOCOL 0 ++#define CONFIG_HTTPS_PROTOCOL 0 ++#define CONFIG_ICECAST_PROTOCOL 0 ++#define CONFIG_MMSH_PROTOCOL 0 ++#define CONFIG_MMST_PROTOCOL 0 ++#define CONFIG_MD5_PROTOCOL 0 ++#define CONFIG_PIPE_PROTOCOL 0 ++#define CONFIG_PROMPEG_PROTOCOL 0 ++#define CONFIG_RTMP_PROTOCOL 0 ++#define CONFIG_RTMPE_PROTOCOL 0 ++#define CONFIG_RTMPS_PROTOCOL 0 ++#define CONFIG_RTMPT_PROTOCOL 0 ++#define CONFIG_RTMPTE_PROTOCOL 0 ++#define CONFIG_RTMPTS_PROTOCOL 0 ++#define CONFIG_RTP_PROTOCOL 0 ++#define CONFIG_SCTP_PROTOCOL 0 ++#define CONFIG_SRTP_PROTOCOL 0 ++#define CONFIG_SUBFILE_PROTOCOL 0 ++#define CONFIG_TEE_PROTOCOL 0 ++#define CONFIG_TCP_PROTOCOL 0 ++#define CONFIG_TLS_PROTOCOL 0 ++#define CONFIG_UDP_PROTOCOL 0 ++#define CONFIG_UDPLITE_PROTOCOL 0 ++#define CONFIG_UNIX_PROTOCOL 0 ++#define CONFIG_LIBAMQP_PROTOCOL 0 ++#define CONFIG_LIBRTMP_PROTOCOL 0 ++#define CONFIG_LIBRTMPE_PROTOCOL 0 ++#define CONFIG_LIBRTMPS_PROTOCOL 0 ++#define CONFIG_LIBRTMPT_PROTOCOL 0 ++#define CONFIG_LIBRTMPTE_PROTOCOL 0 ++#define CONFIG_LIBSRT_PROTOCOL 0 ++#define CONFIG_LIBSSH_PROTOCOL 0 ++#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 ++#define CONFIG_LIBZMQ_PROTOCOL 0 ++#endif /* FFMPEG_CONFIG_H */ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/bsf_list.c +@@ -0,0 +1,3 @@ ++static const AVBitStreamFilter * const bitstream_filters[] = { ++ &ff_null_bsf, ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/codec_list.c +@@ -0,0 +1,20 @@ ++static const AVCodec * const codec_list[] = { ++ &ff_h264_decoder, ++ &ff_theora_decoder, ++ &ff_vp3_decoder, ++ &ff_vp8_decoder, ++ &ff_aac_decoder, ++ &ff_flac_decoder, ++ &ff_mp3_decoder, ++ &ff_vorbis_decoder, ++ &ff_pcm_alaw_decoder, ++ &ff_pcm_f32le_decoder, ++ &ff_pcm_mulaw_decoder, ++ &ff_pcm_s16be_decoder, ++ &ff_pcm_s16le_decoder, ++ &ff_pcm_s24be_decoder, ++ &ff_pcm_s24le_decoder, ++ &ff_pcm_s32le_decoder, ++ &ff_pcm_u8_decoder, ++ &ff_libopus_decoder, ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavcodec/parser_list.c +@@ -0,0 +1,11 @@ ++static const AVCodecParser * const parser_list[] = { ++ &ff_aac_parser, ++ &ff_flac_parser, ++ &ff_h264_parser, ++ &ff_mpegaudio_parser, ++ &ff_opus_parser, ++ &ff_vorbis_parser, ++ &ff_vp3_parser, ++ &ff_vp8_parser, ++ &ff_vp9_parser, ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/demuxer_list.c +@@ -0,0 +1,9 @@ ++static const AVInputFormat * const demuxer_list[] = { ++ &ff_aac_demuxer, ++ &ff_flac_demuxer, ++ &ff_matroska_demuxer, ++ &ff_mov_demuxer, ++ &ff_mp3_demuxer, ++ &ff_ogg_demuxer, ++ &ff_wav_demuxer, ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/muxer_list.c +@@ -0,0 +1,2 @@ ++static const AVOutputFormat * const muxer_list[] = { ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavformat/protocol_list.c +@@ -0,0 +1,2 @@ ++static const URLProtocol * const url_protocols[] = { ++ NULL }; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/avconfig.h +@@ -0,0 +1,6 @@ ++/* Generated by ffmpeg configure */ ++#ifndef AVUTIL_AVCONFIG_H ++#define AVUTIL_AVCONFIG_H ++#define AV_HAVE_BIGENDIAN 0 ++#define AV_HAVE_FAST_UNALIGNED 1 ++#endif /* AVUTIL_AVCONFIG_H */ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/loongarch64/libavutil/ffversion.h +@@ -0,0 +1,5 @@ ++/* Automatically generated by version.sh, do not manually edit! */ ++#ifndef AVUTIL_FFVERSION_H ++#define AVUTIL_FFVERSION_H ++#define FFMPEG_VERSION "git-2024-04-23-445820325" ++#endif /* AVUTIL_FFVERSION_H */ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +@@ -36,7 +36,7 @@ BRANDINGS = [ + ARCH_MAP = { + 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], + 'linux': [ +- 'ia32', 'x64', 'mipsel', 'mips64el', 'noasm-x64', 'arm', 'arm-neon', ++ 'ia32', 'x64', 'mipsel', 'mips64el', 'loongarch64', 'noasm-x64', 'arm', 'arm-neon', + 'arm64' + ], + 'mac': ['x64', 'arm64'], +@@ -133,6 +133,8 @@ def DetermineHostOsAndArch(): + host_arch = 'x64' + elif platform.machine() == 'aarch64': + host_arch = 'arm64' ++ elif platform.machine() == 'loongarch64': ++ host_arch = 'loongarch64' + elif platform.machine() == 'mips32': + host_arch = 'mipsel' + elif platform.machine() == 'mips64': +@@ -820,6 +822,11 @@ def ConfigureAndBuild(target_arch, targe + '--extra-cflags=--target=mips64el-linux-gnuabi64', + '--extra-ldflags=--target=mips64el-linux-gnuabi64', + ]) ++ elif target_arch == 'loongarch64': ++ if target_os == 'linux': ++ configure_flags['Common'].extend([ ++ '--arch=loongarch64', ++ ]) + else: + print( + 'Error: Unknown target arch %r for target OS %r!' % (target_arch, +@@ -834,18 +841,21 @@ def ConfigureAndBuild(target_arch, targe + ]) + + if 'win' not in target_os: +- configure_flags['Common'].extend([ +- '--enable-pic', +- '--cc=clang', +- '--cxx=clang++', +- '--ld=clang', +- ]) ++ if target_arch != 'loongarch64': ++ configure_flags['Common'].extend([ ++ '--enable-pic', ++ '--cc=clang', ++ '--cxx=clang++', ++ '--ld=clang', ++ ]) ++ else: ++ configure_flags['Common'].extend(['--enable-pic']) + + # Clang Linux will use the first 'ld' it finds on the path, which will + # typically be the system one, so explicitly configure use of Clang's + # ld.lld, to ensure that things like cross-compilation and LTO work. + # This does not work for ia32 and is always used on mac. +- if target_arch != 'ia32' and target_os != 'mac': ++ if target_arch != 'ia32' and target_os != 'mac' and target_arch != 'loongarch64': + configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') + + # Should be run on Mac, unless we're cross-compiling on Linux. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py.rej +@@ -0,0 +1,61 @@ ++--- src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +++++ src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py ++@@ -36,7 +36,7 @@ BRANDINGS = [ ++ ARCH_MAP = { ++ 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], ++ 'linux': [ ++- 'ia32', 'x64', 'mipsel', 'mips64el', 'noasm-x64', 'arm', 'arm-neon', +++ 'ia32', 'x64', 'mipsel', 'mips64el', 'loongarch64', 'noasm-x64', 'arm', 'arm-neon', ++ 'arm64' ++ ], ++ 'mac': ['x64', 'arm64'], ++@@ -133,6 +133,8 @@ def DetermineHostOsAndArch(): ++ host_arch = 'x64' ++ elif platform.machine() == 'aarch64': ++ host_arch = 'arm64' +++ elif platform.machine() == 'loongarch64': +++ host_arch = 'loongarch64' ++ elif platform.machine() == 'mips32': ++ host_arch = 'mipsel' ++ elif platform.machine() == 'mips64': ++@@ -820,6 +822,11 @@ def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, ++ '--extra-cflags=--target=mips64el-linux-gnuabi64', ++ '--extra-ldflags=--target=mips64el-linux-gnuabi64', ++ ]) +++ elif target_arch == 'loongarch64': +++ if target_os == 'linux': +++ configure_flags['Common'].extend([ +++ '--arch=loongarch64', +++ ]) ++ else: ++ print( ++ 'Error: Unknown target arch %r for target OS %r!' % (target_arch, ++@@ -834,18 +841,21 @@ def ConfigureAndBuild(target_arch, target_os, host_os, host_arch, parallel_jobs, ++ ]) ++ ++ if 'win' not in target_os: ++- configure_flags['Common'].extend([ ++- '--enable-pic', ++- '--cc=clang', ++- '--cxx=clang++', ++- '--ld=clang', ++- ]) +++ if target_arch != 'loongarch64': +++ configure_flags['Common'].extend([ +++ '--enable-pic', +++ '--cc=clang', +++ '--cxx=clang++', +++ '--ld=clang', +++ ]) +++ else: +++ configure_flags['Common'].extend(['--enable-pic']) ++ ++ # Clang Linux will use the first 'ld' it finds on the path, which will ++ # typically be the system one, so explicitly configure use of Clang's ++ # ld.lld, to ensure that things like cross-compilation and LTO work. ++ # This does not work for ia32 and is always used on mac. ++- if target_arch != 'ia32' and target_os != 'mac': +++ if target_arch != 'ia32' and target_os != 'mac' and target_arch != 'loongarch64': ++ configure_flags['Common'].append('--extra-ldflags=-fuse-ld=lld') ++ ++ # Should be run on Mac, unless we're cross-compiling on Linux. +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh +@@ -10,7 +10,7 @@ for os in android linux linux-noasm mac + # Copy config files for various architectures: + # - ia32/x64 have config.asm, config.h + # - arm/arm-neon have config.h +- for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do ++ for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el loongarch64; do + # Don't waste time on non-existent configs, if no config.h then skip. + [ ! -e "build.$arch.$os/$target/config.h" ] && continue + for f in config.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh +++++ src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh ++@@ -10,7 +10,7 @@ for os in android linux linux-noasm mac win; do ++ # Copy config files for various architectures: ++ # - ia32/x64 have config.asm, config.h ++ # - arm/arm-neon have config.h ++- for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do +++ for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el loongarch64; do ++ # Don't waste time on non-existent configs, if no config.h then skip. ++ [ ! -e "build.$arch.$os/$target/config.h" ] && continue ++ for f in config.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py +@@ -77,7 +77,7 @@ GN_SOURCE_END = """] + Attr = enum('ARCHITECTURE', 'TARGET', 'PLATFORM') + SUPPORT_MATRIX = { + Attr.ARCHITECTURE: +- set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el']), ++ set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el', 'loongarch64']), + Attr.TARGET: + set(['Chromium', 'Chrome', 'ChromeOS']), + Attr.PLATFORM: +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py +++++ src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/generate_gn.py ++@@ -77,7 +77,7 @@ GN_SOURCE_END = """] ++ Attr = enum('ARCHITECTURE', 'TARGET', 'PLATFORM') ++ SUPPORT_MATRIX = { ++ Attr.ARCHITECTURE: ++- set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el']), +++ set(['ia32', 'x64', 'arm', 'arm64', 'arm-neon', 'mipsel', 'mips64el', 'loongarch64']), ++ Attr.TARGET: ++ set(['Chromium', 'Chrome', 'ChromeOS']), ++ Attr.PLATFORM: +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/ffmpeg/configure ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/configure +@@ -1984,6 +1984,7 @@ ARCH_LIST=" + avr32_uc + bfin + ia64 ++ loongarch64 + m68k + mips + mips64 +@@ -2596,10 +2597,10 @@ for ext in $(filter_out mmx $ARCH_EXT_LI + eval ${ext}_suggest='"${ext}_external ${ext}_inline"' + done + +-aligned_stack_if_any="aarch64 ppc x86" +-fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64" +-fast_clz_if_any="aarch64 alpha avr32 mips ppc x86" +-fast_unaligned_if_any="aarch64 ppc x86" ++aligned_stack_if_any="aarch64 ppc x86 loongarch64" ++fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64 loongarch64" ++fast_clz_if_any="aarch64 alpha avr32 mips ppc x86 loongarch64" ++fast_unaligned_if_any="aarch64 ppc x86 loongarch64" + simd_align_16_if_any="altivec neon sse" + simd_align_32_if_any="avx" + simd_align_64_if_any="avx512" +@@ -4871,6 +4872,9 @@ case "$arch" in + arm*|iPad*|iPhone*) + arch="arm" + ;; ++ loongarch64) ++ arch="loongarch64" ++ ;; + mips*|IP*) + case "$arch" in + *el) +@@ -5278,6 +5282,11 @@ case "$arch" in + aarch64|alpha|ia64) + enabled shared && enable_weak pic + ;; ++ loongarch64) ++ enable loongarch64 ++ enabled loongarch64 ++ enabled shared && enabled_weak pic ++ ;; + mips) + check_64bit mips mips64 '_MIPS_SIM > 1' + enabled shared && enable_weak pic +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/ffmpeg/configure.rej +@@ -0,0 +1,47 @@ ++--- src/3rdparty/chromium/third_party/ffmpeg/configure +++++ src/3rdparty/chromium/third_party/ffmpeg/configure ++@@ -1984,6 +1984,7 @@ ARCH_LIST=" ++ avr32_uc ++ bfin ++ ia64 +++ loongarch64 ++ m68k ++ mips ++ mips64 ++@@ -2596,10 +2597,10 @@ for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do ++ eval ${ext}_suggest='"${ext}_external ${ext}_inline"' ++ done ++ ++-aligned_stack_if_any="aarch64 ppc x86" ++-fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64" ++-fast_clz_if_any="aarch64 alpha avr32 mips ppc x86" ++-fast_unaligned_if_any="aarch64 ppc x86" +++aligned_stack_if_any="aarch64 ppc x86 loongarch64" +++fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64 loongarch64" +++fast_clz_if_any="aarch64 alpha avr32 mips ppc x86 loongarch64" +++fast_unaligned_if_any="aarch64 ppc x86 loongarch64" ++ simd_align_16_if_any="altivec neon sse" ++ simd_align_32_if_any="avx" ++ simd_align_64_if_any="avx512" ++@@ -4871,6 +4872,9 @@ case "$arch" in ++ arm*|iPad*|iPhone*) ++ arch="arm" ++ ;; +++ loongarch64) +++ arch="loongarch64" +++ ;; ++ mips*|IP*) ++ case "$arch" in ++ *el) ++@@ -5278,6 +5282,11 @@ case "$arch" in ++ aarch64|alpha|ia64) ++ enabled shared && enable_weak pic ++ ;; +++ loongarch64) +++ enable loongarch64 +++ enabled loongarch64 +++ enabled shared && enabled_weak pic +++ ;; ++ mips) ++ check_64bit mips mips64 '_MIPS_SIM > 1' ++ enabled shared && enable_weak pic +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h +@@ -88,7 +88,7 @@ + */ + #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ + defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ +- defined(__aarch64__) || defined(__s390__)) \ ++ defined(__aarch64__) || defined(__s390__) || defined(__loongarch64)) \ + && (defined(__linux) || defined(__ANDROID__)) + + #ifndef SYS_CPLUSPLUS +@@ -266,6 +266,12 @@ struct kernel_timeval { + long tv_usec; + }; + ++/* include/linux/time.h */ ++struct kernel_itimerval { ++ struct kernel_timeval it_interval; ++ struct kernel_timeval it_value; ++}; ++ + /* include/linux/resource.h */ + struct kernel_rusage { + struct kernel_timeval ru_utime; +@@ -301,8 +307,8 @@ struct kernel_old_sigaction { + } __attribute__((packed,aligned(4))); + #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) + #define kernel_old_sigaction kernel_sigaction +-#elif defined(__aarch64__) +- // No kernel_old_sigaction defined for arm64. ++#elif defined(__aarch64__) || defined(__loongarch64) ++ // No kernel_old_sigaction defined for arm64 and loongarch64. + #endif + + /* Some kernel functions (e.g. sigaction() in 2.6.23) require that the +@@ -341,7 +347,9 @@ struct kernel_sigaction { + void (*sa_sigaction_)(int, siginfo_t *, void *); + }; + unsigned long sa_flags; ++ #if !defined(__loongarch64) + void (*sa_restorer)(void); ++ #endif + struct kernel_sigset_t sa_mask; + #endif + }; +@@ -519,7 +527,7 @@ struct kernel_stat { + int st_blocks; + int st_pad4[14]; + }; +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__loongarch64) + struct kernel_stat { + unsigned long st_dev; + unsigned long st_ino; +@@ -701,6 +709,37 @@ struct kernel_statfs { + }; + #endif + ++struct kernel_statx_timestamp { ++ int64_t tv_sec; ++ uint32_t tv_nsec; ++ int32_t __reserved; ++}; ++ ++struct kernel_statx { ++ uint32_t stx_mask; ++ uint32_t stx_blksize; ++ uint64_t stx_attributes; ++ uint32_t stx_nlink; ++ uint32_t stx_uid; ++ uint32_t stx_gid; ++ uint16_t stx_mode; ++ uint16_t __spare0[1]; ++ uint64_t stx_ino; ++ uint64_t stx_size; ++ uint64_t stx_blocks; ++ uint64_t stx_attributes_mask; ++ struct kernel_statx_timestamp stx_atime; ++ struct kernel_statx_timestamp stx_btime; ++ struct kernel_statx_timestamp stx_ctime; ++ struct kernel_statx_timestamp stx_mtime; ++ uint32_t stx_rdev_major; ++ uint32_t stx_rdev_minor; ++ uint32_t stx_dev_major; ++ uint32_t stx_dev_minor; ++ uint64_t stx_mnt_id; ++ uint64_t __spare2; ++ uint64_t __spare3[12]; ++}; + + /* Definitions missing from the standard header files */ + #ifndef O_DIRECTORY +@@ -737,6 +776,18 @@ struct kernel_statfs { + #ifndef AT_REMOVEDIR + #define AT_REMOVEDIR 0x200 + #endif ++#ifndef AT_NO_AUTOMOUNT ++#define AT_NO_AUTOMOUNT 0x800 ++#endif ++#ifndef AT_EMPTY_PATH ++#define AT_EMPTY_PATH 0x1000 ++#endif ++#ifndef STATX_BASIC_STATS ++#define STATX_BASIC_STATS 0x000007ffU ++#endif ++#ifndef AT_STATX_SYNC_AS_STAT ++#define AT_STATX_SYNC_AS_STAT 0x0000 ++#endif + #ifndef MREMAP_FIXED + #define MREMAP_FIXED 2 + #endif +@@ -1065,7 +1116,7 @@ struct kernel_statfs { + #define __NR_getrandom (__NR_SYSCALL_BASE + 384) + #endif + /* End of ARM 3/EABI definitions */ +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__loongarch64) + #ifndef __NR_setxattr + #define __NR_setxattr 5 + #endif +@@ -1121,9 +1172,11 @@ struct kernel_statfs { + #ifndef __NR_readlinkat + #define __NR_readlinkat 78 + #endif ++#if !defined(__loongarch64) + #ifndef __NR_newfstatat + #define __NR_newfstatat 79 + #endif ++#endif // __loongarch64 + #ifndef __NR_set_tid_address + #define __NR_set_tid_address 96 + #endif +@@ -1164,7 +1217,10 @@ struct kernel_statfs { + #ifndef __NR_getrandom + #define __NR_getrandom 278 + #endif +-/* End of aarch64 definitions */ ++#ifndef __NR_statx ++#define __NR_statx 291 ++#endif ++/* End of aarch64 || __loongarch64 definitions */ + #elif defined(__x86_64__) + #ifndef __NR_pread64 + #define __NR_pread64 17 +@@ -1880,14 +1936,15 @@ struct kernel_statfs { + + #undef LSS_RETURN + #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ +- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) ++ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) \ ++ || defined(__loongarch64)) + /* Failing system calls return a negative result in the range of + * -1..-4095. These are "errno" values with the sign inverted. + */ + #define LSS_RETURN(type, res) \ + do { \ + if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ +- LSS_ERRNO = -(res); \ ++ LSS_ERRNO = (int)(-(res)); \ + res = -1; \ + } \ + return (type) (res); \ +@@ -1980,7 +2037,7 @@ struct kernel_statfs { + LSS_ENTRYPOINT \ + "pop %%ebx" \ + args \ +- : "memory"); \ ++ : "memory"); \ + LSS_RETURN(type,__res) + #undef _syscall0 + #define _syscall0(type,name) \ +@@ -2037,7 +2094,7 @@ struct kernel_statfs { + : "i" (__NR_##name), "ri" ((long)(arg1)), \ + "c" ((long)(arg2)), "d" ((long)(arg3)), \ + "S" ((long)(arg4)), "D" ((long)(arg5)) \ +- : "memory"); \ ++ : "memory"); \ + LSS_RETURN(type,__res); \ + } + #undef _syscall6 +@@ -2059,7 +2116,7 @@ struct kernel_statfs { + : "i" (__NR_##name), "0" ((long)(&__s)), \ + "c" ((long)(arg2)), "d" ((long)(arg3)), \ + "S" ((long)(arg4)), "D" ((long)(arg5)) \ +- : "memory"); \ ++ : "memory"); \ + LSS_RETURN(type,__res); \ + } + LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, +@@ -2241,7 +2298,7 @@ struct kernel_statfs { + #define _LSS_RETURN(type, res, cast) \ + do { \ + if ((uint64_t)(res) >= (uint64_t)(-4095)) { \ +- LSS_ERRNO = -(res); \ ++ LSS_ERRNO = (int)(-(res)); \ + res = -1; \ + } \ + return (type)(cast)(res); \ +@@ -3373,6 +3430,134 @@ struct kernel_statfs { + } + LSS_RETURN(int, __ret); + } ++ #elif defined(__loongarch64) ++ /* Most definitions of _syscallX() neglect to mark "memory" as being ++ * clobbered. This causes problems with compilers, that do a better job ++ * at optimizing across __asm__ calls. ++ * So, we just have to redefine all of the _syscallX() macros. ++ */ ++ #undef LSS_REG ++ #define LSS_REG(ar,a) register int64_t __r##ar __asm__("a"#ar) = (int64_t)a ++ /* syscall is like subroutine calls, all caller-saved registers may be ++ * clobbered, we should add them to the |Clobbers| list. ++ * a0 is not included because it's in the output list. ++ */ ++ #define LSS_SYSCALL_CLOBBERS "t0", "t1", "t2", "t3", "t4", "t5", "t6", \ ++ "t7", "t8", "memory" ++ #undef LSS_BODY ++ #define LSS_BODY(type,name,args...) \ ++ register int64_t __res_a0 __asm__("a0"); \ ++ register int64_t __a7 __asm__("a7") = __NR_##name; \ ++ int64_t __res; \ ++ __asm__ __volatile__ ("syscall 0x0\n" \ ++ : "=r"(__res_a0) \ ++ : "r"(__a7), ## args \ ++ : LSS_SYSCALL_CLOBBERS); \ ++ __res = __res_a0; \ ++ LSS_RETURN(type, __res) ++ #undef _syscall0 ++ #define _syscall0(type, name) \ ++ type LSS_NAME(name)(void) { \ ++ LSS_BODY(type, name); \ ++ } ++ #undef _syscall1 ++ #define _syscall1(type, name, type1, arg1) \ ++ type LSS_NAME(name)(type1 arg1) { \ ++ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ ++ } ++ #undef _syscall2 ++ #define _syscall2(type, name, type1, arg1, type2, arg2) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ ++ } ++ #undef _syscall3 ++ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ ++ } ++ #undef _syscall4 ++ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ ++ } ++ #undef _syscall5 ++ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ ++ type5,arg5) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ ++ type5 arg5) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); LSS_REG(4, arg5); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ ++ "r"(__r4)); \ ++ } ++ #undef _syscall6 ++ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ ++ type5,arg5,type6,arg6) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ ++ type5 arg5, type6 arg6) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ ++ "r"(__r4), "r"(__r5)); \ ++ } ++ ++ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, ++ int flags, void *arg, int *parent_tidptr, ++ void *newtls, int *child_tidptr) { ++ int64_t __res; ++ { ++ register int64_t __res_a0 __asm__("a0"); ++ register uint64_t __flags __asm__("a0") = flags; ++ register void *__stack __asm__("a1") = child_stack; ++ register void *__ptid __asm__("a2") = parent_tidptr; ++ register void *__tls __asm__("a3") = newtls; ++ register int *__ctid __asm__("a4") = child_tidptr; ++ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be ++ * used by the child. ++ */ ++ "addi.d %2, %2, -16\n" ++ "st.d %1, %2, 8\n" ++ "st.d %4, %2, 0\n" ++ ++ /* %a0 = syscall(%a0 = flags, ++ * %a1 = child_stack, ++ * %a2 = parent_tidptr, ++ * %a3 = newtls, ++ * %a4 = child_tidptr) ++ */ ++ "li.d $a7, %8\n" ++ "syscall 0x0\n" ++ ++ /* if (%a0 != 0) ++ * return %a0; ++ */ ++ "bnez $a0, 1f\n" ++ ++ /* In the child, now. Call "fn(arg)". ++ */ ++ "ld.d $a0, $sp, 0\n" ++ "ld.d $a1, $sp, 8\n" ++ "addi.d $sp, $sp, 16\n" ++ "jirl $ra, $a1, 0\n" ++ ++ /* Call _exit(%a0). ++ */ ++ "li.d $a7, %9\n" ++ "syscall 0x0\n" ++ "1:\n" ++ : "=r" (__res_a0) ++ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), ++ "r"(__ptid), "r"(__tls), "r"(__ctid), ++ "i"(__NR_clone), "i"(__NR_exit) ++ : "a7", LSS_SYSCALL_CLOBBERS); ++ __res = __res_a0; ++ } ++ LSS_RETURN(int, __res); ++ } + #endif + #define __NR__exit __NR_exit + #define __NR__gettid __NR_gettid +@@ -3403,8 +3588,10 @@ struct kernel_statfs { + // fork is polyfilled below when not available. + LSS_INLINE _syscall0(pid_t, fork) + #endif ++ #if defined(__NR_fstat) + LSS_INLINE _syscall2(int, fstat, int, f, + struct kernel_stat*, b) ++ #endif + LSS_INLINE _syscall2(int, fstatfs, int, f, + struct kernel_statfs*, b) + #if defined(__x86_64__) +@@ -3426,6 +3613,8 @@ struct kernel_statfs { + struct kernel_dirent64*, d, int, c) + LSS_INLINE _syscall0(gid_t, getegid) + LSS_INLINE _syscall0(uid_t, geteuid) ++ LSS_INLINE _syscall2(int, getitimer, int, w, ++ struct kernel_itimerval*, c) + #if defined(__NR_getpgrp) + LSS_INLINE _syscall0(pid_t, getpgrp) + #endif +@@ -3437,10 +3626,10 @@ struct kernel_statfs { + gid_t *, e, gid_t *, s) + LSS_INLINE _syscall3(int, getresuid, uid_t *, r, + uid_t *, e, uid_t *, s) +-#if !defined(__ARM_EABI__) ++ #if defined(__NR_getrlimit) + LSS_INLINE _syscall2(int, getrlimit, int, r, + struct kernel_rlimit*, l) +-#endif ++ #endif + LSS_INLINE _syscall1(pid_t, getsid, pid_t, p) + LSS_INLINE _syscall0(pid_t, _gettid) + LSS_INLINE _syscall2(pid_t, gettimeofday, struct kernel_timeval*, t, +@@ -3547,6 +3736,9 @@ struct kernel_statfs { + LSS_INLINE _syscall1(int, setfsuid, uid_t, u) + LSS_INLINE _syscall1(int, setuid, uid_t, u) + LSS_INLINE _syscall1(int, setgid, gid_t, g) ++ LSS_INLINE _syscall3(int, setitimer, int, w, ++ const struct kernel_itimerval*, n, ++ struct kernel_itimerval*, o) + LSS_INLINE _syscall2(int, setpgid, pid_t, p, + pid_t, g) + LSS_INLINE _syscall3(int, setpriority, int, a, +@@ -3555,8 +3747,10 @@ struct kernel_statfs { + gid_t, e, gid_t, s) + LSS_INLINE _syscall3(int, setresuid, uid_t, r, + uid_t, e, uid_t, s) ++ #if defined(__NR_setrlimit) + LSS_INLINE _syscall2(int, setrlimit, int, r, + const struct kernel_rlimit*, l) ++ #endif + LSS_INLINE _syscall0(pid_t, setsid) + LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, + const stack_t*, o) +@@ -3586,23 +3780,6 @@ struct kernel_statfs { + LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, + unsigned *, node, void *, unused) + #endif +- #if defined(__x86_64__) || \ +- (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) +- LSS_INLINE _syscall3(int, recvmsg, int, s, +- struct kernel_msghdr*, m, int, f) +- LSS_INLINE _syscall3(int, sendmsg, int, s, +- const struct kernel_msghdr*, m, int, f) +- LSS_INLINE _syscall6(int, sendto, int, s, +- const void*, m, size_t, l, +- int, f, +- const struct kernel_sockaddr*, a, int, t) +- LSS_INLINE _syscall2(int, shutdown, int, s, +- int, h) +- LSS_INLINE _syscall3(int, socket, int, d, +- int, t, int, p) +- LSS_INLINE _syscall4(int, socketpair, int, d, +- int, t, int, p, int*, s) +- #endif + #if defined(__NR_fadvise64) + #if defined(__x86_64__) + /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ +@@ -3685,6 +3862,12 @@ struct kernel_statfs { + const char *, p, + struct kernel_stat*, b, int, f) + #endif ++ #if defined(__NR_statx) ++ LSS_INLINE _syscall5(int, statx, int, d, ++ const char *, p, ++ int, f, int, m, ++ struct kernel_statx*, b) ++ #endif + #if defined(__x86_64__) || defined(__s390x__) + LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, + gid_t *egid, +@@ -4181,23 +4364,30 @@ struct kernel_statfs { + LSS_SC_BODY(4, int, 8, d, type, protocol, sv); + } + #endif +- #if defined(__ARM_EABI__) || defined (__aarch64__) ++ #if defined(__NR_recvmsg) + LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, + int, flags) ++ #endif ++ #if defined(__NR_sendmsg) + LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, + msg, int, flags) ++ #endif ++ #if defined(__NR_sendto) + LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, + int, flags, const struct kernel_sockaddr*, to, + unsigned int, tolen) ++ #endif ++ #if defined(__NR_shutdown) + LSS_INLINE _syscall2(int, shutdown, int, s, int, how) ++ #endif ++ #if defined(__NR_socket) + LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) ++ #endif ++ #if defined(__NR_socketpair) + LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, + int*, sv) + #endif +- #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ +- (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ +- defined(__s390__) +- #define __NR__socketcall __NR_socketcall ++ #if defined(__NR_socketcall) + LSS_INLINE _syscall2(int, _socketcall, int, c, + va_list, a) + LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { +@@ -4209,37 +4399,49 @@ struct kernel_statfs { + return rc; + } + ++ #if !defined(__NR_recvmsg) + LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, + int flags){ + return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); + } ++ #endif + ++ #if !defined(__NR_sendmsg) + LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, + const struct kernel_msghdr *msg, + int flags) { + return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); + } ++ #endif + ++ #if !defined(__NR_sendto) + LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, + int flags, + const struct kernel_sockaddr *to, + unsigned int tolen) { + return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); + } ++ #endif + ++ #if !defined(__NR_shutdown) + LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { + return LSS_NAME(socketcall)(13, s, how); + } ++ #endif + ++ #if !defined(__NR_socket) + LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { + return LSS_NAME(socketcall)(1, domain, type, protocol); + } ++ #endif + ++ #if !defined(__NR_socketpair) + LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, + int sv[2]) { + return LSS_NAME(socketcall)(8, d, type, protocol, sv); + } +- #endif ++ #endif ++ #endif // defined(__NR_socketcall) + #if defined(__NR_fstatat64) + LSS_INLINE _syscall4(int, fstatat64, int, d, + const char *, p, +@@ -4486,10 +4688,64 @@ struct kernel_statfs { + } + #endif + ++#if defined(__NR_statx) ++ /* copy the contents of kernel_statx to the kernel_stat structure. */ ++ LSS_INLINE void LSS_NAME(cp_stat_statx)(struct kernel_stat *to, ++ struct kernel_statx *from) { ++ memset(to, 0, sizeof(struct kernel_stat)); ++ to->st_dev = (unsigned long)((from->stx_dev_minor & 0xff) | ++ ((from->stx_dev_major & 0xfff) << 8) | ++ ((from->stx_dev_minor & ~0xffu) << 12)); ++ to->st_rdev = (unsigned long)((from->stx_rdev_minor & 0xff) | ++ ((from->stx_rdev_major & 0xfff) << 8) | ++ ((from->stx_rdev_minor & ~0xffu) << 12)); ++ to->st_ino = (unsigned long)from->stx_ino; ++ to->st_mode = (unsigned int)from->stx_mode; ++ to->st_nlink = (unsigned int)from->stx_nlink; ++ to->st_uid = (unsigned int)from->stx_uid; ++ to->st_gid = (unsigned int)from->stx_gid; ++ to->st_atime_ = (long)(from->stx_atime.tv_sec); ++ to->st_atime_nsec_ = from->stx_atime.tv_nsec; ++ to->st_mtime_ = (long)(from->stx_mtime.tv_sec); ++ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; ++ to->st_ctime_ = (long)(from->stx_ctime.tv_sec); ++ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; ++ to->st_size = (long)(from->stx_size); ++ to->st_blocks = (int)(from->stx_blocks); ++ to->st_blksize = (int)from->stx_blksize; ++ } ++#endif ++ ++#if !defined(__NR_fstat) ++ LSS_INLINE int LSS_NAME(fstat)(int fd, ++ struct kernel_stat *buf) { ++ #if defined(__NR_newfstatat) ++ return LSS_NAME(newfstatat)(fd, "", buf, AT_EMPTY_PATH); ++ #elif defined(__NR_statx) ++ struct kernel_statx stx; ++ int flags = AT_NO_AUTOMOUNT | AT_EMPTY_PATH; ++ int mask = STATX_BASIC_STATS; ++ int res = LSS_NAME(statx)(fd, "", flags, mask, &stx); ++ LSS_NAME(cp_stat_statx)(buf, &stx); ++ return res; ++ #endif ++ } ++#endif ++ ++ + #if !defined(__NR_stat) + LSS_INLINE int LSS_NAME(stat)(const char *pathname, + struct kernel_stat *buf) { ++ #if defined(__NR_newfstatat) + return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, 0); ++ #elif defined(__NR_statx) ++ struct kernel_statx stx; ++ int flags = AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT; ++ int mask = STATX_BASIC_STATS; ++ int res = LSS_NAME(statx)(AT_FDCWD, pathname, flags, mask, &stx); ++ LSS_NAME(cp_stat_statx)(buf, &stx); ++ return res; ++ #endif + } + #endif + +@@ -4503,7 +4759,7 @@ struct kernel_statfs { + // TODO: define this in an arch-independant way instead of inlining the clone + // syscall body. + +-# if defined(__aarch64__) ++# if defined(__aarch64__) || defined(__loongarch64) + LSS_INLINE pid_t LSS_NAME(fork)(void) { + // No fork syscall on aarch64 - implement by means of the clone syscall. + // Note that this does not reset glibc's cached view of the PID/TID, so +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h.rej +@@ -0,0 +1,585 @@ ++--- src/3rdparty/chromium/third_party/lss/linux_syscall_support.h +++++ src/3rdparty/chromium/third_party/lss/linux_syscall_support.h ++@@ -88,7 +88,7 @@ ++ */ ++ #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ ++ defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ ++- defined(__aarch64__) || defined(__s390__)) \ +++ defined(__aarch64__) || defined(__s390__) || defined(__loongarch64)) \ ++ && (defined(__linux) || defined(__ANDROID__)) ++ ++ #ifndef SYS_CPLUSPLUS ++@@ -266,6 +266,12 @@ struct kernel_timeval { ++ long tv_usec; ++ }; ++ +++/* include/linux/time.h */ +++struct kernel_itimerval { +++ struct kernel_timeval it_interval; +++ struct kernel_timeval it_value; +++}; +++ ++ /* include/linux/resource.h */ ++ struct kernel_rusage { ++ struct kernel_timeval ru_utime; ++@@ -301,8 +307,8 @@ struct kernel_old_sigaction { ++ } __attribute__((packed,aligned(4))); ++ #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) ++ #define kernel_old_sigaction kernel_sigaction ++-#elif defined(__aarch64__) ++- // No kernel_old_sigaction defined for arm64. +++#elif defined(__aarch64__) || defined(__loongarch64) +++ // No kernel_old_sigaction defined for arm64 and loongarch64. ++ #endif ++ ++ /* Some kernel functions (e.g. sigaction() in 2.6.23) require that the ++@@ -341,7 +347,9 @@ struct kernel_sigaction { ++ void (*sa_sigaction_)(int, siginfo_t *, void *); ++ }; ++ unsigned long sa_flags; +++ #if !defined(__loongarch64) ++ void (*sa_restorer)(void); +++ #endif ++ struct kernel_sigset_t sa_mask; ++ #endif ++ }; ++@@ -519,7 +527,7 @@ struct kernel_stat { ++ int st_blocks; ++ int st_pad4[14]; ++ }; ++-#elif defined(__aarch64__) +++#elif defined(__aarch64__) || defined(__loongarch64) ++ struct kernel_stat { ++ unsigned long st_dev; ++ unsigned long st_ino; ++@@ -701,6 +709,37 @@ struct kernel_statfs { ++ }; ++ #endif ++ +++struct kernel_statx_timestamp { +++ int64_t tv_sec; +++ uint32_t tv_nsec; +++ int32_t __reserved; +++}; +++ +++struct kernel_statx { +++ uint32_t stx_mask; +++ uint32_t stx_blksize; +++ uint64_t stx_attributes; +++ uint32_t stx_nlink; +++ uint32_t stx_uid; +++ uint32_t stx_gid; +++ uint16_t stx_mode; +++ uint16_t __spare0[1]; +++ uint64_t stx_ino; +++ uint64_t stx_size; +++ uint64_t stx_blocks; +++ uint64_t stx_attributes_mask; +++ struct kernel_statx_timestamp stx_atime; +++ struct kernel_statx_timestamp stx_btime; +++ struct kernel_statx_timestamp stx_ctime; +++ struct kernel_statx_timestamp stx_mtime; +++ uint32_t stx_rdev_major; +++ uint32_t stx_rdev_minor; +++ uint32_t stx_dev_major; +++ uint32_t stx_dev_minor; +++ uint64_t stx_mnt_id; +++ uint64_t __spare2; +++ uint64_t __spare3[12]; +++}; ++ ++ /* Definitions missing from the standard header files */ ++ #ifndef O_DIRECTORY ++@@ -737,6 +776,18 @@ struct kernel_statfs { ++ #ifndef AT_REMOVEDIR ++ #define AT_REMOVEDIR 0x200 ++ #endif +++#ifndef AT_NO_AUTOMOUNT +++#define AT_NO_AUTOMOUNT 0x800 +++#endif +++#ifndef AT_EMPTY_PATH +++#define AT_EMPTY_PATH 0x1000 +++#endif +++#ifndef STATX_BASIC_STATS +++#define STATX_BASIC_STATS 0x000007ffU +++#endif +++#ifndef AT_STATX_SYNC_AS_STAT +++#define AT_STATX_SYNC_AS_STAT 0x0000 +++#endif ++ #ifndef MREMAP_FIXED ++ #define MREMAP_FIXED 2 ++ #endif ++@@ -1065,7 +1116,7 @@ struct kernel_statfs { ++ #define __NR_getrandom (__NR_SYSCALL_BASE + 384) ++ #endif ++ /* End of ARM 3/EABI definitions */ ++-#elif defined(__aarch64__) +++#elif defined(__aarch64__) || defined(__loongarch64) ++ #ifndef __NR_setxattr ++ #define __NR_setxattr 5 ++ #endif ++@@ -1121,9 +1172,11 @@ struct kernel_statfs { ++ #ifndef __NR_readlinkat ++ #define __NR_readlinkat 78 ++ #endif +++#if !defined(__loongarch64) ++ #ifndef __NR_newfstatat ++ #define __NR_newfstatat 79 ++ #endif +++#endif // __loongarch64 ++ #ifndef __NR_set_tid_address ++ #define __NR_set_tid_address 96 ++ #endif ++@@ -1164,7 +1217,10 @@ struct kernel_statfs { ++ #ifndef __NR_getrandom ++ #define __NR_getrandom 278 ++ #endif ++-/* End of aarch64 definitions */ +++#ifndef __NR_statx +++#define __NR_statx 291 +++#endif +++/* End of aarch64 || __loongarch64 definitions */ ++ #elif defined(__x86_64__) ++ #ifndef __NR_pread64 ++ #define __NR_pread64 17 ++@@ -1880,14 +1936,15 @@ struct kernel_statfs { ++ ++ #undef LSS_RETURN ++ #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ ++- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) +++ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) \ +++ || defined(__loongarch64)) ++ /* Failing system calls return a negative result in the range of ++ * -1..-4095. These are "errno" values with the sign inverted. ++ */ ++ #define LSS_RETURN(type, res) \ ++ do { \ ++ if ((unsigned long)(res) >= (unsigned long)(-4095)) { \ ++- LSS_ERRNO = -(res); \ +++ LSS_ERRNO = (int)(-(res)); \ ++ res = -1; \ ++ } \ ++ return (type) (res); \ ++@@ -1980,7 +2037,7 @@ struct kernel_statfs { ++ LSS_ENTRYPOINT \ ++ "pop %%ebx" \ ++ args \ ++- : "memory"); \ +++ : "memory"); \ ++ LSS_RETURN(type,__res) ++ #undef _syscall0 ++ #define _syscall0(type,name) \ ++@@ -2037,7 +2094,7 @@ struct kernel_statfs { ++ : "i" (__NR_##name), "ri" ((long)(arg1)), \ ++ "c" ((long)(arg2)), "d" ((long)(arg3)), \ ++ "S" ((long)(arg4)), "D" ((long)(arg5)) \ ++- : "memory"); \ +++ : "memory"); \ ++ LSS_RETURN(type,__res); \ ++ } ++ #undef _syscall6 ++@@ -2059,7 +2116,7 @@ struct kernel_statfs { ++ : "i" (__NR_##name), "0" ((long)(&__s)), \ ++ "c" ((long)(arg2)), "d" ((long)(arg3)), \ ++ "S" ((long)(arg4)), "D" ((long)(arg5)) \ ++- : "memory"); \ +++ : "memory"); \ ++ LSS_RETURN(type,__res); \ ++ } ++ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, ++@@ -2241,7 +2298,7 @@ struct kernel_statfs { ++ #define _LSS_RETURN(type, res, cast) \ ++ do { \ ++ if ((uint64_t)(res) >= (uint64_t)(-4095)) { \ ++- LSS_ERRNO = -(res); \ +++ LSS_ERRNO = (int)(-(res)); \ ++ res = -1; \ ++ } \ ++ return (type)(cast)(res); \ ++@@ -3373,6 +3430,134 @@ struct kernel_statfs { ++ } ++ LSS_RETURN(int, __ret); ++ } +++ #elif defined(__loongarch64) +++ /* Most definitions of _syscallX() neglect to mark "memory" as being +++ * clobbered. This causes problems with compilers, that do a better job +++ * at optimizing across __asm__ calls. +++ * So, we just have to redefine all of the _syscallX() macros. +++ */ +++ #undef LSS_REG +++ #define LSS_REG(ar,a) register int64_t __r##ar __asm__("a"#ar) = (int64_t)a +++ /* syscall is like subroutine calls, all caller-saved registers may be +++ * clobbered, we should add them to the |Clobbers| list. +++ * a0 is not included because it's in the output list. +++ */ +++ #define LSS_SYSCALL_CLOBBERS "t0", "t1", "t2", "t3", "t4", "t5", "t6", \ +++ "t7", "t8", "memory" +++ #undef LSS_BODY +++ #define LSS_BODY(type,name,args...) \ +++ register int64_t __res_a0 __asm__("a0"); \ +++ register int64_t __a7 __asm__("a7") = __NR_##name; \ +++ int64_t __res; \ +++ __asm__ __volatile__ ("syscall 0x0\n" \ +++ : "=r"(__res_a0) \ +++ : "r"(__a7), ## args \ +++ : LSS_SYSCALL_CLOBBERS); \ +++ __res = __res_a0; \ +++ LSS_RETURN(type, __res) +++ #undef _syscall0 +++ #define _syscall0(type, name) \ +++ type LSS_NAME(name)(void) { \ +++ LSS_BODY(type, name); \ +++ } +++ #undef _syscall1 +++ #define _syscall1(type, name, type1, arg1) \ +++ type LSS_NAME(name)(type1 arg1) { \ +++ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ +++ } +++ #undef _syscall2 +++ #define _syscall2(type, name, type1, arg1, type2, arg2) \ +++ type LSS_NAME(name)(type1 arg1, type2 arg2) { \ +++ LSS_REG(0, arg1); LSS_REG(1, arg2); \ +++ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ +++ } +++ #undef _syscall3 +++ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ +++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ +++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ +++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ +++ } +++ #undef _syscall4 +++ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ +++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ +++ LSS_REG(3, arg4); \ +++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ +++ } +++ #undef _syscall5 +++ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ +++ type5,arg5) \ +++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ +++ type5 arg5) { \ +++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ +++ LSS_REG(3, arg4); LSS_REG(4, arg5); \ +++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ +++ "r"(__r4)); \ +++ } +++ #undef _syscall6 +++ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ +++ type5,arg5,type6,arg6) \ +++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ +++ type5 arg5, type6 arg6) { \ +++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ +++ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ +++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ +++ "r"(__r4), "r"(__r5)); \ +++ } +++ +++ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, +++ int flags, void *arg, int *parent_tidptr, +++ void *newtls, int *child_tidptr) { +++ int64_t __res; +++ { +++ register int64_t __res_a0 __asm__("a0"); +++ register uint64_t __flags __asm__("a0") = flags; +++ register void *__stack __asm__("a1") = child_stack; +++ register void *__ptid __asm__("a2") = parent_tidptr; +++ register void *__tls __asm__("a3") = newtls; +++ register int *__ctid __asm__("a4") = child_tidptr; +++ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be +++ * used by the child. +++ */ +++ "addi.d %2, %2, -16\n" +++ "st.d %1, %2, 8\n" +++ "st.d %4, %2, 0\n" +++ +++ /* %a0 = syscall(%a0 = flags, +++ * %a1 = child_stack, +++ * %a2 = parent_tidptr, +++ * %a3 = newtls, +++ * %a4 = child_tidptr) +++ */ +++ "li.d $a7, %8\n" +++ "syscall 0x0\n" +++ +++ /* if (%a0 != 0) +++ * return %a0; +++ */ +++ "bnez $a0, 1f\n" +++ +++ /* In the child, now. Call "fn(arg)". +++ */ +++ "ld.d $a0, $sp, 0\n" +++ "ld.d $a1, $sp, 8\n" +++ "addi.d $sp, $sp, 16\n" +++ "jirl $ra, $a1, 0\n" +++ +++ /* Call _exit(%a0). +++ */ +++ "li.d $a7, %9\n" +++ "syscall 0x0\n" +++ "1:\n" +++ : "=r" (__res_a0) +++ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), +++ "r"(__ptid), "r"(__tls), "r"(__ctid), +++ "i"(__NR_clone), "i"(__NR_exit) +++ : "a7", LSS_SYSCALL_CLOBBERS); +++ __res = __res_a0; +++ } +++ LSS_RETURN(int, __res); +++ } ++ #endif ++ #define __NR__exit __NR_exit ++ #define __NR__gettid __NR_gettid ++@@ -3403,8 +3588,10 @@ struct kernel_statfs { ++ // fork is polyfilled below when not available. ++ LSS_INLINE _syscall0(pid_t, fork) ++ #endif +++ #if defined(__NR_fstat) ++ LSS_INLINE _syscall2(int, fstat, int, f, ++ struct kernel_stat*, b) +++ #endif ++ LSS_INLINE _syscall2(int, fstatfs, int, f, ++ struct kernel_statfs*, b) ++ #if defined(__x86_64__) ++@@ -3426,6 +3613,8 @@ struct kernel_statfs { ++ struct kernel_dirent64*, d, int, c) ++ LSS_INLINE _syscall0(gid_t, getegid) ++ LSS_INLINE _syscall0(uid_t, geteuid) +++ LSS_INLINE _syscall2(int, getitimer, int, w, +++ struct kernel_itimerval*, c) ++ #if defined(__NR_getpgrp) ++ LSS_INLINE _syscall0(pid_t, getpgrp) ++ #endif ++@@ -3437,10 +3626,10 @@ struct kernel_statfs { ++ gid_t *, e, gid_t *, s) ++ LSS_INLINE _syscall3(int, getresuid, uid_t *, r, ++ uid_t *, e, uid_t *, s) ++-#if !defined(__ARM_EABI__) +++ #if defined(__NR_getrlimit) ++ LSS_INLINE _syscall2(int, getrlimit, int, r, ++ struct kernel_rlimit*, l) ++-#endif +++ #endif ++ LSS_INLINE _syscall1(pid_t, getsid, pid_t, p) ++ LSS_INLINE _syscall0(pid_t, _gettid) ++ LSS_INLINE _syscall2(pid_t, gettimeofday, struct kernel_timeval*, t, ++@@ -3547,6 +3736,9 @@ struct kernel_statfs { ++ LSS_INLINE _syscall1(int, setfsuid, uid_t, u) ++ LSS_INLINE _syscall1(int, setuid, uid_t, u) ++ LSS_INLINE _syscall1(int, setgid, gid_t, g) +++ LSS_INLINE _syscall3(int, setitimer, int, w, +++ const struct kernel_itimerval*, n, +++ struct kernel_itimerval*, o) ++ LSS_INLINE _syscall2(int, setpgid, pid_t, p, ++ pid_t, g) ++ LSS_INLINE _syscall3(int, setpriority, int, a, ++@@ -3555,8 +3747,10 @@ struct kernel_statfs { ++ gid_t, e, gid_t, s) ++ LSS_INLINE _syscall3(int, setresuid, uid_t, r, ++ uid_t, e, uid_t, s) +++ #if defined(__NR_setrlimit) ++ LSS_INLINE _syscall2(int, setrlimit, int, r, ++ const struct kernel_rlimit*, l) +++ #endif ++ LSS_INLINE _syscall0(pid_t, setsid) ++ LSS_INLINE _syscall2(int, sigaltstack, const stack_t*, s, ++ const stack_t*, o) ++@@ -3586,23 +3780,6 @@ struct kernel_statfs { ++ LSS_INLINE _syscall3(long, getcpu, unsigned *, cpu, ++ unsigned *, node, void *, unused) ++ #endif ++- #if defined(__x86_64__) || \ ++- (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI32) ++- LSS_INLINE _syscall3(int, recvmsg, int, s, ++- struct kernel_msghdr*, m, int, f) ++- LSS_INLINE _syscall3(int, sendmsg, int, s, ++- const struct kernel_msghdr*, m, int, f) ++- LSS_INLINE _syscall6(int, sendto, int, s, ++- const void*, m, size_t, l, ++- int, f, ++- const struct kernel_sockaddr*, a, int, t) ++- LSS_INLINE _syscall2(int, shutdown, int, s, ++- int, h) ++- LSS_INLINE _syscall3(int, socket, int, d, ++- int, t, int, p) ++- LSS_INLINE _syscall4(int, socketpair, int, d, ++- int, t, int, p, int*, s) ++- #endif ++ #if defined(__NR_fadvise64) ++ #if defined(__x86_64__) ++ /* Need to make sure loff_t isn't truncated to 32-bits under x32. */ ++@@ -3685,6 +3862,12 @@ struct kernel_statfs { ++ const char *, p, ++ struct kernel_stat*, b, int, f) ++ #endif +++ #if defined(__NR_statx) +++ LSS_INLINE _syscall5(int, statx, int, d, +++ const char *, p, +++ int, f, int, m, +++ struct kernel_statx*, b) +++ #endif ++ #if defined(__x86_64__) || defined(__s390x__) ++ LSS_INLINE int LSS_NAME(getresgid32)(gid_t *rgid, ++ gid_t *egid, ++@@ -4181,23 +4364,30 @@ struct kernel_statfs { ++ LSS_SC_BODY(4, int, 8, d, type, protocol, sv); ++ } ++ #endif ++- #if defined(__ARM_EABI__) || defined (__aarch64__) +++ #if defined(__NR_recvmsg) ++ LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, ++ int, flags) +++ #endif +++ #if defined(__NR_sendmsg) ++ LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, ++ msg, int, flags) +++ #endif +++ #if defined(__NR_sendto) ++ LSS_INLINE _syscall6(ssize_t, sendto, int, s, const void*, buf, size_t,len, ++ int, flags, const struct kernel_sockaddr*, to, ++ unsigned int, tolen) +++ #endif +++ #if defined(__NR_shutdown) ++ LSS_INLINE _syscall2(int, shutdown, int, s, int, how) +++ #endif +++ #if defined(__NR_socket) ++ LSS_INLINE _syscall3(int, socket, int, domain, int, type, int, protocol) +++ #endif +++ #if defined(__NR_socketpair) ++ LSS_INLINE _syscall4(int, socketpair, int, d, int, type, int, protocol, ++ int*, sv) ++ #endif ++- #if defined(__i386__) || defined(__ARM_ARCH_3__) || \ ++- (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ ++- defined(__s390__) ++- #define __NR__socketcall __NR_socketcall +++ #if defined(__NR_socketcall) ++ LSS_INLINE _syscall2(int, _socketcall, int, c, ++ va_list, a) ++ LSS_INLINE int LSS_NAME(socketcall)(int op, ...) { ++@@ -4209,37 +4399,49 @@ struct kernel_statfs { ++ return rc; ++ } ++ +++ #if !defined(__NR_recvmsg) ++ LSS_INLINE ssize_t LSS_NAME(recvmsg)(int s,struct kernel_msghdr *msg, ++ int flags){ ++ return (ssize_t)LSS_NAME(socketcall)(17, s, msg, flags); ++ } +++ #endif ++ +++ #if !defined(__NR_sendmsg) ++ LSS_INLINE ssize_t LSS_NAME(sendmsg)(int s, ++ const struct kernel_msghdr *msg, ++ int flags) { ++ return (ssize_t)LSS_NAME(socketcall)(16, s, msg, flags); ++ } +++ #endif ++ +++ #if !defined(__NR_sendto) ++ LSS_INLINE ssize_t LSS_NAME(sendto)(int s, const void *buf, size_t len, ++ int flags, ++ const struct kernel_sockaddr *to, ++ unsigned int tolen) { ++ return (ssize_t)LSS_NAME(socketcall)(11, s, buf, len, flags, to, tolen); ++ } +++ #endif ++ +++ #if !defined(__NR_shutdown) ++ LSS_INLINE int LSS_NAME(shutdown)(int s, int how) { ++ return LSS_NAME(socketcall)(13, s, how); ++ } +++ #endif ++ +++ #if !defined(__NR_socket) ++ LSS_INLINE int LSS_NAME(socket)(int domain, int type, int protocol) { ++ return LSS_NAME(socketcall)(1, domain, type, protocol); ++ } +++ #endif ++ +++ #if !defined(__NR_socketpair) ++ LSS_INLINE int LSS_NAME(socketpair)(int d, int type, int protocol, ++ int sv[2]) { ++ return LSS_NAME(socketcall)(8, d, type, protocol, sv); ++ } ++- #endif +++ #endif +++ #endif // defined(__NR_socketcall) ++ #if defined(__NR_fstatat64) ++ LSS_INLINE _syscall4(int, fstatat64, int, d, ++ const char *, p, ++@@ -4486,10 +4688,64 @@ struct kernel_statfs { ++ } ++ #endif ++ +++#if defined(__NR_statx) +++ /* copy the contents of kernel_statx to the kernel_stat structure. */ +++ LSS_INLINE void LSS_NAME(cp_stat_statx)(struct kernel_stat *to, +++ struct kernel_statx *from) { +++ memset(to, 0, sizeof(struct kernel_stat)); +++ to->st_dev = (unsigned long)((from->stx_dev_minor & 0xff) | +++ ((from->stx_dev_major & 0xfff) << 8) | +++ ((from->stx_dev_minor & ~0xffu) << 12)); +++ to->st_rdev = (unsigned long)((from->stx_rdev_minor & 0xff) | +++ ((from->stx_rdev_major & 0xfff) << 8) | +++ ((from->stx_rdev_minor & ~0xffu) << 12)); +++ to->st_ino = (unsigned long)from->stx_ino; +++ to->st_mode = (unsigned int)from->stx_mode; +++ to->st_nlink = (unsigned int)from->stx_nlink; +++ to->st_uid = (unsigned int)from->stx_uid; +++ to->st_gid = (unsigned int)from->stx_gid; +++ to->st_atime_ = (long)(from->stx_atime.tv_sec); +++ to->st_atime_nsec_ = from->stx_atime.tv_nsec; +++ to->st_mtime_ = (long)(from->stx_mtime.tv_sec); +++ to->st_mtime_nsec_ = from->stx_mtime.tv_nsec; +++ to->st_ctime_ = (long)(from->stx_ctime.tv_sec); +++ to->st_ctime_nsec_ = from->stx_ctime.tv_nsec; +++ to->st_size = (long)(from->stx_size); +++ to->st_blocks = (int)(from->stx_blocks); +++ to->st_blksize = (int)from->stx_blksize; +++ } +++#endif +++ +++#if !defined(__NR_fstat) +++ LSS_INLINE int LSS_NAME(fstat)(int fd, +++ struct kernel_stat *buf) { +++ #if defined(__NR_newfstatat) +++ return LSS_NAME(newfstatat)(fd, "", buf, AT_EMPTY_PATH); +++ #elif defined(__NR_statx) +++ struct kernel_statx stx; +++ int flags = AT_NO_AUTOMOUNT | AT_EMPTY_PATH; +++ int mask = STATX_BASIC_STATS; +++ int res = LSS_NAME(statx)(fd, "", flags, mask, &stx); +++ LSS_NAME(cp_stat_statx)(buf, &stx); +++ return res; +++ #endif +++ } +++#endif +++ +++ ++ #if !defined(__NR_stat) ++ LSS_INLINE int LSS_NAME(stat)(const char *pathname, ++ struct kernel_stat *buf) { +++ #if defined(__NR_newfstatat) ++ return LSS_NAME(newfstatat)(AT_FDCWD, pathname, buf, 0); +++ #elif defined(__NR_statx) +++ struct kernel_statx stx; +++ int flags = AT_NO_AUTOMOUNT | AT_STATX_SYNC_AS_STAT; +++ int mask = STATX_BASIC_STATS; +++ int res = LSS_NAME(statx)(AT_FDCWD, pathname, flags, mask, &stx); +++ LSS_NAME(cp_stat_statx)(buf, &stx); +++ return res; +++ #endif ++ } ++ #endif ++ ++@@ -4503,7 +4759,7 @@ struct kernel_statfs { ++ // TODO: define this in an arch-independant way instead of inlining the clone ++ // syscall body. ++ ++-# if defined(__aarch64__) +++# if defined(__aarch64__) || defined(__loongarch64) ++ LSS_INLINE pid_t LSS_NAME(fork)(void) { ++ // No fork syscall on aarch64 - implement by means of the clone syscall. ++ // Note that this does not reset glibc's cached view of the PID/TID, so +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h +@@ -75,7 +75,7 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEX + // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice + // here. + return 16; // 64kB +-#elif defined(_MIPS_ARCH_LOONGSON) ++#elif defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) + return 14; // 16kB + #elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) + // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h.orig +@@ -0,0 +1,160 @@ ++// Copyright (c) 2018 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ ++#define THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ ++ ++#include ++ ++#include "build/build_config.h" ++#include "third_party/base/compiler_specific.h" ++ ++#if defined(OS_APPLE) ++ ++#include ++ ++// Although page allocator constants are not constexpr, they are run-time ++// constant. Because the underlying variables they access, such as vm_page_size, ++// are not marked const, the compiler normally has no way to know that they ++// don’t change and must obtain their values whenever it can't prove that they ++// haven't been modified, even if they had already been obtained previously. ++// Attaching __attribute__((const)) to these declarations allows these redundant ++// accesses to be omitted under optimization such as common subexpression ++// elimination. ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) ++ ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++// This should work for all POSIX (if needed), but currently all other ++// supported OS/architecture combinations use either hard-coded values ++// (such as x86) or have means to determine these values without needing ++// atomics (such as macOS on arm64). ++ ++// Page allocator constants are run-time constant ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) ++ ++#include ++#include ++ ++namespace pdfium::base::internal { ++ ++// Holds the current page size and shift, where size = 1 << shift ++// Use PageAllocationGranularity(), PageAllocationGranularityShift() ++// to initialize and retrieve these values safely. ++struct PageCharacteristics { ++ std::atomic size; ++ std::atomic shift; ++}; ++extern PageCharacteristics page_characteristics; ++ ++} // namespace base::internal ++ ++#else ++ ++// When defined, page size constants are fixed at compile time. When not ++// defined, they may vary at run time. ++#define PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR 1 ++ ++// Use this macro to declare a function as constexpr or not based on whether ++// PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR is defined. ++#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR constexpr ++ ++#endif ++ ++namespace pdfium { ++ ++namespace base { ++// Forward declaration, implementation below ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularity(); ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() { ++#if defined(OS_WIN) || defined(ARCH_CPU_PPC64) ++ // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page ++ // sizes. Since 64kB is the de facto standard on the platform and binaries ++ // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice ++ // here. ++ return 16; // 64kB ++#elif defined(_MIPS_ARCH_LOONGSON) ++ return 14; // 16kB ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++ // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) ++ // page sizes. Retrieve from or initialize cache. ++ int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed); ++ if (UNLIKELY(shift == 0)) { ++ shift = __builtin_ctz((int)base::PageAllocationGranularity()); ++ base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed); ++ } ++ return shift; ++#elif defined(OS_APPLE) ++ return vm_page_shift; ++#else ++ return 12; // 4kB ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularity() { ++#if defined(OS_APPLE) ++ // This is literally equivalent to |1 << PageAllocationGranularityShift()| ++ // below, but was separated out for OS_APPLE to avoid << on a non-constexpr. ++ return vm_page_size; ++#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64) ++ // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or ++ // initialize cache. ++ int size = internal::page_characteristics.size.load(std::memory_order_relaxed); ++ if (UNLIKELY(size == 0)) { ++ size = getpagesize(); ++ internal::page_characteristics.size.store(size, std::memory_order_relaxed); ++ } ++ return size; ++#else ++ return 1ULL << PageAllocationGranularityShift(); ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularityOffsetMask() { ++ return PageAllocationGranularity() - 1; ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++PageAllocationGranularityBaseMask() { ++ return ~PageAllocationGranularityOffsetMask(); ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageSize() { ++#if defined(OS_WIN) ++ return 4096; ++#else ++ return PageAllocationGranularity(); ++#endif ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageOffsetMask() { ++ return SystemPageSize() - 1; ++} ++ ++PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t ++SystemPageBaseMask() { ++ return ~SystemPageOffsetMask(); ++} ++ ++static constexpr size_t kPageMetadataShift = 5; // 32 bytes per partition page. ++static constexpr size_t kPageMetadataSize = 1 << kPageMetadataShift; ++ ++// See DecommitSystemPages(), this is not guaranteed to be synchronous on all ++// platforms. ++static constexpr bool kDecommittedPagesAreAlwaysZeroed = ++#if defined(OS_APPLE) ++ false; ++#else ++ true; ++#endif ++ ++} // namespace base ++} // namespace pdfium ++ ++#endif // THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_CONSTANTS_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h +++++ src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h ++@@ -48,7 +48,7 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() { ++ // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice ++ // here. ++ return 16; // 64kB ++-#elif defined(_MIPS_ARCH_LOONGSON) +++#elif defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) ++ return 14; // 16kB ++ #else ++ return 12; // 4kB +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h +@@ -40,7 +40,7 @@ static const size_t kBucketShift = (kAll + // other constant values, we pack _all_ `PartitionRootGeneric::Alloc` sizes + // perfectly up against the end of a system page. + +-#if defined(_MIPS_ARCH_LOONGSON) ++#if defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) + PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int + PartitionPageShift() { + return 16; // 64 KiB +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h +++++ src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h ++@@ -40,7 +40,7 @@ static const size_t kBucketShift = (kAllocationGranularity == 8) ? 3 : 2; ++ // other constant values, we pack _all_ `PartitionRootGeneric::Alloc` sizes ++ // perfectly up against the end of a system page. ++ ++-#if defined(_MIPS_ARCH_LOONGSON) +++#if defined(_MIPS_ARCH_LOONGSON) || defined(__loongarch64) ++ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int ++ PartitionPageShift() { ++ return 16; // 64 KiB +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn +@@ -149,6 +149,8 @@ swiftshader_llvm_source_set("swiftshader + deps += [ ":swiftshader_llvm_ppc" ] + } else if (current_cpu == "x86" || current_cpu == "x64") { + deps += [ ":swiftshader_llvm_x86" ] ++ } else if (current_cpu == "loongarch64") { ++ # Do Nothing + } else { + assert(false, "Unsupported current_cpu") + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn +++++ src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn ++@@ -149,6 +149,8 @@ swiftshader_llvm_source_set("swiftshader_llvm") { ++ deps += [ ":swiftshader_llvm_ppc" ] ++ } else if (current_cpu == "x86" || current_cpu == "x64") { ++ deps += [ ":swiftshader_llvm_x86" ] +++ } else if (current_cpu == "loongarch64") { +++ # Do Nothing ++ } else { ++ assert(false, "Unsupported current_cpu") ++ } +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc +@@ -30,7 +30,8 @@ bool VectorDifference(const uint8_t* ima + static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr; + + if (!diff_proc) { +-#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) ++#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || \ ++ defined(WEBRTC_ARCH_LOONGARCH_FAMILY) + // For ARM and MIPS processors, always use C version. + // TODO(hclam): Implement a NEON version. + diff_proc = &VectorDifference_C; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc +++++ src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc ++@@ -30,7 +30,8 @@ bool VectorDifference(const uint8_t* image1, const uint8_t* image2) { ++ static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr; ++ ++ if (!diff_proc) { ++-#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) +++#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || \ +++ defined(WEBRTC_ARCH_LOONGARCH_FAMILY) ++ // For ARM and MIPS processors, always use C version. ++ // TODO(hclam): Implement a NEON version. ++ diff_proc = &VectorDifference_C; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h +@@ -50,6 +50,10 @@ + #elif defined(__EMSCRIPTEN__) + #define WEBRTC_ARCH_32_BITS + #define WEBRTC_ARCH_LITTLE_ENDIAN ++#elif defined(__loongarch64) ++#define WEBRTC_ARCH_LOONGARCH_FAMILY ++#define WEBRTC_ARCH_64_BITS ++#define WEBRTC_ARCH_LITTLE_ENDIAN + #else + #error Please add support for your architecture in rtc_base/system/arch.h + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h.rej +@@ -0,0 +1,13 @@ ++--- src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h +++++ src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h ++@@ -50,6 +50,10 @@ ++ #elif defined(__EMSCRIPTEN__) ++ #define WEBRTC_ARCH_32_BITS ++ #define WEBRTC_ARCH_LITTLE_ENDIAN +++#elif defined(__loongarch64) +++#define WEBRTC_ARCH_LOONGARCH_FAMILY +++#define WEBRTC_ARCH_64_BITS +++#define WEBRTC_ARCH_LITTLE_ENDIAN ++ #else ++ #error Please add support for your architecture in rtc_base/system/arch.h ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/BUILD.gn ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/BUILD.gn +@@ -794,6 +794,16 @@ config("toolchain") { + cflags += [ "-march=z196" ] + } + } ++ ++ # loongarch64 simulators. ++ if (target_is_simulator && v8_current_cpu == "loongarch64") { ++ defines += [ "_LOONGARCH64_TARGET_SIMULATOR" ] ++ } ++ ++ if (v8_current_cpu == "loongarch64") { ++ defines += [ "V8_TARGET_ARCH_LOONGARCH64" ] ++ } ++ + if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { + if (v8_current_cpu == "ppc") { + defines += [ "V8_TARGET_ARCH_PPC" ] +@@ -1873,6 +1883,11 @@ v8_source_set("v8_initializers") { + ### gcmole(arch:mips64el) ### + "src/builtins/mips64/builtins-mips64.cc", + ] ++ } else if (v8_current_cpu == "loongarch64") { ++ sources += [ ++ ### gcmole(arch:loongarch64) ### ++ "src/builtins/loongarch64/builtins-loongarch64.cc", ++ ] + } else if (v8_current_cpu == "ppc") { + sources += [ + ### gcmole(arch:ppc) ### +@@ -3672,6 +3687,33 @@ v8_source_set("v8_base_without_compiler" + "src/regexp/mips64/regexp-macro-assembler-mips64.h", + "src/wasm/baseline/mips64/liftoff-assembler-mips64.h", + ] ++ } else if (v8_current_cpu == "loongarch64") { ++ sources += [ ### gcmole(arch:loongarch64) ### ++ "src/codegen/loongarch64/assembler-loongarch64-inl.h", ++ "src/codegen/loongarch64/assembler-loongarch64.cc", ++ "src/codegen/loongarch64/assembler-loongarch64.h", ++ "src/codegen/loongarch64/constants-loongarch64.cc", ++ "src/codegen/loongarch64/constants-loongarch64.h", ++ "src/codegen/loongarch64/cpu-loongarch64.cc", ++ "src/codegen/loongarch64/interface-descriptors-loongarch64.cc", ++ "src/codegen/loongarch64/macro-assembler-loongarch64.cc", ++ "src/codegen/loongarch64/macro-assembler-loongarch64.h", ++ "src/codegen/loongarch64/register-loongarch64.h", ++ "src/compiler/backend/loongarch64/code-generator-loongarch64.cc", ++ "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h", ++ "src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc", ++ "src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc", ++ "src/debug/loongarch64/debug-loongarch64.cc", ++ "src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc", ++ "src/diagnostics/loongarch64/disasm-loongarch64.cc", ++ "src/execution/loongarch64/frame-constants-loongarch64.cc", ++ "src/execution/loongarch64/frame-constants-loongarch64.h", ++ "src/execution/loongarch64/simulator-loongarch64.cc", ++ "src/execution/loongarch64/simulator-loongarch64.h", ++ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc", ++ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h", ++ "src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h", ++ ] + } else if (v8_current_cpu == "ppc") { + sources += [ ### gcmole(arch:ppc) ### + "src/codegen/ppc/assembler-ppc-inl.h", +@@ -4328,6 +4370,8 @@ v8_source_set("v8_cppgc_shared") { + sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ] + } else if (current_cpu == "mips64el") { + sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ] ++ } else if (current_cpu == "loongarch64") { ++ sources += [ "src/heap/base/asm/loongarch64/push_registers_asm.cc" ] + } + } else if (is_win) { + if (current_cpu == "x64") { +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/BUILD.gn.rej +@@ -0,0 +1,74 @@ ++--- src/3rdparty/chromium/v8/BUILD.gn +++++ src/3rdparty/chromium/v8/BUILD.gn ++@@ -794,6 +794,16 @@ config("toolchain") { ++ cflags += [ "-march=z196" ] ++ } ++ } +++ +++ # loongarch64 simulators. +++ if (target_is_simulator && v8_current_cpu == "loongarch64") { +++ defines += [ "_LOONGARCH64_TARGET_SIMULATOR" ] +++ } +++ +++ if (v8_current_cpu == "loongarch64") { +++ defines += [ "V8_TARGET_ARCH_LOONGARCH64" ] +++ } +++ ++ if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { ++ if (v8_current_cpu == "ppc") { ++ defines += [ "V8_TARGET_ARCH_PPC" ] ++@@ -1873,6 +1883,11 @@ v8_source_set("v8_initializers") { ++ ### gcmole(arch:mips64el) ### ++ "src/builtins/mips64/builtins-mips64.cc", ++ ] +++ } else if (v8_current_cpu == "loongarch64") { +++ sources += [ +++ ### gcmole(arch:loongarch64) ### +++ "src/builtins/loongarch64/builtins-loongarch64.cc", +++ ] ++ } else if (v8_current_cpu == "ppc") { ++ sources += [ ++ ### gcmole(arch:ppc) ### ++@@ -3672,6 +3687,33 @@ v8_source_set("v8_base_without_compiler") { ++ "src/regexp/mips64/regexp-macro-assembler-mips64.h", ++ "src/wasm/baseline/mips64/liftoff-assembler-mips64.h", ++ ] +++ } else if (v8_current_cpu == "loongarch64") { +++ sources += [ ### gcmole(arch:loongarch64) ### +++ "src/codegen/loongarch64/assembler-loongarch64-inl.h", +++ "src/codegen/loongarch64/assembler-loongarch64.cc", +++ "src/codegen/loongarch64/assembler-loongarch64.h", +++ "src/codegen/loongarch64/constants-loongarch64.cc", +++ "src/codegen/loongarch64/constants-loongarch64.h", +++ "src/codegen/loongarch64/cpu-loongarch64.cc", +++ "src/codegen/loongarch64/interface-descriptors-loongarch64.cc", +++ "src/codegen/loongarch64/macro-assembler-loongarch64.cc", +++ "src/codegen/loongarch64/macro-assembler-loongarch64.h", +++ "src/codegen/loongarch64/register-loongarch64.h", +++ "src/compiler/backend/loongarch64/code-generator-loongarch64.cc", +++ "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h", +++ "src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc", +++ "src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc", +++ "src/debug/loongarch64/debug-loongarch64.cc", +++ "src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc", +++ "src/diagnostics/loongarch64/disasm-loongarch64.cc", +++ "src/execution/loongarch64/frame-constants-loongarch64.cc", +++ "src/execution/loongarch64/frame-constants-loongarch64.h", +++ "src/execution/loongarch64/simulator-loongarch64.cc", +++ "src/execution/loongarch64/simulator-loongarch64.h", +++ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc", +++ "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h", +++ "src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h", +++ ] ++ } else if (v8_current_cpu == "ppc") { ++ sources += [ ### gcmole(arch:ppc) ### ++ "src/codegen/ppc/assembler-ppc-inl.h", ++@@ -4328,6 +4370,8 @@ v8_source_set("v8_cppgc_shared") { ++ sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ] ++ } else if (current_cpu == "mips64el") { ++ sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ] +++ } else if (current_cpu == "loongarch64") { +++ sources += [ "src/heap/base/asm/loongarch64/push_registers_asm.cc" ] ++ } ++ } else if (is_win) { ++ if (current_cpu == "x64") { +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni +@@ -79,7 +79,8 @@ if (v8_snapshot_toolchain == "") { + + if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { + _cpus = v8_current_cpu +- } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { ++ } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || ++ v8_current_cpu == "loongarch64") { + if (is_win && v8_current_cpu == "arm64") { + # set _cpus to blank for Windows ARM64 so host_toolchain could be + # selected as snapshot toolchain later. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni +++++ src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni ++@@ -79,7 +79,8 @@ if (v8_snapshot_toolchain == "") { ++ ++ if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { ++ _cpus = v8_current_cpu ++- } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { +++ } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" || +++ v8_current_cpu == "loongarch64") { ++ if (is_win && v8_current_cpu == "arm64") { ++ # set _cpus to blank for Windows ARM64 so host_toolchain could be ++ # selected as snapshot toolchain later. +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/base/build_config.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/base/build_config.h +@@ -46,6 +46,13 @@ + #else + #define V8_HOST_ARCH_32_BIT 1 + #endif ++#elif defined(__loongarch__) ++#if defined(__loongarch_lp64) ++#define V8_HOST_ARCH_LOONGARCH64 1 ++#define V8_HOST_ARCH_64_BIT 1 ++#else ++#error "Only lp64 been supported by v8" ++#endif + #else + #error "Host architecture was not detected as supported by v8" + #endif +@@ -77,7 +84,8 @@ + // environment as presented by the compiler. + #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ + !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ +- !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 ++ !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ ++ !V8_TARGET_ARCH_LOONGARCH64 + #if defined(_M_X64) || defined(__x86_64__) + #define V8_TARGET_ARCH_X64 1 + #elif defined(_M_IX86) || defined(__i386__) +@@ -94,6 +102,8 @@ + #define V8_TARGET_ARCH_PPC64 1 + #elif defined(_ARCH_PPC) + #define V8_TARGET_ARCH_PPC 1 ++#elif defined(__loongarch_lp64) ++#define V8_TARGET_ARCH_LOONGARCH64 1 + #else + #error Target architecture was not detected as supported by v8 + #endif +@@ -128,6 +138,8 @@ + #else + #define V8_TARGET_ARCH_32_BIT 1 + #endif ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#define V8_TARGET_ARCH_64_BIT 1 + #else + #error Unknown target architecture pointer size + #endif +@@ -156,6 +168,9 @@ + #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) + #error Target architecture mips64 is only supported on mips64 and x64 host + #endif ++#if (V8_TARGET_ARCH_LOONGARCH64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_LOONGARCH64)) ++#error Target architecture loongarch64 is only supported on loongarch64 and x64 host ++#endif + + // Determine architecture endianness. + #if V8_TARGET_ARCH_IA32 +@@ -190,6 +205,8 @@ + #else + #define V8_TARGET_BIG_ENDIAN 1 + #endif ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#define V8_TARGET_LITTLE_ENDIAN 1 + #else + #error Unknown target architecture endianness + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/base/build_config.h.rej +@@ -0,0 +1,63 @@ ++--- src/3rdparty/chromium/v8/src/base/build_config.h +++++ src/3rdparty/chromium/v8/src/base/build_config.h ++@@ -46,6 +46,13 @@ ++ #else ++ #define V8_HOST_ARCH_32_BIT 1 ++ #endif +++#elif defined(__loongarch__) +++#if defined(__loongarch_lp64) +++#define V8_HOST_ARCH_LOONGARCH64 1 +++#define V8_HOST_ARCH_64_BIT 1 +++#else +++#error "Only lp64 been supported by v8" +++#endif ++ #else ++ #error "Host architecture was not detected as supported by v8" ++ #endif ++@@ -77,7 +84,8 @@ ++ // environment as presented by the compiler. ++ #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ ++ !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ ++- !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 +++ !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ +++ !V8_TARGET_ARCH_LOONGARCH64 ++ #if defined(_M_X64) || defined(__x86_64__) ++ #define V8_TARGET_ARCH_X64 1 ++ #elif defined(_M_IX86) || defined(__i386__) ++@@ -94,6 +102,8 @@ ++ #define V8_TARGET_ARCH_PPC64 1 ++ #elif defined(_ARCH_PPC) ++ #define V8_TARGET_ARCH_PPC 1 +++#elif defined(__loongarch_lp64) +++#define V8_TARGET_ARCH_LOONGARCH64 1 ++ #else ++ #error Target architecture was not detected as supported by v8 ++ #endif ++@@ -128,6 +138,8 @@ ++ #else ++ #define V8_TARGET_ARCH_32_BIT 1 ++ #endif +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#define V8_TARGET_ARCH_64_BIT 1 ++ #else ++ #error Unknown target architecture pointer size ++ #endif ++@@ -156,6 +168,9 @@ ++ #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) ++ #error Target architecture mips64 is only supported on mips64 and x64 host ++ #endif +++#if (V8_TARGET_ARCH_LOONGARCH64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_LOONGARCH64)) +++#error Target architecture loongarch64 is only supported on loongarch64 and x64 host +++#endif ++ ++ // Determine architecture endianness. ++ #if V8_TARGET_ARCH_IA32 ++@@ -190,6 +205,8 @@ ++ #else ++ #define V8_TARGET_BIG_ENDIAN 1 ++ #endif +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#define V8_TARGET_LITTLE_ENDIAN 1 ++ #else ++ #error Unknown target architecture endianness ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc +@@ -324,6 +324,18 @@ void* OS::GetRandomMmapAddr() { + // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance + // to fulfill request. + raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; + #else + raw_addr &= 0x3FFFF000; + +@@ -503,6 +515,8 @@ void OS::DebugBreak() { + asm("break"); + #elif V8_HOST_ARCH_MIPS64 + asm("break"); ++#elif V8_HOST_ARCH_LOONGARCH64 ++ asm("break 0"); + #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 + asm("twge 2,2"); + #elif V8_HOST_ARCH_IA32 +@@ -512,6 +526,8 @@ void OS::DebugBreak() { + #elif V8_HOST_ARCH_S390 + // Software breakpoint instruction is 0x0001 + asm volatile(".word 0x0001"); ++#elif V8_HOST_ARCH_LOONGARCH64 ++ asm("break 0"); + #else + #error Unsupported host architecture. + #endif +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc.orig +@@ -0,0 +1,1053 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Platform-specific code for POSIX goes here. This is not a platform on its ++// own, but contains the parts which are the same across the POSIX platforms ++// Linux, MacOS, FreeBSD, OpenBSD, NetBSD and QNX. ++ ++#include ++#include ++#include ++#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) ++#include // for pthread_set_name_np ++#endif ++#include // for sched_yield ++#include ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ ++ defined(__NetBSD__) || defined(__OpenBSD__) ++#include // NOLINT, for sysctl ++#endif ++ ++#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) ++#define LOG_TAG "v8" ++#include // NOLINT ++#endif ++ ++#include ++#include ++ ++#include "src/base/platform/platform-posix.h" ++ ++#include "src/base/lazy-instance.h" ++#include "src/base/macros.h" ++#include "src/base/platform/platform.h" ++#include "src/base/platform/time.h" ++#include "src/base/utils/random-number-generator.h" ++ ++#ifdef V8_FAST_TLS_SUPPORTED ++#include ++#endif ++ ++#if V8_OS_MACOSX ++#include ++#include ++#endif ++ ++#if V8_OS_LINUX ++#include // NOLINT, for prctl ++#endif ++ ++#if defined(V8_OS_FUCHSIA) ++#include ++#else ++#include ++#endif ++ ++#if !defined(_AIX) && !defined(V8_OS_FUCHSIA) ++#include ++#endif ++ ++#if V8_OS_FREEBSD || V8_OS_MACOSX || V8_OS_OPENBSD || V8_OS_SOLARIS ++#define MAP_ANONYMOUS MAP_ANON ++#endif ++ ++#if defined(V8_OS_SOLARIS) ++#if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__) ++extern "C" int madvise(caddr_t, size_t, int); ++#else ++extern int madvise(caddr_t, size_t, int); ++#endif ++#endif ++ ++#ifndef MADV_FREE ++#define MADV_FREE MADV_DONTNEED ++#endif ++ ++#if defined(V8_LIBC_GLIBC) ++extern "C" void* __libc_stack_end; // NOLINT ++#endif ++ ++namespace v8 { ++namespace base { ++ ++namespace { ++ ++// 0 is never a valid thread id. ++const pthread_t kNoThread = static_cast(0); ++ ++bool g_hard_abort = false; ++ ++const char* g_gc_fake_mmap = nullptr; ++ ++DEFINE_LAZY_LEAKY_OBJECT_GETTER(RandomNumberGenerator, ++ GetPlatformRandomNumberGenerator) ++static LazyMutex rng_mutex = LAZY_MUTEX_INITIALIZER; ++ ++#if !V8_OS_FUCHSIA ++#if V8_OS_MACOSX ++// kMmapFd is used to pass vm_alloc flags to tag the region with the user ++// defined tag 255 This helps identify V8-allocated regions in memory analysis ++// tools like vmmap(1). ++const int kMmapFd = VM_MAKE_TAG(255); ++#else // !V8_OS_MACOSX ++const int kMmapFd = -1; ++#endif // !V8_OS_MACOSX ++ ++#if defined(V8_TARGET_OS_MACOSX) && V8_HOST_ARCH_ARM64 ++// During snapshot generation in cross builds, sysconf() runs on the Intel ++// host and returns host page size, while the snapshot needs to use the ++// target page size. ++constexpr int kAppleArmPageSize = 1 << 14; ++#endif ++ ++const int kMmapFdOffset = 0; ++ ++// TODO(v8:10026): Add the right permission flag to make executable pages ++// guarded. ++int GetProtectionFromMemoryPermission(OS::MemoryPermission access) { ++ switch (access) { ++ case OS::MemoryPermission::kNoAccess: ++ return PROT_NONE; ++ case OS::MemoryPermission::kRead: ++ return PROT_READ; ++ case OS::MemoryPermission::kReadWrite: ++ return PROT_READ | PROT_WRITE; ++ case OS::MemoryPermission::kReadWriteExecute: ++ return PROT_READ | PROT_WRITE | PROT_EXEC; ++ case OS::MemoryPermission::kReadExecute: ++ return PROT_READ | PROT_EXEC; ++ } ++ UNREACHABLE(); ++} ++ ++enum class PageType { kShared, kPrivate }; ++ ++int GetFlagsForMemoryPermission(OS::MemoryPermission access, ++ PageType page_type) { ++ int flags = MAP_ANONYMOUS; ++ flags |= (page_type == PageType::kShared) ? MAP_SHARED : MAP_PRIVATE; ++ if (access == OS::MemoryPermission::kNoAccess) { ++#if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX ++ flags |= MAP_NORESERVE; ++#endif // !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX ++#if V8_OS_QNX ++ flags |= MAP_LAZY; ++#endif // V8_OS_QNX ++#if V8_OS_MACOSX && V8_HOST_ARCH_ARM64 && defined(MAP_JIT) && \ ++ !defined(V8_OS_IOS) ++ // TODO(jkummerow): using the V8_OS_IOS define is a crude approximation ++ // of the fact that we don't want to set the MAP_JIT flag when ++ // FLAG_jitless == true, as src/base/ doesn't know any flags. ++ // TODO(crbug.com/1117591): This is only needed for code spaces. ++ flags |= MAP_JIT; ++#endif ++ } ++ return flags; ++} ++ ++void* Allocate(void* hint, size_t size, OS::MemoryPermission access, ++ PageType page_type) { ++ int prot = GetProtectionFromMemoryPermission(access); ++ int flags = GetFlagsForMemoryPermission(access, page_type); ++ void* result = mmap(hint, size, prot, flags, kMmapFd, kMmapFdOffset); ++ if (result == MAP_FAILED) return nullptr; ++ return result; ++} ++ ++#endif // !V8_OS_FUCHSIA ++ ++} // namespace ++ ++#if V8_OS_LINUX || V8_OS_FREEBSD ++#ifdef __arm__ ++ ++bool OS::ArmUsingHardFloat() { ++ // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify ++ // the Floating Point ABI used (PCS stands for Procedure Call Standard). ++ // We use these as well as a couple of other defines to statically determine ++ // what FP ABI used. ++ // GCC versions 4.4 and below don't support hard-fp. ++ // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or ++ // __ARM_PCS_VFP. ++ ++#define GCC_VERSION \ ++ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) ++#if GCC_VERSION >= 40600 && !defined(__clang__) ++#if defined(__ARM_PCS_VFP) ++ return true; ++#else ++ return false; ++#endif ++ ++#elif GCC_VERSION < 40500 && !defined(__clang__) ++ return false; ++ ++#else ++#if defined(__ARM_PCS_VFP) ++ return true; ++#elif defined(__ARM_PCS) || defined(__SOFTFP__) || defined(__SOFTFP) || \ ++ !defined(__VFP_FP__) ++ return false; ++#else ++#error \ ++ "Your version of compiler does not report the FP ABI compiled for." \ ++ "Please report it on this issue" \ ++ "http://code.google.com/p/v8/issues/detail?id=2140" ++ ++#endif ++#endif ++#undef GCC_VERSION ++} ++ ++#endif // def __arm__ ++#endif ++ ++void OS::Initialize(bool hard_abort, const char* const gc_fake_mmap) { ++ g_hard_abort = hard_abort; ++ g_gc_fake_mmap = gc_fake_mmap; ++} ++ ++int OS::ActivationFrameAlignment() { ++#if V8_TARGET_ARCH_ARM ++ // On EABI ARM targets this is required for fp correctness in the ++ // runtime system. ++ return 8; ++#elif V8_TARGET_ARCH_MIPS ++ return 8; ++#elif V8_TARGET_ARCH_S390 ++ return 8; ++#else ++ // Otherwise we just assume 16 byte alignment, i.e.: ++ // - With gcc 4.4 the tree vectorization optimizer can generate code ++ // that requires 16 byte alignment such as movdqa on x86. ++ // - Mac OS X, PPC and Solaris (64-bit) activation frames must ++ // be 16 byte-aligned; see "Mac OS X ABI Function Call Guide" ++ return 16; ++#endif ++} ++ ++// static ++size_t OS::AllocatePageSize() { ++#if defined(V8_TARGET_OS_MACOSX) && V8_HOST_ARCH_ARM64 ++ return kAppleArmPageSize; ++#else ++ static size_t page_size = static_cast(sysconf(_SC_PAGESIZE)); ++ return page_size; ++#endif ++} ++ ++// static ++size_t OS::CommitPageSize() { ++ // Commit and allocate page size are the same on posix. ++ return OS::AllocatePageSize(); ++} ++ ++// static ++void OS::SetRandomMmapSeed(int64_t seed) { ++ if (seed) { ++ MutexGuard guard(rng_mutex.Pointer()); ++ GetPlatformRandomNumberGenerator()->SetSeed(seed); ++ } ++} ++ ++// static ++void* OS::GetRandomMmapAddr() { ++ uintptr_t raw_addr; ++ { ++ MutexGuard guard(rng_mutex.Pointer()); ++ GetPlatformRandomNumberGenerator()->NextBytes(&raw_addr, sizeof(raw_addr)); ++ } ++#if V8_HOST_ARCH_ARM64 ++#if defined(V8_TARGET_OS_MACOSX) ++ DCHECK_EQ(1 << 14, AllocatePageSize()); ++#endif ++ // Keep the address page-aligned, AArch64 supports 4K, 16K and 64K ++ // configurations. ++ raw_addr = RoundDown(raw_addr, AllocatePageSize()); ++#endif ++#if defined(V8_USE_ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ ++ defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) ++ // If random hint addresses interfere with address ranges hard coded in ++ // sanitizers, bad things happen. This address range is copied from TSAN ++ // source but works with all tools. ++ // See crbug.com/539863. ++ raw_addr &= 0x007fffff0000ULL; ++ raw_addr += 0x7e8000000000ULL; ++#else ++#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 ++ // Currently available CPUs have 48 bits of virtual addressing. Truncate ++ // the hint address to 46 bits to give the kernel a fighting chance of ++ // fulfilling our placement request. ++ raw_addr &= uint64_t{0x3FFFFFFFF000}; ++#elif V8_TARGET_ARCH_PPC64 ++#if V8_OS_AIX ++ // AIX: 64 bits of virtual addressing, but we limit address range to: ++ // a) minimize Segment Lookaside Buffer (SLB) misses and ++ raw_addr &= uint64_t{0x3FFFF000}; ++ // Use extra address space to isolate the mmap regions. ++ raw_addr += uint64_t{0x400000000000}; ++#elif V8_TARGET_BIG_ENDIAN ++ // Big-endian Linux: 42 bits of virtual addressing. ++ raw_addr &= uint64_t{0x03FFFFFFF000}; ++#else ++ // Little-endian Linux: 46 bits of virtual addressing. ++ raw_addr &= uint64_t{0x3FFFFFFF0000}; ++#endif ++#elif V8_TARGET_ARCH_S390X ++ // Linux on Z uses bits 22-32 for Region Indexing, which translates to 42 bits ++ // of virtual addressing. Truncate to 40 bits to allow kernel chance to ++ // fulfill request. ++ raw_addr &= uint64_t{0xFFFFFFF000}; ++#elif V8_TARGET_ARCH_S390 ++ // 31 bits of virtual addressing. Truncate to 29 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= 0x1FFFF000; ++#elif V8_TARGET_ARCH_MIPS64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance ++ // to fulfill request. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#else ++ raw_addr &= 0x3FFFF000; ++ ++#ifdef __sun ++ // For our Solaris/illumos mmap hint, we pick a random address in the bottom ++ // half of the top half of the address space (that is, the third quarter). ++ // Because we do not MAP_FIXED, this will be treated only as a hint -- the ++ // system will not fail to mmap() because something else happens to already ++ // be mapped at our random address. We deliberately set the hint high enough ++ // to get well above the system's break (that is, the heap); Solaris and ++ // illumos will try the hint and if that fails allocate as if there were ++ // no hint at all. The high hint prevents the break from getting hemmed in ++ // at low values, ceding half of the address space to the system heap. ++ raw_addr += 0x80000000; ++#elif V8_OS_AIX ++ // The range 0x30000000 - 0xD0000000 is available on AIX; ++ // choose the upper range. ++ raw_addr += 0x90000000; ++#else ++ // The range 0x20000000 - 0x60000000 is relatively unpopulated across a ++ // variety of ASLR modes (PAE kernel, NX compat mode, etc) and on macos ++ // 10.6 and 10.7. ++ raw_addr += 0x20000000; ++#endif ++#endif ++#endif ++ return reinterpret_cast(raw_addr); ++} ++ ++// TODO(bbudge) Move Cygwin and Fuchsia stuff into platform-specific files. ++#if !V8_OS_CYGWIN && !V8_OS_FUCHSIA ++// static ++void* OS::Allocate(void* hint, size_t size, size_t alignment, ++ MemoryPermission access) { ++ size_t page_size = AllocatePageSize(); ++ DCHECK_EQ(0, size % page_size); ++ DCHECK_EQ(0, alignment % page_size); ++ hint = AlignedAddress(hint, alignment); ++ // Add the maximum misalignment so we are guaranteed an aligned base address. ++ size_t request_size = size + (alignment - page_size); ++ request_size = RoundUp(request_size, OS::AllocatePageSize()); ++ void* result = base::Allocate(hint, request_size, access, PageType::kPrivate); ++ if (result == nullptr) return nullptr; ++ ++ // Unmap memory allocated before the aligned base address. ++ uint8_t* base = static_cast(result); ++ uint8_t* aligned_base = reinterpret_cast( ++ RoundUp(reinterpret_cast(base), alignment)); ++ if (aligned_base != base) { ++ DCHECK_LT(base, aligned_base); ++ size_t prefix_size = static_cast(aligned_base - base); ++ CHECK(Free(base, prefix_size)); ++ request_size -= prefix_size; ++ } ++ // Unmap memory allocated after the potentially unaligned end. ++ if (size != request_size) { ++ DCHECK_LT(size, request_size); ++ size_t suffix_size = request_size - size; ++ CHECK(Free(aligned_base + size, suffix_size)); ++ request_size -= suffix_size; ++ } ++ ++ DCHECK_EQ(size, request_size); ++ return static_cast(aligned_base); ++} ++ ++// static ++void* OS::AllocateShared(size_t size, MemoryPermission access) { ++ DCHECK_EQ(0, size % AllocatePageSize()); ++ return base::Allocate(nullptr, size, access, PageType::kShared); ++} ++ ++// static ++bool OS::Free(void* address, const size_t size) { ++ DCHECK_EQ(0, reinterpret_cast(address) % AllocatePageSize()); ++ DCHECK_EQ(0, size % AllocatePageSize()); ++ return munmap(address, size) == 0; ++} ++ ++// static ++bool OS::Release(void* address, size_t size) { ++ DCHECK_EQ(0, reinterpret_cast(address) % CommitPageSize()); ++ DCHECK_EQ(0, size % CommitPageSize()); ++ return munmap(address, size) == 0; ++} ++ ++// static ++bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { ++ DCHECK_EQ(0, reinterpret_cast(address) % CommitPageSize()); ++ DCHECK_EQ(0, size % CommitPageSize()); ++ ++ int prot = GetProtectionFromMemoryPermission(access); ++ int ret = mprotect(address, size, prot); ++ if (ret == 0 && access == OS::MemoryPermission::kNoAccess) { ++ // This is advisory; ignore errors and continue execution. ++ USE(DiscardSystemPages(address, size)); ++ } ++ ++// For accounting purposes, we want to call MADV_FREE_REUSE on macOS after ++// changing permissions away from OS::MemoryPermission::kNoAccess. Since this ++// state is not kept at this layer, we always call this if access != kNoAccess. ++// The cost is a syscall that effectively no-ops. ++// TODO(erikchen): Fix this to only call MADV_FREE_REUSE when necessary. ++// https://crbug.com/823915 ++#if defined(V8_OS_MACOSX) ++ if (access != OS::MemoryPermission::kNoAccess) ++ madvise(address, size, MADV_FREE_REUSE); ++#endif ++ ++ return ret == 0; ++} ++ ++bool OS::DiscardSystemPages(void* address, size_t size) { ++ DCHECK_EQ(0, reinterpret_cast(address) % CommitPageSize()); ++ DCHECK_EQ(0, size % CommitPageSize()); ++#if defined(V8_OS_MACOSX) ++ // On OSX, MADV_FREE_REUSABLE has comparable behavior to MADV_FREE, but also ++ // marks the pages with the reusable bit, which allows both Activity Monitor ++ // and memory-infra to correctly track the pages. ++ int ret = madvise(address, size, MADV_FREE_REUSABLE); ++#elif defined(_AIX) || defined(V8_OS_SOLARIS) ++ int ret = madvise(reinterpret_cast(address), size, MADV_FREE); ++#else ++ int ret = madvise(address, size, MADV_FREE); ++#endif ++ if (ret != 0 && errno == ENOSYS) ++ return true; // madvise is not available on all systems. ++ if (ret != 0 && errno == EINVAL) { ++// MADV_FREE only works on Linux 4.5+ . If request failed, retry with older ++// MADV_DONTNEED . Note that MADV_FREE being defined at compile time doesn't ++// imply runtime support. ++#if defined(_AIX) || defined(V8_OS_SOLARIS) ++ ret = madvise(reinterpret_cast(address), size, MADV_DONTNEED); ++#else ++ ret = madvise(address, size, MADV_DONTNEED); ++#endif ++ } ++ return ret == 0; ++} ++ ++// static ++bool OS::HasLazyCommits() { ++#if V8_OS_AIX || V8_OS_LINUX || V8_OS_MACOSX ++ return true; ++#else ++ // TODO(bbudge) Return true for all POSIX platforms. ++ return false; ++#endif ++} ++#endif // !V8_OS_CYGWIN && !V8_OS_FUCHSIA ++ ++const char* OS::GetGCFakeMMapFile() { ++ return g_gc_fake_mmap; ++} ++ ++ ++void OS::Sleep(TimeDelta interval) { ++ usleep(static_cast(interval.InMicroseconds())); ++} ++ ++ ++void OS::Abort() { ++ if (g_hard_abort) { ++ V8_IMMEDIATE_CRASH(); ++ } ++ // Redirect to std abort to signal abnormal program termination. ++ abort(); ++} ++ ++ ++void OS::DebugBreak() { ++#if V8_HOST_ARCH_ARM ++ asm("bkpt 0"); ++#elif V8_HOST_ARCH_ARM64 ++ asm("brk 0"); ++#elif V8_HOST_ARCH_MIPS ++ asm("break"); ++#elif V8_HOST_ARCH_MIPS64 ++ asm("break"); ++#elif V8_HOST_ARCH_LOONGARCH64 ++ asm("break 0"); ++#elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 ++ asm("twge 2,2"); ++#elif V8_HOST_ARCH_IA32 ++ asm("int $3"); ++#elif V8_HOST_ARCH_X64 ++ asm("int $3"); ++#elif V8_HOST_ARCH_S390 ++ // Software breakpoint instruction is 0x0001 ++ asm volatile(".word 0x0001"); ++#elif V8_HOST_ARCH_LOONGARCH64 ++ asm("break 0"); ++#else ++#error Unsupported host architecture. ++#endif ++} ++ ++ ++class PosixMemoryMappedFile final : public OS::MemoryMappedFile { ++ public: ++ PosixMemoryMappedFile(FILE* file, void* memory, size_t size) ++ : file_(file), memory_(memory), size_(size) {} ++ ~PosixMemoryMappedFile() final; ++ void* memory() const final { return memory_; } ++ size_t size() const final { return size_; } ++ ++ private: ++ FILE* const file_; ++ void* const memory_; ++ size_t const size_; ++}; ++ ++ ++// static ++OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name, ++ FileMode mode) { ++ const char* fopen_mode = (mode == FileMode::kReadOnly) ? "r" : "r+"; ++ if (FILE* file = fopen(name, fopen_mode)) { ++ if (fseek(file, 0, SEEK_END) == 0) { ++ long size = ftell(file); // NOLINT(runtime/int) ++ if (size == 0) return new PosixMemoryMappedFile(file, nullptr, 0); ++ if (size > 0) { ++ int prot = PROT_READ; ++ int flags = MAP_PRIVATE; ++ if (mode == FileMode::kReadWrite) { ++ prot |= PROT_WRITE; ++ flags = MAP_SHARED; ++ } ++ void* const memory = ++ mmap(OS::GetRandomMmapAddr(), size, prot, flags, fileno(file), 0); ++ if (memory != MAP_FAILED) { ++ return new PosixMemoryMappedFile(file, memory, size); ++ } ++ } ++ } ++ fclose(file); ++ } ++ return nullptr; ++} ++ ++// static ++OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, ++ size_t size, void* initial) { ++ if (FILE* file = fopen(name, "w+")) { ++ if (size == 0) return new PosixMemoryMappedFile(file, nullptr, 0); ++ size_t result = fwrite(initial, 1, size, file); ++ if (result == size && !ferror(file)) { ++ void* memory = mmap(OS::GetRandomMmapAddr(), result, ++ PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); ++ if (memory != MAP_FAILED) { ++ return new PosixMemoryMappedFile(file, memory, result); ++ } ++ } ++ fclose(file); ++ } ++ return nullptr; ++} ++ ++ ++PosixMemoryMappedFile::~PosixMemoryMappedFile() { ++ if (memory_) CHECK(OS::Free(memory_, RoundUp(size_, OS::AllocatePageSize()))); ++ fclose(file_); ++} ++ ++ ++int OS::GetCurrentProcessId() { ++ return static_cast(getpid()); ++} ++ ++ ++int OS::GetCurrentThreadId() { ++#if V8_OS_MACOSX || (V8_OS_ANDROID && defined(__APPLE__)) ++ return static_cast(pthread_mach_thread_np(pthread_self())); ++#elif V8_OS_LINUX ++ return static_cast(syscall(__NR_gettid)); ++#elif V8_OS_ANDROID ++ return static_cast(gettid()); ++#elif V8_OS_AIX ++ return static_cast(thread_self()); ++#elif V8_OS_FUCHSIA ++ return static_cast(zx_thread_self()); ++#elif V8_OS_SOLARIS ++ return static_cast(pthread_self()); ++#else ++ return static_cast(reinterpret_cast(pthread_self())); ++#endif ++} ++ ++void OS::ExitProcess(int exit_code) { ++ // Use _exit instead of exit to avoid races between isolate ++ // threads and static destructors. ++ fflush(stdout); ++ fflush(stderr); ++ _exit(exit_code); ++} ++ ++// ---------------------------------------------------------------------------- ++// POSIX date/time support. ++// ++ ++#if !defined(V8_OS_FUCHSIA) ++int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { ++ struct rusage usage; ++ ++ if (getrusage(RUSAGE_SELF, &usage) < 0) return -1; ++ *secs = static_cast(usage.ru_utime.tv_sec); ++ *usecs = static_cast(usage.ru_utime.tv_usec); ++ return 0; ++} ++#endif ++ ++double OS::TimeCurrentMillis() { ++ return Time::Now().ToJsTime(); ++} ++ ++double PosixTimezoneCache::DaylightSavingsOffset(double time) { ++ if (std::isnan(time)) return std::numeric_limits::quiet_NaN(); ++ time_t tv = static_cast(std::floor(time/msPerSecond)); ++ struct tm tm; ++ struct tm* t = localtime_r(&tv, &tm); ++ if (nullptr == t) return std::numeric_limits::quiet_NaN(); ++ return t->tm_isdst > 0 ? 3600 * msPerSecond : 0; ++} ++ ++ ++int OS::GetLastError() { ++ return errno; ++} ++ ++ ++// ---------------------------------------------------------------------------- ++// POSIX stdio support. ++// ++ ++FILE* OS::FOpen(const char* path, const char* mode) { ++ FILE* file = fopen(path, mode); ++ if (file == nullptr) return nullptr; ++ struct stat file_stat; ++ if (fstat(fileno(file), &file_stat) != 0) { ++ fclose(file); ++ return nullptr; ++ } ++ bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0); ++ if (is_regular_file) return file; ++ fclose(file); ++ return nullptr; ++} ++ ++ ++bool OS::Remove(const char* path) { ++ return (remove(path) == 0); ++} ++ ++char OS::DirectorySeparator() { return '/'; } ++ ++bool OS::isDirectorySeparator(const char ch) { ++ return ch == DirectorySeparator(); ++} ++ ++ ++FILE* OS::OpenTemporaryFile() { ++ return tmpfile(); ++} ++ ++const char* const OS::LogFileOpenMode = "w+"; ++ ++void OS::Print(const char* format, ...) { ++ va_list args; ++ va_start(args, format); ++ VPrint(format, args); ++ va_end(args); ++} ++ ++ ++void OS::VPrint(const char* format, va_list args) { ++#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) ++ __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args); ++#else ++ vprintf(format, args); ++#endif ++} ++ ++ ++void OS::FPrint(FILE* out, const char* format, ...) { ++ va_list args; ++ va_start(args, format); ++ VFPrint(out, format, args); ++ va_end(args); ++} ++ ++ ++void OS::VFPrint(FILE* out, const char* format, va_list args) { ++#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) ++ __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args); ++#else ++ vfprintf(out, format, args); ++#endif ++} ++ ++ ++void OS::PrintError(const char* format, ...) { ++ va_list args; ++ va_start(args, format); ++ VPrintError(format, args); ++ va_end(args); ++} ++ ++ ++void OS::VPrintError(const char* format, va_list args) { ++#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) ++ __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args); ++#else ++ vfprintf(stderr, format, args); ++#endif ++} ++ ++ ++int OS::SNPrintF(char* str, int length, const char* format, ...) { ++ va_list args; ++ va_start(args, format); ++ int result = VSNPrintF(str, length, format, args); ++ va_end(args); ++ return result; ++} ++ ++ ++int OS::VSNPrintF(char* str, ++ int length, ++ const char* format, ++ va_list args) { ++ int n = vsnprintf(str, length, format, args); ++ if (n < 0 || n >= length) { ++ // If the length is zero, the assignment fails. ++ if (length > 0) ++ str[length - 1] = '\0'; ++ return -1; ++ } else { ++ return n; ++ } ++} ++ ++ ++// ---------------------------------------------------------------------------- ++// POSIX string support. ++// ++ ++void OS::StrNCpy(char* dest, int length, const char* src, size_t n) { ++ strncpy(dest, src, n); ++} ++ ++ ++// ---------------------------------------------------------------------------- ++// POSIX thread support. ++// ++ ++class Thread::PlatformData { ++ public: ++ PlatformData() : thread_(kNoThread) {} ++ pthread_t thread_; // Thread handle for pthread. ++ // Synchronizes thread creation ++ Mutex thread_creation_mutex_; ++}; ++ ++Thread::Thread(const Options& options) ++ : data_(new PlatformData), ++ stack_size_(options.stack_size()), ++ start_semaphore_(nullptr) { ++ if (stack_size_ > 0 && static_cast(stack_size_) < PTHREAD_STACK_MIN) { ++ stack_size_ = PTHREAD_STACK_MIN; ++ } ++ set_name(options.name()); ++} ++ ++ ++Thread::~Thread() { ++ delete data_; ++} ++ ++ ++static void SetThreadName(const char* name) { ++#if V8_OS_DRAGONFLYBSD || V8_OS_FREEBSD || V8_OS_OPENBSD ++ pthread_set_name_np(pthread_self(), name); ++#elif V8_OS_NETBSD ++ STATIC_ASSERT(Thread::kMaxThreadNameLength <= PTHREAD_MAX_NAMELEN_NP); ++ pthread_setname_np(pthread_self(), "%s", name); ++#elif V8_OS_MACOSX ++ // pthread_setname_np is only available in 10.6 or later, so test ++ // for it at runtime. ++ int (*dynamic_pthread_setname_np)(const char*); ++ *reinterpret_cast(&dynamic_pthread_setname_np) = ++ dlsym(RTLD_DEFAULT, "pthread_setname_np"); ++ if (dynamic_pthread_setname_np == nullptr) return; ++ ++ // Mac OS X does not expose the length limit of the name, so hardcode it. ++ static const int kMaxNameLength = 63; ++ STATIC_ASSERT(Thread::kMaxThreadNameLength <= kMaxNameLength); ++ dynamic_pthread_setname_np(name); ++#elif defined(PR_SET_NAME) ++ prctl(PR_SET_NAME, ++ reinterpret_cast(name), // NOLINT ++ 0, 0, 0); ++#endif ++} ++ ++ ++static void* ThreadEntry(void* arg) { ++ Thread* thread = reinterpret_cast(arg); ++ // We take the lock here to make sure that pthread_create finished first since ++ // we don't know which thread will run first (the original thread or the new ++ // one). ++ { MutexGuard lock_guard(&thread->data()->thread_creation_mutex_); } ++ SetThreadName(thread->name()); ++ DCHECK_NE(thread->data()->thread_, kNoThread); ++ thread->NotifyStartedAndRun(); ++ return nullptr; ++} ++ ++ ++void Thread::set_name(const char* name) { ++ strncpy(name_, name, sizeof(name_) - 1); ++ name_[sizeof(name_) - 1] = '\0'; ++} ++ ++bool Thread::Start() { ++ int result; ++ pthread_attr_t attr; ++ memset(&attr, 0, sizeof(attr)); ++ result = pthread_attr_init(&attr); ++ if (result != 0) return false; ++ size_t stack_size = stack_size_; ++ if (stack_size == 0) { ++#if V8_OS_MACOSX ++ // Default on Mac OS X is 512kB -- bump up to 1MB ++ stack_size = 1 * 1024 * 1024; ++#elif V8_OS_AIX ++ // Default on AIX is 96kB -- bump up to 2MB ++ stack_size = 2 * 1024 * 1024; ++#endif ++ } ++ if (stack_size > 0) { ++ result = pthread_attr_setstacksize(&attr, stack_size); ++ if (result != 0) return pthread_attr_destroy(&attr), false; ++ } ++ { ++ MutexGuard lock_guard(&data_->thread_creation_mutex_); ++ result = pthread_create(&data_->thread_, &attr, ThreadEntry, this); ++ if (result != 0 || data_->thread_ == kNoThread) { ++ return pthread_attr_destroy(&attr), false; ++ } ++ } ++ result = pthread_attr_destroy(&attr); ++ return result == 0; ++} ++ ++void Thread::Join() { pthread_join(data_->thread_, nullptr); } ++ ++static Thread::LocalStorageKey PthreadKeyToLocalKey(pthread_key_t pthread_key) { ++#if V8_OS_CYGWIN ++ // We need to cast pthread_key_t to Thread::LocalStorageKey in two steps ++ // because pthread_key_t is a pointer type on Cygwin. This will probably not ++ // work on 64-bit platforms, but Cygwin doesn't support 64-bit anyway. ++ STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); ++ intptr_t ptr_key = reinterpret_cast(pthread_key); ++ return static_cast(ptr_key); ++#else ++ return static_cast(pthread_key); ++#endif ++} ++ ++ ++static pthread_key_t LocalKeyToPthreadKey(Thread::LocalStorageKey local_key) { ++#if V8_OS_CYGWIN ++ STATIC_ASSERT(sizeof(Thread::LocalStorageKey) == sizeof(pthread_key_t)); ++ intptr_t ptr_key = static_cast(local_key); ++ return reinterpret_cast(ptr_key); ++#else ++ return static_cast(local_key); ++#endif ++} ++ ++ ++#ifdef V8_FAST_TLS_SUPPORTED ++ ++static std::atomic tls_base_offset_initialized{false}; ++intptr_t kMacTlsBaseOffset = 0; ++ ++// It's safe to do the initialization more that once, but it has to be ++// done at least once. ++static void InitializeTlsBaseOffset() { ++ const size_t kBufferSize = 128; ++ char buffer[kBufferSize]; ++ size_t buffer_size = kBufferSize; ++ int ctl_name[] = { CTL_KERN , KERN_OSRELEASE }; ++ if (sysctl(ctl_name, 2, buffer, &buffer_size, nullptr, 0) != 0) { ++ FATAL("V8 failed to get kernel version"); ++ } ++ // The buffer now contains a string of the form XX.YY.ZZ, where ++ // XX is the major kernel version component. ++ // Make sure the buffer is 0-terminated. ++ buffer[kBufferSize - 1] = '\0'; ++ char* period_pos = strchr(buffer, '.'); ++ *period_pos = '\0'; ++ int kernel_version_major = ++ static_cast(strtol(buffer, nullptr, 10)); // NOLINT ++ // The constants below are taken from pthreads.s from the XNU kernel ++ // sources archive at www.opensource.apple.com. ++ if (kernel_version_major < 11) { ++ // 8.x.x (Tiger), 9.x.x (Leopard), 10.x.x (Snow Leopard) have the ++ // same offsets. ++#if V8_HOST_ARCH_IA32 ++ kMacTlsBaseOffset = 0x48; ++#else ++ kMacTlsBaseOffset = 0x60; ++#endif ++ } else { ++ // 11.x.x (Lion) changed the offset. ++ kMacTlsBaseOffset = 0; ++ } ++ ++ tls_base_offset_initialized.store(true, std::memory_order_release); ++} ++ ++ ++static void CheckFastTls(Thread::LocalStorageKey key) { ++ void* expected = reinterpret_cast(0x1234CAFE); ++ Thread::SetThreadLocal(key, expected); ++ void* actual = Thread::GetExistingThreadLocal(key); ++ if (expected != actual) { ++ FATAL("V8 failed to initialize fast TLS on current kernel"); ++ } ++ Thread::SetThreadLocal(key, nullptr); ++} ++ ++#endif // V8_FAST_TLS_SUPPORTED ++ ++ ++Thread::LocalStorageKey Thread::CreateThreadLocalKey() { ++#ifdef V8_FAST_TLS_SUPPORTED ++ bool check_fast_tls = false; ++ if (!tls_base_offset_initialized.load(std::memory_order_acquire)) { ++ check_fast_tls = true; ++ InitializeTlsBaseOffset(); ++ } ++#endif ++ pthread_key_t key; ++ int result = pthread_key_create(&key, nullptr); ++ DCHECK_EQ(0, result); ++ USE(result); ++ LocalStorageKey local_key = PthreadKeyToLocalKey(key); ++#ifdef V8_FAST_TLS_SUPPORTED ++ // If we just initialized fast TLS support, make sure it works. ++ if (check_fast_tls) CheckFastTls(local_key); ++#endif ++ return local_key; ++} ++ ++ ++void Thread::DeleteThreadLocalKey(LocalStorageKey key) { ++ pthread_key_t pthread_key = LocalKeyToPthreadKey(key); ++ int result = pthread_key_delete(pthread_key); ++ DCHECK_EQ(0, result); ++ USE(result); ++} ++ ++ ++void* Thread::GetThreadLocal(LocalStorageKey key) { ++ pthread_key_t pthread_key = LocalKeyToPthreadKey(key); ++ return pthread_getspecific(pthread_key); ++} ++ ++ ++void Thread::SetThreadLocal(LocalStorageKey key, void* value) { ++ pthread_key_t pthread_key = LocalKeyToPthreadKey(key); ++ int result = pthread_setspecific(pthread_key, value); ++ DCHECK_EQ(0, result); ++ USE(result); ++} ++ ++// pthread_getattr_np used below is non portable (hence the _np suffix). We ++// keep this version in POSIX as most Linux-compatible derivatives will ++// support it. MacOS and FreeBSD are different here. ++#if !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && !defined(_AIX) && \ ++ !defined(V8_OS_SOLARIS) ++ ++// static ++void* Stack::GetStackStart() { ++ pthread_attr_t attr; ++ int error = pthread_getattr_np(pthread_self(), &attr); ++ if (!error) { ++ void* base; ++ size_t size; ++ error = pthread_attr_getstack(&attr, &base, &size); ++ CHECK(!error); ++ pthread_attr_destroy(&attr); ++ return reinterpret_cast(base) + size; ++ } ++ ++#if defined(V8_LIBC_GLIBC) ++ // pthread_getattr_np can fail for the main thread. In this case ++ // just like NaCl we rely on the __libc_stack_end to give us ++ // the start of the stack. ++ // See https://code.google.com/p/nativeclient/issues/detail?id=3431. ++ return __libc_stack_end; ++#endif // !defined(V8_LIBC_GLIBC) ++ return nullptr; ++} ++ ++#endif // !defined(V8_OS_FREEBSD) && !defined(V8_OS_MACOSX) && ++ // !defined(_AIX) && !defined(V8_OS_SOLARIS) ++ ++// static ++void* Stack::GetCurrentStackPosition() { return __builtin_frame_address(0); } ++ ++#undef LOG_TAG ++#undef MAP_ANONYMOUS ++#undef MADV_FREE ++ ++} // namespace base ++} // namespace v8 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc.rej +@@ -0,0 +1,20 @@ ++--- src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc +++++ src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc ++@@ -507,6 +511,8 @@ void OS::DebugBreak() { ++ asm("break"); ++ #elif V8_HOST_ARCH_MIPS64 ++ asm("break"); +++#elif V8_HOST_ARCH_LOONGARCH64 +++ asm("break 0"); ++ #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 ++ asm("twge 2,2"); ++ #elif V8_HOST_ARCH_IA32 ++@@ -516,6 +522,8 @@ void OS::DebugBreak() { ++ #elif V8_HOST_ARCH_S390 ++ // Software breakpoint instruction is 0x0001 ++ asm volatile(".word 0x0001"); +++#elif V8_HOST_ARCH_LOONGARCH64 +++ asm("break 0"); ++ #else ++ #error Unsupported host architecture. ++ #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/builtins/builtins.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/builtins/builtins.cc +@@ -490,7 +490,7 @@ bool Builtins::CodeObjectIsExecutable(in + case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit: + return true; + default: +-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + // TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE + // caused MIPS platform to crash, and we need some time to handle it. Now + // disable this change temporarily on MIPS platform. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/builtins/builtins.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/builtins/builtins.cc +++++ src/3rdparty/chromium/v8/src/builtins/builtins.cc ++@@ -490,7 +490,7 @@ bool Builtins::CodeObjectIsExecutable(int builtin_index) { ++ case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit: ++ return true; ++ default: ++-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 ++ // TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE ++ // caused MIPS platform to crash, and we need some time to handle it. Now ++ // disable this change temporarily on MIPS platform. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/builtins/loongarch64/builtins-loongarch64.cc +@@ -0,0 +1,3549 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/api/api-arguments.h" ++#include "src/codegen/code-factory.h" ++#include "src/debug/debug.h" ++#include "src/deoptimizer/deoptimizer.h" ++#include "src/execution/frame-constants.h" ++#include "src/execution/frames.h" ++#include "src/logging/counters.h" ++// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/macro-assembler-inl.h" ++#include "src/codegen/register-configuration.h" ++#include "src/heap/heap-inl.h" ++#include "src/objects/cell.h" ++#include "src/objects/foreign.h" ++#include "src/objects/heap-number.h" ++#include "src/objects/js-generator.h" ++#include "src/objects/objects-inl.h" ++#include "src/objects/smi.h" ++#include "src/runtime/runtime.h" ++#include "src/wasm/wasm-linkage.h" ++#include "src/wasm/wasm-objects.h" ++ ++namespace v8 { ++namespace internal { ++ ++#define __ ACCESS_MASM(masm) ++ ++void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { ++ __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), ++ RelocInfo::CODE_TARGET); ++} ++ ++static void GenerateTailCallToReturnedCode(MacroAssembler* masm, ++ Runtime::FunctionId function_id) { ++ // ----------- S t a t e ------------- ++ // -- a0 : actual argument count ++ // -- a1 : target function (preserved for callee) ++ // -- a3 : new target (preserved for callee) ++ // ----------------------------------- ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ // Push a copy of the target function, the new target and the actual ++ // argument count. ++ // Push function as parameter to the runtime call. ++ __ SmiTag(kJavaScriptCallArgCountRegister); ++ __ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister, ++ kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister); ++ ++ __ CallRuntime(function_id, 1); ++ __ Add_d(a2, a0, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ // Restore target function, new target and actual argument count. ++ __ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister, ++ kJavaScriptCallArgCountRegister); ++ __ SmiUntag(kJavaScriptCallArgCountRegister); ++ } ++ ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Jump(a2); ++} ++ ++namespace { ++ ++enum StackLimitKind { kInterruptStackLimit, kRealStackLimit }; ++ ++void LoadStackLimit(MacroAssembler* masm, Register destination, ++ StackLimitKind kind) { ++ DCHECK(masm->root_array_available()); ++ Isolate* isolate = masm->isolate(); ++ ExternalReference limit = ++ kind == StackLimitKind::kRealStackLimit ++ ? ExternalReference::address_of_real_jslimit(isolate) ++ : ExternalReference::address_of_jslimit(isolate); ++ DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); ++ ++ intptr_t offset = ++ TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); ++ CHECK(is_int32(offset)); ++ __ Ld_d(destination, MemOperand(kRootRegister, static_cast(offset))); ++} ++ ++void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : number of arguments ++ // -- a1 : constructor function ++ // -- a3 : new target ++ // -- cp : context ++ // -- ra : return address ++ // -- sp[...]: constructor arguments ++ // ----------------------------------- ++ ++ // Enter a construct frame. ++ { ++ FrameScope scope(masm, StackFrame::CONSTRUCT); ++ ++ // Preserve the incoming parameters on the stack. ++ __ SmiTag(a0); ++ __ Push(cp, a0); ++ __ SmiUntag(a0); ++ ++#ifdef V8_REVERSE_JSARGS ++ // Set up pointer to last argument (skip receiver). ++ __ Add_d( ++ t2, fp, ++ Operand(StandardFrameConstants::kCallerSPOffset + kSystemPointerSize)); ++ // Copy arguments and receiver to the expression stack. ++ __ PushArray(t2, a0, t3, t0); ++ // The receiver for the builtin/api call. ++ __ PushRoot(RootIndex::kTheHoleValue); ++#else ++ // The receiver for the builtin/api call. ++ __ PushRoot(RootIndex::kTheHoleValue); ++ // Set up pointer to last argument. ++ __ Add_d(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); ++ ++ // Copy arguments and receiver to the expression stack. ++ __ PushArray(t2, a0, t3, t0); ++#endif ++ ++ // Call the function. ++ // a0: number of arguments (untagged) ++ // a1: constructor function ++ // a3: new target ++ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); ++ ++ // Restore context from the frame. ++ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ // Restore smi-tagged arguments count from the frame. ++ __ Ld_d(t3, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ // Leave construct frame. ++ } ++ ++ // Remove caller arguments from the stack and return. ++ __ SmiScale(t3, t3, kPointerSizeLog2); ++ __ Add_d(sp, sp, t3); ++ __ Add_d(sp, sp, kPointerSize); ++ __ Ret(); ++} ++ ++static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, ++ Register scratch1, Register scratch2, ++ Label* stack_overflow) { ++ // Check the stack for overflow. We are not trying to catch ++ // interruptions (e.g. debug break and preemption) here, so the "real stack ++ // limit" is checked. ++ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); ++ // Make scratch1 the space we have left. The stack might already be overflowed ++ // here which will cause scratch1 to become negative. ++ __ sub_d(scratch1, sp, scratch1); ++ // Check if the arguments will overflow the stack. ++ __ slli_d(scratch2, num_args, kPointerSizeLog2); ++ // Signed comparison. ++ __ Branch(stack_overflow, le, scratch1, Operand(scratch2)); ++} ++ ++} // namespace ++ ++// The construct stub for ES5 constructor functions and ES6 class constructors. ++void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0: number of arguments (untagged) ++ // -- a1: constructor function ++ // -- a3: new target ++ // -- cp: context ++ // -- ra: return address ++ // -- sp[...]: constructor arguments ++ // ----------------------------------- ++ ++ // Enter a construct frame. ++ { ++ FrameScope scope(masm, StackFrame::CONSTRUCT); ++ Label post_instantiation_deopt_entry, not_create_implicit_receiver; ++ ++ // Preserve the incoming parameters on the stack. ++ __ SmiTag(a0); ++ __ Push(cp, a0, a1); ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ Push(a3); ++ ++ // ----------- S t a t e ------------- ++ // -- sp[0*kPointerSize]: new target ++ // -- sp[1*kPointerSize]: padding ++ // -- a1 and sp[2*kPointerSize]: constructor function ++ // -- sp[3*kPointerSize]: number of arguments (tagged) ++ // -- sp[4*kPointerSize]: context ++ // ----------------------------------- ++ ++ __ Ld_d(t2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_wu(t2, FieldMemOperand(t2, SharedFunctionInfo::kFlagsOffset)); ++ __ DecodeField(t2); ++ __ JumpIfIsInRange(t2, kDefaultDerivedConstructor, kDerivedConstructor, ++ ¬_create_implicit_receiver); ++ ++ // If not derived class constructor: Allocate the new receiver object. ++ __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1, ++ t2, t3); ++ __ Call(BUILTIN_CODE(masm->isolate(), FastNewObject), ++ RelocInfo::CODE_TARGET); ++ __ Branch(&post_instantiation_deopt_entry); ++ ++ // Else: use TheHoleValue as receiver for constructor call ++ __ bind(¬_create_implicit_receiver); ++ __ LoadRoot(a0, RootIndex::kTheHoleValue); ++ ++ // ----------- S t a t e ------------- ++ // -- a0: receiver ++ // -- Slot 4 / sp[0*kPointerSize]: new target ++ // -- Slot 3 / sp[1*kPointerSize]: padding ++ // -- Slot 2 / sp[2*kPointerSize]: constructor function ++ // -- Slot 1 / sp[3*kPointerSize]: number of arguments (tagged) ++ // -- Slot 0 / sp[4*kPointerSize]: context ++ // ----------------------------------- ++ // Deoptimizer enters here. ++ masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( ++ masm->pc_offset()); ++ __ bind(&post_instantiation_deopt_entry); ++ ++ // Restore new target. ++ __ Pop(a3); ++ ++#ifdef V8_REVERSE_JSARGS ++ // Push the allocated receiver to the stack. ++ __ Push(a0); ++ ++ // We need two copies because we may have to return the original one ++ // and the calling conventions dictate that the called function pops the ++ // receiver. The second copy is pushed after the arguments, we saved in a6 ++ // since a0 will store the return value of callRuntime. ++ __ mov(a6, a0); ++ ++ // Set up pointer to last argument. ++ __ Add_d( ++ t2, fp, ++ Operand(StandardFrameConstants::kCallerSPOffset + kSystemPointerSize)); ++#else ++ // Push the allocated receiver to the stack. We need two copies ++ // because we may have to return the original one and the calling ++ // conventions dictate that the called function pops the receiver. ++ __ Push(a0, a0); ++ ++ // Set up pointer to last argument. ++ __ Add_d(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); ++#endif ++ ++ // ----------- S t a t e ------------- ++ // -- r3: new target ++ // -- sp[0*kPointerSize]: implicit receiver ++ // -- sp[1*kPointerSize]: implicit receiver ++ // -- sp[2*kPointerSize]: padding ++ // -- sp[3*kPointerSize]: constructor function ++ // -- sp[4*kPointerSize]: number of arguments (tagged) ++ // -- sp[5*kPointerSize]: context ++ // ----------------------------------- ++ ++ // Restore constructor function and argument count. ++ __ Ld_d(a1, MemOperand(fp, ConstructFrameConstants::kConstructorOffset)); ++ __ Ld_d(a0, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ __ SmiUntag(a0); ++ ++ Label enough_stack_space, stack_overflow; ++ Generate_StackOverflowCheck(masm, a0, t0, t1, &stack_overflow); ++ __ Branch(&enough_stack_space); ++ ++ __ bind(&stack_overflow); ++ // Restore the context from the frame. ++ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ ++ __ bind(&enough_stack_space); ++ ++ // Copy arguments and receiver to the expression stack. ++ __ PushArray(t2, a0, t0, t1); ++#ifdef V8_REVERSE_JSARGS ++ // We need two copies because we may have to return the original one ++ // and the calling conventions dictate that the called function pops the ++ // receiver. The second copy is pushed after the arguments, ++ __ Push(a6); ++#endif ++ ++ // Call the function. ++ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); ++ ++ // ----------- S t a t e ------------- ++ // -- a0: constructor result ++ // -- sp[0*kPointerSize]: implicit receiver ++ // -- sp[1*kPointerSize]: padding ++ // -- sp[2*kPointerSize]: constructor function ++ // -- sp[3*kPointerSize]: number of arguments ++ // -- sp[4*kPointerSize]: context ++ // ----------------------------------- ++ ++ // Store offset of return address for deoptimizer. ++ masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( ++ masm->pc_offset()); ++ ++ // Restore the context from the frame. ++ __ Ld_d(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ ++ // If the result is an object (in the ECMA sense), we should get rid ++ // of the receiver and use the result; see ECMA-262 section 13.2.2-7 ++ // on page 74. ++ Label use_receiver, do_throw, leave_frame; ++ ++ // If the result is undefined, we jump out to using the implicit receiver. ++ __ JumpIfRoot(a0, RootIndex::kUndefinedValue, &use_receiver); ++ ++ // Otherwise we do a smi check and fall through to check if the return value ++ // is a valid receiver. ++ ++ // If the result is a smi, it is *not* an object in the ECMA sense. ++ __ JumpIfSmi(a0, &use_receiver); ++ ++ // If the type of the result (stored in its map) is less than ++ // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. ++ __ GetObjectType(a0, t2, t2); ++ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); ++ __ Branch(&leave_frame, greater_equal, t2, Operand(FIRST_JS_RECEIVER_TYPE)); ++ __ Branch(&use_receiver); ++ ++ __ bind(&do_throw); ++ __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); ++ ++ // Throw away the result of the constructor invocation and use the ++ // on-stack receiver as the result. ++ __ bind(&use_receiver); ++ __ Ld_d(a0, MemOperand(sp, 0 * kPointerSize)); ++ __ JumpIfRoot(a0, RootIndex::kTheHoleValue, &do_throw); ++ ++ __ bind(&leave_frame); ++ // Restore smi-tagged arguments count from the frame. ++ __ Ld_d(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ // Leave construct frame. ++ } ++ // Remove caller arguments from the stack and return. ++ __ SmiScale(a4, a1, kPointerSizeLog2); ++ __ Add_d(sp, sp, a4); ++ __ Add_d(sp, sp, kPointerSize); ++ __ Ret(); ++} ++ ++void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { ++ Generate_JSBuiltinsConstructStubHelper(masm); ++} ++ ++static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, ++ Register sfi_data, ++ Register scratch1) { ++ Label done; ++ ++ __ GetObjectType(sfi_data, scratch1, scratch1); ++ __ Branch(&done, ne, scratch1, Operand(INTERPRETER_DATA_TYPE)); ++ __ Ld_d(sfi_data, ++ FieldMemOperand(sfi_data, InterpreterData::kBytecodeArrayOffset)); ++ ++ __ bind(&done); ++} ++ ++// static ++void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the value to pass to the generator ++ // -- a1 : the JSGeneratorObject to resume ++ // -- ra : return address ++ // ----------------------------------- ++ __ AssertGeneratorObject(a1); ++ ++ // Store input value into generator object. ++ __ St_d(a0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); ++ __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, a0, a3, ++ kRAHasNotBeenSaved, kDontSaveFPRegs); ++ ++ // Load suspended function and context. ++ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Ld_d(cp, FieldMemOperand(a4, JSFunction::kContextOffset)); ++ ++ // Flood function if we are stepping. ++ Label prepare_step_in_if_stepping, prepare_step_in_suspended_generator; ++ Label stepping_prepared; ++ ExternalReference debug_hook = ++ ExternalReference::debug_hook_on_function_call_address(masm->isolate()); ++ __ li(a5, debug_hook); ++ __ Ld_b(a5, MemOperand(a5, 0)); ++ __ Branch(&prepare_step_in_if_stepping, ne, a5, Operand(zero_reg)); ++ ++ // Flood function if we need to continue stepping in the suspended generator. ++ ExternalReference debug_suspended_generator = ++ ExternalReference::debug_suspended_generator_address(masm->isolate()); ++ __ li(a5, debug_suspended_generator); ++ __ Ld_d(a5, MemOperand(a5, 0)); ++ __ Branch(&prepare_step_in_suspended_generator, eq, a1, Operand(a5)); ++ __ bind(&stepping_prepared); ++ ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ Label stack_overflow; ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&stack_overflow, lo, sp, Operand(kScratchReg)); ++ ++#ifndef V8_REVERSE_JSARGS ++ // Push receiver. ++ __ Ld_d(a5, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); ++ __ Push(a5); ++#endif ++ ++ // ----------- S t a t e ------------- ++ // -- a1 : the JSGeneratorObject to resume ++ // -- a4 : generator function ++ // -- cp : generator context ++ // -- ra : return address ++ // -- sp[0] : generator receiver ++ // ----------------------------------- ++ ++ // Push holes for arguments to generator function. Since the parser forced ++ // context allocation for any variables in generators, the actual argument ++ // values have already been copied into the context and these dummy values ++ // will never be used. ++ __ Ld_d(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_hu( ++ a3, FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ Ld_d(t1, FieldMemOperand( ++ a1, JSGeneratorObject::kParametersAndRegistersOffset)); ++ { ++#ifdef V8_REVERSE_JSARGS ++ Label done_loop, loop; ++ __ bind(&loop); ++ __ Sub_d(a3, a3, Operand(1)); ++ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); ++ __ Alsl_d(kScratchReg, a3, t1, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); ++ __ Push(kScratchReg); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ // Push receiver. ++ __ Ld_d(kScratchReg, ++ FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); ++ __ Push(kScratchReg); ++#else ++ Label done_loop, loop; ++ __ Move(t2, zero_reg); ++ __ bind(&loop); ++ __ Sub_d(a3, a3, Operand(1)); ++ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); ++ __ Alsl_d(kScratchReg, t2, t1, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); ++ __ Push(kScratchReg); ++ __ Add_d(t2, t2, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++#endif ++ } ++ ++ // Underlying function needs to have bytecode available. ++ if (FLAG_debug_code) { ++ __ Ld_d(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_d(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); ++ GetSharedFunctionInfoBytecode(masm, a3, t5); ++ __ GetObjectType(a3, a3, a3); ++ __ Assert(eq, AbortReason::kMissingBytecodeArray, a3, ++ Operand(BYTECODE_ARRAY_TYPE)); ++ } ++ ++ // Resume (Ignition/TurboFan) generator object. ++ { ++ __ Ld_d(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_hu(a0, FieldMemOperand( ++ a0, SharedFunctionInfo::kFormalParameterCountOffset)); ++ // We abuse new.target both to indicate that this is a resume call and to ++ // pass in the generator object. In ordinary calls, new.target is always ++ // undefined because generator functions are non-constructable. ++ __ Move(a3, a1); ++ __ Move(a1, a4); ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ } ++ ++ __ bind(&prepare_step_in_if_stepping); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1, a4); ++ // Push hole as receiver since we do not use it for stepping. ++ __ PushRoot(RootIndex::kTheHoleValue); ++ __ CallRuntime(Runtime::kDebugOnFunctionCall); ++ __ Pop(a1); ++ } ++ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Branch(&stepping_prepared); ++ ++ __ bind(&prepare_step_in_suspended_generator); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kDebugPrepareStepInSuspendedGenerator); ++ __ Pop(a1); ++ } ++ __ Ld_d(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Branch(&stepping_prepared); ++ ++ __ bind(&stack_overflow); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ __ break_(0xCC); // This should be unreachable. ++ } ++} ++ ++void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowConstructedNonConstructable); ++} ++ ++// Clobbers scratch1 and scratch2; preserves all other registers. ++static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, ++ Register scratch1, Register scratch2) { ++ // Check the stack for overflow. We are not trying to catch ++ // interruptions (e.g. debug break and preemption) here, so the "real stack ++ // limit" is checked. ++ Label okay; ++ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); ++ // Make a2 the space we have left. The stack might already be overflowed ++ // here which will cause r2 to become negative. ++ __ sub_d(scratch1, sp, scratch1); ++ // Check if the arguments will overflow the stack. ++ __ slli_d(scratch2, argc, kPointerSizeLog2); ++ __ Branch(&okay, gt, scratch1, Operand(scratch2)); // Signed comparison. ++ ++ // Out of stack space. ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ ++ __ bind(&okay); ++} ++ ++namespace { ++ ++// Called with the native C calling convention. The corresponding function ++// signature is either: ++// ++// using JSEntryFunction = GeneratedCode; ++// or ++// using JSEntryFunction = GeneratedCode; ++void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ++ Builtins::Name entry_trampoline) { ++ Label invoke, handler_entry, exit; ++ ++ { ++ NoRootArrayScope no_root_array(masm); ++ ++ // TODO(plind): unify the ABI description here. ++ // Registers: ++ // either ++ // a0: root register value ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a0: root register value ++ // a1: microtask_queue ++ // ++ // Stack: ++ // 0 arg slots on mips64 (4 args slots on mips) ++ ++ // Save callee saved registers on the stack. ++ __ MultiPush(kCalleeSaved | ra.bit()); ++ ++ // Save callee-saved FPU registers. ++ __ MultiPushFPU(kCalleeSavedFPU); ++ // Set up the reserved register for 0.0. ++ __ Move(kDoubleRegZero, 0.0); ++ ++ // Initialize the root register. ++ // C calling convention. The first argument is passed in a0. ++ __ mov(kRootRegister, a0); ++ } ++ ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ ++ // We build an EntryFrame. ++ __ li(s1, Operand(-1)); // Push a bad frame pointer to fail if it is used. ++ __ li(s2, Operand(StackFrame::TypeToMarker(type))); ++ __ li(s3, Operand(StackFrame::TypeToMarker(type))); ++ ExternalReference c_entry_fp = ExternalReference::Create( ++ IsolateAddressId::kCEntryFPAddress, masm->isolate()); ++ __ li(s4, c_entry_fp); ++ __ Ld_d(s4, MemOperand(s4, 0)); ++ __ Push(s1, s2, s3, s4); ++ // Set up frame pointer for the frame to be pushed. ++ __ addi_d(fp, sp, -EntryFrameConstants::kCallerFPOffset); ++ ++ // Registers: ++ // either ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a1: microtask_queue ++ // ++ // Stack: ++ // caller fp | ++ // function slot | entry frame ++ // context slot | ++ // bad fp (0xFF...F) | ++ // callee saved registers + ra ++ // [ O32: 4 args slots] ++ // args ++ ++ // If this is the outermost JS call, set js_entry_sp value. ++ Label non_outermost_js; ++ ExternalReference js_entry_sp = ExternalReference::Create( ++ IsolateAddressId::kJSEntrySPAddress, masm->isolate()); ++ __ li(s1, js_entry_sp); ++ __ Ld_d(s2, MemOperand(s1, 0)); ++ __ Branch(&non_outermost_js, ne, s2, Operand(zero_reg)); ++ __ St_d(fp, MemOperand(s1, 0)); ++ __ li(s3, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); ++ Label cont; ++ __ b(&cont); ++ __ nop(); // Branch delay slot nop. ++ __ bind(&non_outermost_js); ++ __ li(s3, Operand(StackFrame::INNER_JSENTRY_FRAME)); ++ __ bind(&cont); ++ __ push(s3); ++ ++ // Jump to a faked try block that does the invoke, with a faked catch ++ // block that sets the pending exception. ++ __ jmp(&invoke); ++ __ bind(&handler_entry); ++ ++ // Store the current pc as the handler offset. It's used later to create the ++ // handler table. ++ masm->isolate()->builtins()->SetJSEntryHandlerOffset(handler_entry.pos()); ++ ++ // Caught exception: Store result (exception) in the pending exception ++ // field in the JSEnv and return a failure sentinel. Coming in here the ++ // fp will be invalid because the PushStackHandler below sets it to 0 to ++ // signal the existence of the JSEntry frame. ++ __ li(s1, ExternalReference::Create( ++ IsolateAddressId::kPendingExceptionAddress, masm->isolate())); ++ __ St_d(a0, ++ MemOperand(s1, 0)); // We come back from 'invoke'. result is in a0. ++ __ LoadRoot(a0, RootIndex::kException); ++ __ b(&exit); // b exposes branch delay slot. ++ __ nop(); // Branch delay slot nop. ++ ++ // Invoke: Link this frame into the handler chain. ++ __ bind(&invoke); ++ __ PushStackHandler(); ++ // If an exception not caught by another handler occurs, this handler ++ // returns control to the code after the bal(&invoke) above, which ++ // restores all kCalleeSaved registers (including cp and fp) to their ++ // saved values before returning a failure to C. ++ // ++ // Registers: ++ // either ++ // a0: root register value ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a0: root register value ++ // a1: microtask_queue ++ // ++ // Stack: ++ // handler frame ++ // entry frame ++ // callee saved registers + ra ++ // [ O32: 4 args slots] ++ // args ++ // ++ // Invoke the function by calling through JS entry trampoline builtin and ++ // pop the faked function when we return. ++ ++ Handle trampoline_code = ++ masm->isolate()->builtins()->builtin_handle(entry_trampoline); ++ __ Call(trampoline_code, RelocInfo::CODE_TARGET); ++ ++ // Unlink this frame from the handler chain. ++ __ PopStackHandler(); ++ ++ __ bind(&exit); // a0 holds result ++ // Check if the current stack frame is marked as the outermost JS frame. ++ Label non_outermost_js_2; ++ __ pop(a5); ++ __ Branch(&non_outermost_js_2, ne, a5, ++ Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); ++ __ li(a5, js_entry_sp); ++ __ St_d(zero_reg, MemOperand(a5, 0)); ++ __ bind(&non_outermost_js_2); ++ ++ // Restore the top frame descriptors from the stack. ++ __ pop(a5); ++ __ li(a4, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, ++ masm->isolate())); ++ __ St_d(a5, MemOperand(a4, 0)); ++ ++ // Reset the stack to the callee saved registers. ++ __ addi_d(sp, sp, -EntryFrameConstants::kCallerFPOffset); ++ ++ // Restore callee-saved fpu registers. ++ __ MultiPopFPU(kCalleeSavedFPU); ++ ++ // Restore callee saved registers from the stack. ++ __ MultiPop(kCalleeSaved | ra.bit()); ++ // Return. ++ __ Jump(ra); ++} ++ ++} // namespace ++ ++void Builtins::Generate_JSEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::ENTRY, ++ Builtins::kJSEntryTrampoline); ++} ++ ++void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::CONSTRUCT_ENTRY, ++ Builtins::kJSConstructEntryTrampoline); ++} ++ ++void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::ENTRY, ++ Builtins::kRunMicrotasksTrampoline); ++} ++ ++static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ++ bool is_construct) { ++ // ----------- S t a t e ------------- ++ // -- a1: new.target ++ // -- a2: function ++ // -- a3: receiver_pointer ++ // -- a4: argc ++ // -- a5: argv ++ // ----------------------------------- ++ ++ // Enter an internal frame. ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ ++ // Setup the context (we need to use the caller context from the isolate). ++ ExternalReference context_address = ExternalReference::Create( ++ IsolateAddressId::kContextAddress, masm->isolate()); ++ __ li(cp, context_address); ++ __ Ld_d(cp, MemOperand(cp, 0)); ++ ++ // Push the function and the receiver onto the stack. ++ __ Push(a2); ++ ++ // Check if we have enough stack space to push all arguments. ++ __ addi_d(a6, a4, 1); ++ Generate_CheckStackOverflow(masm, a6, a0, s2); ++ ++ // Copy arguments to the stack in a loop. ++ // a4: argc ++ // a5: argv, i.e. points to first arg ++#ifdef V8_REVERSE_JSARGS ++ Label loop, entry; ++ __ Alsl_d(s1, a4, a5, kPointerSizeLog2, t7); ++ __ b(&entry); ++ // s1 points past last arg. ++ __ bind(&loop); ++ __ addi_d(s1, s1, -kPointerSize); ++ __ Ld_d(s2, MemOperand(s1, 0)); // Read next parameter. ++ __ Ld_d(s2, MemOperand(s2, 0)); // Dereference handle. ++ __ push(s2); // Push parameter. ++ __ bind(&entry); ++ __ Branch(&loop, ne, a5, Operand(s1)); ++ ++ // Push the receive. ++ __ Push(a3); ++#else ++ // Push the receive. ++ __ Push(a3); ++ ++ Label loop, entry; ++ __ Alsl_d(s1, a4, a5, kPointerSizeLog2, t7); ++ __ b(&entry); ++ // s1 points past last arg. ++ __ bind(&loop); ++ __ Ld_d(s2, MemOperand(a5, 0)); // Read next parameter. ++ __ addi_d(a5, a5, kPointerSize); ++ __ Ld_d(s2, MemOperand(s2, 0)); // Dereference handle. ++ __ push(s2); // Push parameter. ++ __ bind(&entry); ++ __ Branch(&loop, ne, a5, Operand(s1)); ++ ++#endif ++ ++ // a0: argc ++ // a1: function ++ // a3: new.target ++ __ mov(a3, a1); ++ __ mov(a1, a2); ++ __ mov(a0, a4); ++ ++ // Initialize all JavaScript callee-saved registers, since they will be seen ++ // by the garbage collector as part of handlers. ++ __ LoadRoot(a4, RootIndex::kUndefinedValue); ++ __ mov(a5, a4); ++ __ mov(s1, a4); ++ __ mov(s2, a4); ++ __ mov(s3, a4); ++ __ mov(s4, a4); ++ __ mov(s5, a4); ++ // s6 holds the root address. Do not clobber. ++ // s7 is cp. Do not init. ++ ++ // Invoke the code. ++ Handle builtin = is_construct ++ ? BUILTIN_CODE(masm->isolate(), Construct) ++ : masm->isolate()->builtins()->Call(); ++ __ Call(builtin, RelocInfo::CODE_TARGET); ++ ++ // Leave internal frame. ++ } ++ __ Jump(ra); ++} ++ ++void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { ++ Generate_JSEntryTrampolineHelper(masm, false); ++} ++ ++void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ++ Generate_JSEntryTrampolineHelper(masm, true); ++} ++ ++void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) { ++ // a1: microtask_queue ++ __ mov(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1); ++ __ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET); ++} ++ ++static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm, ++ Register optimized_code, ++ Register closure, ++ Register scratch1, ++ Register scratch2) { ++ // Store code entry in the closure. ++ __ St_d(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset)); ++ __ mov(scratch1, optimized_code); // Write barrier clobbers scratch1 below. ++ __ RecordWriteField(closure, JSFunction::kCodeOffset, scratch1, scratch2, ++ kRAHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, ++ OMIT_SMI_CHECK); ++} ++ ++static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { ++ Register args_count = scratch; ++ ++ // Get the arguments + receiver count. ++ __ Ld_d(args_count, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Ld_w(t0, FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); ++ ++ // Leave the frame (also dropping the register file). ++ __ LeaveFrame(StackFrame::INTERPRETED); ++ ++ // Drop receiver + arguments. ++ __ Add_d(sp, sp, args_count); ++} ++ ++// Tail-call |function_id| if |smi_entry| == |marker| ++static void TailCallRuntimeIfMarkerEquals(MacroAssembler* masm, ++ Register smi_entry, ++ OptimizationMarker marker, ++ Runtime::FunctionId function_id) { ++ Label no_match; ++ __ Branch(&no_match, ne, smi_entry, Operand(Smi::FromEnum(marker))); ++ GenerateTailCallToReturnedCode(masm, function_id); ++ __ bind(&no_match); ++} ++ ++static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ++ Register optimized_code_entry, ++ Register scratch1, Register scratch2) { ++ // ----------- S t a t e ------------- ++ // -- a0 : actual argument count ++ // -- a3 : new target (preserved for callee if needed, and caller) ++ // -- a1 : target function (preserved for callee if needed, and caller) ++ // ----------------------------------- ++ DCHECK(!AreAliased(optimized_code_entry, a1, a3, scratch1, scratch2)); ++ ++ Register closure = a1; ++ ++ // Check if the optimized code is marked for deopt. If it is, call the ++ // runtime to clear it. ++ Label found_deoptimized_code; ++ __ Ld_d(a5, FieldMemOperand(optimized_code_entry, ++ Code::kCodeDataContainerOffset)); ++ __ Ld_w(a5, FieldMemOperand(a5, CodeDataContainer::kKindSpecificFlagsOffset)); ++ __ And(a5, a5, Operand(1 << Code::kMarkedForDeoptimizationBit)); ++ __ Branch(&found_deoptimized_code, ne, a5, Operand(zero_reg)); ++ ++ // Optimized code is good, get it into the closure and link the closure into ++ // the optimized functions list, then tail call the optimized code. ++ // The feedback vector is no longer used, so re-use it as a scratch ++ // register. ++ ReplaceClosureCodeWithOptimizedCode(masm, optimized_code_entry, closure, ++ scratch1, scratch2); ++ ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Add_d(a2, optimized_code_entry, ++ Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ ++ // Optimized code slot contains deoptimized code, evict it and re-enter the ++ // closure's code. ++ __ bind(&found_deoptimized_code); ++ GenerateTailCallToReturnedCode(masm, Runtime::kEvictOptimizedCodeSlot); ++} ++ ++static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, ++ Register optimization_marker) { ++ // ----------- S t a t e ------------- ++ // -- a0 : actual argument count ++ // -- a3 : new target (preserved for callee if needed, and caller) ++ // -- a1 : target function (preserved for callee if needed, and caller) ++ // -- feedback vector (preserved for caller if needed) ++ // -- optimization_marker : a Smi containing a non-zero optimization marker. ++ // ----------------------------------- ++ DCHECK(!AreAliased(feedback_vector, a1, a3, optimization_marker)); ++ ++ // TODO(v8:8394): The logging of first execution will break if ++ // feedback vectors are not allocated. We need to find a different way of ++ // logging these events if required. ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kLogFirstExecution, ++ Runtime::kFunctionFirstExecution); ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kCompileOptimized, ++ Runtime::kCompileOptimized_NotConcurrent); ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kCompileOptimizedConcurrent, ++ Runtime::kCompileOptimized_Concurrent); ++ ++ // Otherwise, the marker is InOptimizationQueue, so fall through hoping ++ // that an interrupt will eventually update the slot with optimized code. ++ if (FLAG_debug_code) { ++ __ Assert(eq, AbortReason::kExpectedOptimizationSentinel, ++ optimization_marker, ++ Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); ++ } ++} ++ ++// Advance the current bytecode offset. This simulates what all bytecode ++// handlers do upon completion of the underlying operation. Will bail out to a ++// label if the bytecode (without prefix) is a return bytecode. Will not advance ++// the bytecode offset if the current bytecode is a JumpLoop, instead just ++// re-executing the JumpLoop to jump to the correct bytecode. ++static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ++ Register bytecode_array, ++ Register bytecode_offset, ++ Register bytecode, Register scratch1, ++ Register scratch2, Register scratch3, ++ Label* if_return) { ++ Register bytecode_size_table = scratch1; ++ ++ // The bytecode offset value will be increased by one in wide and extra wide ++ // cases. In the case of having a wide or extra wide JumpLoop bytecode, we ++ // will restore the original bytecode. In order to simplify the code, we have ++ // a backup of it. ++ Register original_bytecode_offset = scratch3; ++ DCHECK(!AreAliased(bytecode_array, bytecode_offset, bytecode, ++ bytecode_size_table, original_bytecode_offset)); ++ __ Move(original_bytecode_offset, bytecode_offset); ++ __ li(bytecode_size_table, ExternalReference::bytecode_size_table_address()); ++ ++ // Check if the bytecode is a Wide or ExtraWide prefix bytecode. ++ Label process_bytecode, extra_wide; ++ STATIC_ASSERT(0 == static_cast(interpreter::Bytecode::kWide)); ++ STATIC_ASSERT(1 == static_cast(interpreter::Bytecode::kExtraWide)); ++ STATIC_ASSERT(2 == static_cast(interpreter::Bytecode::kDebugBreakWide)); ++ STATIC_ASSERT(3 == ++ static_cast(interpreter::Bytecode::kDebugBreakExtraWide)); ++ __ Branch(&process_bytecode, hi, bytecode, Operand(3)); ++ __ And(scratch2, bytecode, Operand(1)); ++ __ Branch(&extra_wide, ne, scratch2, Operand(zero_reg)); ++ ++ // Load the next bytecode and update table to the wide scaled table. ++ __ Add_d(bytecode_offset, bytecode_offset, Operand(1)); ++ __ Add_d(scratch2, bytecode_array, bytecode_offset); ++ __ Ld_bu(bytecode, MemOperand(scratch2, 0)); ++ __ Add_d(bytecode_size_table, bytecode_size_table, ++ Operand(kIntSize * interpreter::Bytecodes::kBytecodeCount)); ++ __ jmp(&process_bytecode); ++ ++ __ bind(&extra_wide); ++ // Load the next bytecode and update table to the extra wide scaled table. ++ __ Add_d(bytecode_offset, bytecode_offset, Operand(1)); ++ __ Add_d(scratch2, bytecode_array, bytecode_offset); ++ __ Ld_bu(bytecode, MemOperand(scratch2, 0)); ++ __ Add_d(bytecode_size_table, bytecode_size_table, ++ Operand(2 * kIntSize * interpreter::Bytecodes::kBytecodeCount)); ++ ++ __ bind(&process_bytecode); ++ ++// Bailout to the return label if this is a return bytecode. ++#define JUMP_IF_EQUAL(NAME) \ ++ __ Branch(if_return, eq, bytecode, \ ++ Operand(static_cast(interpreter::Bytecode::k##NAME))); ++ RETURN_BYTECODE_LIST(JUMP_IF_EQUAL) ++#undef JUMP_IF_EQUAL ++ ++ // If this is a JumpLoop, re-execute it to perform the jump to the beginning ++ // of the loop. ++ Label end, not_jump_loop; ++ __ Branch(¬_jump_loop, ne, bytecode, ++ Operand(static_cast(interpreter::Bytecode::kJumpLoop))); ++ // We need to restore the original bytecode_offset since we might have ++ // increased it to skip the wide / extra-wide prefix bytecode. ++ __ Move(bytecode_offset, original_bytecode_offset); ++ __ jmp(&end); ++ ++ __ bind(¬_jump_loop); ++ // Otherwise, load the size of the current bytecode and advance the offset. ++ __ Alsl_d(scratch2, bytecode, bytecode_size_table, 2, t7); ++ __ Ld_w(scratch2, MemOperand(scratch2, 0)); ++ __ Add_d(bytecode_offset, bytecode_offset, scratch2); ++ ++ __ bind(&end); ++} ++ ++// Generate code for entering a JS function with the interpreter. ++// On entry to the function the receiver and arguments have been pushed on the ++// stack left to right. ++// ++// The live registers are: ++// o a0 : actual argument count (not including the receiver) ++// o a1: the JS function object being called. ++// o a3: the incoming new target or generator object ++// o cp: our context ++// o fp: the caller's frame pointer ++// o sp: stack pointer ++// o ra: return address ++// ++// The function builds an interpreter frame. See InterpreterFrameConstants in ++// frames.h for its layout. ++void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ++ Register closure = a1; ++ Register feedback_vector = a2; ++ ++ // Get the bytecode array from the function object and load it into ++ // kInterpreterBytecodeArrayRegister. ++ __ Ld_d(kScratchReg, ++ FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_d( ++ kInterpreterBytecodeArrayRegister, ++ FieldMemOperand(kScratchReg, SharedFunctionInfo::kFunctionDataOffset)); ++ GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, ++ kScratchReg); ++ ++ // The bytecode array could have been flushed from the shared function info, ++ // if so, call into CompileLazy. ++ Label compile_lazy; ++ __ GetObjectType(kInterpreterBytecodeArrayRegister, kScratchReg, kScratchReg); ++ __ Branch(&compile_lazy, ne, kScratchReg, Operand(BYTECODE_ARRAY_TYPE)); ++ ++ // Load the feedback vector from the closure. ++ __ Ld_d(feedback_vector, ++ FieldMemOperand(closure, JSFunction::kFeedbackCellOffset)); ++ __ Ld_d(feedback_vector, ++ FieldMemOperand(feedback_vector, Cell::kValueOffset)); ++ ++ Label push_stack_frame; ++ // Check if feedback vector is valid. If valid, check for optimized code ++ // and update invocation count. Otherwise, setup the stack frame. ++ __ Ld_d(a4, FieldMemOperand(feedback_vector, HeapObject::kMapOffset)); ++ __ Ld_hu(a4, FieldMemOperand(a4, Map::kInstanceTypeOffset)); ++ __ Branch(&push_stack_frame, ne, a4, Operand(FEEDBACK_VECTOR_TYPE)); ++ ++ // Read off the optimized code slot in the feedback vector, and if there ++ // is optimized code or an optimization marker, call that instead. ++ Register optimized_code_entry = a4; ++ __ Ld_d(optimized_code_entry, ++ FieldMemOperand(feedback_vector, ++ FeedbackVector::kOptimizedCodeWeakOrSmiOffset)); ++ ++ // Check if the optimized code slot is not empty. ++ Label optimized_code_slot_not_empty; ++ ++ __ Branch(&optimized_code_slot_not_empty, ne, optimized_code_entry, ++ Operand(Smi::FromEnum(OptimizationMarker::kNone))); ++ ++ Label not_optimized; ++ __ bind(¬_optimized); ++ ++ // Increment invocation count for the function. ++ __ Ld_w(a4, FieldMemOperand(feedback_vector, ++ FeedbackVector::kInvocationCountOffset)); ++ __ Add_w(a4, a4, Operand(1)); ++ __ St_w(a4, FieldMemOperand(feedback_vector, ++ FeedbackVector::kInvocationCountOffset)); ++ ++ // Open a frame scope to indicate that there is a frame on the stack. The ++ // MANUAL indicates that the scope shouldn't actually generate code to set up ++ // the frame (that is done below). ++ __ bind(&push_stack_frame); ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ PushStandardFrame(closure); ++ ++ // Reset code age and the OSR arming. The OSR field and BytecodeAgeOffset are ++ // 8-bit fields next to each other, so we could just optimize by writing a ++ // 16-bit. These static asserts guard our assumption is valid. ++ STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset == ++ BytecodeArray::kOsrNestingLevelOffset + kCharSize); ++ STATIC_ASSERT(BytecodeArray::kNoAgeBytecodeAge == 0); ++ __ St_h(zero_reg, FieldMemOperand(kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kOsrNestingLevelOffset)); ++ ++ // Load initial bytecode offset. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ ++ // Push bytecode array and Smi tagged bytecode array offset. ++ __ SmiTag(a4, kInterpreterBytecodeOffsetRegister); ++ __ Push(kInterpreterBytecodeArrayRegister, a4); ++ ++ // Allocate the local and temporary register file on the stack. ++ Label stack_overflow; ++ { ++ // Load frame size (word) from the BytecodeArray object. ++ __ Ld_w(a4, FieldMemOperand(kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kFrameSizeOffset)); ++ ++ // Do a stack check to ensure we don't go over the limit. ++ __ Sub_d(a5, sp, Operand(a4)); ++ LoadStackLimit(masm, a2, StackLimitKind::kRealStackLimit); ++ __ Branch(&stack_overflow, lo, a5, Operand(a2)); ++ ++ // If ok, push undefined as the initial value for all register file entries. ++ Label loop_header; ++ Label loop_check; ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ Branch(&loop_check); ++ __ bind(&loop_header); ++ // TODO(rmcilroy): Consider doing more than one push per loop iteration. ++ __ push(a5); ++ // Continue loop if not done. ++ __ bind(&loop_check); ++ __ Sub_d(a4, a4, Operand(kPointerSize)); ++ __ Branch(&loop_header, ge, a4, Operand(zero_reg)); ++ } ++ ++ // If the bytecode array has a valid incoming new target or generator object ++ // register, initialize it with incoming value which was passed in r3. ++ Label no_incoming_new_target_or_generator_register; ++ __ Ld_w(a5, FieldMemOperand( ++ kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kIncomingNewTargetOrGeneratorRegisterOffset)); ++ __ Branch(&no_incoming_new_target_or_generator_register, eq, a5, ++ Operand(zero_reg)); ++ __ Alsl_d(a5, a5, fp, kPointerSizeLog2, t7); ++ __ St_d(a3, MemOperand(a5, 0)); ++ __ bind(&no_incoming_new_target_or_generator_register); ++ ++ // Perform interrupt stack check. ++ // TODO(solanes): Merge with the real stack limit check above. ++ Label stack_check_interrupt, after_stack_check_interrupt; ++ LoadStackLimit(masm, a5, StackLimitKind::kInterruptStackLimit); ++ __ Branch(&stack_check_interrupt, lo, sp, Operand(a5)); ++ __ bind(&after_stack_check_interrupt); ++ ++ // Load accumulator as undefined. ++ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); ++ ++ // Load the dispatch table into a register and dispatch to the bytecode ++ // handler at the current bytecode offset. ++ Label do_dispatch; ++ __ bind(&do_dispatch); ++ __ li(kInterpreterDispatchTableRegister, ++ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); ++ __ Add_d(t5, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Ld_bu(a7, MemOperand(t5, 0)); ++ __ Alsl_d(kScratchReg, a7, kInterpreterDispatchTableRegister, ++ kPointerSizeLog2, t7); ++ __ Ld_d(kJavaScriptCallCodeStartRegister, MemOperand(kScratchReg, 0)); ++ __ Call(kJavaScriptCallCodeStartRegister); ++ masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); ++ ++ // Any returns to the entry trampoline are either due to the return bytecode ++ // or the interpreter tail calling a builtin and then a dispatch. ++ ++ // Get bytecode array and bytecode offset from the stack frame. ++ __ Ld_d(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Ld_d(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister); ++ ++ // Either return, or advance to the next bytecode and dispatch. ++ Label do_return; ++ __ Add_d(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Ld_bu(a1, MemOperand(a1, 0)); ++ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister, a1, a2, a3, ++ a4, &do_return); ++ __ jmp(&do_dispatch); ++ ++ __ bind(&do_return); ++ // The return value is in a0. ++ LeaveInterpreterFrame(masm, t0); ++ __ Jump(ra); ++ ++ __ bind(&stack_check_interrupt); ++ // Modify the bytecode offset in the stack to be kFunctionEntryBytecodeOffset ++ // for the call to the StackGuard. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(Smi::FromInt(BytecodeArray::kHeaderSize - kHeapObjectTag + ++ kFunctionEntryBytecodeOffset))); ++ __ St_d(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ CallRuntime(Runtime::kStackGuard); ++ ++ // After the call, restore the bytecode array, bytecode offset and accumulator ++ // registers again. Also, restore the bytecode offset in the stack to its ++ // previous value. ++ __ Ld_d(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); ++ ++ __ SmiTag(a5, kInterpreterBytecodeOffsetRegister); ++ __ St_d(a5, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ __ jmp(&after_stack_check_interrupt); ++ ++ __ bind(&optimized_code_slot_not_empty); ++ Label maybe_has_optimized_code; ++ // Check if optimized code marker is actually a weak reference to the ++ // optimized code as opposed to an optimization marker. ++ __ JumpIfNotSmi(optimized_code_entry, &maybe_has_optimized_code, t7); ++ MaybeOptimizeCode(masm, feedback_vector, optimized_code_entry); ++ // Fall through if there's no runnable optimized code. ++ __ jmp(¬_optimized); ++ ++ __ bind(&maybe_has_optimized_code); ++ // Load code entry from the weak reference, if it was cleared, resume ++ // execution of unoptimized code. ++ __ LoadWeakValue(optimized_code_entry, optimized_code_entry, ¬_optimized); ++ TailCallOptimizedCodeSlot(masm, optimized_code_entry, t3, a5); ++ ++ __ bind(&compile_lazy); ++ GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); ++ // Unreachable code. ++ __ break_(0xCC); ++ ++ __ bind(&stack_overflow); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++} ++ ++static void Generate_InterpreterPushArgs(MacroAssembler* masm, ++ Register num_args, ++ Register start_address, ++ Register scratch, Register scratch2) { ++ // Find the address of the last argument. ++ __ Sub_d(scratch, num_args, Operand(1)); ++ __ slli_d(scratch, scratch, kPointerSizeLog2); ++ __ Sub_d(start_address, start_address, scratch); ++ ++ // Push the arguments. ++#ifdef V8_REVERSE_JSARGS ++ __ PushArray(start_address, num_args, scratch, scratch2, ++ TurboAssembler::PushArrayOrder::kReverse); ++#else ++ __ PushArray(start_address, num_args, scratch, scratch2); ++#endif ++} ++ ++// static ++void Builtins::Generate_InterpreterPushArgsThenCallImpl( ++ MacroAssembler* masm, ConvertReceiverMode receiver_mode, ++ InterpreterPushArgsMode mode) { ++ DCHECK(mode != InterpreterPushArgsMode::kArrayFunction); ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a2 : the address of the first argument to be pushed. Subsequent ++ // arguments should be consecutive above this, in the same order as ++ // they are to be pushed onto the stack. ++ // -- a1 : the target to call (can be any Object). ++ // ----------------------------------- ++ Label stack_overflow; ++ ++#ifdef V8_REVERSE_JSARGS ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // The spread argument should not be pushed. ++ __ Sub_d(a0, a0, Operand(1)); ++ } ++#endif ++ ++ __ Add_d(a3, a0, Operand(1)); // Add one for receiver. ++ ++ Generate_StackOverflowCheck(masm, a3, a4, t0, &stack_overflow); ++ ++#ifdef V8_REVERSE_JSARGS ++ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { ++ // Don't copy receiver. ++ __ mov(a3, a0); ++ } ++ ++ // This function modifies a2, t0 and a4. ++ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); ++ ++ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { ++ __ PushRoot(RootIndex::kUndefinedValue); ++ } ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // Pass the spread in the register a2. ++ // a2 already points to the penultime argument, the spread ++ // is below that. ++ __ Ld_d(a2, MemOperand(a2, -kSystemPointerSize)); ++ } ++#else ++ // Push "undefined" as the receiver arg if we need to. ++ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ mov(a3, a0); ++ } ++ ++ // This function modifies a2, t0 and a4. ++ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Pop(a2); // Pass the spread in a register ++ __ Sub_d(a0, a0, Operand(1)); // Subtract one for spread ++ } ++#endif ++ ++ // Call the target. ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithSpread), ++ RelocInfo::CODE_TARGET); ++ } else { ++ __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny), ++ RelocInfo::CODE_TARGET); ++ } ++ ++ __ bind(&stack_overflow); ++ { ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ } ++} ++ ++// static ++void Builtins::Generate_InterpreterPushArgsThenConstructImpl( ++ MacroAssembler* masm, InterpreterPushArgsMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argument count (not including receiver) ++ // -- a3 : new target ++ // -- a1 : constructor to call ++ // -- a2 : allocation site feedback if available, undefined otherwise. ++ // -- a4 : address of the first argument ++ // ----------------------------------- ++ Label stack_overflow; ++ __ addi_d(a6, a0, 1); ++ Generate_StackOverflowCheck(masm, a6, a5, t0, &stack_overflow); ++ ++#ifdef V8_REVERSE_JSARGS ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // The spread argument should not be pushed. ++ __ Sub_d(a0, a0, Operand(1)); ++ } ++ ++ // Push the arguments, This function modifies t0, a4 and a5. ++ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); ++ ++ // Push a slot for the receiver. ++ __ push(zero_reg); ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // Pass the spread in the register a2. ++ // a4 already points to the penultimate argument, the spread ++ // lies in the next interpreter register. ++ __ Ld_d(a2, MemOperand(a4, -kSystemPointerSize)); ++ } else { ++ __ AssertUndefinedOrAllocationSite(a2, t0); ++ } ++#else ++ // Push a slot for the receiver. ++ __ push(zero_reg); ++ ++ // This function modifies t0, a4 and a5. ++ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Pop(a2); // Pass the spread in a register ++ __ Sub_d(a0, a0, Operand(1)); // Subtract one for spread ++ } else { ++ __ AssertUndefinedOrAllocationSite(a2, t0); ++ } ++#endif ++ ++ if (mode == InterpreterPushArgsMode::kArrayFunction) { ++ __ AssertFunction(a1); ++ ++ // Tail call to the function-specific construct stub (still in the caller ++ // context at this point). ++ __ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl), ++ RelocInfo::CODE_TARGET); ++ } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // Call the constructor with a0, a1, and a3 unmodified. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithSpread), ++ RelocInfo::CODE_TARGET); ++ } else { ++ DCHECK_EQ(InterpreterPushArgsMode::kOther, mode); ++ // Call the constructor with a0, a1, and a3 unmodified. ++ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); ++ } ++ ++ __ bind(&stack_overflow); ++ { ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ } ++} ++ ++static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { ++ // Set the return address to the correct point in the interpreter entry ++ // trampoline. ++ Label builtin_trampoline, trampoline_loaded; ++ Smi interpreter_entry_return_pc_offset( ++ masm->isolate()->heap()->interpreter_entry_return_pc_offset()); ++ DCHECK_NE(interpreter_entry_return_pc_offset, Smi::zero()); ++ ++ // If the SFI function_data is an InterpreterData, the function will have a ++ // custom copy of the interpreter entry trampoline for profiling. If so, ++ // get the custom trampoline, otherwise grab the entry address of the global ++ // trampoline. ++ __ Ld_d(t0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ Ld_d(t0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_d(t0, FieldMemOperand(t0, SharedFunctionInfo::kFunctionDataOffset)); ++ __ GetObjectType(t0, kInterpreterDispatchTableRegister, ++ kInterpreterDispatchTableRegister); ++ __ Branch(&builtin_trampoline, ne, kInterpreterDispatchTableRegister, ++ Operand(INTERPRETER_DATA_TYPE)); ++ ++ __ Ld_d(t0, ++ FieldMemOperand(t0, InterpreterData::kInterpreterTrampolineOffset)); ++ __ Add_d(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Branch(&trampoline_loaded); ++ ++ __ bind(&builtin_trampoline); ++ __ li(t0, ExternalReference:: ++ address_of_interpreter_entry_trampoline_instruction_start( ++ masm->isolate())); ++ __ Ld_d(t0, MemOperand(t0, 0)); ++ ++ __ bind(&trampoline_loaded); ++ __ Add_d(ra, t0, Operand(interpreter_entry_return_pc_offset.value())); ++ ++ // Initialize the dispatch table register. ++ __ li(kInterpreterDispatchTableRegister, ++ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); ++ ++ // Get the bytecode array pointer from the frame. ++ __ Ld_d(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ ++ if (FLAG_debug_code) { ++ // Check function data field is actually a BytecodeArray object. ++ __ SmiTst(kInterpreterBytecodeArrayRegister, kScratchReg); ++ __ Assert(ne, ++ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, ++ kScratchReg, Operand(zero_reg)); ++ __ GetObjectType(kInterpreterBytecodeArrayRegister, a1, a1); ++ __ Assert(eq, ++ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, ++ a1, Operand(BYTECODE_ARRAY_TYPE)); ++ } ++ ++ // Get the target bytecode offset from the frame. ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ if (FLAG_debug_code) { ++ Label okay; ++ __ Branch(&okay, ge, kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ // Unreachable code. ++ __ break_(0xCC); ++ __ bind(&okay); ++ } ++ ++ // Dispatch to the target bytecode. ++ __ Add_d(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Ld_bu(a7, MemOperand(a1, 0)); ++ __ Alsl_d(a1, a7, kInterpreterDispatchTableRegister, kPointerSizeLog2, t7); ++ __ Ld_d(kJavaScriptCallCodeStartRegister, MemOperand(a1, 0)); ++ __ Jump(kJavaScriptCallCodeStartRegister); ++} ++ ++void Builtins::Generate_InterpreterEnterBytecodeAdvance(MacroAssembler* masm) { ++ // Advance the current bytecode offset stored within the given interpreter ++ // stack frame. This simulates what all bytecode handlers do upon completion ++ // of the underlying operation. ++ __ Ld_d(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Ld_d(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister); ++ ++ Label enter_bytecode, function_entry_bytecode; ++ __ Branch(&function_entry_bytecode, eq, kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag + ++ kFunctionEntryBytecodeOffset)); ++ ++ // Load the current bytecode. ++ __ Add_d(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Ld_bu(a1, MemOperand(a1, 0)); ++ ++ // Advance to the next bytecode. ++ Label if_return; ++ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister, a1, a2, a3, ++ a4, &if_return); ++ ++ __ bind(&enter_bytecode); ++ // Convert new bytecode offset to a Smi and save in the stackframe. ++ __ SmiTag(a2, kInterpreterBytecodeOffsetRegister); ++ __ St_d(a2, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ Generate_InterpreterEnterBytecode(masm); ++ ++ __ bind(&function_entry_bytecode); ++ // If the code deoptimizes during the implicit function entry stack interrupt ++ // check, it will have a bailout ID of kFunctionEntryBytecodeOffset, which is ++ // not a valid bytecode offset. Detect this case and advance to the first ++ // actual bytecode. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ __ Branch(&enter_bytecode); ++ ++ // We should never take the if_return path. ++ __ bind(&if_return); ++ __ Abort(AbortReason::kInvalidBytecodeAdvance); ++} ++ ++void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { ++ Generate_InterpreterEnterBytecode(masm); ++} ++ ++namespace { ++void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, ++ bool java_script_builtin, ++ bool with_result) { ++ const RegisterConfiguration* config(RegisterConfiguration::Default()); ++ int allocatable_register_count = config->num_allocatable_general_registers(); ++ Register scratch = t8; ++ if (with_result) { ++#ifdef V8_REVERSE_JSARGS ++ if (java_script_builtin) { ++ __ mov(scratch, a0); ++ } else { ++ // Overwrite the hole inserted by the deoptimizer with the return value ++ // from the LAZY deopt point. ++ __ St_d( ++ a0, ++ MemOperand( ++ sp, config->num_allocatable_general_registers() * kPointerSize + ++ BuiltinContinuationFrameConstants::kFixedFrameSize)); ++ } ++#else ++ // Overwrite the hole inserted by the deoptimizer with the return value from ++ // the LAZY deopt point. ++ __ St_d(a0, ++ MemOperand( ++ sp, config->num_allocatable_general_registers() * kPointerSize + ++ BuiltinContinuationFrameConstants::kFixedFrameSize)); ++ USE(scratch); ++#endif ++ } ++ for (int i = allocatable_register_count - 1; i >= 0; --i) { ++ int code = config->GetAllocatableGeneralCode(i); ++ __ Pop(Register::from_code(code)); ++ if (java_script_builtin && code == kJavaScriptCallArgCountRegister.code()) { ++ __ SmiUntag(Register::from_code(code)); ++ } ++ } ++ ++#ifdef V8_REVERSE_JSARGS ++ if (with_result && java_script_builtin) { ++ // Overwrite the hole inserted by the deoptimizer with the return value from ++ // the LAZY deopt point. t0 contains the arguments count, the return value ++ // from LAZY is always the last argument. ++ __ Add_d(a0, a0, ++ Operand(BuiltinContinuationFrameConstants::kFixedSlotCount)); ++ __ Alsl_d(t0, a0, sp, kSystemPointerSizeLog2, t7); ++ __ St_d(scratch, MemOperand(t0, 0)); ++ // Recover arguments count. ++ __ Sub_d(a0, a0, ++ Operand(BuiltinContinuationFrameConstants::kFixedSlotCount)); ++ } ++#endif ++ ++ __ Ld_d( ++ fp, ++ MemOperand(sp, BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); ++ // Load builtin index (stored as a Smi) and use it to get the builtin start ++ // address from the builtins table. ++ __ Pop(t0); ++ __ Add_d(sp, sp, ++ Operand(BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); ++ __ Pop(ra); ++ __ LoadEntryFromBuiltinIndex(t0); ++ __ Jump(t0); ++} ++} // namespace ++ ++void Builtins::Generate_ContinueToCodeStubBuiltin(MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, false, false); ++} ++ ++void Builtins::Generate_ContinueToCodeStubBuiltinWithResult( ++ MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, false, true); ++} ++ ++void Builtins::Generate_ContinueToJavaScriptBuiltin(MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, true, false); ++} ++ ++void Builtins::Generate_ContinueToJavaScriptBuiltinWithResult( ++ MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, true, true); ++} ++ ++void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kNotifyDeoptimized); ++ } ++ ++ DCHECK_EQ(kInterpreterAccumulatorRegister.code(), a0.code()); ++ __ Ld_d(a0, MemOperand(sp, 0 * kPointerSize)); ++ __ Add_d(sp, sp, Operand(1 * kPointerSize)); // Remove state. ++ __ Ret(); ++} ++ ++void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kCompileForOnStackReplacement); ++ } ++ ++ // If the code object is null, just return to the caller. ++ __ Ret(eq, a0, Operand(Smi::zero())); ++ ++ // Drop the handler frame that is be sitting on top of the actual ++ // JavaScript frame. This is the case then OSR is triggered from bytecode. ++ __ LeaveFrame(StackFrame::STUB); ++ ++ // Load deoptimization data from the code object. ++ // = [#deoptimization_data_offset] ++ __ Ld_d(a1, MemOperand(a0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); ++ ++ // Load the OSR entrypoint offset from the deoptimization data. ++ // = [#header_size + #osr_pc_offset] ++ __ SmiUntag(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( ++ DeoptimizationData::kOsrPcOffsetIndex) - ++ kHeapObjectTag)); ++ ++ // Compute the target address = code_obj + header_size + osr_offset ++ // = + #header_size + ++ __ Add_d(a0, a0, a1); ++ __ addi_d(ra, a0, Code::kHeaderSize - kHeapObjectTag); ++ ++ // And "return" to the OSR entry point of the function. ++ __ Ret(); ++} ++ ++// static ++void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : argArray ++ // -- sp[4] : thisArg ++ // -- sp[8] : receiver ++ // ----------------------------------- ++ ++ Register argc = a0; ++ Register arg_array = a2; ++ Register receiver = a1; ++ Register this_arg = a5; ++ Register undefined_value = a3; ++ Register scratch = a4; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load receiver into a1, argArray into a2 (if present), remove all ++ // arguments from the stack (including the receiver), and push thisArg (if ++ // present) instead. ++ { ++ // Claim (2 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ ++#ifdef V8_REVERSE_JSARGS ++ __ mov(scratch, argc); ++ __ Ld_d(this_arg, MemOperand(sp, kPointerSize)); ++ __ Ld_d(arg_array, MemOperand(sp, 2 * kPointerSize)); ++ __ Movz(arg_array, undefined_value, scratch); // if argc == 0 ++ __ Movz(this_arg, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arg_array, undefined_value, scratch); // if argc == 1 ++ __ Ld_d(receiver, MemOperand(sp, 0)); ++ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); ++ __ St_d(this_arg, MemOperand(sp, 0)); ++#else ++ __ Sub_d(sp, sp, Operand(2 * kPointerSize)); ++ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); ++ __ mov(scratch, argc); ++ __ Pop(this_arg, arg_array); // Overwrite argc ++ __ Movz(arg_array, undefined_value, scratch); // if argc == 0 ++ __ Movz(this_arg, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arg_array, undefined_value, scratch); // if argc == 1 ++ __ Ld_d(receiver, MemOperand(sp, 0)); ++ __ St_d(this_arg, MemOperand(sp, 0)); ++#endif ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argArray ++ // -- a1 : receiver ++ // -- a3 : undefined root value ++ // -- sp[0] : thisArg ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for callable receiver here, ++ // since that's the first thing the Call/CallWithArrayLike builtins ++ // will do. ++ ++ // 3. Tail call with no arguments if argArray is null or undefined. ++ Label no_arguments; ++ __ JumpIfRoot(arg_array, RootIndex::kNullValue, &no_arguments); ++ __ Branch(&no_arguments, eq, arg_array, Operand(undefined_value)); ++ ++ // 4a. Apply the receiver to the given argArray. ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), ++ RelocInfo::CODE_TARGET); ++ ++ // 4b. The argArray is either null or undefined, so we tail call without any ++ // arguments to the receiver. ++ __ bind(&no_arguments); ++ { ++ __ mov(a0, zero_reg); ++ DCHECK(receiver == a1); ++ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); ++ } ++} ++ ++// static ++void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { ++#ifdef V8_REVERSE_JSARGS ++ // 1. Get the callable to call (passed as receiver) from the stack. ++ { __ Pop(a1); } ++ ++ // 2. Make sure we have at least one argument. ++ // a0: actual number of arguments ++ { ++ Label done; ++ __ Branch(&done, ne, a0, Operand(zero_reg)); ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ Add_d(a0, a0, Operand(1)); ++ __ bind(&done); ++ } ++ ++ // 3. Adjust the actual number of arguments. ++ __ addi_d(a0, a0, -1); ++#else ++ // 1. Make sure we have at least one argument. ++ // a0: actual number of arguments ++ { ++ Label done; ++ __ Branch(&done, ne, a0, Operand(zero_reg)); ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ Add_d(a0, a0, Operand(1)); ++ __ bind(&done); ++ } ++ ++ // 2. Get the function to call (passed as receiver) from the stack. ++ // a0: actual number of arguments ++ __ LoadReceiver(a1, a0); ++ ++ // 3. Shift arguments and return address one slot down on the stack ++ // (overwriting the original receiver). Adjust argument count to make ++ // the original first argument the new receiver. ++ // a0: actual number of arguments ++ // a1: function ++ { ++ Label loop; ++ // Calculate the copy start address (destination). Copy end address is sp. ++ __ Alsl_d(a2, a0, sp, kPointerSizeLog2, t7); ++ ++ __ bind(&loop); ++ __ Ld_d(kScratchReg, MemOperand(a2, -kPointerSize)); ++ __ St_d(kScratchReg, MemOperand(a2, 0)); ++ __ Sub_d(a2, a2, Operand(kPointerSize)); ++ __ Branch(&loop, ne, a2, Operand(sp)); ++ // Adjust the actual number of arguments and remove the top element ++ // (which is a copy of the last argument). ++ __ Sub_d(a0, a0, Operand(1)); ++ __ Pop(); ++ } ++#endif ++ ++ // 4. Call the callable. ++ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ReflectApply(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : argumentsList (if argc ==3) ++ // -- sp[4] : thisArgument (if argc >=2) ++ // -- sp[8] : target (if argc >=1) ++ // -- sp[12] : receiver ++ // ----------------------------------- ++ ++ Register argc = a0; ++ Register arguments_list = a2; ++ Register target = a1; ++ Register this_argument = a5; ++ Register undefined_value = a3; ++ Register scratch = a4; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load target into a1 (if present), argumentsList into a2 (if present), ++ // remove all arguments from the stack (including the receiver), and push ++ // thisArgument (if present) instead. ++ { ++ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ ++#ifdef V8_REVERSE_JSARGS ++ __ mov(scratch, argc); ++ __ Ld_d(target, MemOperand(sp, kPointerSize)); ++ __ Ld_d(this_argument, MemOperand(sp, 2 * kPointerSize)); ++ __ Ld_d(arguments_list, MemOperand(sp, 3 * kPointerSize)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 ++ __ Movz(this_argument, undefined_value, scratch); // if argc == 0 ++ __ Movz(target, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 ++ __ Movz(this_argument, undefined_value, scratch); // if argc == 1 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 2 ++ ++ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); ++ __ St_d(this_argument, MemOperand(sp, 0)); // Overwrite receiver ++#else ++ __ Sub_d(sp, sp, Operand(3 * kPointerSize)); ++ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); ++ __ mov(scratch, argc); ++ __ Pop(target, this_argument, arguments_list); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 ++ __ Movz(this_argument, undefined_value, scratch); // if argc == 0 ++ __ Movz(target, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 ++ __ Movz(this_argument, undefined_value, scratch); // if argc == 1 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 2 ++ ++ __ St_d(this_argument, MemOperand(sp, 0)); // Overwrite receiver ++#endif ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argumentsList ++ // -- a1 : target ++ // -- a3 : undefined root value ++ // -- sp[0] : thisArgument ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for callable target here, ++ // since that's the first thing the Call/CallWithArrayLike builtins ++ // will do. ++ ++ // 3. Apply the target to the given argumentsList. ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), ++ RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : new.target (optional) (dummy value if argc <= 2) ++ // -- sp[4] : argumentsList (dummy value if argc <= 1) ++ // -- sp[8] : target (dummy value if argc == 0) ++ // -- sp[12] : receiver ++ // ----------------------------------- ++ // NOTE: The order of args in the stack are reversed if V8_REVERSE_JSARGS ++ ++ Register argc = a0; ++ Register arguments_list = a2; ++ Register target = a1; ++ Register new_target = a3; ++ Register undefined_value = a4; ++ Register scratch = a5; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load target into a1 (if present), argumentsList into a2 (if present), ++ // new.target into a3 (if present, otherwise use target), remove all ++ // arguments from the stack (including the receiver), and push thisArgument ++ // (if present) instead. ++ { ++ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ ++#ifdef V8_REVERSE_JSARGS ++ __ mov(scratch, argc); ++ __ Ld_d(target, MemOperand(sp, kPointerSize)); ++ __ Ld_d(arguments_list, MemOperand(sp, 2 * kPointerSize)); ++ __ Ld_d(new_target, MemOperand(sp, 3 * kPointerSize)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 ++ __ Movz(new_target, undefined_value, scratch); // if argc == 0 ++ __ Movz(target, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 ++ __ Movz(new_target, target, scratch); // if argc == 1 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(new_target, target, scratch); // if argc == 2 ++ ++ __ Alsl_d(sp, argc, sp, kSystemPointerSizeLog2, t7); ++ __ St_d(undefined_value, MemOperand(sp, 0)); // Overwrite receiver ++#else ++ __ Sub_d(sp, sp, Operand(3 * kPointerSize)); ++ __ Alsl_d(sp, argc, sp, kPointerSizeLog2, t7); ++ __ mov(scratch, argc); ++ __ Pop(target, arguments_list, new_target); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 0 ++ __ Movz(new_target, undefined_value, scratch); // if argc == 0 ++ __ Movz(target, undefined_value, scratch); // if argc == 0 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(arguments_list, undefined_value, scratch); // if argc == 1 ++ __ Movz(new_target, target, scratch); // if argc == 1 ++ __ Sub_d(scratch, scratch, Operand(1)); ++ __ Movz(new_target, target, scratch); // if argc == 2 ++ ++ __ St_d(undefined_value, MemOperand(sp, 0)); // Overwrite receiver ++#endif ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argumentsList ++ // -- a1 : target ++ // -- a3 : new.target ++ // -- sp[0] : receiver (undefined) ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for constructor target here, ++ // since that's the first thing the Construct/ConstructWithArrayLike ++ // builtins will do. ++ ++ // 3. We don't need to check explicitly for constructor new.target here, ++ // since that's the second thing the Construct/ConstructWithArrayLike ++ // builtins will do. ++ ++ // 4. Construct the target with the given new.target and argumentsList. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithArrayLike), ++ RelocInfo::CODE_TARGET); ++} ++ ++static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { ++ __ SmiTag(a0); ++ __ li(a4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ __ Push(ra, fp, a4, a1, a0); ++ __ Push(Smi::zero()); // Padding. ++ __ Add_d(fp, sp, ++ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp)); ++} ++ ++static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : result being passed through ++ // ----------------------------------- ++ // Get the number of arguments passed (as a smi), tear down the frame and ++ // then tear down the parameters. ++ __ Ld_d(a1, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ __ mov(sp, fp); ++ __ Pop(ra, fp); ++ __ SmiScale(a4, a1, kPointerSizeLog2); ++ __ Add_d(sp, sp, a4); ++ // Adjust for the receiver. ++ __ Add_d(sp, sp, Operand(kPointerSize)); ++} ++ ++// static ++void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, ++ Handle code) { ++ // ----------- S t a t e ------------- ++ // -- a1 : target ++ // -- a0 : number of parameters on the stack (not including the receiver) ++ // -- a2 : arguments list (a FixedArray) ++ // -- a4 : len (number of elements to push from args) ++ // -- a3 : new.target (for [[Construct]]) ++ // ----------------------------------- ++ if (masm->emit_debug_code()) { ++ // Allow a2 to be a FixedArray, or a FixedDoubleArray if a4 == 0. ++ Label ok, fail; ++ __ AssertNotSmi(a2); ++ __ GetObjectType(a2, t8, t8); ++ __ Branch(&ok, eq, t8, Operand(FIXED_ARRAY_TYPE)); ++ __ Branch(&fail, ne, t8, Operand(FIXED_DOUBLE_ARRAY_TYPE)); ++ __ Branch(&ok, eq, a4, Operand(zero_reg)); ++ // Fall through. ++ __ bind(&fail); ++ __ Abort(AbortReason::kOperandIsNotAFixedArray); ++ ++ __ bind(&ok); ++ } ++ ++ Register args = a2; ++ Register len = a4; ++ ++ // Check for stack overflow. ++ Label stack_overflow; ++ Generate_StackOverflowCheck(masm, len, kScratchReg, a5, &stack_overflow); ++ ++#ifdef V8_REVERSE_JSARGS ++ // Move the arguments already in the stack, ++ // including the receiver and the return address. ++ { ++ Label copy; ++ Register src = a6, dest = a7; ++ __ mov(src, sp); ++ __ slli_d(t0, a4, kSystemPointerSizeLog2); ++ __ Sub_d(sp, sp, Operand(t0)); ++ // Update stack pointer. ++ __ mov(dest, sp); ++ __ Add_d(t0, a0, Operand(zero_reg)); ++ ++ __ bind(©); ++ __ Ld_d(t1, MemOperand(src, 0)); ++ __ St_d(t1, MemOperand(dest, 0)); ++ __ Sub_d(t0, t0, Operand(1)); ++ __ Add_d(src, src, Operand(kSystemPointerSize)); ++ __ Add_d(dest, dest, Operand(kSystemPointerSize)); ++ __ Branch(©, ge, t0, Operand(zero_reg)); ++ } ++#endif ++ ++ // Push arguments onto the stack (thisArgument is already on the stack). ++ { ++ Label done, push, loop; ++ Register src = a6; ++ Register scratch = len; ++ ++ __ addi_d(src, args, FixedArray::kHeaderSize - kHeapObjectTag); ++ __ Add_d(a0, a0, len); // The 'len' argument for Call() or Construct(). ++ __ Branch(&done, eq, len, Operand(zero_reg)); ++ __ slli_d(scratch, len, kPointerSizeLog2); ++ __ Sub_d(scratch, sp, Operand(scratch)); ++ __ LoadRoot(t1, RootIndex::kTheHoleValue); ++ __ bind(&loop); ++ __ Ld_d(a5, MemOperand(src, 0)); ++ __ addi_d(src, src, kPointerSize); ++ __ Branch(&push, ne, a5, Operand(t1)); ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ bind(&push); ++#ifdef V8_REVERSE_JSARGS ++ __ St_d(a5, MemOperand(a7, 0)); ++ __ Add_d(a7, a7, Operand(kSystemPointerSize)); ++ __ Add_d(scratch, scratch, Operand(kSystemPointerSize)); ++#else ++ __ Push(a5); ++#endif ++ __ Branch(&loop, ne, scratch, Operand(sp)); ++ __ bind(&done); ++ } ++ ++ // Tail-call to the actual Call or Construct builtin. ++ __ Jump(code, RelocInfo::CODE_TARGET); ++ ++ __ bind(&stack_overflow); ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++} ++ ++// static ++void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, ++ CallOrConstructMode mode, ++ Handle code) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a3 : the new.target (for [[Construct]] calls) ++ // -- a1 : the target to call (can be any Object) ++ // -- a2 : start index (to support rest parameters) ++ // ----------------------------------- ++ ++ // Check if new.target has a [[Construct]] internal method. ++ if (mode == CallOrConstructMode::kConstruct) { ++ Label new_target_constructor, new_target_not_constructor; ++ __ JumpIfSmi(a3, &new_target_not_constructor); ++ __ Ld_d(t1, FieldMemOperand(a3, HeapObject::kMapOffset)); ++ __ Ld_bu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t1, t1, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ __ Branch(&new_target_constructor, ne, t1, Operand(zero_reg)); ++ __ bind(&new_target_not_constructor); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ Push(a3); ++ __ CallRuntime(Runtime::kThrowNotConstructor); ++ } ++ __ bind(&new_target_constructor); ++ } ++ ++ // Check if we have an arguments adaptor frame below the function frame. ++ Label arguments_adaptor, arguments_done; ++ __ Ld_d(a6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ __ Ld_d(a7, MemOperand(a6, CommonFrameConstants::kContextOrFrameTypeOffset)); ++ __ Branch(&arguments_adaptor, eq, a7, ++ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ { ++ __ Ld_d(a7, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ Ld_d(a7, FieldMemOperand(a7, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_hu(a7, FieldMemOperand( ++ a7, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ mov(a6, fp); ++ } ++ __ Branch(&arguments_done); ++ __ bind(&arguments_adaptor); ++ { ++ // Just get the length from the ArgumentsAdaptorFrame. ++ __ SmiUntag(a7, ++ MemOperand(a6, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ } ++ __ bind(&arguments_done); ++ ++ Label stack_done, stack_overflow; ++ __ Sub_w(a7, a7, a2); ++ __ Branch(&stack_done, le, a7, Operand(zero_reg)); ++ { ++ // Check for stack overflow. ++ Generate_StackOverflowCheck(masm, a7, a4, a5, &stack_overflow); ++ ++ // Forward the arguments from the caller frame. ++ ++#ifdef V8_REVERSE_JSARGS ++ // Point to the first argument to copy (skipping the receiver). ++ __ Add_d(a6, a6, ++ Operand(CommonFrameConstants::kFixedFrameSizeAboveFp + ++ kSystemPointerSize)); ++ __ Alsl_d(a6, a2, a6, kSystemPointerSizeLog2, t7); ++ ++ // Move the arguments already in the stack, ++ // including the receiver and the return address. ++ { ++ Label copy; ++ Register src = t0, dest = a2; ++ __ mov(src, sp); ++ // Update stack pointer. ++ __ slli_d(t1, a7, kSystemPointerSizeLog2); ++ __ Sub_d(sp, sp, Operand(t1)); ++ __ mov(dest, sp); ++ __ Add_d(t2, a0, Operand(zero_reg)); ++ ++ __ bind(©); ++ __ Ld_d(t1, MemOperand(src, 0)); ++ __ St_d(t1, MemOperand(dest, 0)); ++ __ Sub_d(t2, t2, Operand(1)); ++ __ Add_d(src, src, Operand(kSystemPointerSize)); ++ __ Add_d(dest, dest, Operand(kSystemPointerSize)); ++ __ Branch(©, ge, t2, Operand(zero_reg)); ++ } ++#endif ++ ++ // Copy arguments from the caller frame. ++ // TODO(victorgomes): Consider using forward order as potentially more cache ++ // friendly. ++ { ++ Label loop; ++#ifndef V8_REVERSE_JSARGS ++ __ Add_d(a6, a6, Operand(CommonFrameConstants::kFixedFrameSizeAboveFp)); ++#endif ++ __ Add_d(a0, a0, a7); ++ __ bind(&loop); ++ { ++ __ Sub_w(a7, a7, Operand(1)); ++ __ Alsl_d(t0, a7, a6, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(t0, 0)); ++#ifdef V8_REVERSE_JSARGS ++ __ Alsl_d(t0, a7, a2, kPointerSizeLog2, t7); ++ __ St_d(kScratchReg, MemOperand(t0, 0)); ++#else ++ __ push(kScratchReg); ++#endif ++ __ Branch(&loop, ne, a7, Operand(zero_reg)); ++ } ++ } ++ } ++ __ Branch(&stack_done); ++ __ bind(&stack_overflow); ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ __ bind(&stack_done); ++ ++ // Tail-call to the {code} handler. ++ __ Jump(code, RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_CallFunction(MacroAssembler* masm, ++ ConvertReceiverMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // ----------------------------------- ++ __ AssertFunction(a1); ++ ++ // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) ++ // Check that function is not a "classConstructor". ++ Label class_constructor; ++ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_wu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); ++ __ And(kScratchReg, a3, ++ Operand(SharedFunctionInfo::IsClassConstructorBit::kMask)); ++ __ Branch(&class_constructor, ne, kScratchReg, Operand(zero_reg)); ++ ++ // Enter the context of the function; ToObject has to run in the function ++ // context, and we also need to take the global proxy from the function ++ // context in case of conversion. ++ __ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ // We need to convert the receiver for non-native sloppy mode functions. ++ Label done_convert; ++ __ Ld_wu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); ++ __ And(kScratchReg, a3, ++ Operand(SharedFunctionInfo::IsNativeBit::kMask | ++ SharedFunctionInfo::IsStrictBit::kMask)); ++ __ Branch(&done_convert, ne, kScratchReg, Operand(zero_reg)); ++ { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // -- a2 : the shared function info. ++ // -- cp : the function context. ++ // ----------------------------------- ++ ++ if (mode == ConvertReceiverMode::kNullOrUndefined) { ++ // Patch receiver to global proxy. ++ __ LoadGlobalProxy(a3); ++ } else { ++ Label convert_to_object, convert_receiver; ++ __ LoadReceiver(a3, a0); ++ __ JumpIfSmi(a3, &convert_to_object); ++ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); ++ __ GetObjectType(a3, a4, a4); ++ __ Branch(&done_convert, hs, a4, Operand(FIRST_JS_RECEIVER_TYPE)); ++ if (mode != ConvertReceiverMode::kNotNullOrUndefined) { ++ Label convert_global_proxy; ++ __ JumpIfRoot(a3, RootIndex::kUndefinedValue, &convert_global_proxy); ++ __ JumpIfNotRoot(a3, RootIndex::kNullValue, &convert_to_object); ++ __ bind(&convert_global_proxy); ++ { ++ // Patch receiver to global proxy. ++ __ LoadGlobalProxy(a3); ++ } ++ __ Branch(&convert_receiver); ++ } ++ __ bind(&convert_to_object); ++ { ++ // Convert receiver using ToObject. ++ // TODO(bmeurer): Inline the allocation here to avoid building the frame ++ // in the fast case? (fall back to AllocateInNewSpace?) ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ SmiTag(a0); ++ __ Push(a0, a1); ++ __ mov(a0, a3); ++ __ Push(cp); ++ __ Call(BUILTIN_CODE(masm->isolate(), ToObject), ++ RelocInfo::CODE_TARGET); ++ __ Pop(cp); ++ __ mov(a3, a0); ++ __ Pop(a0, a1); ++ __ SmiUntag(a0); ++ } ++ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ bind(&convert_receiver); ++ } ++ __ StoreReceiver(a3, a0, kScratchReg); ++ } ++ __ bind(&done_convert); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // -- a2 : the shared function info. ++ // -- cp : the function context. ++ // ----------------------------------- ++ ++ __ Ld_hu( ++ a2, FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ InvokeFunctionCode(a1, no_reg, a2, a0, JUMP_FUNCTION); ++ ++ // The function is a "classConstructor", need to raise an exception. ++ __ bind(&class_constructor); ++ { ++ FrameScope frame(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowConstructorNonCallableError); ++ } ++} ++ ++// static ++void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // ----------------------------------- ++ __ AssertBoundFunction(a1); ++ ++ // Patch the receiver to [[BoundThis]]. ++ { ++ __ Ld_d(t0, FieldMemOperand(a1, JSBoundFunction::kBoundThisOffset)); ++ __ StoreReceiver(t0, a0, kScratchReg); ++ } ++ ++ // Load [[BoundArguments]] into a2 and length of that into a4. ++ __ Ld_d(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) ++ // -- a4 : the number of [[BoundArguments]] ++ // ----------------------------------- ++ ++ // Reserve stack space for the [[BoundArguments]]. ++ { ++ Label done; ++ __ slli_d(a5, a4, kPointerSizeLog2); ++ __ Sub_d(t0, sp, Operand(a5)); ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&done, hs, t0, Operand(kScratchReg)); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ } ++ __ bind(&done); ++ } ++ ++#ifdef V8_REVERSE_JSARGS ++ // Pop receiver. ++ __ Pop(t0); ++ ++ // Push [[BoundArguments]]. ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add_d(a0, a0, Operand(a4)); ++ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub_d(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a5, 0)); ++ __ Push(kScratchReg); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Push receiver. ++ __ Push(t0); ++#else ++ __ mov(sp, t0); ++ // Relocate arguments down the stack. ++ { ++ Label loop, done_loop; ++ __ mov(a5, zero_reg); ++ __ bind(&loop); ++ __ Branch(&done_loop, gt, a5, Operand(a0)); ++ __ Alsl_d(a6, a4, sp, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a6, 0)); ++ __ Alsl_d(a6, a5, sp, kPointerSizeLog2, t7); ++ __ St_d(kScratchReg, MemOperand(a6, 0)); ++ __ Add_d(a4, a4, Operand(1)); ++ __ Add_d(a5, a5, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Copy [[BoundArguments]] to the stack (below the arguments). ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub_d(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a5, 0)); ++ __ Alsl_d(a5, a0, sp, kPointerSizeLog2, t7); ++ __ St_d(kScratchReg, MemOperand(a5, 0)); ++ __ Add_d(a0, a0, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++#endif ++ ++ // Call the [[BoundTargetFunction]] via the Call builtin. ++ __ Ld_d(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), Call_ReceiverIsAny), ++ RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the target to call (can be any Object). ++ // ----------------------------------- ++ ++ Label non_callable, non_smi; ++ __ JumpIfSmi(a1, &non_callable); ++ __ bind(&non_smi); ++ __ GetObjectType(a1, t1, t2); ++ __ Jump(masm->isolate()->builtins()->CallFunction(mode), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); ++ ++ // Check if target has a [[Call]] internal method. ++ __ Ld_bu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t1, t1, Operand(Map::Bits1::IsCallableBit::kMask)); ++ __ Branch(&non_callable, eq, t1, Operand(zero_reg)); ++ ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallProxy), RelocInfo::CODE_TARGET, eq, ++ t2, Operand(JS_PROXY_TYPE)); ++ ++ // 2. Call to something else, which might have a [[Call]] internal method (if ++ // not we raise an exception). ++ // Overwrite the original receiver with the (original) target. ++ __ StoreReceiver(a1, a0, kScratchReg); ++ // Let the "call_as_function_delegate" take care of the rest. ++ __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, a1); ++ __ Jump(masm->isolate()->builtins()->CallFunction( ++ ConvertReceiverMode::kNotNullOrUndefined), ++ RelocInfo::CODE_TARGET); ++ ++ // 3. Call to something that is not callable. ++ __ bind(&non_callable); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowCalledNonCallable); ++ } ++} ++ ++void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the constructor to call (checked to be a JSFunction) ++ // -- a3 : the new target (checked to be a constructor) ++ // ----------------------------------- ++ __ AssertConstructor(a1); ++ __ AssertFunction(a1); ++ ++ // Calling convention for function specific ConstructStubs require ++ // a2 to contain either an AllocationSite or undefined. ++ __ LoadRoot(a2, RootIndex::kUndefinedValue); ++ ++ Label call_generic_stub; ++ ++ // Jump to JSBuiltinsConstructStub or JSConstructStubGeneric. ++ __ Ld_d(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_wu(a4, FieldMemOperand(a4, SharedFunctionInfo::kFlagsOffset)); ++ __ And(a4, a4, Operand(SharedFunctionInfo::ConstructAsBuiltinBit::kMask)); ++ __ Branch(&call_generic_stub, eq, a4, Operand(zero_reg)); ++ ++ __ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub), ++ RelocInfo::CODE_TARGET); ++ ++ __ bind(&call_generic_stub); ++ __ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric), ++ RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a3 : the new target (checked to be a constructor) ++ // ----------------------------------- ++ __ AssertConstructor(a1); ++ __ AssertBoundFunction(a1); ++ ++ // Load [[BoundArguments]] into a2 and length of that into a4. ++ __ Ld_d(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) ++ // -- a3 : the new target (checked to be a constructor) ++ // -- a4 : the number of [[BoundArguments]] ++ // ----------------------------------- ++ ++ // Reserve stack space for the [[BoundArguments]]. ++ { ++ Label done; ++ __ slli_d(a5, a4, kPointerSizeLog2); ++ __ Sub_d(t0, sp, Operand(a5)); ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&done, hs, t0, Operand(kScratchReg)); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ } ++ __ bind(&done); ++ } ++ ++#ifdef V8_REVERSE_JSARGS ++ // Pop receiver. ++ __ Pop(t0); ++ ++ // Push [[BoundArguments]]. ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add_d(a0, a0, Operand(a4)); ++ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub_d(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a5, 0)); ++ __ Push(kScratchReg); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Push receiver. ++ __ Push(t0); ++#else ++ __ mov(sp, t0); ++ // Relocate arguments down the stack. ++ { ++ Label loop, done_loop; ++ __ mov(a5, zero_reg); ++ __ bind(&loop); ++ __ Branch(&done_loop, ge, a5, Operand(a0)); ++ __ Alsl_d(a6, a4, sp, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a6, 0)); ++ __ Alsl_d(a6, a5, sp, kPointerSizeLog2, t7); ++ __ St_d(kScratchReg, MemOperand(a6, 0)); ++ __ Add_d(a4, a4, Operand(1)); ++ __ Add_d(a5, a5, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Copy [[BoundArguments]] to the stack (below the arguments). ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add_d(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub_d(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ Alsl_d(a5, a4, a2, kPointerSizeLog2, t7); ++ __ Ld_d(kScratchReg, MemOperand(a5, 0)); ++ __ Alsl_d(a5, a0, sp, kPointerSizeLog2, t7); ++ __ St_d(kScratchReg, MemOperand(a5, 0)); ++ __ Add_d(a0, a0, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++#endif ++ ++ // Patch new.target to [[BoundTargetFunction]] if new.target equals target. ++ { ++ Label skip_load; ++ __ Branch(&skip_load, ne, a1, Operand(a3)); ++ __ Ld_d(a3, ++ FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ bind(&skip_load); ++ } ++ ++ // Construct the [[BoundTargetFunction]] via the Construct builtin. ++ __ Ld_d(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_Construct(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the constructor to call (can be any Object) ++ // -- a3 : the new target (either the same as the constructor or ++ // the JSFunction on which new was invoked initially) ++ // ----------------------------------- ++ ++ // Check if target is a Smi. ++ Label non_constructor, non_proxy; ++ __ JumpIfSmi(a1, &non_constructor); ++ ++ // Check if target has a [[Construct]] internal method. ++ __ Ld_d(t1, FieldMemOperand(a1, HeapObject::kMapOffset)); ++ __ Ld_bu(t3, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t3, t3, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ __ Branch(&non_constructor, eq, t3, Operand(zero_reg)); ++ ++ // Dispatch based on instance type. ++ __ Ld_hu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); ++ ++ // Only dispatch to bound functions after checking whether they are ++ // constructors. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructBoundFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); ++ ++ // Only dispatch to proxies after checking whether they are constructors. ++ __ Branch(&non_proxy, ne, t2, Operand(JS_PROXY_TYPE)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy), ++ RelocInfo::CODE_TARGET); ++ ++ // Called Construct on an exotic Object with a [[Construct]] internal method. ++ __ bind(&non_proxy); ++ { ++ // Overwrite the original receiver with the (original) target. ++ __ StoreReceiver(a1, a0, kScratchReg); ++ // Let the "call_as_constructor_delegate" take care of the rest. ++ __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); ++ __ Jump(masm->isolate()->builtins()->CallFunction(), ++ RelocInfo::CODE_TARGET); ++ } ++ ++ // Called Construct on an Object that doesn't have a [[Construct]] internal ++ // method. ++ __ bind(&non_constructor); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructedNonConstructable), ++ RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ++ // State setup as expected by MacroAssembler::InvokePrologue. ++ // ----------- S t a t e ------------- ++ // -- a0: actual arguments count ++ // -- a1: function (passed through to callee) ++ // -- a2: expected arguments count ++ // -- a3: new target (passed through to callee) ++ // ----------------------------------- ++ ++ Label invoke, dont_adapt_arguments, stack_overflow; ++ ++ Label enough, too_few; ++ __ Branch(&dont_adapt_arguments, eq, a2, ++ Operand(kDontAdaptArgumentsSentinel)); ++ // We use Uless as the number of argument should always be greater than 0. ++ __ Branch(&too_few, Uless, a0, Operand(a2)); ++ ++ { // Enough parameters: actual >= expected. ++ // a0: actual number of arguments as a smi ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ bind(&enough); ++ EnterArgumentsAdaptorFrame(masm); ++ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); ++ ++ // Calculate copy start address into a0 and copy end address into a4. ++#ifdef V8_REVERSE_JSARGS ++ __ slli_d(a0, a2, kPointerSizeLog2); ++ __ Add_d(a0, fp, a0); ++#else ++ __ SmiScale(a0, a0, kPointerSizeLog2); ++ __ Add_d(a0, fp, a0); ++#endif ++ ++ // Adjust for return address and receiver. ++ __ Add_d(a0, a0, Operand(2 * kPointerSize)); ++ // Compute copy end address. ++ __ slli_d(a4, a2, kPointerSizeLog2); ++ __ sub_d(a4, a0, a4); ++ ++ // Copy the arguments (including the receiver) to the new stack frame. ++ // a0: copy start address ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ // a4: copy end address ++ ++ Label copy; ++ __ bind(©); ++ __ Ld_d(a5, MemOperand(a0, 0)); ++ __ push(a5); ++ __ addi_d(a0, a0, -kPointerSize); ++ __ Branch(©, ge, a0, Operand(a4)); ++ ++ __ jmp(&invoke); ++ } ++ ++ { // Too few parameters: Actual < expected. ++ __ bind(&too_few); ++ EnterArgumentsAdaptorFrame(masm); ++ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); ++ ++#ifdef V8_REVERSE_JSARGS ++ // Fill the remaining expected arguments with undefined. ++ __ LoadRoot(t0, RootIndex::kUndefinedValue); ++ __ SmiUntag(t1, a0); ++ __ Sub_d(t2, a2, Operand(t1)); ++ __ slli_d(a4, t2, kSystemPointerSizeLog2); ++ __ Sub_d(a4, fp, a4); ++ // Adjust for frame. ++ __ Sub_d(a4, a4, ++ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + ++ kSystemPointerSize)); ++ ++ Label fill; ++ __ bind(&fill); ++ __ push(t0); ++ __ Branch(&fill, ne, sp, Operand(a4)); ++ ++ // Calculate copy start address into r0 and copy end address is fp. ++ __ SmiScale(a0, a0, kPointerSizeLog2); ++ __ Add_d(a0, fp, a0); ++ ++ // Copy the arguments (including the receiver) to the new stack frame. ++ Label copy; ++ __ bind(©); ++ ++ // Adjust load for return address and receiver. ++ __ Ld_d(t0, MemOperand(a0, 2 * kSystemPointerSize)); ++ __ push(t0); ++ ++ __ Sub_d(a0, a0, Operand(kSystemPointerSize)); ++ __ Branch(©, ge, a0, Operand(fp)); ++#else ++ // Calculate copy start address into a0 and copy end address into a7. ++ // a0: actual number of arguments as a smi ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ SmiScale(a0, a0, kPointerSizeLog2); ++ __ Add_d(a0, fp, a0); ++ // Adjust for return address and receiver. ++ __ Add_d(a0, a0, Operand(2 * kPointerSize)); ++ // Compute copy end address. Also adjust for return address. ++ __ Add_d(a7, fp, kPointerSize); ++ ++ // Copy the arguments (including the receiver) to the new stack frame. ++ // a0: copy start address ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ // a7: copy end address ++ Label copy; ++ __ bind(©); ++ __ Ld_d(a4, ++ MemOperand(a0, 0)); // Adjusted above for return addr and receiver. ++ __ Sub_d(sp, sp, kPointerSize); ++ __ Sub_d(a0, a0, kPointerSize); ++ __ St_d(a4, MemOperand(sp, 0)); ++ __ Branch(©, ne, a0, Operand(a7)); ++ ++ // Fill the remaining expected arguments with undefined. ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ slli_d(a6, a2, kPointerSizeLog2); ++ __ Sub_d(a4, fp, Operand(a6)); ++ // Adjust for frame. ++ __ Sub_d(a4, a4, ++ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + ++ kPointerSize)); ++ ++ Label fill; ++ __ bind(&fill); ++ __ Sub_d(sp, sp, kPointerSize); ++ __ St_d(a5, MemOperand(sp, 0)); ++ __ Branch(&fill, ne, sp, Operand(a4)); ++#endif ++ } ++ ++ // Call the entry point. ++ __ bind(&invoke); ++ __ mov(a0, a2); ++ // a0 : expected number of arguments ++ // a1 : function (passed through to callee) ++ // a3: new target (passed through to callee) ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Call(a2); ++ ++ // Store offset of return address for deoptimizer. ++ masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); ++ ++ // Exit frame and return. ++ LeaveArgumentsAdaptorFrame(masm); ++ __ Ret(); ++ ++ // ------------------------------------------- ++ // Don't adapt arguments. ++ // ------------------------------------------- ++ __ bind(&dont_adapt_arguments); ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld_d(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ ++ __ bind(&stack_overflow); ++ { ++ FrameScope frame(masm, StackFrame::MANUAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ __ break_(0xCC); ++ } ++} ++ ++void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { ++ // The function index was put in t0 by the jump table trampoline. ++ // Convert to Smi for the runtime call ++ __ SmiTag(kWasmCompileLazyFuncIndexRegister); ++ { ++ HardAbortScope hard_abort(masm); // Avoid calls to Abort. ++ FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); ++ ++ // Save all parameter registers (see wasm-linkage.cc). They might be ++ // overwritten in the runtime call below. We don't have any callee-saved ++ // registers in wasm, so no need to store anything else. ++ constexpr RegList gp_regs = Register::ListOf(a0, a2, a3, a4, a5, a6, a7); ++ constexpr RegList fp_regs = ++ DoubleRegister::ListOf(f2, f4, f6, f8, f10, f12, f14); ++ constexpr int16_t num_to_push = base::bits::CountPopulation(gp_regs) + ++ base::bits::CountPopulation(fp_regs); ++ // The number of regs to be pushed before kWasmInstanceRegister should be ++ // equal to kNumberOfSavedAllParamRegs. ++ STATIC_ASSERT(num_to_push == ++ WasmCompileLazyFrameConstants::kNumberOfSavedAllParamRegs); ++ __ MultiPush(gp_regs); ++ __ MultiPushFPU(fp_regs); ++ ++ // Pass instance and function index as an explicit arguments to the runtime ++ // function. ++ __ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister); ++ // Initialize the JavaScript context with 0. CEntry will use it to ++ // set the current context on the isolate. ++ __ Move(kContextRegister, Smi::zero()); ++ __ CallRuntime(Runtime::kWasmCompileLazy, 2); ++ __ mov(t8, a0); ++ ++ // Restore registers. ++ __ MultiPopFPU(fp_regs); ++ __ MultiPop(gp_regs); ++ } ++ // Finally, jump to the entrypoint. ++ __ Jump(t8); ++} ++ ++void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) { ++ HardAbortScope hard_abort(masm); // Avoid calls to Abort. ++ { ++ FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK); ++ ++ // Save all parameter registers. They might hold live values, we restore ++ // them after the runtime call. ++ __ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs); ++ __ MultiPushFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); ++ ++ // Initialize the JavaScript context with 0. CEntry will use it to ++ // set the current context on the isolate. ++ __ Move(cp, Smi::zero()); ++ __ CallRuntime(Runtime::kWasmDebugBreak, 0); ++ ++ // Restore registers. ++ __ MultiPopFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); ++ __ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs); ++ } ++ __ Ret(); ++} ++ ++void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, ++ SaveFPRegsMode save_doubles, ArgvMode argv_mode, ++ bool builtin_exit_frame) { ++ // Called from JavaScript; parameters are on stack as if calling JS function ++ // a0: number of arguments including receiver ++ // a1: pointer to builtin function ++ // fp: frame pointer (restored after C call) ++ // sp: stack pointer (restored as callee's sp after C call) ++ // cp: current context (C callee-saved) ++ // ++ // If argv_mode == kArgvInRegister: ++ // a2: pointer to the first argument ++ ++ if (argv_mode == kArgvInRegister) { ++ // Move argv into the correct register. ++ __ mov(s1, a2); ++ } else { ++ // Compute the argv pointer in a callee-saved register. ++ __ Alsl_d(s1, a0, sp, kPointerSizeLog2, t7); ++ __ Sub_d(s1, s1, kPointerSize); ++ } ++ ++ // Enter the exit frame that transitions from JavaScript to C++. ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame( ++ save_doubles == kSaveFPRegs, 0, ++ builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT); ++ ++ // s0: number of arguments including receiver (C callee-saved) ++ // s1: pointer to first argument (C callee-saved) ++ // s2: pointer to builtin function (C callee-saved) ++ ++ // Prepare arguments for C routine. ++ // a0 = argc ++ __ mov(s0, a0); ++ __ mov(s2, a1); ++ ++ // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We ++ // also need to reserve the 4 argument slots on the stack. ++ ++ __ AssertStackIsAligned(); ++ ++ // a0 = argc, a1 = argv, a2 = isolate ++ __ li(a2, ExternalReference::isolate_address(masm->isolate())); ++ __ mov(a1, s1); ++ ++ __ StoreReturnAddressAndCall(s2); ++ ++ // Result returned in a0 or a1:a0 - do not destroy these registers! ++ ++ // Check result for exception sentinel. ++ Label exception_returned; ++ __ LoadRoot(a4, RootIndex::kException); ++ __ Branch(&exception_returned, eq, a4, Operand(a0)); ++ ++ // Check that there is no pending exception, otherwise we ++ // should have returned the exception sentinel. ++ if (FLAG_debug_code) { ++ Label okay; ++ ExternalReference pending_exception_address = ExternalReference::Create( ++ IsolateAddressId::kPendingExceptionAddress, masm->isolate()); ++ __ li(a2, pending_exception_address); ++ __ Ld_d(a2, MemOperand(a2, 0)); ++ __ LoadRoot(a4, RootIndex::kTheHoleValue); ++ // Cannot use check here as it attempts to generate call into runtime. ++ __ Branch(&okay, eq, a4, Operand(a2)); ++ __ stop(); ++ __ bind(&okay); ++ } ++ ++ // Exit C frame and return. ++ // a0:a1: result ++ // sp: stack pointer ++ // fp: frame pointer ++ Register argc = argv_mode == kArgvInRegister ++ // We don't want to pop arguments so set argc to no_reg. ++ ? no_reg ++ // s0: still holds argc (callee-saved). ++ : s0; ++ __ LeaveExitFrame(save_doubles == kSaveFPRegs, argc, EMIT_RETURN); ++ ++ // Handling of exception. ++ __ bind(&exception_returned); ++ ++ ExternalReference pending_handler_context_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerContextAddress, masm->isolate()); ++ ExternalReference pending_handler_entrypoint_address = ++ ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate()); ++ ExternalReference pending_handler_fp_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerFPAddress, masm->isolate()); ++ ExternalReference pending_handler_sp_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerSPAddress, masm->isolate()); ++ ++ // Ask the runtime for help to determine the handler. This will set a0 to ++ // contain the current pending exception, don't clobber it. ++ ExternalReference find_handler = ++ ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ PrepareCallCFunction(3, 0, a0); ++ __ mov(a0, zero_reg); ++ __ mov(a1, zero_reg); ++ __ li(a2, ExternalReference::isolate_address(masm->isolate())); ++ __ CallCFunction(find_handler, 3); ++ } ++ ++ // Retrieve the handler context, SP and FP. ++ __ li(cp, pending_handler_context_address); ++ __ Ld_d(cp, MemOperand(cp, 0)); ++ __ li(sp, pending_handler_sp_address); ++ __ Ld_d(sp, MemOperand(sp, 0)); ++ __ li(fp, pending_handler_fp_address); ++ __ Ld_d(fp, MemOperand(fp, 0)); ++ ++ // If the handler is a JS frame, restore the context to the frame. Note that ++ // the context will be set to (cp == 0) for non-JS frames. ++ Label zero; ++ __ Branch(&zero, eq, cp, Operand(zero_reg)); ++ __ St_d(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); ++ __ bind(&zero); ++ ++ // Reset the masking register. This is done independent of the underlying ++ // feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work ++ // with both configurations. It is safe to always do this, because the ++ // underlying register is caller-saved and can be arbitrarily clobbered. ++ __ ResetSpeculationPoisonRegister(); ++ ++ // Compute the handler entry address and jump to it. ++ __ li(t7, pending_handler_entrypoint_address); ++ __ Ld_d(t7, MemOperand(t7, 0)); ++ __ Jump(t7); ++} ++ ++void Builtins::Generate_DoubleToI(MacroAssembler* masm) { ++ Label done; ++ Register result_reg = t0; ++ ++ Register scratch = GetRegisterThatIsNotOneOf(result_reg); ++ Register scratch2 = GetRegisterThatIsNotOneOf(result_reg, scratch); ++ Register scratch3 = GetRegisterThatIsNotOneOf(result_reg, scratch, scratch2); ++ DoubleRegister double_scratch = kScratchDoubleReg; ++ ++ // Account for saved regs. ++ const int kArgumentOffset = 4 * kPointerSize; ++ ++ __ Push(result_reg); ++ __ Push(scratch, scratch2, scratch3); ++ ++ // Load double input. ++ __ Fld_d(double_scratch, MemOperand(sp, kArgumentOffset)); ++ ++ // Clear cumulative exception flags and save the FCSR. ++ // __ movfcsr2gr(scratch2, FCSR); ++ // __ movgr2fcsr(FCSR, zero_reg); ++ ++ // Try a conversion to a signed integer. ++ __ ftintrz_w_d(double_scratch, double_scratch); ++ // Move the converted value into the result register. ++ __ movfr2gr_s(scratch3, double_scratch); ++ ++ // Retrieve and restore the FCSR. ++ __ movfcsr2gr(scratch); // __ cfc1(scratch, FCSR); ++ // __ ctc1(scratch2, FCSR); ++ ++ // Check for overflow and NaNs. ++ __ And( ++ scratch, scratch, ++ kFCSROverflowFlagMask | kFCSRUnderflowFlagMask | kFCSRInvalidOpFlagMask); ++ // If we had no exceptions then set result_reg and we are done. ++ Label error; ++ __ Branch(&error, ne, scratch, Operand(zero_reg)); ++ __ Move(result_reg, scratch3); ++ __ Branch(&done); ++ __ bind(&error); ++ ++ // Load the double value and perform a manual truncation. ++ Register input_high = scratch2; ++ Register input_low = scratch3; ++ ++ __ Ld_w(input_low, ++ MemOperand(sp, kArgumentOffset + Register::kMantissaOffset)); ++ __ Ld_w(input_high, ++ MemOperand(sp, kArgumentOffset + Register::kExponentOffset)); ++ ++ Label normal_exponent; ++ // Extract the biased exponent in result. ++ __ bstrpick_w(result_reg, input_high, ++ HeapNumber::kExponentShift + HeapNumber::kExponentBits - 1, ++ HeapNumber::kExponentShift); ++ ++ // Check for Infinity and NaNs, which should return 0. ++ __ Sub_w(scratch, result_reg, HeapNumber::kExponentMask); ++ __ Movz(result_reg, zero_reg, scratch); ++ __ Branch(&done, eq, scratch, Operand(zero_reg)); ++ ++ // Express exponent as delta to (number of mantissa bits + 31). ++ __ Sub_w(result_reg, result_reg, ++ Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits + 31)); ++ ++ // If the delta is strictly positive, all bits would be shifted away, ++ // which means that we can return 0. ++ __ Branch(&normal_exponent, le, result_reg, Operand(zero_reg)); ++ __ mov(result_reg, zero_reg); ++ __ Branch(&done); ++ ++ __ bind(&normal_exponent); ++ const int kShiftBase = HeapNumber::kNonMantissaBitsInTopWord - 1; ++ // Calculate shift. ++ __ Add_w(scratch, result_reg, ++ Operand(kShiftBase + HeapNumber::kMantissaBits)); ++ ++ // Save the sign. ++ Register sign = result_reg; ++ result_reg = no_reg; ++ __ And(sign, input_high, Operand(HeapNumber::kSignMask)); ++ ++ // On ARM shifts > 31 bits are valid and will result in zero. On MIPS we need ++ // to check for this specific case. ++ Label high_shift_needed, high_shift_done; ++ __ Branch(&high_shift_needed, lt, scratch, Operand(32)); ++ __ mov(input_high, zero_reg); ++ __ Branch(&high_shift_done); ++ __ bind(&high_shift_needed); ++ ++ // Set the implicit 1 before the mantissa part in input_high. ++ __ Or(input_high, input_high, ++ Operand(1 << HeapNumber::kMantissaBitsInTopWord)); ++ // Shift the mantissa bits to the correct position. ++ // We don't need to clear non-mantissa bits as they will be shifted away. ++ // If they weren't, it would mean that the answer is in the 32bit range. ++ __ sll_w(input_high, input_high, scratch); ++ ++ __ bind(&high_shift_done); ++ ++ // Replace the shifted bits with bits from the lower mantissa word. ++ Label pos_shift, shift_done; ++ __ li(kScratchReg, 32); ++ __ sub_w(scratch, kScratchReg, scratch); ++ __ Branch(&pos_shift, ge, scratch, Operand(zero_reg)); ++ ++ // Negate scratch. ++ __ Sub_w(scratch, zero_reg, scratch); ++ __ sll_w(input_low, input_low, scratch); ++ __ Branch(&shift_done); ++ ++ __ bind(&pos_shift); ++ __ srl_w(input_low, input_low, scratch); ++ ++ __ bind(&shift_done); ++ __ Or(input_high, input_high, Operand(input_low)); ++ // Restore sign if necessary. ++ __ mov(scratch, sign); ++ result_reg = sign; ++ sign = no_reg; ++ __ Sub_w(result_reg, zero_reg, input_high); ++ __ Movz(result_reg, input_high, scratch); ++ ++ __ bind(&done); ++ ++ __ St_d(result_reg, MemOperand(sp, kArgumentOffset)); ++ __ Pop(scratch, scratch2, scratch3); ++ __ Pop(result_reg); ++ __ Ret(); ++} ++ ++void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) { ++ // TODO(v8:10701): Implement for this platform. ++ __ Trap(); ++} ++ ++namespace { ++ ++int AddressOffset(ExternalReference ref0, ExternalReference ref1) { ++ int64_t offset = (ref0.address() - ref1.address()); ++ DCHECK(static_cast(offset) == offset); ++ return static_cast(offset); ++} ++ ++// Calls an API function. Allocates HandleScope, extracts returned value ++// from handle and propagates exceptions. Restores context. stack_space ++// - space to be unwound on exit (includes the call JS arguments space and ++// the additional space allocated for the fast call). ++void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address, ++ ExternalReference thunk_ref, int stack_space, ++ MemOperand* stack_space_operand, ++ MemOperand return_value_operand) { ++ Isolate* isolate = masm->isolate(); ++ ExternalReference next_address = ++ ExternalReference::handle_scope_next_address(isolate); ++ const int kNextOffset = 0; ++ const int kLimitOffset = AddressOffset( ++ ExternalReference::handle_scope_limit_address(isolate), next_address); ++ const int kLevelOffset = AddressOffset( ++ ExternalReference::handle_scope_level_address(isolate), next_address); ++ ++ DCHECK(function_address == a1 || function_address == a2); ++ ++ Label profiler_enabled, end_profiler_check; ++ __ li(t7, ExternalReference::is_profiling_address(isolate)); ++ __ Ld_b(t7, MemOperand(t7, 0)); ++ __ Branch(&profiler_enabled, ne, t7, Operand(zero_reg)); ++ __ li(t7, ExternalReference::address_of_runtime_stats_flag()); ++ __ Ld_w(t7, MemOperand(t7, 0)); ++ __ Branch(&profiler_enabled, ne, t7, Operand(zero_reg)); ++ { ++ // Call the api function directly. ++ __ mov(t7, function_address); ++ __ Branch(&end_profiler_check); ++ } ++ ++ __ bind(&profiler_enabled); ++ { ++ // Additional parameter is the address of the actual callback. ++ __ li(t7, thunk_ref); ++ } ++ __ bind(&end_profiler_check); ++ ++ // Allocate HandleScope in callee-save registers. ++ __ li(s5, next_address); ++ __ Ld_d(s0, MemOperand(s5, kNextOffset)); ++ __ Ld_d(s1, MemOperand(s5, kLimitOffset)); ++ __ Ld_w(s2, MemOperand(s5, kLevelOffset)); ++ __ Add_w(s2, s2, Operand(1)); ++ __ St_w(s2, MemOperand(s5, kLevelOffset)); ++ ++ __ StoreReturnAddressAndCall(t7); ++ ++ Label promote_scheduled_exception; ++ Label delete_allocated_handles; ++ Label leave_exit_frame; ++ Label return_value_loaded; ++ ++ // Load value from ReturnValue. ++ __ Ld_d(a0, return_value_operand); ++ __ bind(&return_value_loaded); ++ ++ // No more valid handles (the result handle was the last one). Restore ++ // previous handle scope. ++ __ St_d(s0, MemOperand(s5, kNextOffset)); ++ if (__ emit_debug_code()) { ++ __ Ld_w(a1, MemOperand(s5, kLevelOffset)); ++ __ Check(eq, AbortReason::kUnexpectedLevelAfterReturnFromApiCall, a1, ++ Operand(s2)); ++ } ++ __ Sub_w(s2, s2, Operand(1)); ++ __ St_w(s2, MemOperand(s5, kLevelOffset)); ++ __ Ld_d(kScratchReg, MemOperand(s5, kLimitOffset)); ++ __ Branch(&delete_allocated_handles, ne, s1, Operand(kScratchReg)); ++ ++ // Leave the API exit frame. ++ __ bind(&leave_exit_frame); ++ ++ if (stack_space_operand == nullptr) { ++ DCHECK_NE(stack_space, 0); ++ __ li(s0, Operand(stack_space)); ++ } else { ++ DCHECK_EQ(stack_space, 0); ++ STATIC_ASSERT(kCArgSlotCount == 0); ++ __ Ld_d(s0, *stack_space_operand); ++ } ++ ++ static constexpr bool kDontSaveDoubles = false; ++ static constexpr bool kRegisterContainsSlotCount = false; ++ __ LeaveExitFrame(kDontSaveDoubles, s0, NO_EMIT_RETURN, ++ kRegisterContainsSlotCount); ++ ++ // Check if the function scheduled an exception. ++ __ LoadRoot(a4, RootIndex::kTheHoleValue); ++ __ li(kScratchReg, ExternalReference::scheduled_exception_address(isolate)); ++ __ Ld_d(a5, MemOperand(kScratchReg, 0)); ++ __ Branch(&promote_scheduled_exception, ne, a4, Operand(a5)); ++ ++ __ Ret(); ++ ++ // Re-throw by promoting a scheduled exception. ++ __ bind(&promote_scheduled_exception); ++ __ TailCallRuntime(Runtime::kPromoteScheduledException); ++ ++ // HandleScope limit has changed. Delete allocated extensions. ++ __ bind(&delete_allocated_handles); ++ __ St_d(s1, MemOperand(s5, kLimitOffset)); ++ __ mov(s0, a0); ++ __ PrepareCallCFunction(1, s1); ++ __ li(a0, ExternalReference::isolate_address(isolate)); ++ __ CallCFunction(ExternalReference::delete_handle_scope_extensions(), 1); ++ __ mov(a0, s0); ++ __ jmp(&leave_exit_frame); ++} ++ ++} // namespace ++ ++void Builtins::Generate_CallApiCallback(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- cp : context ++ // -- a1 : api function address ++ // -- a2 : arguments count (not including the receiver) ++ // -- a3 : call data ++ // -- a0 : holder ++ // -- ++ // -- sp[0] : last argument ++ // -- ... ++ // -- sp[(argc - 1) * 8] : first argument ++ // -- sp[(argc + 0) * 8] : receiver ++ // ----------------------------------- ++ ++ Register api_function_address = a1; ++ Register argc = a2; ++ Register call_data = a3; ++ Register holder = a0; ++ Register scratch = t0; ++ Register base = t1; // For addressing MemOperands on the stack. ++ ++ DCHECK(!AreAliased(api_function_address, argc, call_data, holder, scratch, ++ base)); ++ ++ using FCA = FunctionCallbackArguments; ++ ++ STATIC_ASSERT(FCA::kArgsLength == 6); ++ STATIC_ASSERT(FCA::kNewTargetIndex == 5); ++ STATIC_ASSERT(FCA::kDataIndex == 4); ++ STATIC_ASSERT(FCA::kReturnValueOffset == 3); ++ STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); ++ STATIC_ASSERT(FCA::kIsolateIndex == 1); ++ STATIC_ASSERT(FCA::kHolderIndex == 0); ++ ++ // Set up FunctionCallbackInfo's implicit_args on the stack as follows: ++ // ++ // Target state: ++ // sp[0 * kPointerSize]: kHolder ++ // sp[1 * kPointerSize]: kIsolate ++ // sp[2 * kPointerSize]: undefined (kReturnValueDefaultValue) ++ // sp[3 * kPointerSize]: undefined (kReturnValue) ++ // sp[4 * kPointerSize]: kData ++ // sp[5 * kPointerSize]: undefined (kNewTarget) ++ ++ // Set up the base register for addressing through MemOperands. It will point ++ // at the receiver (located at sp + argc * kPointerSize). ++ __ Alsl_d(base, argc, sp, kPointerSizeLog2, t7); ++ ++ // Reserve space on the stack. ++ __ Sub_d(sp, sp, Operand(FCA::kArgsLength * kPointerSize)); ++ ++ // kHolder. ++ __ St_d(holder, MemOperand(sp, 0 * kPointerSize)); ++ ++ // kIsolate. ++ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); ++ __ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); ++ ++ // kReturnValueDefaultValue and kReturnValue. ++ __ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ __ St_d(scratch, MemOperand(sp, 2 * kPointerSize)); ++ __ St_d(scratch, MemOperand(sp, 3 * kPointerSize)); ++ ++ // kData. ++ __ St_d(call_data, MemOperand(sp, 4 * kPointerSize)); ++ ++ // kNewTarget. ++ __ St_d(scratch, MemOperand(sp, 5 * kPointerSize)); ++ ++ // Keep a pointer to kHolder (= implicit_args) in a scratch register. ++ // We use it below to set up the FunctionCallbackInfo object. ++ __ mov(scratch, sp); ++ ++ // Allocate the v8::Arguments structure in the arguments' space since ++ // it's not controlled by GC. ++ static constexpr int kApiStackSpace = 4; ++ static constexpr bool kDontSaveDoubles = false; ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame(kDontSaveDoubles, kApiStackSpace); ++ ++ // EnterExitFrame may align the sp. ++ ++ // FunctionCallbackInfo::implicit_args_ (points at kHolder as set up above). ++ // Arguments are after the return address (pushed by EnterExitFrame()). ++ __ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); ++ ++ // FunctionCallbackInfo::values_ (points at the first varargs argument passed ++ // on the stack). ++#ifdef V8_REVERSE_JSARGS ++ __ Add_d(scratch, scratch, ++ Operand((FCA::kArgsLength + 1) * kSystemPointerSize)); ++#else ++ __ Add_d(scratch, scratch, ++ Operand((FCA::kArgsLength - 1) * kSystemPointerSize)); ++ __ slli_d(t2, argc, kSystemPointerSizeLog2); ++ __ Add_d(scratch, scratch, t2); ++#endif ++ ++ __ St_d(scratch, MemOperand(sp, 2 * kPointerSize)); ++ ++ // FunctionCallbackInfo::length_. ++ // Stored as int field, 32-bit integers within struct on stack always left ++ // justified by n64 ABI. ++ __ St_w(argc, MemOperand(sp, 3 * kPointerSize)); ++ ++ // We also store the number of bytes to drop from the stack after returning ++ // from the API function here. ++ // Note: Unlike on other architectures, this stores the number of slots to ++ // drop, not the number of bytes. ++ __ Add_d(scratch, argc, Operand(FCA::kArgsLength + 1 /* receiver */)); ++ __ St_d(scratch, MemOperand(sp, 4 * kPointerSize)); ++ ++ // v8::InvocationCallback's argument. ++ DCHECK(!AreAliased(api_function_address, scratch, a0)); ++ __ Add_d(a0, sp, Operand(1 * kPointerSize)); ++ ++ ExternalReference thunk_ref = ExternalReference::invoke_function_callback(); ++ ++ // There are two stack slots above the arguments we constructed on the stack. ++ // TODO(jgruber): Document what these arguments are. ++ static constexpr int kStackSlotsAboveFCA = 2; ++ MemOperand return_value_operand( ++ fp, (kStackSlotsAboveFCA + FCA::kReturnValueOffset) * kPointerSize); ++ ++ static constexpr int kUseStackSpaceOperand = 0; ++ MemOperand stack_space_operand(sp, 4 * kPointerSize); ++ ++ AllowExternalCallThatCantCauseGC scope(masm); ++ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, ++ kUseStackSpaceOperand, &stack_space_operand, ++ return_value_operand); ++} ++ ++void Builtins::Generate_CallApiGetter(MacroAssembler* masm) { ++ // Build v8::PropertyCallbackInfo::args_ array on the stack and push property ++ // name below the exit frame to make GC aware of them. ++ STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); ++ STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); ++ STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); ++ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); ++ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); ++ STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); ++ STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); ++ STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); ++ ++ Register receiver = ApiGetterDescriptor::ReceiverRegister(); ++ Register holder = ApiGetterDescriptor::HolderRegister(); ++ Register callback = ApiGetterDescriptor::CallbackRegister(); ++ Register scratch = a4; ++ DCHECK(!AreAliased(receiver, holder, callback, scratch)); ++ ++ Register api_function_address = a2; ++ ++ // Here and below +1 is for name() pushed after the args_ array. ++ using PCA = PropertyCallbackArguments; ++ __ Sub_d(sp, sp, (PCA::kArgsLength + 1) * kPointerSize); ++ __ St_d(receiver, MemOperand(sp, (PCA::kThisIndex + 1) * kPointerSize)); ++ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kDataOffset)); ++ __ St_d(scratch, MemOperand(sp, (PCA::kDataIndex + 1) * kPointerSize)); ++ __ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ __ St_d(scratch, ++ MemOperand(sp, (PCA::kReturnValueOffset + 1) * kPointerSize)); ++ __ St_d(scratch, MemOperand(sp, (PCA::kReturnValueDefaultValueIndex + 1) * ++ kPointerSize)); ++ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); ++ __ St_d(scratch, MemOperand(sp, (PCA::kIsolateIndex + 1) * kPointerSize)); ++ __ St_d(holder, MemOperand(sp, (PCA::kHolderIndex + 1) * kPointerSize)); ++ // should_throw_on_error -> false ++ DCHECK_EQ(0, Smi::zero().ptr()); ++ __ St_d(zero_reg, ++ MemOperand(sp, (PCA::kShouldThrowOnErrorIndex + 1) * kPointerSize)); ++ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kNameOffset)); ++ __ St_d(scratch, MemOperand(sp, 0 * kPointerSize)); ++ ++ // v8::PropertyCallbackInfo::args_ array and name handle. ++ const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; ++ ++ // Load address of v8::PropertyAccessorInfo::args_ array and name handle. ++ __ mov(a0, sp); // a0 = Handle ++ __ Add_d(a1, a0, Operand(1 * kPointerSize)); // a1 = v8::PCI::args_ ++ ++ const int kApiStackSpace = 1; ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame(false, kApiStackSpace); ++ ++ // Create v8::PropertyCallbackInfo object on the stack and initialize ++ // it's args_ field. ++ __ St_d(a1, MemOperand(sp, 1 * kPointerSize)); ++ __ Add_d(a1, sp, Operand(1 * kPointerSize)); ++ // a1 = v8::PropertyCallbackInfo& ++ ++ ExternalReference thunk_ref = ++ ExternalReference::invoke_accessor_getter_callback(); ++ ++ __ Ld_d(scratch, FieldMemOperand(callback, AccessorInfo::kJsGetterOffset)); ++ __ Ld_d(api_function_address, ++ FieldMemOperand(scratch, Foreign::kForeignAddressOffset)); ++ ++ // +3 is to skip prolog, return address and name handle. ++ MemOperand return_value_operand( ++ fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); ++ MemOperand* const kUseStackSpaceConstant = nullptr; ++ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, ++ kStackUnwindSpace, kUseStackSpaceConstant, ++ return_value_operand); ++} ++ ++void Builtins::Generate_DirectCEntry(MacroAssembler* masm) { ++ // The sole purpose of DirectCEntry is for movable callers (e.g. any general ++ // purpose Code object) to be able to call into C functions that may trigger ++ // GC and thus move the caller. ++ // ++ // DirectCEntry places the return address on the stack (updated by the GC), ++ // making the call GC safe. The irregexp backend relies on this. ++ ++ // Make place for arguments to fit C calling convention. Callers use ++ // EnterExitFrame/LeaveExitFrame so they handle stack restoring and we don't ++ // have to do that here. Any caller must drop kCArgsSlotsSize stack space ++ // after the call. ++ __ addi_d(sp, sp, -kCArgsSlotsSize); ++ ++ __ St_d(ra, MemOperand(sp, kCArgsSlotsSize)); // Store the return address. ++ __ Call(t7); // Call the C++ function. ++ __ Ld_d(t7, MemOperand(sp, kCArgsSlotsSize)); // Return to calling code. ++ ++ if (FLAG_debug_code && FLAG_enable_slow_asserts) { ++ // In case of an error the return address may point to a memory area ++ // filled with kZapValue by the GC. Dereference the address and check for ++ // this. ++ __ Ld_d(a4, MemOperand(t7, 0)); ++ __ Assert(ne, AbortReason::kReceivedInvalidReturnAddress, a4, ++ Operand(reinterpret_cast(kZapValue))); ++ } ++ ++ __ Jump(t7); ++} ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h +@@ -17,6 +17,8 @@ + #include "src/codegen/arm/assembler-arm.h" + #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 + #include "src/codegen/ppc/assembler-ppc.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/codegen/loongarch64/assembler-loongarch64.h" + #elif V8_TARGET_ARCH_MIPS + #include "src/codegen/mips/assembler-mips.h" + #elif V8_TARGET_ARCH_MIPS64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/assembler-arch.h +++++ src/3rdparty/chromium/v8/src/codegen/assembler-arch.h ++@@ -17,6 +17,8 @@ ++ #include "src/codegen/arm/assembler-arm.h" ++ #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 ++ #include "src/codegen/ppc/assembler-ppc.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/codegen/loongarch64/assembler-loongarch64.h" ++ #elif V8_TARGET_ARCH_MIPS ++ #include "src/codegen/mips/assembler-mips.h" ++ #elif V8_TARGET_ARCH_MIPS64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h +@@ -21,6 +21,8 @@ + #include "src/codegen/mips/assembler-mips-inl.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/codegen/mips64/assembler-mips64-inl.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/assembler-s390-inl.h" + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/assembler-inl.h +++++ src/3rdparty/chromium/v8/src/codegen/assembler-inl.h ++@@ -21,6 +21,8 @@ ++ #include "src/codegen/mips/assembler-mips-inl.h" ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/codegen/mips64/assembler-mips64-inl.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" ++ #elif V8_TARGET_ARCH_S390 ++ #include "src/codegen/s390/assembler-s390-inl.h" ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/assembler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler.h +@@ -258,7 +258,8 @@ class V8_EXPORT_PRIVATE AssemblerBase : + int pc_offset() const { return static_cast(pc_ - buffer_start_); } + + int pc_offset_for_safepoint() { +-#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) ++#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ ++ defined(V8_TARGET_ARCH_LOONGARCH64) + // Mips needs it's own implementation to avoid trampoline's influence. + UNREACHABLE(); + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/assembler.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/src/codegen/assembler.h +++++ src/3rdparty/chromium/v8/src/codegen/assembler.h ++@@ -258,7 +258,8 @@ class V8_EXPORT_PRIVATE AssemblerBase : public Malloced { ++ int pc_offset() const { return static_cast(pc_ - buffer_start_); } ++ ++ int pc_offset_for_safepoint() { ++-#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) +++#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ +++ defined(V8_TARGET_ARCH_LOONGARCH64) ++ // Mips needs it's own implementation to avoid trampoline's influence. ++ UNREACHABLE(); ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/constants-arch.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/constants-arch.h +@@ -11,6 +11,8 @@ + #include "src/codegen/arm64/constants-arm64.h" // NOLINT + #elif V8_TARGET_ARCH_IA32 + #include "src/codegen/ia32/constants-ia32.h" // NOLINT ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/codegen/loongarch64/constants-loongarch64.h" // NOLINT + #elif V8_TARGET_ARCH_MIPS + #include "src/codegen/mips/constants-mips.h" // NOLINT + #elif V8_TARGET_ARCH_MIPS64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/constants-arch.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/constants-arch.h +++++ src/3rdparty/chromium/v8/src/codegen/constants-arch.h ++@@ -11,6 +11,8 @@ ++ #include "src/codegen/arm64/constants-arm64.h" // NOLINT ++ #elif V8_TARGET_ARCH_IA32 ++ #include "src/codegen/ia32/constants-ia32.h" // NOLINT +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/codegen/loongarch64/constants-loongarch64.h" // NOLINT ++ #elif V8_TARGET_ARCH_MIPS ++ #include "src/codegen/mips/constants-mips.h" // NOLINT ++ #elif V8_TARGET_ARCH_MIPS64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/cpu-features.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/cpu-features.h +@@ -50,6 +50,9 @@ enum CpuFeature { + MIPSr6, + MIPS_SIMD, // MSA instructions + ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ FPU, // TODO ++ + #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 + FPU, + FPR_GPR_MOV, +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/cpu-features.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/src/codegen/cpu-features.h +++++ src/3rdparty/chromium/v8/src/codegen/cpu-features.h ++@@ -50,6 +50,9 @@ enum CpuFeature { ++ MIPSr6, ++ MIPS_SIMD, // MSA instructions ++ +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ FPU, // TODO +++ ++ #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 ++ FPU, ++ FPR_GPR_MOV, +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/external-reference.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/external-reference.cc +@@ -500,6 +500,8 @@ ExternalReference ExternalReference::inv + #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState + #elif V8_TARGET_ARCH_MIPS64 + #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#define re_stack_check_func RegExpMacroAssemblerLA64::CheckStackGuardState + #elif V8_TARGET_ARCH_S390 + #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/external-reference.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/external-reference.cc +++++ src/3rdparty/chromium/v8/src/codegen/external-reference.cc ++@@ -500,6 +500,8 @@ ExternalReference ExternalReference::invoke_accessor_getter_callback() { ++ #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState ++ #elif V8_TARGET_ARCH_MIPS64 ++ #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#define re_stack_check_func RegExpMacroAssemblerLA64::CheckStackGuardState ++ #elif V8_TARGET_ARCH_S390 ++ #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc +@@ -131,7 +131,8 @@ const char* CallInterfaceDescriptor::Deb + return ""; + } + +-#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) ++#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ ++ !defined(V8_TARGET_ARCH_LOONGARCH64) + bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) { + return true; + } +@@ -397,7 +398,8 @@ void WasmFloat64ToNumberDescriptor::Init + } + #endif // !V8_TARGET_ARCH_IA32 + +-#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) ++#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ ++ !defined(V8_TARGET_ARCH_LOONGARCH64) + void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( + CallInterfaceDescriptorData* data) { + DefaultInitializePlatformSpecific(data, kParameterCount); +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc.rej +@@ -0,0 +1,22 @@ ++--- src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc +++++ src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc ++@@ -131,7 +131,8 @@ const char* CallInterfaceDescriptor::DebugName() const { ++ return ""; ++ } ++ ++-#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) +++#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ +++ !defined(V8_TARGET_ARCH_LOONGARCH64) ++ bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) { ++ return true; ++ } ++@@ -397,7 +398,8 @@ void WasmFloat64ToNumberDescriptor::InitializePlatformSpecific( ++ } ++ #endif // !V8_TARGET_ARCH_IA32 ++ ++-#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) +++#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ +++ !defined(V8_TARGET_ARCH_LOONGARCH64) ++ void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ DefaultInitializePlatformSpecific(data, kParameterCount); +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64-inl.h +@@ -0,0 +1,267 @@ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#ifndef V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ ++#define V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/loongarch64/assembler-loongarch64.h" ++#include "src/debug/debug.h" ++#include "src/objects/objects-inl.h" ++ ++namespace v8 { ++namespace internal { ++ ++bool CpuFeatures::SupportsOptimizer() { return IsSupported(FPU); } ++ ++bool CpuFeatures::SupportsWasmSimd128() { return false; } ++ ++// ----------------------------------------------------------------------------- ++// Operand and MemOperand. ++ ++bool Operand::is_reg() const { return rm_.is_valid(); } ++ ++int64_t Operand::immediate() const { ++ DCHECK(!is_reg()); ++ DCHECK(!IsHeapObjectRequest()); ++ return value_.immediate; ++} ++ ++// ----------------------------------------------------------------------------- ++// RelocInfo. ++ ++void RelocInfo::apply(intptr_t delta) { ++ if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { ++ // Absolute code pointer inside code object moves with the code object. ++ Assembler::RelocateInternalReference(rmode_, pc_, delta); ++ } ++} ++ ++Address RelocInfo::target_address() { ++ DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++Address RelocInfo::target_address_address() { ++ DCHECK(HasTargetAddressAddress()); ++ // Read the address of the word containing the target_address in an ++ // instruction stream. ++ // The only architecture-independent user of this function is the serializer. ++ // The serializer uses it to find out how many raw bytes of instruction to ++ // output before the next target. ++ // For an instruction like LUI/ORI where the target bits are mixed into the ++ // instruction bits, the size of the target will be zero, indicating that the ++ // serializer should not step forward in memory after a target is resolved ++ // and written. In this case the target_address_address function should ++ // return the end of the instructions to be patched, allowing the ++ // deserializer to deserialize the instructions as raw bytes and put them in ++ // place, ready to be patched with the target. After jump optimization, ++ // that is the address of the instruction that follows J/JAL/JR/JALR ++ // instruction. ++ return pc_ + Assembler::kInstructionsFor64BitConstant * kInstrSize; ++} ++ ++Address RelocInfo::constant_pool_entry_address() { UNREACHABLE(); } ++ ++int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } ++ ++void Assembler::deserialization_set_special_target_at( ++ Address instruction_payload, Code code, Address target) { ++ set_target_address_at(instruction_payload, ++ !code.is_null() ? code.constant_pool() : kNullAddress, ++ target); ++} ++ ++int Assembler::deserialization_special_target_size( ++ Address instruction_payload) { ++ return kSpecialTargetSize; ++} ++ ++void Assembler::set_target_internal_reference_encoded_at(Address pc, ++ Address target) { ++ // TODO, see AssembleJumpTable, la64 does not generate internal reference? ++ abort(); ++} ++ ++void Assembler::deserialization_set_target_internal_reference_at( ++ Address pc, Address target, RelocInfo::Mode mode) { ++ if (mode == RelocInfo::INTERNAL_REFERENCE_ENCODED) { ++ DCHECK(IsJ(instr_at(pc))); ++ set_target_internal_reference_encoded_at(pc, target); ++ } else { ++ DCHECK(mode == RelocInfo::INTERNAL_REFERENCE); ++ Memory
(pc) = target; ++ } ++} ++ ++HeapObject RelocInfo::target_object() { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ return HeapObject::cast( ++ Object(Assembler::target_address_at(pc_, constant_pool_))); ++} ++ ++HeapObject RelocInfo::target_object_no_host(Isolate* isolate) { ++ return target_object(); ++} ++ ++Handle RelocInfo::target_object_handle(Assembler* origin) { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ return Handle(reinterpret_cast( ++ Assembler::target_address_at(pc_, constant_pool_))); ++} ++ ++void RelocInfo::set_target_object(Heap* heap, HeapObject target, ++ WriteBarrierMode write_barrier_mode, ++ ICacheFlushMode icache_flush_mode) { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(), ++ icache_flush_mode); ++ if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null() && ++ !FLAG_disable_write_barriers) { ++ WriteBarrierForCode(host(), this, target); ++ } ++} ++ ++Address RelocInfo::target_external_reference() { ++ DCHECK(rmode_ == EXTERNAL_REFERENCE); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++void RelocInfo::set_target_external_reference( ++ Address target, ICacheFlushMode icache_flush_mode) { ++ DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); ++ Assembler::set_target_address_at(pc_, constant_pool_, target, ++ icache_flush_mode); ++} ++ ++Address RelocInfo::target_internal_reference() { ++ if (rmode_ == INTERNAL_REFERENCE) { ++ return Memory
(pc_); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++Address RelocInfo::target_internal_reference_address() { ++ DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); ++ return pc_; ++} ++ ++Address RelocInfo::target_runtime_entry(Assembler* origin) { ++ DCHECK(IsRuntimeEntry(rmode_)); ++ return target_address(); ++} ++ ++void RelocInfo::set_target_runtime_entry(Address target, ++ WriteBarrierMode write_barrier_mode, ++ ICacheFlushMode icache_flush_mode) { ++ DCHECK(IsRuntimeEntry(rmode_)); ++ if (target_address() != target) ++ set_target_address(target, write_barrier_mode, icache_flush_mode); ++} ++ ++Address RelocInfo::target_off_heap_target() { ++ DCHECK(IsOffHeapTarget(rmode_)); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++void RelocInfo::WipeOut() { ++ DCHECK(IsFullEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || ++ IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || ++ IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_) || ++ IsOffHeapTarget(rmode_)); ++ if (IsInternalReference(rmode_)) { ++ Memory
(pc_) = kNullAddress; ++ } else if (IsInternalReferenceEncoded(rmode_)) { ++ Assembler::set_target_internal_reference_encoded_at(pc_, kNullAddress); ++ } else { ++ Assembler::set_target_address_at(pc_, constant_pool_, kNullAddress); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Assembler. ++ ++void Assembler::CheckBuffer() { ++ if (buffer_space() <= kGap) { ++ GrowBuffer(); ++ } ++} ++ ++void Assembler::EmitHelper(Instr x) { ++ *reinterpret_cast(pc_) = x; ++ pc_ += kInstrSize; ++ CheckTrampolinePoolQuick(); ++} ++ ++template <> ++inline void Assembler::EmitHelper(uint8_t x); ++ ++template ++void Assembler::EmitHelper(T x) { ++ *reinterpret_cast(pc_) = x; ++ pc_ += sizeof(x); ++ CheckTrampolinePoolQuick(); ++} ++ ++template <> ++void Assembler::EmitHelper(uint8_t x) { ++ *reinterpret_cast(pc_) = x; ++ pc_ += sizeof(x); ++ if (reinterpret_cast(pc_) % kInstrSize == 0) { ++ CheckTrampolinePoolQuick(); ++ } ++} ++ ++void Assembler::emit(Instr x) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ EmitHelper(x); ++} ++ ++void Assembler::emit(uint64_t data) { ++ // CheckForEmitInForbiddenSlot(); ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ EmitHelper(data); ++} ++ ++EnsureSpace::EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_LOONGARCH64_ASSEMBLER_LA64_INL_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.cc +@@ -0,0 +1,2689 @@ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/codegen/loongarch64/assembler-loongarch64.h" ++ ++#include "src/base/cpu.h" ++#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" ++#include "src/codegen/safepoint-table.h" ++#include "src/codegen/string-constants.h" ++#include "src/deoptimizer/deoptimizer.h" ++#include "src/objects/heap-number-inl.h" ++ ++namespace v8 { ++namespace internal { ++ ++void CpuFeatures::ProbeImpl(bool cross_compile) { ++ supported_ |= 1u << FPU; ++ ++ // Only use statically determined features for cross compile (snapshot). ++ if (cross_compile) return; ++ ++#if defined(_loongisa_vec) ++ supported_ |= 0u; ++#endif ++ // If the compiler is allowed to use fpu then we can use fpu too in our ++ // code generation. ++#ifdef __loongarch__ ++ // Probe for additional features at runtime. ++ base::CPU cpu; ++ supported_ |= 0u; ++#endif ++} ++ ++void CpuFeatures::PrintTarget() {} ++void CpuFeatures::PrintFeatures() {} ++ ++int ToNumber(Register reg) { ++ DCHECK(reg.is_valid()); ++ const int kNumbers[] = { ++ 0, // zero_reg ++ 1, // r1 ra ++ 2, // r2 gp ++ 3, // r3 sp ++ 4, // a0 v0 ++ 5, // a1 v1 ++ 6, // a2 ++ 7, // a3 ++ 8, // a4 ++ 9, // a5 ++ 10, // a6 ++ 11, // a7 ++ 12, // t0 ++ 13, // t1 ++ 14, // t2 ++ 15, // t3 ++ 16, // t4 ++ 17, // t5 ++ 18, // t6 ++ 19, // t7 ++ 20, // t8 ++ 21, // tp ++ 22, // fp ++ 23, // s0 ++ 24, // s1 ++ 25, // s2 ++ 26, // s3 ++ 27, // s4 ++ 28, // s5 ++ 29, // s6 ++ 30, // s7 ++ 31, // s8 ++ }; ++ return kNumbers[reg.code()]; ++} ++ ++Register ToRegister(int num) { ++ DCHECK(num >= 0 && num < kNumRegisters); ++ const Register kRegisters[] = { ++ zero_reg, ra, gp, sp, a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, t3, ++ t4, t5, t6, t7, t8, tp, fp, s0, s1, s2, s3, s4, s5, s6, s7, s8}; ++ return kRegisters[num]; ++} ++ ++// ----------------------------------------------------------------------------- ++// Implementation of RelocInfo. ++ ++const int RelocInfo::kApplyMask = ++ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | ++ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); ++ ++bool RelocInfo::IsCodedSpecially() { ++ // The deserializer needs to know whether a pointer is specially coded. Being ++ // specially coded on loongisa means that it is a lui/ori instruction, and ++ // that is always the case inside code objects. ++ return true; ++} ++ ++bool RelocInfo::IsInConstantPool() { return false; } ++ ++uint32_t RelocInfo::wasm_call_tag() const { ++ DCHECK(rmode_ == WASM_CALL || rmode_ == WASM_STUB_CALL); ++ return static_cast( ++ Assembler::target_address_at(pc_, constant_pool_)); ++} ++ ++// ----------------------------------------------------------------------------- ++// Implementation of Operand and MemOperand. ++// See assembler-la64-inl.h for inlined constructors. ++ ++Operand::Operand(Handle handle) ++ : rm_(no_reg), rmode_(RelocInfo::FULL_EMBEDDED_OBJECT) { ++ value_.immediate = static_cast(handle.address()); ++} ++ ++Operand Operand::EmbeddedNumber(double value) { ++ int32_t smi; ++ if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi)); ++ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); ++ result.is_heap_object_request_ = true; ++ result.value_.heap_object_request = HeapObjectRequest(value); ++ return result; ++} ++ ++Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) { ++ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); ++ result.is_heap_object_request_ = true; ++ result.value_.heap_object_request = HeapObjectRequest(str); ++ return result; ++} ++ ++MemOperand::MemOperand(Register base, int32_t offset) ++ : base_(base), index_(no_reg), offset_(offset) {} ++ ++MemOperand::MemOperand(Register base, Register index) ++ : base_(base), index_(index), offset_(0) {} ++ ++void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { ++ DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty()); ++ for (auto& request : heap_object_requests_) { ++ Handle object; ++ switch (request.kind()) { ++ case HeapObjectRequest::kHeapNumber: ++ object = isolate->factory()->NewHeapNumber( ++ request.heap_number()); ++ break; ++ case HeapObjectRequest::kStringConstant: ++ const StringConstantBase* str = request.string(); ++ CHECK_NOT_NULL(str); ++ object = str->AllocateStringConstant(isolate); ++ break; ++ } ++ Address pc = reinterpret_cast
(buffer_start_) + request.offset(); ++ set_target_value_at(pc, reinterpret_cast(object.location())); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Specific instructions, constants, and masks. ++ ++// addi_d(sp, sp, 8) aka Pop() operation or part of Pop(r) ++// operations as post-increment of sp. ++const Instr kPopInstruction = ADDI_D | (kPointerSize & kImm12Mask) << kRkShift | ++ (sp.code() << kRjShift) | sp.code(); // NOLINT ++// addi_d(sp, sp, -8) part of Push(r) operation as pre-decrement of sp. ++const Instr kPushInstruction = ADDI_D | ++ (-kPointerSize & kImm12Mask) << kRkShift | ++ (sp.code() << kRjShift) | sp.code(); // NOLINT ++// St_d(r, MemOperand(sp, 0)) ++const Instr kPushRegPattern = ST_D | (sp.code() << kRjShift); // NOLINT ++// Ld_d(r, MemOperand(sp, 0)) ++const Instr kPopRegPattern = LD_D | (sp.code() << kRjShift); // NOLINT ++ ++Assembler::Assembler(const AssemblerOptions& options, ++ std::unique_ptr buffer) ++ : AssemblerBase(options, std::move(buffer)), ++ scratch_register_list_(t7.bit() | t6.bit()) { ++ reloc_info_writer.Reposition(buffer_start_ + buffer_->size(), pc_); ++ ++ last_trampoline_pool_end_ = 0; ++ no_trampoline_pool_before_ = 0; ++ trampoline_pool_blocked_nesting_ = 0; ++ // We leave space (16 * kTrampolineSlotsSize) ++ // for BlockTrampolinePoolScope buffer. ++ next_buffer_check_ = FLAG_force_long_branches ++ ? kMaxInt ++ : kMax16BranchOffset - kTrampolineSlotsSize * 16; ++ internal_trampoline_exception_ = false; ++ last_bound_pos_ = 0; ++ ++ trampoline_emitted_ = FLAG_force_long_branches; // TODO remove this ++ unbound_labels_count_ = 0; ++ block_buffer_growth_ = false; ++} ++ ++void Assembler::GetCode(Isolate* isolate, CodeDesc* desc, ++ SafepointTableBuilder* safepoint_table_builder, ++ int handler_table_offset) { ++ // EmitForbiddenSlotInstruction(); // TODO why? ++ ++ int code_comments_size = WriteCodeComments(); ++ ++ DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. ++ ++ AllocateAndInstallRequestedHeapObjects(isolate); ++ ++ // Set up code descriptor. ++ // TODO(jgruber): Reconsider how these offsets and sizes are maintained up to ++ // this point to make CodeDesc initialization less fiddly. ++ ++ static constexpr int kConstantPoolSize = 0; ++ const int instruction_size = pc_offset(); ++ const int code_comments_offset = instruction_size - code_comments_size; ++ const int constant_pool_offset = code_comments_offset - kConstantPoolSize; ++ const int handler_table_offset2 = (handler_table_offset == kNoHandlerTable) ++ ? constant_pool_offset ++ : handler_table_offset; ++ const int safepoint_table_offset = ++ (safepoint_table_builder == kNoSafepointTable) ++ ? handler_table_offset2 ++ : safepoint_table_builder->GetCodeOffset(); ++ const int reloc_info_offset = ++ static_cast(reloc_info_writer.pos() - buffer_->start()); ++ CodeDesc::Initialize(desc, this, safepoint_table_offset, ++ handler_table_offset2, constant_pool_offset, ++ code_comments_offset, reloc_info_offset); ++} ++ ++void Assembler::Align(int m) { ++ DCHECK(m >= 4 && base::bits::IsPowerOfTwo(m)); ++ while ((pc_offset() & (m - 1)) != 0) { ++ nop(); ++ } ++} ++ ++void Assembler::CodeTargetAlign() { ++ // No advantage to aligning branch/call targets to more than ++ // single instruction, that I am aware of. ++ Align(4); ++} ++ ++Register Assembler::GetRkReg(Instr instr) { ++ return Register::from_code((instr & kRkFieldMask) >> kRkShift); ++} ++ ++Register Assembler::GetRjReg(Instr instr) { ++ return Register::from_code((instr & kRjFieldMask) >> kRjShift); ++} ++ ++Register Assembler::GetRdReg(Instr instr) { ++ return Register::from_code((instr & kRdFieldMask) >> kRdShift); ++} ++ ++uint32_t Assembler::GetRk(Instr instr) { ++ return (instr & kRkFieldMask) >> kRkShift; ++} ++ ++uint32_t Assembler::GetRkField(Instr instr) { return instr & kRkFieldMask; } ++ ++uint32_t Assembler::GetRj(Instr instr) { ++ return (instr & kRjFieldMask) >> kRjShift; ++} ++ ++uint32_t Assembler::GetRjField(Instr instr) { return instr & kRjFieldMask; } ++ ++uint32_t Assembler::GetRd(Instr instr) { ++ return (instr & kRdFieldMask) >> kRdShift; ++} ++ ++uint32_t Assembler::GetRdField(Instr instr) { return instr & kRdFieldMask; } ++ ++uint32_t Assembler::GetSa2(Instr instr) { ++ return (instr & kSa2FieldMask) >> kSaShift; ++} ++ ++uint32_t Assembler::GetSa2Field(Instr instr) { return instr & kSa2FieldMask; } ++ ++uint32_t Assembler::GetSa3(Instr instr) { ++ return (instr & kSa3FieldMask) >> kSaShift; ++} ++ ++uint32_t Assembler::GetSa3Field(Instr instr) { return instr & kSa3FieldMask; } ++ ++bool Assembler::IsPop(Instr instr) { ++ return (instr & 0xffc003e0) == kPopRegPattern; ++} ++ ++bool Assembler::IsPush(Instr instr) { ++ return (instr & 0xffc003e0) == kPushRegPattern; ++} ++ ++// Labels refer to positions in the (to be) generated code. ++// There are bound, linked, and unused labels. ++// ++// Bound labels refer to known positions in the already ++// generated code. pos() is the position the label refers to. ++// ++// Linked labels refer to unknown positions in the code ++// to be generated; pos() is the position of the last ++// instruction using the label. ++ ++// The link chain is terminated by a value in the instruction of -1, ++// which is an otherwise illegal value (branch -1 is inf loop). ++// The instruction 16-bit offset field addresses 32-bit words, but in ++// code is conv to an 18-bit value addressing bytes, hence the -4 value. ++ ++const int kEndOfChain = 0; ++// Determines the end of the Jump chain (a subset of the label link chain). ++const int kEndOfJumpChain = 0; ++ ++bool Assembler::IsBranch(Instr instr) { ++ uint32_t opcode = (instr >> 26) << 26; ++ // Checks if the instruction is a branch. ++ bool isBranch = opcode == BEQZ || opcode == BNEZ || opcode == BCZ || ++ opcode == B || opcode == BL || opcode == BEQ || ++ opcode == BNE || opcode == BLT || opcode == BGE || ++ opcode == BLTU || opcode == BGEU; ++ return isBranch; ++} ++ ++bool Assembler::IsB(Instr instr) { ++ uint32_t opcode = (instr >> 26) << 26; ++ // Checks if the instruction is a b. ++ bool isBranch = opcode == B || opcode == BL; ++ return isBranch; ++} ++ ++bool Assembler::IsBz(Instr instr) { ++ uint32_t opcode = (instr >> 26) << 26; ++ // Checks if the instruction is a branch. ++ bool isBranch = opcode == BEQZ || opcode == BNEZ || opcode == BCZ; ++ return isBranch; ++} ++ ++bool Assembler::IsEmittedConstant(Instr instr) { ++ // Add GetLabelConst function? ++ uint32_t label_constant = instr & ~kImm16Mask; ++ return label_constant == 0; // Emitted label const in reg-exp engine. ++} ++ ++bool Assembler::IsJ(Instr instr) { ++ uint32_t opcode = (instr >> 26) << 26; ++ // Checks if the instruction is a jump. ++ return opcode == JIRL; ++} ++ ++bool Assembler::IsLu12i_w(Instr instr) { ++ uint32_t opcode = (instr >> 25) << 25; ++ return opcode == LU12I_W; ++} ++ ++bool Assembler::IsOri(Instr instr) { ++ uint32_t opcode = (instr >> 22) << 22; ++ return opcode == ORI; ++} ++ ++bool Assembler::IsLu32i_d(Instr instr) { ++ uint32_t opcode = (instr >> 25) << 25; ++ return opcode == LU32I_D; ++} ++ ++bool Assembler::IsLu52i_d(Instr instr) { ++ uint32_t opcode = (instr >> 22) << 22; ++ return opcode == LU52I_D; ++} ++ ++bool Assembler::IsMov(Instr instr, Register rd, Register rj) { ++ // Checks if the instruction is a OR with zero_reg argument (aka MOV). ++ Instr instr1 = ++ OR | zero_reg.code() << kRkShift | rj.code() << kRjShift | rd.code(); ++ return instr == instr1; ++} ++ ++bool Assembler::IsPcAddi(Instr instr, Register rd, int32_t si20) { ++ DCHECK(is_int20(si20)); ++ Instr instr1 = PCADDI | (si20 & 0xfffff) << kRjShift | rd.code(); ++ return instr == instr1; ++} ++ ++bool Assembler::IsNop(Instr instr, unsigned int type) { ++ // See Assembler::nop(type). ++ DCHECK_LT(type, 32); ++ // Traditional loongisa nop == andi(zero_reg, zero_reg, 0) ++ // When marking non-zero type, use andi(zero_reg, t7, type) ++ // to avoid use of ssnop and ehb special encodings of the ++ // andi instruction. ++ ++ Register nop_rt_reg = (type == 0) ? zero_reg : t7; ++ Instr instr1 = ANDI | ((type & kImm12Mask) << kRkShift) | ++ (nop_rt_reg.code() << kRjShift); ++ ++ return instr == instr1; ++} ++ ++static inline int32_t GetOffsetOfBranch(Instr instr, ++ Assembler::OffsetSize bits) { ++ int32_t result = 0; ++ if (bits == 16) { ++ result = (instr << 6) >> 16; ++ } else if (bits == 21) { ++ uint32_t low16 = instr << 6; ++ low16 = low16 >> 16; ++ low16 &= 0xffff; ++ int32_t hi5 = (instr << 27) >> 11; ++ result = hi5 | low16; ++ } else { ++ uint32_t low16 = instr << 6; ++ low16 = low16 >> 16; ++ low16 &= 0xffff; ++ int32_t hi10 = (instr << 22) >> 6; ++ result = hi10 | low16; ++ DCHECK_EQ(bits, 26); ++ } ++ return result << 2; ++} ++ ++static Assembler::OffsetSize OffsetSizeInBits(Instr instr) { ++ if (Assembler::IsB(instr)) { ++ return Assembler::OffsetSize::kOffset26; ++ } else if (Assembler::IsBz(instr)) { ++ return Assembler::OffsetSize::kOffset21; ++ } else { ++ DCHECK(Assembler::IsBranch(instr)); ++ return Assembler::OffsetSize::kOffset16; ++ } ++} ++ ++static inline int32_t AddBranchOffset(int pos, Instr instr) { ++ Assembler::OffsetSize bits = OffsetSizeInBits(instr); ++ ++ int32_t imm = GetOffsetOfBranch(instr, bits); ++ ++ if (imm == kEndOfChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or pos. ++ return kEndOfChain; ++ } else { ++ // Handle the case that next branch position is 0. ++ // TODO: Define -4 as a constant ++ int32_t offset = pos + Assembler::kBranchPCOffset + imm; ++ return offset == 0 ? -4 : offset; ++ } ++} ++ ++int Assembler::target_at(int pos, bool is_internal) { ++ if (is_internal) { ++ int64_t* p = reinterpret_cast(buffer_start_ + pos); ++ int64_t address = *p; ++ if (address == kEndOfJumpChain) { ++ return kEndOfChain; ++ } else { ++ int64_t instr_address = reinterpret_cast(p); ++ DCHECK(instr_address - address < INT_MAX); ++ int delta = static_cast(instr_address - address); ++ DCHECK(pos > delta); ++ return pos - delta; ++ } ++ } ++ Instr instr = instr_at(pos); ++ ++ // TODO remove after remove label_at_put? ++ if ((instr & ~kImm16Mask) == 0) { ++ // Emitted label constant, not part of a branch. ++ if (instr == 0) { ++ return kEndOfChain; ++ } else { ++ int32_t imm18 = ((instr & static_cast(kImm16Mask)) << 16) >> 14; ++ return (imm18 + pos); ++ } ++ } ++ ++ // Check we have a branch or jump instruction. ++ DCHECK(IsBranch(instr) || IsJ(instr) || IsLu12i_w(instr) || ++ IsPcAddi(instr, t8, 16)); ++ // Do NOT change this to <<2. We rely on arithmetic shifts here, assuming ++ // the compiler uses arithmetic shifts for signed integers. ++ if (IsBranch(instr)) { ++ return AddBranchOffset(pos, instr); ++ } else if (IsPcAddi(instr, t8, 16)) { ++ // see BranchLong(Label* L) and BranchAndLinkLong ?? ++ int32_t imm32; ++ Instr instr_lu12i_w = instr_at(pos + 1 * kInstrSize); ++ Instr instr_ori = instr_at(pos + 2 * kInstrSize); ++ DCHECK(IsLu12i_w(instr_lu12i_w)); ++ // DCHECK(IsOri(instr_ori)); ++ imm32 = ((instr_lu12i_w >> 5) & 0xfffff) << 12; ++ imm32 |= ((instr_ori >> 10) & static_cast(kImm12Mask)); ++ if (imm32 == kEndOfJumpChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or pos. ++ return kEndOfChain; ++ } ++ return pos + imm32; ++ } else if (IsLu12i_w(instr)) { ++ abort(); ++ // TODO no used?? ++ /* Instr instr_lui = instr_at(pos + 0 * kInstrSize); ++ Instr instr_ori = instr_at(pos + 1 * kInstrSize); ++ Instr instr_ori2 = instr_at(pos + 3 * kInstrSize); ++ DCHECK(IsOri(instr_ori)); ++ DCHECK(IsOri(instr_ori2)); ++ ++ // TODO(plind) create named constants for shift values. ++ int64_t imm = static_cast(instr_lui & kImm16Mask) << 48; ++ imm |= static_cast(instr_ori & kImm16Mask) << 32; ++ imm |= static_cast(instr_ori2 & kImm16Mask) << 16; ++ // Sign extend address; ++ imm >>= 16; ++ ++ if (imm == kEndOfJumpChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or ++ pos. return kEndOfChain; } else { uint64_t instr_address = ++ reinterpret_cast(buffer_start_ + pos); DCHECK(instr_address - ++ imm < INT_MAX); int delta = static_cast(instr_address - imm); ++ DCHECK(pos > delta); ++ return pos - delta; ++ }*/ ++ } else { ++ DCHECK(IsJ(instr)); ++ // TODO not used??? ++ abort(); ++ } ++} ++ ++static inline Instr SetBranchOffset(int32_t pos, int32_t target_pos, ++ Instr instr) { ++ int32_t bits = OffsetSizeInBits(instr); ++ int32_t imm = target_pos - pos; ++ DCHECK_EQ(imm & 3, 0); ++ imm >>= 2; ++ ++ DCHECK(is_intn(imm, bits)); ++ ++ if (bits == 16) { ++ const int32_t mask = ((1 << 16) - 1) << 10; ++ instr &= ~mask; ++ return instr | ((imm << 10) & mask); ++ } else if (bits == 21) { ++ const int32_t mask = 0x3fffc1f; ++ instr &= ~mask; ++ uint32_t low16 = (imm & kImm16Mask) << 10; ++ int32_t hi5 = (imm >> 16) & 0x1f; ++ return instr | low16 | hi5; ++ } else { ++ DCHECK_EQ(bits, 26); ++ const int32_t mask = 0x3ffffff; ++ instr &= ~mask; ++ uint32_t low16 = (imm & kImm16Mask) << 10; ++ int32_t hi10 = (imm >> 16) & 0x3ff; ++ return instr | low16 | hi10; ++ } ++} ++ ++void Assembler::target_at_put(int pos, int target_pos, bool is_internal) { ++ if (is_internal) { ++ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; ++ *reinterpret_cast(buffer_start_ + pos) = imm; ++ return; ++ } ++ Instr instr = instr_at(pos); ++ if ((instr & ~kImm16Mask) == 0) { ++ DCHECK(target_pos == kEndOfChain || target_pos >= 0); ++ // Emitted label constant, not part of a branch. ++ // Make label relative to Code pointer of generated Code object. ++ instr_at_put(pos, target_pos + (Code::kHeaderSize - kHeapObjectTag)); ++ return; ++ } ++ ++ if (IsBranch(instr)) { ++ instr = SetBranchOffset(pos, target_pos, instr); ++ instr_at_put(pos, instr); ++ } else if (0 == 1 /*IsLui(instr)*/) { ++ /* if (IsPcAddi(instr, t8, 16)) { ++ Instr instr_lui = instr_at(pos + 0 * kInstrSize); ++ Instr instr_ori = instr_at(pos + 2 * kInstrSize); ++ DCHECK(IsLui(instr_lui)); ++ DCHECK(IsOri(instr_ori)); ++ int32_t imm = target_pos - (pos + Assembler::kLongBranchPCOffset); ++ DCHECK_EQ(imm & 3, 0); ++ if (is_int16(imm + Assembler::kLongBranchPCOffset - ++ Assembler::kBranchPCOffset)) { ++ // Optimize by converting to regular branch and link with 16-bit ++ // offset. ++ Instr instr_b = REGIMM | BGEZAL; // Branch and link. ++ instr_b = SetBranchOffset(pos, target_pos, instr_b); ++ // Correct ra register to point to one instruction after jalr from ++ // TurboAssembler::BranchAndLinkLong. ++ Instr instr_a = DADDIU | ra.code() << kRsShift | ra.code() << kRtShift ++ | kOptimizedBranchAndLinkLongReturnOffset; ++ ++ instr_at_put(pos, instr_b); ++ instr_at_put(pos + 1 * kInstrSize, instr_a); ++ } else { ++ instr_lui &= ~kImm16Mask; ++ instr_ori &= ~kImm16Mask; ++ ++ instr_at_put(pos + 0 * kInstrSize, ++ instr_lui | ((imm >> kLuiShift) & kImm16Mask)); ++ instr_at_put(pos + 2 * kInstrSize, instr_ori | (imm & kImm16Mask)); ++ } ++ } else { ++ Instr instr_lui = instr_at(pos + 0 * kInstrSize); ++ Instr instr_ori = instr_at(pos + 1 * kInstrSize); ++ Instr instr_ori2 = instr_at(pos + 3 * kInstrSize); ++ DCHECK(IsOri(instr_ori)); ++ DCHECK(IsOri(instr_ori2)); ++ ++ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; ++ DCHECK_EQ(imm & 3, 0); ++ ++ instr_lui &= ~kImm16Mask; ++ instr_ori &= ~kImm16Mask; ++ instr_ori2 &= ~kImm16Mask; ++ ++ instr_at_put(pos + 0 * kInstrSize, ++ instr_lui | ((imm >> 32) & kImm16Mask)); ++ instr_at_put(pos + 1 * kInstrSize, ++ instr_ori | ((imm >> 16) & kImm16Mask)); ++ instr_at_put(pos + 3 * kInstrSize, instr_ori2 | (imm & kImm16Mask)); ++ }*/ ++ } else if (IsPcAddi(instr, t8, 16)) { ++ abort(); /* ++ Instr instr_lu12i_w = instr_at(pos + 1 * kInstrSize); ++ Instr instr_ori = instr_at(pos + 2 * kInstrSize); ++ DCHECK(IsLu12i_w(instr_lu12i_w)); ++ //DCHECK(IsOri(instr_ori)); ++ ++ int32_t imm_short = target_pos - (pos + Assembler::kBranchPCOffset); ++ ++ if (is_int21(imm_short)) { ++ // Optimize by converting to regular branch with 21-bit ++ // offset ++ Instr instr_b = B; ++ instr_b = SetBranchOffset(pos, target_pos, instr_b); ++ ++ instr_at_put(pos, instr_b); ++ } else { ++ int32_t imm = target_pos - (pos + Assembler::kLongBranchPCOffset); ++ DCHECK_EQ(imm & 3, 0); ++ ++ instr_lu12i_w &= 0xfe00001fu; // opcode:7 | bit20 | rd:5 ++ instr_ori &= 0xffc003ffu; // opcode:10 | bit12 | rj:5 | rd:5 ++ ++ instr_at_put(pos + 1 * kInstrSize, ++ instr_lu12i_w | (((imm >> 12) & 0xfffff) << 5)); ++ instr_at_put(pos + 2 * kInstrSize, instr_ori | ++ ((imm & 0xfff) << 10)); ++ }*/ ++ } else if (IsJ(instr)) { ++ /* ++ int32_t imm28 = target_pos - pos; ++ DCHECK_EQ(imm28 & 3, 0); ++ ++ uint32_t imm26 = static_cast(imm28 >> 2); ++ DCHECK(is_uint26(imm26)); ++ // Place 26-bit signed offset with markings. ++ // When code is committed it will be resolved to j/jal. ++ int32_t mark = IsJ(instr) ? kJRawMark : kJalRawMark; ++ instr_at_put(pos, mark | (imm26 & kImm26Mask));*/ ++ abort(); ++ } else { ++ /* int32_t imm28 = target_pos - pos; ++ DCHECK_EQ(imm28 & 3, 0); ++ ++ uint32_t imm26 = static_cast(imm28 >> 2); ++ DCHECK(is_uint26(imm26)); ++ // Place raw 26-bit signed offset. ++ // When code is committed it will be resolved to j/jal. ++ instr &= ~kImm26Mask; ++ instr_at_put(pos, instr | (imm26 & kImm26Mask));*/ ++ abort(); ++ } ++} ++ ++void Assembler::print(const Label* L) { ++ if (L->is_unused()) { ++ PrintF("unused label\n"); ++ } else if (L->is_bound()) { ++ PrintF("bound label to %d\n", L->pos()); ++ } else if (L->is_linked()) { ++ Label l; ++ l.link_to(L->pos()); ++ PrintF("unbound label"); ++ while (l.is_linked()) { ++ PrintF("@ %d ", l.pos()); ++ Instr instr = instr_at(l.pos()); ++ if ((instr & ~kImm16Mask) == 0) { ++ PrintF("value\n"); ++ } else { ++ PrintF("%d\n", instr); ++ } ++ next(&l, is_internal_reference(&l)); ++ } ++ } else { ++ PrintF("label in inconsistent state (pos = %d)\n", L->pos_); ++ } ++} ++ ++void Assembler::bind_to(Label* L, int pos) { ++ DCHECK(0 <= pos && pos <= pc_offset()); // Must have valid binding position. ++ int trampoline_pos = kInvalidSlotPos; ++ bool is_internal = false; ++ if (L->is_linked() && !trampoline_emitted_) { ++ unbound_labels_count_--; ++ if (!is_internal_reference(L)) { ++ next_buffer_check_ += kTrampolineSlotsSize; ++ } ++ } ++ ++ while (L->is_linked()) { ++ int fixup_pos = L->pos(); ++ int dist = pos - fixup_pos; ++ is_internal = is_internal_reference(L); ++ next(L, is_internal); // Call next before overwriting link with target at ++ // fixup_pos. ++ Instr instr = instr_at(fixup_pos); ++ if (is_internal) { ++ target_at_put(fixup_pos, pos, is_internal); ++ } else { ++ if (IsBranch(instr)) { ++ int branch_offset = BranchOffset(instr); ++ if (dist > branch_offset) { ++ if (trampoline_pos == kInvalidSlotPos) { ++ trampoline_pos = get_trampoline_entry(fixup_pos); ++ CHECK_NE(trampoline_pos, kInvalidSlotPos); ++ } ++ CHECK((trampoline_pos - fixup_pos) <= branch_offset); ++ target_at_put(fixup_pos, trampoline_pos, false); ++ fixup_pos = trampoline_pos; ++ } ++ target_at_put(fixup_pos, pos, false); ++ } else { ++ DCHECK(IsJ(instr) || IsLu12i_w(instr) || IsEmittedConstant(instr) || ++ IsPcAddi(instr, t8, 8)); ++ target_at_put(fixup_pos, pos, false); ++ } ++ } ++ } ++ L->bind_to(pos); ++ ++ // Keep track of the last bound label so we don't eliminate any instructions ++ // before a bound label. ++ if (pos > last_bound_pos_) last_bound_pos_ = pos; ++} ++ ++void Assembler::bind(Label* L) { ++ DCHECK(!L->is_bound()); // Label can only be bound once. ++ bind_to(L, pc_offset()); ++} ++ ++void Assembler::next(Label* L, bool is_internal) { ++ DCHECK(L->is_linked()); ++ int link = target_at(L->pos(), is_internal); ++ if (link == kEndOfChain) { ++ L->Unuse(); ++ } else if (link == -4) { ++ // Next position is pc_offset == 0 ++ L->link_to(0); ++ } else { ++ DCHECK_GE(link, 0); ++ L->link_to(link); ++ } ++} ++ ++bool Assembler::is_near_c(Label* L) { ++ DCHECK(L->is_bound()); ++ return pc_offset() - L->pos() < kMax16BranchOffset - 4 * kInstrSize; ++} ++ ++bool Assembler::is_near(Label* L, OffsetSize bits) { ++ DCHECK(L->is_bound()); ++ return ((pc_offset() - L->pos()) < ++ (1 << (bits + 2 - 1)) - 1 - 5 * kInstrSize); ++} ++ ++bool Assembler::is_near_a(Label* L) { ++ DCHECK(L->is_bound()); ++ return pc_offset() - L->pos() <= kMax26BranchOffset - 4 * kInstrSize; ++} ++ ++int Assembler::BranchOffset(Instr instr) { ++ int bits = OffsetSize::kOffset16; ++ ++ uint32_t opcode = (instr >> 26) << 26; ++ switch (opcode) { ++ case B: ++ case BL: ++ bits = OffsetSize::kOffset26; ++ break; ++ case BNEZ: ++ case BEQZ: ++ case BCZ: ++ bits = OffsetSize::kOffset21; ++ break; ++ case BNE: ++ case BEQ: ++ case BLT: ++ case BGE: ++ case BLTU: ++ case BGEU: ++ case JIRL: ++ bits = OffsetSize::kOffset16; ++ break; ++ default: ++ break; ++ } ++ ++ return (1 << (bits + 2 - 1)) - 1; ++} ++ ++// We have to use a temporary register for things that can be relocated even ++// if they can be encoded in the LA's 16 bits of immediate-offset instruction ++// space. There is no guarantee that the relocated location can be similarly ++// encoded. ++bool Assembler::MustUseReg(RelocInfo::Mode rmode) { ++ return !RelocInfo::IsNone(rmode); ++} ++ ++void Assembler::GenB(Opcode opcode, Register rj, int32_t si21) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK((BEQZ == opcode || BNEZ == opcode) && is_int21(si21) && rj.is_valid()); ++ Instr instr = opcode | (si21 & kImm16Mask) << kRkShift | ++ (rj.code() << kRjShift) | ((si21 & 0x1fffff) >> 16); ++ emit(instr); ++} ++ ++void Assembler::GenB(Opcode opcode, CFRegister cj, int32_t si21, bool isEq) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(BCZ == opcode && is_int21(si21)); ++ DCHECK(cj >= 0 && cj <= 7); ++ int32_t sc = (isEq ? cj : cj + 8); ++ Instr instr = opcode | (si21 & kImm16Mask) << kRkShift | (sc << kRjShift) | ++ ((si21 & 0x1fffff) >> 16); ++ emit(instr); ++} ++ ++void Assembler::GenB(Opcode opcode, int32_t si26) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK((B == opcode || BL == opcode) && is_int26(si26)); ++ Instr instr = ++ opcode | ((si26 & kImm16Mask) << kRkShift) | ((si26 & kImm26Mask) >> 16); ++ emit(instr); ++} ++ ++void Assembler::GenBJ(Opcode opcode, Register rj, Register rd, int32_t si16) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(is_int16(si16)); ++ Instr instr = opcode | ((si16 & kImm16Mask) << kRkShift) | ++ (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenCmp(Opcode opcode, FPUCondition cond, FPURegister fk, ++ FPURegister fj, CFRegister cd) { ++ DCHECK(opcode == FCMP_COND_S || opcode == FCMP_COND_D); ++ Instr instr = opcode | cond << kCondShift | (fk.code() << kFkShift) | ++ (fj.code() << kFjShift) | cd; ++ emit(instr); ++} ++ ++void Assembler::GenSel(Opcode opcode, CFRegister ca, FPURegister fk, ++ FPURegister fj, FPURegister rd) { ++ DCHECK((opcode == FSEL)); ++ Instr instr = opcode | ca << kCondShift | (fk.code() << kFkShift) | ++ (fj.code() << kFjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rj, Register rd, ++ bool rjrd) { ++ DCHECK(rjrd); ++ Instr instr = 0; ++ instr = opcode | (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPURegister fj, FPURegister fd) { ++ Instr instr = opcode | (fj.code() << kFjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rj, FPURegister fd) { ++ DCHECK((opcode == MOVGR2FR_W) || (opcode == MOVGR2FR_D) || ++ (opcode == MOVGR2FRH_W)); ++ Instr instr = opcode | (rj.code() << kRjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPURegister fj, Register rd) { ++ DCHECK((opcode == MOVFR2GR_S) || (opcode == MOVFR2GR_D) || ++ (opcode == MOVFRH2GR_S)); ++ Instr instr = opcode | (fj.code() << kFjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rj, FPUControlRegister fd) { ++ DCHECK((opcode == MOVGR2FCSR)); ++ Instr instr = opcode | (rj.code() << kRjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPUControlRegister fj, Register rd) { ++ DCHECK((opcode == MOVFCSR2GR)); ++ Instr instr = opcode | (fj.code() << kFjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPURegister fj, CFRegister cd) { ++ DCHECK((opcode == MOVFR2CF)); ++ Instr instr = opcode | (fj.code() << kFjShift) | cd; ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, CFRegister cj, FPURegister fd) { ++ DCHECK((opcode == MOVCF2FR)); ++ Instr instr = opcode | cj << kFjShift | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rj, CFRegister cd) { ++ DCHECK((opcode == MOVGR2CF)); ++ Instr instr = opcode | (rj.code() << kRjShift) | cd; ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, CFRegister cj, Register rd) { ++ DCHECK((opcode == MOVCF2GR)); ++ Instr instr = opcode | cj << kFjShift | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rk, Register rj, ++ Register rd) { ++ Instr instr = ++ opcode | (rk.code() << kRkShift) | (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPURegister fk, FPURegister fj, ++ FPURegister fd) { ++ Instr instr = ++ opcode | (fk.code() << kFkShift) | (fj.code() << kFjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, FPURegister fa, FPURegister fk, ++ FPURegister fj, FPURegister fd) { ++ Instr instr = opcode | (fa.code() << kFaShift) | (fk.code() << kFkShift) | ++ (fj.code() << kFjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenRegister(Opcode opcode, Register rk, Register rj, ++ FPURegister fd) { ++ Instr instr = ++ opcode | (rk.code() << kRkShift) | (rj.code() << kRjShift) | fd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t bit3, Register rk, Register rj, ++ Register rd) { ++ DCHECK(is_uint3(bit3)); ++ Instr instr = opcode | (bit3 & 0x7) << kSaShift | (rk.code() << kRkShift) | ++ (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t bit6m, int32_t bit6l, Register rj, ++ Register rd) { ++ DCHECK(is_uint6(bit6m) && is_uint6(bit6l)); ++ Instr instr = opcode | (bit6m & 0x3f) << 16 | (bit6l & 0x3f) << kRkShift | ++ (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t bit20, Register rd) { ++ // DCHECK(is_uint20(bit20) || is_int20(bit20)); ++ Instr instr = opcode | (bit20 & 0xfffff) << kRjShift | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t bit15) { ++ DCHECK(is_uint15(bit15)); ++ Instr instr = opcode | (bit15 & 0x7fff); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t value, Register rj, Register rd, ++ int32_t value_bits) { ++ DCHECK(value_bits == 6 || value_bits == 12 || value_bits == 14 || ++ value_bits == 16); ++ uint32_t imm = value & 0x3f; ++ if (value_bits == 12) { ++ imm = value & kImm12Mask; ++ } else if (value_bits == 14) { ++ imm = value & 0x3fff; ++ } else if (value_bits == 16) { ++ imm = value & kImm16Mask; ++ } ++ Instr instr = opcode | imm << kRkShift | (rj.code() << kRjShift) | rd.code(); ++ emit(instr); ++} ++ ++void Assembler::GenImm(Opcode opcode, int32_t bit12, Register rj, ++ FPURegister fd) { ++ DCHECK(is_int12(bit12)); ++ Instr instr = opcode | ((bit12 & kImm12Mask) << kRkShift) | ++ (rj.code() << kRjShift) | fd.code(); ++ emit(instr); ++} ++ ++// Returns the next free trampoline entry. ++int32_t Assembler::get_trampoline_entry(int32_t pos) { ++ int32_t trampoline_entry = kInvalidSlotPos; ++ if (!internal_trampoline_exception_) { ++ if (trampoline_.start() > pos) { ++ trampoline_entry = trampoline_.take_slot(); ++ } ++ ++ if (kInvalidSlotPos == trampoline_entry) { ++ internal_trampoline_exception_ = true; ++ } ++ } ++ return trampoline_entry; ++} ++ ++uint64_t Assembler::jump_address(Label* L) { ++ int64_t target_pos; ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ L->link_to(pc_offset()); ++ } else { ++ L->link_to(pc_offset()); ++ return kEndOfJumpChain; ++ } ++ } ++ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; ++ DCHECK_EQ(imm & 3, 0); ++ ++ return imm; ++} ++ ++uint64_t Assembler::branch_long_offset(Label* L) { ++ int64_t target_pos; ++ ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ L->link_to(pc_offset()); ++ } else { ++ L->link_to(pc_offset()); ++ return kEndOfJumpChain; ++ } ++ } ++ int64_t offset = target_pos - (pc_offset() + kLongBranchPCOffset); ++ DCHECK_EQ(offset & 3, 0); ++ ++ return static_cast(offset); ++} ++ ++int32_t Assembler::branch_offset_helper(Label* L, OffsetSize bits) { ++ int32_t target_pos; ++ ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); ++ L->link_to(pc_offset()); ++ } else { ++ L->link_to(pc_offset()); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ return kEndOfChain; ++ } ++ } ++ ++ int32_t offset = target_pos - (pc_offset() + kBranchPCOffset); ++ DCHECK(is_intn(offset, bits + 2)); ++ DCHECK_EQ(offset & 3, 0); ++ ++ return offset; ++} ++ ++void Assembler::label_at_put(Label* L, int at_offset) { ++ int target_pos; ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ instr_at_put(at_offset, target_pos + (Code::kHeaderSize - kHeapObjectTag)); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ int32_t imm18 = target_pos - at_offset; ++ DCHECK_EQ(imm18 & 3, 0); ++ int32_t imm16 = imm18 >> 2; ++ DCHECK(is_int16(imm16)); ++ instr_at_put(at_offset, (imm16 & kImm16Mask)); ++ } else { ++ target_pos = kEndOfChain; ++ instr_at_put(at_offset, 0); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ } ++ L->link_to(at_offset); ++ } ++ // TODO PushBackTrack() ++} ++ ++//------- Branch and jump instructions -------- ++ ++void Assembler::b(int32_t offset) { GenB(B, offset); } ++ ++void Assembler::bl(int32_t offset) { GenB(BL, offset); } ++ ++void Assembler::beq(Register rj, Register rd, int32_t offset) { ++ GenBJ(BEQ, rj, rd, offset); ++} ++ ++void Assembler::bne(Register rj, Register rd, int32_t offset) { ++ GenBJ(BNE, rj, rd, offset); ++} ++ ++void Assembler::blt(Register rj, Register rd, int32_t offset) { ++ GenBJ(BLT, rj, rd, offset); ++} ++ ++void Assembler::bge(Register rj, Register rd, int32_t offset) { ++ GenBJ(BGE, rj, rd, offset); ++} ++ ++void Assembler::bltu(Register rj, Register rd, int32_t offset) { ++ GenBJ(BLTU, rj, rd, offset); ++} ++ ++void Assembler::bgeu(Register rj, Register rd, int32_t offset) { ++ GenBJ(BGEU, rj, rd, offset); ++} ++ ++void Assembler::beqz(Register rj, int32_t offset) { GenB(BEQZ, rj, offset); } ++void Assembler::bnez(Register rj, int32_t offset) { GenB(BNEZ, rj, offset); } ++ ++void Assembler::jirl(Register rd, Register rj, int32_t offset) { ++ GenBJ(JIRL, rj, rd, offset); ++} ++ ++void Assembler::bceqz(CFRegister cj, int32_t si21) { ++ GenB(BCZ, cj, si21, true); ++} ++ ++void Assembler::bcnez(CFRegister cj, int32_t si21) { ++ GenB(BCZ, cj, si21, false); ++} ++ ++// -------Data-processing-instructions--------- ++ ++// Arithmetic. ++void Assembler::add_w(Register rd, Register rj, Register rk) { ++ GenRegister(ADD_W, rk, rj, rd); ++} ++ ++void Assembler::add_d(Register rd, Register rj, Register rk) { ++ GenRegister(ADD_D, rk, rj, rd); ++} ++ ++void Assembler::sub_w(Register rd, Register rj, Register rk) { ++ GenRegister(SUB_W, rk, rj, rd); ++} ++ ++void Assembler::sub_d(Register rd, Register rj, Register rk) { ++ GenRegister(SUB_D, rk, rj, rd); ++} ++ ++void Assembler::addi_w(Register rd, Register rj, int32_t si12) { ++ GenImm(ADDI_W, si12, rj, rd, 12); ++} ++ ++void Assembler::addi_d(Register rd, Register rj, int32_t si12) { ++ GenImm(ADDI_D, si12, rj, rd, 12); ++} ++ ++void Assembler::addu16i_d(Register rd, Register rj, int32_t si16) { ++ GenImm(ADDU16I_D, si16, rj, rd, 16); ++} ++ ++void Assembler::alsl_w(Register rd, Register rj, Register rk, int32_t sa2) { ++ DCHECK(is_uint2(sa2 - 1)); ++ GenImm(ALSL_W, sa2 - 1, rk, rj, rd); ++} ++ ++void Assembler::alsl_wu(Register rd, Register rj, Register rk, int32_t sa2) { ++ DCHECK(is_uint2(sa2 - 1)); ++ GenImm(ALSL_WU, sa2 + 3, rk, rj, rd); ++} ++ ++void Assembler::alsl_d(Register rd, Register rj, Register rk, int32_t sa2) { ++ DCHECK(is_uint2(sa2 - 1)); ++ GenImm(ALSL_D, sa2 - 1, rk, rj, rd); ++} ++ ++void Assembler::lu12i_w(Register rd, int32_t si20) { ++ GenImm(LU12I_W, si20, rd); ++} ++ ++void Assembler::lu32i_d(Register rd, int32_t si20) { ++ GenImm(LU32I_D, si20, rd); ++} ++ ++void Assembler::lu52i_d(Register rd, Register rj, int32_t si12) { ++ GenImm(LU52I_D, si12, rj, rd, 12); ++} ++ ++void Assembler::slt(Register rd, Register rj, Register rk) { ++ GenRegister(SLT, rk, rj, rd); ++} ++ ++void Assembler::sltu(Register rd, Register rj, Register rk) { ++ GenRegister(SLTU, rk, rj, rd); ++} ++ ++void Assembler::slti(Register rd, Register rj, int32_t si12) { ++ GenImm(SLTI, si12, rj, rd, 12); ++} ++ ++void Assembler::sltui(Register rd, Register rj, int32_t si12) { ++ GenImm(SLTUI, si12, rj, rd, 12); ++} ++ ++void Assembler::pcaddi(Register rd, int32_t si20) { GenImm(PCADDI, si20, rd); } ++ ++void Assembler::pcaddu12i(Register rd, int32_t si20) { ++ GenImm(PCADDU12I, si20, rd); ++} ++ ++void Assembler::pcaddu18i(Register rd, int32_t si20) { ++ GenImm(PCADDU18I, si20, rd); ++} ++ ++void Assembler::pcalau12i(Register rd, int32_t si20) { ++ GenImm(PCALAU12I, si20, rd); ++} ++ ++void Assembler::and_(Register rd, Register rj, Register rk) { ++ GenRegister(AND, rk, rj, rd); ++} ++ ++void Assembler::or_(Register rd, Register rj, Register rk) { ++ GenRegister(OR, rk, rj, rd); ++} ++ ++void Assembler::xor_(Register rd, Register rj, Register rk) { ++ GenRegister(XOR, rk, rj, rd); ++} ++ ++void Assembler::nor(Register rd, Register rj, Register rk) { ++ GenRegister(NOR, rk, rj, rd); ++} ++ ++void Assembler::andn(Register rd, Register rj, Register rk) { ++ GenRegister(ANDN, rk, rj, rd); ++} ++ ++void Assembler::orn(Register rd, Register rj, Register rk) { ++ GenRegister(ORN, rk, rj, rd); ++} ++ ++void Assembler::andi(Register rd, Register rj, int32_t ui12) { ++ GenImm(ANDI, ui12, rj, rd, 12); ++} ++ ++void Assembler::ori(Register rd, Register rj, int32_t ui12) { ++ GenImm(ORI, ui12, rj, rd, 12); ++} ++ ++void Assembler::xori(Register rd, Register rj, int32_t ui12) { ++ GenImm(XORI, ui12, rj, rd, 12); ++} ++ ++void Assembler::mul_w(Register rd, Register rj, Register rk) { ++ GenRegister(MUL_W, rk, rj, rd); ++} ++ ++void Assembler::mulh_w(Register rd, Register rj, Register rk) { ++ GenRegister(MULH_W, rk, rj, rd); ++} ++ ++void Assembler::mulh_wu(Register rd, Register rj, Register rk) { ++ GenRegister(MULH_WU, rk, rj, rd); ++} ++ ++void Assembler::mul_d(Register rd, Register rj, Register rk) { ++ GenRegister(MUL_D, rk, rj, rd); ++} ++ ++void Assembler::mulh_d(Register rd, Register rj, Register rk) { ++ GenRegister(MULH_D, rk, rj, rd); ++} ++ ++void Assembler::mulh_du(Register rd, Register rj, Register rk) { ++ GenRegister(MULH_DU, rk, rj, rd); ++} ++ ++void Assembler::mulw_d_w(Register rd, Register rj, Register rk) { ++ GenRegister(MULW_D_W, rk, rj, rd); ++} ++ ++void Assembler::mulw_d_wu(Register rd, Register rj, Register rk) { ++ GenRegister(MULW_D_WU, rk, rj, rd); ++} ++ ++void Assembler::div_w(Register rd, Register rj, Register rk) { ++ GenRegister(DIV_W, rk, rj, rd); ++} ++ ++void Assembler::mod_w(Register rd, Register rj, Register rk) { ++ GenRegister(MOD_W, rk, rj, rd); ++} ++ ++void Assembler::div_wu(Register rd, Register rj, Register rk) { ++ GenRegister(DIV_WU, rk, rj, rd); ++} ++ ++void Assembler::mod_wu(Register rd, Register rj, Register rk) { ++ GenRegister(MOD_WU, rk, rj, rd); ++} ++ ++void Assembler::div_d(Register rd, Register rj, Register rk) { ++ GenRegister(DIV_D, rk, rj, rd); ++} ++ ++void Assembler::mod_d(Register rd, Register rj, Register rk) { ++ GenRegister(MOD_D, rk, rj, rd); ++} ++ ++void Assembler::div_du(Register rd, Register rj, Register rk) { ++ GenRegister(DIV_DU, rk, rj, rd); ++} ++ ++void Assembler::mod_du(Register rd, Register rj, Register rk) { ++ GenRegister(MOD_DU, rk, rj, rd); ++} ++ ++// Shifts. ++void Assembler::sll_w(Register rd, Register rj, Register rk) { ++ GenRegister(SLL_W, rk, rj, rd); ++} ++ ++void Assembler::srl_w(Register rd, Register rj, Register rk) { ++ GenRegister(SRL_W, rk, rj, rd); ++} ++ ++void Assembler::sra_w(Register rd, Register rj, Register rk) { ++ GenRegister(SRA_W, rk, rj, rd); ++} ++ ++void Assembler::rotr_w(Register rd, Register rj, Register rk) { ++ GenRegister(ROTR_W, rk, rj, rd); ++} ++ ++void Assembler::slli_w(Register rd, Register rj, int32_t ui5) { ++ DCHECK(is_uint5(ui5)); ++ GenImm(SLLI_W, ui5 + 0x20, rj, rd, 6); ++} ++ ++void Assembler::srli_w(Register rd, Register rj, int32_t ui5) { ++ DCHECK(is_uint5(ui5)); ++ GenImm(SRLI_W, ui5 + 0x20, rj, rd, 6); ++} ++ ++void Assembler::srai_w(Register rd, Register rj, int32_t ui5) { ++ DCHECK(is_uint5(ui5)); ++ GenImm(SRAI_W, ui5 + 0x20, rj, rd, 6); ++} ++ ++void Assembler::rotri_w(Register rd, Register rj, int32_t ui5) { ++ DCHECK(is_uint5(ui5)); ++ GenImm(ROTRI_W, ui5 + 0x20, rj, rd, 6); ++} ++ ++void Assembler::sll_d(Register rd, Register rj, Register rk) { ++ GenRegister(SLL_D, rk, rj, rd); ++} ++ ++void Assembler::srl_d(Register rd, Register rj, Register rk) { ++ GenRegister(SRL_D, rk, rj, rd); ++} ++ ++void Assembler::sra_d(Register rd, Register rj, Register rk) { ++ GenRegister(SRA_D, rk, rj, rd); ++} ++ ++void Assembler::rotr_d(Register rd, Register rj, Register rk) { ++ GenRegister(ROTR_D, rk, rj, rd); ++} ++ ++void Assembler::slli_d(Register rd, Register rj, int32_t ui6) { ++ GenImm(SLLI_D, ui6, rj, rd, 6); ++} ++ ++void Assembler::srli_d(Register rd, Register rj, int32_t ui6) { ++ GenImm(SRLI_D, ui6, rj, rd, 6); ++} ++ ++void Assembler::srai_d(Register rd, Register rj, int32_t ui6) { ++ GenImm(SRAI_D, ui6, rj, rd, 6); ++} ++ ++void Assembler::rotri_d(Register rd, Register rj, int32_t ui6) { ++ GenImm(ROTRI_D, ui6, rj, rd, 6); ++} ++ ++// Bit twiddling. ++void Assembler::ext_w_b(Register rd, Register rj) { ++ GenRegister(EXT_W_B, rj, rd); ++} ++ ++void Assembler::ext_w_h(Register rd, Register rj) { ++ GenRegister(EXT_W_H, rj, rd); ++} ++ ++void Assembler::clo_w(Register rd, Register rj) { GenRegister(CLO_W, rj, rd); } ++ ++void Assembler::clz_w(Register rd, Register rj) { GenRegister(CLZ_W, rj, rd); } ++ ++void Assembler::cto_w(Register rd, Register rj) { GenRegister(CTO_W, rj, rd); } ++ ++void Assembler::ctz_w(Register rd, Register rj) { GenRegister(CTZ_W, rj, rd); } ++ ++void Assembler::clo_d(Register rd, Register rj) { GenRegister(CLO_D, rj, rd); } ++ ++void Assembler::clz_d(Register rd, Register rj) { GenRegister(CLZ_D, rj, rd); } ++ ++void Assembler::cto_d(Register rd, Register rj) { GenRegister(CTO_D, rj, rd); } ++ ++void Assembler::ctz_d(Register rd, Register rj) { GenRegister(CTZ_D, rj, rd); } ++ ++void Assembler::bytepick_w(Register rd, Register rj, Register rk, int32_t sa2) { ++ DCHECK(is_uint2(sa2)); ++ GenImm(BYTEPICK_W, sa2, rk, rj, rd); ++} ++ ++void Assembler::bytepick_d(Register rd, Register rj, Register rk, int32_t sa3) { ++ GenImm(BYTEPICK_D, sa3, rk, rj, rd); ++} ++ ++void Assembler::revb_2h(Register rd, Register rj) { ++ GenRegister(REVB_2H, rj, rd); ++} ++ ++void Assembler::revb_4h(Register rd, Register rj) { ++ GenRegister(REVB_4H, rj, rd); ++} ++ ++void Assembler::revb_2w(Register rd, Register rj) { ++ GenRegister(REVB_2W, rj, rd); ++} ++ ++void Assembler::revb_d(Register rd, Register rj) { ++ GenRegister(REVB_D, rj, rd); ++} ++ ++void Assembler::revh_2w(Register rd, Register rj) { ++ GenRegister(REVH_2W, rj, rd); ++} ++ ++void Assembler::revh_d(Register rd, Register rj) { ++ GenRegister(REVH_D, rj, rd); ++} ++ ++void Assembler::bitrev_4b(Register rd, Register rj) { ++ GenRegister(BITREV_4B, rj, rd); ++} ++ ++void Assembler::bitrev_8b(Register rd, Register rj) { ++ GenRegister(BITREV_8B, rj, rd); ++} ++ ++void Assembler::bitrev_w(Register rd, Register rj) { ++ GenRegister(BITREV_W, rj, rd); ++} ++ ++void Assembler::bitrev_d(Register rd, Register rj) { ++ GenRegister(BITREV_D, rj, rd); ++} ++ ++void Assembler::bstrins_w(Register rd, Register rj, int32_t msbw, ++ int32_t lsbw) { ++ DCHECK(is_uint5(msbw) && is_uint5(lsbw)); ++ GenImm(BSTR_W, msbw + 0x20, lsbw, rj, rd); ++} ++ ++void Assembler::bstrins_d(Register rd, Register rj, int32_t msbd, ++ int32_t lsbd) { ++ GenImm(BSTRINS_D, msbd, lsbd, rj, rd); ++} ++ ++void Assembler::bstrpick_w(Register rd, Register rj, int32_t msbw, ++ int32_t lsbw) { ++ DCHECK(is_uint5(msbw) && is_uint5(lsbw)); ++ GenImm(BSTR_W, msbw + 0x20, lsbw + 0x20, rj, rd); ++} ++ ++void Assembler::bstrpick_d(Register rd, Register rj, int32_t msbd, ++ int32_t lsbd) { ++ GenImm(BSTRPICK_D, msbd, lsbd, rj, rd); ++} ++ ++void Assembler::maskeqz(Register rd, Register rj, Register rk) { ++ GenRegister(MASKEQZ, rk, rj, rd); ++} ++ ++void Assembler::masknez(Register rd, Register rj, Register rk) { ++ GenRegister(MASKNEZ, rk, rj, rd); ++} ++ ++// Memory-instructions ++void Assembler::ld_b(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_B, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_h(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_H, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_w(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_W, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_d(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_D, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_bu(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_BU, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_hu(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_HU, si12, rj, rd, 12); ++} ++ ++void Assembler::ld_wu(Register rd, Register rj, int32_t si12) { ++ GenImm(LD_WU, si12, rj, rd, 12); ++} ++ ++void Assembler::st_b(Register rd, Register rj, int32_t si12) { ++ GenImm(ST_B, si12, rj, rd, 12); ++} ++ ++void Assembler::st_h(Register rd, Register rj, int32_t si12) { ++ GenImm(ST_H, si12, rj, rd, 12); ++} ++ ++void Assembler::st_w(Register rd, Register rj, int32_t si12) { ++ GenImm(ST_W, si12, rj, rd, 12); ++} ++ ++void Assembler::st_d(Register rd, Register rj, int32_t si12) { ++ GenImm(ST_D, si12, rj, rd, 12); ++} ++ ++void Assembler::ldx_b(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_B, rk, rj, rd); ++} ++ ++void Assembler::ldx_h(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_H, rk, rj, rd); ++} ++ ++void Assembler::ldx_w(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_W, rk, rj, rd); ++} ++ ++void Assembler::ldx_d(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_D, rk, rj, rd); ++} ++ ++void Assembler::ldx_bu(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_BU, rk, rj, rd); ++} ++ ++void Assembler::ldx_hu(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_HU, rk, rj, rd); ++} ++ ++void Assembler::ldx_wu(Register rd, Register rj, Register rk) { ++ GenRegister(LDX_WU, rk, rj, rd); ++} ++ ++void Assembler::stx_b(Register rd, Register rj, Register rk) { ++ GenRegister(STX_B, rk, rj, rd); ++} ++ ++void Assembler::stx_h(Register rd, Register rj, Register rk) { ++ GenRegister(STX_H, rk, rj, rd); ++} ++ ++void Assembler::stx_w(Register rd, Register rj, Register rk) { ++ GenRegister(STX_W, rk, rj, rd); ++} ++ ++void Assembler::stx_d(Register rd, Register rj, Register rk) { ++ GenRegister(STX_D, rk, rj, rd); ++} ++ ++void Assembler::ldptr_w(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(LDPTR_W, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::ldptr_d(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(LDPTR_D, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::stptr_w(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(STPTR_W, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::stptr_d(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(STPTR_D, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::amswap_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMSWAP_W, rk, rj, rd); ++} ++ ++void Assembler::amswap_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMSWAP_D, rk, rj, rd); ++} ++ ++void Assembler::amadd_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMADD_W, rk, rj, rd); ++} ++ ++void Assembler::amadd_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMADD_D, rk, rj, rd); ++} ++ ++void Assembler::amand_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMAND_W, rk, rj, rd); ++} ++ ++void Assembler::amand_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMAND_D, rk, rj, rd); ++} ++ ++void Assembler::amor_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMOR_W, rk, rj, rd); ++} ++ ++void Assembler::amor_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMOR_D, rk, rj, rd); ++} ++ ++void Assembler::amxor_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMXOR_W, rk, rj, rd); ++} ++ ++void Assembler::amxor_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMXOR_D, rk, rj, rd); ++} ++ ++void Assembler::ammax_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_W, rk, rj, rd); ++} ++ ++void Assembler::ammax_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_D, rk, rj, rd); ++} ++ ++void Assembler::ammin_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_W, rk, rj, rd); ++} ++ ++void Assembler::ammin_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_D, rk, rj, rd); ++} ++ ++void Assembler::ammax_wu(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_WU, rk, rj, rd); ++} ++ ++void Assembler::ammax_du(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_DU, rk, rj, rd); ++} ++ ++void Assembler::ammin_wu(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_WU, rk, rj, rd); ++} ++ ++void Assembler::ammin_du(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_DU, rk, rj, rd); ++} ++ ++void Assembler::amswap_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMSWAP_DB_W, rk, rj, rd); ++} ++ ++void Assembler::amswap_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMSWAP_DB_D, rk, rj, rd); ++} ++ ++void Assembler::amadd_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMADD_DB_W, rk, rj, rd); ++} ++ ++void Assembler::amadd_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMADD_DB_D, rk, rj, rd); ++} ++ ++void Assembler::amand_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMAND_DB_W, rk, rj, rd); ++} ++ ++void Assembler::amand_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMAND_DB_D, rk, rj, rd); ++} ++ ++void Assembler::amor_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMOR_DB_W, rk, rj, rd); ++} ++ ++void Assembler::amor_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMOR_DB_D, rk, rj, rd); ++} ++ ++void Assembler::amxor_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMXOR_DB_W, rk, rj, rd); ++} ++ ++void Assembler::amxor_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMXOR_DB_D, rk, rj, rd); ++} ++ ++void Assembler::ammax_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_DB_W, rk, rj, rd); ++} ++ ++void Assembler::ammax_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_DB_D, rk, rj, rd); ++} ++ ++void Assembler::ammin_db_w(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_DB_W, rk, rj, rd); ++} ++ ++void Assembler::ammin_db_d(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_DB_D, rk, rj, rd); ++} ++ ++void Assembler::ammax_db_wu(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_DB_WU, rk, rj, rd); ++} ++ ++void Assembler::ammax_db_du(Register rd, Register rk, Register rj) { ++ GenRegister(AMMAX_DB_DU, rk, rj, rd); ++} ++ ++void Assembler::ammin_db_wu(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_DB_WU, rk, rj, rd); ++} ++ ++void Assembler::ammin_db_du(Register rd, Register rk, Register rj) { ++ GenRegister(AMMIN_DB_DU, rk, rj, rd); ++} ++ ++void Assembler::ll_w(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(LL_W, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::ll_d(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(LL_D, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::sc_w(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(SC_W, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::sc_d(Register rd, Register rj, int32_t si14) { ++ DCHECK(is_int16(si14) && ((si14 & 0x3) == 0)); ++ GenImm(SC_D, si14 >> 2, rj, rd, 14); ++} ++ ++void Assembler::dbar(int32_t hint) { GenImm(DBAR, hint); } ++ ++void Assembler::ibar(int32_t hint) { GenImm(IBAR, hint); } ++ ++// Break / Trap instructions. ++void Assembler::break_(uint32_t code, bool break_as_stop) { ++ DCHECK( ++ (break_as_stop && code <= kMaxStopCode && code > kMaxWatchpointCode) || ++ (!break_as_stop && (code > kMaxStopCode || code <= kMaxWatchpointCode))); ++ GenImm(BREAK, code); ++} ++ ++void Assembler::stop(uint32_t code) { ++ DCHECK_GT(code, kMaxWatchpointCode); ++ DCHECK_LE(code, kMaxStopCode); ++#if defined(V8_HOST_ARCH_LA64) ++ break_(0x4321); ++#else // V8_HOST_ARCH_LA64 ++ break_(code, true); ++#endif ++} ++ ++void Assembler::fadd_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FADD_S, fk, fj, fd); ++} ++ ++void Assembler::fadd_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FADD_D, fk, fj, fd); ++} ++ ++void Assembler::fsub_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FSUB_S, fk, fj, fd); ++} ++ ++void Assembler::fsub_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FSUB_D, fk, fj, fd); ++} ++ ++void Assembler::fmul_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMUL_S, fk, fj, fd); ++} ++ ++void Assembler::fmul_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMUL_D, fk, fj, fd); ++} ++ ++void Assembler::fdiv_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FDIV_S, fk, fj, fd); ++} ++ ++void Assembler::fdiv_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FDIV_D, fk, fj, fd); ++} ++ ++void Assembler::fmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FMADD_S, fa, fk, fj, fd); ++} ++ ++void Assembler::fmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FMADD_D, fa, fk, fj, fd); ++} ++ ++void Assembler::fmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FMSUB_S, fa, fk, fj, fd); ++} ++ ++void Assembler::fmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FMSUB_D, fa, fk, fj, fd); ++} ++ ++void Assembler::fnmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FNMADD_S, fa, fk, fj, fd); ++} ++ ++void Assembler::fnmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FNMADD_D, fa, fk, fj, fd); ++} ++ ++void Assembler::fnmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FNMSUB_S, fa, fk, fj, fd); ++} ++ ++void Assembler::fnmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, ++ FPURegister fa) { ++ GenRegister(FNMSUB_D, fa, fk, fj, fd); ++} ++ ++void Assembler::fmax_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMAX_S, fk, fj, fd); ++} ++ ++void Assembler::fmax_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMAX_D, fk, fj, fd); ++} ++ ++void Assembler::fmin_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMIN_S, fk, fj, fd); ++} ++ ++void Assembler::fmin_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMIN_D, fk, fj, fd); ++} ++ ++void Assembler::fmaxa_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMAXA_S, fk, fj, fd); ++} ++ ++void Assembler::fmaxa_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMAXA_D, fk, fj, fd); ++} ++ ++void Assembler::fmina_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMINA_S, fk, fj, fd); ++} ++ ++void Assembler::fmina_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FMINA_D, fk, fj, fd); ++} ++ ++void Assembler::fabs_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FABS_S, fj, fd); ++} ++ ++void Assembler::fabs_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FABS_D, fj, fd); ++} ++ ++void Assembler::fneg_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FNEG_S, fj, fd); ++} ++ ++void Assembler::fneg_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FNEG_D, fj, fd); ++} ++ ++void Assembler::fsqrt_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FSQRT_S, fj, fd); ++} ++ ++void Assembler::fsqrt_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FSQRT_D, fj, fd); ++} ++ ++void Assembler::frecip_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FRECIP_S, fj, fd); ++} ++ ++void Assembler::frecip_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FRECIP_D, fj, fd); ++} ++ ++void Assembler::frsqrt_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FRSQRT_S, fj, fd); ++} ++ ++void Assembler::frsqrt_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FRSQRT_D, fj, fd); ++} ++ ++void Assembler::fscaleb_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FSCALEB_S, fk, fj, fd); ++} ++ ++void Assembler::fscaleb_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FSCALEB_D, fk, fj, fd); ++} ++ ++void Assembler::flogb_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FLOGB_S, fj, fd); ++} ++ ++void Assembler::flogb_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FLOGB_D, fj, fd); ++} ++ ++void Assembler::fcopysign_s(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FCOPYSIGN_S, fk, fj, fd); ++} ++ ++void Assembler::fcopysign_d(FPURegister fd, FPURegister fj, FPURegister fk) { ++ GenRegister(FCOPYSIGN_D, fk, fj, fd); ++} ++ ++void Assembler::fclass_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FCLASS_S, fj, fd); ++} ++ ++void Assembler::fclass_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FCLASS_D, fj, fd); ++} ++ ++void Assembler::fcmp_cond_s(FPUCondition cc, FPURegister fj, FPURegister fk, ++ CFRegister cd) { ++ GenCmp(FCMP_COND_S, cc, fk, fj, cd); ++} ++ ++void Assembler::fcmp_cond_d(FPUCondition cc, FPURegister fj, FPURegister fk, ++ CFRegister cd) { ++ GenCmp(FCMP_COND_D, cc, fk, fj, cd); ++} ++ ++void Assembler::fcvt_s_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FCVT_S_D, fj, fd); ++} ++ ++void Assembler::fcvt_d_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FCVT_D_S, fj, fd); ++} ++ ++void Assembler::ffint_s_w(FPURegister fd, FPURegister fj) { ++ GenRegister(FFINT_S_W, fj, fd); ++} ++ ++void Assembler::ffint_s_l(FPURegister fd, FPURegister fj) { ++ GenRegister(FFINT_S_L, fj, fd); ++} ++ ++void Assembler::ffint_d_w(FPURegister fd, FPURegister fj) { ++ GenRegister(FFINT_D_W, fj, fd); ++} ++ ++void Assembler::ffint_d_l(FPURegister fd, FPURegister fj) { ++ GenRegister(FFINT_D_L, fj, fd); ++} ++ ++void Assembler::ftint_w_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINT_W_S, fj, fd); ++} ++ ++void Assembler::ftint_w_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINT_W_D, fj, fd); ++} ++ ++void Assembler::ftint_l_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINT_L_S, fj, fd); ++} ++ ++void Assembler::ftint_l_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINT_L_D, fj, fd); ++} ++ ++void Assembler::ftintrm_w_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRM_W_S, fj, fd); ++} ++ ++void Assembler::ftintrm_w_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRM_W_D, fj, fd); ++} ++ ++void Assembler::ftintrm_l_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRM_L_S, fj, fd); ++} ++ ++void Assembler::ftintrm_l_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRM_L_D, fj, fd); ++} ++ ++void Assembler::ftintrp_w_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRP_W_S, fj, fd); ++} ++ ++void Assembler::ftintrp_w_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRP_W_D, fj, fd); ++} ++ ++void Assembler::ftintrp_l_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRP_L_S, fj, fd); ++} ++ ++void Assembler::ftintrp_l_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRP_L_D, fj, fd); ++} ++ ++void Assembler::ftintrz_w_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRZ_W_S, fj, fd); ++} ++ ++void Assembler::ftintrz_w_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRZ_W_D, fj, fd); ++} ++ ++void Assembler::ftintrz_l_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRZ_L_S, fj, fd); ++} ++ ++void Assembler::ftintrz_l_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRZ_L_D, fj, fd); ++} ++ ++void Assembler::ftintrne_w_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRNE_W_S, fj, fd); ++} ++ ++void Assembler::ftintrne_w_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRNE_W_D, fj, fd); ++} ++ ++void Assembler::ftintrne_l_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRNE_L_S, fj, fd); ++} ++ ++void Assembler::ftintrne_l_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FTINTRNE_L_D, fj, fd); ++} ++ ++void Assembler::frint_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FRINT_S, fj, fd); ++} ++ ++void Assembler::frint_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FRINT_D, fj, fd); ++} ++ ++void Assembler::fmov_s(FPURegister fd, FPURegister fj) { ++ GenRegister(FMOV_S, fj, fd); ++} ++ ++void Assembler::fmov_d(FPURegister fd, FPURegister fj) { ++ GenRegister(FMOV_D, fj, fd); ++} ++ ++void Assembler::fsel(CFRegister ca, FPURegister fd, FPURegister fj, ++ FPURegister fk) { ++ GenSel(FSEL, ca, fk, fj, fd); ++} ++ ++void Assembler::movgr2fr_w(FPURegister fd, Register rj) { ++ GenRegister(MOVGR2FR_W, rj, fd); ++} ++ ++void Assembler::movgr2fr_d(FPURegister fd, Register rj) { ++ GenRegister(MOVGR2FR_D, rj, fd); ++} ++ ++void Assembler::movgr2frh_w(FPURegister fd, Register rj) { ++ GenRegister(MOVGR2FRH_W, rj, fd); ++} ++ ++void Assembler::movfr2gr_s(Register rd, FPURegister fj) { ++ GenRegister(MOVFR2GR_S, fj, rd); ++} ++ ++void Assembler::movfr2gr_d(Register rd, FPURegister fj) { ++ GenRegister(MOVFR2GR_D, fj, rd); ++} ++ ++void Assembler::movfrh2gr_s(Register rd, FPURegister fj) { ++ GenRegister(MOVFRH2GR_S, fj, rd); ++} ++ ++void Assembler::movgr2fcsr(Register rj) { GenRegister(MOVGR2FCSR, rj, FCSR); } ++ ++void Assembler::movfcsr2gr(Register rd) { GenRegister(MOVFCSR2GR, FCSR, rd); } ++ ++void Assembler::movfr2cf(CFRegister cd, FPURegister fj) { ++ GenRegister(MOVFR2CF, fj, cd); ++} ++ ++void Assembler::movcf2fr(FPURegister fd, CFRegister cj) { ++ GenRegister(MOVCF2FR, cj, fd); ++} ++ ++void Assembler::movgr2cf(CFRegister cd, Register rj) { ++ GenRegister(MOVGR2CF, rj, cd); ++} ++ ++void Assembler::movcf2gr(Register rd, CFRegister cj) { ++ GenRegister(MOVCF2GR, cj, rd); ++} ++ ++void Assembler::fld_s(FPURegister fd, Register rj, int32_t si12) { ++ GenImm(FLD_S, si12, rj, fd); ++} ++ ++void Assembler::fld_d(FPURegister fd, Register rj, int32_t si12) { ++ GenImm(FLD_D, si12, rj, fd); ++} ++ ++void Assembler::fst_s(FPURegister fd, Register rj, int32_t si12) { ++ GenImm(FST_S, si12, rj, fd); ++} ++ ++void Assembler::fst_d(FPURegister fd, Register rj, int32_t si12) { ++ GenImm(FST_D, si12, rj, fd); ++} ++ ++void Assembler::fldx_s(FPURegister fd, Register rj, Register rk) { ++ GenRegister(FLDX_S, rk, rj, fd); ++} ++ ++void Assembler::fldx_d(FPURegister fd, Register rj, Register rk) { ++ GenRegister(FLDX_D, rk, rj, fd); ++} ++ ++void Assembler::fstx_s(FPURegister fd, Register rj, Register rk) { ++ GenRegister(FSTX_S, rk, rj, fd); ++} ++ ++void Assembler::fstx_d(FPURegister fd, Register rj, Register rk) { ++ GenRegister(FSTX_D, rk, rj, fd); ++} ++ ++// ------------Memory-instructions------------- ++ ++/*void Assembler::AdjustBaseAndOffset(MemOperand* src, ++ OffsetAccessType access_type, ++ int second_access_add_to_offset) { ++ // TODO should be optimized. ++ // This method is used to adjust the base register and offset pair ++ // for a load/store when the offset doesn't fit into int12_t. ++ ++ bool doubleword_aligned = (src->offset() & (kDoubleSize - 1)) == 0; ++ bool two_accesses = static_cast(access_type) || !doubleword_aligned; ++ DCHECK_LE(second_access_add_to_offset, 7); // Must be <= 7. ++ ++ // is_int12 must be passed a signed value, hence the static cast below. ++ if (is_int12(src->offset()) && ++ (!two_accesses || is_int12(static_cast( ++ src->offset() + second_access_add_to_offset)))) { ++ // Nothing to do: 'offset' (and, if needed, 'offset + 4', or other specified ++ // value) fits into int16_t. ++ return; ++ } ++ ++ DCHECK(src->rm() != ++ at); // Must not overwrite the register 'base' while loading 'offset'. ++ ++#ifdef DEBUG ++ // Remember the "(mis)alignment" of 'offset', it will be checked at the end. ++ uint32_t misalignment = src->offset() & (kDoubleSize - 1); ++#endif ++ ++ // Do not load the whole 32-bit 'offset' if it can be represented as ++ // a sum of two 16-bit signed offsets. This can save an instruction or two. ++ // To simplify matters, only do this for a symmetric range of offsets from ++ // about -64KB to about +64KB, allowing further addition of 4 when accessing ++ // 64-bit variables with two 32-bit accesses. ++ constexpr int32_t kMinOffsetForSimpleAdjustment = ++ 0x7FF8; // Max int16_t that's a multiple of 8. ++ constexpr int32_t kMaxOffsetForSimpleAdjustment = ++ 2 * kMinOffsetForSimpleAdjustment; ++ ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ if (0 <= src->offset() && src->offset() <= kMaxOffsetForSimpleAdjustment) { ++ daddiu(scratch, src->rm(), kMinOffsetForSimpleAdjustment); ++ src->offset_ -= kMinOffsetForSimpleAdjustment; ++ } else if (-kMaxOffsetForSimpleAdjustment <= src->offset() && ++ src->offset() < 0) { ++ daddiu(scratch, src->rm(), -kMinOffsetForSimpleAdjustment); ++ src->offset_ += kMinOffsetForSimpleAdjustment; ++ } else if (kArchVariant == kMips64r6) { ++ // On r6 take advantage of the daui instruction, e.g.: ++ // daui at, base, offset_high ++ // [dahi at, 1] // When `offset` is close to +2GB. ++ // lw reg_lo, offset_low(at) ++ // [lw reg_hi, (offset_low+4)(at)] // If misaligned 64-bit load. ++ // or when offset_low+4 overflows int16_t: ++ // daui at, base, offset_high ++ // daddiu at, at, 8 ++ // lw reg_lo, (offset_low-8)(at) ++ // lw reg_hi, (offset_low-4)(at) ++ int16_t offset_low = static_cast(src->offset()); ++ int32_t offset_low32 = offset_low; ++ int16_t offset_high = static_cast(src->offset() >> 16); ++ bool increment_hi16 = offset_low < 0; ++ bool overflow_hi16 = false; ++ ++ if (increment_hi16) { ++ offset_high++; ++ overflow_hi16 = (offset_high == -32768); ++ } ++ daui(scratch, src->rm(), static_cast(offset_high)); ++ ++ if (overflow_hi16) { ++ dahi(scratch, 1); ++ } ++ ++ if (two_accesses && !is_int16(static_cast( ++ offset_low32 + second_access_add_to_offset))) { ++ // Avoid overflow in the 16-bit offset of the load/store instruction when ++ // adding 4. ++ daddiu(scratch, scratch, kDoubleSize); ++ offset_low32 -= kDoubleSize; ++ } ++ ++ src->offset_ = offset_low32; ++ } else { ++ // Do not load the whole 32-bit 'offset' if it can be represented as ++ // a sum of three 16-bit signed offsets. This can save an instruction. ++ // To simplify matters, only do this for a symmetric range of offsets from ++ // about -96KB to about +96KB, allowing further addition of 4 when accessing ++ // 64-bit variables with two 32-bit accesses. ++ constexpr int32_t kMinOffsetForMediumAdjustment = ++ 2 * kMinOffsetForSimpleAdjustment; ++ constexpr int32_t kMaxOffsetForMediumAdjustment = ++ 3 * kMinOffsetForSimpleAdjustment; ++ if (0 <= src->offset() && src->offset() <= kMaxOffsetForMediumAdjustment) { ++ daddiu(scratch, src->rm(), kMinOffsetForMediumAdjustment / 2); ++ daddiu(scratch, scratch, kMinOffsetForMediumAdjustment / 2); ++ src->offset_ -= kMinOffsetForMediumAdjustment; ++ } else if (-kMaxOffsetForMediumAdjustment <= src->offset() && ++ src->offset() < 0) { ++ daddiu(scratch, src->rm(), -kMinOffsetForMediumAdjustment / 2); ++ daddiu(scratch, scratch, -kMinOffsetForMediumAdjustment / 2); ++ src->offset_ += kMinOffsetForMediumAdjustment; ++ } else { ++ // Now that all shorter options have been exhausted, load the full 32-bit ++ // offset. ++ int32_t loaded_offset = RoundDown(src->offset(), kDoubleSize); ++ lui(scratch, (loaded_offset >> kLuiShift) & kImm16Mask); ++ ori(scratch, scratch, loaded_offset & kImm16Mask); // Load 32-bit offset. ++ daddu(scratch, scratch, src->rm()); ++ src->offset_ -= loaded_offset; ++ } ++ } ++ src->rm_ = scratch; ++ ++ DCHECK(is_int16(src->offset())); ++ if (two_accesses) { ++ DCHECK(is_int16( ++ static_cast(src->offset() + second_access_add_to_offset))); ++ } ++ DCHECK(misalignment == (src->offset() & (kDoubleSize - 1))); ++}*/ ++ ++void Assembler::AdjustBaseAndOffset(MemOperand* src) { ++ // is_int12 must be passed a signed value, hence the static cast below. ++ if ((!src->hasIndexReg() && is_int12(src->offset())) || src->hasIndexReg()) { ++ return; ++ } ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ if (is_uint12(static_cast(src->offset()))) { ++ ori(scratch, zero_reg, src->offset() & kImm12Mask); ++ } else { ++ lu12i_w(scratch, src->offset() >> 12 & 0xfffff); ++ if (src->offset() & kImm12Mask) { ++ ori(scratch, scratch, src->offset() & kImm12Mask); ++ } ++ } ++ src->index_ = scratch; ++ src->offset_ = 0; ++ // TODO can be optimized, for example 2 * [int12_min, int12_max] ++ // addi_d scratch base, offset/2 only on instr ++ // base = scratch ++ // offset = offset - offset / 2 ++} ++ ++int Assembler::RelocateInternalReference(RelocInfo::Mode rmode, Address pc, ++ intptr_t pc_delta) { ++ if (RelocInfo::IsInternalReference(rmode)) { ++ int64_t* p = reinterpret_cast(pc); ++ if (*p == kEndOfJumpChain) { ++ return 0; // Number of instructions patched. ++ } ++ *p += pc_delta; ++ return 2; // Number of instructions patched. ++ } ++ abort(); ++ /* Instr instr = instr_at(pc); ++ DCHECK(RelocInfo::IsInternalReferenceEncoded(rmode)); ++ if (IsLui(instr)) { ++ Instr instr_lui = instr_at(pc + 0 * kInstrSize); ++ Instr instr_ori = instr_at(pc + 1 * kInstrSize); ++ Instr instr_ori2 = instr_at(pc + 3 * kInstrSize); ++ DCHECK(IsOri(instr_ori)); ++ DCHECK(IsOri(instr_ori2)); ++ // TODO(plind): symbolic names for the shifts. ++ int64_t imm = (instr_lui & static_cast(kImm16Mask)) << 48; ++ imm |= (instr_ori & static_cast(kImm16Mask)) << 32; ++ imm |= (instr_ori2 & static_cast(kImm16Mask)) << 16; ++ // Sign extend address. ++ imm >>= 16; ++ ++ if (imm == kEndOfJumpChain) { ++ return 0; // Number of instructions patched. ++ } ++ imm += pc_delta; ++ DCHECK_EQ(imm & 3, 0); ++ ++ instr_lui &= ~kImm16Mask; ++ instr_ori &= ~kImm16Mask; ++ instr_ori2 &= ~kImm16Mask; ++ ++ instr_at_put(pc + 0 * kInstrSize, instr_lui | ((imm >> 32) & kImm16Mask)); ++ instr_at_put(pc + 1 * kInstrSize, instr_ori | (imm >> 16 & kImm16Mask)); ++ instr_at_put(pc + 3 * kInstrSize, instr_ori2 | (imm & kImm16Mask)); ++ return 4; // Number of instructions patched. ++ } else if (IsJ(instr) || IsJal(instr)) { ++ // Regular j/jal relocation. ++ uint32_t imm28 = (instr & static_cast(kImm26Mask)) << 2; ++ imm28 += pc_delta; ++ imm28 &= kImm28Mask; ++ instr &= ~kImm26Mask; ++ DCHECK_EQ(imm28 & 3, 0); ++ uint32_t imm26 = static_cast(imm28 >> 2); ++ instr_at_put(pc, instr | (imm26 & kImm26Mask)); ++ return 1; // Number of instructions patched. ++ } else { ++ DCHECK(((instr & kJumpRawMask) == kJRawMark) || ++ ((instr & kJumpRawMask) == kJalRawMark)); ++ // Unbox raw offset and emit j/jal. ++ int32_t imm28 = (instr & static_cast(kImm26Mask)) << 2; ++ // Sign extend 28-bit offset to 32-bit. ++ imm28 = (imm28 << 4) >> 4; ++ uint64_t target = ++ static_cast(imm28) + reinterpret_cast(pc); ++ target &= kImm28Mask; ++ DCHECK_EQ(imm28 & 3, 0); ++ uint32_t imm26 = static_cast(target >> 2); ++ // Check markings whether to emit j or jal. ++ uint32_t unbox = (instr & kJRawMark) ? J : JAL; ++ instr_at_put(pc, unbox | (imm26 & kImm26Mask)); ++ return 1; // Number of instructions patched. ++ }*/ ++} ++ ++void Assembler::GrowBuffer() { ++ // Compute new buffer size. ++ int old_size = buffer_->size(); ++ int new_size = std::min(2 * old_size, old_size + 1 * MB); ++ ++ // Some internal data structures overflow for very large buffers, ++ // they must ensure that kMaximalBufferSize is not too large. ++ if (new_size > kMaximalBufferSize) { ++ V8::FatalProcessOutOfMemory(nullptr, "Assembler::GrowBuffer"); ++ } ++ ++ // Set up new buffer. ++ std::unique_ptr new_buffer = buffer_->Grow(new_size); ++ DCHECK_EQ(new_size, new_buffer->size()); ++ byte* new_start = new_buffer->start(); ++ ++ // Copy the data. ++ intptr_t pc_delta = new_start - buffer_start_; ++ intptr_t rc_delta = (new_start + new_size) - (buffer_start_ + old_size); ++ size_t reloc_size = (buffer_start_ + old_size) - reloc_info_writer.pos(); ++ MemMove(new_start, buffer_start_, pc_offset()); ++ MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(), ++ reloc_size); ++ ++ // Switch buffers. ++ buffer_ = std::move(new_buffer); ++ buffer_start_ = new_start; ++ pc_ += pc_delta; ++ last_call_pc_ += pc_delta; ++ reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, ++ reloc_info_writer.last_pc() + pc_delta); ++ ++ // Relocate runtime entries. ++ Vector instructions{buffer_start_, pc_offset()}; ++ Vector reloc_info{reloc_info_writer.pos(), reloc_size}; ++ for (RelocIterator it(instructions, reloc_info, 0); !it.done(); it.next()) { ++ RelocInfo::Mode rmode = it.rinfo()->rmode(); ++ if (rmode == RelocInfo::INTERNAL_REFERENCE) { ++ RelocateInternalReference(rmode, it.rinfo()->pc(), pc_delta); ++ } ++ } ++ DCHECK(!overflow()); ++} ++ ++void Assembler::db(uint8_t data) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ *reinterpret_cast(pc_) = data; ++ pc_ += sizeof(uint8_t); ++} ++ ++void Assembler::dd(uint32_t data) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ *reinterpret_cast(pc_) = data; ++ pc_ += sizeof(uint32_t); ++} ++ ++void Assembler::dq(uint64_t data) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ *reinterpret_cast(pc_) = data; ++ pc_ += sizeof(uint64_t); ++} ++ ++void Assembler::dd(Label* label) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ uint64_t data; ++ if (label->is_bound()) { ++ data = reinterpret_cast(buffer_start_ + label->pos()); ++ } else { ++ data = jump_address(label); ++ unbound_labels_count_++; ++ internal_reference_positions_.insert(label->pos()); ++ } ++ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE); ++ EmitHelper(data); ++} ++ ++void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ++ if (!ShouldRecordRelocInfo(rmode)) return; ++ // We do not try to reuse pool constants. ++ RelocInfo rinfo(reinterpret_cast
(pc_), rmode, data, Code()); ++ DCHECK_GE(buffer_space(), kMaxRelocSize); // Too late to grow buffer here. ++ reloc_info_writer.Write(&rinfo); ++} ++ ++void Assembler::BlockTrampolinePoolFor(int instructions) { ++ CheckTrampolinePoolQuick(instructions); ++ BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); ++} ++ ++void Assembler::CheckTrampolinePool() { ++ // Some small sequences of instructions must not be broken up by the ++ // insertion of a trampoline pool; such sequences are protected by setting ++ // either trampoline_pool_blocked_nesting_ or no_trampoline_pool_before_, ++ // which are both checked here. Also, recursive calls to CheckTrampolinePool ++ // are blocked by trampoline_pool_blocked_nesting_. ++ if ((trampoline_pool_blocked_nesting_ > 0) || ++ (pc_offset() < no_trampoline_pool_before_)) { ++ // Emission is currently blocked; make sure we try again as soon as ++ // possible. ++ if (trampoline_pool_blocked_nesting_ > 0) { ++ next_buffer_check_ = pc_offset() + kInstrSize; ++ } else { ++ next_buffer_check_ = no_trampoline_pool_before_; ++ } ++ return; ++ } ++ ++ DCHECK(!trampoline_emitted_); ++ DCHECK_GE(unbound_labels_count_, 0); ++ if (unbound_labels_count_ > 0) { ++ // First we emit jump (2 instructions), then we emit trampoline pool. ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Label after_pool; ++ b(&after_pool); ++ nop(); // TODO remove this ++ ++ int pool_start = pc_offset(); ++ for (int i = 0; i < unbound_labels_count_; i++) { ++ { ++ b(&after_pool); ++ nop(); // TODO remove this ++ } ++ } ++ nop(); ++ trampoline_ = Trampoline(pool_start, unbound_labels_count_); ++ bind(&after_pool); ++ ++ trampoline_emitted_ = true; ++ // As we are only going to emit trampoline once, we need to prevent any ++ // further emission. ++ next_buffer_check_ = kMaxInt; ++ } ++ } else { ++ // Number of branches to unbound label at this point is zero, so we can ++ // move next buffer check to maximum. ++ next_buffer_check_ = ++ pc_offset() + kMax16BranchOffset - kTrampolineSlotsSize * 16; ++ } ++ return; ++} ++ ++Address Assembler::target_address_at(Address pc) { ++ Instr instr0 = instr_at(pc); ++ Instr instr1 = instr_at(pc + 1 * kInstrSize); ++ Instr instr2 = instr_at(pc + 2 * kInstrSize); ++ ++ // Interpret 4 instructions for address generated by li: See listing in ++ // Assembler::set_target_address_at() just below. ++ DCHECK((IsLu12i_w(instr0) && (IsOri(instr1)) && (IsLu32i_d(instr2)))); ++ ++ // Assemble the 48 bit value. ++ uint64_t hi20 = ((uint64_t)(instr2 >> 5) & 0xfffff) << 32; ++ uint64_t mid20 = ((uint64_t)(instr0 >> 5) & 0xfffff) << 12; ++ uint64_t low12 = ((uint64_t)(instr1 >> 10) & 0xfff); ++ int64_t addr = static_cast(hi20 | mid20 | low12); ++ ++ // Sign extend to get canonical address. ++ addr = (addr << 16) >> 16; ++ // printf("add : 0x%lx 0x%lx 0x%lx 0x%lx\n", addr, hi20, mid20, low12); ++ return static_cast
(addr); ++} ++ ++// On la64, a target address is stored in a 3-instruction sequence: ++// 0: lu12i_w(rd, (j.imm64_ >> 12) & kImm20Mask); ++// 1: ori(rd, rd, j.imm64_ & kImm12Mask); ++// 2: lu32i_d(rd, (j.imm64_ >> 32) & kImm20Mask); ++// ++// Patching the address must replace all the lui & ori instructions, ++// and flush the i-cache. ++// ++// There is an optimization below, which emits a nop when the address ++// fits in just 16 bits. This is unlikely to help, and should be benchmarked, ++// and possibly removed. ++void Assembler::set_target_value_at(Address pc, uint64_t target, ++ ICacheFlushMode icache_flush_mode) { ++ // There is an optimization where only 3 instructions are used to load address ++ // in code on LA64 because only 48-bits of address is effectively used. ++ // It relies on fact the upper [63:48] bits are not used for virtual address ++ // translation and they have to be set according to value of bit 47 in order ++ // get canonical address. ++#ifdef DEBUG ++ // Check we have the result from a li macro-instruction. ++ Instr instr0 = instr_at(pc); ++ Instr instr1 = instr_at(pc + kInstrSize); ++ Instr instr2 = instr_at(pc + kInstrSize * 2); ++ DCHECK(IsLu12i_w(instr0) && IsOri(instr1) && IsLu32i_d(instr2)); ++#endif ++ ++ Instr instr = instr_at(pc); ++ uint32_t rd_code = GetRd(instr); ++ uint32_t* p = reinterpret_cast(pc); ++ ++ // Must use 3 instructions to insure patchable code. ++ // lu12i_w rd, middle-20. ++ // ori rd, rd, low-12. ++ // li32i_d rd, high-20. ++ *p = LU12I_W | (((target >> 12) & 0xfffff) << kRjShift) | rd_code; ++ *(p + 1) = ++ ORI | (target & 0xfff) << kRkShift | (rd_code << kRjShift) | rd_code; ++ *(p + 2) = LU32I_D | (((target >> 32) & 0xfffff) << kRjShift) | rd_code; ++ ++ if (icache_flush_mode != SKIP_ICACHE_FLUSH) { ++ FlushInstructionCache(pc, 3 * kInstrSize); ++ } ++} ++ ++UseScratchRegisterScope::UseScratchRegisterScope(Assembler* assembler) ++ : available_(assembler->GetScratchRegisterList()), ++ old_available_(*available_) {} ++ ++UseScratchRegisterScope::~UseScratchRegisterScope() { ++ *available_ = old_available_; ++} ++ ++Register UseScratchRegisterScope::Acquire() { ++ DCHECK_NOT_NULL(available_); ++ DCHECK_NE(*available_, 0); ++ int index = static_cast(base::bits::CountTrailingZeros32(*available_)); ++ *available_ &= ~(1UL << index); ++ ++ return Register::from_code(index); ++} ++ ++bool UseScratchRegisterScope::hasAvailable() const { return *available_ != 0; } ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/assembler-loongarch64.h +@@ -0,0 +1,1137 @@ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#ifndef V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ ++#define V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ ++ ++#include ++ ++#include ++#include ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/external-reference.h" ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/loongarch64/register-loongarch64.h" ++#include "src/codegen/label.h" ++#include "src/objects/contexts.h" ++#include "src/objects/smi.h" ++ ++namespace v8 { ++namespace internal { ++ ++class SafepointTableBuilder; ++ ++// ----------------------------------------------------------------------------- ++// Machine instruction Operands. ++constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize; ++constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; ++// Class Operand represents a shifter operand in data processing instructions. ++class Operand { ++ public: ++ // Immediate. ++ V8_INLINE explicit Operand(int64_t immediate, ++ RelocInfo::Mode rmode = RelocInfo::NONE) ++ : rm_(no_reg), rmode_(rmode) { ++ value_.immediate = immediate; ++ } ++ V8_INLINE explicit Operand(const ExternalReference& f) ++ : rm_(no_reg), rmode_(RelocInfo::EXTERNAL_REFERENCE) { ++ value_.immediate = static_cast(f.address()); ++ } ++ explicit Operand(Handle handle); ++ V8_INLINE explicit Operand(Smi value) : rm_(no_reg), rmode_(RelocInfo::NONE) { ++ value_.immediate = static_cast(value.ptr()); ++ } ++ ++ static Operand EmbeddedNumber(double number); // Smi or HeapNumber. ++ static Operand EmbeddedStringConstant(const StringConstantBase* str); ++ ++ // Register. ++ V8_INLINE explicit Operand(Register rm) : rm_(rm) {} ++ ++ // Return true if this is a register operand. ++ V8_INLINE bool is_reg() const; ++ ++ inline int64_t immediate() const; ++ ++ bool IsImmediate() const { return !rm_.is_valid(); } ++ ++ HeapObjectRequest heap_object_request() const { ++ DCHECK(IsHeapObjectRequest()); ++ return value_.heap_object_request; ++ } ++ ++ bool IsHeapObjectRequest() const { ++ DCHECK_IMPLIES(is_heap_object_request_, IsImmediate()); ++ DCHECK_IMPLIES(is_heap_object_request_, ++ rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT || ++ rmode_ == RelocInfo::CODE_TARGET); ++ return is_heap_object_request_; ++ } ++ ++ Register rm() const { return rm_; } ++ ++ RelocInfo::Mode rmode() const { return rmode_; } ++ ++ private: ++ Register rm_; ++ union Value { ++ Value() {} ++ HeapObjectRequest heap_object_request; // if is_heap_object_request_ ++ int64_t immediate; // otherwise ++ } value_; // valid if rm_ == no_reg ++ bool is_heap_object_request_ = false; ++ RelocInfo::Mode rmode_; ++ ++ friend class Assembler; ++ friend class MacroAssembler; ++}; ++ ++// Class MemOperand represents a memory operand in load and store instructions. ++// 1: base_reg + off_imm( si12 | si14<<2) ++// 2: base_reg + offset_reg ++class V8_EXPORT_PRIVATE MemOperand { ++ public: ++ explicit MemOperand(Register rj, int32_t offset = 0); ++ explicit MemOperand(Register rj, Register offset = no_reg); ++ Register base() const { return base_; } ++ Register index() const { return index_; } ++ int32_t offset() const { return offset_; } ++ ++ bool hasIndexReg() const { return index_ != no_reg; } ++ ++ private: ++ Register base_; // base ++ Register index_; // index ++ int32_t offset_; // offset ++ ++ friend class Assembler; ++}; ++ ++class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ++ public: ++ // Create an assembler. Instructions and relocation information are emitted ++ // into a buffer, with the instructions starting from the beginning and the ++ // relocation information starting from the end of the buffer. See CodeDesc ++ // for a detailed comment on the layout (globals.h). ++ // ++ // If the provided buffer is nullptr, the assembler allocates and grows its ++ // own buffer. Otherwise it takes ownership of the provided buffer. ++ explicit Assembler(const AssemblerOptions&, ++ std::unique_ptr = {}); ++ ++ virtual ~Assembler() {} ++ ++ // GetCode emits any pending (non-emitted) code and fills the descriptor desc. ++ static constexpr int kNoHandlerTable = 0; ++ static constexpr SafepointTableBuilder* kNoSafepointTable = nullptr; ++ void GetCode(Isolate* isolate, CodeDesc* desc, ++ SafepointTableBuilder* safepoint_table_builder, ++ int handler_table_offset); ++ ++ // Convenience wrapper for code without safepoint or handler tables. ++ void GetCode(Isolate* isolate, CodeDesc* desc) { ++ GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable); ++ } ++ ++ // Unused on this architecture. ++ void MaybeEmitOutOfLineConstantPool() {} ++ ++ // La64 uses BlockTrampolinePool to prevent generating trampoline inside a ++ // continuous instruction block. For Call instruction, it prevents generating ++ // trampoline between jalr and delay slot instruction. In the destructor of ++ // BlockTrampolinePool, it must check if it needs to generate trampoline ++ // immediately, if it does not do this, the branch range will go beyond the ++ // max branch offset, that means the pc_offset after call CheckTrampolinePool ++ // may be not the Call instruction's location. So we use last_call_pc here for ++ // safepoint record. ++ int pc_offset_for_safepoint() { ++ return static_cast(last_call_pc_ - buffer_start_); ++ } ++ ++ // Label operations & relative jumps (PPUM Appendix D). ++ // ++ // Takes a branch opcode (cc) and a label (L) and generates ++ // either a backward branch or a forward branch and links it ++ // to the label fixup chain. Usage: ++ // ++ // Label L; // unbound label ++ // j(cc, &L); // forward branch to unbound label ++ // bind(&L); // bind label to the current pc ++ // j(cc, &L); // backward branch to bound label ++ // bind(&L); // illegal: a label may be bound only once ++ // ++ // Note: The same Label can be used for forward and backward branches ++ // but it may be bound only once. ++ void bind(Label* L); // Binds an unbound label L to current code position. ++ ++ enum OffsetSize : int { kOffset26 = 26, kOffset21 = 21, kOffset16 = 16 }; ++ ++ // Determines if Label is bound and near enough so that branch instruction ++ // can be used to reach it, instead of jump instruction. ++ // c means conditinal branch, a means always branch. ++ bool is_near_c(Label* L); ++ bool is_near(Label* L, OffsetSize bits); ++ bool is_near_a(Label* L); ++ ++ int BranchOffset(Instr instr); ++ ++ // Returns the branch offset to the given label from the current code ++ // position. Links the label to the current position if it is still unbound. ++ // Manages the jump elimination optimization if the second parameter is true. ++ int32_t branch_offset_helper(Label* L, OffsetSize bits); ++ inline int32_t branch_offset(Label* L) { ++ return branch_offset_helper(L, OffsetSize::kOffset16); ++ } ++ inline int32_t branch_offset21(Label* L) { ++ return branch_offset_helper(L, OffsetSize::kOffset21); ++ } ++ inline int32_t branch_offset26(Label* L) { ++ return branch_offset_helper(L, OffsetSize::kOffset26); ++ } ++ inline int32_t shifted_branch_offset(Label* L) { ++ return branch_offset(L) >> 2; ++ } ++ inline int32_t shifted_branch_offset21(Label* L) { ++ return branch_offset21(L) >> 2; ++ } ++ inline int32_t shifted_branch_offset26(Label* L) { ++ return branch_offset26(L) >> 2; ++ } ++ uint64_t jump_address(Label* L); ++ uint64_t jump_offset(Label* L); ++ uint64_t branch_long_offset(Label* L); ++ ++ // Puts a labels target address at the given position. ++ // The high 8 bits are set to zero. ++ void label_at_put(Label* L, int at_offset); ++ ++ // Read/Modify the code target address in the branch/call instruction at pc. ++ // The isolate argument is unused (and may be nullptr) when skipping flushing. ++ static Address target_address_at(Address pc); ++ V8_INLINE static void set_target_address_at( ++ Address pc, Address target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { ++ set_target_value_at(pc, target, icache_flush_mode); ++ } ++ // On MIPS there is no Constant Pool so we skip that parameter. ++ V8_INLINE static Address target_address_at(Address pc, ++ Address constant_pool) { ++ return target_address_at(pc); ++ } ++ V8_INLINE static void set_target_address_at( ++ Address pc, Address constant_pool, Address target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { ++ set_target_address_at(pc, target, icache_flush_mode); ++ } ++ ++ static void set_target_value_at( ++ Address pc, uint64_t target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); ++ ++ static void JumpLabelToJumpRegister(Address pc); ++ ++ // This sets the branch destination (which gets loaded at the call address). ++ // This is for calls and branches within generated code. The serializer ++ // has already deserialized the lui/ori instructions etc. ++ inline static void deserialization_set_special_target_at( ++ Address instruction_payload, Code code, Address target); ++ ++ // Get the size of the special target encoded at 'instruction_payload'. ++ inline static int deserialization_special_target_size( ++ Address instruction_payload); ++ ++ // This sets the internal reference at the pc. ++ inline static void deserialization_set_target_internal_reference_at( ++ Address pc, Address target, ++ RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); ++ ++ // Here we are patching the address in the LUI/ORI instruction pair. ++ // These values are used in the serialization process and must be zero for ++ // LA platform, as Code, Embedded Object or External-reference pointers ++ // are split across two consecutive instructions and don't exist separately ++ // in the code, so the serializer should not step forwards in memory after ++ // a target is resolved and written. ++ static constexpr int kSpecialTargetSize = 0; ++ ++ // Number of consecutive instructions used to store 32bit/64bit constant. ++ // This constant was used in RelocInfo::target_address_address() function ++ // to tell serializer address of the instruction that follows ++ // LUI/ORI instruction pair. ++ // TODO check this ++ static constexpr int kInstructionsFor64BitConstant = 4; ++ ++ // Difference between address of current opcode and target address offset. ++ static constexpr int kBranchPCOffset = 0; ++ ++ // Difference between address of current opcode and target address offset, ++ // when we are generatinga sequence of instructions for long relative PC ++ // branches ++ static constexpr int kLongBranchPCOffset = 0; // 3 * kInstrSize; ++ ++ // Max offset for instructions with 16-bit offset field ++ static constexpr int kMax16BranchOffset = (1 << (18 - 1)) - 1; ++ ++ // Max offset for instructions with 21-bit offset field ++ static constexpr int kMax21BranchOffset = (1 << (23 - 1)) - 1; ++ ++ // Max offset for compact branch instructions with 26-bit offset field ++ static constexpr int kMax26BranchOffset = (1 << (28 - 1)) - 1; ++ ++ static constexpr int kTrampolineSlotsSize = 2 * kInstrSize; ++ ++ RegList* GetScratchRegisterList() { return &scratch_register_list_; } ++ ++ // --------------------------------------------------------------------------- ++ // Code generation. ++ ++ // Insert the smallest number of nop instructions ++ // possible to align the pc offset to a multiple ++ // of m. m must be a power of 2 (>= 4). ++ void Align(int m); ++ // Insert the smallest number of zero bytes possible to align the pc offset ++ // to a mulitple of m. m must be a power of 2 (>= 2). ++ void DataAlign(int m); ++ // Aligns code to something that's optimal for a jump target for the platform. ++ void CodeTargetAlign(); ++ ++ // Different nop operations are used by the code generator to detect certain ++ // states of the generated code. ++ enum NopMarkerTypes { ++ NON_MARKING_NOP = 0, ++ DEBUG_BREAK_NOP, ++ // IC markers. ++ PROPERTY_ACCESS_INLINED, ++ PROPERTY_ACCESS_INLINED_CONTEXT, ++ PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, ++ // Helper values. ++ LAST_CODE_MARKER, ++ FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED, ++ }; ++ ++ // Type == 0 is the default non-marking nop. For loongisa this is a ++ // andi(zero_reg, zero_reg, 0). We use rt_reg == r1 for non-zero ++ // marking, to avoid conflict with ssnop and ehb instructions. ++ void nop(unsigned int type = 0) { ++ DCHECK_LT(type, 32); ++ Register nop_rt_reg = (type == 0) ? zero_reg : t7; ++ andi(zero_reg, nop_rt_reg, type); ++ } ++ ++ // --------Branch-and-jump-instructions---------- ++ // We don't use likely variant of instructions. ++ void b(int32_t offset); ++ inline void b(Label* L) { b(shifted_branch_offset26(L)); } ++ void bl(int32_t offset); ++ inline void bl(Label* L) { bl(shifted_branch_offset26(L)); } ++ ++ void beq(Register rj, Register rd, int32_t offset); ++ inline void beq(Register rj, Register rd, Label* L) { ++ beq(rj, rd, shifted_branch_offset(L)); ++ } ++ void bne(Register rj, Register rd, int32_t offset); ++ inline void bne(Register rj, Register rd, Label* L) { ++ bne(rj, rd, shifted_branch_offset(L)); ++ } ++ void blt(Register rj, Register rd, int32_t offset); ++ inline void blt(Register rj, Register rd, Label* L) { ++ blt(rj, rd, shifted_branch_offset(L)); ++ } ++ void bge(Register rj, Register rd, int32_t offset); ++ inline void bge(Register rj, Register rd, Label* L) { ++ bge(rj, rd, shifted_branch_offset(L)); ++ } ++ void bltu(Register rj, Register rd, int32_t offset); ++ inline void bltu(Register rj, Register rd, Label* L) { ++ bltu(rj, rd, shifted_branch_offset(L)); ++ } ++ void bgeu(Register rj, Register rd, int32_t offset); ++ inline void bgeu(Register rj, Register rd, Label* L) { ++ bgeu(rj, rd, shifted_branch_offset(L)); ++ } ++ void beqz(Register rj, int32_t offset); ++ inline void beqz(Register rj, Label* L) { ++ beqz(rj, shifted_branch_offset21(L)); ++ } ++ void bnez(Register rj, int32_t offset); ++ inline void bnez(Register rj, Label* L) { ++ bnez(rj, shifted_branch_offset21(L)); ++ } ++ ++ void jirl(Register rd, Register rj, int32_t offset); ++ ++ void bceqz(CFRegister cj, int32_t si21); ++ inline void bceqz(CFRegister cj, Label* L) { ++ bceqz(cj, shifted_branch_offset21(L)); ++ } ++ void bcnez(CFRegister cj, int32_t si21); ++ inline void bcnez(CFRegister cj, Label* L) { ++ bcnez(cj, shifted_branch_offset21(L)); ++ } ++ ++ // -------Data-processing-instructions--------- ++ ++ // Arithmetic. ++ void add_w(Register rd, Register rj, Register rk); ++ void add_d(Register rd, Register rj, Register rk); ++ void sub_w(Register rd, Register rj, Register rk); ++ void sub_d(Register rd, Register rj, Register rk); ++ ++ void addi_w(Register rd, Register rj, int32_t si12); ++ void addi_d(Register rd, Register rj, int32_t si12); ++ ++ void addu16i_d(Register rd, Register rj, int32_t si16); ++ ++ void alsl_w(Register rd, Register rj, Register rk, int32_t sa2); ++ void alsl_wu(Register rd, Register rj, Register rk, int32_t sa2); ++ void alsl_d(Register rd, Register rj, Register rk, int32_t sa2); ++ ++ void lu12i_w(Register rd, int32_t si20); ++ void lu32i_d(Register rd, int32_t si20); ++ void lu52i_d(Register rd, Register rj, int32_t si12); ++ ++ void slt(Register rd, Register rj, Register rk); ++ void sltu(Register rd, Register rj, Register rk); ++ void slti(Register rd, Register rj, int32_t si12); ++ void sltui(Register rd, Register rj, int32_t si12); ++ ++ void pcaddi(Register rd, int32_t si20); ++ void pcaddu12i(Register rd, int32_t si20); ++ void pcaddu18i(Register rd, int32_t si20); ++ void pcalau12i(Register rd, int32_t si20); ++ ++ void and_(Register rd, Register rj, Register rk); ++ void or_(Register rd, Register rj, Register rk); ++ void xor_(Register rd, Register rj, Register rk); ++ void nor(Register rd, Register rj, Register rk); ++ void andn(Register rd, Register rj, Register rk); ++ void orn(Register rd, Register rj, Register rk); ++ ++ void andi(Register rd, Register rj, int32_t ui12); ++ void ori(Register rd, Register rj, int32_t ui12); ++ void xori(Register rd, Register rj, int32_t ui12); ++ ++ void mul_w(Register rd, Register rj, Register rk); ++ void mulh_w(Register rd, Register rj, Register rk); ++ void mulh_wu(Register rd, Register rj, Register rk); ++ void mul_d(Register rd, Register rj, Register rk); ++ void mulh_d(Register rd, Register rj, Register rk); ++ void mulh_du(Register rd, Register rj, Register rk); ++ ++ void mulw_d_w(Register rd, Register rj, Register rk); ++ void mulw_d_wu(Register rd, Register rj, Register rk); ++ ++ void div_w(Register rd, Register rj, Register rk); ++ void mod_w(Register rd, Register rj, Register rk); ++ void div_wu(Register rd, Register rj, Register rk); ++ void mod_wu(Register rd, Register rj, Register rk); ++ void div_d(Register rd, Register rj, Register rk); ++ void mod_d(Register rd, Register rj, Register rk); ++ void div_du(Register rd, Register rj, Register rk); ++ void mod_du(Register rd, Register rj, Register rk); ++ ++ // Shifts. ++ void sll_w(Register rd, Register rj, Register rk); ++ void srl_w(Register rd, Register rj, Register rk); ++ void sra_w(Register rd, Register rj, Register rk); ++ void rotr_w(Register rd, Register rj, Register rk); ++ ++ void slli_w(Register rd, Register rj, int32_t ui5); ++ void srli_w(Register rd, Register rj, int32_t ui5); ++ void srai_w(Register rd, Register rj, int32_t ui5); ++ void rotri_w(Register rd, Register rj, int32_t ui5); ++ ++ void sll_d(Register rd, Register rj, Register rk); ++ void srl_d(Register rd, Register rj, Register rk); ++ void sra_d(Register rd, Register rj, Register rk); ++ void rotr_d(Register rd, Register rj, Register rk); ++ ++ void slli_d(Register rd, Register rj, int32_t ui6); ++ void srli_d(Register rd, Register rj, int32_t ui6); ++ void srai_d(Register rd, Register rj, int32_t ui6); ++ void rotri_d(Register rd, Register rj, int32_t ui6); ++ ++ // Bit twiddling. ++ void ext_w_b(Register rd, Register rj); ++ void ext_w_h(Register rd, Register rj); ++ ++ void clo_w(Register rd, Register rj); ++ void clz_w(Register rd, Register rj); ++ void cto_w(Register rd, Register rj); ++ void ctz_w(Register rd, Register rj); ++ void clo_d(Register rd, Register rj); ++ void clz_d(Register rd, Register rj); ++ void cto_d(Register rd, Register rj); ++ void ctz_d(Register rd, Register rj); ++ ++ void bytepick_w(Register rd, Register rj, Register rk, int32_t sa2); ++ void bytepick_d(Register rd, Register rj, Register rk, int32_t sa3); ++ ++ void revb_2h(Register rd, Register rj); ++ void revb_4h(Register rd, Register rj); ++ void revb_2w(Register rd, Register rj); ++ void revb_d(Register rd, Register rj); ++ ++ void revh_2w(Register rd, Register rj); ++ void revh_d(Register rd, Register rj); ++ ++ void bitrev_4b(Register rd, Register rj); ++ void bitrev_8b(Register rd, Register rj); ++ ++ void bitrev_w(Register rd, Register rj); ++ void bitrev_d(Register rd, Register rj); ++ ++ void bstrins_w(Register rd, Register rj, int32_t msbw, int32_t lsbw); ++ void bstrins_d(Register rd, Register rj, int32_t msbd, int32_t lsbd); ++ ++ void bstrpick_w(Register rd, Register rj, int32_t msbw, int32_t lsbw); ++ void bstrpick_d(Register rd, Register rj, int32_t msbd, int32_t lsbd); ++ ++ void maskeqz(Register rd, Register rj, Register rk); ++ void masknez(Register rd, Register rj, Register rk); ++ ++ // Memory-instructions ++ void ld_b(Register rd, Register rj, int32_t si12); ++ void ld_h(Register rd, Register rj, int32_t si12); ++ void ld_w(Register rd, Register rj, int32_t si12); ++ void ld_d(Register rd, Register rj, int32_t si12); ++ void ld_bu(Register rd, Register rj, int32_t si12); ++ void ld_hu(Register rd, Register rj, int32_t si12); ++ void ld_wu(Register rd, Register rj, int32_t si12); ++ void st_b(Register rd, Register rj, int32_t si12); ++ void st_h(Register rd, Register rj, int32_t si12); ++ void st_w(Register rd, Register rj, int32_t si12); ++ void st_d(Register rd, Register rj, int32_t si12); ++ ++ void ldx_b(Register rd, Register rj, Register rk); ++ void ldx_h(Register rd, Register rj, Register rk); ++ void ldx_w(Register rd, Register rj, Register rk); ++ void ldx_d(Register rd, Register rj, Register rk); ++ void ldx_bu(Register rd, Register rj, Register rk); ++ void ldx_hu(Register rd, Register rj, Register rk); ++ void ldx_wu(Register rd, Register rj, Register rk); ++ void stx_b(Register rd, Register rj, Register rk); ++ void stx_h(Register rd, Register rj, Register rk); ++ void stx_w(Register rd, Register rj, Register rk); ++ void stx_d(Register rd, Register rj, Register rk); ++ ++ void ldptr_w(Register rd, Register rj, int32_t si14); ++ void ldptr_d(Register rd, Register rj, int32_t si14); ++ void stptr_w(Register rd, Register rj, int32_t si14); ++ void stptr_d(Register rd, Register rj, int32_t si14); ++ ++ void amswap_w(Register rd, Register rk, Register rj); ++ void amswap_d(Register rd, Register rk, Register rj); ++ void amadd_w(Register rd, Register rk, Register rj); ++ void amadd_d(Register rd, Register rk, Register rj); ++ void amand_w(Register rd, Register rk, Register rj); ++ void amand_d(Register rd, Register rk, Register rj); ++ void amor_w(Register rd, Register rk, Register rj); ++ void amor_d(Register rd, Register rk, Register rj); ++ void amxor_w(Register rd, Register rk, Register rj); ++ void amxor_d(Register rd, Register rk, Register rj); ++ void ammax_w(Register rd, Register rk, Register rj); ++ void ammax_d(Register rd, Register rk, Register rj); ++ void ammin_w(Register rd, Register rk, Register rj); ++ void ammin_d(Register rd, Register rk, Register rj); ++ void ammax_wu(Register rd, Register rk, Register rj); ++ void ammax_du(Register rd, Register rk, Register rj); ++ void ammin_wu(Register rd, Register rk, Register rj); ++ void ammin_du(Register rd, Register rk, Register rj); ++ ++ void amswap_db_w(Register rd, Register rk, Register rj); ++ void amswap_db_d(Register rd, Register rk, Register rj); ++ void amadd_db_w(Register rd, Register rk, Register rj); ++ void amadd_db_d(Register rd, Register rk, Register rj); ++ void amand_db_w(Register rd, Register rk, Register rj); ++ void amand_db_d(Register rd, Register rk, Register rj); ++ void amor_db_w(Register rd, Register rk, Register rj); ++ void amor_db_d(Register rd, Register rk, Register rj); ++ void amxor_db_w(Register rd, Register rk, Register rj); ++ void amxor_db_d(Register rd, Register rk, Register rj); ++ void ammax_db_w(Register rd, Register rk, Register rj); ++ void ammax_db_d(Register rd, Register rk, Register rj); ++ void ammin_db_w(Register rd, Register rk, Register rj); ++ void ammin_db_d(Register rd, Register rk, Register rj); ++ void ammax_db_wu(Register rd, Register rk, Register rj); ++ void ammax_db_du(Register rd, Register rk, Register rj); ++ void ammin_db_wu(Register rd, Register rk, Register rj); ++ void ammin_db_du(Register rd, Register rk, Register rj); ++ ++ void ll_w(Register rd, Register rj, int32_t si14); ++ void ll_d(Register rd, Register rj, int32_t si14); ++ void sc_w(Register rd, Register rj, int32_t si14); ++ void sc_d(Register rd, Register rj, int32_t si14); ++ ++ void dbar(int32_t hint); ++ void ibar(int32_t hint); ++ ++ // Break / Trap instructions. ++ void break_(uint32_t code, bool break_as_stop = false); ++ void stop(uint32_t code = kMaxStopCode); ++ ++ // Arithmetic. ++ void fadd_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fadd_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fsub_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fsub_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmul_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmul_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fdiv_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fdiv_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ ++ void fmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fnmadd_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fnmadd_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fnmsub_s(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ void fnmsub_d(FPURegister fd, FPURegister fj, FPURegister fk, FPURegister fa); ++ ++ void fmax_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmax_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmin_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmin_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ ++ void fmaxa_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmaxa_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmina_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fmina_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ ++ void fabs_s(FPURegister fd, FPURegister fj); ++ void fabs_d(FPURegister fd, FPURegister fj); ++ void fneg_s(FPURegister fd, FPURegister fj); ++ void fneg_d(FPURegister fd, FPURegister fj); ++ ++ void fsqrt_s(FPURegister fd, FPURegister fj); ++ void fsqrt_d(FPURegister fd, FPURegister fj); ++ void frecip_s(FPURegister fd, FPURegister fj); ++ void frecip_d(FPURegister fd, FPURegister fj); ++ void frsqrt_s(FPURegister fd, FPURegister fj); ++ void frsqrt_d(FPURegister fd, FPURegister fj); ++ ++ void fscaleb_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fscaleb_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ void flogb_s(FPURegister fd, FPURegister fj); ++ void flogb_d(FPURegister fd, FPURegister fj); ++ void fcopysign_s(FPURegister fd, FPURegister fj, FPURegister fk); ++ void fcopysign_d(FPURegister fd, FPURegister fj, FPURegister fk); ++ ++ void fclass_s(FPURegister fd, FPURegister fj); ++ void fclass_d(FPURegister fd, FPURegister fj); ++ ++ void fcmp_cond_s(FPUCondition cc, FPURegister fj, FPURegister fk, ++ CFRegister cd); ++ void fcmp_cond_d(FPUCondition cc, FPURegister fj, FPURegister fk, ++ CFRegister cd); ++ ++ void fcvt_s_d(FPURegister fd, FPURegister fj); ++ void fcvt_d_s(FPURegister fd, FPURegister fj); ++ ++ void ffint_s_w(FPURegister fd, FPURegister fj); ++ void ffint_s_l(FPURegister fd, FPURegister fj); ++ void ffint_d_w(FPURegister fd, FPURegister fj); ++ void ffint_d_l(FPURegister fd, FPURegister fj); ++ void ftint_w_s(FPURegister fd, FPURegister fj); ++ void ftint_w_d(FPURegister fd, FPURegister fj); ++ void ftint_l_s(FPURegister fd, FPURegister fj); ++ void ftint_l_d(FPURegister fd, FPURegister fj); ++ ++ void ftintrm_w_s(FPURegister fd, FPURegister fj); ++ void ftintrm_w_d(FPURegister fd, FPURegister fj); ++ void ftintrm_l_s(FPURegister fd, FPURegister fj); ++ void ftintrm_l_d(FPURegister fd, FPURegister fj); ++ void ftintrp_w_s(FPURegister fd, FPURegister fj); ++ void ftintrp_w_d(FPURegister fd, FPURegister fj); ++ void ftintrp_l_s(FPURegister fd, FPURegister fj); ++ void ftintrp_l_d(FPURegister fd, FPURegister fj); ++ void ftintrz_w_s(FPURegister fd, FPURegister fj); ++ void ftintrz_w_d(FPURegister fd, FPURegister fj); ++ void ftintrz_l_s(FPURegister fd, FPURegister fj); ++ void ftintrz_l_d(FPURegister fd, FPURegister fj); ++ void ftintrne_w_s(FPURegister fd, FPURegister fj); ++ void ftintrne_w_d(FPURegister fd, FPURegister fj); ++ void ftintrne_l_s(FPURegister fd, FPURegister fj); ++ void ftintrne_l_d(FPURegister fd, FPURegister fj); ++ ++ void frint_s(FPURegister fd, FPURegister fj); ++ void frint_d(FPURegister fd, FPURegister fj); ++ ++ void fmov_s(FPURegister fd, FPURegister fj); ++ void fmov_d(FPURegister fd, FPURegister fj); ++ ++ void fsel(CFRegister ca, FPURegister fd, FPURegister fj, FPURegister fk); ++ ++ void movgr2fr_w(FPURegister fd, Register rj); ++ void movgr2fr_d(FPURegister fd, Register rj); ++ void movgr2frh_w(FPURegister fd, Register rj); ++ ++ void movfr2gr_s(Register rd, FPURegister fj); ++ void movfr2gr_d(Register rd, FPURegister fj); ++ void movfrh2gr_s(Register rd, FPURegister fj); ++ ++ void movgr2fcsr(Register rj); ++ void movfcsr2gr(Register rd); ++ ++ void movfr2cf(CFRegister cd, FPURegister fj); ++ void movcf2fr(FPURegister fd, CFRegister cj); ++ ++ void movgr2cf(CFRegister cd, Register rj); ++ void movcf2gr(Register rd, CFRegister cj); ++ ++ void fld_s(FPURegister fd, Register rj, int32_t si12); ++ void fld_d(FPURegister fd, Register rj, int32_t si12); ++ void fst_s(FPURegister fd, Register rj, int32_t si12); ++ void fst_d(FPURegister fd, Register rj, int32_t si12); ++ ++ void fldx_s(FPURegister fd, Register rj, Register rk); ++ void fldx_d(FPURegister fd, Register rj, Register rk); ++ void fstx_s(FPURegister fd, Register rj, Register rk); ++ void fstx_d(FPURegister fd, Register rj, Register rk); ++ ++ // Check the code size generated from label to here. ++ int SizeOfCodeGeneratedSince(Label* label) { ++ return pc_offset() - label->pos(); ++ } ++ ++ // Check the number of instructions generated from label to here. ++ int InstructionsGeneratedSince(Label* label) { ++ return SizeOfCodeGeneratedSince(label) / kInstrSize; ++ } ++ ++ // Class for scoping postponing the trampoline pool generation. ++ class BlockTrampolinePoolScope { ++ public: ++ explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) { ++ assem_->StartBlockTrampolinePool(); ++ } ++ ~BlockTrampolinePoolScope() { assem_->EndBlockTrampolinePool(); } ++ ++ private: ++ Assembler* assem_; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope); ++ }; ++ ++ // Class for postponing the assembly buffer growth. Typically used for ++ // sequences of instructions that must be emitted as a unit, before ++ // buffer growth (and relocation) can occur. ++ // This blocking scope is not nestable. ++ class BlockGrowBufferScope { ++ public: ++ explicit BlockGrowBufferScope(Assembler* assem) : assem_(assem) { ++ assem_->StartBlockGrowBuffer(); ++ } ++ ~BlockGrowBufferScope() { assem_->EndBlockGrowBuffer(); } ++ ++ private: ++ Assembler* assem_; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope); ++ }; ++ ++ // Record a deoptimization reason that can be used by a log or cpu profiler. ++ // Use --trace-deopt to enable. ++ void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, ++ int id); ++ ++ static int RelocateInternalReference(RelocInfo::Mode rmode, Address pc, ++ intptr_t pc_delta); ++ ++ // Writes a single byte or word of data in the code stream. Used for ++ // inline tables, e.g., jump-tables. ++ void db(uint8_t data); ++ void dd(uint32_t data); ++ void dq(uint64_t data); ++ void dp(uintptr_t data) { dq(data); } ++ void dd(Label* label); ++ ++ // Postpone the generation of the trampoline pool for the specified number of ++ // instructions. ++ void BlockTrampolinePoolFor(int instructions); ++ ++ // Check if there is less than kGap bytes available in the buffer. ++ // If this is the case, we need to grow the buffer before emitting ++ // an instruction or relocation information. ++ inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } ++ ++ // Get the number of bytes available in the buffer. ++ inline intptr_t available_space() const { ++ return reloc_info_writer.pos() - pc_; ++ } ++ ++ // Read/patch instructions. ++ static Instr instr_at(Address pc) { return *reinterpret_cast(pc); } ++ static void instr_at_put(Address pc, Instr instr) { ++ *reinterpret_cast(pc) = instr; ++ } ++ Instr instr_at(int pos) { ++ return *reinterpret_cast(buffer_start_ + pos); ++ } ++ void instr_at_put(int pos, Instr instr) { ++ *reinterpret_cast(buffer_start_ + pos) = instr; ++ } ++ ++ // Check if an instruction is a branch of some kind. ++ static bool IsBranch(Instr instr); ++ static bool IsB(Instr instr); ++ static bool IsBz(Instr instr); ++ static bool IsNal(Instr instr); ++ ++ static bool IsBeq(Instr instr); ++ static bool IsBne(Instr instr); ++ ++ static bool IsJump(Instr instr); ++ static bool IsMov(Instr instr, Register rd, Register rs); ++ static bool IsPcAddi(Instr instr, Register rd, int32_t si20); ++ ++ static bool IsJ(Instr instr); ++ static bool IsLu12i_w(Instr instr); ++ static bool IsOri(Instr instr); ++ static bool IsLu32i_d(Instr instr); ++ static bool IsLu52i_d(Instr instr); ++ ++ static bool IsNop(Instr instr, unsigned int type); ++ static bool IsPop(Instr instr); ++ static bool IsPush(Instr instr); ++ // static bool IsLwRegFpOffset(Instr instr); ++ // static bool IsSwRegFpOffset(Instr instr); ++ // static bool IsLwRegFpNegOffset(Instr instr); ++ // static bool IsSwRegFpNegOffset(Instr instr); ++ ++ static Register GetRjReg(Instr instr); ++ static Register GetRkReg(Instr instr); ++ static Register GetRdReg(Instr instr); ++ ++ static uint32_t GetRj(Instr instr); ++ static uint32_t GetRjField(Instr instr); ++ static uint32_t GetRk(Instr instr); ++ static uint32_t GetRkField(Instr instr); ++ static uint32_t GetRd(Instr instr); ++ static uint32_t GetRdField(Instr instr); ++ static uint32_t GetSa2(Instr instr); ++ static uint32_t GetSa3(Instr instr); ++ static uint32_t GetSa2Field(Instr instr); ++ static uint32_t GetSa3Field(Instr instr); ++ static uint32_t GetOpcodeField(Instr instr); ++ static uint32_t GetFunction(Instr instr); ++ static uint32_t GetFunctionField(Instr instr); ++ static uint32_t GetImmediate16(Instr instr); ++ static uint32_t GetLabelConst(Instr instr); ++ ++ static bool IsAddImmediate(Instr instr); ++ static Instr SetAddImmediateOffset(Instr instr, int16_t offset); ++ ++ static bool IsAndImmediate(Instr instr); ++ static bool IsEmittedConstant(Instr instr); ++ ++ void CheckTrampolinePool(); ++ ++ inline int UnboundLabelsCount() { return unbound_labels_count_; } ++ ++ protected: ++ // Helper function for memory load/store. ++ void AdjustBaseAndOffset(MemOperand* src); ++ ++ inline static void set_target_internal_reference_encoded_at(Address pc, ++ Address target); ++ ++ int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } ++ ++ // Decode branch instruction at pos and return branch target pos. ++ int target_at(int pos, bool is_internal); ++ ++ // Patch branch instruction at pos to branch to given branch target pos. ++ void target_at_put(int pos, int target_pos, bool is_internal); ++ ++ // Say if we need to relocate with this mode. ++ bool MustUseReg(RelocInfo::Mode rmode); ++ ++ // Record reloc info for current pc_. ++ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); ++ ++ // Block the emission of the trampoline pool before pc_offset. ++ void BlockTrampolinePoolBefore(int pc_offset) { ++ if (no_trampoline_pool_before_ < pc_offset) ++ no_trampoline_pool_before_ = pc_offset; ++ } ++ ++ void StartBlockTrampolinePool() { trampoline_pool_blocked_nesting_++; } ++ ++ void EndBlockTrampolinePool() { ++ trampoline_pool_blocked_nesting_--; ++ if (trampoline_pool_blocked_nesting_ == 0) { ++ CheckTrampolinePoolQuick(1); ++ } ++ } ++ ++ bool is_trampoline_pool_blocked() const { ++ return trampoline_pool_blocked_nesting_ > 0; ++ } ++ ++ bool has_exception() const { return internal_trampoline_exception_; } ++ ++ bool is_trampoline_emitted() const { return trampoline_emitted_; } ++ ++ // Temporarily block automatic assembly buffer growth. ++ void StartBlockGrowBuffer() { ++ DCHECK(!block_buffer_growth_); ++ block_buffer_growth_ = true; ++ } ++ ++ void EndBlockGrowBuffer() { ++ DCHECK(block_buffer_growth_); ++ block_buffer_growth_ = false; ++ } ++ ++ bool is_buffer_growth_blocked() const { return block_buffer_growth_; } ++ ++ void CheckTrampolinePoolQuick(int extra_instructions = 0) { ++ if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { ++ CheckTrampolinePool(); ++ } ++ } ++ ++ void set_last_call_pc_(byte* pc) { last_call_pc_ = pc; } ++ ++ private: ++ // Avoid overflows for displacements etc. ++ static const int kMaximalBufferSize = 512 * MB; ++ ++ // Buffer size and constant pool distance are checked together at regular ++ // intervals of kBufferCheckInterval emitted bytes. ++ static constexpr int kBufferCheckInterval = 1 * KB / 2; ++ ++ // Code generation. ++ // The relocation writer's position is at least kGap bytes below the end of ++ // the generated instructions. This is so that multi-instruction sequences do ++ // not have to check for overflow. The same is true for writes of large ++ // relocation info entries. ++ static constexpr int kGap = 64; ++ STATIC_ASSERT(AssemblerBase::kMinimalBufferSize >= 2 * kGap); ++ ++ // Repeated checking whether the trampoline pool should be emitted is rather ++ // expensive. By default we only check again once a number of instructions ++ // has been generated. ++ static constexpr int kCheckConstIntervalInst = 32; ++ static constexpr int kCheckConstInterval = ++ kCheckConstIntervalInst * kInstrSize; ++ ++ int next_buffer_check_; // pc offset of next buffer check. ++ ++ // Emission of the trampoline pool may be blocked in some code sequences. ++ int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. ++ int no_trampoline_pool_before_; // Block emission before this pc offset. ++ ++ // Keep track of the last emitted pool to guarantee a maximal distance. ++ int last_trampoline_pool_end_; // pc offset of the end of the last pool. ++ ++ // Automatic growth of the assembly buffer may be blocked for some sequences. ++ bool block_buffer_growth_; // Block growth when true. ++ ++ // Relocation information generation. ++ // Each relocation is encoded as a variable size value. ++ static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; ++ RelocInfoWriter reloc_info_writer; ++ ++ // The bound position, before this we cannot do instruction elimination. ++ int last_bound_pos_; ++ ++ // Code emission. ++ inline void CheckBuffer(); ++ void GrowBuffer(); ++ inline void emit(Instr x); ++ inline void emit(uint64_t x); ++ // inline void CheckForEmitInForbiddenSlot(); ++ template ++ inline void EmitHelper(T x); ++ inline void EmitHelper(Instr x); ++ ++ void GenB(Opcode opcode, Register rj, int32_t si21); // opcode:6 ++ void GenB(Opcode opcode, CFRegister cj, int32_t si21, bool isEq); ++ void GenB(Opcode opcode, int32_t si26); ++ void GenBJ(Opcode opcode, Register rj, Register rd, int32_t si16); ++ void GenCmp(Opcode opcode, FPUCondition cond, FPURegister fk, FPURegister fj, ++ CFRegister cd); ++ void GenSel(Opcode opcode, CFRegister ca, FPURegister fk, FPURegister fj, ++ FPURegister rd); ++ ++ void GenRegister(Opcode opcode, Register rj, Register rd, bool rjrd = true); ++ void GenRegister(Opcode opcode, FPURegister fj, FPURegister fd); ++ void GenRegister(Opcode opcode, Register rj, FPURegister fd); ++ void GenRegister(Opcode opcode, FPURegister fj, Register rd); ++ void GenRegister(Opcode opcode, Register rj, FPUControlRegister fd); ++ void GenRegister(Opcode opcode, FPUControlRegister fj, Register rd); ++ void GenRegister(Opcode opcode, FPURegister fj, CFRegister cd); ++ void GenRegister(Opcode opcode, CFRegister cj, FPURegister fd); ++ void GenRegister(Opcode opcode, Register rj, CFRegister cd); ++ void GenRegister(Opcode opcode, CFRegister cj, Register rd); ++ ++ void GenRegister(Opcode opcode, Register rk, Register rj, Register rd); ++ void GenRegister(Opcode opcode, FPURegister fk, FPURegister fj, ++ FPURegister fd); ++ ++ void GenRegister(Opcode opcode, FPURegister fa, FPURegister fk, ++ FPURegister fj, FPURegister fd); ++ void GenRegister(Opcode opcode, Register rk, Register rj, FPURegister fd); ++ ++ void GenImm(Opcode opcode, int32_t bit3, Register rk, Register rj, ++ Register rd); ++ void GenImm(Opcode opcode, int32_t bit6m, int32_t bit6l, Register rj, ++ Register rd); ++ void GenImm(Opcode opcode, int32_t bit20, Register rd); ++ void GenImm(Opcode opcode, int32_t bit15); ++ void GenImm(Opcode opcode, int32_t value, Register rj, Register rd, ++ int32_t value_bits); // 6 | 12 | 14 | 16 ++ void GenImm(Opcode opcode, int32_t bit12, Register rj, FPURegister fd); ++ ++ // Labels. ++ void print(const Label* L); ++ void bind_to(Label* L, int pos); ++ void next(Label* L, bool is_internal); ++ ++ // One trampoline consists of: ++ // - space for trampoline slots, ++ // - space for labels. ++ // ++ // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. ++ // Space for trampoline slots precedes space for labels. Each label is of one ++ // instruction size, so total amount for labels is equal to ++ // label_count * kInstrSize. ++ class Trampoline { ++ public: ++ Trampoline() { ++ start_ = 0; ++ next_slot_ = 0; ++ free_slot_count_ = 0; ++ end_ = 0; ++ } ++ Trampoline(int start, int slot_count) { ++ start_ = start; ++ next_slot_ = start; ++ free_slot_count_ = slot_count; ++ end_ = start + slot_count * kTrampolineSlotsSize; ++ } ++ int start() { return start_; } ++ int end() { return end_; } ++ int take_slot() { ++ int trampoline_slot = kInvalidSlotPos; ++ if (free_slot_count_ <= 0) { ++ // We have run out of space on trampolines. ++ // Make sure we fail in debug mode, so we become aware of each case ++ // when this happens. ++ DCHECK(0); ++ // Internal exception will be caught. ++ } else { ++ trampoline_slot = next_slot_; ++ free_slot_count_--; ++ next_slot_ += kTrampolineSlotsSize; ++ } ++ return trampoline_slot; ++ } ++ ++ private: ++ int start_; ++ int end_; ++ int next_slot_; ++ int free_slot_count_; ++ }; ++ ++ int32_t get_trampoline_entry(int32_t pos); ++ int unbound_labels_count_; ++ // After trampoline is emitted, long branches are used in generated code for ++ // the forward branches whose target offsets could be beyond reach of branch ++ // instruction. We use this information to trigger different mode of ++ // branch instruction generation, where we use jump instructions rather ++ // than regular branch instructions. ++ bool trampoline_emitted_; ++ static constexpr int kInvalidSlotPos = -1; ++ ++ // Internal reference positions, required for unbounded internal reference ++ // labels. ++ std::set internal_reference_positions_; ++ bool is_internal_reference(Label* L) { ++ return internal_reference_positions_.find(L->pos()) != ++ internal_reference_positions_.end(); ++ } ++ ++ void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } ++ void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } ++ bool prev_instr_compact_branch_ = false; ++ ++ Trampoline trampoline_; ++ bool internal_trampoline_exception_; ++ ++ // Keep track of the last Call's position to ensure that safepoint can get the ++ // correct information even if there is a trampoline immediately after the ++ // Call. ++ byte* last_call_pc_; ++ ++ RegList scratch_register_list_; ++ ++ private: ++ void AllocateAndInstallRequestedHeapObjects(Isolate* isolate); ++ ++ int WriteCodeComments(); ++ ++ friend class RegExpMacroAssemblerMIPS; ++ friend class RelocInfo; ++ friend class BlockTrampolinePoolScope; ++ friend class EnsureSpace; ++}; ++ ++class EnsureSpace { ++ public: ++ explicit inline EnsureSpace(Assembler* assembler); ++}; ++ ++class V8_EXPORT_PRIVATE UseScratchRegisterScope { ++ public: ++ explicit UseScratchRegisterScope(Assembler* assembler); ++ ~UseScratchRegisterScope(); ++ ++ Register Acquire(); ++ bool hasAvailable() const; ++ ++ private: ++ RegList* available_; ++ RegList old_available_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_LOONGARCH64_ASSEMBLER_LOONGARCH64_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.cc +@@ -0,0 +1,100 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++ ++namespace v8 { ++namespace internal { ++ ++// ----------------------------------------------------------------------------- ++// Registers. ++ ++// These register names are defined in a way to match the native disassembler ++// formatting. See for example the command "objdump -d ". ++const char* Registers::names_[kNumSimuRegisters] = { ++ "zero_reg", "ra", "gp", "sp", "a0", "a1", "a2", "a3", "a4", "a5", "a6", ++ "a7", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "tp", ++ "fp", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "pc"}; ++ ++// List of alias names which can be used when referring to MIPS registers. ++const Registers::RegisterAlias Registers::aliases_[] = { ++ {0, "zero"}, {23, "cp"}, {kInvalidRegister, nullptr}}; ++ ++const char* Registers::Name(int reg) { ++ const char* result; ++ if ((0 <= reg) && (reg < kNumSimuRegisters)) { ++ result = names_[reg]; ++ } else { ++ result = "noreg"; ++ } ++ return result; ++} ++ ++int Registers::Number(const char* name) { ++ // Look through the canonical names. ++ for (int i = 0; i < kNumSimuRegisters; i++) { ++ if (strcmp(names_[i], name) == 0) { ++ return i; ++ } ++ } ++ ++ // Look through the alias names. ++ int i = 0; ++ while (aliases_[i].reg != kInvalidRegister) { ++ if (strcmp(aliases_[i].name, name) == 0) { ++ return aliases_[i].reg; ++ } ++ i++; ++ } ++ ++ // No register with the reguested name found. ++ return kInvalidRegister; ++} ++ ++const char* FPURegisters::names_[kNumFPURegisters] = { ++ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", ++ "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", ++ "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"}; ++ ++// List of alias names which can be used when referring to MIPS registers. ++const FPURegisters::RegisterAlias FPURegisters::aliases_[] = { ++ {kInvalidRegister, nullptr}}; ++ ++const char* FPURegisters::Name(int creg) { ++ const char* result; ++ if ((0 <= creg) && (creg < kNumFPURegisters)) { ++ result = names_[creg]; ++ } else { ++ result = "nocreg"; ++ } ++ return result; ++} ++ ++int FPURegisters::Number(const char* name) { ++ // Look through the canonical names. ++ for (int i = 0; i < kNumFPURegisters; i++) { ++ if (strcmp(names_[i], name) == 0) { ++ return i; ++ } ++ } ++ ++ // Look through the alias names. ++ int i = 0; ++ while (aliases_[i].creg != kInvalidRegister) { ++ if (strcmp(aliases_[i].name, name) == 0) { ++ return aliases_[i].creg; ++ } ++ i++; ++ } ++ ++ // No Cregister with the reguested name found. ++ return kInvalidFPURegister; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/constants-loongarch64.h +@@ -0,0 +1,1340 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ ++#define V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ ++ ++#include "src/base/logging.h" ++#include "src/base/macros.h" ++#include "src/common/globals.h" ++ ++// UNIMPLEMENTED_ macro for LOONGISA. ++#ifdef DEBUG ++#define UNIMPLEMENTED_LOONGISA() \ ++ v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ ++ __FILE__, __LINE__, __func__) ++#else ++#define UNIMPLEMENTED_LOONGISA() ++#endif ++ ++#define UNSUPPORTED_LOONGISA() \ ++ v8::internal::PrintF("Unsupported instruction.\n") ++ ++const uint32_t kLeastSignificantByteInInt32Offset = 0; ++const uint32_t kLessSignificantWordInDoublewordOffset = 0; ++ ++#ifndef __STDC_FORMAT_MACROS ++#define __STDC_FORMAT_MACROS ++#endif ++#include ++ ++// Defines constants and accessor classes to assemble, disassemble and ++// simulate LA64 instructions. ++ ++namespace v8 { ++namespace internal { ++ ++constexpr size_t kMaxPCRelativeCodeRangeInMB = 128; ++ ++// ----------------------------------------------------------------------------- ++// Registers and FPURegisters. ++ ++// Number of general purpose registers. ++const int kNumRegisters = 32; ++const int kInvalidRegister = -1; ++ ++// Number of registers with pc. ++const int kNumSimuRegisters = 33; ++ ++// In the simulator, the PC register is simulated as the 34th register. ++const int kPCRegister = 32; ++ ++// Number coprocessor registers. ++const int kNumFPURegisters = 32; ++const int kInvalidFPURegister = -1; ++ ++// FPU (coprocessor 1) control registers. Currently only FCSR is implemented. ++// TODO fcsr0 fcsr1 fcsr2 fcsr3 ++const int kFCSRRegister = 0; ++const int kInvalidFPUControlRegister = -1; ++const uint32_t kFPUInvalidResult = static_cast(1u << 31) - 1; ++const int32_t kFPUInvalidResultNegative = static_cast(1u << 31); ++const uint64_t kFPU64InvalidResult = ++ static_cast(static_cast(1) << 63) - 1; ++const int64_t kFPU64InvalidResultNegative = ++ static_cast(static_cast(1) << 63); ++ ++// FCSR constants. ++// TODO ++const uint32_t kFCSRInexactFlagBit = 16; ++const uint32_t kFCSRUnderflowFlagBit = 17; ++const uint32_t kFCSROverflowFlagBit = 18; ++const uint32_t kFCSRDivideByZeroFlagBit = 19; ++const uint32_t kFCSRInvalidOpFlagBit = 20; ++ ++const uint32_t kFCSRInexactFlagMask = 1 << kFCSRInexactFlagBit; ++const uint32_t kFCSRUnderflowFlagMask = 1 << kFCSRUnderflowFlagBit; ++const uint32_t kFCSROverflowFlagMask = 1 << kFCSROverflowFlagBit; ++const uint32_t kFCSRDivideByZeroFlagMask = 1 << kFCSRDivideByZeroFlagBit; ++const uint32_t kFCSRInvalidOpFlagMask = 1 << kFCSRInvalidOpFlagBit; ++ ++const uint32_t kFCSRFlagMask = ++ kFCSRInexactFlagMask | kFCSRUnderflowFlagMask | kFCSROverflowFlagMask | ++ kFCSRDivideByZeroFlagMask | kFCSRInvalidOpFlagMask; ++ ++const uint32_t kFCSRExceptionFlagMask = kFCSRFlagMask ^ kFCSRInexactFlagMask; ++ ++// Actual value of root register is offset from the root array's start ++// to take advantage of negative displacement values. ++// TODO(sigurds): Choose best value. ++constexpr int kRootRegisterBias = 256; ++ ++// Helper functions for converting between register numbers and names. ++class Registers { ++ public: ++ // Return the name of the register. ++ static const char* Name(int reg); ++ ++ // Lookup the register number for the name provided. ++ static int Number(const char* name); ++ ++ struct RegisterAlias { ++ int reg; ++ const char* name; ++ }; ++ ++ static const int64_t kMaxValue = 0x7fffffffffffffffl; ++ static const int64_t kMinValue = 0x8000000000000000l; ++ ++ private: ++ static const char* names_[kNumSimuRegisters]; ++ static const RegisterAlias aliases_[]; ++}; ++ ++// Helper functions for converting between register numbers and names. ++class FPURegisters { ++ public: ++ // Return the name of the register. ++ static const char* Name(int reg); ++ ++ // Lookup the register number for the name provided. ++ static int Number(const char* name); ++ ++ struct RegisterAlias { ++ int creg; ++ const char* name; ++ }; ++ ++ private: ++ static const char* names_[kNumFPURegisters]; ++ static const RegisterAlias aliases_[]; ++}; ++ ++// ----------------------------------------------------------------------------- ++// Instructions encoding constants. ++ ++// On LoongISA all instructions are 32 bits. ++using Instr = int32_t; ++ ++// Special Software Interrupt codes when used in the presence of the LA64 ++// simulator. ++enum SoftwareInterruptCodes { ++ // Transition to C code. ++ call_rt_redirected = 0x7fff ++}; ++ ++// On LA64 Simulator breakpoints can have different codes: ++// - Breaks between 0 and kMaxWatchpointCode are treated as simple watchpoints, ++// the simulator will run through them and print the registers. ++// - Breaks between kMaxWatchpointCode and kMaxStopCode are treated as stop() ++// instructions (see Assembler::stop()). ++// - Breaks larger than kMaxStopCode are simple breaks, dropping you into the ++// debugger. ++const uint32_t kMaxWatchpointCode = 31; ++const uint32_t kMaxStopCode = 127; ++STATIC_ASSERT(kMaxWatchpointCode < kMaxStopCode); ++ ++// ----- Fields offset and length. ++const int kRjShift = 5; ++const int kRjBits = 5; ++const int kRkShift = 10; ++const int kRkBits = 5; ++const int kRdShift = 0; ++const int kRdBits = 5; ++const int kSaShift = 15; ++const int kSa2Bits = 2; ++const int kSa3Bits = 3; ++const int kCdShift = 0; ++const int kCdBits = 3; ++const int kCjShift = 5; ++const int kCjBits = 3; ++const int kCodeShift = 0; ++const int kCodeBits = 15; ++const int kCondShift = 15; ++const int kCondBits = 5; ++const int kUi5Shift = 10; ++const int kUi5Bits = 5; ++const int kUi6Shift = 10; ++const int kUi6Bits = 6; ++const int kUi12Shift = 10; ++const int kUi12Bits = 12; ++const int kSi12Shift = 10; ++const int kSi12Bits = 12; ++const int kSi14Shift = 10; ++const int kSi14Bits = 14; ++const int kSi16Shift = 10; ++const int kSi16Bits = 16; ++const int kSi20Shift = 5; ++const int kSi20Bits = 20; ++const int kMsbwShift = 16; ++const int kMsbwBits = 5; ++const int kLsbwShift = 10; ++const int kLsbwBits = 5; ++const int kMsbdShift = 16; ++const int kMsbdBits = 6; ++const int kLsbdShift = 10; ++const int kLsbdBits = 6; ++const int kFdShift = 0; ++const int kFdBits = 5; ++const int kFjShift = 5; ++const int kFjBits = 5; ++const int kFkShift = 10; ++const int kFkBits = 5; ++const int kFaShift = 15; ++const int kFaBits = 5; ++const int kCaShift = 15; ++const int kCaBits = 3; ++const int kHint15Shift = 0; ++const int kHint15Bits = 15; ++const int kHint5Shift = 0; ++const int kHint5Bits = 5; ++const int kOffsLowShift = 10; ++const int kOffsLowBits = 16; ++const int kOffs26HighShift = 0; ++const int kOffs26HighBits = 10; ++const int kOffs21HighShift = 0; ++const int kOffs21HighBits = 5; ++const int kImm12Shift = 0; ++const int kImm12Bits = 12; ++const int kImm16Shift = 0; ++const int kImm16Bits = 16; ++const int kImm26Shift = 0; ++const int kImm26Bits = 26; ++const int kImm28Shift = 0; ++const int kImm28Bits = 28; ++const int kImm32Shift = 0; ++const int kImm32Bits = 32; ++ ++// ----- Miscellaneous useful masks. ++// Instruction bit masks. ++const int kRjFieldMask = ((1 << kRjBits) - 1) << kRjShift; ++const int kRkFieldMask = ((1 << kRkBits) - 1) << kRkShift; ++const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; ++const int kSa2FieldMask = ((1 << kSa2Bits) - 1) << kSaShift; ++const int kSa3FieldMask = ((1 << kSa3Bits) - 1) << kSaShift; ++// Misc masks. ++const int kHiMaskOf32 = 0xffff << 16; // Only to be used with 32-bit values ++const int kLoMaskOf32 = 0xffff; ++const int kSignMaskOf32 = 0x80000000; // Only to be used with 32-bit values ++const int64_t kTop16MaskOf64 = (int64_t)0xffff << 48; ++const int64_t kHigher16MaskOf64 = (int64_t)0xffff << 32; ++const int64_t kUpper16MaskOf64 = (int64_t)0xffff << 16; ++ ++const int kImm12Mask = ((1 << kImm12Bits) - 1) << kImm12Shift; ++const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; ++const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; ++const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; ++ ++// ----- LA64 Opcodes and Function Fields. ++enum Opcode : uint32_t { ++ BEQZ = 0x10U << 26, ++ BNEZ = 0x11U << 26, ++ BCZ = 0x12U << 26, // BCEQZ & BCNEZ ++ JIRL = 0x13U << 26, ++ B = 0x14U << 26, ++ BL = 0x15U << 26, ++ BEQ = 0x16U << 26, ++ BNE = 0x17U << 26, ++ BLT = 0x18U << 26, ++ BGE = 0x19U << 26, ++ BLTU = 0x1aU << 26, ++ BGEU = 0x1bU << 26, ++ ++ ADDU16I_D = 0x4U << 26, ++ ++ LU12I_W = 0xaU << 25, ++ LU32I_D = 0xbU << 25, ++ PCADDI = 0xcU << 25, ++ PCALAU12I = 0xdU << 25, ++ PCADDU12I = 0xeU << 25, ++ PCADDU18I = 0xfU << 25, ++ ++ LL_W = 0x20U << 24, ++ SC_W = 0x21U << 24, ++ LL_D = 0x22U << 24, ++ SC_D = 0x23U << 24, ++ LDPTR_W = 0x24U << 24, ++ STPTR_W = 0x25U << 24, ++ LDPTR_D = 0x26U << 24, ++ STPTR_D = 0x27U << 24, ++ ++ BSTR_W = 0x1U << 22, // BSTRINS_W & BSTRPICK_W ++ BSTRINS_W = BSTR_W, ++ BSTRPICK_W = BSTR_W, ++ BSTRINS_D = 0x2U << 22, ++ BSTRPICK_D = 0x3U << 22, ++ ++ SLTI = 0x8U << 22, ++ SLTUI = 0x9U << 22, ++ ADDI_W = 0xaU << 22, ++ ADDI_D = 0xbU << 22, ++ LU52I_D = 0xcU << 22, ++ ANDI = 0xdU << 22, ++ ORI = 0xeU << 22, ++ XORI = 0xfU << 22, ++ ++ LD_B = 0xa0U << 22, ++ LD_H = 0xa1U << 22, ++ LD_W = 0xa2U << 22, ++ LD_D = 0xa3U << 22, ++ ST_B = 0xa4U << 22, ++ ST_H = 0xa5U << 22, ++ ST_W = 0xa6U << 22, ++ ST_D = 0xa7U << 22, ++ LD_BU = 0xa8U << 22, ++ LD_HU = 0xa9U << 22, ++ LD_WU = 0xaaU << 22, ++ FLD_S = 0xacU << 22, ++ FST_S = 0xadU << 22, ++ FLD_D = 0xaeU << 22, ++ FST_D = 0xafU << 22, ++ ++ FMADD_S = 0x81U << 20, ++ FMADD_D = 0x82U << 20, ++ FMSUB_S = 0x85U << 20, ++ FMSUB_D = 0x86U << 20, ++ FNMADD_S = 0x89U << 20, ++ FNMADD_D = 0x8aU << 20, ++ FNMSUB_S = 0x8dU << 20, ++ FNMSUB_D = 0x8eU << 20, ++ FCMP_COND_S = 0xc1U << 20, ++ FCMP_COND_D = 0xc2U << 20, ++ ++ BYTEPICK_D = 0x3U << 18, ++ BYTEPICK_W = 0x2U << 18, ++ ++ FSEL = 0x340U << 18, ++ ++ ALSL = 0x1U << 18, ++ ALSL_W = ALSL, ++ ALSL_WU = ALSL, ++ ++ ALSL_D = 0xbU << 18, ++ ++ SLLI_W = 0x40U << 16, ++ SRLI_W = 0x44U << 16, ++ SRAI_W = 0x48U << 16, ++ ROTRI_W = 0x4cU << 16, ++ ++ SLLI_D = 0x41U << 16, ++ SRLI_D = 0x45U << 16, ++ SRAI_D = 0x49U << 16, ++ ROTRI_D = 0x4dU << 16, ++ ++ SLLI = 0x10U << 18, ++ SRLI = 0x11U << 18, ++ SRAI = 0x12U << 18, ++ ROTRI = 0x13U << 18, ++ ++ ADD_W = 0x20U << 15, ++ ADD_D = 0x21U << 15, ++ SUB_W = 0x22U << 15, ++ SUB_D = 0x23U << 15, ++ SLT = 0x24U << 15, ++ SLTU = 0x25U << 15, ++ MASKNEZ = 0x26U << 15, ++ MASKEQZ = 0x27U << 15, ++ NOR = 0x28U << 15, ++ AND = 0x29U << 15, ++ OR = 0x2aU << 15, ++ XOR = 0x2bU << 15, ++ ORN = 0x2cU << 15, ++ ANDN = 0x2dU << 15, ++ SLL_W = 0x2eU << 15, ++ SRL_W = 0x2fU << 15, ++ SRA_W = 0x30U << 15, ++ SLL_D = 0x31U << 15, ++ SRL_D = 0x32U << 15, ++ SRA_D = 0x33U << 15, ++ ROTR_W = 0x36U << 15, ++ ROTR_D = 0x37U << 15, ++ MUL_W = 0x38U << 15, ++ MULH_W = 0x39U << 15, ++ MULH_WU = 0x3aU << 15, ++ MUL_D = 0x3bU << 15, ++ MULH_D = 0x3cU << 15, ++ MULH_DU = 0x3dU << 15, ++ MULW_D_W = 0x3eU << 15, ++ MULW_D_WU = 0x3fU << 15, ++ ++ DIV_W = 0x40U << 15, ++ MOD_W = 0x41U << 15, ++ DIV_WU = 0x42U << 15, ++ MOD_WU = 0x43U << 15, ++ DIV_D = 0x44U << 15, ++ MOD_D = 0x45U << 15, ++ DIV_DU = 0x46U << 15, ++ MOD_DU = 0x47U << 15, ++ ++ BREAK = 0x54U << 15, ++ ++ FADD_S = 0x201U << 15, ++ FADD_D = 0x202U << 15, ++ FSUB_S = 0x205U << 15, ++ FSUB_D = 0x206U << 15, ++ FMUL_S = 0x209U << 15, ++ FMUL_D = 0x20aU << 15, ++ FDIV_S = 0x20dU << 15, ++ FDIV_D = 0x20eU << 15, ++ FMAX_S = 0x211U << 15, ++ FMAX_D = 0x212U << 15, ++ FMIN_S = 0x215U << 15, ++ FMIN_D = 0x216U << 15, ++ FMAXA_S = 0x219U << 15, ++ FMAXA_D = 0x21aU << 15, ++ FMINA_S = 0x21dU << 15, ++ FMINA_D = 0x21eU << 15, ++ FSCALEB_S = 0x221U << 15, ++ FSCALEB_D = 0x222U << 15, ++ FCOPYSIGN_S = 0x225U << 15, ++ FCOPYSIGN_D = 0x226U << 15, ++ ++ LDX_B = 0x7000U << 15, ++ LDX_H = 0x7008U << 15, ++ LDX_W = 0x7010U << 15, ++ LDX_D = 0x7018U << 15, ++ STX_B = 0x7020U << 15, ++ STX_H = 0x7028U << 15, ++ STX_W = 0x7030U << 15, ++ STX_D = 0x7038U << 15, ++ LDX_BU = 0x7040U << 15, ++ LDX_HU = 0x7048U << 15, ++ LDX_WU = 0x7050U << 15, ++ FLDX_S = 0x7060U << 15, ++ FLDX_D = 0x7068U << 15, ++ FSTX_S = 0x7070U << 15, ++ FSTX_D = 0x7078U << 15, ++ ++ AMSWAP_W = 0x70c0U << 15, ++ AMSWAP_D = 0x70c1U << 15, ++ AMADD_W = 0x70c2U << 15, ++ AMADD_D = 0x70c3U << 15, ++ AMAND_W = 0x70c4U << 15, ++ AMAND_D = 0x70c5U << 15, ++ AMOR_W = 0x70c6U << 15, ++ AMOR_D = 0x70c7U << 15, ++ AMXOR_W = 0x70c8U << 15, ++ AMXOR_D = 0x70c9U << 15, ++ AMMAX_W = 0x70caU << 15, ++ AMMAX_D = 0x70cbU << 15, ++ AMMIN_W = 0x70ccU << 15, ++ AMMIN_D = 0x70cdU << 15, ++ AMMAX_WU = 0x70ceU << 15, ++ AMMAX_DU = 0x70cfU << 15, ++ AMMIN_WU = 0x70d0U << 15, ++ AMMIN_DU = 0x70d1U << 15, ++ AMSWAP_DB_W = 0x70d2U << 15, ++ AMSWAP_DB_D = 0x70d3U << 15, ++ AMADD_DB_W = 0x70d4U << 15, ++ AMADD_DB_D = 0x70d5U << 15, ++ AMAND_DB_W = 0x70d6U << 15, ++ AMAND_DB_D = 0x70d7U << 15, ++ AMOR_DB_W = 0x70d8U << 15, ++ AMOR_DB_D = 0x70d9U << 15, ++ AMXOR_DB_W = 0x70daU << 15, ++ AMXOR_DB_D = 0x70dbU << 15, ++ AMMAX_DB_W = 0x70dcU << 15, ++ AMMAX_DB_D = 0x70ddU << 15, ++ AMMIN_DB_W = 0x70deU << 15, ++ AMMIN_DB_D = 0x70dfU << 15, ++ AMMAX_DB_WU = 0x70e0U << 15, ++ AMMAX_DB_DU = 0x70e1U << 15, ++ AMMIN_DB_WU = 0x70e2U << 15, ++ AMMIN_DB_DU = 0x70e3U << 15, ++ ++ DBAR = 0x70e4U << 15, ++ IBAR = 0x70e5U << 15, ++ ++ CLO_W = 0X4U << 10, ++ CLZ_W = 0X5U << 10, ++ CTO_W = 0X6U << 10, ++ CTZ_W = 0X7U << 10, ++ CLO_D = 0X8U << 10, ++ CLZ_D = 0X9U << 10, ++ CTO_D = 0XaU << 10, ++ CTZ_D = 0XbU << 10, ++ REVB_2H = 0XcU << 10, ++ REVB_4H = 0XdU << 10, ++ REVB_2W = 0XeU << 10, ++ REVB_D = 0XfU << 10, ++ REVH_2W = 0X10U << 10, ++ REVH_D = 0X11U << 10, ++ BITREV_4B = 0X12U << 10, ++ BITREV_8B = 0X13U << 10, ++ BITREV_W = 0X14U << 10, ++ BITREV_D = 0X15U << 10, ++ EXT_W_H = 0X16U << 10, ++ EXT_W_B = 0X17U << 10, ++ ++ FABS_S = 0X4501U << 10, ++ FABS_D = 0X4502U << 10, ++ FNEG_S = 0X4505U << 10, ++ FNEG_D = 0X4506U << 10, ++ FLOGB_S = 0X4509U << 10, ++ FLOGB_D = 0X450aU << 10, ++ FCLASS_S = 0X450dU << 10, ++ FCLASS_D = 0X450eU << 10, ++ FSQRT_S = 0X4511U << 10, ++ FSQRT_D = 0X4512U << 10, ++ FRECIP_S = 0X4515U << 10, ++ FRECIP_D = 0X4516U << 10, ++ FRSQRT_S = 0X4519U << 10, ++ FRSQRT_D = 0X451aU << 10, ++ FMOV_S = 0X4525U << 10, ++ FMOV_D = 0X4526U << 10, ++ MOVGR2FR_W = 0X4529U << 10, ++ MOVGR2FR_D = 0X452aU << 10, ++ MOVGR2FRH_W = 0X452bU << 10, ++ MOVFR2GR_S = 0X452dU << 10, ++ MOVFR2GR_D = 0X452eU << 10, ++ MOVFRH2GR_S = 0X452fU << 10, ++ MOVGR2FCSR = 0X4530U << 10, ++ MOVFCSR2GR = 0X4532U << 10, ++ MOVFR2CF = 0X4534U << 10, ++ MOVGR2CF = 0X4536U << 10, ++ ++ FCVT_S_D = 0x4646U << 10, ++ FCVT_D_S = 0x4649U << 10, ++ FTINTRM_W_S = 0x4681U << 10, ++ FTINTRM_W_D = 0x4682U << 10, ++ FTINTRM_L_S = 0x4689U << 10, ++ FTINTRM_L_D = 0x468aU << 10, ++ FTINTRP_W_S = 0x4691U << 10, ++ FTINTRP_W_D = 0x4692U << 10, ++ FTINTRP_L_S = 0x4699U << 10, ++ FTINTRP_L_D = 0x469aU << 10, ++ FTINTRZ_W_S = 0x46a1U << 10, ++ FTINTRZ_W_D = 0x46a2U << 10, ++ FTINTRZ_L_S = 0x46a9U << 10, ++ FTINTRZ_L_D = 0x46aaU << 10, ++ FTINTRNE_W_S = 0x46b1U << 10, ++ FTINTRNE_W_D = 0x46b2U << 10, ++ FTINTRNE_L_S = 0x46b9U << 10, ++ FTINTRNE_L_D = 0x46baU << 10, ++ FTINT_W_S = 0x46c1U << 10, ++ FTINT_W_D = 0x46c2U << 10, ++ FTINT_L_S = 0x46c9U << 10, ++ FTINT_L_D = 0x46caU << 10, ++ FFINT_S_W = 0x4744U << 10, ++ FFINT_S_L = 0x4746U << 10, ++ FFINT_D_W = 0x4748U << 10, ++ FFINT_D_L = 0x474aU << 10, ++ FRINT_S = 0x4791U << 10, ++ FRINT_D = 0x4792U << 10, ++ ++ MOVCF2FR = 0x4535U << 10, ++ MOVCF2GR = 0x4537U << 10, ++}; ++ ++// ----- Emulated conditions. ++// On LA64 we use this enum to abstract from conditional branch instructions. ++// The 'U' prefix is used to specify unsigned comparisons. ++enum Condition { ++ // Any value < 0 is considered no_condition. ++ kNoCondition = -1, ++ overflow = 0, ++ no_overflow = 1, ++ Uless = 2, ++ Ugreater_equal = 3, ++ Uless_equal = 4, ++ Ugreater = 5, ++ equal = 6, ++ not_equal = 7, // Unordered or Not Equal. ++ negative = 8, ++ positive = 9, ++ parity_even = 10, ++ parity_odd = 11, ++ less = 12, ++ greater_equal = 13, ++ less_equal = 14, ++ greater = 15, ++ ueq = 16, // Unordered or Equal. ++ ogl = 17, // Ordered and Not Equal. ++ cc_always = 18, ++ ++ // Aliases. ++ carry = Uless, ++ not_carry = Ugreater_equal, ++ zero = equal, ++ eq = equal, ++ not_zero = not_equal, ++ ne = not_equal, ++ nz = not_equal, ++ sign = negative, ++ not_sign = positive, ++ mi = negative, ++ pl = positive, ++ hi = Ugreater, ++ ls = Uless_equal, ++ ge = greater_equal, ++ lt = less, ++ gt = greater, ++ le = less_equal, ++ hs = Ugreater_equal, ++ lo = Uless, ++ al = cc_always, ++ ult = Uless, ++ uge = Ugreater_equal, ++ ule = Uless_equal, ++ ugt = Ugreater, ++ cc_default = kNoCondition ++}; ++ ++// Returns the equivalent of !cc. ++// Negation of the default kNoCondition (-1) results in a non-default ++// no_condition value (-2). As long as tests for no_condition check ++// for condition < 0, this will work as expected. ++inline Condition NegateCondition(Condition cc) { ++ DCHECK(cc != cc_always); ++ return static_cast(cc ^ 1); ++} ++ ++inline Condition NegateFpuCondition(Condition cc) { ++ DCHECK(cc != cc_always); ++ switch (cc) { ++ case ult: ++ return ge; ++ case ugt: ++ return le; ++ case uge: ++ return lt; ++ case ule: ++ return gt; ++ case lt: ++ return uge; ++ case gt: ++ return ule; ++ case ge: ++ return ult; ++ case le: ++ return ugt; ++ case eq: ++ return ne; ++ case ne: ++ return eq; ++ case ueq: ++ return ogl; ++ case ogl: ++ return ueq; ++ default: ++ return cc; ++ } ++} ++ ++// ----- Coprocessor conditions. ++enum FPUCondition { ++ kNoFPUCondition = -1, ++ ++ CAF = 0x00, // False. ++ SAF = 0x01, // False. ++ CLT = 0x02, // Less Than quiet ++ // SLT = 0x03, // Less Than signaling ++ CEQ = 0x04, ++ SEQ = 0x05, ++ CLE = 0x06, ++ SLE = 0x07, ++ CUN = 0x08, ++ SUN = 0x09, ++ CULT = 0x0a, ++ SULT = 0x0b, ++ CUEQ = 0x0c, ++ SUEQ = 0x0d, ++ CULE = 0x0e, ++ SULE = 0x0f, ++ CNE = 0x10, ++ SNE = 0x11, ++ COR = 0x14, ++ SOR = 0x15, ++ CUNE = 0x18, ++ SUNE = 0x19, ++}; ++ ++const uint32_t kFPURoundingModeShift = 8; ++const uint32_t kFPURoundingModeMask = 0b11 << kFPURoundingModeShift; ++ ++// FPU rounding modes. ++enum FPURoundingMode { ++ RN = 0b00 << kFPURoundingModeShift, // Round to Nearest. ++ RZ = 0b01 << kFPURoundingModeShift, // Round towards zero. ++ RP = 0b10 << kFPURoundingModeShift, // Round towards Plus Infinity. ++ RM = 0b11 << kFPURoundingModeShift, // Round towards Minus Infinity. ++ ++ // Aliases. ++ kRoundToNearest = RN, ++ kRoundToZero = RZ, ++ kRoundToPlusInf = RP, ++ kRoundToMinusInf = RM, ++ ++ mode_round = RN, ++ mode_ceil = RP, ++ mode_floor = RM, ++ mode_trunc = RZ ++}; ++ ++enum CheckForInexactConversion { ++ kCheckForInexactConversion, ++ kDontCheckForInexactConversion ++}; ++ ++enum class MaxMinKind : int { kMin = 0, kMax = 1 }; ++ ++// ----------------------------------------------------------------------------- ++// Hints. ++ ++// Branch hints are not used on the LA64. They are defined so that they can ++// appear in shared function signatures, but will be ignored in LA64 ++// implementations. ++enum Hint { no_hint = 0 }; ++ ++inline Hint NegateHint(Hint hint) { return no_hint; } ++ ++// ----------------------------------------------------------------------------- ++// Specific instructions, constants, and masks. ++// These constants are declared in assembler-mips.cc, as they use named ++// registers and other constants. ++ ++// addi_d(sp, sp, 8) aka Pop() operation or part of Pop(r) ++// operations as post-increment of sp. ++extern const Instr kPopInstruction; ++// addi_d(sp, sp, -8) part of Push(r) operation as pre-decrement of sp. ++extern const Instr kPushInstruction; ++// St_d(r, MemOperand(sp, 0)) ++extern const Instr kPushRegPattern; ++// Ld_d(r, MemOperand(sp, 0)) ++extern const Instr kPopRegPattern; ++// extern const Instr kLwRegFpOffsetPattern; ++// extern const Instr kSwRegFpOffsetPattern; ++// extern const Instr kLwRegFpNegOffsetPattern; ++// extern const Instr kSwRegFpNegOffsetPattern; ++// A mask for the Rk register for push, pop, lw, sw instructions. ++extern const Instr kRtMask; ++// extern const Instr kLwSwInstrTypeMask; ++// extern const Instr kLwSwInstrArgumentMask; ++// extern const Instr kLwSwOffsetMask; ++ ++// Break 0xfffff, reserved for redirected real time call. ++const Instr rtCallRedirInstr = BREAK | call_rt_redirected; ++// A nop instruction. (Encoding of addi_w 0 0 0). ++const Instr nopInstr = ADDI_W; ++ ++constexpr uint8_t kInstrSize = 4; ++constexpr uint8_t kInstrSizeLog2 = 2; ++ ++class InstructionBase { ++ public: ++ enum { ++ // On Loonisa PC cannot actually be directly accessed. We behave as if PC ++ // was ++ // always the value of the current instruction being executed. ++ kPCReadOffset = 0 ++ }; ++ ++ enum Type { ++ kOp6Type, ++ kOp7Type, ++ kOp8Type, ++ kOp10Type, ++ kOp12Type, ++ kOp14Type, ++ kOp17Type, ++ kOp22Type, ++ kUnsupported = -1 ++ }; ++ ++ // Get the raw instruction bits. ++ inline Instr InstructionBits() const { ++ return *reinterpret_cast(this); ++ } ++ ++ // Set the raw instruction bits to value. ++ inline void SetInstructionBits(Instr value) { ++ *reinterpret_cast(this) = value; ++ } ++ ++ // Read one particular bit out of the instruction bits. ++ inline int Bit(int nr) const { return (InstructionBits() >> nr) & 1; } ++ ++ // Read a bit field out of the instruction bits. ++ inline int Bits(int hi, int lo) const { ++ return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); ++ } ++ ++ // Safe to call within InstructionType(). ++ inline int RjFieldRawNoAssert() const { ++ return InstructionBits() & kRjFieldMask; ++ } ++ ++ // Get the encoding type of the instruction. ++ inline Type InstructionType() const; ++ ++ protected: ++ InstructionBase() {} ++}; ++ ++template ++class InstructionGetters : public T { ++ public: ++ inline int RjValue() const { ++ return this->Bits(kRjShift + kRjBits - 1, kRjShift); ++ } ++ ++ inline int RkValue() const { ++ return this->Bits(kRkShift + kRkBits - 1, kRkShift); ++ } ++ ++ inline int RdValue() const { ++ return this->Bits(kRdShift + kRdBits - 1, kRdShift); ++ } ++ ++ inline int Sa2Value() const { ++ return this->Bits(kSaShift + kSa2Bits - 1, kSaShift); ++ } ++ ++ inline int Sa3Value() const { ++ return this->Bits(kSaShift + kSa3Bits - 1, kSaShift); ++ } ++ ++ inline int Ui5Value() const { ++ return this->Bits(kUi5Shift + kUi5Bits - 1, kUi5Shift); ++ } ++ ++ inline int Ui6Value() const { ++ return this->Bits(kUi6Shift + kUi6Bits - 1, kUi6Shift); ++ } ++ ++ inline int Ui12Value() const { ++ return this->Bits(kUi12Shift + kUi12Bits - 1, kUi12Shift); ++ } ++ ++ inline int LsbwValue() const { ++ return this->Bits(kLsbwShift + kLsbwBits - 1, kLsbwShift); ++ } ++ ++ inline int MsbwValue() const { ++ return this->Bits(kMsbwShift + kMsbwBits - 1, kMsbwShift); ++ } ++ ++ inline int LsbdValue() const { ++ return this->Bits(kLsbdShift + kLsbdBits - 1, kLsbdShift); ++ } ++ ++ inline int MsbdValue() const { ++ return this->Bits(kMsbdShift + kMsbdBits - 1, kMsbdShift); ++ } ++ ++ inline int CondValue() const { ++ return this->Bits(kCondShift + kCondBits - 1, kCondShift); ++ } ++ ++ inline int Si12Value() const { ++ return this->Bits(kSi12Shift + kSi12Bits - 1, kSi12Shift); ++ } ++ ++ inline int Si14Value() const { ++ return this->Bits(kSi14Shift + kSi14Bits - 1, kSi14Shift); ++ } ++ ++ inline int Si16Value() const { ++ return this->Bits(kSi16Shift + kSi16Bits - 1, kSi16Shift); ++ } ++ ++ inline int Si20Value() const { ++ return this->Bits(kSi20Shift + kSi20Bits - 1, kSi20Shift); ++ } ++ ++ inline int FdValue() const { ++ return this->Bits(kFdShift + kFdBits - 1, kFdShift); ++ } ++ ++ inline int FaValue() const { ++ return this->Bits(kFaShift + kFaBits - 1, kFaShift); ++ } ++ ++ inline int FjValue() const { ++ return this->Bits(kFjShift + kFjBits - 1, kFjShift); ++ } ++ ++ inline int FkValue() const { ++ return this->Bits(kFkShift + kFkBits - 1, kFkShift); ++ } ++ ++ inline int CjValue() const { ++ return this->Bits(kCjShift + kCjBits - 1, kCjShift); ++ } ++ ++ inline int CdValue() const { ++ return this->Bits(kCdShift + kCdBits - 1, kCdShift); ++ } ++ ++ inline int CaValue() const { ++ return this->Bits(kCaShift + kCaBits - 1, kCaShift); ++ } ++ ++ inline int CodeValue() const { ++ return this->Bits(kCodeShift + kCodeBits - 1, kCodeShift); ++ } ++ ++ inline int Hint5Value() const { ++ return this->Bits(kHint5Shift + kHint5Bits - 1, kHint5Shift); ++ } ++ ++ inline int Hint15Value() const { ++ return this->Bits(kHint15Shift + kHint15Bits - 1, kHint15Shift); ++ } ++ ++ inline int Offs16Value() const { ++ return this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); ++ } ++ ++ inline int Offs21Value() const { ++ int low = this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); ++ int high = ++ this->Bits(kOffs21HighShift + kOffs21HighBits - 1, kOffs21HighShift); ++ return ((high << kOffsLowBits) + low); ++ } ++ ++ inline int Offs26Value() const { ++ int low = this->Bits(kOffsLowShift + kOffsLowBits - 1, kOffsLowShift); ++ int high = ++ this->Bits(kOffs26HighShift + kOffs26HighBits - 1, kOffs26HighShift); ++ return ((high << kOffsLowBits) + low); ++ } ++ ++ inline int RjFieldRaw() const { ++ return this->InstructionBits() & kRjFieldMask; ++ } ++ ++ inline int RkFieldRaw() const { ++ return this->InstructionBits() & kRkFieldMask; ++ } ++ ++ inline int RdFieldRaw() const { ++ return this->InstructionBits() & kRdFieldMask; ++ } ++ ++ inline int32_t ImmValue(int bits) const { return this->Bits(bits - 1, 0); } ++ ++ /*TODO*/ ++ inline int32_t Imm12Value() const { abort(); } ++ ++ inline int32_t Imm14Value() const { abort(); } ++ ++ inline int32_t Imm16Value() const { abort(); } ++ ++ // Say if the instruction 'links'. e.g. jal, bal. ++ bool IsLinkingInstruction() const; ++ // Say if the instruction is a break or a trap. ++ bool IsTrap() const; ++}; ++ ++class Instruction : public InstructionGetters { ++ public: ++ // Instructions are read of out a code stream. The only way to get a ++ // reference to an instruction is to convert a pointer. There is no way ++ // to allocate or create instances of class Instruction. ++ // Use the At(pc) function to create references to Instruction. ++ static Instruction* At(byte* pc) { ++ return reinterpret_cast(pc); ++ } ++ ++ private: ++ // We need to prevent the creation of instances of class Instruction. ++ DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); ++}; ++ ++// ----------------------------------------------------------------------------- ++// LA64 assembly various constants. ++ ++// C/C++ argument slots size. ++const int kCArgSlotCount = 0; ++ ++const int kCArgsSlotsSize = kCArgSlotCount * kInstrSize * 2; ++ ++const int kInvalidStackOffset = -1; ++ ++static const int kNegOffset = 0x00008000; ++ ++InstructionBase::Type InstructionBase::InstructionType() const { ++ InstructionBase::Type kType = kUnsupported; ++ ++ // Check for kOp6Type ++ switch (Bits(31, 26) << 26) { ++ case ADDU16I_D: ++ case BEQZ: ++ case BNEZ: ++ case BCZ: ++ case JIRL: ++ case B: ++ case BL: ++ case BEQ: ++ case BNE: ++ case BLT: ++ case BGE: ++ case BLTU: ++ case BGEU: ++ kType = kOp6Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp7Type ++ switch (Bits(31, 25) << 25) { ++ case LU12I_W: ++ case LU32I_D: ++ case PCADDI: ++ case PCALAU12I: ++ case PCADDU12I: ++ case PCADDU18I: ++ kType = kOp7Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp8Type ++ switch (Bits(31, 24) << 24) { ++ case LDPTR_W: ++ case STPTR_W: ++ case LDPTR_D: ++ case STPTR_D: ++ case LL_W: ++ case SC_W: ++ case LL_D: ++ case SC_D: ++ kType = kOp8Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp10Type ++ switch (Bits(31, 22) << 22) { ++ case BSTR_W: { ++ // If Bit(21) = 0, then the Opcode is not BSTR_W. ++ if (Bit(21) == 0) ++ kType = kUnsupported; ++ else ++ kType = kOp10Type; ++ break; ++ } ++ case BSTRINS_D: ++ case BSTRPICK_D: ++ case SLTI: ++ case SLTUI: ++ case ADDI_W: ++ case ADDI_D: ++ case LU52I_D: ++ case ANDI: ++ case ORI: ++ case XORI: ++ case LD_B: ++ case LD_H: ++ case LD_W: ++ case LD_D: ++ case ST_B: ++ case ST_H: ++ case ST_W: ++ case ST_D: ++ case LD_BU: ++ case LD_HU: ++ case LD_WU: ++ case FLD_S: ++ case FST_S: ++ case FLD_D: ++ case FST_D: ++ kType = kOp10Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp12Type ++ switch (Bits(31, 20) << 20) { ++ case FMADD_S: ++ case FMADD_D: ++ case FMSUB_S: ++ case FMSUB_D: ++ case FNMADD_S: ++ case FNMADD_D: ++ case FNMSUB_S: ++ case FNMSUB_D: ++ case FCMP_COND_S: ++ case FCMP_COND_D: ++ case FSEL: ++ kType = kOp12Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp14Type ++ switch (Bits(31, 18) << 18) { ++ case ALSL: ++ case BYTEPICK_W: ++ case BYTEPICK_D: ++ case ALSL_D: ++ case SLLI: ++ case SRLI: ++ case SRAI: ++ case ROTRI: ++ kType = kOp14Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp17Type ++ switch (Bits(31, 15) << 15) { ++ case ADD_W: ++ case ADD_D: ++ case SUB_W: ++ case SUB_D: ++ case SLT: ++ case SLTU: ++ case MASKEQZ: ++ case MASKNEZ: ++ case NOR: ++ case AND: ++ case OR: ++ case XOR: ++ case ORN: ++ case ANDN: ++ case SLL_W: ++ case SRL_W: ++ case SRA_W: ++ case SLL_D: ++ case SRL_D: ++ case SRA_D: ++ case ROTR_D: ++ case ROTR_W: ++ case MUL_W: ++ case MULH_W: ++ case MULH_WU: ++ case MUL_D: ++ case MULH_D: ++ case MULH_DU: ++ case MULW_D_W: ++ case MULW_D_WU: ++ case DIV_W: ++ case MOD_W: ++ case DIV_WU: ++ case MOD_WU: ++ case DIV_D: ++ case MOD_D: ++ case DIV_DU: ++ case MOD_DU: ++ case BREAK: ++ case FADD_S: ++ case FADD_D: ++ case FSUB_S: ++ case FSUB_D: ++ case FMUL_S: ++ case FMUL_D: ++ case FDIV_S: ++ case FDIV_D: ++ case FMAX_S: ++ case FMAX_D: ++ case FMIN_S: ++ case FMIN_D: ++ case FMAXA_S: ++ case FMAXA_D: ++ case FMINA_S: ++ case FMINA_D: ++ case LDX_B: ++ case LDX_H: ++ case LDX_W: ++ case LDX_D: ++ case STX_B: ++ case STX_H: ++ case STX_W: ++ case STX_D: ++ case LDX_BU: ++ case LDX_HU: ++ case LDX_WU: ++ case FLDX_S: ++ case FLDX_D: ++ case FSTX_S: ++ case FSTX_D: ++ case AMSWAP_W: ++ case AMSWAP_D: ++ case AMADD_W: ++ case AMADD_D: ++ case AMAND_W: ++ case AMAND_D: ++ case AMOR_W: ++ case AMOR_D: ++ case AMXOR_W: ++ case AMXOR_D: ++ case AMMAX_W: ++ case AMMAX_D: ++ case AMMIN_W: ++ case AMMIN_D: ++ case AMMAX_WU: ++ case AMMAX_DU: ++ case AMMIN_WU: ++ case AMMIN_DU: ++ case AMSWAP_DB_W: ++ case AMSWAP_DB_D: ++ case AMADD_DB_W: ++ case AMADD_DB_D: ++ case AMAND_DB_W: ++ case AMAND_DB_D: ++ case AMOR_DB_W: ++ case AMOR_DB_D: ++ case AMXOR_DB_W: ++ case AMXOR_DB_D: ++ case AMMAX_DB_W: ++ case AMMAX_DB_D: ++ case AMMIN_DB_W: ++ case AMMIN_DB_D: ++ case AMMAX_DB_WU: ++ case AMMAX_DB_DU: ++ case AMMIN_DB_WU: ++ case AMMIN_DB_DU: ++ case DBAR: ++ case IBAR: ++ case FSCALEB_S: ++ case FSCALEB_D: ++ case FCOPYSIGN_S: ++ case FCOPYSIGN_D: ++ kType = kOp17Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ if (kType == kUnsupported) { ++ // Check for kOp22Type ++ switch (Bits(31, 10) << 10) { ++ case CLZ_W: ++ case CTZ_W: ++ case CLZ_D: ++ case CTZ_D: ++ case REVB_2H: ++ case REVB_4H: ++ case REVB_2W: ++ case REVB_D: ++ case REVH_2W: ++ case REVH_D: ++ case BITREV_4B: ++ case BITREV_8B: ++ case BITREV_W: ++ case BITREV_D: ++ case EXT_W_B: ++ case EXT_W_H: ++ case FABS_S: ++ case FABS_D: ++ case FNEG_S: ++ case FNEG_D: ++ case FSQRT_S: ++ case FSQRT_D: ++ case FMOV_S: ++ case FMOV_D: ++ case MOVGR2FR_W: ++ case MOVGR2FR_D: ++ case MOVGR2FRH_W: ++ case MOVFR2GR_S: ++ case MOVFR2GR_D: ++ case MOVFRH2GR_S: ++ case MOVGR2FCSR: ++ case MOVFCSR2GR: ++ case FCVT_S_D: ++ case FCVT_D_S: ++ case FTINTRM_W_S: ++ case FTINTRM_W_D: ++ case FTINTRM_L_S: ++ case FTINTRM_L_D: ++ case FTINTRP_W_S: ++ case FTINTRP_W_D: ++ case FTINTRP_L_S: ++ case FTINTRP_L_D: ++ case FTINTRZ_W_S: ++ case FTINTRZ_W_D: ++ case FTINTRZ_L_S: ++ case FTINTRZ_L_D: ++ case FTINTRNE_W_S: ++ case FTINTRNE_W_D: ++ case FTINTRNE_L_S: ++ case FTINTRNE_L_D: ++ case FTINT_W_S: ++ case FTINT_W_D: ++ case FTINT_L_S: ++ case FTINT_L_D: ++ case FFINT_S_W: ++ case FFINT_S_L: ++ case FFINT_D_W: ++ case FFINT_D_L: ++ case FRINT_S: ++ case FRINT_D: ++ case MOVFR2CF: ++ case MOVCF2FR: ++ case MOVGR2CF: ++ case MOVCF2GR: ++ case FRECIP_S: ++ case FRECIP_D: ++ case FRSQRT_S: ++ case FRSQRT_D: ++ case FCLASS_S: ++ case FCLASS_D: ++ case FLOGB_S: ++ case FLOGB_D: ++ case CLO_W: ++ case CTO_W: ++ case CLO_D: ++ case CTO_D: ++ kType = kOp22Type; ++ break; ++ default: ++ kType = kUnsupported; ++ } ++ } ++ ++ return kType; ++} ++ ++// ----------------------------------------------------------------------------- ++// Instructions. ++ ++template ++bool InstructionGetters

::IsTrap() const { ++ return true; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_LOONGARCH64_CONSTANTS_LOONGARCH64_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/cpu-loongarch64.cc +@@ -0,0 +1,38 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// CPU specific code for loongisa independent of OS goes here. ++ ++#include ++#include ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/codegen/cpu-features.h" ++ ++namespace v8 { ++namespace internal { ++ ++void CpuFeatures::FlushICache(void* start, size_t size) { ++#if !defined(USE_SIMULATOR) ++ // Nothing to do, flushing no instructions. ++ if (size == 0) { ++ return; ++ } ++ ++#if defined(ANDROID) && !defined(__LP64__) ++ // Bionic cacheflush can typically run in userland, avoiding kernel call. ++ char* end = reinterpret_cast(start) + size; ++ cacheflush(reinterpret_cast(start), reinterpret_cast(end), ++ 0); ++#else // ANDROID ++ asm("ibar 0\n"); ++#endif // ANDROID ++#endif // !USE_SIMULATOR. ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/interface-descriptors-loongarch64.cc +@@ -0,0 +1,357 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/codegen/interface-descriptors.h" ++#include "src/execution/frames.h" ++ ++namespace v8 { ++namespace internal { ++ ++const Register CallInterfaceDescriptor::ContextRegister() { return cp; } ++ ++void CallInterfaceDescriptor::DefaultInitializePlatformSpecific( ++ CallInterfaceDescriptorData* data, int register_parameter_count) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ CHECK_LE(static_cast(register_parameter_count), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(register_parameter_count, ++ default_stub_registers); ++} ++ ++// On MIPS it is not allowed to use odd numbered floating point registers ++// (e.g. f1, f3, etc.) for parameters. This can happen if we use ++// DefaultInitializePlatformSpecific to assign float registers for parameters. ++// E.g if fourth parameter goes to float register, f7 would be assigned for ++// parameter (a3 casted to int is 7). ++bool CallInterfaceDescriptor::IsValidFloatParameterRegister(Register reg) { ++ return reg.code() % 2 == 0; ++} ++ ++void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3}; ++ CHECK_EQ(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++void WasmI64AtomicWait32Descriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ CHECK_EQ(static_cast(kParameterCount - kStackArgumentsCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount - kStackArgumentsCount, ++ default_stub_registers); ++} ++ ++void RecordWriteDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ ++ data->RestrictAllocatableRegisters(default_stub_registers, ++ arraysize(default_stub_registers)); ++ ++ CHECK_LE(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ ++ data->RestrictAllocatableRegisters(default_stub_registers, ++ arraysize(default_stub_registers)); ++ ++ CHECK_LE(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++const Register LoadDescriptor::ReceiverRegister() { return a1; } ++const Register LoadDescriptor::NameRegister() { return a2; } ++const Register LoadDescriptor::SlotRegister() { return a0; } ++ ++const Register LoadWithVectorDescriptor::VectorRegister() { return a3; } ++ ++const Register ++LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() { ++ return a4; ++} ++ ++const Register StoreDescriptor::ReceiverRegister() { return a1; } ++const Register StoreDescriptor::NameRegister() { return a2; } ++const Register StoreDescriptor::ValueRegister() { return a0; } ++const Register StoreDescriptor::SlotRegister() { return a4; } ++ ++const Register StoreWithVectorDescriptor::VectorRegister() { return a3; } ++ ++const Register StoreTransitionDescriptor::SlotRegister() { return a4; } ++const Register StoreTransitionDescriptor::VectorRegister() { return a3; } ++const Register StoreTransitionDescriptor::MapRegister() { return a5; } ++ ++const Register ApiGetterDescriptor::HolderRegister() { return a0; } ++const Register ApiGetterDescriptor::CallbackRegister() { return a3; } ++ ++const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } ++const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } ++ ++// static ++const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } ++ ++void TypeofDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a3}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallTrampolineDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: target ++ // a0: number of arguments ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a4 : arguments list length (untagged) ++ // a2 : arguments list (FixedArray) ++ Register registers[] = {a1, a0, a4, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallForwardVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: the target to call ++ // a0: number of arguments ++ // a2: start index (to support rest parameters) ++ Register registers[] = {a1, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallFunctionTemplateDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : function template info ++ // a0 : number of arguments (on the stack, not including receiver) ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallWithSpreadDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a2 : the object to spread ++ Register registers[] = {a1, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallWithArrayLikeDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : the target to call ++ // a2 : the arguments list ++ Register registers[] = {a1, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a3 : the new target ++ // a4 : arguments list length (untagged) ++ // a2 : arguments list (FixedArray) ++ Register registers[] = {a1, a3, a0, a4, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: the target to call ++ // a3: new target ++ // a0: number of arguments ++ // a2: start index (to support rest parameters) ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructWithSpreadDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a3 : the new target ++ // a2 : the object to spread ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : the target to call ++ // a3 : the new target ++ // a2 : the arguments list ++ Register registers[] = {a1, a3, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructStubDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: target ++ // a3: new target ++ // a0: number of arguments ++ // a2: allocation site or undefined ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void AbortDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CompareDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void BinaryOpDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ArgumentsAdaptorDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // JSFunction ++ a3, // the new target ++ a0, // actual number of arguments ++ a2, // expected number of arguments ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ApiCallbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // kApiFunctionAddress ++ a2, // kArgc ++ a3, // kCallData ++ a0, // kHolder ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterDispatchDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister, ++ kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // argument count (not including receiver) ++ a2, // address of first argument ++ a1 // the target callable to be call ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // argument count (not including receiver) ++ a4, // address of the first argument ++ a1, // constructor to call ++ a3, // new target ++ a2, // allocation site feedback if available, undefined otherwise ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ResumeGeneratorDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // the value to pass to the generator ++ a1 // the JSGeneratorObject to resume ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void FrameDropperTrampolineDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // loaded new FP ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void RunMicrotasksEntryDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a0, a1}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void BinaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallTrampoline_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void ConstructWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void ConstructWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void Compare_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void UnaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 3); ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LA64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.cc +@@ -0,0 +1,4021 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include // For LONG_MIN, LONG_MAX. ++ ++#include "src/base/bits.h" ++#include "src/base/division-by-constant.h" ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/callable.h" ++#include "src/codegen/code-factory.h" ++#include "src/codegen/external-reference-table.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/register-configuration.h" ++#include "src/debug/debug.h" ++#include "src/execution/frames-inl.h" ++#include "src/heap/memory-chunk.h" ++#include "src/init/bootstrapper.h" ++#include "src/logging/counters.h" ++#include "src/objects/heap-number.h" ++#include "src/runtime/runtime.h" ++#include "src/snapshot/embedded/embedded-data.h" ++#include "src/snapshot/snapshot.h" ++#include "src/wasm/wasm-code-manager.h" ++ ++// Satisfy cpplint check, but don't include platform-specific header. It is ++// included recursively via macro-assembler.h. ++#if 0 ++#include "src/codegen/loongarch64/macro-assembler-loongarch64.h" ++#endif ++ ++namespace v8 { ++namespace internal { ++ ++static inline bool IsZero(const Operand& rk) { ++ if (rk.is_reg()) { ++ return rk.rm() == zero_reg; ++ } else { ++ return rk.immediate() == 0; ++ } ++} ++ ++int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, ++ Register exclusion1, ++ Register exclusion2, ++ Register exclusion3) const { ++ int bytes = 0; ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ bytes += NumRegs(list) * kPointerSize; ++ ++ if (fp_mode == kSaveFPRegs) { ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ return bytes; ++} ++ ++int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ++ Register exclusion2, Register exclusion3) { ++ int bytes = 0; ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ MultiPush(list); ++ bytes += NumRegs(list) * kPointerSize; ++ ++ if (fp_mode == kSaveFPRegs) { ++ MultiPushFPU(kCallerSavedFPU); ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ return bytes; ++} ++ ++int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ++ Register exclusion2, Register exclusion3) { ++ int bytes = 0; ++ if (fp_mode == kSaveFPRegs) { ++ MultiPopFPU(kCallerSavedFPU); ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ MultiPop(list); ++ bytes += NumRegs(list) * kPointerSize; ++ ++ return bytes; ++} ++ ++void TurboAssembler::LoadRoot(Register destination, RootIndex index) { ++ Ld_d(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); ++} ++ ++void TurboAssembler::PushCommonFrame(Register marker_reg) { ++ if (marker_reg.is_valid()) { ++ Push(ra, fp, marker_reg); ++ Add_d(fp, sp, Operand(kPointerSize)); ++ } else { ++ Push(ra, fp); ++ mov(fp, sp); ++ } ++} ++ ++void TurboAssembler::PushStandardFrame(Register function_reg) { ++ int offset = -StandardFrameConstants::kContextOffset; ++ if (function_reg.is_valid()) { ++ Push(ra, fp, cp, function_reg, kJavaScriptCallArgCountRegister); ++ offset += 2 * kPointerSize; ++ } else { ++ Push(ra, fp, cp, kJavaScriptCallArgCountRegister); ++ offset += kPointerSize; ++ } ++ Add_d(fp, sp, Operand(offset)); ++} ++ ++int MacroAssembler::SafepointRegisterStackIndex(int reg_code) { ++ // The registers are pushed starting with the highest encoding, ++ // which means that lowest encodings are closest to the stack pointer. ++ return kSafepointRegisterStackIndexMap[reg_code]; ++} ++ ++// Clobbers object, dst, value, and ra, if (ra_status == kRAHasBeenSaved) ++// The register 'object' contains a heap object pointer. The heap object ++// tag is shifted away. ++void MacroAssembler::RecordWriteField(Register object, int offset, ++ Register value, Register dst, ++ RAStatus ra_status, ++ SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action, ++ SmiCheck smi_check) { ++ DCHECK(!AreAliased(value, dst, t8, object)); ++ // First, check if a write barrier is even needed. The tests below ++ // catch stores of Smis. ++ Label done; ++ ++ // Skip barrier if writing a smi. ++ if (smi_check == INLINE_SMI_CHECK) { ++ JumpIfSmi(value, &done); ++ } ++ ++ // Although the object register is tagged, the offset is relative to the start ++ // of the object, so so offset must be a multiple of kPointerSize. ++ DCHECK(IsAligned(offset, kPointerSize)); ++ ++ Add_d(dst, object, Operand(offset - kHeapObjectTag)); ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Label ok; ++ And(t8, dst, Operand(kPointerSize - 1)); ++ Branch(&ok, eq, t8, Operand(zero_reg)); ++ stop(); ++ bind(&ok); ++ } ++ ++ RecordWrite(object, dst, value, ra_status, save_fp, remembered_set_action, ++ OMIT_SMI_CHECK); ++ ++ bind(&done); ++ ++ // Clobber clobbered input registers when running with the debug-code flag ++ // turned on to provoke errors. ++ if (emit_debug_code()) { ++ li(value, Operand(bit_cast(kZapValue + 4))); ++ li(dst, Operand(bit_cast(kZapValue + 8))); ++ } ++} ++ ++void TurboAssembler::SaveRegisters(RegList registers) { ++ DCHECK_GT(NumRegs(registers), 0); ++ RegList regs = 0; ++ for (int i = 0; i < Register::kNumRegisters; ++i) { ++ if ((registers >> i) & 1u) { ++ regs |= Register::from_code(i).bit(); ++ } ++ } ++ MultiPush(regs); ++} ++ ++void TurboAssembler::RestoreRegisters(RegList registers) { ++ DCHECK_GT(NumRegs(registers), 0); ++ RegList regs = 0; ++ for (int i = 0; i < Register::kNumRegisters; ++i) { ++ if ((registers >> i) & 1u) { ++ regs |= Register::from_code(i).bit(); ++ } ++ } ++ MultiPop(regs); ++} ++ ++void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address, ++ SaveFPRegsMode fp_mode) { ++ EphemeronKeyBarrierDescriptor descriptor; ++ RegList registers = descriptor.allocatable_registers(); ++ ++ SaveRegisters(registers); ++ ++ Register object_parameter( ++ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kObject)); ++ Register slot_parameter(descriptor.GetRegisterParameter( ++ EphemeronKeyBarrierDescriptor::kSlotAddress)); ++ Register fp_mode_parameter( ++ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kFPMode)); ++ ++ Push(object); ++ Push(address); ++ ++ Pop(slot_parameter); ++ Pop(object_parameter); ++ ++ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); ++ Call(isolate()->builtins()->builtin_handle(Builtins::kEphemeronKeyBarrier), ++ RelocInfo::CODE_TARGET); ++ RestoreRegisters(registers); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) { ++ CallRecordWriteStub( ++ object, address, remembered_set_action, fp_mode, ++ isolate()->builtins()->builtin_handle(Builtins::kRecordWrite), ++ kNullAddress); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, ++ Address wasm_target) { ++ CallRecordWriteStub(object, address, remembered_set_action, fp_mode, ++ Handle::null(), wasm_target); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, ++ Handle code_target, Address wasm_target) { ++ DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress); ++ // TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode, ++ // i.e. always emit remember set and save FP registers in RecordWriteStub. If ++ // large performance regression is observed, we should use these values to ++ // avoid unnecessary work. ++ ++ RecordWriteDescriptor descriptor; ++ RegList registers = descriptor.allocatable_registers(); ++ ++ SaveRegisters(registers); ++ Register object_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kObject)); ++ Register slot_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kSlot)); ++ Register remembered_set_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kRememberedSet)); ++ Register fp_mode_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kFPMode)); ++ ++ Push(object); ++ Push(address); ++ ++ Pop(slot_parameter); ++ Pop(object_parameter); ++ ++ Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action)); ++ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); ++ if (code_target.is_null()) { ++ Call(wasm_target, RelocInfo::WASM_STUB_CALL); ++ } else { ++ Call(code_target, RelocInfo::CODE_TARGET); ++ } ++ ++ RestoreRegisters(registers); ++} ++ ++// Clobbers object, address, value, and ra, if (ra_status == kRAHasBeenSaved) ++// The register 'object' contains a heap object pointer. The heap object ++// tag is shifted away. ++void MacroAssembler::RecordWrite(Register object, Register address, ++ Register value, RAStatus ra_status, ++ SaveFPRegsMode fp_mode, ++ RememberedSetAction remembered_set_action, ++ SmiCheck smi_check) { ++ DCHECK(!AreAliased(object, address, value)); ++ ++ if (emit_debug_code()) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Ld_d(scratch, MemOperand(address, 0)); ++ Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, ++ Operand(value)); ++ } ++ ++ if ((remembered_set_action == OMIT_REMEMBERED_SET && ++ !FLAG_incremental_marking) || ++ FLAG_disable_write_barriers) { ++ return; ++ } ++ ++ // First, check if a write barrier is even needed. The tests below ++ // catch stores of smis and stores into the young generation. ++ Label done; ++ ++ if (smi_check == INLINE_SMI_CHECK) { ++ DCHECK_EQ(0, kSmiTag); ++ JumpIfSmi(value, &done); ++ } ++ ++ CheckPageFlag(value, ++ value, // Used as scratch. ++ MemoryChunk::kPointersToHereAreInterestingMask, eq, &done); ++ CheckPageFlag(object, ++ value, // Used as scratch. ++ MemoryChunk::kPointersFromHereAreInterestingMask, eq, &done); ++ ++ // Record the actual write. ++ if (ra_status == kRAHasNotBeenSaved) { ++ push(ra); ++ } ++ CallRecordWriteStub(object, address, remembered_set_action, fp_mode); ++ if (ra_status == kRAHasNotBeenSaved) { ++ pop(ra); ++ } ++ ++ bind(&done); ++ ++ // Clobber clobbered registers when running with the debug-code flag ++ // turned on to provoke errors. ++ if (emit_debug_code()) { ++ li(address, Operand(bit_cast(kZapValue + 12))); ++ li(value, Operand(bit_cast(kZapValue + 16))); ++ } ++} ++ ++// --------------------------------------------------------------------------- ++// Instruction macros. ++ ++void TurboAssembler::Add_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ add_w(rd, rj, rk.rm()); ++ } else { ++ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ addi_w(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ add_w(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Add_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ add_d(rd, rj, rk.rm()); ++ } else { ++ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ addi_d(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ add_d(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sub_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ sub_w(rd, rj, rk.rm()); ++ } else { ++ DCHECK(is_int32(rk.immediate())); ++ if (is_int12(-rk.immediate()) && !MustUseReg(rk.rmode())) { ++ addi_w(rd, rj, ++ static_cast( ++ -rk.immediate())); // No subi_w instr, use addi_w(x, y, -imm). ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ if (-rk.immediate() >> 12 == 0 && !MustUseReg(rk.rmode())) { ++ // Use load -imm and addu when loading -imm generates one instruction. ++ li(scratch, -rk.immediate()); ++ add_w(rd, rj, scratch); ++ } else { ++ // li handles the relocation. ++ li(scratch, rk); ++ sub_w(rd, rj, scratch); ++ } ++ } ++ } ++} ++ ++void TurboAssembler::Sub_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ sub_d(rd, rj, rk.rm()); ++ } else if (is_int12(-rk.immediate()) && !MustUseReg(rk.rmode())) { ++ addi_d(rd, rj, ++ static_cast( ++ -rk.immediate())); // No subi_d instr, use addi_d(x, y, -imm). ++ } else { ++ DCHECK(rj != t7); ++ int li_count = InstrCountForLi64Bit(rk.immediate()); ++ int li_neg_count = InstrCountForLi64Bit(-rk.immediate()); ++ if (li_neg_count < li_count && !MustUseReg(rk.rmode())) { ++ // Use load -imm and add_d when loading -imm generates one instruction. ++ DCHECK(rk.immediate() != std::numeric_limits::min()); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(-rk.immediate())); ++ add_d(rd, rj, scratch); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, rk); ++ sub_d(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Mul_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mul_w(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mul_w(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mulh_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mulh_w(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mulh_w(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mulh_wu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mulh_wu(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mulh_wu(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mul_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mul_d(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mul_d(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mulh_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mulh_d(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mulh_d(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Div_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ div_w(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ div_w(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mod_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mod_w(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mod_w(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mod_wu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mod_wu(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mod_wu(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Div_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ div_d(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ div_d(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Div_wu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ div_wu(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ div_wu(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Div_du(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ div_du(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ div_du(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mod_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mod_d(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mod_d(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Mod_du(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ mod_du(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ mod_du(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::And(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ and_(rd, rj, rk.rm()); ++ } else { ++ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ andi(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ and_(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Or(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ or_(rd, rj, rk.rm()); ++ } else { ++ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ ori(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ or_(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Xor(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ xor_(rd, rj, rk.rm()); ++ } else { ++ if (is_uint12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ xori(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ xor_(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Nor(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ nor(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ nor(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Andn(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ andn(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ andn(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Orn(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ orn(rd, rj, rk.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ orn(rd, rj, scratch); ++ } ++} ++ ++void TurboAssembler::Neg(Register rj, const Operand& rk) { ++ DCHECK(rk.is_reg()); ++ sub_d(rj, zero_reg, rk.rm()); ++} ++ ++void TurboAssembler::Slt(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ slt(rd, rj, rk.rm()); ++ } else { ++ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ slti(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ // TODO why?? ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ slt(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sltu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ sltu(rd, rj, rk.rm()); ++ } else { ++ if (is_int12(rk.immediate()) && !MustUseReg(rk.rmode())) { ++ sltui(rd, rj, static_cast(rk.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ sltu(rd, rj, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sle(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ slt(rd, rk.rm(), rj); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ slt(rd, scratch, rj); ++ } ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sleu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ sltu(rd, rk.rm(), rj); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ sltu(rd, scratch, rj); ++ } ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sge(Register rd, Register rj, const Operand& rk) { ++ Slt(rd, rj, rk); ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sgeu(Register rd, Register rj, const Operand& rk) { ++ Sltu(rd, rj, rk); ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sgt(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ slt(rd, rk.rm(), rj); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ slt(rd, scratch, rj); ++ } ++} ++ ++void TurboAssembler::Sgtu(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ sltu(rd, rk.rm(), rj); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rj != scratch); ++ li(scratch, rk); ++ sltu(rd, scratch, rj); ++ } ++} ++ ++void TurboAssembler::Rotr_w(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ rotr_w(rd, rj, rk.rm()); ++ } else { ++ int64_t ror_value = rk.immediate() % 32; ++ if (ror_value < 0) { ++ ror_value += 32; ++ } ++ rotri_w(rd, rj, ror_value); ++ } ++} ++ ++void TurboAssembler::Rotr_d(Register rd, Register rj, const Operand& rk) { ++ if (rk.is_reg()) { ++ rotr_d(rd, rj, rk.rm()); ++ } else { ++ int64_t dror_value = rk.immediate() % 64; ++ if (dror_value < 0) dror_value += 64; ++ rotri_d(rd, rj, dror_value); ++ } ++} ++ ++void MacroAssembler::Pref(int32_t hint, const MemOperand& rj) { ++ // TODO ++ // pref(hint); ++} ++ ++void TurboAssembler::Alsl_w(Register rd, Register rj, Register rk, uint8_t sa, ++ Register scratch) { ++ DCHECK(sa >= 1 && sa <= 31); ++ if (sa <= 4) { ++ alsl_w(rd, rj, rk, sa); ++ } else { ++ Register tmp = rd == rk ? scratch : rd; ++ DCHECK(tmp != rk); ++ slli_w(tmp, rj, sa); ++ add_w(rd, rk, tmp); ++ } ++} ++ ++void TurboAssembler::Alsl_d(Register rd, Register rj, Register rk, uint8_t sa, ++ Register scratch) { ++ DCHECK(sa >= 1 && sa <= 31); ++ if (sa <= 4) { ++ alsl_d(rd, rj, rk, sa); ++ } else { ++ Register tmp = rd == rk ? scratch : rd; ++ DCHECK(tmp != rk); ++ slli_d(tmp, rj, sa); ++ add_d(rd, rk, tmp); ++ } ++} ++ ++// ------------Pseudo-instructions------------- ++ ++// Change endianness ++void TurboAssembler::ByteSwapSigned(Register dest, Register src, ++ int operand_size) { ++ DCHECK(operand_size == 2 || operand_size == 4 || operand_size == 8); ++ if (operand_size == 2) { ++ revb_2h(dest, src); ++ ext_w_h(dest, dest); ++ } else if (operand_size == 4) { ++ revb_2w(dest, src); ++ slli_w(dest, dest, 0); ++ } else { ++ revb_d(dest, dest); ++ } ++} ++ ++void TurboAssembler::ByteSwapUnsigned(Register dest, Register src, ++ int operand_size) { ++ DCHECK(operand_size == 2 || operand_size == 4); ++ if (operand_size == 2) { ++ revb_2h(dest, src); ++ bstrins_d(dest, zero_reg, 63, 16); ++ } else { ++ revb_2w(dest, src); ++ bstrins_d(dest, zero_reg, 63, 32); ++ } ++} ++ ++void TurboAssembler::Ld_b(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_b(rd, source.base(), source.index()); ++ } else { ++ ld_b(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_bu(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_bu(rd, source.base(), source.index()); ++ } else { ++ ld_bu(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::St_b(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ stx_b(rd, source.base(), source.index()); ++ } else { ++ st_b(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_h(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_h(rd, source.base(), source.index()); ++ } else { ++ ld_h(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_hu(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_hu(rd, source.base(), source.index()); ++ } else { ++ ld_hu(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::St_h(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ stx_h(rd, source.base(), source.index()); ++ } else { ++ st_h(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_w(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); // TODO ldptr_w ?? ++ if (source.hasIndexReg()) { ++ ldx_w(rd, source.base(), source.index()); ++ } else { ++ ld_w(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_wu(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_wu(rd, source.base(), source.index()); ++ } else { ++ ld_wu(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::St_w(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ stx_w(rd, source.base(), source.index()); ++ } else { ++ st_w(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Ld_d(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ ldx_d(rd, source.base(), source.index()); ++ } else { ++ ld_d(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::St_d(Register rd, const MemOperand& rj) { ++ MemOperand source = rj; ++ AdjustBaseAndOffset(&source); ++ if (source.hasIndexReg()) { ++ stx_d(rd, source.base(), source.index()); ++ } else { ++ st_d(rd, source.base(), source.offset()); ++ } ++} ++ ++void TurboAssembler::Fld_s(FPURegister fd, const MemOperand& src) { ++ MemOperand tmp = src; ++ AdjustBaseAndOffset(&tmp); ++ if (tmp.hasIndexReg()) { ++ fldx_s(fd, tmp.base(), tmp.index()); ++ } else { ++ fld_s(fd, tmp.base(), tmp.offset()); ++ } ++} ++ ++void TurboAssembler::Fst_s(FPURegister fs, const MemOperand& src) { ++ MemOperand tmp = src; ++ AdjustBaseAndOffset(&tmp); ++ if (tmp.hasIndexReg()) { ++ fstx_s(fs, tmp.base(), tmp.index()); ++ } else { ++ fst_s(fs, tmp.base(), tmp.offset()); ++ } ++} ++ ++void TurboAssembler::Fld_d(FPURegister fd, const MemOperand& src) { ++ MemOperand tmp = src; ++ AdjustBaseAndOffset(&tmp); ++ if (tmp.hasIndexReg()) { ++ fldx_d(fd, tmp.base(), tmp.index()); ++ } else { ++ fld_d(fd, tmp.base(), tmp.offset()); ++ } ++} ++ ++void TurboAssembler::Fst_d(FPURegister fs, const MemOperand& src) { ++ MemOperand tmp = src; ++ AdjustBaseAndOffset(&tmp); ++ if (tmp.hasIndexReg()) { ++ fstx_d(fs, tmp.base(), tmp.index()); ++ } else { ++ fst_d(fs, tmp.base(), tmp.offset()); ++ } ++} ++ ++void TurboAssembler::Ll_w(Register rd, const MemOperand& rj) { ++ DCHECK(!rj.hasIndexReg()); ++ bool is_one_instruction = is_int14(rj.offset()); ++ if (is_one_instruction) { ++ ll_w(rd, rj.base(), rj.offset()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, rj.offset()); ++ add_d(scratch, scratch, rj.base()); ++ ll_w(rd, scratch, 0); ++ } ++} ++ ++void TurboAssembler::Ll_d(Register rd, const MemOperand& rj) { ++ DCHECK(!rj.hasIndexReg()); ++ bool is_one_instruction = is_int14(rj.offset()); ++ if (is_one_instruction) { ++ ll_d(rd, rj.base(), rj.offset()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, rj.offset()); ++ add_d(scratch, scratch, rj.base()); ++ ll_d(rd, scratch, 0); ++ } ++} ++ ++void TurboAssembler::Sc_w(Register rd, const MemOperand& rj) { ++ DCHECK(!rj.hasIndexReg()); ++ bool is_one_instruction = is_int14(rj.offset()); ++ if (is_one_instruction) { ++ sc_w(rd, rj.base(), rj.offset()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, rj.offset()); ++ add_d(scratch, scratch, rj.base()); ++ sc_w(rd, scratch, 0); ++ } ++} ++ ++void TurboAssembler::Sc_d(Register rd, const MemOperand& rj) { ++ DCHECK(!rj.hasIndexReg()); ++ bool is_one_instruction = is_int14(rj.offset()); ++ if (is_one_instruction) { ++ sc_d(rd, rj.base(), rj.offset()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, rj.offset()); ++ add_d(scratch, scratch, rj.base()); ++ sc_d(rd, scratch, 0); ++ } ++} ++ ++void TurboAssembler::li(Register dst, Handle value, LiFlags mode) { ++ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating ++ // non-isolate-independent code. In many cases it might be cheaper than ++ // embedding the relocatable value. ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(dst, value); ++ return; ++ } ++ li(dst, Operand(value), mode); ++} ++ ++void TurboAssembler::li(Register dst, ExternalReference value, LiFlags mode) { ++ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating ++ // non-isolate-independent code. In many cases it might be cheaper than ++ // embedding the relocatable value. ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadExternalReference(dst, value); ++ return; ++ } ++ li(dst, Operand(value), mode); ++} ++ ++void TurboAssembler::li(Register dst, const StringConstantBase* string, ++ LiFlags mode) { ++ li(dst, Operand::EmbeddedStringConstant(string), mode); ++} ++ ++static inline int InstrCountForLiLower32Bit(int64_t value) { ++ if (is_int12(static_cast(value)) || ++ is_uint12(static_cast(value)) || !(value & kImm12Mask)) { ++ return 1; ++ } else { ++ return 2; ++ } ++} ++ ++void TurboAssembler::LiLower32BitHelper(Register rd, Operand j) { ++ if (is_int12(static_cast(j.immediate()))) { ++ addi_d(rd, zero_reg, j.immediate()); ++ } else if (is_uint12(static_cast(j.immediate()))) { ++ ori(rd, zero_reg, j.immediate() & kImm12Mask); ++ } else { ++ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); ++ if (j.immediate() & kImm12Mask) { ++ ori(rd, rd, j.immediate() & kImm12Mask); ++ } ++ } ++} ++ ++int TurboAssembler::InstrCountForLi64Bit(int64_t value) { ++ if (is_int32(value)) { ++ return InstrCountForLiLower32Bit(value); ++ } else if (is_int52(value)) { ++ return InstrCountForLiLower32Bit(value) + 1; ++ } else if ((value & 0xffffffffL) == 0) { ++ // 32 LSBs (Least Significant Bits) all set to zero. ++ uint8_t tzc = base::bits::CountTrailingZeros32(value >> 32); ++ uint8_t lzc = base::bits::CountLeadingZeros32(value >> 32); ++ if (tzc >= 20) { ++ return 1; ++ } else if (tzc + lzc > 12) { ++ return 2; ++ } else { ++ return 3; ++ } ++ } else { ++ int64_t imm21 = (value >> 31) & 0x1fffffL; ++ if (imm21 != 0x1fffffL && imm21 != 0) { ++ return InstrCountForLiLower32Bit(value) + 2; ++ } else { ++ return InstrCountForLiLower32Bit(value) + 1; ++ } ++ } ++ UNREACHABLE(); ++ return INT_MAX; ++} ++ ++// All changes to if...else conditions here must be added to ++// InstrCountForLi64Bit as well. ++void TurboAssembler::li_optimized(Register rd, Operand j, LiFlags mode) { ++ DCHECK(!j.is_reg()); ++ DCHECK(!MustUseReg(j.rmode())); ++ DCHECK(mode == OPTIMIZE_SIZE); ++ int64_t imm = j.immediate(); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Normal load of an immediate value which does not need Relocation Info. ++ if (is_int32(imm)) { ++ LiLower32BitHelper(rd, j); ++ } else if (is_int52(imm)) { ++ LiLower32BitHelper(rd, j); ++ lu32i_d(rd, imm >> 32 & 0xfffff); ++ } else if ((imm & 0xffffffffL) == 0) { ++ // 32 LSBs (Least Significant Bits) all set to zero. ++ uint8_t tzc = base::bits::CountTrailingZeros32(imm >> 32); ++ uint8_t lzc = base::bits::CountLeadingZeros32(imm >> 32); ++ if (tzc >= 20) { ++ lu52i_d(rd, zero_reg, imm >> 52 & kImm12Mask); ++ } else if (tzc + lzc > 12) { ++ int32_t mask = (1 << (32 - tzc)) - 1; ++ lu12i_w(rd, imm >> (tzc + 32) & mask); ++ slli_d(rd, rd, tzc + 20); ++ } else { ++ xor_(rd, rd, rd); ++ lu32i_d(rd, imm >> 32 & 0xfffff); ++ lu52i_d(rd, rd, imm >> 52 & kImm12Mask); ++ } ++ } else { ++ int64_t imm21 = (imm >> 31) & 0x1fffffL; ++ LiLower32BitHelper(rd, j); ++ if (imm21 != 0x1fffffL && imm21 != 0) lu32i_d(rd, imm >> 32 & 0xfffff); ++ lu52i_d(rd, rd, imm >> 52 & kImm12Mask); ++ } ++} ++ ++void TurboAssembler::li(Register rd, Operand j, LiFlags mode) { ++ DCHECK(!j.is_reg()); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (!MustUseReg(j.rmode()) && mode == OPTIMIZE_SIZE) { ++ li_optimized(rd, j, mode); ++ } else if (MustUseReg(j.rmode())) { ++ int64_t immediate; ++ if (j.IsHeapObjectRequest()) { ++ RequestHeapObject(j.heap_object_request()); ++ immediate = 0; ++ } else { ++ immediate = j.immediate(); ++ } ++ ++ RecordRelocInfo(j.rmode(), immediate); ++ lu12i_w(rd, immediate >> 12 & 0xfffff); ++ ori(rd, rd, immediate & kImm12Mask); ++ lu32i_d(rd, immediate >> 32 & 0xfffff); ++ } else if (mode == ADDRESS_LOAD) { ++ // We always need the same number of instructions as we may need to patch ++ // this code to load another value which may need all 3 instructions. ++ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); ++ ori(rd, rd, j.immediate() & kImm12Mask); ++ lu32i_d(rd, j.immediate() >> 32 & 0xfffff); ++ } else { // mode == CONSTANT_SIZE - always emit the same instruction ++ // sequence. ++ lu12i_w(rd, j.immediate() >> 12 & 0xfffff); ++ ori(rd, rd, j.immediate() & kImm12Mask); ++ lu32i_d(rd, j.immediate() >> 32 & 0xfffff); ++ lu52i_d(rd, rd, j.immediate() >> 52 & kImm12Mask); ++ } ++} ++ ++void TurboAssembler::MultiPush(RegList regs) { ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPush(RegList regs1, RegList regs2) { ++ DCHECK_EQ(regs1 & regs2, 0); ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs1 & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs2 & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPush(RegList regs1, RegList regs2, RegList regs3) { ++ DCHECK_EQ(regs1 & regs2, 0); ++ DCHECK_EQ(regs1 & regs3, 0); ++ DCHECK_EQ(regs2 & regs3, 0); ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs1 & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs2 & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs3 & (1 << i)) != 0) { ++ stack_offset -= kPointerSize; ++ St_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPop(RegList regs) { ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPop(RegList regs1, RegList regs2) { ++ DCHECK_EQ(regs1 & regs2, 0); ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs2 & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs1 & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPop(RegList regs1, RegList regs2, RegList regs3) { ++ DCHECK_EQ(regs1 & regs2, 0); ++ DCHECK_EQ(regs1 & regs3, 0); ++ DCHECK_EQ(regs2 & regs3, 0); ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs3 & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs2 & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs1 & (1 << i)) != 0) { ++ Ld_d(ToRegister(i), MemOperand(sp, stack_offset)); ++ stack_offset += kPointerSize; ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::MultiPushFPU(RegList regs) { ++ int16_t num_to_push = base::bits::CountPopulation(regs); ++ int16_t stack_offset = num_to_push * kDoubleSize; ++ ++ Sub_d(sp, sp, Operand(stack_offset)); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs & (1 << i)) != 0) { ++ stack_offset -= kDoubleSize; ++ Fst_d(FPURegister::from_code(i), MemOperand(sp, stack_offset)); ++ } ++ } ++} ++ ++void TurboAssembler::MultiPopFPU(RegList regs) { ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs & (1 << i)) != 0) { ++ Fld_d(FPURegister::from_code(i), MemOperand(sp, stack_offset)); ++ stack_offset += kDoubleSize; ++ } ++ } ++ addi_d(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::Bstrpick_w(Register rk, Register rj, uint16_t msbw, ++ uint16_t lsbw) { ++ DCHECK_LT(lsbw, msbw); ++ DCHECK_LT(lsbw, 32); ++ DCHECK_LT(msbw, 32); ++ bstrpick_w(rk, rj, msbw, lsbw); ++} ++ ++void TurboAssembler::Bstrpick_d(Register rk, Register rj, uint16_t msbw, ++ uint16_t lsbw) { ++ DCHECK_LT(lsbw, msbw); ++ DCHECK_LT(lsbw, 64); ++ DCHECK_LT(msbw, 64); ++ bstrpick_d(rk, rj, msbw, lsbw); ++} ++ ++void TurboAssembler::Neg_s(FPURegister fd, FPURegister fj) { fneg_s(fd, fj); } ++ ++void TurboAssembler::Neg_d(FPURegister fd, FPURegister fj) { fneg_d(fd, fj); } ++ ++void TurboAssembler::Ffint_d_uw(FPURegister fd, FPURegister fj) { ++ // Move the data from fs to t8. ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ movfr2gr_s(t8, fj); ++ Ffint_d_uw(fd, t8); ++} ++ ++void TurboAssembler::Ffint_d_uw(FPURegister fd, Register rj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ ++ // Convert rj to a FP value in fd. ++ DCHECK(rj != t7); ++ ++ // Zero extend int32 in rj. ++ Bstrpick_d(t7, rj, 31, 0); ++ movgr2fr_d(fd, t7); ++ ffint_d_l(fd, fd); ++} ++ ++void TurboAssembler::Ffint_d_ul(FPURegister fd, FPURegister fj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Move the data from fs to t8. ++ movfr2gr_d(t8, fj); ++ Ffint_d_ul(fd, t8); ++} ++ ++void TurboAssembler::Ffint_d_ul(FPURegister fd, Register rj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Convert rj to a FP value in fd. ++ ++ DCHECK(rj != t7); ++ ++ Label msb_clear, conversion_done; ++ ++ Branch(&msb_clear, ge, rj, Operand(zero_reg)); ++ ++ // Rj >= 2^63 ++ andi(t7, rj, 1); ++ srli_d(rj, rj, 1); ++ or_(t7, t7, rj); ++ movgr2fr_d(fd, t7); ++ ffint_d_l(fd, fd); ++ fadd_d(fd, fd, fd); ++ Branch(&conversion_done); ++ ++ bind(&msb_clear); ++ // Rs < 2^63, we can do simple conversion. ++ movgr2fr_d(fd, rj); ++ ffint_d_l(fd, fd); ++ ++ bind(&conversion_done); ++} ++ ++void TurboAssembler::Ffint_s_uw(FPURegister fd, FPURegister fj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Move the data from fs to t8. ++ movfr2gr_d(t8, fj); ++ Ffint_s_uw(fd, t8); ++} ++ ++void TurboAssembler::Ffint_s_uw(FPURegister fd, Register rj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Convert rj to a FP value in fd. ++ DCHECK(rj != t7); ++ ++ // Zero extend int32 in rj. ++ bstrpick_d(t7, rj, 31, 0); ++ movgr2fr_d(fd, t7); ++ ffint_s_l(fd, fd); ++} ++ ++void TurboAssembler::Ffint_s_ul(FPURegister fd, FPURegister fj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Move the data from fs to t8. ++ movfr2gr_d(t8, fj); ++ Ffint_s_ul(fd, t8); ++} ++ ++void TurboAssembler::Ffint_s_ul(FPURegister fd, Register rj) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Convert rj to a FP value in fd. ++ ++ DCHECK(rj != t7); ++ ++ Label positive, conversion_done; ++ ++ Branch(&positive, ge, rj, Operand(zero_reg)); ++ ++ // Rs >= 2^31. ++ andi(t7, rj, 1); ++ srli_d(rj, rj, 1); ++ or_(t7, t7, rj); ++ movgr2fr_d(fd, t7); ++ ffint_s_l(fd, fd); ++ fadd_s(fd, fd, fd); ++ Branch(&conversion_done); ++ ++ bind(&positive); ++ // Rs < 2^31, we can do simple conversion. ++ movgr2fr_d(fd, rj); ++ ffint_s_l(fd, fd); ++ ++ bind(&conversion_done); ++} ++ ++void MacroAssembler::Ftintrne_l_d(FPURegister fd, FPURegister fj) { ++ ftintrne_l_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrm_l_d(FPURegister fd, FPURegister fj) { ++ ftintrm_l_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrp_l_d(FPURegister fd, FPURegister fj) { ++ ftintrp_l_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrz_l_d(FPURegister fd, FPURegister fj) { ++ ftintrz_l_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrz_l_ud(FPURegister fd, FPURegister fj, ++ FPURegister scratch) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Load to GPR. ++ movfr2gr_d(t8, fj); ++ // Reset sign bit. ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ li(scratch1, 0x7FFFFFFFFFFFFFFFl); ++ and_(t8, t8, scratch1); ++ } ++ movgr2fr_d(scratch, t8); ++ Ftintrz_l_d(fd, scratch); ++} ++ ++void TurboAssembler::Ftintrz_uw_d(FPURegister fd, FPURegister fj, ++ FPURegister scratch) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Ftintrz_uw_d(t8, fj, scratch); ++ movgr2fr_w(fd, t8); ++} ++ ++void TurboAssembler::Ftintrz_uw_s(FPURegister fd, FPURegister fj, ++ FPURegister scratch) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Ftintrz_uw_s(t8, fj, scratch); ++ movgr2fr_w(fd, t8); ++} ++ ++void TurboAssembler::Ftintrz_ul_d(FPURegister fd, FPURegister fj, ++ FPURegister scratch, Register result) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Ftintrz_ul_d(t8, fj, scratch, result); ++ movgr2fr_d(fd, t8); ++} ++ ++void TurboAssembler::Ftintrz_ul_s(FPURegister fd, FPURegister fj, ++ FPURegister scratch, Register result) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Ftintrz_ul_s(t8, fj, scratch, result); ++ movgr2fr_d(fd, t8); ++} ++ ++void MacroAssembler::Ftintrz_w_d(FPURegister fd, FPURegister fj) { ++ ftintrz_w_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrne_w_d(FPURegister fd, FPURegister fj) { ++ ftintrne_w_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrm_w_d(FPURegister fd, FPURegister fj) { ++ ftintrm_w_d(fd, fj); ++} ++ ++void MacroAssembler::Ftintrp_w_d(FPURegister fd, FPURegister fj) { ++ ftintrp_w_d(fd, fj); ++} ++ ++void TurboAssembler::Ftintrz_uw_d(Register rd, FPURegister fj, ++ FPURegister scratch) { ++ DCHECK(fj != scratch); ++ DCHECK(rd != t7); ++ ++ { ++ // Load 2^31 into scratch as its float representation. ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ li(scratch1, 0x41E00000); ++ movgr2fr_w(scratch, zero_reg); ++ movgr2frh_w(scratch, scratch1); ++ } ++ // Test if scratch > fd. ++ // If fd < 2^31 we can convert it normally. ++ Label simple_convert; ++ CompareF64(fj, scratch, CLT); ++ BranchTrueShortF(&simple_convert); ++ ++ // First we subtract 2^31 from fd, then trunc it to rs ++ // and add 2^31 to rj. ++ fsub_d(scratch, fj, scratch); ++ ftintrz_w_d(scratch, scratch); ++ movfr2gr_s(rd, scratch); ++ Or(rd, rd, 1 << 31); ++ ++ Label done; ++ Branch(&done); ++ // Simple conversion. ++ bind(&simple_convert); ++ ftintrz_w_d(scratch, fj); ++ movfr2gr_s(rd, scratch); ++ ++ bind(&done); ++} ++ ++void TurboAssembler::Ftintrz_uw_s(Register rd, FPURegister fj, ++ FPURegister scratch) { ++ DCHECK(fj != scratch); ++ DCHECK(rd != t7); ++ { ++ // Load 2^31 into scratch as its float representation. ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ li(scratch1, 0x4F000000); ++ movgr2fr_w(scratch, scratch1); ++ } ++ // Test if scratch > fs. ++ // If fs < 2^31 we can convert it normally. ++ Label simple_convert; ++ CompareF32(fj, scratch, CLT); ++ BranchTrueShortF(&simple_convert); ++ ++ // First we subtract 2^31 from fs, then trunc it to rd ++ // and add 2^31 to rd. ++ fsub_s(scratch, fj, scratch); ++ ftintrz_w_s(scratch, scratch); ++ movfr2gr_s(rd, scratch); ++ Or(rd, rd, 1 << 31); ++ ++ Label done; ++ Branch(&done); ++ // Simple conversion. ++ bind(&simple_convert); ++ ftintrz_w_s(scratch, fj); ++ movfr2gr_s(rd, scratch); ++ ++ bind(&done); ++} ++ ++void TurboAssembler::Ftintrz_ul_d(Register rd, FPURegister fj, ++ FPURegister scratch, Register result) { ++ DCHECK(fj != scratch); ++ DCHECK(result.is_valid() ? !AreAliased(rd, result, t7) : !AreAliased(rd, t7)); ++ ++ Label simple_convert, done, fail; ++ if (result.is_valid()) { ++ mov(result, zero_reg); ++ Move(scratch, -1.0); ++ // If fd =< -1 or unordered, then the conversion fails. ++ CompareF64(fj, scratch, CLE); ++ BranchTrueShortF(&fail); ++ CompareIsNanF64(fj, scratch); ++ BranchTrueShortF(&fail); ++ } ++ ++ // Load 2^63 into scratch as its double representation. ++ li(t7, 0x43E0000000000000); ++ movgr2fr_d(scratch, t7); ++ ++ // Test if scratch > fs. ++ // If fs < 2^63 we can convert it normally. ++ CompareF64(fj, scratch, CLT); ++ BranchTrueShortF(&simple_convert); ++ ++ // First we subtract 2^63 from fs, then trunc it to rd ++ // and add 2^63 to rd. ++ fsub_d(scratch, fj, scratch); ++ ftintrz_l_d(scratch, scratch); ++ movfr2gr_d(rd, scratch); ++ Or(rd, rd, Operand(1UL << 63)); ++ Branch(&done); ++ ++ // Simple conversion. ++ bind(&simple_convert); ++ ftintrz_l_d(scratch, fj); ++ movfr2gr_d(rd, scratch); ++ ++ bind(&done); ++ if (result.is_valid()) { ++ // Conversion is failed if the result is negative. ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ addi_d(scratch1, zero_reg, -1); ++ srli_d(scratch1, scratch1, 1); // Load 2^62. ++ movfr2gr_d(result, scratch); ++ xor_(result, result, scratch1); ++ } ++ Slt(result, zero_reg, result); ++ } ++ ++ bind(&fail); ++} ++ ++void TurboAssembler::Ftintrz_ul_s(Register rd, FPURegister fj, ++ FPURegister scratch, Register result) { ++ DCHECK(fj != scratch); ++ DCHECK(result.is_valid() ? !AreAliased(rd, result, t7) : !AreAliased(rd, t7)); ++ ++ Label simple_convert, done, fail; ++ if (result.is_valid()) { ++ mov(result, zero_reg); ++ Move(scratch, -1.0f); ++ // If fd =< -1 or unordered, then the conversion fails. ++ CompareF32(fj, scratch, CLE); ++ BranchTrueShortF(&fail); ++ CompareIsNanF32(fj, scratch); ++ BranchTrueShortF(&fail); ++ } ++ ++ { ++ // Load 2^63 into scratch as its float representation. ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ li(scratch1, 0x5F000000); ++ movgr2fr_w(scratch, scratch1); ++ } ++ ++ // Test if scratch > fs. ++ // If fs < 2^63 we can convert it normally. ++ CompareF32(fj, scratch, CLT); ++ BranchTrueShortF(&simple_convert); ++ ++ // First we subtract 2^63 from fs, then trunc it to rd ++ // and add 2^63 to rd. ++ fsub_s(scratch, fj, scratch); ++ ftintrz_l_s(scratch, scratch); ++ movfr2gr_d(rd, scratch); ++ Or(rd, rd, Operand(1UL << 63)); ++ Branch(&done); ++ ++ // Simple conversion. ++ bind(&simple_convert); ++ ftintrz_l_s(scratch, fj); ++ movfr2gr_d(rd, scratch); ++ ++ bind(&done); ++ if (result.is_valid()) { ++ // Conversion is failed if the result is negative or unordered. ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch1 = temps.Acquire(); ++ addi_d(scratch1, zero_reg, -1); ++ srli_d(scratch1, scratch1, 1); // Load 2^62. ++ movfr2gr_d(result, scratch); ++ xor_(result, result, scratch1); ++ } ++ Slt(result, zero_reg, result); ++ } ++ ++ bind(&fail); ++} ++ ++void TurboAssembler::RoundDouble(FPURegister dst, FPURegister src, ++ FPURoundingMode mode) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = t8; ++ movfcsr2gr(scratch); ++ li(t7, Operand(mode)); ++ movgr2fcsr(t7); ++ frint_d(dst, src); ++ movgr2fcsr(scratch); ++} ++ ++void TurboAssembler::Floor_d(FPURegister dst, FPURegister src) { ++ RoundDouble(dst, src, mode_floor); ++} ++ ++void TurboAssembler::Ceil_d(FPURegister dst, FPURegister src) { ++ RoundDouble(dst, src, mode_ceil); ++} ++ ++void TurboAssembler::Trunc_d(FPURegister dst, FPURegister src) { ++ RoundDouble(dst, src, mode_trunc); ++} ++ ++void TurboAssembler::Round_d(FPURegister dst, FPURegister src) { ++ RoundDouble(dst, src, mode_round); ++} ++ ++void TurboAssembler::RoundFloat(FPURegister dst, FPURegister src, ++ FPURoundingMode mode) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = t8; ++ movfcsr2gr(scratch); ++ li(t7, Operand(mode)); ++ movgr2fcsr(t7); ++ frint_s(dst, src); ++ movgr2fcsr(scratch); ++} ++ ++void TurboAssembler::Floor_s(FPURegister dst, FPURegister src) { ++ RoundFloat(dst, src, mode_floor); ++} ++ ++void TurboAssembler::Ceil_s(FPURegister dst, FPURegister src) { ++ RoundFloat(dst, src, mode_ceil); ++} ++ ++void TurboAssembler::Trunc_s(FPURegister dst, FPURegister src) { ++ RoundFloat(dst, src, mode_trunc); ++} ++ ++void TurboAssembler::Round_s(FPURegister dst, FPURegister src) { ++ RoundFloat(dst, src, mode_round); ++} ++ ++void TurboAssembler::CompareF(FPURegister cmp1, FPURegister cmp2, ++ FPUCondition cc, CFRegister cd, bool f32) { ++ if (f32) { ++ fcmp_cond_s(cc, cmp1, cmp2, cd); ++ } else { ++ fcmp_cond_d(cc, cmp1, cmp2, cd); ++ } ++} ++ ++void TurboAssembler::CompareIsNanF(FPURegister cmp1, FPURegister cmp2, ++ CFRegister cd, bool f32) { ++ CompareF(cmp1, cmp2, CUN, cd, f32); ++} ++ ++void TurboAssembler::BranchTrueShortF(Label* target, CFRegister cj) { ++ bcnez(cj, target); ++} ++ ++void TurboAssembler::BranchFalseShortF(Label* target, CFRegister cj) { ++ bceqz(cj, target); ++} ++ ++void TurboAssembler::BranchTrueF(Label* target, CFRegister cj) { ++ // TODO can be optimzed ++ bool long_branch = target->is_bound() ++ ? !is_near(target, OffsetSize::kOffset21) ++ : is_trampoline_emitted(); ++ if (long_branch) { ++ Label skip; ++ BranchFalseShortF(&skip, cj); ++ Branch(target); ++ bind(&skip); ++ } else { ++ BranchTrueShortF(target, cj); ++ } ++} ++ ++void TurboAssembler::BranchFalseF(Label* target, CFRegister cj) { ++ bool long_branch = target->is_bound() ++ ? !is_near(target, OffsetSize::kOffset21) ++ : is_trampoline_emitted(); ++ if (long_branch) { ++ Label skip; ++ BranchTrueShortF(&skip, cj); ++ Branch(target); ++ bind(&skip); ++ } else { ++ BranchFalseShortF(target, cj); ++ } ++} ++ ++void TurboAssembler::FmoveLow(FPURegister dst, Register src_low) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(src_low != scratch); ++ movfrh2gr_s(scratch, dst); ++ movgr2fr_w(dst, src_low); ++ movgr2frh_w(dst, scratch); ++} ++ ++void TurboAssembler::Move(FPURegister dst, uint32_t src) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(static_cast(src))); ++ movgr2fr_w(dst, scratch); ++} ++ ++void TurboAssembler::Move(FPURegister dst, uint64_t src) { ++ // Handle special values first. ++ if (src == bit_cast(0.0) && has_double_zero_reg_set_) { ++ fmov_d(dst, kDoubleRegZero); ++ } else if (src == bit_cast(-0.0) && has_double_zero_reg_set_) { ++ Neg_d(dst, kDoubleRegZero); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(static_cast(src))); ++ movgr2fr_d(dst, scratch); ++ if (dst == kDoubleRegZero) has_double_zero_reg_set_ = true; ++ } ++} ++ ++void TurboAssembler::Movz(Register rd, Register rj, Register rk) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ maskeqz(scratch, rj, rk); ++ masknez(rd, rd, rk); ++ or_(rd, rd, scratch); ++} ++ ++void TurboAssembler::Movn(Register rd, Register rj, Register rk) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ masknez(scratch, rj, rk); ++ maskeqz(rd, rd, rk); ++ or_(rd, rd, scratch); ++} ++ ++void TurboAssembler::LoadZeroOnCondition(Register rd, Register rj, ++ const Operand& rk, Condition cond) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ switch (cond) { ++ case cc_always: ++ mov(rd, zero_reg); ++ break; ++ case eq: ++ if (rj == zero_reg) { ++ if (rk.is_reg()) { ++ LoadZeroIfConditionZero(rd, rk.rm()); ++ } else { ++ if (rk.immediate() == 0) { ++ mov(rd, zero_reg); ++ } else { ++ // nop(); ++ } ++ } ++ } else if (IsZero(rk)) { ++ LoadZeroIfConditionZero(rd, rj); ++ } else { ++ Sub_d(t7, rj, rk); ++ LoadZeroIfConditionZero(rd, t7); ++ } ++ break; ++ case ne: ++ if (rj == zero_reg) { ++ if (rk.is_reg()) { ++ LoadZeroIfConditionNotZero(rd, rk.rm()); ++ } else { ++ if (rk.immediate() != 0) { ++ mov(rd, zero_reg); ++ } else { ++ // nop(); ++ } ++ } ++ } else if (IsZero(rk)) { ++ LoadZeroIfConditionNotZero(rd, rj); ++ } else { ++ Sub_d(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ } ++ break; ++ ++ // Signed comparison. ++ case greater: ++ Sgt(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ break; ++ case greater_equal: ++ Sge(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj >= rk ++ break; ++ case less: ++ Slt(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj < rk ++ break; ++ case less_equal: ++ Sle(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj <= rk ++ break; ++ ++ // Unsigned comparison. ++ case Ugreater: ++ Sgtu(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj > rk ++ break; ++ ++ case Ugreater_equal: ++ Sgeu(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj >= rk ++ break; ++ case Uless: ++ Sltu(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj < rk ++ break; ++ case Uless_equal: ++ Sleu(t7, rj, rk); ++ LoadZeroIfConditionNotZero(rd, t7); ++ // rj <= rk ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void TurboAssembler::LoadZeroIfConditionNotZero(Register dest, ++ Register condition) { ++ maskeqz(dest, dest, condition); ++} ++ ++void TurboAssembler::LoadZeroIfConditionZero(Register dest, ++ Register condition) { ++ masknez(dest, dest, condition); ++} ++ ++void TurboAssembler::LoadZeroIfFPUCondition(Register dest, CFRegister cc) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ movcf2gr(scratch, cc); ++ LoadZeroIfConditionNotZero(dest, scratch); ++} ++ ++void TurboAssembler::LoadZeroIfNotFPUCondition(Register dest, CFRegister cc) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ movcf2gr(scratch, cc); ++ LoadZeroIfConditionZero(dest, scratch); ++} ++ ++void TurboAssembler::Clz_w(Register rd, Register rj) { clz_w(rd, rj); } ++ ++void TurboAssembler::Clz_d(Register rd, Register rj) { clz_d(rd, rj); } ++ ++void TurboAssembler::Ctz_w(Register rd, Register rj) { ctz_w(rd, rj); } ++ ++void TurboAssembler::Ctz_d(Register rd, Register rj) { ctz_d(rd, rj); } ++ ++// TODO: Optimize like arm64, use simd instruction ++void TurboAssembler::Popcnt_w(Register rd, Register rj) { ++ // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel ++ // ++ // A generalization of the best bit counting method to integers of ++ // bit-widths up to 128 (parameterized by type T) is this: ++ // ++ // v = v - ((v >> 1) & (T)~(T)0/3); // temp ++ // v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); // temp ++ // v = (v + (v >> 4)) & (T)~(T)0/255*15; // temp ++ // c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * BITS_PER_BYTE; //count ++ // ++ // For comparison, for 32-bit quantities, this algorithm can be executed ++ // using 20 MIPS instructions (the calls to LoadConst32() generate two ++ // machine instructions each for the values being used in this algorithm). ++ // A(n unrolled) loop-based algorithm requires 25 instructions. ++ // ++ // For a 64-bit operand this can be performed in 24 instructions compared ++ // to a(n unrolled) loop based algorithm which requires 38 instructions. ++ // ++ // There are algorithms which are faster in the cases where very few ++ // bits are set but the algorithm here attempts to minimize the total ++ // number of instructions executed even when a large number of bits ++ // are set. ++ int32_t B0 = 0x55555555; // (T)~(T)0/3 ++ int32_t B1 = 0x33333333; // (T)~(T)0/15*3 ++ int32_t B2 = 0x0F0F0F0F; // (T)~(T)0/255*15 ++ int32_t value = 0x01010101; // (T)~(T)0/255 ++ uint32_t shift = 24; // (sizeof(T) - 1) * BITS_PER_BYTE ++ ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.Acquire(); ++ Register scratch2 = t8; ++ srli_w(scratch, rj, 1); ++ li(scratch2, B0); ++ And(scratch, scratch, scratch2); ++ Sub_w(scratch, rj, scratch); ++ li(scratch2, B1); ++ And(rd, scratch, scratch2); ++ srli_w(scratch, scratch, 2); ++ And(scratch, scratch, scratch2); ++ Add_w(scratch, rd, scratch); ++ srli_w(rd, scratch, 4); ++ Add_w(rd, rd, scratch); ++ li(scratch2, B2); ++ And(rd, rd, scratch2); ++ li(scratch, value); ++ Mul_w(rd, rd, scratch); ++ srli_w(rd, rd, shift); ++} ++ ++void TurboAssembler::Popcnt_d(Register rd, Register rj) { ++ int64_t B0 = 0x5555555555555555l; // (T)~(T)0/3 ++ int64_t B1 = 0x3333333333333333l; // (T)~(T)0/15*3 ++ int64_t B2 = 0x0F0F0F0F0F0F0F0Fl; // (T)~(T)0/255*15 ++ int64_t value = 0x0101010101010101l; // (T)~(T)0/255 ++ uint32_t shift = 56; // (sizeof(T) - 1) * BITS_PER_BYTE ++ ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.Acquire(); ++ Register scratch2 = t8; ++ srli_d(scratch, rj, 1); ++ li(scratch2, B0); ++ And(scratch, scratch, scratch2); ++ Sub_d(scratch, rj, scratch); ++ li(scratch2, B1); ++ And(rd, scratch, scratch2); ++ srli_d(scratch, scratch, 2); ++ And(scratch, scratch, scratch2); ++ Add_d(scratch, rd, scratch); ++ srli_d(rd, scratch, 4); ++ Add_d(rd, rd, scratch); ++ li(scratch2, B2); ++ And(rd, rd, scratch2); ++ li(scratch, value); ++ Mul_d(rd, rd, scratch); ++ srli_d(rd, rd, shift); ++} ++ ++void TurboAssembler::ExtractBits(Register dest, Register source, Register pos, ++ int size, bool sign_extend) { ++ sra_d(dest, source, pos); ++ bstrpick_d(dest, dest, size - 1, 0); ++ if (sign_extend) { ++ switch (size) { ++ case 8: ++ ext_w_b(dest, dest); ++ break; ++ case 16: ++ ext_w_h(dest, dest); ++ break; ++ case 32: ++ // sign-extend word ++ slli_w(dest, dest, 0); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++void TurboAssembler::InsertBits(Register dest, Register source, Register pos, ++ int size) { ++ Rotr_d(dest, dest, pos); ++ bstrins_d(dest, source, size - 1, 0); ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Sub_d(scratch, zero_reg, pos); ++ Rotr_d(dest, dest, scratch); ++ } ++} ++ ++void MacroAssembler::EmitFPUTruncate( ++ FPURoundingMode rounding_mode, Register result, DoubleRegister double_input, ++ Register scratch, DoubleRegister double_scratch, Register except_flag, ++ CheckForInexactConversion check_inexact) { ++ break_(3); ++} ++ ++void TurboAssembler::TryInlineTruncateDoubleToI(Register result, ++ DoubleRegister double_input, ++ Label* done) { ++ DoubleRegister single_scratch = kScratchDoubleReg.low(); ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.Acquire(); ++ Register scratch2 = t7; ++ ++ // Clear cumulative exception flags and save the FCSR. ++ /* movfcsr2gr(scratch2, FCSR); ++ movgr2fcsr(FCSR, zero_reg); ++ // Try a conversion to a signed integer. ++ ftintrz_w_d(single_scratch, double_input); ++ movfr2gr_w(result, single_scratch); ++ // Retrieve and restore the FCSR. ++ movfcsr2gr(scratch, FCSR); ++ movgr2fcsr(FCSR, scratch2); ++ // Check for overflow and NaNs. ++ And(scratch, scratch, ++ kFCSROverflowFlagMask | kFCSRUnderflowFlagMask | ++ kFCSRInvalidOpFlagMask); ++ // If we had no exceptions we are done. ++ Branch(done, eq, scratch, Operand(zero_reg));*/ ++ ++ CompareIsNanF64(double_input, double_input); ++ Move(result, zero_reg); ++ bcnez(FCC0, done); ++ ftintrz_l_d(single_scratch, double_input); ++ movfr2gr_d(scratch2, single_scratch); ++ li(scratch, 1L << 63); ++ Xor(scratch, scratch, scratch2); ++ rotri_d(scratch2, scratch, 1); ++ movfr2gr_s(result, single_scratch); ++ Branch(done, ne, scratch, Operand(scratch2)); ++} ++ ++void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone, ++ Register result, ++ DoubleRegister double_input, ++ StubCallMode stub_mode) { ++ Label done; ++ ++ TryInlineTruncateDoubleToI(result, double_input, &done); ++ ++ // If we fell through then inline version didn't succeed - call stub instead. ++ Sub_d(sp, sp, ++ Operand(kDoubleSize + kSystemPointerSize)); // Put input on stack. ++ St_d(ra, MemOperand(sp, kSystemPointerSize)); ++ Fst_d(double_input, MemOperand(sp, 0)); ++ ++ if (stub_mode == StubCallMode::kCallWasmRuntimeStub) { ++ Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL); ++ } else { ++ Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET); ++ } ++ ++ Pop(ra, result); ++ bind(&done); ++} ++ ++// BRANCH_ARGS_CHECK checks that conditional jump arguments are correct. ++#define BRANCH_ARGS_CHECK(cond, rj, rk) \ ++ DCHECK((cond == cc_always && rj == zero_reg && rk.rm() == zero_reg) || \ ++ (cond != cc_always && (rj != zero_reg || rk.rm() != zero_reg))) ++ ++void TurboAssembler::Branch(Label* L, bool need_link) { ++ int offset = GetOffset(L, OffsetSize::kOffset26); ++ if (need_link) { ++ bl(offset); ++ } else { ++ b(offset); ++ } ++} ++ ++void TurboAssembler::Branch(Label* L, Condition cond, Register rj, ++ const Operand& rk, bool need_link) { ++ if (L->is_bound()) { ++ BRANCH_ARGS_CHECK(cond, rj, rk); ++ if (!BranchShortOrFallback(L, cond, rj, rk, need_link)) { ++ if (cond != cc_always) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rj, rk, need_link); ++ Branch(L, need_link); ++ bind(&skip); ++ } else { ++ Branch(L); ++ } ++ } ++ } else { ++ if (is_trampoline_emitted()) { ++ if (cond != cc_always) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rj, rk, need_link); ++ Branch(L, need_link); ++ bind(&skip); ++ } else { ++ Branch(L); ++ } ++ } else { ++ BranchShort(L, cond, rj, rk, need_link); ++ } ++ } ++} ++ ++void TurboAssembler::Branch(Label* L, Condition cond, Register rj, ++ RootIndex index) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(L, cond, rj, Operand(scratch)); ++} ++ ++int32_t TurboAssembler::GetOffset(Label* L, OffsetSize bits) { ++ return branch_offset_helper(L, bits) >> 2; ++} ++ ++Register TurboAssembler::GetRkAsRegisterHelper(const Operand& rk, ++ Register scratch) { ++ Register r2 = no_reg; ++ if (rk.is_reg()) { ++ r2 = rk.rm(); ++ } else { ++ r2 = scratch; ++ li(r2, rk); ++ } ++ ++ return r2; ++} ++ ++bool TurboAssembler::BranchShortOrFallback(Label* L, Condition cond, ++ Register rj, const Operand& rk, ++ bool need_link) { ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t8; ++ ++ // Be careful to always use shifted_branch_offset only just before the ++ // branch instruction, as the location will be remember for patching the ++ // target. ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ int offset = 0; ++ switch (cond) { ++ case cc_always: ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ if (need_link) { ++ bl(offset); ++ } else { ++ b(offset); ++ } ++ break; ++ case eq: ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ // beq is used here to make the code patchable. Otherwise b should ++ // be used which has no condition field so is not patchable. ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ beq(rj, rj, offset); ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset21)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset21); ++ beqz(rj, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ // We don't want any other register but scratch clobbered. ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ beq(rj, sc, offset); ++ } ++ break; ++ case ne: ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ // bne is used here to make the code patchable. Otherwise we ++ // should not generate any instruction. ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bne(rj, rj, offset); ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset21)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset21); ++ bnez(rj, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ // We don't want any other register but scratch clobbered. ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bne(rj, sc, offset); ++ } ++ break; ++ ++ // Signed comparison. ++ case greater: ++ // rj > rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ // No code needs to be emitted. ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ blt(zero_reg, rj, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ blt(sc, rj, offset); ++ } ++ break; ++ case greater_equal: ++ // rj >= rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bge(rj, zero_reg, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bge(rj, sc, offset); ++ } ++ break; ++ case less: ++ // rj < rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ // No code needs to be emitted. ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ blt(rj, zero_reg, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ blt(rj, sc, offset); ++ } ++ break; ++ case less_equal: ++ // rj <= rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bge(zero_reg, rj, offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bge(sc, rj, offset); ++ } ++ break; ++ ++ // Unsigned comparison. ++ case Ugreater: ++ // rj > rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ // No code needs to be emitted. ++ } else if (rj == zero_reg) { ++ // No code needs to be emitted. ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bltu(sc, rj, offset); ++ } ++ break; ++ case Ugreater_equal: ++ // rj >= rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (IsZero(rk)) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (rj == zero_reg) { ++ // No code needs to be emitted. ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bgeu(rj, sc, offset); ++ } ++ break; ++ case Uless: ++ // rj < rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ // No code needs to be emitted. ++ } else if (IsZero(rk)) { ++ // No code needs to be emitted. ++ } else if (rj == zero_reg) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bltu(rj, sc, offset); ++ } ++ break; ++ case Uless_equal: ++ // rj <= rk ++ if (rk.is_reg() && rj.code() == rk.rm().code()) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (rj == zero_reg) { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset26)) return false; ++ if (need_link) pcaddi(ra, 2); ++ offset = GetOffset(L, OffsetSize::kOffset26); ++ b(offset); ++ } else if (IsZero(rk)) { ++ // No code needs to be emitted. ++ } else { ++ if (L->is_bound() && !is_near(L, OffsetSize::kOffset16)) return false; ++ if (need_link) pcaddi(ra, 2); ++ Register sc = GetRkAsRegisterHelper(rk, scratch); ++ DCHECK(rj != sc); ++ offset = GetOffset(L, OffsetSize::kOffset16); ++ bgeu(sc, rj, offset); ++ } ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ return true; ++} ++ ++void TurboAssembler::BranchShort(Label* L, Condition cond, Register rj, ++ const Operand& rk, bool need_link) { ++ BRANCH_ARGS_CHECK(cond, rj, rk); ++ bool result = BranchShortOrFallback(L, cond, rj, rk, need_link); ++ DCHECK(result); ++ USE(result); ++} ++ ++void TurboAssembler::LoadFromConstantsTable(Register destination, ++ int constant_index) { ++ DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kBuiltinsConstantsTable)); ++ LoadRoot(destination, RootIndex::kBuiltinsConstantsTable); ++ Ld_d(destination, ++ FieldMemOperand(destination, FixedArray::kHeaderSize + ++ constant_index * kPointerSize)); ++} ++ ++void TurboAssembler::LoadRootRelative(Register destination, int32_t offset) { ++ Ld_d(destination, MemOperand(kRootRegister, offset)); ++} ++ ++void TurboAssembler::LoadRootRegisterOffset(Register destination, ++ intptr_t offset) { ++ if (offset == 0) { ++ Move(destination, kRootRegister); ++ } else { ++ Add_d(destination, kRootRegister, Operand(offset)); ++ } ++} ++ ++void TurboAssembler::Jump(Register target, Condition cond, Register rj, ++ const Operand& rk) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (cond == cc_always) { ++ jirl(zero_reg, target, 0); ++ } else { ++ BRANCH_ARGS_CHECK(cond, rj, rk); ++ Label skip; ++ Branch(&skip, NegateCondition(cond), rj, rk); ++ jirl(zero_reg, target, 0); ++ bind(&skip); ++ } ++} ++ ++void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode, ++ Condition cond, Register rj, const Operand& rk) { ++ Label skip; ++ if (cond != cc_always) { ++ Branch(&skip, NegateCondition(cond), rj, rk); ++ } ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t7, Operand(target, rmode)); ++ jirl(zero_reg, t7, 0); ++ bind(&skip); ++ } ++} ++ ++void TurboAssembler::Jump(Address target, RelocInfo::Mode rmode, Condition cond, ++ Register rj, const Operand& rk) { ++ DCHECK(!RelocInfo::IsCodeTarget(rmode)); ++ Jump(static_cast(target), rmode, cond, rj, rk); ++} ++ ++void TurboAssembler::Jump(Handle code, RelocInfo::Mode rmode, ++ Condition cond, Register rj, const Operand& rk) { ++ DCHECK(RelocInfo::IsCodeTarget(rmode)); ++ ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(t7, code); ++ Add_d(t7, t7, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Jump(t7, cond, rj, rk); ++ return; ++ } else if (options().inline_offheap_trampolines) { ++ int builtin_index = Builtins::kNoBuiltinId; ++ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && ++ Builtins::IsIsolateIndependent(builtin_index)) { ++ // Inline the trampoline. ++ RecordCommentForOffHeapTrampoline(builtin_index); ++ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ Address entry = d.InstructionStartOfBuiltin(builtin_index); ++ li(t7, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Jump(t7, cond, rj, rk); ++ return; ++ } ++ } ++ ++ Jump(static_cast(code.address()), rmode, cond, rj, rk); ++} ++ ++void TurboAssembler::Jump(const ExternalReference& reference) { ++ li(t7, reference); ++ Jump(t7); ++} ++ ++// Note: To call gcc-compiled C code on loonarch, you must call through t[0-8]. ++void TurboAssembler::Call(Register target, Condition cond, Register rj, ++ const Operand& rk) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (cond == cc_always) { ++ jirl(ra, target, 0); ++ } else { ++ BRANCH_ARGS_CHECK(cond, rj, rk); ++ Label skip; ++ Branch(&skip, NegateCondition(cond), rj, rk); ++ jirl(ra, target, 0); ++ bind(&skip); ++ } ++ set_last_call_pc_(pc_); ++} ++ ++void MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit, ++ unsigned higher_limit, ++ Label* on_in_range) { ++ if (lower_limit != 0) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Sub_d(scratch, value, Operand(lower_limit)); ++ Branch(on_in_range, ls, scratch, Operand(higher_limit - lower_limit)); ++ } else { ++ Branch(on_in_range, ls, value, Operand(higher_limit - lower_limit)); ++ } ++} ++ ++void TurboAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond, ++ Register rj, const Operand& rk) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t7, Operand(static_cast(target), rmode), ADDRESS_LOAD); ++ Call(t7, cond, rj, rk); ++} ++ ++void TurboAssembler::Call(Handle code, RelocInfo::Mode rmode, ++ Condition cond, Register rj, const Operand& rk) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(t7, code); ++ Add_d(t7, t7, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Call(t7, cond, rj, rk); ++ return; ++ } else if (options().inline_offheap_trampolines) { ++ int builtin_index = Builtins::kNoBuiltinId; ++ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && ++ Builtins::IsIsolateIndependent(builtin_index)) { ++ // Inline the trampoline. ++ RecordCommentForOffHeapTrampoline(builtin_index); ++ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ Address entry = d.InstructionStartOfBuiltin(builtin_index); ++ li(t7, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Call(t7, cond, rj, rk); ++ return; ++ } ++ } ++ ++ DCHECK(RelocInfo::IsCodeTarget(rmode)); ++ DCHECK(code->IsExecutable()); ++ Call(code.address(), rmode, cond, rj, rk); ++} ++ ++void TurboAssembler::LoadEntryFromBuiltinIndex(Register builtin_index) { ++ STATIC_ASSERT(kSystemPointerSize == 8); ++ STATIC_ASSERT(kSmiTagSize == 1); ++ STATIC_ASSERT(kSmiTag == 0); ++ ++ // The builtin_index register contains the builtin index as a Smi. ++ SmiUntag(builtin_index, builtin_index); ++ Alsl_d(builtin_index, builtin_index, kRootRegister, kSystemPointerSizeLog2, ++ t7); ++ Ld_d(builtin_index, ++ MemOperand(builtin_index, IsolateData::builtin_entry_table_offset())); ++} ++ ++void TurboAssembler::CallBuiltinByIndex(Register builtin_index) { ++ LoadEntryFromBuiltinIndex(builtin_index); ++ Call(builtin_index); ++} ++ ++void TurboAssembler::PatchAndJump(Address target) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ pcaddi(scratch, 4); ++ Ld_d(t7, MemOperand(scratch, 0)); ++ jirl(zero_reg, t7, 0); ++ nop(); ++ DCHECK_EQ(reinterpret_cast(pc_) % 8, 0); ++ *reinterpret_cast(pc_) = target; // pc_ should be align. ++ pc_ += sizeof(uint64_t); ++} ++ ++void TurboAssembler::StoreReturnAddressAndCall(Register target) { ++ // This generates the final instruction sequence for calls to C functions ++ // once an exit frame has been constructed. ++ // ++ // Note that this assumes the caller code (i.e. the Code object currently ++ // being generated) is immovable or that the callee function cannot trigger ++ // GC, since the callee function will return to it. ++ ++ Assembler::BlockTrampolinePoolScope block_trampoline_pool(this); ++ static constexpr int kNumInstructionsToJump = 2; ++ Label find_ra; ++ // Adjust the value in ra to point to the correct return location, 2nd ++ // instruction past the real call into C code (the jirl)), and push it. ++ // This is the return address of the exit frame. ++ pcaddi(ra, kNumInstructionsToJump + 1); ++ bind(&find_ra); ++ ++ // This spot was reserved in EnterExitFrame. ++ St_d(ra, MemOperand(sp, 0)); ++ // Stack is still aligned. ++ ++ // TODO can be jirl target? a0 -- a7? ++ jirl(zero_reg, target, 0); ++ // Make sure the stored 'ra' points to this position. ++ DCHECK_EQ(kNumInstructionsToJump, InstructionsGeneratedSince(&find_ra)); ++} ++ ++void TurboAssembler::Ret(Condition cond, Register rj, const Operand& rk) { ++ Jump(ra, cond, rj, rk); ++} ++ ++void TurboAssembler::DropAndRet(int drop) { ++ DCHECK(is_int16(drop * kPointerSize)); ++ addi_d(sp, sp, drop * kPointerSize); ++ Ret(); ++} ++ ++void TurboAssembler::DropAndRet(int drop, Condition cond, Register r1, ++ const Operand& r2) { ++ // Both Drop and Ret need to be conditional. ++ Label skip; ++ if (cond != cc_always) { ++ Branch(&skip, NegateCondition(cond), r1, r2); ++ } ++ ++ Drop(drop); ++ Ret(); ++ ++ if (cond != cc_always) { ++ bind(&skip); ++ } ++} ++ ++void TurboAssembler::Drop(int count, Condition cond, Register reg, ++ const Operand& op) { ++ if (count <= 0) { ++ return; ++ } ++ ++ Label skip; ++ ++ if (cond != al) { ++ Branch(&skip, NegateCondition(cond), reg, op); ++ } ++ ++ Add_d(sp, sp, Operand(count * kPointerSize)); ++ ++ if (cond != al) { ++ bind(&skip); ++ } ++} ++ ++void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) { ++ if (scratch == no_reg) { ++ Xor(reg1, reg1, Operand(reg2)); ++ Xor(reg2, reg2, Operand(reg1)); ++ Xor(reg1, reg1, Operand(reg2)); ++ } else { ++ mov(scratch, reg1); ++ mov(reg1, reg2); ++ mov(reg2, scratch); ++ } ++} ++ ++void TurboAssembler::Call(Label* target) { Branch(target, true); } ++ ++void TurboAssembler::Push(Smi smi) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(smi)); ++ push(scratch); ++} ++ ++void TurboAssembler::Push(Handle handle) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(handle)); ++ push(scratch); ++} ++ ++void TurboAssembler::PushArray(Register array, Register size, Register scratch, ++ Register scratch2, PushArrayOrder order) { ++ DCHECK(!AreAliased(array, size, scratch, scratch2)); ++ Label loop, entry; ++ if (order == PushArrayOrder::kReverse) { ++ mov(scratch, zero_reg); ++ jmp(&entry); ++ bind(&loop); ++ Alsl_d(scratch2, scratch, array, kPointerSizeLog2, t7); ++ Ld_d(scratch2, MemOperand(scratch2, 0)); ++ push(scratch2); ++ Add_d(scratch, scratch, Operand(1)); ++ bind(&entry); ++ Branch(&loop, less, scratch, Operand(size)); ++ } else { ++ mov(scratch, size); ++ jmp(&entry); ++ bind(&loop); ++ Alsl_d(scratch2, scratch, array, kPointerSizeLog2, t7); ++ Ld_d(scratch2, MemOperand(scratch2, 0)); ++ push(scratch2); ++ bind(&entry); ++ Add_d(scratch, scratch, Operand(-1)); ++ Branch(&loop, greater_equal, scratch, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::MaybeDropFrames() { ++ // Check whether we need to drop frames to restart a function on the stack. ++ li(a1, ExternalReference::debug_restart_fp_address(isolate())); ++ Ld_d(a1, MemOperand(a1, 0)); ++ Jump(BUILTIN_CODE(isolate(), FrameDropperTrampoline), RelocInfo::CODE_TARGET, ++ ne, a1, Operand(zero_reg)); ++} ++ ++// --------------------------------------------------------------------------- ++// Exception handling. ++ ++void MacroAssembler::PushStackHandler() { ++ // Adjust this code if not the case. ++ STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize); ++ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); ++ ++ Push(Smi::zero()); // Padding. ++ ++ // Link the current handler as the next handler. ++ li(t2, ++ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); ++ Ld_d(t1, MemOperand(t2, 0)); ++ push(t1); ++ ++ // Set this new handler as the current one. ++ St_d(sp, MemOperand(t2, 0)); ++} ++ ++void MacroAssembler::PopStackHandler() { ++ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); ++ pop(a1); ++ Add_d(sp, sp, ++ Operand( ++ static_cast(StackHandlerConstants::kSize - kPointerSize))); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, ++ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); ++ St_d(a1, MemOperand(scratch, 0)); ++} ++ ++void TurboAssembler::FPUCanonicalizeNaN(const DoubleRegister dst, ++ const DoubleRegister src) { ++ fsub_d(dst, src, kDoubleRegZero); ++} ++ ++void TurboAssembler::MovFromFloatResult(const DoubleRegister dst) { ++ Move(dst, f0); // Reg f0 is loongarch return value ++} ++ ++void TurboAssembler::MovFromFloatParameter(const DoubleRegister dst) { ++ Move(dst, f0); // Reg f0 is loongarch first argument value. ++} ++ ++void TurboAssembler::MovToFloatParameter(DoubleRegister src) { Move(f0, src); } ++ ++void TurboAssembler::MovToFloatResult(DoubleRegister src) { Move(f0, src); } ++ ++void TurboAssembler::MovToFloatParameters(DoubleRegister src1, ++ DoubleRegister src2) { ++ const DoubleRegister fparg2 = f1; ++ if (src2 == f0) { ++ DCHECK(src1 != fparg2); ++ Move(fparg2, src2); ++ Move(f0, src1); ++ } else { ++ Move(f0, src1); ++ Move(fparg2, src2); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// JavaScript invokes. ++ ++void TurboAssembler::PrepareForTailCall(Register callee_args_count, ++ Register caller_args_count, ++ Register scratch0, Register scratch1) { ++ // Calculate the end of destination area where we will put the arguments ++ // after we drop current frame. We add kPointerSize to count the receiver ++ // argument which is not included into formal parameters count. ++ Register dst_reg = scratch0; ++ Alsl_d(dst_reg, caller_args_count, fp, kPointerSizeLog2, t7); ++ Add_d(dst_reg, dst_reg, ++ Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); ++ ++ Register src_reg = caller_args_count; ++ // Calculate the end of source area. +kPointerSize is for the receiver. ++ Alsl_d(src_reg, callee_args_count, sp, kPointerSizeLog2, t7); ++ Add_d(src_reg, src_reg, Operand(kPointerSize)); ++ ++ if (FLAG_debug_code) { ++ Check(lo, AbortReason::kStackAccessBelowStackPointer, src_reg, ++ Operand(dst_reg)); ++ } ++ ++ // Restore caller's frame pointer and return address now as they will be ++ // overwritten by the copying loop. ++ Ld_d(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); ++ Ld_d(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ ++ // Now copy callee arguments to the caller frame going backwards to avoid ++ // callee arguments corruption (source and destination areas could overlap). ++ ++ // Both src_reg and dst_reg are pointing to the word after the one to copy, ++ // so they must be pre-decremented in the loop. ++ Register tmp_reg = scratch1; ++ Label loop, entry; ++ Branch(&entry); ++ bind(&loop); ++ Sub_d(src_reg, src_reg, Operand(kPointerSize)); ++ Sub_d(dst_reg, dst_reg, Operand(kPointerSize)); ++ Ld_d(tmp_reg, MemOperand(src_reg, 0)); ++ St_d(tmp_reg, MemOperand(dst_reg, 0)); ++ bind(&entry); ++ Branch(&loop, ne, sp, Operand(src_reg)); ++ ++ // Leave current frame. ++ mov(sp, dst_reg); ++} ++ ++void MacroAssembler::InvokePrologue(Register expected_parameter_count, ++ Register actual_parameter_count, ++ Label* done, InvokeFlag flag) { ++ Label regular_invoke; ++ ++ // Check whether the expected and actual arguments count match. The registers ++ // are set up according to contract with ArgumentsAdaptorTrampoline: ++ // a0: actual arguments count ++ // a1: function (passed through to callee) ++ // a2: expected arguments count ++ ++ // The code below is made a lot easier because the calling code already sets ++ // up actual and expected registers according to the contract. ++ ++ DCHECK_EQ(actual_parameter_count, a0); ++ DCHECK_EQ(expected_parameter_count, a2); ++ ++ Branch(®ular_invoke, eq, expected_parameter_count, ++ Operand(actual_parameter_count)); ++ ++ Handle adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline); ++ if (flag == CALL_FUNCTION) { ++ Call(adaptor); ++ Branch(done); ++ } else { ++ Jump(adaptor, RelocInfo::CODE_TARGET); ++ } ++ ++ bind(®ular_invoke); ++} ++ ++void MacroAssembler::CheckDebugHook(Register fun, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count) { ++ Label skip_hook; ++ ++ li(t0, ExternalReference::debug_hook_on_function_call_address(isolate())); ++ Ld_b(t0, MemOperand(t0, 0)); ++ Branch(&skip_hook, eq, t0, Operand(zero_reg)); ++ ++ { ++ // Load receiver to pass it later to DebugOnFunctionCall hook. ++ LoadReceiver(t0, actual_parameter_count); ++ ++ FrameScope frame(this, ++ has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); ++ SmiTag(expected_parameter_count); ++ Push(expected_parameter_count); ++ ++ SmiTag(actual_parameter_count); ++ Push(actual_parameter_count); ++ ++ if (new_target.is_valid()) { ++ Push(new_target); ++ } ++ // TODO: MultiPush/Pop ++ Push(fun); ++ Push(fun); ++ Push(t0); ++ CallRuntime(Runtime::kDebugOnFunctionCall); ++ Pop(fun); ++ if (new_target.is_valid()) { ++ Pop(new_target); ++ } ++ ++ Pop(actual_parameter_count); ++ SmiUntag(actual_parameter_count); ++ ++ Pop(expected_parameter_count); ++ SmiUntag(expected_parameter_count); ++ } ++ bind(&skip_hook); ++} ++ ++void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ DCHECK_EQ(function, a1); ++ DCHECK_IMPLIES(new_target.is_valid(), new_target == a3); ++ ++ // On function call, call into the debugger if necessary. ++ CheckDebugHook(function, new_target, expected_parameter_count, ++ actual_parameter_count); ++ ++ // Clear the new.target register if not given. ++ if (!new_target.is_valid()) { ++ LoadRoot(a3, RootIndex::kUndefinedValue); ++ } ++ ++ Label done; ++ InvokePrologue(expected_parameter_count, actual_parameter_count, &done, flag); ++ // We call indirectly through the code field in the function to ++ // allow recompilation to take effect without changing any of the ++ // call sites. ++ Register code = kJavaScriptCallCodeStartRegister; ++ Ld_d(code, FieldMemOperand(function, JSFunction::kCodeOffset)); ++ if (flag == CALL_FUNCTION) { ++ Add_d(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Call(code); ++ } else { ++ DCHECK(flag == JUMP_FUNCTION); ++ Add_d(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Jump(code); ++ } ++ ++ // Continue here if InvokePrologue does handle the invocation due to ++ // mismatched parameter counts. ++ bind(&done); ++} ++ ++void MacroAssembler::InvokeFunctionWithNewTarget( ++ Register function, Register new_target, Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ ++ // Contract with called JS functions requires that function is passed in a1. ++ DCHECK_EQ(function, a1); ++ Register expected_parameter_count = a2; ++ Register temp_reg = t0; ++ Ld_d(temp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ // The argument count is stored as uint16_t ++ Ld_hu(expected_parameter_count, ++ FieldMemOperand(temp_reg, ++ SharedFunctionInfo::kFormalParameterCountOffset)); ++ ++ InvokeFunctionCode(a1, new_target, expected_parameter_count, ++ actual_parameter_count, flag); ++} ++ ++void MacroAssembler::InvokeFunction(Register function, ++ Register expected_parameter_count, ++ Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ ++ // Contract with called JS functions requires that function is passed in a1. ++ DCHECK_EQ(function, a1); ++ ++ // Get the function and setup the context. ++ Ld_d(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ ++ InvokeFunctionCode(a1, no_reg, expected_parameter_count, ++ actual_parameter_count, flag); ++} ++ ++// --------------------------------------------------------------------------- ++// Support functions. ++ ++void MacroAssembler::GetObjectType(Register object, Register map, ++ Register type_reg) { ++ LoadMap(map, object); ++ Ld_hu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); ++} ++ ++// ----------------------------------------------------------------------------- ++// Runtime calls. ++ ++void TurboAssembler::AdddOverflow(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t8; ++ if (!right.is_reg()) { ++ li(t7, Operand(right)); ++ right_reg = t7; ++ } else { ++ right_reg = right.rm(); ++ } ++ ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ ++ if (dst == left || dst == right_reg) { ++ add_d(scratch, left, right_reg); ++ xor_(overflow, scratch, left); ++ xor_(t7, scratch, right_reg); ++ and_(overflow, overflow, t7); ++ mov(dst, scratch); ++ } else { ++ add_d(dst, left, right_reg); ++ xor_(overflow, dst, left); ++ xor_(t7, dst, right_reg); ++ and_(overflow, overflow, t7); ++ } ++} ++ ++void TurboAssembler::SubdOverflow(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t8; ++ if (!right.is_reg()) { ++ li(t7, Operand(right)); ++ right_reg = t7; ++ } else { ++ right_reg = right.rm(); ++ } ++ ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ ++ if (dst == left || dst == right_reg) { ++ Sub_d(scratch, left, right_reg); ++ xor_(overflow, left, scratch); ++ xor_(t7, left, right_reg); ++ and_(overflow, overflow, t7); ++ mov(dst, scratch); ++ } else { ++ sub_d(dst, left, right_reg); ++ xor_(overflow, left, dst); ++ xor_(t7, left, right_reg); ++ and_(overflow, overflow, t7); ++ } ++} ++ ++void TurboAssembler::MulOverflow(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t8; ++ if (!right.is_reg()) { ++ li(t7, Operand(right)); ++ right_reg = t7; ++ } else { ++ right_reg = right.rm(); ++ } ++ ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ ++ if (dst == left || dst == right_reg) { ++ Mul_w(scratch, left, right_reg); ++ Mulh_w(overflow, left, right_reg); ++ mov(dst, scratch); ++ } else { ++ Mul_w(dst, left, right_reg); ++ Mulh_w(overflow, left, right_reg); ++ } ++ ++ srai_d(scratch, dst, 32); ++ xor_(overflow, overflow, scratch); ++} ++ ++void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, ++ SaveFPRegsMode save_doubles) { ++ // All parameters are on the stack. v0 has the return value after call. ++ ++ // If the expected number of arguments of the runtime function is ++ // constant, we check that the actual number of arguments match the ++ // expectation. ++ CHECK(f->nargs < 0 || f->nargs == num_arguments); ++ ++ // TODO(1236192): Most runtime routines don't need the number of ++ // arguments passed in because it is constant. At some point we ++ // should remove this need and make the runtime routine entry code ++ // smarter. ++ PrepareCEntryArgs(num_arguments); ++ PrepareCEntryFunction(ExternalReference::Create(f)); ++ Handle code = ++ CodeFactory::CEntry(isolate(), f->result_size, save_doubles); ++ Call(code, RelocInfo::CODE_TARGET); ++} ++ ++void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { ++ const Runtime::Function* function = Runtime::FunctionForId(fid); ++ DCHECK_EQ(1, function->result_size); ++ if (function->nargs >= 0) { ++ PrepareCEntryArgs(function->nargs); ++ } ++ JumpToExternalReference(ExternalReference::Create(fid)); ++} ++ ++void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, ++ bool builtin_exit_frame) { ++ PrepareCEntryFunction(builtin); ++ Handle code = CodeFactory::CEntry(isolate(), 1, kDontSaveFPRegs, ++ kArgvOnStack, builtin_exit_frame); ++ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg)); ++} ++ ++void MacroAssembler::JumpToInstructionStream(Address entry) { ++ li(kOffHeapTrampolineRegister, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Jump(kOffHeapTrampolineRegister); ++} ++ ++void MacroAssembler::LoadWeakValue(Register out, Register in, ++ Label* target_if_cleared) { ++ Branch(target_if_cleared, eq, in, Operand(kClearedWeakHeapObjectLower32)); ++ ++ And(out, in, Operand(~kWeakHeapObjectMask)); ++} ++ ++void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, ++ Register scratch1, Register scratch2) { ++ DCHECK_GT(value, 0); ++ if (FLAG_native_code_counters && counter->Enabled()) { ++ // This operation has to be exactly 32-bit wide in case the external ++ // reference table redirects the counter to a uint32_t dummy_stats_counter_ ++ // field. ++ li(scratch2, ExternalReference::Create(counter)); ++ Ld_w(scratch1, MemOperand(scratch2, 0)); ++ Add_w(scratch1, scratch1, Operand(value)); ++ St_w(scratch1, MemOperand(scratch2, 0)); ++ } ++} ++ ++void MacroAssembler::DecrementCounter(StatsCounter* counter, int value, ++ Register scratch1, Register scratch2) { ++ DCHECK_GT(value, 0); ++ if (FLAG_native_code_counters && counter->Enabled()) { ++ // This operation has to be exactly 32-bit wide in case the external ++ // reference table redirects the counter to a uint32_t dummy_stats_counter_ ++ // field. ++ li(scratch2, ExternalReference::Create(counter)); ++ Ld_w(scratch1, MemOperand(scratch2, 0)); ++ Sub_w(scratch1, scratch1, Operand(value)); ++ St_w(scratch1, MemOperand(scratch2, 0)); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Debugging. ++ ++void TurboAssembler::Trap() { stop(); } ++void TurboAssembler::DebugBreak() { stop(); } ++ ++void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs, ++ Operand rk) { ++ if (emit_debug_code()) Check(cc, reason, rs, rk); ++} ++ ++void TurboAssembler::Check(Condition cc, AbortReason reason, Register rj, ++ Operand rk) { ++ Label L; ++ Branch(&L, cc, rj, rk); ++ Abort(reason); ++ // Will not return here. ++ bind(&L); ++} ++ ++void TurboAssembler::Abort(AbortReason reason) { ++ Label abort_start; ++ bind(&abort_start); ++#ifdef DEBUG ++ const char* msg = GetAbortReason(reason); ++ RecordComment("Abort message: "); ++ RecordComment(msg); ++#endif ++ ++ // Avoid emitting call to builtin if requested. ++ if (trap_on_abort()) { ++ stop(); ++ return; ++ } ++ ++ if (should_abort_hard()) { ++ // We don't care if we constructed a frame. Just pretend we did. ++ FrameScope assume_frame(this, StackFrame::NONE); ++ PrepareCallCFunction(0, a0); ++ li(a0, Operand(static_cast(reason))); ++ CallCFunction(ExternalReference::abort_with_reason(), 1); ++ return; ++ } ++ ++ Move(a0, Smi::FromInt(static_cast(reason))); ++ ++ // Disable stub call restrictions to always allow calls to abort. ++ if (!has_frame()) { ++ // We don't actually want to generate a pile of code for this, so just ++ // claim there is a stack frame, without generating one. ++ FrameScope scope(this, StackFrame::NONE); ++ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); ++ } else { ++ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); ++ } ++ // Will not return here. ++ if (is_trampoline_pool_blocked()) { ++ // If the calling code cares about the exact number of ++ // instructions generated, we insert padding here to keep the size ++ // of the Abort macro constant. ++ // Currently in debug mode with debug_code enabled the number of ++ // generated instructions is 10, so we use this as a maximum value. ++ static const int kExpectedAbortInstructions = 10; ++ int abort_instructions = InstructionsGeneratedSince(&abort_start); ++ DCHECK_LE(abort_instructions, kExpectedAbortInstructions); ++ while (abort_instructions++ < kExpectedAbortInstructions) { ++ nop(); ++ } ++ } ++} ++ ++void MacroAssembler::LoadMap(Register destination, Register object) { ++ Ld_d(destination, FieldMemOperand(object, HeapObject::kMapOffset)); ++} ++ ++void MacroAssembler::LoadNativeContextSlot(int index, Register dst) { ++ LoadMap(dst, cp); ++ Ld_d(dst, FieldMemOperand( ++ dst, Map::kConstructorOrBackPointerOrNativeContextOffset)); ++ Ld_d(dst, MemOperand(dst, Context::SlotOffset(index))); ++} ++ ++void TurboAssembler::StubPrologue(StackFrame::Type type) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(StackFrame::TypeToMarker(type))); ++ PushCommonFrame(scratch); ++} ++ ++void TurboAssembler::Prologue() { PushStandardFrame(a1); } ++ ++void TurboAssembler::EnterFrame(StackFrame::Type type) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ int stack_offset = -3 * kPointerSize; ++ const int fp_offset = 1 * kPointerSize; ++ addi_d(sp, sp, stack_offset); ++ stack_offset = -stack_offset - kPointerSize; ++ St_d(ra, MemOperand(sp, stack_offset)); ++ stack_offset -= kPointerSize; ++ St_d(fp, MemOperand(sp, stack_offset)); ++ stack_offset -= kPointerSize; ++ li(t7, Operand(StackFrame::TypeToMarker(type))); ++ St_d(t7, MemOperand(sp, stack_offset)); ++ // Adjust FP to point to saved FP. ++ DCHECK_EQ(stack_offset, 0); ++ Add_d(fp, sp, Operand(fp_offset)); ++} ++ ++void TurboAssembler::LeaveFrame(StackFrame::Type type) { ++ addi_d(sp, fp, 2 * kPointerSize); ++ Ld_d(ra, MemOperand(fp, 1 * kPointerSize)); ++ Ld_d(fp, MemOperand(fp, 0 * kPointerSize)); ++} ++ ++void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, ++ StackFrame::Type frame_type) { ++ DCHECK(frame_type == StackFrame::EXIT || ++ frame_type == StackFrame::BUILTIN_EXIT); ++ ++ // Set up the frame structure on the stack. ++ STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); ++ STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); ++ STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); ++ ++ // This is how the stack will look: ++ // fp + 2 (==kCallerSPDisplacement) - old stack's end ++ // [fp + 1 (==kCallerPCOffset)] - saved old ra ++ // [fp + 0 (==kCallerFPOffset)] - saved old fp ++ // [fp - 1 StackFrame::EXIT Smi ++ // [fp - 2 (==kSPOffset)] - sp of the called function ++ // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the ++ // new stack (will contain saved ra) ++ ++ // Save registers and reserve room for saved entry sp. ++ addi_d(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp); ++ St_d(ra, MemOperand(sp, 3 * kPointerSize)); ++ St_d(fp, MemOperand(sp, 2 * kPointerSize)); ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(StackFrame::TypeToMarker(frame_type))); ++ St_d(scratch, MemOperand(sp, 1 * kPointerSize)); ++ } ++ // Set up new frame pointer. ++ addi_d(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp); ++ ++ if (emit_debug_code()) { ++ St_d(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); ++ } ++ ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Save the frame pointer and the context in top. ++ li(t8, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, ++ isolate())); ++ St_d(fp, MemOperand(t8, 0)); ++ li(t8, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ St_d(cp, MemOperand(t8, 0)); ++ } ++ ++ const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); ++ if (save_doubles) { ++ // The stack is already aligned to 0 modulo 8 for stores with sdc1. ++ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; ++ int space = kNumOfSavedRegisters * kDoubleSize; ++ Sub_d(sp, sp, Operand(space)); ++ // Remember: we only need to save every 2nd double FPU value. ++ for (int i = 0; i < kNumOfSavedRegisters; i++) { ++ FPURegister reg = FPURegister::from_code(2 * i); ++ Fst_d(reg, MemOperand(sp, i * kDoubleSize)); ++ } ++ } ++ ++ // Reserve place for the return address, stack space and an optional slot ++ // (used by DirectCEntry to hold the return value if a struct is ++ // returned) and align the frame preparing for calling the runtime function. ++ DCHECK_GE(stack_space, 0); ++ Sub_d(sp, sp, Operand((stack_space + 2) * kPointerSize)); ++ if (frame_alignment > 0) { ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ And(sp, sp, Operand(-frame_alignment)); // Align stack. ++ } ++ ++ // Set the exit frame sp value to point just before the return address ++ // location. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ addi_d(scratch, sp, kPointerSize); ++ St_d(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); ++} ++ ++void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count, ++ bool do_return, ++ bool argument_count_is_length) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Optionally restore all double registers. ++ if (save_doubles) { ++ // Remember: we only need to restore every 2nd double FPU value. ++ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; ++ Sub_d(t8, fp, ++ Operand(ExitFrameConstants::kFixedFrameSizeFromFp + ++ kNumOfSavedRegisters * kDoubleSize)); ++ for (int i = 0; i < kNumOfSavedRegisters; i++) { ++ FPURegister reg = FPURegister::from_code(2 * i); ++ Fld_d(reg, MemOperand(t8, i * kDoubleSize)); ++ } ++ } ++ ++ // Clear top frame. ++ li(t8, ++ ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate())); ++ St_d(zero_reg, MemOperand(t8, 0)); ++ ++ // Restore current context from top and clear it in debug mode. ++ li(t8, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ Ld_d(cp, MemOperand(t8, 0)); ++ ++#ifdef DEBUG ++ li(t8, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ St_d(a3, MemOperand(t8, 0)); ++#endif ++ ++ // Pop the arguments, restore registers, and return. ++ mov(sp, fp); // Respect ABI stack constraint. ++ Ld_d(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); ++ Ld_d(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); ++ ++ if (argument_count.is_valid()) { ++ if (argument_count_is_length) { ++ add_d(sp, sp, argument_count); ++ } else { ++ Alsl_d(sp, argument_count, sp, kPointerSizeLog2, t8); ++ } ++ } ++ ++ addi_d(sp, sp, 2 * kPointerSize); ++ if (do_return) { ++ Ret(); ++ } ++} ++ ++int TurboAssembler::ActivationFrameAlignment() { ++#if V8_HOST_ARCH_LA64 ++ // Running on the real platform. Use the alignment as mandated by the local ++ // environment. ++ // Note: This will break if we ever start generating snapshots on one Mips ++ // platform for another Mips platform with a different alignment. ++ return base::OS::ActivationFrameAlignment(); ++#else // V8_HOST_ARCH_LA64 ++ // If we are using the simulator then we should always align to the expected ++ // alignment. As the simulator is used to generate snapshots we do not know ++ // if the target platform will need alignment, so this is controlled from a ++ // flag. ++ return FLAG_sim_stack_alignment; ++#endif // V8_HOST_ARCH_LA64 ++} ++ ++void MacroAssembler::AssertStackIsAligned() { ++ if (emit_debug_code()) { ++ const int frame_alignment = ActivationFrameAlignment(); ++ const int frame_alignment_mask = frame_alignment - 1; ++ ++ if (frame_alignment > kPointerSize) { ++ Label alignment_as_expected; ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, sp, frame_alignment_mask); ++ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); ++ } ++ // Don't use Check here, as it will call Runtime_Abort re-entering here. ++ stop(); ++ bind(&alignment_as_expected); ++ } ++ } ++} ++ ++void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { ++ if (SmiValuesAre32Bits()) { ++ Ld_w(dst, MemOperand(src.base(), SmiWordOffset(src.offset()))); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ Ld_w(dst, src); ++ SmiUntag(dst); ++ } ++} ++ ++void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, ++ Register scratch) { ++ DCHECK_EQ(0, kSmiTag); ++ andi(scratch, value, kSmiTagMask); ++ Branch(smi_label, eq, scratch, Operand(zero_reg)); ++} ++ ++void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, ++ Register scratch) { ++ DCHECK_EQ(0, kSmiTag); ++ andi(scratch, value, kSmiTagMask); ++ Branch(not_smi_label, ne, scratch, Operand(zero_reg)); ++} ++ ++void MacroAssembler::AssertNotSmi(Register object) { ++ if (emit_debug_code()) { ++ STATIC_ASSERT(kSmiTag == 0); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, object, kSmiTagMask); ++ Check(ne, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertSmi(Register object) { ++ if (emit_debug_code()) { ++ STATIC_ASSERT(kSmiTag == 0); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, object, kSmiTagMask); ++ Check(eq, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertConstructor(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t8); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor, t8, ++ Operand(zero_reg)); ++ ++ LoadMap(t8, object); ++ Ld_bu(t8, FieldMemOperand(t8, Map::kBitFieldOffset)); ++ And(t8, t8, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ Check(ne, AbortReason::kOperandIsNotAConstructor, t8, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertFunction(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t8); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8, ++ Operand(zero_reg)); ++ GetObjectType(object, t8, t8); ++ Check(eq, AbortReason::kOperandIsNotAFunction, t8, ++ Operand(JS_FUNCTION_TYPE)); ++ } ++} ++ ++void MacroAssembler::AssertBoundFunction(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t8); ++ Check(ne, AbortReason::kOperandIsASmiAndNotABoundFunction, t8, ++ Operand(zero_reg)); ++ GetObjectType(object, t8, t8); ++ Check(eq, AbortReason::kOperandIsNotABoundFunction, t8, ++ Operand(JS_BOUND_FUNCTION_TYPE)); ++ } ++} ++ ++void MacroAssembler::AssertGeneratorObject(Register object) { ++ if (!emit_debug_code()) return; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t8); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAGeneratorObject, t8, ++ Operand(zero_reg)); ++ ++ GetObjectType(object, t8, t8); ++ ++ Label done; ++ ++ // Check if JSGeneratorObject ++ Branch(&done, eq, t8, Operand(JS_GENERATOR_OBJECT_TYPE)); ++ ++ // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) ++ Branch(&done, eq, t8, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); ++ ++ // Check if JSAsyncGeneratorObject ++ Branch(&done, eq, t8, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); ++ ++ Abort(AbortReason::kOperandIsNotAGeneratorObject); ++ ++ bind(&done); ++} ++ ++void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, ++ Register scratch) { ++ if (emit_debug_code()) { ++ Label done_checking; ++ AssertNotSmi(object); ++ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ Branch(&done_checking, eq, object, Operand(scratch)); ++ GetObjectType(object, scratch, scratch); ++ Assert(eq, AbortReason::kExpectedUndefinedOrCell, scratch, ++ Operand(ALLOCATION_SITE_TYPE)); ++ bind(&done_checking); ++ } ++} ++ ++void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1, ++ FPURegister src2, Label* out_of_line) { ++ if (src1 == src2) { ++ Move_s(dst, src1); ++ return; ++ } ++ ++ // Check if one of operands is NaN. ++ CompareIsNanF32(src1, src2); ++ BranchTrueF(out_of_line); ++ ++ fmax_s(dst, src1, src2); ++} ++ ++void TurboAssembler::Float32MaxOutOfLine(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ fadd_s(dst, src1, src2); ++} ++ ++void TurboAssembler::Float32Min(FPURegister dst, FPURegister src1, ++ FPURegister src2, Label* out_of_line) { ++ if (src1 == src2) { ++ Move_s(dst, src1); ++ return; ++ } ++ ++ // Check if one of operands is NaN. ++ CompareIsNanF32(src1, src2); ++ BranchTrueF(out_of_line); ++ ++ fmin_s(dst, src1, src2); ++} ++ ++void TurboAssembler::Float32MinOutOfLine(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ fadd_s(dst, src1, src2); ++} ++ ++void TurboAssembler::Float64Max(FPURegister dst, FPURegister src1, ++ FPURegister src2, Label* out_of_line) { ++ if (src1 == src2) { ++ Move_d(dst, src1); ++ return; ++ } ++ ++ // Check if one of operands is NaN. ++ CompareIsNanF64(src1, src2); ++ BranchTrueF(out_of_line); ++ ++ fmax_d(dst, src1, src2); ++} ++ ++void TurboAssembler::Float64MaxOutOfLine(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ fadd_d(dst, src1, src2); ++} ++ ++void TurboAssembler::Float64Min(FPURegister dst, FPURegister src1, ++ FPURegister src2, Label* out_of_line) { ++ if (src1 == src2) { ++ Move_d(dst, src1); ++ return; ++ } ++ ++ // Check if one of operands is NaN. ++ CompareIsNanF64(src1, src2); ++ BranchTrueF(out_of_line); ++ ++ fmin_d(dst, src1, src2); ++} ++ ++void TurboAssembler::Float64MinOutOfLine(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ fadd_d(dst, src1, src2); ++} ++ ++static const int kRegisterPassedArguments = 8; ++ ++int TurboAssembler::CalculateStackPassedWords(int num_reg_arguments, ++ int num_double_arguments) { ++ int stack_passed_words = 0; ++ num_reg_arguments += 2 * num_double_arguments; ++ ++ // O32: Up to four simple arguments are passed in registers a0..a3. ++ // N64: Up to eight simple arguments are passed in registers a0..a7. ++ if (num_reg_arguments > kRegisterPassedArguments) { ++ stack_passed_words += num_reg_arguments - kRegisterPassedArguments; ++ } ++ stack_passed_words += kCArgSlotCount; ++ return stack_passed_words; ++} ++ ++void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, ++ int num_double_arguments, ++ Register scratch) { ++ int frame_alignment = ActivationFrameAlignment(); ++ ++ // n64: Up to eight simple arguments in a0..a3, a4..a7, No argument slots. ++ // O32: Up to four simple arguments are passed in registers a0..a3. ++ // Those four arguments must have reserved argument slots on the stack for ++ // mips, even though those argument slots are not normally used. ++ // Both ABIs: Remaining arguments are pushed on the stack, above (higher ++ // address than) the (O32) argument slots. (arg slot calculation handled by ++ // CalculateStackPassedWords()). ++ int stack_passed_arguments = ++ CalculateStackPassedWords(num_reg_arguments, num_double_arguments); ++ if (frame_alignment > kPointerSize) { ++ // Make stack end at alignment and make room for num_arguments - 4 words ++ // and the original value of sp. ++ mov(scratch, sp); ++ Sub_d(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ bstrins_d(sp, zero_reg, std::log2(frame_alignment) - 1, 0); ++ St_d(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); ++ } else { ++ Sub_d(sp, sp, Operand(stack_passed_arguments * kPointerSize)); ++ } ++} ++ ++void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, ++ Register scratch) { ++ PrepareCallCFunction(num_reg_arguments, 0, scratch); ++} ++ ++void TurboAssembler::CallCFunction(ExternalReference function, ++ int num_reg_arguments, ++ int num_double_arguments) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t7, function); ++ CallCFunctionHelper(t7, num_reg_arguments, num_double_arguments); ++} ++ ++void TurboAssembler::CallCFunction(Register function, int num_reg_arguments, ++ int num_double_arguments) { ++ CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); ++} ++ ++void TurboAssembler::CallCFunction(ExternalReference function, ++ int num_arguments) { ++ CallCFunction(function, num_arguments, 0); ++} ++ ++void TurboAssembler::CallCFunction(Register function, int num_arguments) { ++ CallCFunction(function, num_arguments, 0); ++} ++ ++void TurboAssembler::CallCFunctionHelper(Register function, ++ int num_reg_arguments, ++ int num_double_arguments) { ++ DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); ++ DCHECK(has_frame()); ++ // Make sure that the stack is aligned before calling a C function unless ++ // running in the simulator. The simulator has its own alignment check which ++ // provides more information. ++ // The argument stots are presumed to have been set up by ++ // PrepareCallCFunction. The C function must be called via t9, for mips ABI. ++ ++#if V8_HOST_ARCH_LA64 ++ if (emit_debug_code()) { ++ int frame_alignment = base::OS::ActivationFrameAlignment(); ++ int frame_alignment_mask = frame_alignment - 1; ++ if (frame_alignment > kPointerSize) { ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ Label alignment_as_expected; ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ And(scratch, sp, Operand(frame_alignment_mask)); ++ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); ++ } ++ // Don't use Check here, as it will call Runtime_Abort possibly ++ // re-entering here. ++ stop(); ++ bind(&alignment_as_expected); ++ } ++ } ++#endif // V8_HOST_ARCH_LA64 ++ ++ // Just call directly. The function called cannot cause a GC, or ++ // allow preemption, so the return address in the link register ++ // stays correct. ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (function != t7) { ++ mov(t7, function); ++ function = t7; ++ } ++ ++ // Save the frame pointer and PC so that the stack layout remains iterable, ++ // even without an ExitFrame which normally exists between JS and C frames. ++ // 't' registers are caller-saved so this is safe as a scratch register. ++ Register pc_scratch = t1; ++ Register scratch = t2; ++ DCHECK(!AreAliased(pc_scratch, scratch, function)); ++ ++ pcaddi(pc_scratch, 1); ++ ++ // See x64 code for reasoning about how to address the isolate data fields. ++ if (root_array_available()) { ++ St_d(pc_scratch, MemOperand(kRootRegister, ++ IsolateData::fast_c_call_caller_pc_offset())); ++ St_d(fp, MemOperand(kRootRegister, ++ IsolateData::fast_c_call_caller_fp_offset())); ++ } else { ++ DCHECK_NOT_NULL(isolate()); ++ li(scratch, ExternalReference::fast_c_call_caller_pc_address(isolate())); ++ St_d(pc_scratch, MemOperand(scratch, 0)); ++ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); ++ St_d(fp, MemOperand(scratch, 0)); ++ } ++ ++ Call(function); ++ ++ // We don't unset the PC; the FP is the source of truth. ++ if (root_array_available()) { ++ St_d(zero_reg, MemOperand(kRootRegister, ++ IsolateData::fast_c_call_caller_fp_offset())); ++ } else { ++ DCHECK_NOT_NULL(isolate()); ++ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); ++ St_d(zero_reg, MemOperand(scratch, 0)); ++ } ++ } ++ ++ int stack_passed_arguments = ++ CalculateStackPassedWords(num_reg_arguments, num_double_arguments); ++ ++ if (base::OS::ActivationFrameAlignment() > kPointerSize) { ++ Ld_d(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); ++ } else { ++ Add_d(sp, sp, Operand(stack_passed_arguments * kPointerSize)); ++ } ++} ++ ++#undef BRANCH_ARGS_CHECK ++ ++void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask, ++ Condition cc, Label* condition_met) { ++ And(scratch, object, Operand(~kPageAlignmentMask)); ++ Ld_d(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); ++ And(scratch, scratch, Operand(mask)); ++ Branch(condition_met, cc, scratch, Operand(zero_reg)); ++} ++ ++Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, ++ Register reg4, Register reg5, ++ Register reg6) { ++ RegList regs = 0; ++ if (reg1.is_valid()) regs |= reg1.bit(); ++ if (reg2.is_valid()) regs |= reg2.bit(); ++ if (reg3.is_valid()) regs |= reg3.bit(); ++ if (reg4.is_valid()) regs |= reg4.bit(); ++ if (reg5.is_valid()) regs |= reg5.bit(); ++ if (reg6.is_valid()) regs |= reg6.bit(); ++ ++ const RegisterConfiguration* config = RegisterConfiguration::Default(); ++ for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { ++ int code = config->GetAllocatableGeneralCode(i); ++ Register candidate = Register::from_code(code); ++ if (regs & candidate.bit()) continue; ++ return candidate; ++ } ++ UNREACHABLE(); ++} ++ ++void TurboAssembler::ComputeCodeStartAddress(Register dst) { ++ // TODO: range check, add Pcadd macro function? ++ pcaddi(dst, -pc_offset() >> 2); ++} ++ ++void TurboAssembler::ResetSpeculationPoisonRegister() { ++ li(kSpeculationPoisonRegister, -1); ++} ++ ++void TurboAssembler::CallForDeoptimization(Address target, int deopt_id, ++ Label* exit, DeoptimizeKind kind) { ++ USE(exit, kind); ++ NoRootArrayScope no_root_array(this); ++ ++ // Save the deopt id in kRootRegister (we don't need the roots array from now ++ // on). ++ DCHECK_LE(deopt_id, 0xFFFF); ++ li(kRootRegister, deopt_id); ++ Call(target, RelocInfo::RUNTIME_ENTRY); ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/macro-assembler-loongarch64.h +@@ -0,0 +1,1110 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef INCLUDED_FROM_MACRO_ASSEMBLER_H ++#error This header must be included via macro-assembler.h ++#endif ++ ++#ifndef V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ ++#define V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/loongarch64/assembler-loongarch64.h" ++#include "src/common/globals.h" ++ ++namespace v8 { ++namespace internal { ++ ++// Forward declarations. ++enum class AbortReason : uint8_t; ++ ++// Reserved Register Usage Summary. ++// ++// Registers t8 and t7 are reserved for use by the MacroAssembler. ++// ++// The programmer should know that the MacroAssembler may clobber these two, ++// but won't touch other registers except in special cases. ++// ++// Per the MIPS ABI, register t0 -- t8 must be used for indirect function call ++// via 'jirl t[0-8]' instructions. gcc? ++ ++// Flags used for LeaveExitFrame function. ++enum LeaveExitFrameMode { EMIT_RETURN = true, NO_EMIT_RETURN = false }; ++ ++// Flags used for the li macro-assembler function. ++enum LiFlags { ++ // If the constant value can be represented in just 12 bits, then ++ // optimize the li to use a single instruction, rather than lu12i_w/lu32i_d/ ++ // lu52i_d/ori sequence. A number of other optimizations that emits less than ++ // maximum number of instructions exists. ++ OPTIMIZE_SIZE = 0, ++ // Always use 4 instructions (lu12i_w/ori/lu32i_d/lu52i_d sequence), ++ // even if the constant could be loaded with just one, so that this value is ++ // patchable later. ++ CONSTANT_SIZE = 1, ++ // For address loads only 3 instruction are required. Used to mark ++ // constant load that will be used as address without relocation ++ // information. It ensures predictable code size, so specific sites ++ // in code are patchable. ++ ADDRESS_LOAD = 2 ++}; ++ ++enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; ++enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; ++enum RAStatus { kRAHasNotBeenSaved, kRAHasBeenSaved }; ++ ++Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg, ++ Register reg3 = no_reg, ++ Register reg4 = no_reg, ++ Register reg5 = no_reg, ++ Register reg6 = no_reg); ++ ++// ----------------------------------------------------------------------------- ++// Static helper functions. ++ ++#define SmiWordOffset(offset) (offset + kPointerSize / 2) ++ ++// Generate a MemOperand for loading a field from an object. ++inline MemOperand FieldMemOperand(Register object, int offset) { ++ return MemOperand(object, offset - kHeapObjectTag); ++} ++ ++class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ++ public: ++ using TurboAssemblerBase::TurboAssemblerBase; ++ ++ // Activation support. ++ void EnterFrame(StackFrame::Type type); ++ void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) { ++ // Out-of-line constant pool not implemented on la64. ++ UNREACHABLE(); ++ } ++ void LeaveFrame(StackFrame::Type type); ++ ++ // Generates function and stub prologue code. ++ void StubPrologue(StackFrame::Type type); ++ void Prologue(); ++ ++ void InitializeRootRegister() { ++ ExternalReference isolate_root = ExternalReference::isolate_root(isolate()); ++ li(kRootRegister, Operand(isolate_root)); ++ } ++ ++ // Jump unconditionally to given label. ++ // Use rather b(Label) for code generation. ++ void jmp(Label* L) { Branch(L); } ++ ++ // ------------------------------------------------------------------------- ++ // Debugging. ++ ++ void Trap() override; ++ void DebugBreak() override; ++ ++ // Calls Abort(msg) if the condition cc is not satisfied. ++ // Use --debug_code to enable. ++ void Assert(Condition cc, AbortReason reason, Register rj, Operand rk); ++ ++ // Like Assert(), but always enabled. ++ void Check(Condition cc, AbortReason reason, Register rj, Operand rk); ++ ++ // Print a message to stdout and abort execution. ++ void Abort(AbortReason msg); ++ ++ void Branch(Label* label, bool need_link = false); ++ void Branch(Label* label, Condition cond, Register r1, const Operand& r2, ++ bool need_link = false); ++ void BranchShort(Label* label, Condition cond, Register r1, const Operand& r2, ++ bool need_link = false); ++ void Branch(Label* L, Condition cond, Register rj, RootIndex index); ++ ++ // Floating point branches ++ void CompareF32(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, ++ CFRegister cd = FCC0) { ++ CompareF(cmp1, cmp2, cc, cd, true); ++ } ++ ++ void CompareIsNanF32(FPURegister cmp1, FPURegister cmp2, ++ CFRegister cd = FCC0) { ++ CompareIsNanF(cmp1, cmp2, cd, true); ++ } ++ ++ void CompareF64(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, ++ CFRegister cd = FCC0) { ++ CompareF(cmp1, cmp2, cc, cd, false); ++ } ++ ++ void CompareIsNanF64(FPURegister cmp1, FPURegister cmp2, ++ CFRegister cd = FCC0) { ++ CompareIsNanF(cmp1, cmp2, cd, false); ++ } ++ ++ void BranchTrueShortF(Label* target, CFRegister cc = FCC0); ++ void BranchFalseShortF(Label* target, CFRegister cc = FCC0); ++ ++ void BranchTrueF(Label* target, CFRegister cc = FCC0); ++ void BranchFalseF(Label* target, CFRegister cc = FCC0); ++ ++ static int InstrCountForLi64Bit(int64_t value); ++ inline void LiLower32BitHelper(Register rd, Operand j); ++ void li_optimized(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); ++ void li(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); ++ inline void li(Register rd, int64_t j, LiFlags mode = OPTIMIZE_SIZE) { ++ li(rd, Operand(j), mode); ++ } ++ inline void li(Register rd, int32_t j, LiFlags mode = OPTIMIZE_SIZE) { ++ li(rd, Operand(static_cast(j)), mode); ++ } ++ void li(Register dst, Handle value, LiFlags mode = OPTIMIZE_SIZE); ++ void li(Register dst, ExternalReference value, LiFlags mode = OPTIMIZE_SIZE); ++ void li(Register dst, const StringConstantBase* string, ++ LiFlags mode = OPTIMIZE_SIZE); ++ ++ void LoadFromConstantsTable(Register destination, ++ int constant_index) override; ++ void LoadRootRegisterOffset(Register destination, intptr_t offset) override; ++ void LoadRootRelative(Register destination, int32_t offset) override; ++ ++// Jump, Call, and Ret pseudo instructions implementing inter-working. ++#define COND_ARGS \ ++ Condition cond = al, Register rj = zero_reg, \ ++ const Operand &rk = Operand(zero_reg) ++ ++ void Jump(Register target, COND_ARGS); ++ void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS); ++ void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS); ++ // Deffer from li, this method save target to the memory, and then load ++ // it to register use ld_d, it can be used in wasm jump table for concurrent ++ // patching. ++ void PatchAndJump(Address target); ++ void Jump(Handle code, RelocInfo::Mode rmode, COND_ARGS); ++ void Jump(const ExternalReference& reference) override; ++ void Call(Register target, COND_ARGS); ++ void Call(Address target, RelocInfo::Mode rmode, COND_ARGS); ++ void Call(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, ++ COND_ARGS); ++ void Call(Label* target); ++ void LoadAddress(Register dst, Label* target); ++ ++ // Load the builtin given by the Smi in |builtin_index| into the same ++ // register. ++ void LoadEntryFromBuiltinIndex(Register builtin_index); ++ void CallBuiltinByIndex(Register builtin_index) override; ++ ++ void LoadCodeObjectEntry(Register destination, ++ Register code_object) override { ++ // TODO(mips): Implement. ++ UNIMPLEMENTED(); ++ } ++ void CallCodeObject(Register code_object) override { ++ // TODO(mips): Implement. ++ UNIMPLEMENTED(); ++ } ++ void JumpCodeObject(Register code_object) override { ++ // TODO(mips): Implement. ++ UNIMPLEMENTED(); ++ } ++ ++ // Generates an instruction sequence s.t. the return address points to the ++ // instruction following the call. ++ // The return address on the stack is used by frame iteration. ++ void StoreReturnAddressAndCall(Register target); ++ ++ void CallForDeoptimization(Address target, int deopt_id, Label* exit, ++ DeoptimizeKind kind); ++ ++ void Ret(COND_ARGS); ++ ++ // Emit code to discard a non-negative number of pointer-sized elements ++ // from the stack, clobbering only the sp register. ++ void Drop(int count, Condition cond = cc_always, Register reg = no_reg, ++ const Operand& op = Operand(no_reg)); ++ ++ // Trivial case of DropAndRet that utilizes the delay slot and only emits ++ // 2 instructions. ++ void DropAndRet(int drop); ++ ++ void DropAndRet(int drop, Condition cond, Register reg, const Operand& op); ++ ++ void Ld_d(Register rd, const MemOperand& rj); ++ void St_d(Register rd, const MemOperand& rj); ++ ++ void push(Register src) { ++ Add_d(sp, sp, Operand(-kPointerSize)); ++ St_d(src, MemOperand(sp, 0)); ++ } ++ void Push(Register src) { push(src); } ++ void Push(Handle handle); ++ void Push(Smi smi); ++ ++ // Push two registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2) { ++ Sub_d(sp, sp, Operand(2 * kPointerSize)); ++ St_d(src1, MemOperand(sp, 1 * kPointerSize)); ++ St_d(src2, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push three registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3) { ++ Sub_d(sp, sp, Operand(3 * kPointerSize)); ++ St_d(src1, MemOperand(sp, 2 * kPointerSize)); ++ St_d(src2, MemOperand(sp, 1 * kPointerSize)); ++ St_d(src3, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push four registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3, Register src4) { ++ Sub_d(sp, sp, Operand(4 * kPointerSize)); ++ St_d(src1, MemOperand(sp, 3 * kPointerSize)); ++ St_d(src2, MemOperand(sp, 2 * kPointerSize)); ++ St_d(src3, MemOperand(sp, 1 * kPointerSize)); ++ St_d(src4, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push five registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3, Register src4, ++ Register src5) { ++ Sub_d(sp, sp, Operand(5 * kPointerSize)); ++ St_d(src1, MemOperand(sp, 4 * kPointerSize)); ++ St_d(src2, MemOperand(sp, 3 * kPointerSize)); ++ St_d(src3, MemOperand(sp, 2 * kPointerSize)); ++ St_d(src4, MemOperand(sp, 1 * kPointerSize)); ++ St_d(src5, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ void Push(Register src, Condition cond, Register tst1, Register tst2) { ++ // Since we don't have conditional execution we use a Branch. ++ Label skip; ++ Branch(&skip, cond, tst1, Operand(tst2)); ++ addi_d(sp, sp, -kPointerSize); ++ st_d(src, sp, 0); ++ bind(&skip); ++ } ++ ++ enum PushArrayOrder { kNormal, kReverse }; ++ void PushArray(Register array, Register size, Register scratch, ++ Register scratch2, PushArrayOrder order = kNormal); ++ ++ void SaveRegisters(RegList registers); ++ void RestoreRegisters(RegList registers); ++ ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode); ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode, Address wasm_target); ++ void CallEphemeronKeyBarrier(Register object, Register address, ++ SaveFPRegsMode fp_mode); ++ ++ // Push multiple registers on the stack. ++ // Registers are saved in numerical order, with higher numbered registers ++ // saved in higher memory addresses. ++ void MultiPush(RegList regs); ++ void MultiPush(RegList regs1, RegList regs2); ++ void MultiPush(RegList regs1, RegList regs2, RegList regs3); ++ void MultiPushFPU(RegList regs); ++ ++ // Calculate how much stack space (in bytes) are required to store caller ++ // registers excluding those specified in the arguments. ++ int RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, ++ Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg) const; ++ ++ // Push caller saved registers on the stack, and return the number of bytes ++ // stack pointer is adjusted. ++ int PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg); ++ // Restore caller saved registers from the stack, and return the number of ++ // bytes stack pointer is adjusted. ++ int PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg); ++ ++ void pop(Register dst) { ++ Ld_d(dst, MemOperand(sp, 0)); ++ Add_d(sp, sp, Operand(kPointerSize)); ++ } ++ void Pop(Register dst) { pop(dst); } ++ ++ // Pop two registers. Pops rightmost register first (from lower address). ++ void Pop(Register src1, Register src2) { ++ DCHECK(src1 != src2); ++ Ld_d(src2, MemOperand(sp, 0 * kPointerSize)); ++ Ld_d(src1, MemOperand(sp, 1 * kPointerSize)); ++ Add_d(sp, sp, 2 * kPointerSize); ++ } ++ ++ // Pop three registers. Pops rightmost register first (from lower address). ++ void Pop(Register src1, Register src2, Register src3) { ++ Ld_d(src3, MemOperand(sp, 0 * kPointerSize)); ++ Ld_d(src2, MemOperand(sp, 1 * kPointerSize)); ++ Ld_d(src1, MemOperand(sp, 2 * kPointerSize)); ++ Add_d(sp, sp, 3 * kPointerSize); ++ } ++ ++ void Pop(uint32_t count = 1) { Add_d(sp, sp, Operand(count * kPointerSize)); } ++ ++ // Pops multiple values from the stack and load them in the ++ // registers specified in regs. Pop order is the opposite as in MultiPush. ++ void MultiPop(RegList regs); ++ void MultiPop(RegList regs1, RegList regs2); ++ void MultiPop(RegList regs1, RegList regs2, RegList regs3); ++ ++ void MultiPopFPU(RegList regs); ++ ++#define DEFINE_INSTRUCTION(instr) \ ++ void instr(Register rd, Register rj, const Operand& rk); \ ++ void instr(Register rd, Register rj, Register rk) { \ ++ instr(rd, rj, Operand(rk)); \ ++ } \ ++ void instr(Register rj, Register rk, int32_t j) { instr(rj, rk, Operand(j)); } ++ ++#define DEFINE_INSTRUCTION2(instr) \ ++ void instr(Register rj, const Operand& rk); \ ++ void instr(Register rj, Register rk) { instr(rj, Operand(rk)); } \ ++ void instr(Register rj, int32_t j) { instr(rj, Operand(j)); } ++ ++ DEFINE_INSTRUCTION(Add_w) ++ DEFINE_INSTRUCTION(Add_d) ++ DEFINE_INSTRUCTION(Div_w) ++ DEFINE_INSTRUCTION(Div_wu) ++ DEFINE_INSTRUCTION(Div_du) ++ DEFINE_INSTRUCTION(Mod_w) ++ DEFINE_INSTRUCTION(Mod_wu) ++ DEFINE_INSTRUCTION(Div_d) ++ DEFINE_INSTRUCTION(Sub_w) ++ DEFINE_INSTRUCTION(Sub_d) ++ DEFINE_INSTRUCTION(Mod_d) ++ DEFINE_INSTRUCTION(Mod_du) ++ DEFINE_INSTRUCTION(Mul_w) ++ DEFINE_INSTRUCTION(Mulh_w) ++ DEFINE_INSTRUCTION(Mulh_wu) ++ DEFINE_INSTRUCTION(Mul_d) ++ DEFINE_INSTRUCTION(Mulh_d) ++ DEFINE_INSTRUCTION2(Div_w) ++ DEFINE_INSTRUCTION2(Div_d) ++ DEFINE_INSTRUCTION2(Div_wu) ++ DEFINE_INSTRUCTION2(Div_du) ++ ++ DEFINE_INSTRUCTION(And) ++ DEFINE_INSTRUCTION(Or) ++ DEFINE_INSTRUCTION(Xor) ++ DEFINE_INSTRUCTION(Nor) ++ DEFINE_INSTRUCTION2(Neg) ++ DEFINE_INSTRUCTION(Andn) ++ DEFINE_INSTRUCTION(Orn) ++ ++ DEFINE_INSTRUCTION(Slt) ++ DEFINE_INSTRUCTION(Sltu) ++ DEFINE_INSTRUCTION(Slti) ++ DEFINE_INSTRUCTION(Sltiu) ++ DEFINE_INSTRUCTION(Sle) ++ DEFINE_INSTRUCTION(Sleu) ++ DEFINE_INSTRUCTION(Sgt) ++ DEFINE_INSTRUCTION(Sgtu) ++ DEFINE_INSTRUCTION(Sge) ++ DEFINE_INSTRUCTION(Sgeu) ++ ++ DEFINE_INSTRUCTION(Rotr_w) ++ DEFINE_INSTRUCTION(Rotr_d) ++ ++#undef DEFINE_INSTRUCTION ++#undef DEFINE_INSTRUCTION2 ++#undef DEFINE_INSTRUCTION3 ++ ++ void SmiUntag(Register dst, const MemOperand& src); ++ void SmiUntag(Register dst, Register src) { ++ if (SmiValuesAre32Bits()) { ++ srai_d(dst, src, kSmiShift); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ srai_w(dst, src, kSmiShift); ++ } ++ } ++ ++ void SmiUntag(Register reg) { SmiUntag(reg, reg); } ++ ++ // Removes current frame and its arguments from the stack preserving ++ // the arguments and a return address pushed to the stack for the next call. ++ // Both |callee_args_count| and |caller_args_count| do not include ++ // receiver. |callee_args_count| is not modified. |caller_args_count| ++ // is trashed. ++ void PrepareForTailCall(Register callee_args_count, ++ Register caller_args_count, Register scratch0, ++ Register scratch1); ++ ++ int CalculateStackPassedWords(int num_reg_arguments, ++ int num_double_arguments); ++ ++ // Before calling a C-function from generated code, align arguments on stack ++ // and add space for the four mips argument slots. ++ // After aligning the frame, non-register arguments must be stored on the ++ // stack, after the argument-slots using helper: CFunctionArgumentOperand(). ++ // The argument count assumes all arguments are word sized. ++ // Some compilers/platforms require the stack to be aligned when calling ++ // C++ code. ++ // Needs a scratch register to do some arithmetic. This register will be ++ // trashed. ++ void PrepareCallCFunction(int num_reg_arguments, int num_double_registers, ++ Register scratch); ++ void PrepareCallCFunction(int num_reg_arguments, Register scratch); ++ ++ // Calls a C function and cleans up the space for arguments allocated ++ // by PrepareCallCFunction. The called function is not allowed to trigger a ++ // garbage collection, since that might move the code and invalidate the ++ // return address (unless this is somehow accounted for by the called ++ // function). ++ void CallCFunction(ExternalReference function, int num_arguments); ++ void CallCFunction(Register function, int num_arguments); ++ void CallCFunction(ExternalReference function, int num_reg_arguments, ++ int num_double_arguments); ++ void CallCFunction(Register function, int num_reg_arguments, ++ int num_double_arguments); ++ void MovFromFloatResult(DoubleRegister dst); ++ void MovFromFloatParameter(DoubleRegister dst); ++ ++ // There are two ways of passing double arguments on MIPS, depending on ++ // whether soft or hard floating point ABI is used. These functions ++ // abstract parameter passing for the three different ways we call ++ // C functions from generated code. ++ void MovToFloatParameter(DoubleRegister src); ++ void MovToFloatParameters(DoubleRegister src1, DoubleRegister src2); ++ void MovToFloatResult(DoubleRegister src); ++ ++ // See comments at the beginning of Builtins::Generate_CEntry. ++ inline void PrepareCEntryArgs(int num_args) { li(a0, num_args); } ++ inline void PrepareCEntryFunction(const ExternalReference& ref) { ++ li(a1, ref); ++ } ++ ++ void CheckPageFlag(Register object, Register scratch, int mask, Condition cc, ++ Label* condition_met); ++#undef COND_ARGS ++ ++ // Performs a truncating conversion of a floating point number as used by ++ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. ++ // Exits with 'result' holding the answer. ++ void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result, ++ DoubleRegister double_input, StubCallMode stub_mode); ++ ++ // Conditional move. ++ void Movz(Register rd, Register rj, Register rk); ++ void Movn(Register rd, Register rj, Register rk); ++ ++ void LoadZeroIfFPUCondition(Register dest, CFRegister = FCC0); ++ void LoadZeroIfNotFPUCondition(Register dest, CFRegister = FCC0); ++ ++ void LoadZeroIfConditionNotZero(Register dest, Register condition); ++ void LoadZeroIfConditionZero(Register dest, Register condition); ++ void LoadZeroOnCondition(Register rd, Register rj, const Operand& rk, ++ Condition cond); ++ ++ void Clz_w(Register rd, Register rj); ++ void Clz_d(Register rd, Register rj); ++ void Ctz_w(Register rd, Register rj); ++ void Ctz_d(Register rd, Register rj); ++ void Popcnt_w(Register rd, Register rj); ++ void Popcnt_d(Register rd, Register rj); ++ ++ void ExtractBits(Register dest, Register source, Register pos, int size, ++ bool sign_extend = false); ++ void InsertBits(Register dest, Register source, Register pos, int size); ++ ++ void Bstrins_w(Register rk, Register rj, uint16_t msbw, uint16_t lswb); ++ void Bstrins_d(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); ++ void Bstrpick_w(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); ++ void Bstrpick_d(Register rk, Register rj, uint16_t msbw, uint16_t lsbw); ++ void Neg_s(FPURegister fd, FPURegister fj); ++ void Neg_d(FPURegister fd, FPURegister fk); ++ ++ // Convert single to unsigned word. ++ void Trunc_uw_s(FPURegister fd, FPURegister fj, FPURegister scratch); ++ void Trunc_uw_s(Register rd, FPURegister fj, FPURegister scratch); ++ ++ // Change endianness ++ void ByteSwapSigned(Register dest, Register src, int operand_size); ++ void ByteSwapUnsigned(Register dest, Register src, int operand_size); ++ ++ void Ld_b(Register rd, const MemOperand& rj); ++ void Ld_bu(Register rd, const MemOperand& rj); ++ void St_b(Register rd, const MemOperand& rj); ++ ++ void Ld_h(Register rd, const MemOperand& rj); ++ void Ld_hu(Register rd, const MemOperand& rj); ++ void St_h(Register rd, const MemOperand& rj); ++ ++ void Ld_w(Register rd, const MemOperand& rj); ++ void Ld_wu(Register rd, const MemOperand& rj); ++ void St_w(Register rd, const MemOperand& rj); ++ ++ void Fld_s(FPURegister fd, const MemOperand& src); ++ void Fst_s(FPURegister fj, const MemOperand& dst); ++ ++ void Fld_d(FPURegister fd, const MemOperand& src); ++ void Fst_d(FPURegister fj, const MemOperand& dst); ++ ++ void Ll_w(Register rd, const MemOperand& rj); ++ void Sc_w(Register rd, const MemOperand& rj); ++ ++ void Ll_d(Register rd, const MemOperand& rj); ++ void Sc_d(Register rd, const MemOperand& rj); ++ ++ // These functions assume (and assert) that src1!=src2. It is permitted ++ // for the result to alias either input register. ++ void Float32Max(FPURegister dst, FPURegister src1, FPURegister src2, ++ Label* out_of_line); ++ void Float32Min(FPURegister dst, FPURegister src1, FPURegister src2, ++ Label* out_of_line); ++ void Float64Max(FPURegister dst, FPURegister src1, FPURegister src2, ++ Label* out_of_line); ++ void Float64Min(FPURegister dst, FPURegister src1, FPURegister src2, ++ Label* out_of_line); ++ ++ // Generate out-of-line cases for the macros above. ++ void Float32MaxOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float32MinOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float64MaxOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float64MinOutOfLine(FPURegister dst, FPURegister src1, FPURegister src2); ++ ++ bool IsDoubleZeroRegSet() { return has_double_zero_reg_set_; } ++ ++ void mov(Register rd, Register rj) { or_(rd, rj, zero_reg); } ++ ++ inline void Move(Register dst, Handle handle) { li(dst, handle); } ++ inline void Move(Register dst, Smi smi) { li(dst, Operand(smi)); } ++ ++ inline void Move(Register dst, Register src) { ++ if (dst != src) { ++ mov(dst, src); ++ } ++ } ++ ++ inline void FmoveLow(Register dst_low, FPURegister src) { ++ movfr2gr_s(dst_low, src); ++ } ++ ++ void FmoveLow(FPURegister dst, Register src_low); ++ ++ inline void Move(FPURegister dst, FPURegister src) { Move_d(dst, src); } ++ ++ inline void Move_d(FPURegister dst, FPURegister src) { ++ if (dst != src) { ++ fmov_d(dst, src); ++ } ++ } ++ ++ inline void Move_s(FPURegister dst, FPURegister src) { ++ if (dst != src) { ++ fmov_s(dst, src); ++ } ++ } ++ ++ void Move(FPURegister dst, float imm) { Move(dst, bit_cast(imm)); } ++ void Move(FPURegister dst, double imm) { Move(dst, bit_cast(imm)); } ++ void Move(FPURegister dst, uint32_t src); ++ void Move(FPURegister dst, uint64_t src); ++ ++ // AdddOverflow sets overflow register to a negative value if ++ // overflow occured, otherwise it is zero or positive ++ void AdddOverflow(Register dst, Register left, const Operand& right, ++ Register overflow); ++ // SubdOverflow sets overflow register to a negative value if ++ // overflow occured, otherwise it is zero or positive ++ void SubdOverflow(Register dst, Register left, const Operand& right, ++ Register overflow); ++ // MulOverflow sets overflow register to zero if no overflow occured ++ void MulOverflow(Register dst, Register left, const Operand& right, ++ Register overflow); ++ ++ // Number of instructions needed for calculation of switch table entry address ++ static const int kSwitchTablePrologueSize = 5; ++ ++ // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a ++ // functor/function with 'Label *func(size_t index)' declaration. ++ template ++ void GenerateSwitchTable(Register index, size_t case_count, ++ Func GetLabelFunction); ++ ++ // Load an object from the root table. ++ void LoadRoot(Register destination, RootIndex index) override; ++ void LoadRoot(Register destination, RootIndex index, Condition cond, ++ Register src1, const Operand& src2); ++ ++ // If the value is a NaN, canonicalize the value, src must be nan. ++ void FPUCanonicalizeNaN(const DoubleRegister dst, const DoubleRegister src); ++ ++ // --------------------------------------------------------------------------- ++ // FPU macros. These do not handle special cases like NaN or +- inf. ++ ++ // Convert unsigned word to double. ++ void Ffint_d_uw(FPURegister fd, FPURegister fj); ++ void Ffint_d_uw(FPURegister fd, Register rj); ++ ++ // Convert unsigned long to double. ++ void Ffint_d_ul(FPURegister fd, FPURegister fj); ++ void Ffint_d_ul(FPURegister fd, Register rj); ++ ++ // Convert unsigned word to float. ++ void Ffint_s_uw(FPURegister fd, FPURegister fj); ++ void Ffint_s_uw(FPURegister fd, Register rj); ++ ++ // Convert unsigned long to float. ++ void Ffint_s_ul(FPURegister fd, FPURegister fj); ++ void Ffint_s_ul(FPURegister fd, Register rj); ++ ++ // Convert double to unsigned word. ++ void Ftintrz_uw_d(FPURegister fd, FPURegister fj, FPURegister scratch); ++ void Ftintrz_uw_d(Register rd, FPURegister fj, FPURegister scratch); ++ ++ // Convert single to unsigned word. ++ void Ftintrz_uw_s(FPURegister fd, FPURegister fs, FPURegister scratch); ++ void Ftintrz_uw_s(Register rd, FPURegister fs, FPURegister scratch); ++ ++ // Convert double to unsigned long. ++ void Ftintrz_ul_d(FPURegister fd, FPURegister fj, FPURegister scratch, ++ Register result = no_reg); ++ void Ftintrz_ul_d(Register rd, FPURegister fj, FPURegister scratch, ++ Register result = no_reg); ++ ++ // Convert single to unsigned long. ++ void Ftintrz_ul_s(FPURegister fd, FPURegister fj, FPURegister scratch, ++ Register result = no_reg); ++ void Ftintrz_ul_s(Register rd, FPURegister fj, FPURegister scratch, ++ Register result = no_reg); ++ ++ // Round double functions ++ void Trunc_d(FPURegister fd, FPURegister fj); ++ void Round_d(FPURegister fd, FPURegister fj); ++ void Floor_d(FPURegister fd, FPURegister fj); ++ void Ceil_d(FPURegister fd, FPURegister fj); ++ ++ // Round float functions ++ void Trunc_s(FPURegister fd, FPURegister fj); ++ void Round_s(FPURegister fd, FPURegister fj); ++ void Floor_s(FPURegister fd, FPURegister fj); ++ void Ceil_s(FPURegister fd, FPURegister fj); ++ ++ // Jump the register contains a smi. ++ void JumpIfSmi(Register value, Label* smi_label, Register scratch = t7); ++ ++ void JumpIfEqual(Register a, int32_t b, Label* dest) { ++ li(kScratchReg, Operand(b)); ++ Branch(dest, eq, a, Operand(kScratchReg)); ++ } ++ ++ void JumpIfLessThan(Register a, int32_t b, Label* dest) { ++ li(kScratchReg, Operand(b)); ++ Branch(dest, lt, a, Operand(kScratchReg)); ++ } ++ ++ // Push a standard frame, consisting of ra, fp, context and JS function. ++ void PushStandardFrame(Register function_reg); ++ ++ // Get the actual activation frame alignment for target environment. ++ static int ActivationFrameAlignment(); ++ ++ // Load Scaled Address instructions. Parameter sa (shift argument) must be ++ // between [1, 31] (inclusive). The scratch register may be clobbered. ++ void Alsl_w(Register rd, Register rj, Register rk, uint8_t sa, ++ Register scratch = t7); ++ void Alsl_d(Register rd, Register rj, Register rk, uint8_t sa, ++ Register scratch = t7); ++ ++ // Compute the start of the generated instruction stream from the current PC. ++ // This is an alternative to embedding the {CodeObject} handle as a reference. ++ void ComputeCodeStartAddress(Register dst); ++ ++ void ResetSpeculationPoisonRegister(); ++ ++ // Control-flow integrity: ++ ++ // Define a function entrypoint. This doesn't emit any code for this ++ // architecture, as control-flow integrity is not supported for it. ++ void CodeEntry() {} ++ // Define an exception handler. ++ void ExceptionHandler() {} ++ // Define an exception handler and bind a label. ++ void BindExceptionHandler(Label* label) { bind(label); } ++ ++ protected: ++ inline Register GetRkAsRegisterHelper(const Operand& rk, Register scratch); ++ inline int32_t GetOffset(Label* L, OffsetSize bits); ++ ++ private: ++ bool has_double_zero_reg_set_ = false; ++ ++ // Performs a truncating conversion of a floating point number as used by ++ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it ++ // succeeds, otherwise falls through if result is saturated. On return ++ // 'result' either holds answer, or is clobbered on fall through. ++ void TryInlineTruncateDoubleToI(Register result, DoubleRegister input, ++ Label* done); ++ ++ bool BranchShortOrFallback(Label* L, Condition cond, Register rj, ++ const Operand& rk, bool need_link); ++ ++ // f32 or f64 ++ void CompareF(FPURegister cmp1, FPURegister cmp2, FPUCondition cc, ++ CFRegister cd, bool f32 = true); ++ ++ void CompareIsNanF(FPURegister cmp1, FPURegister cmp2, CFRegister cd, ++ bool f32 = true); ++ ++ void CallCFunctionHelper(Register function, int num_reg_arguments, ++ int num_double_arguments); ++ ++ void RoundDouble(FPURegister dst, FPURegister src, FPURoundingMode mode); ++ ++ void RoundFloat(FPURegister dst, FPURegister src, FPURoundingMode mode); ++ ++ // Push a fixed frame, consisting of ra, fp. ++ void PushCommonFrame(Register marker_reg = no_reg); ++ ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode, Handle code_target, ++ Address wasm_target); ++}; ++ ++// MacroAssembler implements a collection of frequently used macros. ++class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { ++ public: ++ using TurboAssembler::TurboAssembler; ++ ++ // It assumes that the arguments are located below the stack pointer. ++ // argc is the number of arguments not including the receiver. ++ // TODO(victorgomes): Remove this function once we stick with the reversed ++ // arguments order. ++ void LoadReceiver(Register dest, Register argc) { ++#ifdef V8_REVERSE_JSARGS ++ Ld_d(dest, MemOperand(sp, 0)); ++#else ++ Alsl_d(dest, argc, sp, kPointerSizeLog2, t7); ++ Ld_d(dest, MemOperand(dest, 0)); ++#endif ++ } ++ ++ void StoreReceiver(Register rec, Register argc, Register scratch) { ++#ifdef V8_REVERSE_JSARGS ++ St_d(rec, MemOperand(sp, 0)); ++#else ++ Alsl_d(scratch, argc, sp, kPointerSizeLog2, t7); ++ St_d(rec, MemOperand(scratch, 0)); ++#endif ++ } ++ ++ bool IsNear(Label* L, Condition cond, int rs_reg); ++ ++ // Swap two registers. If the scratch register is omitted then a slightly ++ // less efficient form using xor instead of mov is emitted. ++ void Swap(Register reg1, Register reg2, Register scratch = no_reg); ++ ++ void PushRoot(RootIndex index) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Push(scratch); ++ } ++ ++ // Compare the object in a register to a value and jump if they are equal. ++ void JumpIfRoot(Register with, RootIndex index, Label* if_equal) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(if_equal, eq, with, Operand(scratch)); ++ } ++ ++ // Compare the object in a register to a value and jump if they are not equal. ++ void JumpIfNotRoot(Register with, RootIndex index, Label* if_not_equal) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(if_not_equal, ne, with, Operand(scratch)); ++ } ++ ++ // Checks if value is in range [lower_limit, higher_limit] using a single ++ // comparison. ++ void JumpIfIsInRange(Register value, unsigned lower_limit, ++ unsigned higher_limit, Label* on_in_range); ++ ++ // --------------------------------------------------------------------------- ++ // GC Support ++ ++ // Notify the garbage collector that we wrote a pointer into an object. ++ // |object| is the object being stored into, |value| is the object being ++ // stored. value and scratch registers are clobbered by the operation. ++ // The offset is the offset from the start of the object, not the offset from ++ // the tagged HeapObject pointer. For use with FieldOperand(reg, off). ++ void RecordWriteField( ++ Register object, int offset, Register value, Register scratch, ++ RAStatus ra_status, SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, ++ SmiCheck smi_check = INLINE_SMI_CHECK); ++ ++ // For a given |object| notify the garbage collector that the slot |address| ++ // has been written. |value| is the object being stored. The value and ++ // address registers are clobbered by the operation. ++ void RecordWrite( ++ Register object, Register address, Register value, RAStatus ra_status, ++ SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, ++ SmiCheck smi_check = INLINE_SMI_CHECK); ++ ++ void Pref(int32_t hint, const MemOperand& rs); ++ ++ // --------------------------------------------------------------------------- ++ // Pseudo-instructions. ++ ++ void LoadWordPair(Register rd, const MemOperand& rj, Register scratch); ++ void StoreWordPair(Register rd, const MemOperand& rj, Register scratch); ++ ++ // Convert double to unsigned long. ++ void Ftintrz_l_ud(FPURegister fd, FPURegister fj, FPURegister scratch); ++ ++ void Ftintrz_l_d(FPURegister fd, FPURegister fj); ++ void Ftintrne_l_d(FPURegister fd, FPURegister fj); ++ void Ftintrm_l_d(FPURegister fd, FPURegister fj); ++ void Ftintrp_l_d(FPURegister fd, FPURegister fj); ++ ++ void Ftintrz_w_d(FPURegister fd, FPURegister fj); ++ void Ftintrne_w_d(FPURegister fd, FPURegister fj); ++ void Ftintrm_w_d(FPURegister fd, FPURegister fj); ++ void Ftintrp_w_d(FPURegister fd, FPURegister fj); ++ ++ void Madd_s(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); ++ void Madd_d(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); ++ void Msub_s(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); ++ void Msub_d(FPURegister fd, FPURegister fa, FPURegister fj, FPURegister fk); ++ ++ // Truncates a double using a specific rounding mode, and writes the value ++ // to the result register. ++ // The except_flag will contain any exceptions caused by the instruction. ++ // If check_inexact is kDontCheckForInexactConversion, then the inexact ++ // exception is masked. ++ void EmitFPUTruncate( ++ FPURoundingMode rounding_mode, Register result, ++ DoubleRegister double_input, Register scratch, ++ DoubleRegister double_scratch, Register except_flag, ++ CheckForInexactConversion check_inexact = kDontCheckForInexactConversion); ++ ++ // Enter exit frame. ++ // argc - argument count to be dropped by LeaveExitFrame. ++ // save_doubles - saves FPU registers on stack, currently disabled. ++ // stack_space - extra stack space. ++ void EnterExitFrame(bool save_doubles, int stack_space = 0, ++ StackFrame::Type frame_type = StackFrame::EXIT); ++ ++ // Leave the current exit frame. ++ void LeaveExitFrame(bool save_doubles, Register arg_count, ++ bool do_return = NO_EMIT_RETURN, ++ bool argument_count_is_length = false); ++ ++ void LoadMap(Register destination, Register object); ++ ++ // Make sure the stack is aligned. Only emits code in debug mode. ++ void AssertStackIsAligned(); ++ ++ // Load the global proxy from the current context. ++ void LoadGlobalProxy(Register dst) { ++ LoadNativeContextSlot(Context::GLOBAL_PROXY_INDEX, dst); ++ } ++ ++ void LoadNativeContextSlot(int index, Register dst); ++ ++ // Load the initial map from the global function. The registers ++ // function and map can be the same, function is then overwritten. ++ void LoadGlobalFunctionInitialMap(Register function, Register map, ++ Register scratch); ++ ++ // ------------------------------------------------------------------------- ++ // JavaScript invokes. ++ ++ // Invoke the JavaScript function code by either calling or jumping. ++ void InvokeFunctionCode(Register function, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count, InvokeFlag flag); ++ ++ // On function call, call into the debugger if necessary. ++ void CheckDebugHook(Register fun, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count); ++ ++ // Invoke the JavaScript function in the given register. Changes the ++ // current context to the context in the function before invoking. ++ void InvokeFunctionWithNewTarget(Register function, Register new_target, ++ Register actual_parameter_count, ++ InvokeFlag flag); ++ void InvokeFunction(Register function, Register expected_parameter_count, ++ Register actual_parameter_count, InvokeFlag flag); ++ ++ // Frame restart support. ++ void MaybeDropFrames(); ++ ++ // Exception handling. ++ ++ // Push a new stack handler and link into stack handler chain. ++ void PushStackHandler(); ++ ++ // Unlink the stack handler on top of the stack from the stack handler chain. ++ // Must preserve the result register. ++ void PopStackHandler(); ++ ++ // ------------------------------------------------------------------------- ++ // Support functions. ++ ++ void GetObjectType(Register function, Register map, Register type_reg); ++ ++ // ------------------------------------------------------------------------- ++ // Runtime calls. ++ ++ // Call a runtime routine. ++ void CallRuntime(const Runtime::Function* f, int num_arguments, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs); ++ ++ // Convenience function: Same as above, but takes the fid instead. ++ void CallRuntime(Runtime::FunctionId fid, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { ++ const Runtime::Function* function = Runtime::FunctionForId(fid); ++ CallRuntime(function, function->nargs, save_doubles); ++ } ++ ++ // Convenience function: Same as above, but takes the fid instead. ++ void CallRuntime(Runtime::FunctionId fid, int num_arguments, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { ++ CallRuntime(Runtime::FunctionForId(fid), num_arguments, save_doubles); ++ } ++ ++ // Convenience function: tail call a runtime routine (jump). ++ void TailCallRuntime(Runtime::FunctionId fid); ++ ++ // Jump to the builtin routine. ++ void JumpToExternalReference(const ExternalReference& builtin, ++ bool builtin_exit_frame = false); ++ ++ // Generates a trampoline to jump to the off-heap instruction stream. ++ void JumpToInstructionStream(Address entry); ++ ++ // --------------------------------------------------------------------------- ++ // In-place weak references. ++ void LoadWeakValue(Register out, Register in, Label* target_if_cleared); ++ ++ // ------------------------------------------------------------------------- ++ // StatsCounter support. ++ ++ void IncrementCounter(StatsCounter* counter, int value, Register scratch1, ++ Register scratch2); ++ void DecrementCounter(StatsCounter* counter, int value, Register scratch1, ++ Register scratch2); ++ ++ // ------------------------------------------------------------------------- ++ // Smi utilities. ++ ++ void SmiTag(Register dst, Register src) { ++ STATIC_ASSERT(kSmiTag == 0); ++ if (SmiValuesAre32Bits()) { ++ slli_d(dst, src, 32); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ add_w(dst, src, src); ++ } ++ } ++ ++ void SmiTag(Register reg) { SmiTag(reg, reg); } ++ ++ // Left-shifted from int32 equivalent of Smi. ++ void SmiScale(Register dst, Register src, int scale) { ++ if (SmiValuesAre32Bits()) { ++ // The int portion is upper 32-bits of 64-bit word. ++ srai_d(dst, src, kSmiShift - scale); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ DCHECK_GE(scale, kSmiTagSize); ++ slli_w(dst, src, scale - kSmiTagSize); ++ } ++ } ++ ++ // Test if the register contains a smi. ++ inline void SmiTst(Register value, Register scratch) { ++ And(scratch, value, Operand(kSmiTagMask)); ++ } ++ ++ // Jump if the register contains a non-smi. ++ void JumpIfNotSmi(Register value, Label* not_smi_label, Register scratch); ++ ++ // Abort execution if argument is a smi, enabled via --debug-code. ++ void AssertNotSmi(Register object); ++ void AssertSmi(Register object); ++ ++ // Abort execution if argument is not a Constructor, enabled via --debug-code. ++ void AssertConstructor(Register object); ++ ++ // Abort execution if argument is not a JSFunction, enabled via --debug-code. ++ void AssertFunction(Register object); ++ ++ // Abort execution if argument is not a JSBoundFunction, ++ // enabled via --debug-code. ++ void AssertBoundFunction(Register object); ++ ++ // Abort execution if argument is not a JSGeneratorObject (or subclass), ++ // enabled via --debug-code. ++ void AssertGeneratorObject(Register object); ++ ++ // Abort execution if argument is not undefined or an AllocationSite, enabled ++ // via --debug-code. ++ void AssertUndefinedOrAllocationSite(Register object, Register scratch); ++ ++ template ++ void DecodeField(Register dst, Register src) { ++ Bstrpick_d(dst, src, Field::kShift + Field::kSize - 1, Field::kShift); ++ } ++ ++ template ++ void DecodeField(Register reg) { ++ DecodeField(reg, reg); ++ } ++ ++ private: ++ // Helper functions for generating invokes. ++ void InvokePrologue(Register expected_parameter_count, ++ Register actual_parameter_count, Label* done, ++ InvokeFlag flag); ++ ++ // Compute memory operands for safepoint stack slots. ++ static int SafepointRegisterStackIndex(int reg_code); ++ ++ // Needs access to SafepointRegisterStackIndex for compiled frame ++ // traversal. ++ friend class StandardFrame; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(MacroAssembler); ++}; ++ ++template ++void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count, ++ Func GetLabelFunction) { ++ // Ensure that dd-ed labels following this instruction use 8 bytes aligned ++ // addresses. ++ BlockTrampolinePoolFor(static_cast(case_count) * 2 + ++ kSwitchTablePrologueSize); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Align(8); // next is 4 instrs. ++ pcaddi(scratch, 4); ++ // alsl_d will do sa ++ alsl_d(scratch, index, scratch, kPointerSizeLog2); ++ Ld_d(scratch, MemOperand(scratch, 0)); ++ jirl(zero_reg, scratch, 0); ++ for (size_t index = 0; index < case_count; ++index) { ++ dd(GetLabelFunction(index)); ++ } ++} ++ ++#define ACCESS_MASM(masm) masm-> ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_LOONGARCH64_MACRO_ASSEMBLER_LOONGARCH64_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/loongarch64/register-loongarch64.h +@@ -0,0 +1,330 @@ ++// Copyright 2018 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ ++#define V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ ++ ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/register.h" ++#include "src/codegen/reglist.h" ++ ++namespace v8 { ++namespace internal { ++ ++// clang-format off ++#define GENERAL_REGISTERS(V) \ ++ V(zero_reg) V(ra) V(gp) V(sp) \ ++ V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) \ ++ V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) V(t7) V(t8) \ ++ V(tp) V(fp) \ ++ V(s0) V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) \ ++ ++#define ALLOCATABLE_GENERAL_REGISTERS(V) \ ++ V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) \ ++ V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(s7) ++ ++#define DOUBLE_REGISTERS(V) \ ++ V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ ++ V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) \ ++ V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ ++ V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) ++ ++#define FLOAT_REGISTERS DOUBLE_REGISTERS ++#define SIMD128_REGISTERS(V) \ ++ V(w0) V(w1) V(w2) V(w3) V(w4) V(w5) V(w6) V(w7) \ ++ V(w8) V(w9) V(w10) V(w11) V(w12) V(w13) V(w14) V(w15) \ ++ V(w16) V(w17) V(w18) V(w19) V(w20) V(w21) V(w22) V(w23) \ ++ V(w24) V(w25) V(w26) V(w27) V(w28) V(w29) V(w30) V(w31) ++ ++#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ ++ V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ ++ V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) V(f16) \ ++ V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) ++// clang-format on ++ ++// Note that the bit values must match those used in actual instruction ++// encoding. ++const int kNumRegs = 32; ++ ++const RegList kJSCallerSaved = 1 << 4 | // a0 ++ 1 << 5 | // a1 ++ 1 << 6 | // a2 ++ 1 << 7 | // a3 ++ 1 << 8 | // a4 ++ 1 << 9 | // a5 ++ 1 << 10 | // a6 ++ 1 << 11 | // a7 ++ 1 << 12 | // t0 ++ 1 << 13 | // t1 ++ 1 << 14 | // t2 ++ 1 << 15 | // t3 ++ 1 << 16 | // t4 ++ 1 << 17 | // t5 ++ 1 << 20; // t8 ++ ++const int kNumJSCallerSaved = 15; ++ ++// Callee-saved registers preserved when switching from C to JavaScript. ++const RegList kCalleeSaved = 1 << 22 | // fp ++ 1 << 23 | // s0 ++ 1 << 24 | // s1 ++ 1 << 25 | // s2 ++ 1 << 26 | // s3 ++ 1 << 27 | // s4 ++ 1 << 28 | // s5 ++ 1 << 29 | // s6 (roots in Javascript code) ++ 1 << 30 | // s7 (cp in Javascript code) ++ 1 << 31; // s8 ++ ++const int kNumCalleeSaved = 10; ++ ++const RegList kCalleeSavedFPU = 1 << 24 | // f24 ++ 1 << 25 | // f25 ++ 1 << 26 | // f26 ++ 1 << 27 | // f27 ++ 1 << 28 | // f28 ++ 1 << 29 | // f29 ++ 1 << 30 | // f30 ++ 1 << 31; // f31 ++ ++const int kNumCalleeSavedFPU = 8; ++ ++const RegList kCallerSavedFPU = 1 << 0 | // f0 ++ 1 << 1 | // f1 ++ 1 << 2 | // f2 ++ 1 << 3 | // f3 ++ 1 << 4 | // f4 ++ 1 << 5 | // f5 ++ 1 << 6 | // f6 ++ 1 << 7 | // f7 ++ 1 << 8 | // f8 ++ 1 << 9 | // f9 ++ 1 << 10 | // f10 ++ 1 << 11 | // f11 ++ 1 << 12 | // f12 ++ 1 << 13 | // f13 ++ 1 << 14 | // f14 ++ 1 << 15 | // f15 ++ 1 << 16 | // f16 ++ 1 << 17 | // f17 ++ 1 << 18 | // f18 ++ 1 << 19 | // f19 ++ 1 << 20 | // f20 ++ 1 << 21 | // f21 ++ 1 << 22 | // f22 ++ 1 << 23; // f23 ++ ++// Number of registers for which space is reserved in safepoints. Must be a ++// multiple of 8. ++const int kNumSafepointRegisters = 32; ++ ++// Define the list of registers actually saved at safepoints. ++// Note that the number of saved registers may be smaller than the reserved ++// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. ++const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; ++const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; ++ ++const int kUndefIndex = -1; ++// Map with indexes on stack that corresponds to codes of saved registers. ++const int kSafepointRegisterStackIndexMap[kNumRegs] = {kUndefIndex, // zero_reg ++ kUndefIndex, // ra ++ kUndefIndex, // gp ++ kUndefIndex, // sp ++ 0, // a0 ++ 1, // a1 ++ 2, // a2 ++ 3, // a3 ++ 4, // a4 ++ 5, // a5 ++ 6, // a6 ++ 7, // a7 ++ 8, // t0 ++ 9, // t1 ++ 10, // t2 ++ 11, // t3 ++ 12, // t4 ++ 13, // t5 ++ kUndefIndex, // t6 ++ kUndefIndex, // t7 ++ 14, // t8 ++ kUndefIndex, // tp ++ 15, // fp ++ 16, // s0 ++ 17, // s1 ++ 28, // s2 ++ 29, // s3 ++ 20, // s4 ++ 21, // s5 ++ 22, // s6 ++ 23, // s7 ++ 24}; // s8 ++ ++// CPU Registers. ++// ++// 1) We would prefer to use an enum, but enum values are assignment- ++// compatible with int, which has caused code-generation bugs. ++// ++// 2) We would prefer to use a class instead of a struct but we don't like ++// the register initialization to depend on the particular initialization ++// order (which appears to be different on OS X, Linux, and Windows for the ++// installed versions of C++ we tried). Using a struct permits C-style ++// "initialization". Also, the Register objects cannot be const as this ++// forces initialization stubs in MSVC, making us dependent on initialization ++// order. ++// ++// 3) By not using an enum, we are possibly preventing the compiler from ++// doing certain constant folds, which may significantly reduce the ++// code generated for some assembly instructions (because they boil down ++// to a few constants). If this is a problem, we could change the code ++// such that we use an enum in optimized mode, and the struct in debug ++// mode. This way we get the compile-time error checking in debug mode ++// and best performance in optimized code. ++ ++// ----------------------------------------------------------------------------- ++// Implementation of Register and FPURegister. ++ ++enum RegisterCode { ++#define REGISTER_CODE(R) kRegCode_##R, ++ GENERAL_REGISTERS(REGISTER_CODE) ++#undef REGISTER_CODE ++ kRegAfterLast ++}; ++ ++class Register : public RegisterBase { ++ public: ++ static constexpr int kMantissaOffset = 0; ++ static constexpr int kExponentOffset = 4; ++ ++ private: ++ friend class RegisterBase; ++ explicit constexpr Register(int code) : RegisterBase(code) {} ++}; ++ ++// s7: context register ++// s3: scratch register ++// s4: scratch register 2 ++#define DECLARE_REGISTER(R) \ ++ constexpr Register R = Register::from_code(kRegCode_##R); ++GENERAL_REGISTERS(DECLARE_REGISTER) ++#undef DECLARE_REGISTER ++ ++constexpr Register no_reg = Register::no_reg(); ++ ++int ToNumber(Register reg); ++ ++Register ToRegister(int num); ++ ++constexpr bool kPadArguments = false; ++constexpr bool kSimpleFPAliasing = true; ++constexpr bool kSimdMaskRegisters = false; ++ ++enum DoubleRegisterCode { ++#define REGISTER_CODE(R) kDoubleCode_##R, ++ DOUBLE_REGISTERS(REGISTER_CODE) ++#undef REGISTER_CODE ++ kDoubleAfterLast ++}; ++ ++// Coprocessor register. ++class FPURegister : public RegisterBase { ++ public: ++ FPURegister low() const { ++ // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. ++ // Find low reg of a Double-reg pair, which is the reg itself. ++ DCHECK_EQ(code() % 2, 0); // Specified Double reg must be even. ++ return FPURegister::from_code(code()); ++ } ++ ++ private: ++ friend class RegisterBase; ++ explicit constexpr FPURegister(int code) : RegisterBase(code) {} ++}; ++ ++enum CFRegister { FCC0, FCC1, FCC2, FCC3, FCC4, FCC5, FCC6, FCC7 }; ++ ++using FloatRegister = FPURegister; ++ ++using DoubleRegister = FPURegister; ++ ++// TODO here only for build success ++using Simd128Register = FPURegister; ++ ++#define DECLARE_DOUBLE_REGISTER(R) \ ++ constexpr DoubleRegister R = DoubleRegister::from_code(kDoubleCode_##R); ++DOUBLE_REGISTERS(DECLARE_DOUBLE_REGISTER) ++#undef DECLARE_DOUBLE_REGISTER ++ ++constexpr DoubleRegister no_dreg = DoubleRegister::no_reg(); ++ ++// Register aliases. ++// cp is assumed to be a callee saved register. ++constexpr Register kRootRegister = s6; ++constexpr Register cp = s7; ++constexpr Register kScratchReg = s3; ++constexpr Register kScratchReg2 = s4; ++constexpr DoubleRegister kScratchDoubleReg = f30; ++// FPU zero reg is often used to hold 0.0, but it's not hardwired to 0.0. ++constexpr DoubleRegister kDoubleRegZero = f28; ++ ++// FPU (coprocessor 1) control registers. ++// Currently only FCSR0 is implemented. ++// TODO fscr0 fcsr1 fcsr2 fscsr3 ++struct FPUControlRegister { ++ bool is_valid() const { return reg_code == kFCSRRegister; } ++ bool is(FPUControlRegister creg) const { return reg_code == creg.reg_code; } ++ int code() const { ++ DCHECK(is_valid()); ++ return reg_code; ++ } ++ int bit() const { ++ DCHECK(is_valid()); ++ return 1 << reg_code; ++ } ++ void setcode(int f) { ++ reg_code = f; ++ DCHECK(is_valid()); ++ } ++ // Unfortunately we can't make this private in a struct. ++ int reg_code; ++}; ++ ++constexpr FPUControlRegister no_fpucreg = {kInvalidFPUControlRegister}; ++constexpr FPUControlRegister FCSR = {kFCSRRegister}; ++ ++// Define {RegisterName} methods for the register types. ++DEFINE_REGISTER_NAMES(Register, GENERAL_REGISTERS) ++DEFINE_REGISTER_NAMES(FPURegister, DOUBLE_REGISTERS) ++ ++// Give alias names to registers for calling conventions. ++constexpr Register kReturnRegister0 = a0; ++constexpr Register kReturnRegister1 = a1; ++constexpr Register kReturnRegister2 = a2; ++constexpr Register kJSFunctionRegister = a1; ++constexpr Register kContextRegister = s7; ++constexpr Register kAllocateSizeRegister = a0; ++constexpr Register kSpeculationPoisonRegister = t3; ++constexpr Register kInterpreterAccumulatorRegister = a0; ++constexpr Register kInterpreterBytecodeOffsetRegister = t0; ++constexpr Register kInterpreterBytecodeArrayRegister = t1; ++constexpr Register kInterpreterDispatchTableRegister = t2; ++ ++constexpr Register kJavaScriptCallArgCountRegister = a0; ++constexpr Register kJavaScriptCallCodeStartRegister = a2; ++constexpr Register kJavaScriptCallTargetRegister = kJSFunctionRegister; ++constexpr Register kJavaScriptCallNewTargetRegister = a3; ++constexpr Register kJavaScriptCallExtraArg1Register = a2; ++ ++constexpr Register kOffHeapTrampolineRegister = t7; ++constexpr Register kRuntimeCallFunctionRegister = a1; ++constexpr Register kRuntimeCallArgCountRegister = a0; ++constexpr Register kRuntimeCallArgvRegister = a2; ++constexpr Register kWasmInstanceRegister = a0; ++constexpr Register kWasmCompileLazyFuncIndexRegister = t0; ++ ++constexpr DoubleRegister kFPReturnRegister0 = f0; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_LOONGARCH64_REGISTER_LOONGARCH64_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h +@@ -49,6 +49,9 @@ enum AllocationFlags { + #elif V8_TARGET_ARCH_MIPS64 + #include "src/codegen/mips64/constants-mips64.h" + #include "src/codegen/mips64/macro-assembler-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/loongarch64/macro-assembler-loongarch64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/constants-s390.h" + #include "src/codegen/s390/macro-assembler-s390.h" +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/src/codegen/macro-assembler.h +++++ src/3rdparty/chromium/v8/src/codegen/macro-assembler.h ++@@ -49,6 +49,9 @@ enum AllocationFlags { ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/codegen/mips64/constants-mips64.h" ++ #include "src/codegen/mips64/macro-assembler-mips64.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/codegen/loongarch64/constants-loongarch64.h" +++#include "src/codegen/loongarch64/macro-assembler-loongarch64.h" ++ #elif V8_TARGET_ARCH_S390 ++ #include "src/codegen/s390/constants-s390.h" ++ #include "src/codegen/s390/macro-assembler-s390.h" +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/register-arch.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/register-arch.h +@@ -22,6 +22,8 @@ + #include "src/codegen/mips/register-mips.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/codegen/mips64/register-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/codegen/loongarch64/register-loongarch64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/register-s390.h" + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/register-arch.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/register-arch.h +++++ src/3rdparty/chromium/v8/src/codegen/register-arch.h ++@@ -22,6 +22,8 @@ ++ #include "src/codegen/mips/register-mips.h" ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/codegen/mips64/register-mips64.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/codegen/loongarch64/register-loongarch64.h" ++ #elif V8_TARGET_ARCH_S390 ++ #include "src/codegen/s390/register-s390.h" ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc +@@ -58,6 +58,8 @@ static int get_num_allocatable_double_re + kMaxAllocatableDoubleRegisterCount; + #elif V8_TARGET_ARCH_MIPS64 + kMaxAllocatableDoubleRegisterCount; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ kMaxAllocatableDoubleRegisterCount; + #elif V8_TARGET_ARCH_PPC + kMaxAllocatableDoubleRegisterCount; + #elif V8_TARGET_ARCH_PPC64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/codegen/register-configuration.cc +++++ src/3rdparty/chromium/v8/src/codegen/register-configuration.cc ++@@ -58,6 +58,8 @@ static int get_num_allocatable_double_registers() { ++ kMaxAllocatableDoubleRegisterCount; ++ #elif V8_TARGET_ARCH_MIPS64 ++ kMaxAllocatableDoubleRegisterCount; +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ kMaxAllocatableDoubleRegisterCount; ++ #elif V8_TARGET_ARCH_PPC ++ kMaxAllocatableDoubleRegisterCount; ++ #elif V8_TARGET_ARCH_PPC64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc +@@ -330,7 +330,8 @@ bool RelocInfo::OffHeapTargetIsCodedSpec + return false; + #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \ + defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) || \ +- defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) ++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) || \ ++ defined(V8_TARGET_ARCH_LOONGARCH64) + return true; + #endif + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/src/codegen/reloc-info.cc +++++ src/3rdparty/chromium/v8/src/codegen/reloc-info.cc ++@@ -330,7 +330,8 @@ bool RelocInfo::OffHeapTargetIsCodedSpecially() { ++ return false; ++ #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \ ++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) || \ ++- defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) +++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) || \ +++ defined(V8_TARGET_ARCH_LOONGARCH64) ++ return true; ++ #endif ++ } +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/common/globals.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/common/globals.h +@@ -58,6 +58,9 @@ constexpr int GB = MB * 1024; + #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) + #define USE_SIMULATOR 1 + #endif ++#if (V8_TARGET_ARCH_LOONGARCH64 && !V8_HOST_ARCH_LOONGARCH64) ++#define USE_SIMULATOR 1 ++#endif + #endif + + // Determine whether the architecture uses an embedded constant pool +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/common/globals.h.rej +@@ -0,0 +1,12 @@ ++--- src/3rdparty/chromium/v8/src/common/globals.h +++++ src/3rdparty/chromium/v8/src/common/globals.h ++@@ -58,6 +58,9 @@ constexpr int GB = MB * 1024; ++ #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) ++ #define USE_SIMULATOR 1 ++ #endif +++#if (V8_TARGET_ARCH_LOONGARCH64 && !V8_HOST_ARCH_LOONGARCH64) +++#define USE_SIMULATOR 1 +++#endif ++ #endif ++ ++ // Determine whether the architecture uses an embedded constant pool +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h +@@ -17,6 +17,8 @@ + #include "src/compiler/backend/mips/instruction-codes-mips.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/compiler/backend/mips64/instruction-codes-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h" + #elif V8_TARGET_ARCH_X64 + #include "src/compiler/backend/x64/instruction-codes-x64.h" + #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h +++++ src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h ++@@ -17,6 +17,8 @@ ++ #include "src/compiler/backend/mips/instruction-codes-mips.h" ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/compiler/backend/mips64/instruction-codes-mips64.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/compiler/backend/loongarch64/instruction-codes-loongarch64.h" ++ #elif V8_TARGET_ARCH_X64 ++ #include "src/compiler/backend/x64/instruction-codes-x64.h" ++ #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc +@@ -2624,7 +2624,7 @@ void InstructionSelector::VisitWord32Ato + #endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS + + #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && \ +- !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 ++ !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_LOONGARCH64 + void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); } + + void InstructionSelector::VisitWord64AtomicStore(Node* node) { +@@ -2649,7 +2649,8 @@ void InstructionSelector::VisitWord64Ato + UNIMPLEMENTED(); + } + #endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_PPC64 +- // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 ++ // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 && ++ // !V8_TARGET_ARCH_LOONGARCH64 + + #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM + // This is only needed on 32-bit to split the 64-bit value into two operands. +@@ -2663,11 +2664,11 @@ void InstructionSelector::VisitI64x2Repl + + #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_S390X + #if !V8_TARGET_ARCH_ARM64 +-#if !V8_TARGET_ARCH_MIPS64 ++#if !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 + void InstructionSelector::VisitI64x2Splat(Node* node) { UNIMPLEMENTED(); } + void InstructionSelector::VisitI64x2ExtractLane(Node* node) { UNIMPLEMENTED(); } + void InstructionSelector::VisitI64x2ReplaceLane(Node* node) { UNIMPLEMENTED(); } +-#endif // !V8_TARGET_ARCH_MIPS64 ++#endif // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 + void InstructionSelector::VisitI64x2Eq(Node* node) { UNIMPLEMENTED(); } + void InstructionSelector::VisitI64x2Ne(Node* node) { UNIMPLEMENTED(); } + void InstructionSelector::VisitI64x2GtS(Node* node) { UNIMPLEMENTED(); } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc.rej +@@ -0,0 +1,35 @@ ++--- src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc +++++ src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc ++@@ -2624,7 +2624,7 @@ void InstructionSelector::VisitWord32AtomicPairCompareExchange(Node* node) { ++ #endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS ++ ++ #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && \ ++- !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 +++ !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_LOONGARCH64 ++ void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); } ++ ++ void InstructionSelector::VisitWord64AtomicStore(Node* node) { ++@@ -2649,7 +2649,8 @@ void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { ++ UNIMPLEMENTED(); ++ } ++ #endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_PPC64 ++- // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 +++ // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 && +++ // !V8_TARGET_ARCH_LOONGARCH64 ++ ++ #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM ++ // This is only needed on 32-bit to split the 64-bit value into two operands. ++@@ -2663,11 +2664,11 @@ void InstructionSelector::VisitI64x2ReplaceLaneI32Pair(Node* node) { ++ ++ #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_S390X ++ #if !V8_TARGET_ARCH_ARM64 ++-#if !V8_TARGET_ARCH_MIPS64 +++#if !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 ++ void InstructionSelector::VisitI64x2Splat(Node* node) { UNIMPLEMENTED(); } ++ void InstructionSelector::VisitI64x2ExtractLane(Node* node) { UNIMPLEMENTED(); } ++ void InstructionSelector::VisitI64x2ReplaceLane(Node* node) { UNIMPLEMENTED(); } ++-#endif // !V8_TARGET_ARCH_MIPS64 +++#endif // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_LOONGARCH64 ++ void InstructionSelector::VisitI64x2Eq(Node* node) { UNIMPLEMENTED(); } ++ void InstructionSelector::VisitI64x2Ne(Node* node) { UNIMPLEMENTED(); } ++ void InstructionSelector::VisitI64x2GtS(Node* node) { UNIMPLEMENTED(); } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/code-generator-loongarch64.cc +@@ -0,0 +1,2846 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/callable.h" ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/optimized-compilation-info.h" ++#include "src/compiler/backend/code-generator-impl.h" ++#include "src/compiler/backend/code-generator.h" ++#include "src/compiler/backend/gap-resolver.h" ++#include "src/compiler/node-matchers.h" ++#include "src/compiler/osr.h" ++#include "src/heap/memory-chunk.h" ++#include "src/wasm/wasm-code-manager.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++#define __ tasm()-> ++ ++// TODO(plind): consider renaming these macros. ++#define TRACE_MSG(msg) \ ++ PrintF("code_gen: \'%s\' in function %s at line %d\n", msg, __FUNCTION__, \ ++ __LINE__) ++ ++#define TRACE_UNIMPL() \ ++ PrintF("UNIMPLEMENTED code_generator_la64: %s at line %d\n", __FUNCTION__, \ ++ __LINE__) ++ ++// Adds La64-specific methods to convert InstructionOperands. ++class La64OperandConverter final : public InstructionOperandConverter { ++ public: ++ La64OperandConverter(CodeGenerator* gen, Instruction* instr) ++ : InstructionOperandConverter(gen, instr) {} ++ ++ FloatRegister OutputSingleRegister(size_t index = 0) { ++ return ToSingleRegister(instr_->OutputAt(index)); ++ } ++ ++ FloatRegister InputSingleRegister(size_t index) { ++ return ToSingleRegister(instr_->InputAt(index)); ++ } ++ ++ FloatRegister ToSingleRegister(InstructionOperand* op) { ++ // Single (Float) and Double register namespace is same on LA64, ++ // both are typedefs of FPURegister. ++ return ToDoubleRegister(op); ++ } ++ ++ Register InputOrZeroRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) { ++ DCHECK_EQ(0, InputInt32(index)); ++ return zero_reg; ++ } ++ return InputRegister(index); ++ } ++ ++ DoubleRegister InputOrZeroDoubleRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; ++ ++ return InputDoubleRegister(index); ++ } ++ ++ DoubleRegister InputOrZeroSingleRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; ++ ++ return InputSingleRegister(index); ++ } ++ ++ Operand InputImmediate(size_t index) { ++ Constant constant = ToConstant(instr_->InputAt(index)); ++ switch (constant.type()) { ++ case Constant::kInt32: ++ return Operand(constant.ToInt32()); ++ case Constant::kInt64: ++ return Operand(constant.ToInt64()); ++ case Constant::kFloat32: ++ return Operand::EmbeddedNumber(constant.ToFloat32()); ++ case Constant::kFloat64: ++ return Operand::EmbeddedNumber(constant.ToFloat64().value()); ++ case Constant::kExternalReference: ++ case Constant::kCompressedHeapObject: ++ case Constant::kHeapObject: ++ // TODO(plind): Maybe we should handle ExtRef & HeapObj here? ++ // maybe not done on arm due to const pool ?? ++ break; ++ case Constant::kDelayedStringConstant: ++ return Operand::EmbeddedStringConstant( ++ constant.ToDelayedStringConstant()); ++ case Constant::kRpoNumber: ++ UNREACHABLE(); // TODO(titzer): RPO immediates on la64? ++ break; ++ } ++ UNREACHABLE(); ++ } ++ ++ Operand InputOperand(size_t index) { ++ InstructionOperand* op = instr_->InputAt(index); ++ if (op->IsRegister()) { ++ return Operand(ToRegister(op)); ++ } ++ return InputImmediate(index); ++ } ++ ++ MemOperand MemoryOperand(size_t* first_index) { ++ const size_t index = *first_index; ++ switch (AddressingModeField::decode(instr_->opcode())) { ++ case kMode_None: ++ break; ++ case kMode_MRI: ++ *first_index += 2; ++ return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); ++ case kMode_MRR: ++ *first_index += 2; ++ return MemOperand(InputRegister(index + 0), InputRegister(index + 1)); ++ } ++ UNREACHABLE(); ++ } ++ ++ MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } ++ ++ MemOperand ToMemOperand(InstructionOperand* op) const { ++ DCHECK_NOT_NULL(op); ++ DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); ++ return SlotToMemOperand(AllocatedOperand::cast(op)->index()); ++ } ++ ++ MemOperand SlotToMemOperand(int slot) const { ++ FrameOffset offset = frame_access_state()->GetFrameOffset(slot); ++ return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); ++ } ++}; ++ ++static inline bool HasRegisterInput(Instruction* instr, size_t index) { ++ return instr->InputAt(index)->IsRegister(); ++} ++ ++namespace { ++ ++class OutOfLineRecordWrite final : public OutOfLineCode { ++ public: ++ OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, ++ Register value, Register scratch0, Register scratch1, ++ RecordWriteMode mode, StubCallMode stub_mode) ++ : OutOfLineCode(gen), ++ object_(object), ++ index_(index), ++ value_(value), ++ scratch0_(scratch0), ++ scratch1_(scratch1), ++ mode_(mode), ++ stub_mode_(stub_mode), ++ must_save_lr_(!gen->frame_access_state()->has_frame()), ++ zone_(gen->zone()) {} ++ ++ void Generate() final { ++ if (mode_ > RecordWriteMode::kValueIsPointer) { ++ __ JumpIfSmi(value_, exit()); ++ } ++ __ CheckPageFlag(value_, scratch0_, ++ MemoryChunk::kPointersToHereAreInterestingMask, eq, ++ exit()); ++ __ Add_d(scratch1_, object_, index_); ++ RememberedSetAction const remembered_set_action = ++ mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET ++ : OMIT_REMEMBERED_SET; ++ SaveFPRegsMode const save_fp_mode = ++ frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; ++ if (must_save_lr_) { ++ // We need to save and restore ra if the frame was elided. ++ __ Push(ra); ++ } ++ if (mode_ == RecordWriteMode::kValueIsEphemeronKey) { ++ __ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode); ++ } else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) { ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched when the code ++ // is added to the native module and copied into wasm code space. ++ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, ++ save_fp_mode, wasm::WasmCode::kRecordWrite); ++ } else { ++ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, ++ save_fp_mode); ++ } ++ if (must_save_lr_) { ++ __ Pop(ra); ++ } ++ } ++ ++ private: ++ Register const object_; ++ Register const index_; ++ Register const value_; ++ Register const scratch0_; ++ Register const scratch1_; ++ RecordWriteMode const mode_; ++ StubCallMode const stub_mode_; ++ bool must_save_lr_; ++ Zone* zone_; ++}; ++ ++#define CREATE_OOL_CLASS(ool_name, tasm_ool_name, T) \ ++ class ool_name final : public OutOfLineCode { \ ++ public: \ ++ ool_name(CodeGenerator* gen, T dst, T src1, T src2) \ ++ : OutOfLineCode(gen), dst_(dst), src1_(src1), src2_(src2) {} \ ++ \ ++ void Generate() final { __ tasm_ool_name(dst_, src1_, src2_); } \ ++ \ ++ private: \ ++ T const dst_; \ ++ T const src1_; \ ++ T const src2_; \ ++ } ++ ++CREATE_OOL_CLASS(OutOfLineFloat32Max, Float32MaxOutOfLine, FPURegister); ++CREATE_OOL_CLASS(OutOfLineFloat32Min, Float32MinOutOfLine, FPURegister); ++CREATE_OOL_CLASS(OutOfLineFloat64Max, Float64MaxOutOfLine, FPURegister); ++CREATE_OOL_CLASS(OutOfLineFloat64Min, Float64MinOutOfLine, FPURegister); ++ ++#undef CREATE_OOL_CLASS ++ ++Condition FlagsConditionToConditionCmp(FlagsCondition condition) { ++ switch (condition) { ++ case kEqual: ++ return eq; ++ case kNotEqual: ++ return ne; ++ case kSignedLessThan: ++ return lt; ++ case kSignedGreaterThanOrEqual: ++ return ge; ++ case kSignedLessThanOrEqual: ++ return le; ++ case kSignedGreaterThan: ++ return gt; ++ case kUnsignedLessThan: ++ return lo; ++ case kUnsignedGreaterThanOrEqual: ++ return hs; ++ case kUnsignedLessThanOrEqual: ++ return ls; ++ case kUnsignedGreaterThan: ++ return hi; ++ case kUnorderedEqual: ++ case kUnorderedNotEqual: ++ break; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++Condition FlagsConditionToConditionTst(FlagsCondition condition) { ++ switch (condition) { ++ case kNotEqual: ++ return ne; ++ case kEqual: ++ return eq; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++Condition FlagsConditionToConditionOvf(FlagsCondition condition) { ++ switch (condition) { ++ case kOverflow: ++ return ne; ++ case kNotOverflow: ++ return eq; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++FPUCondition FlagsConditionToConditionCmpFPU(bool* predicate, ++ FlagsCondition condition) { ++ switch (condition) { ++ case kEqual: ++ *predicate = true; ++ return CEQ; ++ case kNotEqual: ++ *predicate = false; ++ return CEQ; ++ case kUnsignedLessThan: ++ *predicate = true; ++ return CLT; ++ case kUnsignedGreaterThanOrEqual: ++ *predicate = false; ++ return CLT; ++ case kUnsignedLessThanOrEqual: ++ *predicate = true; ++ return CLE; ++ case kUnsignedGreaterThan: ++ *predicate = false; ++ return CLE; ++ case kUnorderedEqual: ++ case kUnorderedNotEqual: ++ *predicate = true; ++ break; ++ default: ++ *predicate = true; ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, ++ InstructionCode opcode, Instruction* instr, ++ La64OperandConverter const& i) { ++ const MemoryAccessMode access_mode = ++ static_cast(MiscField::decode(opcode)); ++ if (access_mode == kMemoryAccessPoisoned) { ++ Register value = i.OutputRegister(); ++ codegen->tasm()->And(value, value, kSpeculationPoisonRegister); ++ } ++} ++ ++} // namespace ++ ++#define ASSEMBLE_ATOMIC_LOAD_INTEGER(asm_instr) \ ++ do { \ ++ __ asm_instr(i.OutputRegister(), i.MemoryOperand()); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// TODO remove second dbar? ++#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ ++ do { \ ++ __ dbar(0); \ ++ __ asm_instr(i.InputOrZeroRegister(2), i.MemoryOperand()); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// only use for sub_w and sub_d ++#define ASSEMBLE_ATOMIC_BINOP(load_linked, store_conditional, bin_instr) \ ++ do { \ ++ Label binop; \ ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ __ dbar(0); \ ++ __ bind(&binop); \ ++ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ ++ __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \ ++ Operand(i.InputRegister(2))); \ ++ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&binop, eq, i.TempRegister(1), Operand(zero_reg)); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// TODO remove second dbar? ++#define ASSEMBLE_ATOMIC_BINOP_EXT(load_linked, store_conditional, sign_extend, \ ++ size, bin_instr, representation) \ ++ do { \ ++ Label binop; \ ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ andi(i.TempRegister(3), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ andi(i.TempRegister(3), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(3))); \ ++ __ slli_w(i.TempRegister(3), i.TempRegister(3), 3); \ ++ __ dbar(0); \ ++ __ bind(&binop); \ ++ __ load_linked(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(1), i.TempRegister(3), \ ++ size, sign_extend); \ ++ __ bin_instr(i.TempRegister(2), i.OutputRegister(0), \ ++ Operand(i.InputRegister(2))); \ ++ __ InsertBits(i.TempRegister(1), i.TempRegister(2), i.TempRegister(3), \ ++ size); \ ++ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&binop, eq, i.TempRegister(1), Operand(zero_reg)); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// TODO remove second dbar? ++#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT( \ ++ load_linked, store_conditional, sign_extend, size, representation) \ ++ do { \ ++ Label exchange; \ ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ andi(i.TempRegister(1), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ andi(i.TempRegister(1), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(1))); \ ++ __ slli_w(i.TempRegister(1), i.TempRegister(1), 3); \ ++ __ dbar(0); \ ++ __ bind(&exchange); \ ++ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ InsertBits(i.TempRegister(2), i.InputRegister(2), i.TempRegister(1), \ ++ size); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&exchange, eq, i.TempRegister(2), Operand(zero_reg)); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// TODO remove second dbar? ++#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_linked, \ ++ store_conditional) \ ++ do { \ ++ Label compareExchange; \ ++ Label exit; \ ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ __ dbar(0); \ ++ __ bind(&compareExchange); \ ++ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&exit, ne, i.InputRegister(2), \ ++ Operand(i.OutputRegister(0))); \ ++ __ mov(i.TempRegister(2), i.InputRegister(3)); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&compareExchange, eq, i.TempRegister(2), \ ++ Operand(zero_reg)); \ ++ __ bind(&exit); \ ++ __ dbar(0); \ ++ } while (0) ++ ++// TODO remove second dbar? ++#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT( \ ++ load_linked, store_conditional, sign_extend, size, representation) \ ++ do { \ ++ Label compareExchange; \ ++ Label exit; \ ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ andi(i.TempRegister(1), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ andi(i.TempRegister(1), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub_d(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(1))); \ ++ __ slli_w(i.TempRegister(1), i.TempRegister(1), 3); \ ++ __ dbar(0); \ ++ __ bind(&compareExchange); \ ++ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ ExtractBits(i.InputRegister(2), i.InputRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ BranchShort(&exit, ne, i.InputRegister(2), \ ++ Operand(i.OutputRegister(0))); \ ++ __ InsertBits(i.TempRegister(2), i.InputRegister(3), i.TempRegister(1), \ ++ size); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&compareExchange, eq, i.TempRegister(2), \ ++ Operand(zero_reg)); \ ++ __ bind(&exit); \ ++ __ dbar(0); \ ++ } while (0) ++ ++#define ASSEMBLE_IEEE754_BINOP(name) \ ++ do { \ ++ FrameScope scope(tasm(), StackFrame::MANUAL); \ ++ __ PrepareCallCFunction(0, 2, kScratchReg); \ ++ __ MovToFloatParameters(i.InputDoubleRegister(0), \ ++ i.InputDoubleRegister(1)); \ ++ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 2); \ ++ /* Move the result in the double result register. */ \ ++ __ MovFromFloatResult(i.OutputDoubleRegister()); \ ++ } while (0) ++ ++#define ASSEMBLE_IEEE754_UNOP(name) \ ++ do { \ ++ FrameScope scope(tasm(), StackFrame::MANUAL); \ ++ __ PrepareCallCFunction(0, 1, kScratchReg); \ ++ __ MovToFloatParameter(i.InputDoubleRegister(0)); \ ++ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 1); \ ++ /* Move the result in the double result register. */ \ ++ __ MovFromFloatResult(i.OutputDoubleRegister()); \ ++ } while (0) ++ ++#define ASSEMBLE_F64X2_ARITHMETIC_BINOP(op) \ ++ do { \ ++ __ op(i.OutputSimd128Register(), i.InputSimd128Register(0), \ ++ i.InputSimd128Register(1)); \ ++ } while (0) ++ ++void CodeGenerator::AssembleDeconstructFrame() { ++ __ mov(sp, fp); ++ __ Pop(ra, fp); ++} ++ ++void CodeGenerator::AssemblePrepareTailCall() { ++ if (frame_access_state()->has_frame()) { ++ __ Ld_d(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); ++ __ Ld_d(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ } ++ frame_access_state()->SetFrameAccessToSP(); ++} ++ ++void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ++ Register scratch1, ++ Register scratch2, ++ Register scratch3) { ++ DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); ++ Label done; ++ ++ // Check if current frame is an arguments adaptor frame. ++ __ Ld_d(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset)); ++ __ Branch(&done, ne, scratch3, ++ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ ++ // Load arguments count from current arguments adaptor frame (note, it ++ // does not include receiver). ++ Register caller_args_count_reg = scratch1; ++ __ Ld_d(caller_args_count_reg, ++ MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ __ SmiUntag(caller_args_count_reg); ++ ++ __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3); ++ __ bind(&done); ++} ++ ++namespace { ++ ++void AdjustStackPointerForTailCall(TurboAssembler* tasm, ++ FrameAccessState* state, ++ int new_slot_above_sp, ++ bool allow_shrinkage = true) { ++ int current_sp_offset = state->GetSPToFPSlotCount() + ++ StandardFrameConstants::kFixedSlotCountAboveFp; ++ int stack_slot_delta = new_slot_above_sp - current_sp_offset; ++ if (stack_slot_delta > 0) { ++ tasm->Sub_d(sp, sp, stack_slot_delta * kSystemPointerSize); ++ state->IncreaseSPDelta(stack_slot_delta); ++ } else if (allow_shrinkage && stack_slot_delta < 0) { ++ tasm->Add_d(sp, sp, -stack_slot_delta * kSystemPointerSize); ++ state->IncreaseSPDelta(stack_slot_delta); ++ } ++} ++ ++} // namespace ++ ++void CodeGenerator::AssembleTailCallBeforeGap(Instruction* instr, ++ int first_unused_stack_slot) { ++ AdjustStackPointerForTailCall(tasm(), frame_access_state(), ++ first_unused_stack_slot, false); ++} ++ ++void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr, ++ int first_unused_stack_slot) { ++ AdjustStackPointerForTailCall(tasm(), frame_access_state(), ++ first_unused_stack_slot); ++} ++ ++// Check that {kJavaScriptCallCodeStartRegister} is correct. ++void CodeGenerator::AssembleCodeStartRegisterCheck() { ++ __ ComputeCodeStartAddress(kScratchReg); ++ __ Assert(eq, AbortReason::kWrongFunctionCodeStart, ++ kJavaScriptCallCodeStartRegister, Operand(kScratchReg)); ++} ++ ++// Check if the code object is marked for deoptimization. If it is, then it ++// jumps to the CompileLazyDeoptimizedCode builtin. In order to do this we need ++// to: ++// 1. read from memory the word that contains that bit, which can be found in ++// the flags in the referenced {CodeDataContainer} object; ++// 2. test kMarkedForDeoptimizationBit in those flags; and ++// 3. if it is not zero then it jumps to the builtin. ++void CodeGenerator::BailoutIfDeoptimized() { ++ int offset = Code::kCodeDataContainerOffset - Code::kHeaderSize; ++ __ Ld_d(kScratchReg, MemOperand(kJavaScriptCallCodeStartRegister, offset)); ++ __ Ld_w(kScratchReg, ++ FieldMemOperand(kScratchReg, ++ CodeDataContainer::kKindSpecificFlagsOffset)); ++ __ And(kScratchReg, kScratchReg, ++ Operand(1 << Code::kMarkedForDeoptimizationBit)); ++ __ Jump(BUILTIN_CODE(isolate(), CompileLazyDeoptimizedCode), ++ RelocInfo::CODE_TARGET, ne, kScratchReg, Operand(zero_reg)); ++} ++ ++void CodeGenerator::GenerateSpeculationPoisonFromCodeStartRegister() { ++ // Calculate a mask which has all bits set in the normal case, but has all ++ // bits cleared if we are speculatively executing the wrong PC. ++ __ li(kSpeculationPoisonRegister, -1); ++ __ ComputeCodeStartAddress(kScratchReg); ++ __ sub_d(kScratchReg, kScratchReg, kJavaScriptCallCodeStartRegister); ++ __ maskeqz(kSpeculationPoisonRegister, kSpeculationPoisonRegister, ++ kScratchReg); ++} ++ ++void CodeGenerator::AssembleRegisterArgumentPoisoning() { ++ __ And(kJSFunctionRegister, kJSFunctionRegister, kSpeculationPoisonRegister); ++ __ And(kContextRegister, kContextRegister, kSpeculationPoisonRegister); ++ __ And(sp, sp, kSpeculationPoisonRegister); ++} ++ ++// Assembles an instruction after register allocation, producing machine code. ++CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ++ Instruction* instr) { ++ La64OperandConverter i(this, instr); ++ InstructionCode opcode = instr->opcode(); ++ ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); ++ switch (arch_opcode) { ++ case kArchCallCodeObject: { ++ if (instr->InputAt(0)->IsImmediate()) { ++ __ Call(i.InputCode(0), RelocInfo::CODE_TARGET); ++ } else { ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ addi_d(reg, reg, Code::kHeaderSize - kHeapObjectTag); ++ __ Call(reg); ++ } ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchCallBuiltinPointer: { ++ DCHECK(!instr->InputAt(0)->IsImmediate()); ++ Register builtin_index = i.InputRegister(0); ++ __ CallBuiltinByIndex(builtin_index); ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchCallWasmFunction: { ++ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { ++ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, ++ i.TempRegister(0), i.TempRegister(1), ++ i.TempRegister(2)); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ Constant constant = i.ToConstant(instr->InputAt(0)); ++ Address wasm_code = static_cast

(constant.ToInt64()); ++ __ Call(wasm_code, constant.rmode()); ++ } else { ++ __ addi_d(kScratchReg, i.InputRegister(0), 0); ++ __ Call(kScratchReg); ++ } ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchTailCallCodeObjectFromJSFunction: ++ case kArchTailCallCodeObject: { ++ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { ++ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, ++ i.TempRegister(0), i.TempRegister(1), ++ i.TempRegister(2)); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ __ Jump(i.InputCode(0), RelocInfo::CODE_TARGET); ++ } else { ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ addi_d(reg, reg, Code::kHeaderSize - kHeapObjectTag); ++ __ Jump(reg); ++ } ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchTailCallWasm: { ++ if (instr->InputAt(0)->IsImmediate()) { ++ Constant constant = i.ToConstant(instr->InputAt(0)); ++ Address wasm_code = static_cast
(constant.ToInt64()); ++ __ Jump(wasm_code, constant.rmode()); ++ } else { ++ __ addi_d(kScratchReg, i.InputRegister(0), 0); ++ __ Jump(kScratchReg); ++ } ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchTailCallAddress: { ++ CHECK(!instr->InputAt(0)->IsImmediate()); ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ Jump(reg); ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchCallJSFunction: { ++ Register func = i.InputRegister(0); ++ if (FLAG_debug_code) { ++ // Check the function's context matches the context argument. ++ __ Ld_d(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); ++ __ Assert(eq, AbortReason::kWrongFunctionContext, cp, ++ Operand(kScratchReg)); ++ } ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld_d(a2, FieldMemOperand(func, JSFunction::kCodeOffset)); ++ __ Add_d(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Call(a2); ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchPrepareCallCFunction: { ++ int const num_parameters = MiscField::decode(instr->opcode()); ++ __ PrepareCallCFunction(num_parameters, kScratchReg); ++ // Frame alignment requires using FP-relative frame addressing. ++ frame_access_state()->SetFrameAccessToFP(); ++ break; ++ } ++ case kArchSaveCallerRegisters: { ++ fp_mode_ = ++ static_cast(MiscField::decode(instr->opcode())); ++ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); ++ // kReturnRegister0 should have been saved before entering the stub. ++ int bytes = __ PushCallerSaved(fp_mode_, kReturnRegister0); ++ DCHECK(IsAligned(bytes, kSystemPointerSize)); ++ DCHECK_EQ(0, frame_access_state()->sp_delta()); ++ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); ++ DCHECK(!caller_registers_saved_); ++ caller_registers_saved_ = true; ++ break; ++ } ++ case kArchRestoreCallerRegisters: { ++ DCHECK(fp_mode_ == ++ static_cast(MiscField::decode(instr->opcode()))); ++ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); ++ // Don't overwrite the returned value. ++ int bytes = __ PopCallerSaved(fp_mode_, kReturnRegister0); ++ frame_access_state()->IncreaseSPDelta(-(bytes / kSystemPointerSize)); ++ DCHECK_EQ(0, frame_access_state()->sp_delta()); ++ DCHECK(caller_registers_saved_); ++ caller_registers_saved_ = false; ++ break; ++ } ++ case kArchPrepareTailCall: ++ AssemblePrepareTailCall(); ++ break; ++ case kArchCallCFunction: { ++ int const num_parameters = MiscField::decode(instr->opcode()); ++ Label start_call; ++ bool isWasmCapiFunction = ++ linkage()->GetIncomingDescriptor()->IsWasmCapiFunction(); ++ // from start_call to return address. ++ int offset = __ root_array_available() ? 44 : 80; // 11 or 20 instrs ++#if V8_HOST_ARCH_LA64 ++ if (__ emit_debug_code()) { ++ offset += 12; // see CallCFunction ++ } ++#endif ++ if (isWasmCapiFunction) { ++ // Put the return address in a stack slot. ++ // __ mov(kScratchReg, ra); ++ __ bind(&start_call); ++ __ pcaddi(t7, -4); // __ nal(); ++ //__ nop(); ++ //__ Daddu(ra, ra, offset - 8); // 8 = nop + nal ++ __ St_d(t7, MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset)); ++ // __ mov(ra, kScratchReg); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ ExternalReference ref = i.InputExternalReference(0); ++ __ CallCFunction(ref, num_parameters); ++ } else { ++ Register func = i.InputRegister(0); ++ __ CallCFunction(func, num_parameters); ++ } ++ if (isWasmCapiFunction) { ++ CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call)); ++ RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt); ++ } ++ ++ frame_access_state()->SetFrameAccessToDefault(); ++ // Ideally, we should decrement SP delta to match the change of stack ++ // pointer in CallCFunction. However, for certain architectures (e.g. ++ // ARM), there may be more strict alignment requirement, causing old SP ++ // to be saved on the stack. In those cases, we can not calculate the SP ++ // delta statically. ++ frame_access_state()->ClearSPDelta(); ++ if (caller_registers_saved_) { ++ // Need to re-sync SP delta introduced in kArchSaveCallerRegisters. ++ // Here, we assume the sequence to be: ++ // kArchSaveCallerRegisters; ++ // kArchCallCFunction; ++ // kArchRestoreCallerRegisters; ++ int bytes = ++ __ RequiredStackSizeForCallerSaved(fp_mode_, kReturnRegister0); ++ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); ++ } ++ break; ++ } ++ case kArchJmp: ++ AssembleArchJump(i.InputRpo(0)); ++ break; ++ case kArchBinarySearchSwitch: ++ AssembleArchBinarySearchSwitch(instr); ++ break; ++ break; ++ case kArchTableSwitch: ++ AssembleArchTableSwitch(instr); ++ break; ++ case kArchAbortCSAAssert: ++ DCHECK(i.InputRegister(0) == a0); ++ { ++ // We don't actually want to generate a pile of code for this, so just ++ // claim there is a stack frame, without generating one. ++ FrameScope scope(tasm(), StackFrame::NONE); ++ __ Call( ++ isolate()->builtins()->builtin_handle(Builtins::kAbortCSAAssert), ++ RelocInfo::CODE_TARGET); ++ } ++ __ stop(); ++ break; ++ case kArchDebugBreak: ++ __ DebugBreak(); ++ break; ++ case kArchComment: ++ __ RecordComment(reinterpret_cast(i.InputInt64(0))); ++ break; ++ case kArchNop: ++ case kArchThrowTerminator: ++ // don't emit code for nops. ++ break; ++ case kArchDeoptimize: { ++ DeoptimizationExit* exit = ++ BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); ++ CodeGenResult result = AssembleDeoptimizerCall(exit); ++ if (result != kSuccess) return result; ++ break; ++ } ++ case kArchRet: ++ AssembleReturn(instr->InputAt(0)); ++ break; ++ case kArchStackPointerGreaterThan: ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kArchStackCheckOffset: ++ __ Move(i.OutputRegister(), Smi::FromInt(GetStackCheckOffset())); ++ break; ++ case kArchFramePointer: ++ __ mov(i.OutputRegister(), fp); ++ break; ++ case kArchParentFramePointer: ++ if (frame_access_state()->has_frame()) { ++ __ Ld_d(i.OutputRegister(), MemOperand(fp, 0)); ++ } else { ++ __ mov(i.OutputRegister(), fp); ++ } ++ break; ++ case kArchTruncateDoubleToI: ++ __ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(), ++ i.InputDoubleRegister(0), DetermineStubCallMode()); ++ break; ++ case kArchStoreWithWriteBarrier: { ++ RecordWriteMode mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ Register object = i.InputRegister(0); ++ Register index = i.InputRegister(1); ++ Register value = i.InputRegister(2); ++ Register scratch0 = i.TempRegister(0); ++ Register scratch1 = i.TempRegister(1); ++ auto ool = zone()->New(this, object, index, value, ++ scratch0, scratch1, mode, ++ DetermineStubCallMode()); ++ __ Add_d(kScratchReg, object, index); ++ __ St_d(value, MemOperand(kScratchReg, 0)); ++ __ CheckPageFlag(object, scratch0, ++ MemoryChunk::kPointersFromHereAreInterestingMask, ne, ++ ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kArchStackSlot: { ++ FrameOffset offset = ++ frame_access_state()->GetFrameOffset(i.InputInt32(0)); ++ Register base_reg = offset.from_stack_pointer() ? sp : fp; ++ __ Add_d(i.OutputRegister(), base_reg, Operand(offset.offset())); ++ int alignment = i.InputInt32(1); ++ DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || ++ alignment == 16); ++ if (FLAG_debug_code && alignment > 0) { ++ // Verify that the output_register is properly aligned ++ __ And(kScratchReg, i.OutputRegister(), ++ Operand(kSystemPointerSize - 1)); ++ __ Assert(eq, AbortReason::kAllocationIsNotDoubleAligned, kScratchReg, ++ Operand(zero_reg)); ++ } ++ if (alignment == 2 * kSystemPointerSize) { ++ Label done; ++ __ Add_d(kScratchReg, base_reg, Operand(offset.offset())); ++ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); ++ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); ++ __ Add_d(i.OutputRegister(), i.OutputRegister(), kSystemPointerSize); ++ __ bind(&done); ++ } else if (alignment > 2 * kSystemPointerSize) { ++ Label done; ++ __ Add_d(kScratchReg, base_reg, Operand(offset.offset())); ++ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); ++ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); ++ __ li(kScratchReg2, alignment); ++ __ Sub_d(kScratchReg2, kScratchReg2, Operand(kScratchReg)); ++ __ Add_d(i.OutputRegister(), i.OutputRegister(), kScratchReg2); ++ __ bind(&done); ++ } ++ ++ break; ++ } ++ case kArchWordPoisonOnSpeculation: ++ __ And(i.OutputRegister(), i.InputRegister(0), ++ kSpeculationPoisonRegister); ++ break; ++ case kIeee754Float64Acos: ++ ASSEMBLE_IEEE754_UNOP(acos); ++ break; ++ case kIeee754Float64Acosh: ++ ASSEMBLE_IEEE754_UNOP(acosh); ++ break; ++ case kIeee754Float64Asin: ++ ASSEMBLE_IEEE754_UNOP(asin); ++ break; ++ case kIeee754Float64Asinh: ++ ASSEMBLE_IEEE754_UNOP(asinh); ++ break; ++ case kIeee754Float64Atan: ++ ASSEMBLE_IEEE754_UNOP(atan); ++ break; ++ case kIeee754Float64Atanh: ++ ASSEMBLE_IEEE754_UNOP(atanh); ++ break; ++ case kIeee754Float64Atan2: ++ ASSEMBLE_IEEE754_BINOP(atan2); ++ break; ++ case kIeee754Float64Cos: ++ ASSEMBLE_IEEE754_UNOP(cos); ++ break; ++ case kIeee754Float64Cosh: ++ ASSEMBLE_IEEE754_UNOP(cosh); ++ break; ++ case kIeee754Float64Cbrt: ++ ASSEMBLE_IEEE754_UNOP(cbrt); ++ break; ++ case kIeee754Float64Exp: ++ ASSEMBLE_IEEE754_UNOP(exp); ++ break; ++ case kIeee754Float64Expm1: ++ ASSEMBLE_IEEE754_UNOP(expm1); ++ break; ++ case kIeee754Float64Log: ++ ASSEMBLE_IEEE754_UNOP(log); ++ break; ++ case kIeee754Float64Log1p: ++ ASSEMBLE_IEEE754_UNOP(log1p); ++ break; ++ case kIeee754Float64Log2: ++ ASSEMBLE_IEEE754_UNOP(log2); ++ break; ++ case kIeee754Float64Log10: ++ ASSEMBLE_IEEE754_UNOP(log10); ++ break; ++ case kIeee754Float64Pow: ++ ASSEMBLE_IEEE754_BINOP(pow); ++ break; ++ case kIeee754Float64Sin: ++ ASSEMBLE_IEEE754_UNOP(sin); ++ break; ++ case kIeee754Float64Sinh: ++ ASSEMBLE_IEEE754_UNOP(sinh); ++ break; ++ case kIeee754Float64Tan: ++ ASSEMBLE_IEEE754_UNOP(tan); ++ break; ++ case kIeee754Float64Tanh: ++ ASSEMBLE_IEEE754_UNOP(tanh); ++ break; ++ case kLa64Add: ++ __ Add_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Dadd: ++ __ Add_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64DaddOvf: ++ __ AdddOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), ++ kScratchReg); ++ break; ++ case kLa64Sub: ++ __ Sub_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Dsub: ++ __ Sub_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64DsubOvf: ++ __ SubdOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), ++ kScratchReg); ++ break; ++ case kLa64Mul: ++ __ Mul_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64MulOvf: ++ __ MulOverflow(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), ++ kScratchReg); ++ break; ++ case kLa64MulHigh: ++ __ Mulh_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64MulHighU: ++ __ Mulh_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64DMulHigh: ++ __ Mulh_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Div: ++ __ Div_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ break; ++ case kLa64DivU: ++ __ Div_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ break; ++ case kLa64Mod: ++ __ Mod_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64ModU: ++ __ Mod_wu(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Dmul: ++ __ Mul_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Ddiv: ++ __ Div_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ break; ++ case kLa64DdivU: ++ __ Div_du(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ masknez(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ break; ++ case kLa64Dmod: ++ __ Mod_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64DmodU: ++ __ Mod_du(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Dlsa: ++ DCHECK(instr->InputAt(2)->IsImmediate()); ++ __ Alsl_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), ++ i.InputInt8(2), t7); ++ break; ++ case kLa64Lsa: ++ DCHECK(instr->InputAt(2)->IsImmediate()); ++ __ Alsl_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1), ++ i.InputInt8(2), t7); ++ break; ++ case kLa64And: ++ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64And32: ++ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kLa64Or: ++ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Or32: ++ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kLa64Nor: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ } else { ++ DCHECK_EQ(0, i.InputOperand(1).immediate()); ++ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); ++ } ++ break; ++ case kLa64Nor32: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); ++ } else { ++ DCHECK_EQ(0, i.InputOperand(1).immediate()); ++ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); ++ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); ++ } ++ break; ++ case kLa64Xor: ++ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Xor32: ++ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ slli_w(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kLa64Clz: ++ __ Clz_w(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kLa64Dclz: ++ __ clz_d(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kLa64Ctz: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Ctz_w(dst, src); ++ } break; ++ case kLa64Dctz: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Ctz_d(dst, src); ++ } break; ++ case kLa64Popcnt: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Popcnt_w(dst, src); ++ } break; ++ case kLa64Dpopcnt: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Popcnt_d(dst, src); ++ } break; ++ case kLa64Shl: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ sll_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ slli_w(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kLa64Shr: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ slli_w(i.InputRegister(0), i.InputRegister(0), 0x0); ++ __ srl_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ slli_w(i.OutputRegister(), i.InputRegister(0), 0x0); ++ __ srli_w(i.OutputRegister(), i.OutputRegister(), ++ static_cast(imm)); ++ } ++ break; ++ case kLa64Sar: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ slli_w(i.InputRegister(0), i.InputRegister(0), 0x0); ++ __ sra_w(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ slli_w(i.OutputRegister(), i.InputRegister(0), 0x0); ++ __ srai_w(i.OutputRegister(), i.OutputRegister(), ++ static_cast(imm)); ++ } ++ break; ++ case kLa64Ext: ++ __ bstrpick_w(i.OutputRegister(), i.InputRegister(0), ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ break; ++ case kLa64Ins: ++ if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { ++ __ bstrins_w(i.OutputRegister(), zero_reg, ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ } else { ++ __ bstrins_w(i.OutputRegister(), i.InputRegister(0), ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ } ++ break; ++ case kLa64Dext: { ++ __ bstrpick_d(i.OutputRegister(), i.InputRegister(0), ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ break; ++ } ++ case kLa64Dins: ++ if (instr->InputAt(1)->IsImmediate() && i.InputInt8(1) == 0) { ++ __ bstrins_d(i.OutputRegister(), zero_reg, ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ } else { ++ __ bstrins_d(i.OutputRegister(), i.InputRegister(0), ++ i.InputInt8(1) + i.InputInt8(2) - 1, i.InputInt8(1)); ++ } ++ break; ++ case kLa64Dshl: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ sll_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ slli_d(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kLa64Dshr: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ srl_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ srli_d(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kLa64Dsar: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ sra_d(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ srai_d(i.OutputRegister(), i.InputRegister(0), imm); ++ } ++ break; ++ case kLa64Ror: ++ __ Rotr_w(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Dror: ++ __ Rotr_d(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kLa64Tst: ++ __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kLa64Cmp: ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kLa64Mov: ++ // TODO(plind): Should we combine mov/li like this, or use separate instr? ++ // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType ++ if (HasRegisterInput(instr, 0)) { ++ __ mov(i.OutputRegister(), i.InputRegister(0)); ++ } else { ++ __ li(i.OutputRegister(), i.InputOperand(0)); ++ } ++ break; ++ ++ case kLa64CmpS: { ++ FPURegister left = i.InputOrZeroSingleRegister(0); ++ FPURegister right = i.InputOrZeroSingleRegister(1); ++ bool predicate; ++ FPUCondition cc = ++ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); ++ ++ if ((left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ CompareF32(left, right, cc); ++ } break; ++ case kLa64AddS: ++ // TODO(plind): add special case: combine mult & add. ++ __ fadd_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64SubS: ++ __ fsub_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64MulS: ++ // TODO(plind): add special case: right op is -1.0, see arm port. ++ __ fmul_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64DivS: ++ __ fdiv_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64ModS: { ++ // TODO(bmeurer): We should really get rid of this special instruction, ++ // and generate a CallAddress instruction instead. ++ FrameScope scope(tasm(), StackFrame::MANUAL); ++ __ PrepareCallCFunction(0, 2, kScratchReg); ++ __ MovToFloatParameters(i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ // TODO(balazs.kilvady): implement mod_two_floats_operation(isolate()) ++ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); ++ // Move the result in the double result register. ++ __ MovFromFloatResult(i.OutputSingleRegister()); ++ break; ++ } ++ case kLa64AbsS: ++ __ fabs_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kLa64NegS: ++ __ Neg_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kLa64SqrtS: { ++ __ fsqrt_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64MaxS: ++ __ fmax_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64MinS: ++ __ fmin_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64CmpD: { ++ FPURegister left = i.InputOrZeroDoubleRegister(0); ++ FPURegister right = i.InputOrZeroDoubleRegister(1); ++ bool predicate; ++ FPUCondition cc = ++ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); ++ if ((left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ CompareF64(left, right, cc); ++ } break; ++ case kLa64AddD: ++ // TODO(plind): add special case: combine mult & add. ++ __ fadd_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64SubD: ++ __ fsub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64MulD: ++ // TODO(plind): add special case: right op is -1.0, see arm port. ++ __ fmul_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64DivD: ++ __ fdiv_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64ModD: { ++ // TODO(bmeurer): We should really get rid of this special instruction, ++ // and generate a CallAddress instruction instead. ++ FrameScope scope(tasm(), StackFrame::MANUAL); ++ __ PrepareCallCFunction(0, 2, kScratchReg); ++ __ MovToFloatParameters(i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); ++ // Move the result in the double result register. ++ __ MovFromFloatResult(i.OutputDoubleRegister()); ++ break; ++ } ++ case kLa64AbsD: ++ __ fabs_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64NegD: ++ __ Neg_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64SqrtD: { ++ __ fsqrt_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64MaxD: ++ __ fmax_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64MinD: ++ __ fmin_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kLa64Float64RoundDown: { ++ __ Floor_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64Float32RoundDown: { ++ __ Floor_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ } ++ case kLa64Float64RoundTruncate: { ++ __ Trunc_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64Float32RoundTruncate: { ++ __ Trunc_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ } ++ case kLa64Float64RoundUp: { ++ __ Ceil_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64Float32RoundUp: { ++ __ Ceil_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ } ++ case kLa64Float64RoundTiesEven: { ++ __ Round_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kLa64Float32RoundTiesEven: { ++ __ Round_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ } ++ case kLa64Float32Max: { ++ FPURegister dst = i.OutputSingleRegister(); ++ FPURegister src1 = i.InputSingleRegister(0); ++ FPURegister src2 = i.InputSingleRegister(1); ++ auto ool = zone()->New(this, dst, src1, src2); ++ __ Float32Max(dst, src1, src2, ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kLa64Float64Max: { ++ FPURegister dst = i.OutputDoubleRegister(); ++ FPURegister src1 = i.InputDoubleRegister(0); ++ FPURegister src2 = i.InputDoubleRegister(1); ++ auto ool = zone()->New(this, dst, src1, src2); ++ __ Float64Max(dst, src1, src2, ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kLa64Float32Min: { ++ FPURegister dst = i.OutputSingleRegister(); ++ FPURegister src1 = i.InputSingleRegister(0); ++ FPURegister src2 = i.InputSingleRegister(1); ++ auto ool = zone()->New(this, dst, src1, src2); ++ __ Float32Min(dst, src1, src2, ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kLa64Float64Min: { ++ FPURegister dst = i.OutputDoubleRegister(); ++ FPURegister src1 = i.InputDoubleRegister(0); ++ FPURegister src2 = i.InputDoubleRegister(1); ++ auto ool = zone()->New(this, dst, src1, src2); ++ __ Float64Min(dst, src1, src2, ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kLa64Float64SilenceNaN: ++ __ FPUCanonicalizeNaN(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64CvtSD: ++ __ fcvt_s_d(i.OutputSingleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64CvtDS: ++ __ fcvt_d_s(i.OutputDoubleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kLa64CvtDW: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ movgr2fr_w(scratch, i.InputRegister(0)); ++ __ ffint_d_w(i.OutputDoubleRegister(), scratch); ++ break; ++ } ++ case kLa64CvtSW: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ movgr2fr_w(scratch, i.InputRegister(0)); ++ __ ffint_s_w(i.OutputDoubleRegister(), scratch); ++ break; ++ } ++ case kLa64CvtSUw: { ++ __ Ffint_s_uw(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kLa64CvtSL: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ movgr2fr_d(scratch, i.InputRegister(0)); ++ __ ffint_s_l(i.OutputDoubleRegister(), scratch); ++ break; ++ } ++ case kLa64CvtDL: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ movgr2fr_d(scratch, i.InputRegister(0)); ++ __ ffint_d_l(i.OutputDoubleRegister(), scratch); ++ break; ++ } ++ case kLa64CvtDUw: { ++ __ Ffint_d_uw(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kLa64CvtDUl: { ++ __ Ffint_d_ul(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kLa64CvtSUl: { ++ __ Ffint_s_ul(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kLa64FloorWD: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrm_w_d(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64CeilWD: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrp_w_d(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64RoundWD: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrne_w_d(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64TruncWD: { ++ FPURegister scratch = kScratchDoubleReg; ++ // Other arches use round to zero here, so we follow. ++ __ ftintrz_w_d(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64FloorWS: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrm_w_s(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64CeilWS: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrp_w_s(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64RoundWS: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrne_w_s(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ break; ++ } ++ case kLa64TruncWS: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ ftintrz_w_s(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_s(i.OutputRegister(), scratch); ++ // Avoid INT32_MAX as an overflow indicator and use INT32_MIN instead, ++ // because INT32_MIN allows easier out-of-bounds detection. ++ __ addi_w(kScratchReg, i.OutputRegister(), 1); ++ __ slt(kScratchReg2, kScratchReg, i.OutputRegister()); ++ __ Movn(i.OutputRegister(), kScratchReg, kScratchReg2); ++ break; ++ } ++ case kLa64TruncLS: { ++ FPURegister scratch = kScratchDoubleReg; ++ Register tmp_fcsr = kScratchReg; ++ Register result = kScratchReg2; ++ ++ bool load_status = instr->OutputCount() > 1; ++ if (load_status) { ++ // Save FCSR. ++ __ movfcsr2gr(tmp_fcsr); // __ cfc1(tmp_fcsr, FCSR); ++ // Clear FPU flags. ++ __ movgr2fcsr(zero_reg); // __ ctc1(zero_reg, FCSR); ++ } ++ // Other arches use round to zero here, so we follow. ++ __ ftintrz_l_s(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_d(i.OutputRegister(), scratch); ++ if (load_status) { ++ __ movfcsr2gr(result); // __ cfc1(result, FCSR); ++ // Check for overflow and NaNs. ++ __ And(result, result, ++ (kFCSROverflowFlagMask | kFCSRInvalidOpFlagMask)); ++ __ Slt(result, zero_reg, result); ++ __ xori(result, result, 1); ++ __ mov(i.OutputRegister(1), result); ++ // Restore FCSR ++ __ movgr2fcsr(tmp_fcsr); // __ ctc1(tmp_fcsr, FCSR); ++ } ++ break; ++ } ++ case kLa64TruncLD: { ++ FPURegister scratch = kScratchDoubleReg; ++ Register tmp_fcsr = kScratchReg; ++ Register result = kScratchReg2; ++ ++ bool load_status = instr->OutputCount() > 1; ++ if (load_status) { ++ // Save FCSR. ++ __ movfcsr2gr(tmp_fcsr); // __ cfc1(tmp_fcsr, FCSR); ++ // Clear FPU flags. ++ __ movgr2fcsr(zero_reg); // __ ctc1(zero_reg, FCSR); ++ } ++ // Other arches use round to zero here, so we follow. ++ __ ftintrz_l_d(scratch, i.InputDoubleRegister(0)); ++ __ movfr2gr_d(i.OutputRegister(0), scratch); ++ if (load_status) { ++ __ movfcsr2gr(result); // __ cfc1(result, FCSR); ++ // Check for overflow and NaNs. ++ __ And(result, result, ++ (kFCSROverflowFlagMask | kFCSRInvalidOpFlagMask)); ++ __ Slt(result, zero_reg, result); ++ __ xori(result, result, 1); ++ __ mov(i.OutputRegister(1), result); ++ // Restore FCSR ++ __ movgr2fcsr(tmp_fcsr); // __ ctc1(tmp_fcsr, FCSR); ++ } ++ break; ++ } ++ case kLa64TruncUwD: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ Ftintrz_uw_d(i.OutputRegister(), i.InputDoubleRegister(0), scratch); ++ break; ++ } ++ case kLa64TruncUwS: { ++ FPURegister scratch = kScratchDoubleReg; ++ __ Ftintrz_uw_s(i.OutputRegister(), i.InputDoubleRegister(0), scratch); ++ // Avoid UINT32_MAX as an overflow indicator and use 0 instead, ++ // because 0 allows easier out-of-bounds detection. ++ __ addi_w(kScratchReg, i.OutputRegister(), 1); ++ __ Movz(i.OutputRegister(), zero_reg, kScratchReg); ++ break; ++ } ++ case kLa64TruncUlS: { ++ FPURegister scratch = kScratchDoubleReg; ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Ftintrz_ul_s(i.OutputRegister(), i.InputDoubleRegister(0), scratch, ++ result); ++ break; ++ } ++ case kLa64TruncUlD: { ++ FPURegister scratch = kScratchDoubleReg; ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Ftintrz_ul_d(i.OutputRegister(0), i.InputDoubleRegister(0), scratch, ++ result); ++ break; ++ } ++ case kLa64BitcastDL: ++ __ movfr2gr_d(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64BitcastLD: ++ __ movgr2fr_d(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ case kLa64Float64ExtractLowWord32: ++ __ FmoveLow(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64Float64ExtractHighWord32: ++ __ movfrh2gr_s(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kLa64Float64InsertLowWord32: ++ __ FmoveLow(i.OutputDoubleRegister(), i.InputRegister(1)); ++ break; ++ case kLa64Float64InsertHighWord32: ++ __ movgr2frh_w(i.OutputDoubleRegister(), i.InputRegister(1)); ++ break; ++ // ... more basic instructions ... ++ ++ case kLa64Seb: ++ __ ext_w_b(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kLa64Seh: ++ __ ext_w_h(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kLa64Lbu: ++ __ Ld_bu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Lb: ++ __ Ld_b(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Sb: ++ __ St_b(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Lhu: ++ __ Ld_hu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Ulhu: ++ __ Ld_hu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Lh: ++ __ Ld_h(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Ulh: ++ __ Ld_h(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Sh: ++ __ St_h(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Ush: ++ __ St_h(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Lw: ++ __ Ld_w(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Ulw: ++ __ Ld_w(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Lwu: ++ __ Ld_wu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Ulwu: ++ __ Ld_wu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Ld: ++ __ Ld_d(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Uld: ++ __ Ld_d(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kLa64Sw: ++ __ St_w(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Usw: ++ __ St_w(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Sd: ++ __ St_d(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Usd: ++ __ St_d(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kLa64Lwc1: { ++ __ Fld_s(i.OutputSingleRegister(), i.MemoryOperand()); ++ break; ++ } ++ case kLa64Ulwc1: { ++ __ Fld_s(i.OutputSingleRegister(), i.MemoryOperand()); ++ break; ++ } ++ case kLa64Swc1: { ++ size_t index = 0; ++ MemOperand operand = i.MemoryOperand(&index); ++ FPURegister ft = i.InputOrZeroSingleRegister(index); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ Fst_s(ft, operand); ++ break; ++ } ++ case kLa64Uswc1: { ++ size_t index = 0; ++ MemOperand operand = i.MemoryOperand(&index); ++ FPURegister ft = i.InputOrZeroSingleRegister(index); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ Fst_s(ft, operand); ++ break; ++ } ++ case kLa64Ldc1: ++ __ Fld_d(i.OutputDoubleRegister(), i.MemoryOperand()); ++ break; ++ case kLa64Uldc1: ++ __ Fld_d(i.OutputDoubleRegister(), i.MemoryOperand()); ++ break; ++ case kLa64Sdc1: { ++ FPURegister ft = i.InputOrZeroDoubleRegister(2); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ Fst_d(ft, i.MemoryOperand()); ++ break; ++ } ++ case kLa64Usdc1: { ++ FPURegister ft = i.InputOrZeroDoubleRegister(2); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ ++ __ Fst_d(ft, i.MemoryOperand()); ++ break; ++ } ++ case kLa64Sync: { ++ __ dbar(0); ++ break; ++ } ++ case kLa64Push: ++ if (instr->InputAt(0)->IsFPRegister()) { ++ __ Fst_d(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); ++ __ Sub_d(sp, sp, Operand(kDoubleSize)); ++ frame_access_state()->IncreaseSPDelta(kDoubleSize / kSystemPointerSize); ++ } else { ++ __ Push(i.InputRegister(0)); ++ frame_access_state()->IncreaseSPDelta(1); ++ } ++ break; ++ case kLa64Peek: { ++ int reverse_slot = i.InputInt32(0); ++ int offset = ++ FrameSlotToFPOffset(frame()->GetTotalFrameSlotCount() - reverse_slot); ++ if (instr->OutputAt(0)->IsFPRegister()) { ++ LocationOperand* op = LocationOperand::cast(instr->OutputAt(0)); ++ if (op->representation() == MachineRepresentation::kFloat64) { ++ __ Fld_d(i.OutputDoubleRegister(), MemOperand(fp, offset)); ++ } else if (op->representation() == MachineRepresentation::kFloat32) { ++ __ Fld_s( ++ i.OutputSingleRegister(0), ++ MemOperand(fp, offset + kLessSignificantWordInDoublewordOffset)); ++ } else { ++ DCHECK_EQ(MachineRepresentation::kSimd128, op->representation()); ++ abort(); ++ } ++ } else { ++ __ Ld_d(i.OutputRegister(0), MemOperand(fp, offset)); ++ } ++ break; ++ } ++ case kLa64StackClaim: { ++ __ Sub_d(sp, sp, Operand(i.InputInt32(0))); ++ frame_access_state()->IncreaseSPDelta(i.InputInt32(0) / ++ kSystemPointerSize); ++ break; ++ } ++ case kLa64StoreToStackSlot: { ++ if (instr->InputAt(0)->IsFPRegister()) { ++ __ Fst_d(i.InputDoubleRegister(0), MemOperand(sp, i.InputInt32(1))); ++ } else { ++ __ St_d(i.InputRegister(0), MemOperand(sp, i.InputInt32(1))); ++ } ++ break; ++ } ++ case kLa64ByteSwap64: { ++ __ ByteSwapSigned(i.OutputRegister(0), i.InputRegister(0), 8); ++ break; ++ } ++ case kLa64ByteSwap32: { ++ __ ByteSwapSigned(i.OutputRegister(0), i.InputRegister(0), 4); ++ break; ++ } ++ case kWord32AtomicLoadInt8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_b); ++ break; ++ case kWord32AtomicLoadUint8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_bu); ++ break; ++ case kWord32AtomicLoadInt16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_h); ++ break; ++ case kWord32AtomicLoadUint16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_hu); ++ break; ++ case kWord32AtomicLoadWord32: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_w); ++ break; ++ case kLa64Word64AtomicLoadUint8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_bu); ++ break; ++ case kLa64Word64AtomicLoadUint16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_hu); ++ break; ++ case kLa64Word64AtomicLoadUint32: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_wu); ++ break; ++ case kLa64Word64AtomicLoadUint64: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld_d); ++ break; ++ case kWord32AtomicStoreWord8: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_b); ++ break; ++ case kWord32AtomicStoreWord16: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_h); ++ break; ++ case kWord32AtomicStoreWord32: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_w); ++ break; ++ case kLa64Word64AtomicStoreWord8: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_b); ++ break; ++ case kLa64Word64AtomicStoreWord16: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_h); ++ break; ++ case kLa64Word64AtomicStoreWord32: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_w); ++ break; ++ case kLa64Word64AtomicStoreWord64: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(St_d); ++ break; ++ case kWord32AtomicExchangeInt8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 8, 32); ++ break; ++ case kWord32AtomicExchangeUint8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 8, 32); ++ break; ++ case kWord32AtomicExchangeInt16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 16, 32); ++ break; ++ case kWord32AtomicExchangeUint16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 16, 32); ++ break; ++ case kWord32AtomicExchangeWord32: ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amswap_db_w(i.OutputRegister(0), i.InputRegister(2), ++ i.TempRegister(0)); ++ break; ++ case kLa64Word64AtomicExchangeUint8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 8, 64); ++ break; ++ case kLa64Word64AtomicExchangeUint16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 16, 64); ++ break; ++ case kLa64Word64AtomicExchangeUint32: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 32, 64); ++ break; ++ case kLa64Word64AtomicExchangeUint64: ++ __ add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amswap_db_d(i.OutputRegister(0), i.InputRegister(2), ++ i.TempRegister(0)); ++ break; ++ case kWord32AtomicCompareExchangeInt8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 8, 32); ++ break; ++ case kWord32AtomicCompareExchangeUint8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 8, 32); ++ break; ++ case kWord32AtomicCompareExchangeInt16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, true, 16, 32); ++ break; ++ case kWord32AtomicCompareExchangeUint16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_w, Sc_w, false, 16, 32); ++ break; ++ case kWord32AtomicCompareExchangeWord32: ++ __ slli_w(i.InputRegister(2), i.InputRegister(2), 0); ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll_w, Sc_w); ++ break; ++ case kLa64Word64AtomicCompareExchangeUint8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 8, 64); ++ break; ++ case kLa64Word64AtomicCompareExchangeUint16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 16, 64); ++ break; ++ case kLa64Word64AtomicCompareExchangeUint32: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll_d, Sc_d, false, 32, 64); ++ break; ++ case kLa64Word64AtomicCompareExchangeUint64: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll_d, Sc_d); ++ break; ++ case kWord32AtomicAddWord32: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amadd_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kWord32AtomicSubWord32: ++ ASSEMBLE_ATOMIC_BINOP(Ll_w, Sc_w, Sub_w); ++ break; ++ case kWord32AtomicAndWord32: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amand_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kWord32AtomicOrWord32: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amor_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kWord32AtomicXorWord32: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amxor_db_w(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++#define ATOMIC_BINOP_CASE(op, inst) \ ++ case kWord32Atomic##op##Int8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, true, 8, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Uint8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, false, 8, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Int16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, true, 16, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Uint16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_w, Sc_w, false, 16, inst, 32); \ ++ break; ++ ATOMIC_BINOP_CASE(Add, Add_w) ++ ATOMIC_BINOP_CASE(Sub, Sub_w) ++ ATOMIC_BINOP_CASE(And, And) ++ ATOMIC_BINOP_CASE(Or, Or) ++ ATOMIC_BINOP_CASE(Xor, Xor) ++#undef ATOMIC_BINOP_CASE ++ ++ case kLa64Word64AtomicAddUint64: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amadd_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kLa64Word64AtomicSubUint64: ++ ASSEMBLE_ATOMIC_BINOP(Ll_d, Sc_d, Sub_d); ++ break; ++ case kLa64Word64AtomicAndUint64: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amand_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kLa64Word64AtomicOrUint64: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amor_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++ case kLa64Word64AtomicXorUint64: ++ __ Add_d(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); ++ __ amxor_db_d(i.OutputRegister(0), i.InputRegister(2), i.TempRegister(0)); ++ break; ++#define ATOMIC_BINOP_CASE(op, inst) \ ++ case kLa64Word64Atomic##op##Uint8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 8, inst, 64); \ ++ break; \ ++ case kLa64Word64Atomic##op##Uint16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 16, inst, 64); \ ++ break; \ ++ case kLa64Word64Atomic##op##Uint32: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll_d, Sc_d, false, 32, inst, 64); \ ++ break; ++ ATOMIC_BINOP_CASE(Add, Add_d) ++ ATOMIC_BINOP_CASE(Sub, Sub_d) ++ ATOMIC_BINOP_CASE(And, And) ++ ATOMIC_BINOP_CASE(Or, Or) ++ ATOMIC_BINOP_CASE(Xor, Xor) ++#undef ATOMIC_BINOP_CASE ++ case kLa64AssertEqual: ++ __ Assert(eq, static_cast(i.InputOperand(2).immediate()), ++ i.InputRegister(0), Operand(i.InputRegister(1))); ++ break; ++ case kLa64S128Const: ++ case kLa64S128Zero: ++ case kLa64I32x4Splat: ++ case kLa64I32x4ExtractLane: ++ case kLa64I32x4AddHoriz: ++ case kLa64I32x4Add: ++ case kLa64I32x4ReplaceLane: ++ case kLa64I32x4Sub: ++ case kLa64F64x2Abs: ++ default: ++ break; ++ } ++ return kSuccess; ++} // NOLINT(readability/fn_size) ++ ++#define UNSUPPORTED_COND(opcode, condition) \ ++ StdoutStream{} << "Unsupported " << #opcode << " condition: \"" << condition \ ++ << "\""; \ ++ UNIMPLEMENTED(); ++ ++void AssembleBranchToLabels(CodeGenerator* gen, TurboAssembler* tasm, ++ Instruction* instr, FlagsCondition condition, ++ Label* tlabel, Label* flabel, bool fallthru) { ++#undef __ ++#define __ tasm-> ++ La64OperandConverter i(gen, instr); ++ ++ Condition cc = kNoCondition; ++ // LA64 does not have condition code flags, so compare and branch are ++ // implemented differently than on the other arch's. The compare operations ++ // emit la64 pseudo-instructions, which are handled here by branch ++ // instructions that do the actual comparison. Essential that the input ++ // registers to compare pseudo-op are not modified before this branch op, as ++ // they are tested here. ++ ++ if (instr->arch_opcode() == kLa64Tst) { ++ cc = FlagsConditionToConditionTst(condition); ++ __ Branch(tlabel, cc, kScratchReg, Operand(zero_reg)); ++ } else if (instr->arch_opcode() == kLa64Dadd || ++ instr->arch_opcode() == kLa64Dsub) { ++ cc = FlagsConditionToConditionOvf(condition); ++ __ srai_d(kScratchReg, i.OutputRegister(), 32); ++ __ srai_w(kScratchReg2, i.OutputRegister(), 31); ++ __ Branch(tlabel, cc, kScratchReg2, Operand(kScratchReg)); ++ } else if (instr->arch_opcode() == kLa64DaddOvf || ++ instr->arch_opcode() == kLa64DsubOvf) { ++ switch (condition) { ++ // Overflow occurs if overflow register is negative ++ case kOverflow: ++ __ Branch(tlabel, lt, kScratchReg, Operand(zero_reg)); ++ break; ++ case kNotOverflow: ++ __ Branch(tlabel, ge, kScratchReg, Operand(zero_reg)); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ break; ++ } ++ } else if (instr->arch_opcode() == kLa64MulOvf) { ++ // Overflow occurs if overflow register is not zero ++ switch (condition) { ++ case kOverflow: ++ __ Branch(tlabel, ne, kScratchReg, Operand(zero_reg)); ++ break; ++ case kNotOverflow: ++ __ Branch(tlabel, eq, kScratchReg, Operand(zero_reg)); ++ break; ++ default: ++ UNSUPPORTED_COND(kLa64MulOvf, condition); ++ break; ++ } ++ } else if (instr->arch_opcode() == kLa64Cmp) { ++ cc = FlagsConditionToConditionCmp(condition); ++ __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); ++ } else if (instr->arch_opcode() == kArchStackPointerGreaterThan) { ++ cc = FlagsConditionToConditionCmp(condition); ++ Register lhs_register = sp; ++ uint32_t offset; ++ if (gen->ShouldApplyOffsetToStackCheck(instr, &offset)) { ++ lhs_register = i.TempRegister(0); ++ __ Sub_d(lhs_register, sp, offset); ++ } ++ __ Branch(tlabel, cc, lhs_register, Operand(i.InputRegister(0))); ++ } else if (instr->arch_opcode() == kLa64CmpS || ++ instr->arch_opcode() == kLa64CmpD) { ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ if (predicate) { ++ __ BranchTrueF(tlabel); ++ } else { ++ __ BranchFalseF(tlabel); ++ } ++ } else { ++ PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", ++ instr->arch_opcode()); ++ UNIMPLEMENTED(); ++ } ++ if (!fallthru) __ Branch(flabel); // no fallthru to flabel. ++#undef __ ++#define __ tasm()-> ++} ++ ++// Assembles branches after an instruction. ++void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { ++ Label* tlabel = branch->true_label; ++ Label* flabel = branch->false_label; ++ ++ AssembleBranchToLabels(this, tasm(), instr, branch->condition, tlabel, flabel, ++ branch->fallthru); ++} ++ ++void CodeGenerator::AssembleBranchPoisoning(FlagsCondition condition, ++ Instruction* instr) { ++ // TODO(jarin) Handle float comparisons (kUnordered[Not]Equal). ++ if (condition == kUnorderedEqual || condition == kUnorderedNotEqual) { ++ return; ++ } ++ ++ La64OperandConverter i(this, instr); ++ condition = NegateFlagsCondition(condition); ++ ++ switch (instr->arch_opcode()) { ++ case kLa64Cmp: { ++ __ LoadZeroOnCondition(kSpeculationPoisonRegister, i.InputRegister(0), ++ i.InputOperand(1), ++ FlagsConditionToConditionCmp(condition)); ++ } ++ return; ++ case kLa64Tst: { ++ switch (condition) { ++ case kEqual: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); ++ break; ++ case kNotEqual: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ return; ++ case kLa64Dadd: ++ case kLa64Dsub: { ++ // Check for overflow creates 1 or 0 for result. ++ __ srli_d(kScratchReg, i.OutputRegister(), 63); ++ __ srli_w(kScratchReg2, i.OutputRegister(), 31); ++ __ xor_(kScratchReg2, kScratchReg, kScratchReg2); ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg2); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kLa64DaddOvf: ++ case kLa64DsubOvf: { ++ // Overflow occurs if overflow register is negative ++ __ Slt(kScratchReg2, kScratchReg, zero_reg); ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg2); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kLa64MulOvf: { ++ // Overflow occurs if overflow register is not zero ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kLa64CmpS: ++ case kLa64CmpD: { ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ if (predicate) { ++ __ LoadZeroIfFPUCondition(kSpeculationPoisonRegister); ++ } else { ++ __ LoadZeroIfNotFPUCondition(kSpeculationPoisonRegister); ++ } ++ } ++ return; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++#undef UNSUPPORTED_COND ++ ++void CodeGenerator::AssembleArchDeoptBranch(Instruction* instr, ++ BranchInfo* branch) { ++ AssembleArchBranch(instr, branch); ++} ++ ++void CodeGenerator::AssembleArchJump(RpoNumber target) { ++ if (!IsNextInAssemblyOrder(target)) __ Branch(GetLabel(target)); ++} ++ ++void CodeGenerator::AssembleArchTrap(Instruction* instr, ++ FlagsCondition condition) { ++ class OutOfLineTrap final : public OutOfLineCode { ++ public: ++ OutOfLineTrap(CodeGenerator* gen, Instruction* instr) ++ : OutOfLineCode(gen), instr_(instr), gen_(gen) {} ++ void Generate() final { ++ La64OperandConverter i(gen_, instr_); ++ TrapId trap_id = ++ static_cast(i.InputInt32(instr_->InputCount() - 1)); ++ GenerateCallToTrap(trap_id); ++ } ++ ++ private: ++ void GenerateCallToTrap(TrapId trap_id) { ++ if (trap_id == TrapId::kInvalid) { ++ // We cannot test calls to the runtime in cctest/test-run-wasm. ++ // Therefore we emit a call to C here instead of a call to the runtime. ++ // We use the context register as the scratch register, because we do ++ // not have a context here. ++ __ PrepareCallCFunction(0, 0, cp); ++ __ CallCFunction( ++ ExternalReference::wasm_call_trap_callback_for_testing(), 0); ++ __ LeaveFrame(StackFrame::WASM); ++ auto call_descriptor = gen_->linkage()->GetIncomingDescriptor(); ++ int pop_count = ++ static_cast(call_descriptor->StackParameterCount()); ++ pop_count += (pop_count & 1); // align ++ __ Drop(pop_count); ++ __ Ret(); ++ } else { ++ gen_->AssembleSourcePosition(instr_); ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched when the code ++ // is added to the native module and copied into wasm code space. ++ __ Call(static_cast
(trap_id), RelocInfo::WASM_STUB_CALL); ++ ReferenceMap* reference_map = ++ gen_->zone()->New(gen_->zone()); ++ gen_->RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); ++ if (FLAG_debug_code) { ++ __ stop(); ++ } ++ } ++ } ++ Instruction* instr_; ++ CodeGenerator* gen_; ++ }; ++ auto ool = zone()->New(this, instr); ++ Label* tlabel = ool->entry(); ++ AssembleBranchToLabels(this, tasm(), instr, condition, tlabel, nullptr, true); ++} ++ ++// Assembles boolean materializations after an instruction. ++void CodeGenerator::AssembleArchBoolean(Instruction* instr, ++ FlagsCondition condition) { ++ La64OperandConverter i(this, instr); ++ ++ // Materialize a full 32-bit 1 or 0 value. The result register is always the ++ // last output of the instruction. ++ DCHECK_NE(0u, instr->OutputCount()); ++ Register result = i.OutputRegister(instr->OutputCount() - 1); ++ Condition cc = kNoCondition; ++ // La64 does not have condition code flags, so compare and branch are ++ // implemented differently than on the other arch's. The compare operations ++ // emit la64 pseudo-instructions, which are checked and handled here. ++ ++ if (instr->arch_opcode() == kLa64Tst) { ++ cc = FlagsConditionToConditionTst(condition); ++ if (cc == eq) { ++ __ Sltu(result, kScratchReg, 1); ++ } else { ++ __ Sltu(result, zero_reg, kScratchReg); ++ } ++ return; ++ } else if (instr->arch_opcode() == kLa64Dadd || ++ instr->arch_opcode() == kLa64Dsub) { ++ cc = FlagsConditionToConditionOvf(condition); ++ // Check for overflow creates 1 or 0 for result. ++ __ srli_d(kScratchReg, i.OutputRegister(), 63); ++ __ srli_w(kScratchReg2, i.OutputRegister(), 31); ++ __ xor_(result, kScratchReg, kScratchReg2); ++ if (cc == eq) // Toggle result for not overflow. ++ __ xori(result, result, 1); ++ return; ++ } else if (instr->arch_opcode() == kLa64DaddOvf || ++ instr->arch_opcode() == kLa64DsubOvf) { ++ // Overflow occurs if overflow register is negative ++ __ slt(result, kScratchReg, zero_reg); ++ } else if (instr->arch_opcode() == kLa64MulOvf) { ++ // Overflow occurs if overflow register is not zero ++ __ Sgtu(result, kScratchReg, zero_reg); ++ } else if (instr->arch_opcode() == kLa64Cmp) { ++ cc = FlagsConditionToConditionCmp(condition); ++ switch (cc) { ++ case eq: ++ case ne: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ if (instr->InputAt(1)->IsImmediate()) { ++ if (is_int12(-right.immediate())) { ++ if (right.immediate() == 0) { ++ if (cc == eq) { ++ __ Sltu(result, left, 1); ++ } else { ++ __ Sltu(result, zero_reg, left); ++ } ++ } else { ++ __ Add_d(result, left, Operand(-right.immediate())); ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } else { ++ if (is_uint12(right.immediate())) { ++ __ Xor(result, left, right); ++ } else { ++ __ li(kScratchReg, right); ++ __ Xor(result, left, kScratchReg); ++ } ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } else { ++ __ Xor(result, left, right); ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } break; ++ case lt: ++ case ge: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ __ Slt(result, left, right); ++ if (cc == ge) { ++ __ xori(result, result, 1); ++ } ++ } break; ++ case gt: ++ case le: { ++ Register left = i.InputRegister(1); ++ Operand right = i.InputOperand(0); ++ __ Slt(result, left, right); ++ if (cc == le) { ++ __ xori(result, result, 1); ++ } ++ } break; ++ case lo: ++ case hs: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ __ Sltu(result, left, right); ++ if (cc == hs) { ++ __ xori(result, result, 1); ++ } ++ } break; ++ case hi: ++ case ls: { ++ Register left = i.InputRegister(1); ++ Operand right = i.InputOperand(0); ++ __ Sltu(result, left, right); ++ if (cc == ls) { ++ __ xori(result, result, 1); ++ } ++ } break; ++ default: ++ UNREACHABLE(); ++ } ++ return; ++ } else if (instr->arch_opcode() == kLa64CmpD || ++ instr->arch_opcode() == kLa64CmpS) { ++ FPURegister left = i.InputOrZeroDoubleRegister(0); ++ FPURegister right = i.InputOrZeroDoubleRegister(1); ++ if ((left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsDoubleZeroRegSet()) { ++ __ Move(kDoubleRegZero, 0.0); ++ } ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ { ++ __ movcf2gr(result, FCC0); ++ if (!predicate) { ++ __ xori(result, result, 1); ++ } ++ } ++ return; ++ } else { ++ PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", ++ instr->arch_opcode()); ++ TRACE_UNIMPL(); ++ UNIMPLEMENTED(); ++ } ++} ++ ++void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) { ++ La64OperandConverter i(this, instr); ++ Register input = i.InputRegister(0); ++ std::vector> cases; ++ for (size_t index = 2; index < instr->InputCount(); index += 2) { ++ cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))}); ++ } ++ AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(), ++ cases.data() + cases.size()); ++} ++ ++void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { ++ La64OperandConverter i(this, instr); ++ Register input = i.InputRegister(0); ++ size_t const case_count = instr->InputCount() - 2; ++ ++ __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); ++ __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { ++ return GetLabel(i.InputRpo(index + 2)); ++ }); ++} ++ ++void CodeGenerator::FinishFrame(Frame* frame) { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ if (saves_fpu != 0) { ++ int count = base::bits::CountPopulation(saves_fpu); ++ DCHECK_EQ(kNumCalleeSavedFPU, count); ++ frame->AllocateSavedCalleeRegisterSlots(count * ++ (kDoubleSize / kSystemPointerSize)); ++ } ++ ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ if (saves != 0) { ++ int count = base::bits::CountPopulation(saves); ++ DCHECK_EQ(kNumCalleeSaved, count + 1); ++ frame->AllocateSavedCalleeRegisterSlots(count); ++ } ++} ++ ++void CodeGenerator::AssembleConstructFrame() { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ if (frame_access_state()->has_frame()) { ++ if (call_descriptor->IsCFunctionCall()) { ++ if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) { ++ __ StubPrologue(StackFrame::C_WASM_ENTRY); ++ // Reserve stack space for saving the c_entry_fp later. ++ __ Sub_d(sp, sp, Operand(kSystemPointerSize)); ++ } else { ++ __ Push(ra, fp); ++ __ mov(fp, sp); ++ } ++ } else if (call_descriptor->IsJSFunctionCall()) { ++ __ Prologue(); ++ } else { ++ __ StubPrologue(info()->GetOutputStackFrameType()); ++ if (call_descriptor->IsWasmFunctionCall()) { ++ __ Push(kWasmInstanceRegister); ++ } else if (call_descriptor->IsWasmImportWrapper() || ++ call_descriptor->IsWasmCapiFunction()) { ++ // Wasm import wrappers are passed a tuple in the place of the instance. ++ // Unpack the tuple into the instance and the target callable. ++ // This must be done here in the codegen because it cannot be expressed ++ // properly in the graph. ++ __ Ld_d(kJSFunctionRegister, ++ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset)); ++ __ Ld_d(kWasmInstanceRegister, ++ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); ++ __ Push(kWasmInstanceRegister); ++ if (call_descriptor->IsWasmCapiFunction()) { ++ // Reserve space for saving the PC later. ++ __ Sub_d(sp, sp, Operand(kSystemPointerSize)); ++ } ++ } ++ } ++ } ++ ++ int required_slots = ++ frame()->GetTotalFrameSlotCount() - frame()->GetFixedSlotCount(); ++ ++ if (info()->is_osr()) { ++ // TurboFan OSR-compiled functions cannot be entered directly. ++ __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); ++ ++ // Unoptimized code jumps directly to this entrypoint while the unoptimized ++ // frame is still on the stack. Optimized code uses OSR values directly from ++ // the unoptimized frame. Thus, all that needs to be done is to allocate the ++ // remaining stack slots. ++ if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); ++ osr_pc_offset_ = __ pc_offset(); ++ required_slots -= osr_helper()->UnoptimizedFrameSlots(); ++ ResetSpeculationPoison(); ++ } ++ ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ ++ if (required_slots > 0) { ++ DCHECK(frame_access_state()->has_frame()); ++ if (info()->IsWasm() && required_slots > 128) { ++ // For WebAssembly functions with big frames we have to do the stack ++ // overflow check before we construct the frame. Otherwise we may not ++ // have enough space on the stack to call the runtime for the stack ++ // overflow. ++ Label done; ++ ++ // If the frame is bigger than the stack, we throw the stack overflow ++ // exception unconditionally. Thereby we can avoid the integer overflow ++ // check in the condition code. ++ if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { ++ __ Ld_d( ++ kScratchReg, ++ FieldMemOperand(kWasmInstanceRegister, ++ WasmInstanceObject::kRealStackLimitAddressOffset)); ++ __ Ld_d(kScratchReg, MemOperand(kScratchReg, 0)); ++ __ Add_d(kScratchReg, kScratchReg, ++ Operand(required_slots * kSystemPointerSize)); ++ __ Branch(&done, uge, sp, Operand(kScratchReg)); ++ } ++ ++ __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); ++ // We come from WebAssembly, there are no references for the GC. ++ ReferenceMap* reference_map = zone()->New(zone()); ++ RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); ++ if (FLAG_debug_code) { ++ __ stop(); ++ } ++ ++ __ bind(&done); ++ } ++ } ++ ++ const int returns = frame()->GetReturnSlotCount(); ++ ++ // Skip callee-saved and return slots, which are pushed below. ++ required_slots -= base::bits::CountPopulation(saves); ++ required_slots -= base::bits::CountPopulation(saves_fpu); ++ required_slots -= returns; ++ if (required_slots > 0) { ++ __ Sub_d(sp, sp, Operand(required_slots * kSystemPointerSize)); ++ } ++ ++ if (saves_fpu != 0) { ++ // Save callee-saved FPU registers. ++ __ MultiPushFPU(saves_fpu); ++ DCHECK_EQ(kNumCalleeSavedFPU, base::bits::CountPopulation(saves_fpu)); ++ } ++ ++ if (saves != 0) { ++ // Save callee-saved registers. ++ __ MultiPush(saves); ++ DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1); ++ } ++ ++ if (returns != 0) { ++ // Create space for returns. ++ __ Sub_d(sp, sp, Operand(returns * kSystemPointerSize)); ++ } ++} ++ ++void CodeGenerator::AssembleReturn(InstructionOperand* pop) { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ const int returns = frame()->GetReturnSlotCount(); ++ if (returns != 0) { ++ __ Add_d(sp, sp, Operand(returns * kSystemPointerSize)); ++ } ++ ++ // Restore GP registers. ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ if (saves != 0) { ++ __ MultiPop(saves); ++ } ++ ++ // Restore FPU registers. ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ if (saves_fpu != 0) { ++ __ MultiPopFPU(saves_fpu); ++ } ++ ++ La64OperandConverter g(this, nullptr); ++ if (call_descriptor->IsCFunctionCall()) { ++ AssembleDeconstructFrame(); ++ } else if (frame_access_state()->has_frame()) { ++ // Canonicalize JSFunction return sites for now unless they have an variable ++ // number of stack slot pops. ++ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { ++ if (return_label_.is_bound()) { ++ __ Branch(&return_label_); ++ return; ++ } else { ++ __ bind(&return_label_); ++ AssembleDeconstructFrame(); ++ } ++ } else { ++ AssembleDeconstructFrame(); ++ } ++ } ++ int pop_count = static_cast(call_descriptor->StackParameterCount()); ++ if (pop->IsImmediate()) { ++ pop_count += g.ToConstant(pop).ToInt32(); ++ } else { ++ Register pop_reg = g.ToRegister(pop); ++ __ slli_d(pop_reg, pop_reg, kSystemPointerSizeLog2); ++ __ Add_d(sp, sp, pop_reg); ++ } ++ if (pop_count != 0) { ++ __ DropAndRet(pop_count); ++ } else { ++ __ Ret(); ++ } ++} ++ ++void CodeGenerator::FinishCode() {} ++ ++void CodeGenerator::PrepareForDeoptimizationExits(int deopt_count) {} ++ ++void CodeGenerator::AssembleMove(InstructionOperand* source, ++ InstructionOperand* destination) { ++ La64OperandConverter g(this, nullptr); ++ // Dispatch on the source and destination operand kinds. Not all ++ // combinations are possible. ++ if (source->IsRegister()) { ++ DCHECK(destination->IsRegister() || destination->IsStackSlot()); ++ Register src = g.ToRegister(source); ++ if (destination->IsRegister()) { ++ __ mov(g.ToRegister(destination), src); ++ } else { ++ __ St_d(src, g.ToMemOperand(destination)); ++ } ++ } else if (source->IsStackSlot()) { ++ DCHECK(destination->IsRegister() || destination->IsStackSlot()); ++ MemOperand src = g.ToMemOperand(source); ++ if (destination->IsRegister()) { ++ __ Ld_d(g.ToRegister(destination), src); ++ } else { ++ Register temp = kScratchReg; ++ __ Ld_d(temp, src); ++ __ St_d(temp, g.ToMemOperand(destination)); ++ } ++ } else if (source->IsConstant()) { ++ Constant src = g.ToConstant(source); ++ if (destination->IsRegister() || destination->IsStackSlot()) { ++ Register dst = ++ destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; ++ switch (src.type()) { ++ case Constant::kInt32: ++ __ li(dst, Operand(src.ToInt32())); ++ break; ++ case Constant::kFloat32: ++ __ li(dst, Operand::EmbeddedNumber(src.ToFloat32())); ++ break; ++ case Constant::kInt64: ++ if (RelocInfo::IsWasmReference(src.rmode())) { ++ __ li(dst, Operand(src.ToInt64(), src.rmode())); ++ } else { ++ __ li(dst, Operand(src.ToInt64())); ++ } ++ break; ++ case Constant::kFloat64: ++ __ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value())); ++ break; ++ case Constant::kExternalReference: ++ __ li(dst, src.ToExternalReference()); ++ break; ++ case Constant::kDelayedStringConstant: ++ __ li(dst, src.ToDelayedStringConstant()); ++ break; ++ case Constant::kHeapObject: { ++ Handle src_object = src.ToHeapObject(); ++ RootIndex index; ++ if (IsMaterializableFromRoot(src_object, &index)) { ++ __ LoadRoot(dst, index); ++ } else { ++ __ li(dst, src_object); ++ } ++ break; ++ } ++ case Constant::kCompressedHeapObject: ++ UNREACHABLE(); ++ case Constant::kRpoNumber: ++ UNREACHABLE(); // TODO(titzer): loading RPO numbers on LA64. ++ break; ++ } ++ if (destination->IsStackSlot()) __ St_d(dst, g.ToMemOperand(destination)); ++ } else if (src.type() == Constant::kFloat32) { ++ if (destination->IsFPStackSlot()) { ++ MemOperand dst = g.ToMemOperand(destination); ++ if (bit_cast(src.ToFloat32()) == 0) { ++ __ St_d(zero_reg, dst); ++ } else { ++ __ li(kScratchReg, Operand(bit_cast(src.ToFloat32()))); ++ __ St_d(kScratchReg, dst); ++ } ++ } else { ++ DCHECK(destination->IsFPRegister()); ++ FloatRegister dst = g.ToSingleRegister(destination); ++ __ Move(dst, src.ToFloat32()); ++ } ++ } else { ++ DCHECK_EQ(Constant::kFloat64, src.type()); ++ DoubleRegister dst = destination->IsFPRegister() ++ ? g.ToDoubleRegister(destination) ++ : kScratchDoubleReg; ++ __ Move(dst, src.ToFloat64().value()); ++ if (destination->IsFPStackSlot()) { ++ __ Fst_d(dst, g.ToMemOperand(destination)); ++ } ++ } ++ } else if (source->IsFPRegister()) { ++ FPURegister src = g.ToDoubleRegister(source); ++ if (destination->IsFPRegister()) { ++ FPURegister dst = g.ToDoubleRegister(destination); ++ __ Move(dst, src); ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ __ Fst_d(src, g.ToMemOperand(destination)); ++ } ++ } else if (source->IsFPStackSlot()) { ++ DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); ++ MemOperand src = g.ToMemOperand(source); ++ if (destination->IsFPRegister()) { ++ __ Fld_d(g.ToDoubleRegister(destination), src); ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ FPURegister temp = kScratchDoubleReg; ++ __ Fld_d(temp, src); ++ __ Fst_d(temp, g.ToMemOperand(destination)); ++ } ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void CodeGenerator::AssembleSwap(InstructionOperand* source, ++ InstructionOperand* destination) { ++ La64OperandConverter g(this, nullptr); ++ // Dispatch on the source and destination operand kinds. Not all ++ // combinations are possible. ++ if (source->IsRegister()) { ++ // Register-register. ++ Register temp = kScratchReg; ++ Register src = g.ToRegister(source); ++ if (destination->IsRegister()) { ++ Register dst = g.ToRegister(destination); ++ __ Move(temp, src); ++ __ Move(src, dst); ++ __ Move(dst, temp); ++ } else { ++ DCHECK(destination->IsStackSlot()); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ mov(temp, src); ++ __ Ld_d(src, dst); ++ __ St_d(temp, dst); ++ } ++ } else if (source->IsStackSlot()) { ++ DCHECK(destination->IsStackSlot()); ++ Register temp_0 = kScratchReg; ++ Register temp_1 = kScratchReg2; ++ MemOperand src = g.ToMemOperand(source); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ Ld_d(temp_0, src); ++ __ Ld_d(temp_1, dst); ++ __ St_d(temp_0, dst); ++ __ St_d(temp_1, src); ++ } else if (source->IsFPRegister()) { ++ FPURegister temp = kScratchDoubleReg; ++ FPURegister src = g.ToDoubleRegister(source); ++ if (destination->IsFPRegister()) { ++ FPURegister dst = g.ToDoubleRegister(destination); ++ __ Move(temp, src); ++ __ Move(src, dst); ++ __ Move(dst, temp); ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ Move(temp, src); ++ __ Fld_d(src, dst); ++ __ Fst_d(temp, dst); ++ } ++ } else if (source->IsFPStackSlot()) { ++ DCHECK(destination->IsFPStackSlot()); ++ Register temp_0 = kScratchReg; ++ MemOperand src0 = g.ToMemOperand(source); ++ MemOperand src1(src0.base(), src0.offset() + kIntSize); ++ MemOperand dst0 = g.ToMemOperand(destination); ++ MemOperand dst1(dst0.base(), dst0.offset() + kIntSize); ++ FPURegister temp_1 = kScratchDoubleReg; ++ __ Fld_d(temp_1, dst0); // Save destination in temp_1. ++ __ Ld_w(temp_0, src0); // Then use temp_0 to copy source to destination. ++ __ St_w(temp_0, dst0); ++ __ Ld_w(temp_0, src1); ++ __ St_w(temp_0, dst1); ++ __ Fst_d(temp_1, src0); ++ } else { ++ // No other combinations are possible. ++ UNREACHABLE(); ++ } ++} ++ ++void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { ++ // On 64-bit LA64 we emit the jump tables inline. ++ UNREACHABLE(); ++} ++ ++#undef ASSEMBLE_ATOMIC_LOAD_INTEGER ++#undef ASSEMBLE_ATOMIC_STORE_INTEGER ++#undef ASSEMBLE_ATOMIC_BINOP ++#undef ASSEMBLE_ATOMIC_BINOP_EXT ++#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER ++#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT ++#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER ++#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT ++#undef ASSEMBLE_IEEE754_BINOP ++#undef ASSEMBLE_IEEE754_UNOP ++ ++#undef TRACE_MSG ++#undef TRACE_UNIMPL ++#undef __ ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-codes-loongarch64.h +@@ -0,0 +1,432 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ ++#define V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++// LA64-specific opcodes that specify which assembly sequence to emit. ++// Most opcodes specify a single instruction. ++#define TARGET_ARCH_OPCODE_LIST(V) \ ++ V(La64Add) \ ++ V(La64Dadd) \ ++ V(La64DaddOvf) \ ++ V(La64Sub) \ ++ V(La64Dsub) \ ++ V(La64DsubOvf) \ ++ V(La64Mul) \ ++ V(La64MulOvf) \ ++ V(La64MulHigh) \ ++ V(La64DMulHigh) \ ++ V(La64MulHighU) \ ++ V(La64Dmul) \ ++ V(La64Div) \ ++ V(La64Ddiv) \ ++ V(La64DivU) \ ++ V(La64DdivU) \ ++ V(La64Mod) \ ++ V(La64Dmod) \ ++ V(La64ModU) \ ++ V(La64DmodU) \ ++ V(La64And) \ ++ V(La64And32) \ ++ V(La64Or) \ ++ V(La64Or32) \ ++ V(La64Nor) \ ++ V(La64Nor32) \ ++ V(La64Xor) \ ++ V(La64Xor32) \ ++ V(La64Clz) \ ++ V(La64Lsa) \ ++ V(La64Dlsa) \ ++ V(La64Shl) \ ++ V(La64Shr) \ ++ V(La64Sar) \ ++ V(La64Ext) \ ++ V(La64Ins) \ ++ V(La64Dext) \ ++ V(La64Dins) \ ++ V(La64Dclz) \ ++ V(La64Ctz) \ ++ V(La64Dctz) \ ++ V(La64Popcnt) \ ++ V(La64Dpopcnt) \ ++ V(La64Dshl) \ ++ V(La64Dshr) \ ++ V(La64Dsar) \ ++ V(La64Ror) \ ++ V(La64Dror) \ ++ V(La64Mov) \ ++ V(La64Tst) \ ++ V(La64Cmp) \ ++ V(La64CmpS) \ ++ V(La64AddS) \ ++ V(La64SubS) \ ++ V(La64MulS) \ ++ V(La64DivS) \ ++ V(La64ModS) \ ++ V(La64AbsS) \ ++ V(La64NegS) \ ++ V(La64SqrtS) \ ++ V(La64MaxS) \ ++ V(La64MinS) \ ++ V(La64CmpD) \ ++ V(La64AddD) \ ++ V(La64SubD) \ ++ V(La64MulD) \ ++ V(La64DivD) \ ++ V(La64ModD) \ ++ V(La64AbsD) \ ++ V(La64NegD) \ ++ V(La64SqrtD) \ ++ V(La64MaxD) \ ++ V(La64MinD) \ ++ V(La64Float64RoundDown) \ ++ V(La64Float64RoundTruncate) \ ++ V(La64Float64RoundUp) \ ++ V(La64Float64RoundTiesEven) \ ++ V(La64Float32RoundDown) \ ++ V(La64Float32RoundTruncate) \ ++ V(La64Float32RoundUp) \ ++ V(La64Float32RoundTiesEven) \ ++ V(La64CvtSD) \ ++ V(La64CvtDS) \ ++ V(La64TruncWD) \ ++ V(La64RoundWD) \ ++ V(La64FloorWD) \ ++ V(La64CeilWD) \ ++ V(La64TruncWS) \ ++ V(La64RoundWS) \ ++ V(La64FloorWS) \ ++ V(La64CeilWS) \ ++ V(La64TruncLS) \ ++ V(La64TruncLD) \ ++ V(La64TruncUwD) \ ++ V(La64TruncUwS) \ ++ V(La64TruncUlS) \ ++ V(La64TruncUlD) \ ++ V(La64CvtDW) \ ++ V(La64CvtSL) \ ++ V(La64CvtSW) \ ++ V(La64CvtSUw) \ ++ V(La64CvtSUl) \ ++ V(La64CvtDL) \ ++ V(La64CvtDUw) \ ++ V(La64CvtDUl) \ ++ V(La64Lb) \ ++ V(La64Lbu) \ ++ V(La64Sb) \ ++ V(La64Lh) \ ++ V(La64Ulh) \ ++ V(La64Lhu) \ ++ V(La64Ulhu) \ ++ V(La64Sh) \ ++ V(La64Ush) \ ++ V(La64Ld) \ ++ V(La64Uld) \ ++ V(La64Lw) \ ++ V(La64Ulw) \ ++ V(La64Lwu) \ ++ V(La64Ulwu) \ ++ V(La64Sw) \ ++ V(La64Usw) \ ++ V(La64Sd) \ ++ V(La64Usd) \ ++ V(La64Lwc1) \ ++ V(La64Ulwc1) \ ++ V(La64Swc1) \ ++ V(La64Uswc1) \ ++ V(La64Ldc1) \ ++ V(La64Uldc1) \ ++ V(La64Sdc1) \ ++ V(La64Usdc1) \ ++ V(La64BitcastDL) \ ++ V(La64BitcastLD) \ ++ V(La64Float64ExtractLowWord32) \ ++ V(La64Float64ExtractHighWord32) \ ++ V(La64Float64InsertLowWord32) \ ++ V(La64Float64InsertHighWord32) \ ++ V(La64Float32Max) \ ++ V(La64Float64Max) \ ++ V(La64Float32Min) \ ++ V(La64Float64Min) \ ++ V(La64Float64SilenceNaN) \ ++ V(La64Push) \ ++ V(La64Peek) \ ++ V(La64StoreToStackSlot) \ ++ V(La64ByteSwap64) \ ++ V(La64ByteSwap32) \ ++ V(La64StackClaim) \ ++ V(La64Seb) \ ++ V(La64Seh) \ ++ V(La64Sync) \ ++ V(La64AssertEqual) \ ++ V(La64S128Const) \ ++ V(La64S128Zero) \ ++ V(La64S128AllOnes) \ ++ V(La64I32x4Splat) \ ++ V(La64I32x4ExtractLane) \ ++ V(La64I32x4ReplaceLane) \ ++ V(La64I32x4Add) \ ++ V(La64I32x4AddHoriz) \ ++ V(La64I32x4Sub) \ ++ V(La64F64x2Abs) \ ++ V(La64F64x2Neg) \ ++ V(La64F32x4Splat) \ ++ V(La64F32x4ExtractLane) \ ++ V(La64F32x4ReplaceLane) \ ++ V(La64F32x4SConvertI32x4) \ ++ V(La64F32x4UConvertI32x4) \ ++ V(La64I32x4Mul) \ ++ V(La64I32x4MaxS) \ ++ V(La64I32x4MinS) \ ++ V(La64I32x4Eq) \ ++ V(La64I32x4Ne) \ ++ V(La64I32x4Shl) \ ++ V(La64I32x4ShrS) \ ++ V(La64I32x4ShrU) \ ++ V(La64I32x4MaxU) \ ++ V(La64I32x4MinU) \ ++ V(La64F64x2Sqrt) \ ++ V(La64F64x2Add) \ ++ V(La64F64x2Sub) \ ++ V(La64F64x2Mul) \ ++ V(La64F64x2Div) \ ++ V(La64F64x2Min) \ ++ V(La64F64x2Max) \ ++ V(La64F64x2Eq) \ ++ V(La64F64x2Ne) \ ++ V(La64F64x2Lt) \ ++ V(La64F64x2Le) \ ++ V(La64F64x2Splat) \ ++ V(La64F64x2ExtractLane) \ ++ V(La64F64x2ReplaceLane) \ ++ V(La64F64x2Pmin) \ ++ V(La64F64x2Pmax) \ ++ V(La64F64x2Ceil) \ ++ V(La64F64x2Floor) \ ++ V(La64F64x2Trunc) \ ++ V(La64F64x2NearestInt) \ ++ V(La64I64x2Splat) \ ++ V(La64I64x2ExtractLane) \ ++ V(La64I64x2ReplaceLane) \ ++ V(La64I64x2Add) \ ++ V(La64I64x2Sub) \ ++ V(La64I64x2Mul) \ ++ V(La64I64x2Neg) \ ++ V(La64I64x2Shl) \ ++ V(La64I64x2ShrS) \ ++ V(La64I64x2ShrU) \ ++ V(La64F32x4Abs) \ ++ V(La64F32x4Neg) \ ++ V(La64F32x4Sqrt) \ ++ V(La64F32x4RecipApprox) \ ++ V(La64F32x4RecipSqrtApprox) \ ++ V(La64F32x4Add) \ ++ V(La64F32x4AddHoriz) \ ++ V(La64F32x4Sub) \ ++ V(La64F32x4Mul) \ ++ V(La64F32x4Div) \ ++ V(La64F32x4Max) \ ++ V(La64F32x4Min) \ ++ V(La64F32x4Eq) \ ++ V(La64F32x4Ne) \ ++ V(La64F32x4Lt) \ ++ V(La64F32x4Le) \ ++ V(La64F32x4Pmin) \ ++ V(La64F32x4Pmax) \ ++ V(La64F32x4Ceil) \ ++ V(La64F32x4Floor) \ ++ V(La64F32x4Trunc) \ ++ V(La64F32x4NearestInt) \ ++ V(La64I32x4SConvertF32x4) \ ++ V(La64I32x4UConvertF32x4) \ ++ V(La64I32x4Neg) \ ++ V(La64I32x4GtS) \ ++ V(La64I32x4GeS) \ ++ V(La64I32x4GtU) \ ++ V(La64I32x4GeU) \ ++ V(La64I32x4Abs) \ ++ V(La64I32x4BitMask) \ ++ V(La64I16x8Splat) \ ++ V(La64I16x8ExtractLaneU) \ ++ V(La64I16x8ExtractLaneS) \ ++ V(La64I16x8ReplaceLane) \ ++ V(La64I16x8Neg) \ ++ V(La64I16x8Shl) \ ++ V(La64I16x8ShrS) \ ++ V(La64I16x8ShrU) \ ++ V(La64I16x8Add) \ ++ V(La64I16x8AddSaturateS) \ ++ V(La64I16x8AddHoriz) \ ++ V(La64I16x8Sub) \ ++ V(La64I16x8SubSaturateS) \ ++ V(La64I16x8Mul) \ ++ V(La64I16x8MaxS) \ ++ V(La64I16x8MinS) \ ++ V(La64I16x8Eq) \ ++ V(La64I16x8Ne) \ ++ V(La64I16x8GtS) \ ++ V(La64I16x8GeS) \ ++ V(La64I16x8AddSaturateU) \ ++ V(La64I16x8SubSaturateU) \ ++ V(La64I16x8MaxU) \ ++ V(La64I16x8MinU) \ ++ V(La64I16x8GtU) \ ++ V(La64I16x8GeU) \ ++ V(La64I16x8RoundingAverageU) \ ++ V(La64I16x8Abs) \ ++ V(La64I16x8BitMask) \ ++ V(La64I8x16Splat) \ ++ V(La64I8x16ExtractLaneU) \ ++ V(La64I8x16ExtractLaneS) \ ++ V(La64I8x16ReplaceLane) \ ++ V(La64I8x16Neg) \ ++ V(La64I8x16Shl) \ ++ V(La64I8x16ShrS) \ ++ V(La64I8x16Add) \ ++ V(La64I8x16AddSaturateS) \ ++ V(La64I8x16Sub) \ ++ V(La64I8x16SubSaturateS) \ ++ V(La64I8x16Mul) \ ++ V(La64I8x16MaxS) \ ++ V(La64I8x16MinS) \ ++ V(La64I8x16Eq) \ ++ V(La64I8x16Ne) \ ++ V(La64I8x16GtS) \ ++ V(La64I8x16GeS) \ ++ V(La64I8x16ShrU) \ ++ V(La64I8x16AddSaturateU) \ ++ V(La64I8x16SubSaturateU) \ ++ V(La64I8x16MaxU) \ ++ V(La64I8x16MinU) \ ++ V(La64I8x16GtU) \ ++ V(La64I8x16GeU) \ ++ V(La64I8x16RoundingAverageU) \ ++ V(La64I8x16Abs) \ ++ V(La64I8x16BitMask) \ ++ V(La64S128And) \ ++ V(La64S128Or) \ ++ V(La64S128Xor) \ ++ V(La64S128Not) \ ++ V(La64S128Select) \ ++ V(La64S128AndNot) \ ++ V(La64V32x4AnyTrue) \ ++ V(La64V32x4AllTrue) \ ++ V(La64V16x8AnyTrue) \ ++ V(La64V16x8AllTrue) \ ++ V(La64V8x16AnyTrue) \ ++ V(La64V8x16AllTrue) \ ++ V(La64S32x4InterleaveRight) \ ++ V(La64S32x4InterleaveLeft) \ ++ V(La64S32x4PackEven) \ ++ V(La64S32x4PackOdd) \ ++ V(La64S32x4InterleaveEven) \ ++ V(La64S32x4InterleaveOdd) \ ++ V(La64S32x4Shuffle) \ ++ V(La64S16x8InterleaveRight) \ ++ V(La64S16x8InterleaveLeft) \ ++ V(La64S16x8PackEven) \ ++ V(La64S16x8PackOdd) \ ++ V(La64S16x8InterleaveEven) \ ++ V(La64S16x8InterleaveOdd) \ ++ V(La64S16x4Reverse) \ ++ V(La64S16x2Reverse) \ ++ V(La64S8x16InterleaveRight) \ ++ V(La64S8x16InterleaveLeft) \ ++ V(La64S8x16PackEven) \ ++ V(La64S8x16PackOdd) \ ++ V(La64S8x16InterleaveEven) \ ++ V(La64S8x16InterleaveOdd) \ ++ V(La64I8x16Shuffle) \ ++ V(La64I8x16Swizzle) \ ++ V(La64S8x16Concat) \ ++ V(La64S8x8Reverse) \ ++ V(La64S8x4Reverse) \ ++ V(La64S8x2Reverse) \ ++ V(La64S8x16LoadSplat) \ ++ V(La64S16x8LoadSplat) \ ++ V(La64S32x4LoadSplat) \ ++ V(La64S64x2LoadSplat) \ ++ V(La64I16x8Load8x8S) \ ++ V(La64I16x8Load8x8U) \ ++ V(La64I32x4Load16x4S) \ ++ V(La64I32x4Load16x4U) \ ++ V(La64I64x2Load32x2S) \ ++ V(La64I64x2Load32x2U) \ ++ V(La64I32x4SConvertI16x8Low) \ ++ V(La64I32x4SConvertI16x8High) \ ++ V(La64I32x4UConvertI16x8Low) \ ++ V(La64I32x4UConvertI16x8High) \ ++ V(La64I16x8SConvertI8x16Low) \ ++ V(La64I16x8SConvertI8x16High) \ ++ V(La64I16x8SConvertI32x4) \ ++ V(La64I16x8UConvertI32x4) \ ++ V(La64I16x8UConvertI8x16Low) \ ++ V(La64I16x8UConvertI8x16High) \ ++ V(La64I8x16SConvertI16x8) \ ++ V(La64I8x16UConvertI16x8) \ ++ V(La64Word64AtomicLoadUint8) \ ++ V(La64Word64AtomicLoadUint16) \ ++ V(La64Word64AtomicLoadUint32) \ ++ V(La64Word64AtomicLoadUint64) \ ++ V(La64Word64AtomicStoreWord8) \ ++ V(La64Word64AtomicStoreWord16) \ ++ V(La64Word64AtomicStoreWord32) \ ++ V(La64Word64AtomicStoreWord64) \ ++ V(La64Word64AtomicAddUint8) \ ++ V(La64Word64AtomicAddUint16) \ ++ V(La64Word64AtomicAddUint32) \ ++ V(La64Word64AtomicAddUint64) \ ++ V(La64Word64AtomicSubUint8) \ ++ V(La64Word64AtomicSubUint16) \ ++ V(La64Word64AtomicSubUint32) \ ++ V(La64Word64AtomicSubUint64) \ ++ V(La64Word64AtomicAndUint8) \ ++ V(La64Word64AtomicAndUint16) \ ++ V(La64Word64AtomicAndUint32) \ ++ V(La64Word64AtomicAndUint64) \ ++ V(La64Word64AtomicOrUint8) \ ++ V(La64Word64AtomicOrUint16) \ ++ V(La64Word64AtomicOrUint32) \ ++ V(La64Word64AtomicOrUint64) \ ++ V(La64Word64AtomicXorUint8) \ ++ V(La64Word64AtomicXorUint16) \ ++ V(La64Word64AtomicXorUint32) \ ++ V(La64Word64AtomicXorUint64) \ ++ V(La64Word64AtomicExchangeUint8) \ ++ V(La64Word64AtomicExchangeUint16) \ ++ V(La64Word64AtomicExchangeUint32) \ ++ V(La64Word64AtomicExchangeUint64) \ ++ V(La64Word64AtomicCompareExchangeUint8) \ ++ V(La64Word64AtomicCompareExchangeUint16) \ ++ V(La64Word64AtomicCompareExchangeUint32) \ ++ V(La64Word64AtomicCompareExchangeUint64) ++ ++// Addressing modes represent the "shape" of inputs to an instruction. ++// Many instructions support multiple addressing modes. Addressing modes ++// are encoded into the InstructionCode of the instruction and tell the ++// code generator after register allocation which assembler method to call. ++// ++// We use the following local notation for addressing modes: ++// ++// R = register ++// O = register or stack slot ++// D = double register ++// I = immediate (handle, external, int32) ++// MRI = [register + immediate] ++// MRR = [register + register] ++// TODO(plind): Add the new r6 address modes. ++#define TARGET_ADDRESSING_MODE_LIST(V) \ ++ V(MRI) /* [%r0 + K] */ \ ++ V(MRR) /* [%r0 + %r1] */ ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_COMPILER_BACKEND_LOONGARCH64_INSTRUCTION_CODES_LOONGARCH64_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-scheduler-loongarch64.cc +@@ -0,0 +1,1554 @@ ++// Copyright 2015 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/compiler/backend/instruction-scheduler.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++bool InstructionScheduler::SchedulerSupported() { return true; } ++ ++int InstructionScheduler::GetTargetInstructionFlags( ++ const Instruction* instr) const { ++ switch (instr->arch_opcode()) { ++ case kLa64AbsD: ++ case kLa64AbsS: ++ case kLa64Add: ++ case kLa64AddD: ++ case kLa64AddS: ++ case kLa64And: ++ case kLa64And32: ++ case kLa64AssertEqual: ++ case kLa64BitcastDL: ++ case kLa64BitcastLD: ++ case kLa64ByteSwap32: ++ case kLa64ByteSwap64: ++ case kLa64CeilWD: ++ case kLa64CeilWS: ++ case kLa64Clz: ++ case kLa64Cmp: ++ case kLa64CmpD: ++ case kLa64CmpS: ++ case kLa64Ctz: ++ case kLa64CvtDL: ++ case kLa64CvtDS: ++ case kLa64CvtDUl: ++ case kLa64CvtDUw: ++ case kLa64CvtDW: ++ case kLa64CvtSD: ++ case kLa64CvtSL: ++ case kLa64CvtSUl: ++ case kLa64CvtSUw: ++ case kLa64CvtSW: ++ case kLa64DMulHigh: ++ case kLa64MulHighU: ++ case kLa64Dadd: ++ case kLa64DaddOvf: ++ case kLa64Dclz: ++ case kLa64Dctz: ++ case kLa64Ddiv: ++ case kLa64DdivU: ++ case kLa64Dext: ++ case kLa64Dins: ++ case kLa64Div: ++ case kLa64DivD: ++ case kLa64DivS: ++ case kLa64DivU: ++ case kLa64Dlsa: ++ case kLa64Dmod: ++ case kLa64DmodU: ++ case kLa64Dmul: ++ case kLa64Dpopcnt: ++ case kLa64Dror: ++ case kLa64Dsar: ++ case kLa64Dshl: ++ case kLa64Dshr: ++ case kLa64Dsub: ++ case kLa64DsubOvf: ++ case kLa64Ext: ++ case kLa64F64x2Abs: ++ case kLa64F64x2Neg: ++ case kLa64F64x2Sqrt: ++ case kLa64F64x2Add: ++ case kLa64F64x2Sub: ++ case kLa64F64x2Mul: ++ case kLa64F64x2Div: ++ case kLa64F64x2Min: ++ case kLa64F64x2Max: ++ case kLa64F64x2Eq: ++ case kLa64F64x2Ne: ++ case kLa64F64x2Lt: ++ case kLa64F64x2Le: ++ case kLa64F64x2Pmin: ++ case kLa64F64x2Pmax: ++ case kLa64F64x2Ceil: ++ case kLa64F64x2Floor: ++ case kLa64F64x2Trunc: ++ case kLa64F64x2NearestInt: ++ case kLa64I64x2Splat: ++ case kLa64I64x2ExtractLane: ++ case kLa64I64x2ReplaceLane: ++ case kLa64I64x2Add: ++ case kLa64I64x2Sub: ++ case kLa64I64x2Mul: ++ case kLa64I64x2Neg: ++ case kLa64I64x2Shl: ++ case kLa64I64x2ShrS: ++ case kLa64I64x2ShrU: ++ case kLa64F32x4Abs: ++ case kLa64F32x4Add: ++ case kLa64F32x4AddHoriz: ++ case kLa64F32x4Eq: ++ case kLa64F32x4ExtractLane: ++ case kLa64F32x4Lt: ++ case kLa64F32x4Le: ++ case kLa64F32x4Max: ++ case kLa64F32x4Min: ++ case kLa64F32x4Mul: ++ case kLa64F32x4Div: ++ case kLa64F32x4Ne: ++ case kLa64F32x4Neg: ++ case kLa64F32x4Sqrt: ++ case kLa64F32x4RecipApprox: ++ case kLa64F32x4RecipSqrtApprox: ++ case kLa64F32x4ReplaceLane: ++ case kLa64F32x4SConvertI32x4: ++ case kLa64F32x4Splat: ++ case kLa64F32x4Sub: ++ case kLa64F32x4UConvertI32x4: ++ case kLa64F32x4Pmin: ++ case kLa64F32x4Pmax: ++ case kLa64F32x4Ceil: ++ case kLa64F32x4Floor: ++ case kLa64F32x4Trunc: ++ case kLa64F32x4NearestInt: ++ case kLa64F64x2Splat: ++ case kLa64F64x2ExtractLane: ++ case kLa64F64x2ReplaceLane: ++ case kLa64Float32Max: ++ case kLa64Float32Min: ++ case kLa64Float32RoundDown: ++ case kLa64Float32RoundTiesEven: ++ case kLa64Float32RoundTruncate: ++ case kLa64Float32RoundUp: ++ case kLa64Float64ExtractLowWord32: ++ case kLa64Float64ExtractHighWord32: ++ case kLa64Float64InsertLowWord32: ++ case kLa64Float64InsertHighWord32: ++ case kLa64Float64Max: ++ case kLa64Float64Min: ++ case kLa64Float64RoundDown: ++ case kLa64Float64RoundTiesEven: ++ case kLa64Float64RoundTruncate: ++ case kLa64Float64RoundUp: ++ case kLa64Float64SilenceNaN: ++ case kLa64FloorWD: ++ case kLa64FloorWS: ++ case kLa64I16x8Add: ++ case kLa64I16x8AddHoriz: ++ case kLa64I16x8AddSaturateS: ++ case kLa64I16x8AddSaturateU: ++ case kLa64I16x8Eq: ++ case kLa64I16x8ExtractLaneU: ++ case kLa64I16x8ExtractLaneS: ++ case kLa64I16x8GeS: ++ case kLa64I16x8GeU: ++ case kLa64I16x8GtS: ++ case kLa64I16x8GtU: ++ case kLa64I16x8MaxS: ++ case kLa64I16x8MaxU: ++ case kLa64I16x8MinS: ++ case kLa64I16x8MinU: ++ case kLa64I16x8Mul: ++ case kLa64I16x8Ne: ++ case kLa64I16x8Neg: ++ case kLa64I16x8ReplaceLane: ++ case kLa64I8x16SConvertI16x8: ++ case kLa64I16x8SConvertI32x4: ++ case kLa64I16x8SConvertI8x16High: ++ case kLa64I16x8SConvertI8x16Low: ++ case kLa64I16x8Shl: ++ case kLa64I16x8ShrS: ++ case kLa64I16x8ShrU: ++ case kLa64I16x8Splat: ++ case kLa64I16x8Sub: ++ case kLa64I16x8SubSaturateS: ++ case kLa64I16x8SubSaturateU: ++ case kLa64I8x16UConvertI16x8: ++ case kLa64I16x8UConvertI32x4: ++ case kLa64I16x8UConvertI8x16High: ++ case kLa64I16x8UConvertI8x16Low: ++ case kLa64I16x8RoundingAverageU: ++ case kLa64I16x8Abs: ++ case kLa64I16x8BitMask: ++ case kLa64I32x4Add: ++ case kLa64I32x4AddHoriz: ++ case kLa64I32x4Eq: ++ case kLa64I32x4ExtractLane: ++ case kLa64I32x4GeS: ++ case kLa64I32x4GeU: ++ case kLa64I32x4GtS: ++ case kLa64I32x4GtU: ++ case kLa64I32x4MaxS: ++ case kLa64I32x4MaxU: ++ case kLa64I32x4MinS: ++ case kLa64I32x4MinU: ++ case kLa64I32x4Mul: ++ case kLa64I32x4Ne: ++ case kLa64I32x4Neg: ++ case kLa64I32x4ReplaceLane: ++ case kLa64I32x4SConvertF32x4: ++ case kLa64I32x4SConvertI16x8High: ++ case kLa64I32x4SConvertI16x8Low: ++ case kLa64I32x4Shl: ++ case kLa64I32x4ShrS: ++ case kLa64I32x4ShrU: ++ case kLa64I32x4Splat: ++ case kLa64I32x4Sub: ++ case kLa64I32x4UConvertF32x4: ++ case kLa64I32x4UConvertI16x8High: ++ case kLa64I32x4UConvertI16x8Low: ++ case kLa64I32x4Abs: ++ case kLa64I32x4BitMask: ++ case kLa64I8x16Add: ++ case kLa64I8x16AddSaturateS: ++ case kLa64I8x16AddSaturateU: ++ case kLa64I8x16Eq: ++ case kLa64I8x16ExtractLaneU: ++ case kLa64I8x16ExtractLaneS: ++ case kLa64I8x16GeS: ++ case kLa64I8x16GeU: ++ case kLa64I8x16GtS: ++ case kLa64I8x16GtU: ++ case kLa64I8x16MaxS: ++ case kLa64I8x16MaxU: ++ case kLa64I8x16MinS: ++ case kLa64I8x16MinU: ++ case kLa64I8x16Mul: ++ case kLa64I8x16Ne: ++ case kLa64I8x16Neg: ++ case kLa64I8x16ReplaceLane: ++ case kLa64I8x16Shl: ++ case kLa64I8x16ShrS: ++ case kLa64I8x16ShrU: ++ case kLa64I8x16Splat: ++ case kLa64I8x16Sub: ++ case kLa64I8x16SubSaturateS: ++ case kLa64I8x16SubSaturateU: ++ case kLa64I8x16RoundingAverageU: ++ case kLa64I8x16Abs: ++ case kLa64I8x16BitMask: ++ case kLa64Ins: ++ case kLa64Lsa: ++ case kLa64MaxD: ++ case kLa64MaxS: ++ case kLa64MinD: ++ case kLa64MinS: ++ case kLa64Mod: ++ case kLa64ModU: ++ case kLa64Mov: ++ case kLa64Mul: ++ case kLa64MulD: ++ case kLa64MulHigh: ++ case kLa64MulOvf: ++ case kLa64MulS: ++ case kLa64NegD: ++ case kLa64NegS: ++ case kLa64Nor: ++ case kLa64Nor32: ++ case kLa64Or: ++ case kLa64Or32: ++ case kLa64Popcnt: ++ case kLa64Ror: ++ case kLa64RoundWD: ++ case kLa64RoundWS: ++ case kLa64S128And: ++ case kLa64S128Or: ++ case kLa64S128Not: ++ case kLa64S128Select: ++ case kLa64S128AndNot: ++ case kLa64S128Xor: ++ case kLa64S128Const: ++ case kLa64S128Zero: ++ case kLa64S128AllOnes: ++ case kLa64S16x8InterleaveEven: ++ case kLa64S16x8InterleaveOdd: ++ case kLa64S16x8InterleaveLeft: ++ case kLa64S16x8InterleaveRight: ++ case kLa64S16x8PackEven: ++ case kLa64S16x8PackOdd: ++ case kLa64S16x2Reverse: ++ case kLa64S16x4Reverse: ++ case kLa64V8x16AllTrue: ++ case kLa64V8x16AnyTrue: ++ case kLa64V32x4AllTrue: ++ case kLa64V32x4AnyTrue: ++ case kLa64V16x8AllTrue: ++ case kLa64V16x8AnyTrue: ++ case kLa64S32x4InterleaveEven: ++ case kLa64S32x4InterleaveOdd: ++ case kLa64S32x4InterleaveLeft: ++ case kLa64S32x4InterleaveRight: ++ case kLa64S32x4PackEven: ++ case kLa64S32x4PackOdd: ++ case kLa64S32x4Shuffle: ++ case kLa64S8x16Concat: ++ case kLa64S8x16InterleaveEven: ++ case kLa64S8x16InterleaveOdd: ++ case kLa64S8x16InterleaveLeft: ++ case kLa64S8x16InterleaveRight: ++ case kLa64S8x16PackEven: ++ case kLa64S8x16PackOdd: ++ case kLa64S8x2Reverse: ++ case kLa64S8x4Reverse: ++ case kLa64S8x8Reverse: ++ case kLa64I8x16Shuffle: ++ case kLa64I8x16Swizzle: ++ case kLa64Sar: ++ case kLa64Seb: ++ case kLa64Seh: ++ case kLa64Shl: ++ case kLa64Shr: ++ case kLa64SqrtD: ++ case kLa64SqrtS: ++ case kLa64Sub: ++ case kLa64SubD: ++ case kLa64SubS: ++ case kLa64TruncLD: ++ case kLa64TruncLS: ++ case kLa64TruncUlD: ++ case kLa64TruncUlS: ++ case kLa64TruncUwD: ++ case kLa64TruncUwS: ++ case kLa64TruncWD: ++ case kLa64TruncWS: ++ case kLa64Tst: ++ case kLa64Xor: ++ case kLa64Xor32: ++ return kNoOpcodeFlags; ++ ++ case kLa64Lb: ++ case kLa64Lbu: ++ case kLa64Ld: ++ case kLa64Ldc1: ++ case kLa64Lh: ++ case kLa64Lhu: ++ case kLa64Lw: ++ case kLa64Lwc1: ++ case kLa64Lwu: ++ case kLa64Peek: ++ case kLa64Uld: ++ case kLa64Uldc1: ++ case kLa64Ulh: ++ case kLa64Ulhu: ++ case kLa64Ulw: ++ case kLa64Ulwu: ++ case kLa64Ulwc1: ++ case kLa64S8x16LoadSplat: ++ case kLa64S16x8LoadSplat: ++ case kLa64S32x4LoadSplat: ++ case kLa64S64x2LoadSplat: ++ case kLa64I16x8Load8x8S: ++ case kLa64I16x8Load8x8U: ++ case kLa64I32x4Load16x4S: ++ case kLa64I32x4Load16x4U: ++ case kLa64I64x2Load32x2S: ++ case kLa64I64x2Load32x2U: ++ case kLa64Word64AtomicLoadUint8: ++ case kLa64Word64AtomicLoadUint16: ++ case kLa64Word64AtomicLoadUint32: ++ case kLa64Word64AtomicLoadUint64: ++ ++ return kIsLoadOperation; ++ ++ case kLa64ModD: ++ case kLa64ModS: ++ case kLa64Push: ++ case kLa64Sb: ++ case kLa64Sd: ++ case kLa64Sdc1: ++ case kLa64Sh: ++ case kLa64StackClaim: ++ case kLa64StoreToStackSlot: ++ case kLa64Sw: ++ case kLa64Swc1: ++ case kLa64Usd: ++ case kLa64Usdc1: ++ case kLa64Ush: ++ case kLa64Usw: ++ case kLa64Uswc1: ++ case kLa64Sync: ++ case kLa64Word64AtomicStoreWord8: ++ case kLa64Word64AtomicStoreWord16: ++ case kLa64Word64AtomicStoreWord32: ++ case kLa64Word64AtomicStoreWord64: ++ case kLa64Word64AtomicAddUint8: ++ case kLa64Word64AtomicAddUint16: ++ case kLa64Word64AtomicAddUint32: ++ case kLa64Word64AtomicAddUint64: ++ case kLa64Word64AtomicSubUint8: ++ case kLa64Word64AtomicSubUint16: ++ case kLa64Word64AtomicSubUint32: ++ case kLa64Word64AtomicSubUint64: ++ case kLa64Word64AtomicAndUint8: ++ case kLa64Word64AtomicAndUint16: ++ case kLa64Word64AtomicAndUint32: ++ case kLa64Word64AtomicAndUint64: ++ case kLa64Word64AtomicOrUint8: ++ case kLa64Word64AtomicOrUint16: ++ case kLa64Word64AtomicOrUint32: ++ case kLa64Word64AtomicOrUint64: ++ case kLa64Word64AtomicXorUint8: ++ case kLa64Word64AtomicXorUint16: ++ case kLa64Word64AtomicXorUint32: ++ case kLa64Word64AtomicXorUint64: ++ case kLa64Word64AtomicExchangeUint8: ++ case kLa64Word64AtomicExchangeUint16: ++ case kLa64Word64AtomicExchangeUint32: ++ case kLa64Word64AtomicExchangeUint64: ++ case kLa64Word64AtomicCompareExchangeUint8: ++ case kLa64Word64AtomicCompareExchangeUint16: ++ case kLa64Word64AtomicCompareExchangeUint32: ++ case kLa64Word64AtomicCompareExchangeUint64: ++ return kHasSideEffect; ++ ++#define CASE(Name) case k##Name: ++ COMMON_ARCH_OPCODE_LIST(CASE) ++#undef CASE ++ // Already covered in architecture independent code. ++ UNREACHABLE(); ++ } ++ ++ UNREACHABLE(); ++} ++ ++enum Latency { ++ BRANCH = 4, // Estimated max. ++ RINT_S = 4, // Estimated. ++ RINT_D = 4, // Estimated. ++ ++ MULT = 4, ++ MULTU = 4, ++ DMULT = 4, ++ DMULTU = 4, ++ ++ MUL = 7, ++ DMUL = 7, ++ MUH = 7, ++ MUHU = 7, ++ DMUH = 7, ++ DMUHU = 7, ++ ++ DIV = 50, // Min:11 Max:50 ++ DDIV = 50, ++ DIVU = 50, ++ DDIVU = 50, ++ ++ ABS_S = 4, ++ ABS_D = 4, ++ NEG_S = 4, ++ NEG_D = 4, ++ ADD_S = 4, ++ ADD_D = 4, ++ SUB_S = 4, ++ SUB_D = 4, ++ MAX_S = 4, // Estimated. ++ MIN_S = 4, ++ MAX_D = 4, // Estimated. ++ MIN_D = 4, ++ C_cond_S = 4, ++ C_cond_D = 4, ++ MUL_S = 4, ++ ++ MADD_S = 4, ++ MSUB_S = 4, ++ NMADD_S = 4, ++ NMSUB_S = 4, ++ ++ CABS_cond_S = 4, ++ CABS_cond_D = 4, ++ ++ CVT_D_S = 4, ++ CVT_PS_PW = 4, ++ ++ CVT_S_W = 4, ++ CVT_S_L = 4, ++ CVT_D_W = 4, ++ CVT_D_L = 4, ++ ++ CVT_S_D = 4, ++ ++ CVT_W_S = 4, ++ CVT_W_D = 4, ++ CVT_L_S = 4, ++ CVT_L_D = 4, ++ ++ CEIL_W_S = 4, ++ CEIL_W_D = 4, ++ CEIL_L_S = 4, ++ CEIL_L_D = 4, ++ ++ FLOOR_W_S = 4, ++ FLOOR_W_D = 4, ++ FLOOR_L_S = 4, ++ FLOOR_L_D = 4, ++ ++ ROUND_W_S = 4, ++ ROUND_W_D = 4, ++ ROUND_L_S = 4, ++ ROUND_L_D = 4, ++ ++ TRUNC_W_S = 4, ++ TRUNC_W_D = 4, ++ TRUNC_L_S = 4, ++ TRUNC_L_D = 4, ++ ++ MOV_S = 4, ++ MOV_D = 4, ++ ++ MOVF_S = 4, ++ MOVF_D = 4, ++ ++ MOVN_S = 4, ++ MOVN_D = 4, ++ ++ MOVT_S = 4, ++ MOVT_D = 4, ++ ++ MOVZ_S = 4, ++ MOVZ_D = 4, ++ ++ MUL_D = 5, ++ MADD_D = 5, ++ MSUB_D = 5, ++ NMADD_D = 5, ++ NMSUB_D = 5, ++ ++ RECIP_S = 13, ++ RECIP_D = 26, ++ ++ RSQRT_S = 17, ++ RSQRT_D = 36, ++ ++ DIV_S = 17, ++ SQRT_S = 17, ++ ++ DIV_D = 32, ++ SQRT_D = 32, ++ ++ MTC1 = 4, ++ MTHC1 = 4, ++ DMTC1 = 4, ++ LWC1 = 4, ++ LDC1 = 4, ++ ++ MFC1 = 1, ++ MFHC1 = 1, ++ DMFC1 = 1, ++ MFHI = 1, ++ MFLO = 1, ++ SWC1 = 1, ++ SDC1 = 1, ++}; ++ ++int DadduLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int DsubuLatency(bool is_operand_register = true) { ++ return DadduLatency(is_operand_register); ++} ++ ++int AndLatency(bool is_operand_register = true) { ++ return DadduLatency(is_operand_register); ++} ++ ++int OrLatency(bool is_operand_register = true) { ++ return DadduLatency(is_operand_register); ++} ++ ++int NorLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int XorLatency(bool is_operand_register = true) { ++ return DadduLatency(is_operand_register); ++} ++ ++int MulLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::MUL; ++ } else { ++ return Latency::MUL + 1; ++ } ++} ++ ++int DmulLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::DMUL; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int MulhLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::MUH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int MulhuLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::MUH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int DMulhLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::DMUH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int DivLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::DIV; ++ } else { ++ return Latency::DIV + 1; ++ } ++} ++ ++int DivuLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::DIVU; ++ } else { ++ return Latency::DIVU + 1; ++ } ++} ++ ++int DdivLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::DDIV; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int DdivuLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = Latency::DDIVU; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int ModLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = 1; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int ModuLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = 1; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int DmodLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = 1; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int DmoduLatency(bool is_operand_register = true) { ++ int latency = 0; ++ latency = 1; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int MovzLatency() { return Latency::BRANCH + 1; } ++ ++int MovnLatency() { return Latency::BRANCH + 1; } ++ ++int DlsaLatency() { ++ // Estimated max. ++ return DadduLatency() + 1; ++} ++ ++int CallLatency() { ++ // Estimated. ++ return DadduLatency(false) + Latency::BRANCH + 5; ++} ++ ++int JumpLatency() { ++ // Estimated max. ++ return 1 + DadduLatency() + Latency::BRANCH + 2; ++} ++ ++int SmiUntagLatency() { return 1; } ++ ++int PrepareForTailCallLatency() { ++ // Estimated max. ++ return 2 * (DlsaLatency() + DadduLatency(false)) + 2 + Latency::BRANCH + ++ Latency::BRANCH + 2 * DsubuLatency(false) + 2 + Latency::BRANCH + 1; ++} ++ ++int AssemblePopArgumentsAdoptFrameLatency() { ++ return 1 + Latency::BRANCH + 1 + SmiUntagLatency() + ++ PrepareForTailCallLatency(); ++} ++ ++int AssertLatency() { return 1; } ++ ++int PrepareCallCFunctionLatency() { ++ int frame_alignment = TurboAssembler::ActivationFrameAlignment(); ++ if (frame_alignment > kSystemPointerSize) { ++ return 1 + DsubuLatency(false) + AndLatency(false) + 1; ++ } else { ++ return DsubuLatency(false); ++ } ++} ++ ++int AdjustBaseAndOffsetLatency() { ++ return 3; // Estimated max. ++} ++ ++int AlignedMemoryLatency() { return AdjustBaseAndOffsetLatency() + 1; } ++ ++int UlhuLatency() { return AlignedMemoryLatency(); } ++ ++int UlwLatency() { return AlignedMemoryLatency(); } ++ ++int UlwuLatency() { return AlignedMemoryLatency(); } ++ ++int UldLatency() { return AlignedMemoryLatency(); } ++ ++int Ulwc1Latency() { return AlignedMemoryLatency(); } ++ ++int Uldc1Latency() { return AlignedMemoryLatency(); } ++ ++int UshLatency() { return AlignedMemoryLatency(); } ++ ++int UswLatency() { return AlignedMemoryLatency(); } ++ ++int UsdLatency() { return AlignedMemoryLatency(); } ++ ++int Uswc1Latency() { return AlignedMemoryLatency(); } ++ ++int Usdc1Latency() { return AlignedMemoryLatency(); } ++ ++int Lwc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::LWC1; } ++ ++int Swc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::SWC1; } ++ ++int Sdc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::SDC1; } ++ ++int Ldc1Latency() { return AdjustBaseAndOffsetLatency() + Latency::LDC1; } ++ ++int MultiPushLatency() { ++ int latency = DsubuLatency(false); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ latency++; ++ } ++ return latency; ++} ++ ++int MultiPushFPULatency() { ++ int latency = DsubuLatency(false); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ latency += Sdc1Latency(); ++ } ++ return latency; ++} ++ ++int PushCallerSavedLatency(SaveFPRegsMode fp_mode) { ++ int latency = MultiPushLatency(); ++ if (fp_mode == kSaveFPRegs) { ++ latency += MultiPushFPULatency(); ++ } ++ return latency; ++} ++ ++int MultiPopLatency() { ++ int latency = DadduLatency(false); ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ latency++; ++ } ++ return latency; ++} ++ ++int MultiPopFPULatency() { ++ int latency = DadduLatency(false); ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ latency += Ldc1Latency(); ++ } ++ return latency; ++} ++ ++int PopCallerSavedLatency(SaveFPRegsMode fp_mode) { ++ int latency = MultiPopLatency(); ++ if (fp_mode == kSaveFPRegs) { ++ latency += MultiPopFPULatency(); ++ } ++ return latency; ++} ++ ++int CallCFunctionHelperLatency() { ++ // Estimated. ++ int latency = AndLatency(false) + Latency::BRANCH + 2 + CallLatency(); ++ if (base::OS::ActivationFrameAlignment() > kSystemPointerSize) { ++ latency++; ++ } else { ++ latency += DadduLatency(false); ++ } ++ return latency; ++} ++ ++int CallCFunctionLatency() { return 1 + CallCFunctionHelperLatency(); } ++ ++int AssembleArchJumpLatency() { ++ // Estimated max. ++ return Latency::BRANCH; ++} ++ ++int GenerateSwitchTableLatency() { ++ int latency = 0; ++ latency = DlsaLatency() + 2; ++ latency += 2; ++ return latency; ++} ++ ++int AssembleArchTableSwitchLatency() { ++ return Latency::BRANCH + GenerateSwitchTableLatency(); ++} ++ ++int DropAndRetLatency() { ++ // Estimated max. ++ return DadduLatency(false) + JumpLatency(); ++} ++ ++int AssemblerReturnLatency() { ++ // Estimated max. ++ return DadduLatency(false) + MultiPopLatency() + MultiPopFPULatency() + ++ Latency::BRANCH + DadduLatency() + 1 + DropAndRetLatency(); ++} ++ ++int TryInlineTruncateDoubleToILatency() { ++ return 2 + Latency::TRUNC_W_D + Latency::MFC1 + 2 + AndLatency(false) + ++ Latency::BRANCH; ++} ++ ++int CallStubDelayedLatency() { return 1 + CallLatency(); } ++ ++int TruncateDoubleToIDelayedLatency() { ++ // TODO(la64): This no longer reflects how TruncateDoubleToI is called. ++ return TryInlineTruncateDoubleToILatency() + 1 + DsubuLatency(false) + ++ Sdc1Latency() + CallStubDelayedLatency() + DadduLatency(false) + 1; ++} ++ ++int CheckPageFlagLatency() { ++ return AndLatency(false) + AlignedMemoryLatency() + AndLatency(false) + ++ Latency::BRANCH; ++} ++ ++int SltuLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int BranchShortHelperLatency() { ++ return 2; // Estimated max. ++} ++ ++int BranchShortLatency() { return BranchShortHelperLatency(); } ++ ++int MoveLatency() { return 1; } ++ ++int MovToFloatParametersLatency() { return 2 * MoveLatency(); } ++ ++int MovFromFloatResultLatency() { return MoveLatency(); } ++ ++int DaddOverflowLatency() { ++ // Estimated max. ++ return 6; ++} ++ ++int DsubOverflowLatency() { ++ // Estimated max. ++ return 6; ++} ++ ++int MulOverflowLatency() { ++ // Estimated max. ++ return MulLatency() + MulhLatency() + 2; ++} ++ ++int DclzLatency() { return 1; } ++ ++int CtzLatency() { return 3 + DclzLatency(); } ++ ++int DctzLatency() { return 4; } ++ ++int PopcntLatency() { ++ return 2 + AndLatency() + DsubuLatency() + 1 + AndLatency() + 1 + ++ AndLatency() + DadduLatency() + 1 + DadduLatency() + 1 + AndLatency() + ++ 1 + MulLatency() + 1; ++} ++ ++int DpopcntLatency() { ++ return 2 + AndLatency() + DsubuLatency() + 1 + AndLatency() + 1 + ++ AndLatency() + DadduLatency() + 1 + DadduLatency() + 1 + AndLatency() + ++ 1 + DmulLatency() + 1; ++} ++ ++int CompareFLatency() { return Latency::C_cond_S; } ++ ++int CompareF32Latency() { return CompareFLatency(); } ++ ++int CompareF64Latency() { return CompareFLatency(); } ++ ++int CompareIsNanFLatency() { return CompareFLatency(); } ++ ++int CompareIsNanF32Latency() { return CompareIsNanFLatency(); } ++ ++int CompareIsNanF64Latency() { return CompareIsNanFLatency(); } ++ ++int NegsLatency() { return Latency::NEG_S; } ++ ++int NegdLatency() { return Latency::NEG_D; } ++ ++int Float64RoundLatency() { return Latency::RINT_D + 4; } ++ ++int Float32RoundLatency() { return Latency::RINT_S + 4; } ++ ++int Float32MaxLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF32Latency() + Latency::BRANCH; ++ return latency + Latency::MAX_S; ++} ++ ++int Float64MaxLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF64Latency() + Latency::BRANCH; ++ return latency + Latency::MAX_D; ++} ++ ++int Float32MinLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF32Latency() + Latency::BRANCH; ++ return latency + Latency::MIN_S; ++} ++ ++int Float64MinLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF64Latency() + Latency::BRANCH; ++ return latency + Latency::MIN_D; ++} ++ ++int TruncLSLatency(bool load_status) { ++ int latency = Latency::TRUNC_L_S + Latency::DMFC1; ++ if (load_status) { ++ latency += SltuLatency() + 7; ++ } ++ return latency; ++} ++ ++int TruncLDLatency(bool load_status) { ++ int latency = Latency::TRUNC_L_D + Latency::DMFC1; ++ if (load_status) { ++ latency += SltuLatency() + 7; ++ } ++ return latency; ++} ++ ++int TruncUlSLatency() { ++ // Estimated max. ++ return 2 * CompareF32Latency() + CompareIsNanF32Latency() + ++ 4 * Latency::BRANCH + Latency::SUB_S + 2 * Latency::TRUNC_L_S + ++ 3 * Latency::DMFC1 + OrLatency() + Latency::MTC1 + Latency::MOV_S + ++ SltuLatency() + 4; ++} ++ ++int TruncUlDLatency() { ++ // Estimated max. ++ return 2 * CompareF64Latency() + CompareIsNanF64Latency() + ++ 4 * Latency::BRANCH + Latency::SUB_D + 2 * Latency::TRUNC_L_D + ++ 3 * Latency::DMFC1 + OrLatency() + Latency::DMTC1 + Latency::MOV_D + ++ SltuLatency() + 4; ++} ++ ++int PushLatency() { return DadduLatency() + AlignedMemoryLatency(); } ++ ++int ByteSwapSignedLatency() { return 2; } ++ ++int LlLatency(int offset) { ++ bool is_one_instruction = is_int14(offset); ++ if (is_one_instruction) { ++ return 1; ++ } else { ++ return 3; ++ } ++} ++ ++int ExtractBitsLatency(bool sign_extend, int size) { ++ int latency = 2; ++ if (sign_extend) { ++ switch (size) { ++ case 8: ++ case 16: ++ case 32: ++ latency += 1; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ return latency; ++} ++ ++int InsertBitsLatency() { return 2 + DsubuLatency(false) + 2; } ++ ++int ScLatency(int offset) { ++ bool is_one_instruction = is_int14(offset); ++ if (is_one_instruction) { ++ return 1; ++ } else { ++ return 3; ++ } ++} ++ ++int Word32AtomicExchangeLatency(bool sign_extend, int size) { ++ return DadduLatency(false) + 1 + DsubuLatency() + 2 + LlLatency(0) + ++ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + ++ ScLatency(0) + BranchShortLatency() + 1; ++} ++ ++int Word32AtomicCompareExchangeLatency(bool sign_extend, int size) { ++ return 2 + DsubuLatency() + 2 + LlLatency(0) + ++ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + ++ ScLatency(0) + BranchShortLatency() + 1; ++} ++ ++int InstructionScheduler::GetInstructionLatency(const Instruction* instr) { ++ // Basic latency modeling for LA64 instructions. They have been determined ++ // in empirical way. ++ switch (instr->arch_opcode()) { ++ case kArchCallCodeObject: ++ case kArchCallWasmFunction: ++ return CallLatency(); ++ case kArchTailCallCodeObjectFromJSFunction: ++ case kArchTailCallCodeObject: { ++ int latency = 0; ++ if (instr->arch_opcode() == kArchTailCallCodeObjectFromJSFunction) { ++ latency = AssemblePopArgumentsAdoptFrameLatency(); ++ } ++ return latency + JumpLatency(); ++ } ++ case kArchTailCallWasm: ++ case kArchTailCallAddress: ++ return JumpLatency(); ++ case kArchCallJSFunction: { ++ int latency = 0; ++ if (FLAG_debug_code) { ++ latency = 1 + AssertLatency(); ++ } ++ return latency + 1 + DadduLatency(false) + CallLatency(); ++ } ++ case kArchPrepareCallCFunction: ++ return PrepareCallCFunctionLatency(); ++ case kArchSaveCallerRegisters: { ++ auto fp_mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ return PushCallerSavedLatency(fp_mode); ++ } ++ case kArchRestoreCallerRegisters: { ++ auto fp_mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ return PopCallerSavedLatency(fp_mode); ++ } ++ case kArchPrepareTailCall: ++ return 2; ++ case kArchCallCFunction: ++ return CallCFunctionLatency(); ++ case kArchJmp: ++ return AssembleArchJumpLatency(); ++ case kArchTableSwitch: ++ return AssembleArchTableSwitchLatency(); ++ case kArchAbortCSAAssert: ++ return CallLatency() + 1; ++ case kArchDebugBreak: ++ return 1; ++ case kArchComment: ++ case kArchNop: ++ case kArchThrowTerminator: ++ case kArchDeoptimize: ++ return 0; ++ case kArchRet: ++ return AssemblerReturnLatency(); ++ case kArchFramePointer: ++ return 1; ++ case kArchParentFramePointer: ++ // Estimated max. ++ return AlignedMemoryLatency(); ++ case kArchTruncateDoubleToI: ++ return TruncateDoubleToIDelayedLatency(); ++ case kArchStoreWithWriteBarrier: ++ return DadduLatency() + 1 + CheckPageFlagLatency(); ++ case kArchStackSlot: ++ // Estimated max. ++ return DadduLatency(false) + AndLatency(false) + AssertLatency() + ++ DadduLatency(false) + AndLatency(false) + BranchShortLatency() + ++ 1 + DsubuLatency() + DadduLatency(); ++ case kArchWordPoisonOnSpeculation: ++ return AndLatency(); ++ case kIeee754Float64Acos: ++ case kIeee754Float64Acosh: ++ case kIeee754Float64Asin: ++ case kIeee754Float64Asinh: ++ case kIeee754Float64Atan: ++ case kIeee754Float64Atanh: ++ case kIeee754Float64Atan2: ++ case kIeee754Float64Cos: ++ case kIeee754Float64Cosh: ++ case kIeee754Float64Cbrt: ++ case kIeee754Float64Exp: ++ case kIeee754Float64Expm1: ++ case kIeee754Float64Log: ++ case kIeee754Float64Log1p: ++ case kIeee754Float64Log10: ++ case kIeee754Float64Log2: ++ case kIeee754Float64Pow: ++ case kIeee754Float64Sin: ++ case kIeee754Float64Sinh: ++ case kIeee754Float64Tan: ++ case kIeee754Float64Tanh: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kLa64Add: ++ case kLa64Dadd: ++ return DadduLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64DaddOvf: ++ return DaddOverflowLatency(); ++ case kLa64Sub: ++ case kLa64Dsub: ++ return DsubuLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64DsubOvf: ++ return DsubOverflowLatency(); ++ case kLa64Mul: ++ return MulLatency(); ++ case kLa64MulOvf: ++ return MulOverflowLatency(); ++ case kLa64MulHigh: ++ return MulhLatency(); ++ case kLa64MulHighU: ++ return MulhuLatency(); ++ case kLa64DMulHigh: ++ return DMulhLatency(); ++ case kLa64Div: { ++ int latency = DivLatency(instr->InputAt(1)->IsRegister()); ++ return latency++; ++ } ++ case kLa64DivU: { ++ int latency = DivuLatency(instr->InputAt(1)->IsRegister()); ++ return latency++; ++ } ++ case kLa64Mod: ++ return ModLatency(); ++ case kLa64ModU: ++ return ModuLatency(); ++ case kLa64Dmul: ++ return DmulLatency(); ++ case kLa64Ddiv: { ++ int latency = DdivLatency(); ++ return latency++; ++ } ++ case kLa64DdivU: { ++ int latency = DdivuLatency(); ++ return latency++; ++ } ++ case kLa64Dmod: ++ return DmodLatency(); ++ case kLa64DmodU: ++ return DmoduLatency(); ++ case kLa64Dlsa: ++ case kLa64Lsa: ++ return DlsaLatency(); ++ case kLa64And: ++ return AndLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64And32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = AndLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kLa64Or: ++ return OrLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64Or32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = OrLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kLa64Nor: ++ return NorLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64Nor32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = NorLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kLa64Xor: ++ return XorLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64Xor32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = XorLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kLa64Clz: ++ case kLa64Dclz: ++ return DclzLatency(); ++ case kLa64Ctz: ++ return CtzLatency(); ++ case kLa64Dctz: ++ return DctzLatency(); ++ case kLa64Popcnt: ++ return PopcntLatency(); ++ case kLa64Dpopcnt: ++ return DpopcntLatency(); ++ case kLa64Shl: ++ return 1; ++ case kLa64Shr: ++ case kLa64Sar: ++ return 2; ++ case kLa64Ext: ++ case kLa64Ins: ++ case kLa64Dext: ++ case kLa64Dins: ++ case kLa64Dshl: ++ case kLa64Dshr: ++ case kLa64Dsar: ++ case kLa64Ror: ++ case kLa64Dror: ++ return 1; ++ case kLa64Tst: ++ return AndLatency(instr->InputAt(1)->IsRegister()); ++ case kLa64Mov: ++ return 1; ++ case kLa64CmpS: ++ return MoveLatency() + CompareF32Latency(); ++ case kLa64AddS: ++ return Latency::ADD_S; ++ case kLa64SubS: ++ return Latency::SUB_S; ++ case kLa64MulS: ++ return Latency::MUL_S; ++ case kLa64DivS: ++ return Latency::DIV_S; ++ case kLa64ModS: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kLa64AbsS: ++ return Latency::ABS_S; ++ case kLa64NegS: ++ return NegdLatency(); ++ case kLa64SqrtS: ++ return Latency::SQRT_S; ++ case kLa64MaxS: ++ return Latency::MAX_S; ++ case kLa64MinS: ++ return Latency::MIN_S; ++ case kLa64CmpD: ++ return MoveLatency() + CompareF64Latency(); ++ case kLa64AddD: ++ return Latency::ADD_D; ++ case kLa64SubD: ++ return Latency::SUB_D; ++ case kLa64MulD: ++ return Latency::MUL_D; ++ case kLa64DivD: ++ return Latency::DIV_D; ++ case kLa64ModD: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kLa64AbsD: ++ return Latency::ABS_D; ++ case kLa64NegD: ++ return NegdLatency(); ++ case kLa64SqrtD: ++ return Latency::SQRT_D; ++ case kLa64MaxD: ++ return Latency::MAX_D; ++ case kLa64MinD: ++ return Latency::MIN_D; ++ case kLa64Float64RoundDown: ++ case kLa64Float64RoundTruncate: ++ case kLa64Float64RoundUp: ++ case kLa64Float64RoundTiesEven: ++ return Float64RoundLatency(); ++ case kLa64Float32RoundDown: ++ case kLa64Float32RoundTruncate: ++ case kLa64Float32RoundUp: ++ case kLa64Float32RoundTiesEven: ++ return Float32RoundLatency(); ++ case kLa64Float32Max: ++ return Float32MaxLatency(); ++ case kLa64Float64Max: ++ return Float64MaxLatency(); ++ case kLa64Float32Min: ++ return Float32MinLatency(); ++ case kLa64Float64Min: ++ return Float64MinLatency(); ++ case kLa64Float64SilenceNaN: ++ return Latency::SUB_D; ++ case kLa64CvtSD: ++ return Latency::CVT_S_D; ++ case kLa64CvtDS: ++ return Latency::CVT_D_S; ++ case kLa64CvtDW: ++ return Latency::MTC1 + Latency::CVT_D_W; ++ case kLa64CvtSW: ++ return Latency::MTC1 + Latency::CVT_S_W; ++ case kLa64CvtSUw: ++ return 1 + Latency::DMTC1 + Latency::CVT_S_L; ++ case kLa64CvtSL: ++ return Latency::DMTC1 + Latency::CVT_S_L; ++ case kLa64CvtDL: ++ return Latency::DMTC1 + Latency::CVT_D_L; ++ case kLa64CvtDUw: ++ return 1 + Latency::DMTC1 + Latency::CVT_D_L; ++ case kLa64CvtDUl: ++ return 2 * Latency::BRANCH + 3 + 2 * Latency::DMTC1 + ++ 2 * Latency::CVT_D_L + Latency::ADD_D; ++ case kLa64CvtSUl: ++ return 2 * Latency::BRANCH + 3 + 2 * Latency::DMTC1 + ++ 2 * Latency::CVT_S_L + Latency::ADD_S; ++ case kLa64FloorWD: ++ return Latency::FLOOR_W_D + Latency::MFC1; ++ case kLa64CeilWD: ++ return Latency::CEIL_W_D + Latency::MFC1; ++ case kLa64RoundWD: ++ return Latency::ROUND_W_D + Latency::MFC1; ++ case kLa64TruncWD: ++ return Latency::TRUNC_W_D + Latency::MFC1; ++ case kLa64FloorWS: ++ return Latency::FLOOR_W_S + Latency::MFC1; ++ case kLa64CeilWS: ++ return Latency::CEIL_W_S + Latency::MFC1; ++ case kLa64RoundWS: ++ return Latency::ROUND_W_S + Latency::MFC1; ++ case kLa64TruncWS: ++ return Latency::TRUNC_W_S + Latency::MFC1 + 2 + MovnLatency(); ++ case kLa64TruncLS: ++ return TruncLSLatency(instr->OutputCount() > 1); ++ case kLa64TruncLD: ++ return TruncLDLatency(instr->OutputCount() > 1); ++ case kLa64TruncUwD: ++ // Estimated max. ++ return CompareF64Latency() + 2 * Latency::BRANCH + ++ 2 * Latency::TRUNC_W_D + Latency::SUB_D + OrLatency() + ++ Latency::MTC1 + Latency::MFC1 + Latency::MTHC1 + 1; ++ case kLa64TruncUwS: ++ // Estimated max. ++ return CompareF32Latency() + 2 * Latency::BRANCH + ++ 2 * Latency::TRUNC_W_S + Latency::SUB_S + OrLatency() + ++ Latency::MTC1 + 2 * Latency::MFC1 + 2 + MovzLatency(); ++ case kLa64TruncUlS: ++ return TruncUlSLatency(); ++ case kLa64TruncUlD: ++ return TruncUlDLatency(); ++ case kLa64BitcastDL: ++ return Latency::DMFC1; ++ case kLa64BitcastLD: ++ return Latency::DMTC1; ++ case kLa64Float64ExtractLowWord32: ++ return Latency::MFC1; ++ case kLa64Float64InsertLowWord32: ++ return Latency::MFHC1 + Latency::MTC1 + Latency::MTHC1; ++ case kLa64Float64ExtractHighWord32: ++ return Latency::MFHC1; ++ case kLa64Float64InsertHighWord32: ++ return Latency::MTHC1; ++ case kLa64Seb: ++ case kLa64Seh: ++ return 1; ++ case kLa64Lbu: ++ case kLa64Lb: ++ case kLa64Lhu: ++ case kLa64Lh: ++ case kLa64Lwu: ++ case kLa64Lw: ++ case kLa64Ld: ++ case kLa64Sb: ++ case kLa64Sh: ++ case kLa64Sw: ++ case kLa64Sd: ++ return AlignedMemoryLatency(); ++ case kLa64Lwc1: ++ return Lwc1Latency(); ++ case kLa64Ldc1: ++ return Ldc1Latency(); ++ case kLa64Swc1: ++ return Swc1Latency(); ++ case kLa64Sdc1: ++ return Sdc1Latency(); ++ case kLa64Ulhu: ++ case kLa64Ulh: ++ return UlhuLatency(); ++ case kLa64Ulwu: ++ return UlwuLatency(); ++ case kLa64Ulw: ++ return UlwLatency(); ++ case kLa64Uld: ++ return UldLatency(); ++ case kLa64Ulwc1: ++ return Ulwc1Latency(); ++ case kLa64Uldc1: ++ return Uldc1Latency(); ++ case kLa64Ush: ++ return UshLatency(); ++ case kLa64Usw: ++ return UswLatency(); ++ case kLa64Usd: ++ return UsdLatency(); ++ case kLa64Uswc1: ++ return Uswc1Latency(); ++ case kLa64Usdc1: ++ return Usdc1Latency(); ++ case kLa64Push: { ++ int latency = 0; ++ if (instr->InputAt(0)->IsFPRegister()) { ++ latency = Sdc1Latency() + DsubuLatency(false); ++ } else { ++ latency = PushLatency(); ++ } ++ return latency; ++ } ++ case kLa64Peek: { ++ int latency = 0; ++ if (instr->OutputAt(0)->IsFPRegister()) { ++ auto op = LocationOperand::cast(instr->OutputAt(0)); ++ switch (op->representation()) { ++ case MachineRepresentation::kFloat64: ++ latency = Ldc1Latency(); ++ break; ++ case MachineRepresentation::kFloat32: ++ latency = Latency::LWC1; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } else { ++ latency = AlignedMemoryLatency(); ++ } ++ return latency; ++ } ++ case kLa64StackClaim: ++ return DsubuLatency(false); ++ case kLa64StoreToStackSlot: { ++ int latency = 0; ++ if (instr->InputAt(0)->IsFPRegister()) { ++ if (instr->InputAt(0)->IsSimd128Register()) { ++ latency = 1; // Estimated value. ++ } else { ++ latency = Sdc1Latency(); ++ } ++ } else { ++ latency = AlignedMemoryLatency(); ++ } ++ return latency; ++ } ++ case kLa64ByteSwap64: ++ return ByteSwapSignedLatency(); ++ case kLa64ByteSwap32: ++ return ByteSwapSignedLatency(); ++ case kWord32AtomicLoadInt8: ++ case kWord32AtomicLoadUint8: ++ case kWord32AtomicLoadInt16: ++ case kWord32AtomicLoadUint16: ++ case kWord32AtomicLoadWord32: ++ return 2; ++ case kWord32AtomicStoreWord8: ++ case kWord32AtomicStoreWord16: ++ case kWord32AtomicStoreWord32: ++ return 3; ++ case kWord32AtomicExchangeInt8: ++ return Word32AtomicExchangeLatency(true, 8); ++ case kWord32AtomicExchangeUint8: ++ return Word32AtomicExchangeLatency(false, 8); ++ case kWord32AtomicExchangeInt16: ++ return Word32AtomicExchangeLatency(true, 16); ++ case kWord32AtomicExchangeUint16: ++ return Word32AtomicExchangeLatency(false, 16); ++ case kWord32AtomicExchangeWord32: ++ return 2 + LlLatency(0) + 1 + ScLatency(0) + BranchShortLatency() + 1; ++ case kWord32AtomicCompareExchangeInt8: ++ return Word32AtomicCompareExchangeLatency(true, 8); ++ case kWord32AtomicCompareExchangeUint8: ++ return Word32AtomicCompareExchangeLatency(false, 8); ++ case kWord32AtomicCompareExchangeInt16: ++ return Word32AtomicCompareExchangeLatency(true, 16); ++ case kWord32AtomicCompareExchangeUint16: ++ return Word32AtomicCompareExchangeLatency(false, 16); ++ case kWord32AtomicCompareExchangeWord32: ++ return 3 + LlLatency(0) + BranchShortLatency() + 1 + ScLatency(0) + ++ BranchShortLatency() + 1; ++ case kLa64AssertEqual: ++ return AssertLatency(); ++ default: ++ return 1; ++ } ++} ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/backend/loongarch64/instruction-selector-loongarch64.cc +@@ -0,0 +1,3170 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/base/bits.h" ++#include "src/compiler/backend/instruction-selector-impl.h" ++#include "src/compiler/node-matchers.h" ++#include "src/compiler/node-properties.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++#define TRACE_UNIMPL() \ ++ PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) ++ ++#define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) ++ ++// Adds la64-specific methods for generating InstructionOperands. ++class La64OperandGenerator final : public OperandGenerator { ++ public: ++ explicit La64OperandGenerator(InstructionSelector* selector) ++ : OperandGenerator(selector) {} ++ ++ InstructionOperand UseOperand(Node* node, InstructionCode opcode) { ++ if (CanBeImmediate(node, opcode)) { ++ return UseImmediate(node); ++ } ++ return UseRegister(node); ++ } ++ ++ // Use the zero register if the node has the immediate value zero, otherwise ++ // assign a register. ++ InstructionOperand UseRegisterOrImmediateZero(Node* node) { ++ if ((IsIntegerConstant(node) && (GetIntegerConstantValue(node) == 0)) || ++ (IsFloatConstant(node) && ++ (bit_cast(GetFloatConstantValue(node)) == 0))) { ++ return UseImmediate(node); ++ } ++ return UseRegister(node); ++ } ++ ++ bool IsIntegerConstant(Node* node) { ++ return (node->opcode() == IrOpcode::kInt32Constant) || ++ (node->opcode() == IrOpcode::kInt64Constant); ++ } ++ ++ int64_t GetIntegerConstantValue(Node* node) { ++ if (node->opcode() == IrOpcode::kInt32Constant) { ++ return OpParameter(node->op()); ++ } ++ DCHECK_EQ(IrOpcode::kInt64Constant, node->opcode()); ++ return OpParameter(node->op()); ++ } ++ ++ bool IsFloatConstant(Node* node) { ++ return (node->opcode() == IrOpcode::kFloat32Constant) || ++ (node->opcode() == IrOpcode::kFloat64Constant); ++ } ++ ++ double GetFloatConstantValue(Node* node) { ++ if (node->opcode() == IrOpcode::kFloat32Constant) { ++ return OpParameter(node->op()); ++ } ++ DCHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); ++ return OpParameter(node->op()); ++ } ++ ++ bool CanBeImmediate(Node* node, InstructionCode mode) { ++ return IsIntegerConstant(node) && ++ CanBeImmediate(GetIntegerConstantValue(node), mode); ++ } ++ ++ bool CanBeImmediate(int64_t value, InstructionCode opcode) { ++ switch (ArchOpcodeField::decode(opcode)) { ++ case kLa64Shl: ++ case kLa64Sar: ++ case kLa64Shr: ++ return is_uint5(value); ++ case kLa64Dshl: ++ case kLa64Dsar: ++ case kLa64Dshr: ++ return is_uint6(value); ++ case kLa64Add: ++ case kLa64And32: ++ case kLa64And: ++ case kLa64Dadd: ++ case kLa64Or32: ++ case kLa64Or: ++ case kLa64Tst: ++ case kLa64Xor: ++ return is_uint12(value); ++ case kLa64Lb: ++ case kLa64Lbu: ++ case kLa64Sb: ++ case kLa64Lh: ++ case kLa64Lhu: ++ case kLa64Sh: ++ case kLa64Lw: ++ case kLa64Sw: ++ case kLa64Ld: ++ case kLa64Sd: ++ case kLa64Lwc1: ++ case kLa64Swc1: ++ case kLa64Ldc1: ++ case kLa64Sdc1: ++ return is_int12(value); ++ default: ++ return is_int12(value); ++ } ++ } ++ ++ private: ++ bool ImmediateFitsAddrMode1Instruction(int32_t imm) const { ++ TRACE_UNIMPL(); ++ return false; ++ } ++}; ++ ++static void VisitRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++static void VisitRRI(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ int32_t imm = OpParameter(node->op()); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm)); ++} ++ ++static void VisitSimdShift(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ if (g.IsIntegerConstant(node->InputAt(1))) { ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseImmediate(node->InputAt(1))); ++ } else { ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++ } ++} ++ ++static void VisitRRIR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ int32_t imm = OpParameter(node->op()); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm), ++ g.UseRegister(node->InputAt(1))); ++} ++ ++static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++} ++ ++static void VisitUniqueRRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseUniqueRegister(node->InputAt(0)), ++ g.UseUniqueRegister(node->InputAt(1))); ++} ++ ++void VisitRRRR(InstructionSelector* selector, ArchOpcode opcode, Node* node) { ++ La64OperandGenerator g(selector); ++ selector->Emit( ++ opcode, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(2))); ++} ++ ++static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ La64OperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseOperand(node->InputAt(1), opcode)); ++} ++ ++struct ExtendingLoadMatcher { ++ ExtendingLoadMatcher(Node* node, InstructionSelector* selector) ++ : matches_(false), selector_(selector), base_(nullptr), immediate_(0) { ++ Initialize(node); ++ } ++ ++ bool Matches() const { return matches_; } ++ ++ Node* base() const { ++ DCHECK(Matches()); ++ return base_; ++ } ++ int64_t immediate() const { ++ DCHECK(Matches()); ++ return immediate_; ++ } ++ ArchOpcode opcode() const { ++ DCHECK(Matches()); ++ return opcode_; ++ } ++ ++ private: ++ bool matches_; ++ InstructionSelector* selector_; ++ Node* base_; ++ int64_t immediate_; ++ ArchOpcode opcode_; ++ ++ void Initialize(Node* node) { ++ Int64BinopMatcher m(node); ++ // When loading a 64-bit value and shifting by 32, we should ++ // just load and sign-extend the interesting 4 bytes instead. ++ // This happens, for example, when we're loading and untagging SMIs. ++ DCHECK(m.IsWord64Sar()); ++ if (m.left().IsLoad() && m.right().Is(32) && ++ selector_->CanCover(m.node(), m.left().node())) { ++ DCHECK_EQ(selector_->GetEffectLevel(node), ++ selector_->GetEffectLevel(m.left().node())); ++ MachineRepresentation rep = ++ LoadRepresentationOf(m.left().node()->op()).representation(); ++ DCHECK_EQ(3, ElementSizeLog2Of(rep)); ++ if (rep != MachineRepresentation::kTaggedSigned && ++ rep != MachineRepresentation::kTaggedPointer && ++ rep != MachineRepresentation::kTagged && ++ rep != MachineRepresentation::kWord64) { ++ return; ++ } ++ ++ La64OperandGenerator g(selector_); ++ Node* load = m.left().node(); ++ Node* offset = load->InputAt(1); ++ base_ = load->InputAt(0); ++ opcode_ = kLa64Lw; ++ if (g.CanBeImmediate(offset, opcode_)) { ++ immediate_ = g.GetIntegerConstantValue(offset) + 4; ++ matches_ = g.CanBeImmediate(immediate_, kLa64Lw); ++ } ++ } ++ } ++}; ++ ++bool TryEmitExtendingLoad(InstructionSelector* selector, Node* node, ++ Node* output_node) { ++ ExtendingLoadMatcher m(node, selector); ++ La64OperandGenerator g(selector); ++ if (m.Matches()) { ++ InstructionOperand inputs[2]; ++ inputs[0] = g.UseRegister(m.base()); ++ InstructionCode opcode = ++ m.opcode() | AddressingModeField::encode(kMode_MRI); ++ DCHECK(is_int32(m.immediate())); ++ inputs[1] = g.TempImmediate(static_cast(m.immediate())); ++ InstructionOperand outputs[] = {g.DefineAsRegister(output_node)}; ++ selector->Emit(opcode, arraysize(outputs), outputs, arraysize(inputs), ++ inputs); ++ return true; ++ } ++ return false; ++} ++ ++bool TryMatchImmediate(InstructionSelector* selector, ++ InstructionCode* opcode_return, Node* node, ++ size_t* input_count_return, InstructionOperand* inputs) { ++ La64OperandGenerator g(selector); ++ if (g.CanBeImmediate(node, *opcode_return)) { ++ *opcode_return |= AddressingModeField::encode(kMode_MRI); ++ inputs[0] = g.UseImmediate(node); ++ *input_count_return = 1; ++ return true; ++ } ++ return false; ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, bool has_reverse_opcode, ++ InstructionCode reverse_opcode, ++ FlagsContinuation* cont) { ++ La64OperandGenerator g(selector); ++ Int32BinopMatcher m(node); ++ InstructionOperand inputs[2]; ++ size_t input_count = 0; ++ InstructionOperand outputs[1]; ++ size_t output_count = 0; ++ ++ if (TryMatchImmediate(selector, &opcode, m.right().node(), &input_count, ++ &inputs[1])) { ++ inputs[0] = g.UseRegister(m.left().node()); ++ input_count++; ++ } else if (has_reverse_opcode && ++ TryMatchImmediate(selector, &reverse_opcode, m.left().node(), ++ &input_count, &inputs[1])) { ++ inputs[0] = g.UseRegister(m.right().node()); ++ opcode = reverse_opcode; ++ input_count++; ++ } else { ++ inputs[input_count++] = g.UseRegister(m.left().node()); ++ inputs[input_count++] = g.UseOperand(m.right().node(), opcode); ++ } ++ ++ if (cont->IsDeoptimize()) { ++ // If we can deoptimize as a result of the binop, we need to make sure that ++ // the deopt inputs are not overwritten by the binop result. One way ++ // to achieve that is to declare the output register as same-as-first. ++ outputs[output_count++] = g.DefineSameAsFirst(node); ++ } else { ++ outputs[output_count++] = g.DefineAsRegister(node); ++ } ++ ++ DCHECK_NE(0u, input_count); ++ DCHECK_EQ(1u, output_count); ++ DCHECK_GE(arraysize(inputs), input_count); ++ DCHECK_GE(arraysize(outputs), output_count); ++ ++ selector->EmitWithContinuation(opcode, output_count, outputs, input_count, ++ inputs, cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, bool has_reverse_opcode, ++ InstructionCode reverse_opcode) { ++ FlagsContinuation cont; ++ VisitBinop(selector, node, opcode, has_reverse_opcode, reverse_opcode, &cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont) { ++ VisitBinop(selector, node, opcode, false, kArchNop, cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode) { ++ VisitBinop(selector, node, opcode, false, kArchNop); ++} ++ ++void InstructionSelector::VisitStackSlot(Node* node) { ++ StackSlotRepresentation rep = StackSlotRepresentationOf(node->op()); ++ int alignment = rep.alignment(); ++ int slot = frame_->AllocateSpillSlot(rep.size(), alignment); ++ OperandGenerator g(this); ++ ++ Emit(kArchStackSlot, g.DefineAsRegister(node), ++ sequence()->AddImmediate(Constant(slot)), ++ sequence()->AddImmediate(Constant(alignment)), 0, nullptr); ++} ++ ++void InstructionSelector::VisitAbortCSAAssert(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), a0)); ++} ++ ++void EmitLoad(InstructionSelector* selector, Node* node, InstructionCode opcode, ++ Node* output = nullptr) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(output == nullptr ? node : output), ++ g.UseRegister(base), g.UseImmediate(index)); ++ } else { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRR), ++ g.DefineAsRegister(output == nullptr ? node : output), ++ g.UseRegister(base), g.UseRegister(index)); ++ } ++} ++ ++void InstructionSelector::VisitLoadTransform(Node* node) { ++ LoadTransformParameters params = LoadTransformParametersOf(node->op()); ++ ++ InstructionCode opcode = kArchNop; ++ switch (params.transformation) { ++ case LoadTransformation::kS8x16LoadSplat: ++ opcode = kLa64S8x16LoadSplat; ++ break; ++ case LoadTransformation::kS16x8LoadSplat: ++ opcode = kLa64S16x8LoadSplat; ++ break; ++ case LoadTransformation::kS32x4LoadSplat: ++ opcode = kLa64S32x4LoadSplat; ++ break; ++ case LoadTransformation::kS64x2LoadSplat: ++ opcode = kLa64S64x2LoadSplat; ++ break; ++ case LoadTransformation::kI16x8Load8x8S: ++ opcode = kLa64I16x8Load8x8S; ++ break; ++ case LoadTransformation::kI16x8Load8x8U: ++ opcode = kLa64I16x8Load8x8U; ++ break; ++ case LoadTransformation::kI32x4Load16x4S: ++ opcode = kLa64I32x4Load16x4S; ++ break; ++ case LoadTransformation::kI32x4Load16x4U: ++ opcode = kLa64I32x4Load16x4U; ++ break; ++ case LoadTransformation::kI64x2Load32x2S: ++ opcode = kLa64I64x2Load32x2S; ++ break; ++ case LoadTransformation::kI64x2Load32x2U: ++ opcode = kLa64I64x2Load32x2U; ++ break; ++ default: ++ UNIMPLEMENTED(); ++ } ++ ++ EmitLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ++ InstructionCode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kFloat32: ++ opcode = kLa64Lwc1; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kLa64Ldc1; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kLa64Lhu : kLa64Lh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = load_rep.IsUnsigned() ? kLa64Lwu : kLa64Lw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Ld; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ case MachineRepresentation::kSimd128: ++ UNREACHABLE(); ++ } ++ if (node->opcode() == IrOpcode::kPoisonedLoad) { ++ CHECK_NE(poisoning_level_, PoisoningMitigationLevel::kDontPoison); ++ opcode |= MiscField::encode(kMemoryAccessPoisoned); ++ } ++ ++ EmitLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitPoisonedLoad(Node* node) { VisitLoad(node); } ++ ++void InstructionSelector::VisitProtectedLoad(Node* node) { ++ // TODO(eholk) ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitStore(Node* node) { ++ La64OperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ StoreRepresentation store_rep = StoreRepresentationOf(node->op()); ++ WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); ++ MachineRepresentation rep = store_rep.representation(); ++ ++ if (FLAG_enable_unconditional_write_barriers && CanBeTaggedPointer(rep)) { ++ write_barrier_kind = kFullWriteBarrier; ++ } ++ ++ // TODO(la64): I guess this could be done in a better way. ++ if (write_barrier_kind != kNoWriteBarrier && ++ V8_LIKELY(!FLAG_disable_write_barriers)) { ++ DCHECK(CanBeTaggedPointer(rep)); ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ RecordWriteMode record_write_mode = ++ WriteBarrierKindToRecordWriteMode(write_barrier_kind); ++ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; ++ size_t const temp_count = arraysize(temps); ++ InstructionCode code = kArchStoreWithWriteBarrier; ++ code |= MiscField::encode(static_cast(record_write_mode)); ++ Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); ++ } else { ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kFloat32: ++ opcode = kLa64Swc1; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kLa64Sdc1; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = kLa64Sb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kLa64Sh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kLa64Sw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Sd; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ case MachineRepresentation::kSimd128: ++ UNREACHABLE(); ++ return; ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ Emit(opcode | AddressingModeField::encode(kMode_MRR), g.NoOutput(), ++ g.UseRegister(base), g.UseRegister(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } ++ } ++} ++ ++void InstructionSelector::VisitProtectedStore(Node* node) { ++ // TODO(eholk) ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitWord32And(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32Shr() && CanCover(node, m.left().node()) && ++ m.right().HasValue()) { ++ uint32_t mask = m.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { ++ // The mask must be contiguous, and occupy the least-significant bits. ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); ++ ++ // Select Ext for And(Shr(x, imm), mask) where the mask is in the least ++ // significant bits. ++ Int32BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue()) { ++ // Any shift value can match; int32 shifts use `value % 32`. ++ uint32_t lsb = mleft.right().Value() & 0x1F; ++ ++ // Ext cannot extract bits past the register size, however since ++ // shifting the original value would have introduced some zeros we can ++ // still use Ext with a smaller mask and the remaining bits will be ++ // zeros. ++ if (lsb + mask_width > 32) mask_width = 32 - lsb; ++ ++ Emit(kLa64Ext, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), ++ g.TempImmediate(mask_width)); ++ return; ++ } ++ // Other cases fall through to the normal And operation. ++ } ++ } ++ if (m.right().HasValue()) { ++ uint32_t mask = m.right().Value(); ++ uint32_t shift = base::bits::CountPopulation(~mask); ++ uint32_t msb = base::bits::CountLeadingZeros32(~mask); ++ if (shift != 0 && shift != 32 && msb + shift == 32) { ++ // Insert zeros for (x >> K) << K => x & ~(2^K - 1) expression reduction ++ // and remove constant loading of inverted mask. ++ Emit(kLa64Ins, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0), g.TempImmediate(shift)); ++ return; ++ } ++ } ++ VisitBinop(this, node, kLa64And32, true, kLa64And32); ++} ++ ++void InstructionSelector::VisitWord64And(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ if (m.left().IsWord64Shr() && CanCover(node, m.left().node()) && ++ m.right().HasValue()) { ++ uint64_t mask = m.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { ++ // The mask must be contiguous, and occupy the least-significant bits. ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); ++ ++ // Select Dext for And(Shr(x, imm), mask) where the mask is in the least ++ // significant bits. ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue()) { ++ // Any shift value can match; int64 shifts use `value % 64`. ++ uint32_t lsb = static_cast(mleft.right().Value() & 0x3F); ++ ++ // Dext cannot extract bits past the register size, however since ++ // shifting the original value would have introduced some zeros we can ++ // still use Dext with a smaller mask and the remaining bits will be ++ // zeros. ++ if (lsb + mask_width > 64) mask_width = 64 - lsb; ++ ++ if (lsb == 0 && mask_width == 64) { ++ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(mleft.left().node())); ++ } else { ++ Emit(kLa64Dext, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), ++ g.TempImmediate(static_cast(mask_width))); ++ } ++ return; ++ } ++ // Other cases fall through to the normal And operation. ++ } ++ } ++ if (m.right().HasValue()) { ++ uint64_t mask = m.right().Value(); ++ uint32_t shift = base::bits::CountPopulation(~mask); ++ uint32_t msb = base::bits::CountLeadingZeros64(~mask); ++ if (shift != 0 && shift < 32 && msb + shift == 64) { ++ // Insert zeros for (x >> K) << K => x & ~(2^K - 1) expression reduction ++ // and remove constant loading of inverted mask. Dins cannot insert bits ++ // past word size, so shifts smaller than 32 are covered. ++ Emit(kLa64Dins, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0), g.TempImmediate(shift)); ++ return; ++ } ++ } ++ VisitBinop(this, node, kLa64And, true, kLa64And); ++} ++ ++void InstructionSelector::VisitWord32Or(Node* node) { ++ VisitBinop(this, node, kLa64Or32, true, kLa64Or32); ++} ++ ++void InstructionSelector::VisitWord64Or(Node* node) { ++ VisitBinop(this, node, kLa64Or, true, kLa64Or); ++} ++ ++void InstructionSelector::VisitWord32Xor(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32Or() && CanCover(node, m.left().node()) && ++ m.right().Is(-1)) { ++ Int32BinopMatcher mleft(m.left().node()); ++ if (!mleft.right().HasValue()) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Nor32, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(mleft.right().node())); ++ return; ++ } ++ } ++ if (m.right().Is(-1)) { ++ // Use Nor for bit negation and eliminate constant loading for xori. ++ La64OperandGenerator g(this); ++ Emit(kLa64Nor32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0)); ++ return; ++ } ++ VisitBinop(this, node, kLa64Xor32, true, kLa64Xor32); ++} ++ ++void InstructionSelector::VisitWord64Xor(Node* node) { ++ Int64BinopMatcher m(node); ++ if (m.left().IsWord64Or() && CanCover(node, m.left().node()) && ++ m.right().Is(-1)) { ++ Int64BinopMatcher mleft(m.left().node()); ++ if (!mleft.right().HasValue()) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Nor, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(mleft.right().node())); ++ return; ++ } ++ } ++ if (m.right().Is(-1)) { ++ // Use Nor for bit negation and eliminate constant loading for xori. ++ La64OperandGenerator g(this); ++ Emit(kLa64Nor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0)); ++ return; ++ } ++ VisitBinop(this, node, kLa64Xor, true, kLa64Xor); ++} ++ ++void InstructionSelector::VisitWord32Shl(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32And() && CanCover(node, m.left().node()) && ++ m.right().IsInRange(1, 31)) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher mleft(m.left().node()); ++ // Match Word32Shl(Word32And(x, mask), imm) to Shl where the mask is ++ // contiguous, and the shift immediate non-zero. ++ if (mleft.right().HasValue()) { ++ uint32_t mask = mleft.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { ++ uint32_t shift = m.right().Value(); ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); ++ DCHECK_NE(0u, shift); ++ if ((shift + mask_width) >= 32) { ++ // If the mask is contiguous and reaches or extends beyond the top ++ // bit, only the shift is needed. ++ Emit(kLa64Shl, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ } ++ } ++ VisitRRO(this, kLa64Shl, node); ++} ++ ++void InstructionSelector::VisitWord32Shr(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32And() && m.right().HasValue()) { ++ uint32_t lsb = m.right().Value() & 0x1F; ++ Int32BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue() && mleft.right().Value() != 0) { ++ // Select Ext for Shr(And(x, mask), imm) where the result of the mask is ++ // shifted into the least-significant bits. ++ uint32_t mask = (mleft.right().Value() >> lsb) << lsb; ++ unsigned mask_width = base::bits::CountPopulation(mask); ++ unsigned mask_msb = base::bits::CountLeadingZeros32(mask); ++ if ((mask_msb + mask_width + lsb) == 32) { ++ La64OperandGenerator g(this); ++ DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); ++ Emit(kLa64Ext, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), ++ g.TempImmediate(mask_width)); ++ return; ++ } ++ } ++ } ++ VisitRRO(this, kLa64Shr, node); ++} ++ ++void InstructionSelector::VisitWord32Sar(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32Shl() && CanCover(node, m.left().node())) { ++ Int32BinopMatcher mleft(m.left().node()); ++ if (m.right().HasValue() && mleft.right().HasValue()) { ++ La64OperandGenerator g(this); ++ uint32_t sar = m.right().Value(); ++ uint32_t shl = mleft.right().Value(); ++ if ((sar == shl) && (sar == 16)) { ++ Emit(kLa64Seh, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node())); ++ return; ++ } else if ((sar == shl) && (sar == 24)) { ++ Emit(kLa64Seb, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node())); ++ return; ++ } else if ((sar == shl) && (sar == 32)) { ++ Emit(kLa64Shl, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(0)); ++ return; ++ } ++ } ++ } ++ VisitRRO(this, kLa64Sar, node); ++} ++ ++void InstructionSelector::VisitWord64Shl(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && ++ m.right().IsInRange(32, 63) && CanCover(node, m.left().node())) { ++ // There's no need to sign/zero-extend to 64-bit if we shift out the upper ++ // 32 bits anyway. ++ Emit(kLa64Dshl, g.DefineSameAsFirst(node), ++ g.UseRegister(m.left().node()->InputAt(0)), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ if (m.left().IsWord64And() && CanCover(node, m.left().node()) && ++ m.right().IsInRange(1, 63)) { ++ // Match Word64Shl(Word64And(x, mask), imm) to Dshl where the mask is ++ // contiguous, and the shift immediate non-zero. ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue()) { ++ uint64_t mask = mleft.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { ++ uint64_t shift = m.right().Value(); ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); ++ DCHECK_NE(0u, shift); ++ ++ if ((shift + mask_width) >= 64) { ++ // If the mask is contiguous and reaches or extends beyond the top ++ // bit, only the shift is needed. ++ Emit(kLa64Dshl, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ } ++ } ++ VisitRRO(this, kLa64Dshl, node); ++} ++ ++void InstructionSelector::VisitWord64Shr(Node* node) { ++ Int64BinopMatcher m(node); ++ if (m.left().IsWord64And() && m.right().HasValue()) { ++ uint32_t lsb = m.right().Value() & 0x3F; ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue() && mleft.right().Value() != 0) { ++ // Select Dext for Shr(And(x, mask), imm) where the result of the mask is ++ // shifted into the least-significant bits. ++ uint64_t mask = (mleft.right().Value() >> lsb) << lsb; ++ unsigned mask_width = base::bits::CountPopulation(mask); ++ unsigned mask_msb = base::bits::CountLeadingZeros64(mask); ++ if ((mask_msb + mask_width + lsb) == 64) { ++ La64OperandGenerator g(this); ++ DCHECK_EQ(lsb, base::bits::CountTrailingZeros64(mask)); ++ Emit(kLa64Dext, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), ++ g.TempImmediate(mask_width)); ++ return; ++ } ++ } ++ } ++ VisitRRO(this, kLa64Dshr, node); ++} ++ ++void InstructionSelector::VisitWord64Sar(Node* node) { ++ if (TryEmitExtendingLoad(this, node, node)) return; ++ VisitRRO(this, kLa64Dsar, node); ++} ++ ++void InstructionSelector::VisitWord32Rol(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64Rol(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord32Ror(Node* node) { ++ VisitRRO(this, kLa64Ror, node); ++} ++ ++void InstructionSelector::VisitWord32Clz(Node* node) { ++ VisitRR(this, kLa64Clz, node); ++} ++ ++void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64ReverseBytes(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64ByteSwap64, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord32ReverseBytes(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64ByteSwap32, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSimd128ReverseBytes(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitWord32Ctz(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Ctz, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Ctz(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Dctz, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord32Popcnt(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Popcnt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Popcnt(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Dpopcnt, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Ror(Node* node) { ++ VisitRRO(this, kLa64Dror, node); ++} ++ ++void InstructionSelector::VisitWord64Clz(Node* node) { ++ VisitRR(this, kLa64Dclz, node); ++} ++ ++void InstructionSelector::VisitInt32Add(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ ++ // Select Lsa for (left + (left_of_right << imm)). ++ if (m.right().opcode() == IrOpcode::kWord32Shl && ++ CanCover(node, m.left().node()) && CanCover(node, m.right().node())) { ++ Int32BinopMatcher mright(m.right().node()); ++ if (mright.right().HasValue() && !m.left().HasValue()) { ++ int32_t shift_value = static_cast(mright.right().Value()); ++ if (shift_value > 0 && shift_value <= 31) { ++ Emit(kLa64Lsa, g.DefineAsRegister(node), ++ g.UseRegister(mright.left().node()), ++ g.UseRegister(m.left().node()), g.TempImmediate(shift_value)); ++ return; ++ } ++ } ++ } ++ ++ // Select Lsa for ((left_of_left << imm) + right). ++ if (m.left().opcode() == IrOpcode::kWord32Shl && ++ CanCover(node, m.right().node()) && CanCover(node, m.left().node())) { ++ Int32BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue() && !m.right().HasValue()) { ++ int32_t shift_value = static_cast(mleft.right().Value()); ++ if (shift_value > 0 && shift_value <= 31) { ++ Emit(kLa64Lsa, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(m.right().node()), g.TempImmediate(shift_value)); ++ return; ++ } ++ } ++ } ++ ++ VisitBinop(this, node, kLa64Add, true, kLa64Add); ++} ++ ++void InstructionSelector::VisitInt64Add(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ ++ // Select Dlsa for (left + (left_of_right << imm)). ++ if (m.right().opcode() == IrOpcode::kWord64Shl && ++ CanCover(node, m.left().node()) && CanCover(node, m.right().node())) { ++ Int64BinopMatcher mright(m.right().node()); ++ if (mright.right().HasValue() && !m.left().HasValue()) { ++ int32_t shift_value = static_cast(mright.right().Value()); ++ if (shift_value > 0 && shift_value <= 31) { ++ Emit(kLa64Dlsa, g.DefineAsRegister(node), ++ g.UseRegister(mright.left().node()), ++ g.UseRegister(m.left().node()), g.TempImmediate(shift_value)); ++ return; ++ } ++ } ++ } ++ ++ // Select Dlsa for ((left_of_left << imm) + right). ++ if (m.left().opcode() == IrOpcode::kWord64Shl && ++ CanCover(node, m.right().node()) && CanCover(node, m.left().node())) { ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue() && !m.right().HasValue()) { ++ int32_t shift_value = static_cast(mleft.right().Value()); ++ if (shift_value > 0 && shift_value <= 31) { ++ Emit(kLa64Dlsa, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(m.right().node()), g.TempImmediate(shift_value)); ++ return; ++ } ++ } ++ } ++ ++ VisitBinop(this, node, kLa64Dadd, true, kLa64Dadd); ++} ++ ++void InstructionSelector::VisitInt32Sub(Node* node) { ++ VisitBinop(this, node, kLa64Sub); ++} ++ ++void InstructionSelector::VisitInt64Sub(Node* node) { ++ VisitBinop(this, node, kLa64Dsub); ++} ++ ++void InstructionSelector::VisitInt32Mul(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ if (m.right().HasValue() && m.right().Value() > 0) { ++ uint32_t value = static_cast(m.right().Value()); ++ if (base::bits::IsPowerOfTwo(value)) { ++ Emit(kLa64Shl | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value - 1) && /*kArchVariant == kLa64r6 &&*/ ++ value - 1 > 0 && value - 1 <= 31) { ++ Emit(kLa64Lsa, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value - 1))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value + 1)) { ++ InstructionOperand temp = g.TempRegister(); ++ Emit(kLa64Shl | AddressingModeField::encode(kMode_None), temp, ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); ++ Emit(kLa64Sub | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); ++ return; ++ } ++ } ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher leftInput(left), rightInput(right); ++ if (leftInput.right().Is(32) && rightInput.right().Is(32)) { ++ // Combine untagging shifts with Dmul high. ++ Emit(kLa64DMulHigh, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ VisitRRR(this, kLa64Mul, node); ++} ++ ++void InstructionSelector::VisitInt32MulHigh(Node* node) { ++ VisitRRR(this, kLa64MulHigh, node); ++} ++ ++void InstructionSelector::VisitUint32MulHigh(Node* node) { ++ VisitRRR(this, kLa64MulHighU, node); ++} ++ ++void InstructionSelector::VisitInt64Mul(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ // TODO(dusmil): Add optimization for shifts larger than 32. ++ if (m.right().HasValue() && m.right().Value() > 0) { ++ uint32_t value = static_cast(m.right().Value()); ++ if (base::bits::IsPowerOfTwo(value)) { ++ Emit(kLa64Dshl | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value - 1) && /*kArchVariant == kLa64r6 &&*/ ++ value - 1 > 0 && value - 1 <= 31) { ++ // Dlsa macro will handle the shifting value out of bound cases. ++ Emit(kLa64Dlsa, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value - 1))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value + 1)) { ++ InstructionOperand temp = g.TempRegister(); ++ Emit(kLa64Dshl | AddressingModeField::encode(kMode_None), temp, ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); ++ Emit(kLa64Dsub | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); ++ return; ++ } ++ } ++ Emit(kLa64Dmul, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt32Div(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher rightInput(right), leftInput(left); ++ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { ++ // Combine both shifted operands with Ddiv. ++ Emit(kLa64Ddiv, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ Emit(kLa64Div, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint32Div(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Emit(kLa64DivU, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt32Mod(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher rightInput(right), leftInput(left); ++ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { ++ // Combine both shifted operands with Dmod. ++ Emit(kLa64Dmod, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ Emit(kLa64Mod, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint32Mod(Node* node) { ++ La64OperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Emit(kLa64ModU, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt64Div(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kLa64Ddiv, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint64Div(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kLa64DdivU, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt64Mod(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kLa64Dmod, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint64Mod(Node* node) { ++ La64OperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kLa64DmodU, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDS, node); ++} ++ ++void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) { ++ VisitRR(this, kLa64CvtSW, node); ++} ++ ++void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) { ++ VisitRR(this, kLa64CvtSUw, node); ++} ++ ++void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDW, node); ++} ++ ++void InstructionSelector::VisitChangeInt64ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDL, node); ++} ++ ++void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDUw, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat32ToInt32(Node* node) { ++ VisitRR(this, kLa64TruncWS, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat32ToUint32(Node* node) { ++ VisitRR(this, kLa64TruncUwS, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { ++ La64OperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ // Match ChangeFloat64ToInt32(Float64Round##OP) to corresponding instruction ++ // which does rounding and conversion to integer format. ++ if (CanCover(node, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kFloat64RoundDown: ++ Emit(kLa64FloorWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundUp: ++ Emit(kLa64CeilWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundTiesEven: ++ Emit(kLa64RoundWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundTruncate: ++ Emit(kLa64TruncWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ default: ++ break; ++ } ++ if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) { ++ Node* next = value->InputAt(0); ++ if (CanCover(value, next)) { ++ // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP)) ++ switch (next->opcode()) { ++ case IrOpcode::kFloat32RoundDown: ++ Emit(kLa64FloorWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundUp: ++ Emit(kLa64CeilWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundTiesEven: ++ Emit(kLa64RoundWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundTruncate: ++ Emit(kLa64TruncWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ default: ++ Emit(kLa64TruncWS, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ } else { ++ // Match float32 -> float64 -> int32 representation change path. ++ Emit(kLa64TruncWS, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ } ++ } ++ VisitRR(this, kLa64TruncWD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) { ++ VisitRR(this, kLa64TruncLD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { ++ VisitRR(this, kLa64TruncUwD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) { ++ VisitRR(this, kLa64TruncUlD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToUint32(Node* node) { ++ VisitRR(this, kLa64TruncUwD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToInt64(Node* node) { ++ VisitRR(this, kLa64TruncLD, node); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) { ++ La64OperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ this->Emit(kLa64TruncLS, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat64ToInt64(Node* node) { ++ La64OperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kLa64TruncLD, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat32ToUint64(Node* node) { ++ La64OperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kLa64TruncUlS, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) { ++ La64OperandGenerator g(this); ++ ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kLa64TruncUlD, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitBitcastWord32ToWord64(Node* node) { ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitChangeInt32ToInt64(Node* node) { ++ Node* value = node->InputAt(0); ++ if (value->opcode() == IrOpcode::kLoad && CanCover(node, value)) { ++ // Generate sign-extending load. ++ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); ++ InstructionCode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kLa64Lhu : kLa64Lh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kLa64Lw; ++ break; ++ default: ++ UNREACHABLE(); ++ return; ++ } ++ EmitLoad(this, value, opcode, node); ++ } else { ++ La64OperandGenerator g(this); ++ Emit(kLa64Shl, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0)); ++ } ++} ++ ++bool InstructionSelector::ZeroExtendsWord32ToWord64NoPhis(Node* node) { ++ DCHECK_NE(node->opcode(), IrOpcode::kPhi); ++ switch (node->opcode()) { ++ // 32-bit operations will write their result in a 64 bit register, ++ // clearing the top 32 bits of the destination register. ++ case IrOpcode::kUint32Div: ++ case IrOpcode::kUint32Mod: ++ case IrOpcode::kUint32MulHigh: ++ return true; ++ case IrOpcode::kLoad: { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ if (load_rep.IsUnsigned()) { ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ case MachineRepresentation::kWord16: ++ case MachineRepresentation::kWord32: ++ return true; ++ default: ++ return false; ++ } ++ } ++ return false; ++ } ++ default: ++ return false; ++ } ++} ++ ++void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { ++ La64OperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ if (ZeroExtendsWord32ToWord64(value)) { ++ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); ++ return; ++ } ++ Emit(kLa64Dext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0), g.TempImmediate(32)); ++} ++ ++void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) { ++ La64OperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ if (CanCover(node, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kWord64Sar: { ++ if (TryEmitExtendingLoad(this, value, node)) { ++ return; ++ } else { ++ Int64BinopMatcher m(value); ++ if (m.right().IsInRange(32, 63)) { ++ // After smi untagging no need for truncate. Combine sequence. ++ Emit(kLa64Dsar, g.DefineSameAsFirst(node), ++ g.UseRegister(m.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ break; ++ } ++ default: ++ break; ++ } ++ } ++ Emit(kLa64Ext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0), g.TempImmediate(32)); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { ++ La64OperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding ++ // instruction. ++ if (CanCover(node, value) && ++ value->opcode() == IrOpcode::kChangeInt32ToFloat64) { ++ Emit(kLa64CvtSW, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ VisitRR(this, kLa64CvtSD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToWord32(Node* node) { ++ VisitRR(this, kArchTruncateDoubleToI, node); ++} ++ ++void InstructionSelector::VisitRoundFloat64ToInt32(Node* node) { ++ VisitRR(this, kLa64TruncWD, node); ++} ++ ++void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) { ++ VisitRR(this, kLa64CvtSL, node); ++} ++ ++void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDL, node); ++} ++ ++void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { ++ VisitRR(this, kLa64CvtSUl, node); ++} ++ ++void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { ++ VisitRR(this, kLa64CvtDUl, node); ++} ++ ++void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) { ++ VisitRR(this, kLa64Float64ExtractLowWord32, node); ++} ++ ++void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { ++ VisitRR(this, kLa64BitcastDL, node); ++} ++ ++void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Float64InsertLowWord32, g.DefineAsRegister(node), ++ ImmediateOperand(ImmediateOperand::INLINE, 0), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { ++ VisitRR(this, kLa64BitcastLD, node); ++} ++ ++void InstructionSelector::VisitFloat32Add(Node* node) { ++ // Optimization with Madd.S(z, x, y) is intentionally removed. ++ // See explanation for madd_s in assembler-la64.cc. ++ VisitRRR(this, kLa64AddS, node); ++} ++ ++void InstructionSelector::VisitFloat64Add(Node* node) { ++ // Optimization with Madd.D(z, x, y) is intentionally removed. ++ // See explanation for madd_d in assembler-la64.cc. ++ VisitRRR(this, kLa64AddD, node); ++} ++ ++void InstructionSelector::VisitFloat32Sub(Node* node) { ++ // Optimization with Msub.S(z, x, y) is intentionally removed. ++ // See explanation for madd_s in assembler-la64.cc. ++ VisitRRR(this, kLa64SubS, node); ++} ++ ++void InstructionSelector::VisitFloat64Sub(Node* node) { ++ // Optimization with Msub.D(z, x, y) is intentionally removed. ++ // See explanation for madd_d in assembler-la64.cc. ++ VisitRRR(this, kLa64SubD, node); ++} ++ ++void InstructionSelector::VisitFloat32Mul(Node* node) { ++ VisitRRR(this, kLa64MulS, node); ++} ++ ++void InstructionSelector::VisitFloat64Mul(Node* node) { ++ VisitRRR(this, kLa64MulD, node); ++} ++ ++void InstructionSelector::VisitFloat32Div(Node* node) { ++ VisitRRR(this, kLa64DivS, node); ++} ++ ++void InstructionSelector::VisitFloat64Div(Node* node) { ++ VisitRRR(this, kLa64DivD, node); ++} ++ ++void InstructionSelector::VisitFloat64Mod(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64ModD, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f0), ++ g.UseFixed(node->InputAt(1), f1)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::VisitFloat32Max(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Float32Max, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat64Max(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Float64Max, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat32Min(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Float32Min, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat64Min(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Float64Min, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat32Abs(Node* node) { ++ VisitRR(this, kLa64AbsS, node); ++} ++ ++void InstructionSelector::VisitFloat64Abs(Node* node) { ++ VisitRR(this, kLa64AbsD, node); ++} ++ ++void InstructionSelector::VisitFloat32Sqrt(Node* node) { ++ VisitRR(this, kLa64SqrtS, node); ++} ++ ++void InstructionSelector::VisitFloat64Sqrt(Node* node) { ++ VisitRR(this, kLa64SqrtD, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundDown(Node* node) { ++ VisitRR(this, kLa64Float32RoundDown, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundDown(Node* node) { ++ VisitRR(this, kLa64Float64RoundDown, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundUp(Node* node) { ++ VisitRR(this, kLa64Float32RoundUp, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundUp(Node* node) { ++ VisitRR(this, kLa64Float64RoundUp, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { ++ VisitRR(this, kLa64Float32RoundTruncate, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { ++ VisitRR(this, kLa64Float64RoundTruncate, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { ++ VisitRR(this, kLa64Float32RoundTiesEven, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { ++ VisitRR(this, kLa64Float64RoundTiesEven, node); ++} ++ ++void InstructionSelector::VisitFloat32Neg(Node* node) { ++ VisitRR(this, kLa64NegS, node); ++} ++ ++void InstructionSelector::VisitFloat64Neg(Node* node) { ++ VisitRR(this, kLa64NegD, node); ++} ++ ++void InstructionSelector::VisitFloat64Ieee754Binop(Node* node, ++ InstructionCode opcode) { ++ La64OperandGenerator g(this); ++ Emit(opcode, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f2), ++ g.UseFixed(node->InputAt(1), f4)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::VisitFloat64Ieee754Unop(Node* node, ++ InstructionCode opcode) { ++ La64OperandGenerator g(this); ++ Emit(opcode, g.DefineAsFixed(node, f0), g.UseFixed(node->InputAt(0), f0)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::EmitPrepareArguments( ++ ZoneVector* arguments, const CallDescriptor* call_descriptor, ++ Node* node) { ++ La64OperandGenerator g(this); ++ ++ // Prepare for C function call. ++ if (call_descriptor->IsCFunctionCall()) { ++ Emit(kArchPrepareCallCFunction | MiscField::encode(static_cast( ++ call_descriptor->ParameterCount())), ++ 0, nullptr, 0, nullptr); ++ ++ // Poke any stack arguments. ++ int slot = kCArgSlotCount; ++ for (PushParameter input : (*arguments)) { ++ Emit(kLa64StoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), ++ g.TempImmediate(slot << kSystemPointerSizeLog2)); ++ ++slot; ++ } ++ } else { ++ int push_count = static_cast(call_descriptor->StackParameterCount()); ++ if (push_count > 0) { ++ // Calculate needed space ++ int stack_size = 0; ++ for (PushParameter input : (*arguments)) { ++ if (input.node) { ++ stack_size += input.location.GetSizeInPointers(); ++ } ++ } ++ Emit(kLa64StackClaim, g.NoOutput(), ++ g.TempImmediate(stack_size << kSystemPointerSizeLog2)); ++ } ++ for (size_t n = 0; n < arguments->size(); ++n) { ++ PushParameter input = (*arguments)[n]; ++ if (input.node) { ++ Emit(kLa64StoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), ++ g.TempImmediate(static_cast(n << kSystemPointerSizeLog2))); ++ } ++ } ++ } ++} ++ ++void InstructionSelector::EmitPrepareResults( ++ ZoneVector* results, const CallDescriptor* call_descriptor, ++ Node* node) { ++ La64OperandGenerator g(this); ++ ++ int reverse_slot = 1; ++ for (PushParameter output : *results) { ++ if (!output.location.IsCallerFrameSlot()) continue; ++ // Skip any alignment holes in nodes. ++ if (output.node != nullptr) { ++ DCHECK(!call_descriptor->IsCFunctionCall()); ++ if (output.location.GetType() == MachineType::Float32()) { ++ MarkAsFloat32(output.node); ++ } else if (output.location.GetType() == MachineType::Float64()) { ++ MarkAsFloat64(output.node); ++ } else if (output.location.GetType() == MachineType::Simd128()) { ++ abort(); ++ } ++ Emit(kLa64Peek, g.DefineAsRegister(output.node), ++ g.UseImmediate(reverse_slot)); ++ } ++ reverse_slot += output.location.GetSizeInPointers(); ++ } ++} ++ ++bool InstructionSelector::IsTailCallAddressImmediate() { return false; } ++ ++int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } ++ ++void InstructionSelector::VisitUnalignedLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ La64OperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kFloat32: ++ opcode = kLa64Ulwc1; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kLa64Uldc1; ++ break; ++ case MachineRepresentation::kWord8: ++ opcode = load_rep.IsUnsigned() ? kLa64Lbu : kLa64Lb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kLa64Ulhu : kLa64Ulh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = load_rep.IsUnsigned() ? kLa64Ulwu : kLa64Ulw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Uld; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ case MachineRepresentation::kSimd128: ++ UNREACHABLE(); ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), addr_reg, ++ g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired load opcode, using temp addr_reg. ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); ++ } ++} ++ ++void InstructionSelector::VisitUnalignedStore(Node* node) { ++ La64OperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kFloat32: ++ opcode = kLa64Uswc1; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kLa64Usdc1; ++ break; ++ case MachineRepresentation::kWord8: ++ opcode = kLa64Sb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kLa64Ush; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kLa64Usw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Usd; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ case MachineRepresentation::kSimd128: ++ UNREACHABLE(); ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), addr_reg, ++ g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired store opcode, using temp addr_reg. ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); ++ } ++} ++ ++namespace { ++ ++// Shared routine for multiple compare operations. ++static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, ++ InstructionOperand left, InstructionOperand right, ++ FlagsContinuation* cont) { ++ selector->EmitWithContinuation(opcode, left, right, cont); ++} ++ ++// Shared routine for multiple float32 compare operations. ++void VisitFloat32Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ La64OperandGenerator g(selector); ++ Float32BinopMatcher m(node); ++ InstructionOperand lhs, rhs; ++ ++ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) ++ : g.UseRegister(m.left().node()); ++ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) ++ : g.UseRegister(m.right().node()); ++ VisitCompare(selector, kLa64CmpS, lhs, rhs, cont); ++} ++ ++// Shared routine for multiple float64 compare operations. ++void VisitFloat64Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ La64OperandGenerator g(selector); ++ Float64BinopMatcher m(node); ++ InstructionOperand lhs, rhs; ++ ++ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) ++ : g.UseRegister(m.left().node()); ++ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) ++ : g.UseRegister(m.right().node()); ++ VisitCompare(selector, kLa64CmpD, lhs, rhs, cont); ++} ++ ++// Shared routine for multiple word compare operations. ++void VisitWordCompare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont, ++ bool commutative) { ++ La64OperandGenerator g(selector); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ ++ // Match immediates on left or right side of comparison. ++ if (g.CanBeImmediate(right, opcode)) { ++ if (opcode == kLa64Tst) { ++ VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), ++ cont); ++ } else { ++ switch (cont->condition()) { ++ case kEqual: ++ case kNotEqual: ++ if (cont->IsSet()) { ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseImmediate(right), cont); ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseRegister(right), cont); ++ } ++ break; ++ case kSignedLessThan: ++ case kSignedGreaterThanOrEqual: ++ case kUnsignedLessThan: ++ case kUnsignedGreaterThanOrEqual: ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseImmediate(right), cont); ++ break; ++ default: ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseRegister(right), cont); ++ } ++ } ++ } else if (g.CanBeImmediate(left, opcode)) { ++ if (!commutative) cont->Commute(); ++ if (opcode == kLa64Tst) { ++ VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), ++ cont); ++ } else { ++ switch (cont->condition()) { ++ case kEqual: ++ case kNotEqual: ++ if (cont->IsSet()) { ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseImmediate(left), cont); ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseRegister(left), cont); ++ } ++ break; ++ case kSignedLessThan: ++ case kSignedGreaterThanOrEqual: ++ case kUnsignedLessThan: ++ case kUnsignedGreaterThanOrEqual: ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseImmediate(left), cont); ++ break; ++ default: ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseRegister(left), cont); ++ } ++ } ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), ++ cont); ++ } ++} ++ ++bool IsNodeUnsigned(Node* n) { ++ NodeMatcher m(n); ++ ++ if (m.IsLoad() || m.IsUnalignedLoad() || m.IsPoisonedLoad() || ++ m.IsProtectedLoad() || m.IsWord32AtomicLoad() || m.IsWord64AtomicLoad()) { ++ LoadRepresentation load_rep = LoadRepresentationOf(n->op()); ++ return load_rep.IsUnsigned(); ++ } else { ++ return m.IsUint32Div() || m.IsUint32LessThan() || ++ m.IsUint32LessThanOrEqual() || m.IsUint32Mod() || ++ m.IsUint32MulHigh() || m.IsChangeFloat64ToUint32() || ++ m.IsTruncateFloat64ToUint32() || m.IsTruncateFloat32ToUint32(); ++ } ++} ++ ++// Shared routine for multiple word compare operations. ++void VisitFullWord32Compare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont) { ++ La64OperandGenerator g(selector); ++ InstructionOperand leftOp = g.TempRegister(); ++ InstructionOperand rightOp = g.TempRegister(); ++ ++ selector->Emit(kLa64Dshl, leftOp, g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(32)); ++ selector->Emit(kLa64Dshl, rightOp, g.UseRegister(node->InputAt(1)), ++ g.TempImmediate(32)); ++ ++ VisitCompare(selector, opcode, leftOp, rightOp, cont); ++} ++ ++void VisitOptimizedWord32Compare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, ++ FlagsContinuation* cont) { ++ if (FLAG_debug_code) { ++ La64OperandGenerator g(selector); ++ InstructionOperand leftOp = g.TempRegister(); ++ InstructionOperand rightOp = g.TempRegister(); ++ InstructionOperand optimizedResult = g.TempRegister(); ++ InstructionOperand fullResult = g.TempRegister(); ++ FlagsCondition condition = cont->condition(); ++ InstructionCode testOpcode = opcode | ++ FlagsConditionField::encode(condition) | ++ FlagsModeField::encode(kFlags_set); ++ ++ selector->Emit(testOpcode, optimizedResult, g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++ ++ selector->Emit(kLa64Dshl, leftOp, g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(32)); ++ selector->Emit(kLa64Dshl, rightOp, g.UseRegister(node->InputAt(1)), ++ g.TempImmediate(32)); ++ selector->Emit(testOpcode, fullResult, leftOp, rightOp); ++ ++ selector->Emit(kLa64AssertEqual, g.NoOutput(), optimizedResult, fullResult, ++ g.TempImmediate(static_cast( ++ AbortReason::kUnsupportedNonPrimitiveCompare))); ++ } ++ ++ VisitWordCompare(selector, node, opcode, cont, false); ++} ++ ++void VisitWord32Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ // LA64 doesn't support Word32 compare instructions. Instead it relies ++ // that the values in registers are correctly sign-extended and uses ++ // Word64 comparison instead. This behavior is correct in most cases, ++ // but doesn't work when comparing signed with unsigned operands. ++ // We could simulate full Word32 compare in all cases but this would ++ // create an unnecessary overhead since unsigned integers are rarely ++ // used in JavaScript. ++ // The solution proposed here tries to match a comparison of signed ++ // with unsigned operand, and perform full Word32Compare only ++ // in those cases. Unfortunately, the solution is not complete because ++ // it might skip cases where Word32 full compare is needed, so ++ // basically it is a hack. ++ // When call to a host function in simulator, if the function return a ++ // int32 value, the simulator do not sign-extended to int64 because in ++ // simulator we do not know the function whether return a int32 or int64. ++ // so we need do a full word32 compare in this case. ++#ifndef USE_SIMULATOR ++ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1))) { ++#else ++ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1)) || ++ node->InputAt(0)->opcode() == IrOpcode::kCall || ++ node->InputAt(1)->opcode() == IrOpcode::kCall) { ++#endif ++ VisitFullWord32Compare(selector, node, kLa64Cmp, cont); ++ } else { ++ VisitOptimizedWord32Compare(selector, node, kLa64Cmp, cont); ++ } ++} ++ ++void VisitWord64Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ VisitWordCompare(selector, node, kLa64Cmp, cont, false); ++} ++ ++void EmitWordCompareZero(InstructionSelector* selector, Node* value, ++ FlagsContinuation* cont) { ++ La64OperandGenerator g(selector); ++ selector->EmitWithContinuation(kLa64Cmp, g.UseRegister(value), ++ g.TempImmediate(0), cont); ++} ++ ++void VisitAtomicLoad(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), g.UseRegister(base), ++ g.UseImmediate(index)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ selector->Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), ++ addr_reg, g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired load opcode, using temp addr_reg. ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); ++ } ++} ++ ++void VisitAtomicStore(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.NoOutput(), g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ selector->Emit(kLa64Dadd | AddressingModeField::encode(kMode_None), ++ addr_reg, g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired store opcode, using temp addr_reg. ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.NoOutput(), addr_reg, g.TempImmediate(0), ++ g.UseRegisterOrImmediateZero(value)); ++ } ++} ++ ++void VisitAtomicExchange(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temp[3]; ++ temp[0] = g.TempRegister(); ++ temp[1] = g.TempRegister(); ++ temp[2] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); ++} ++ ++void VisitAtomicCompareExchange(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* old_value = node->InputAt(2); ++ Node* new_value = node->InputAt(3); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[4]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(old_value); ++ inputs[input_count++] = g.UseUniqueRegister(new_value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temp[3]; ++ temp[0] = g.TempRegister(); ++ temp[1] = g.TempRegister(); ++ temp[2] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); ++} ++ ++void VisitAtomicBinop(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ La64OperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temps[4]; ++ temps[0] = g.TempRegister(); ++ temps[1] = g.TempRegister(); ++ temps[2] = g.TempRegister(); ++ temps[3] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 4, temps); ++} ++ ++} // namespace ++ ++void InstructionSelector::VisitStackPointerGreaterThan( ++ Node* node, FlagsContinuation* cont) { ++ StackCheckKind kind = StackCheckKindOf(node->op()); ++ InstructionCode opcode = ++ kArchStackPointerGreaterThan | MiscField::encode(static_cast(kind)); ++ ++ La64OperandGenerator g(this); ++ ++ // No outputs. ++ InstructionOperand* const outputs = nullptr; ++ const int output_count = 0; ++ ++ // Applying an offset to this stack check requires a temp register. Offsets ++ // are only applied to the first stack check. If applying an offset, we must ++ // ensure the input and temp registers do not alias, thus kUniqueRegister. ++ InstructionOperand temps[] = {g.TempRegister()}; ++ const int temp_count = (kind == StackCheckKind::kJSFunctionEntry ? 1 : 0); ++ const auto register_mode = (kind == StackCheckKind::kJSFunctionEntry) ++ ? OperandGenerator::kUniqueRegister ++ : OperandGenerator::kRegister; ++ ++ Node* const value = node->InputAt(0); ++ InstructionOperand inputs[] = {g.UseRegisterWithMode(value, register_mode)}; ++ static constexpr int input_count = arraysize(inputs); ++ ++ EmitWithContinuation(opcode, output_count, outputs, input_count, inputs, ++ temp_count, temps, cont); ++} ++ ++// Shared routine for word comparisons against zero. ++void InstructionSelector::VisitWordCompareZero(Node* user, Node* value, ++ FlagsContinuation* cont) { ++ // Try to combine with comparisons against 0 by simply inverting the branch. ++ while (CanCover(user, value)) { ++ if (value->opcode() == IrOpcode::kWord32Equal) { ++ Int32BinopMatcher m(value); ++ if (!m.right().Is(0)) break; ++ user = value; ++ value = m.left().node(); ++ } else if (value->opcode() == IrOpcode::kWord64Equal) { ++ Int64BinopMatcher m(value); ++ if (!m.right().Is(0)) break; ++ user = value; ++ value = m.left().node(); ++ } else { ++ break; ++ } ++ ++ cont->Negate(); ++ } ++ ++ if (CanCover(user, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kWord32Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kInt32LessThan: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThan); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kInt32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kUint32LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kUint32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kWord64Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kInt64LessThan: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThan); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kInt64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kUint64LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kUint64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kFloat32Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat32LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat64Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kFloat64LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kFloat64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kProjection: ++ // Check if this is the overflow output projection of an ++ // WithOverflow node. ++ if (ProjectionIndexOf(value->op()) == 1u) { ++ // We cannot combine the WithOverflow with this branch ++ // unless the 0th projection (the use of the actual value of the ++ // is either nullptr, which means there's no use of the ++ // actual value, or was already defined, which means it is scheduled ++ // *AFTER* this branch). ++ Node* const node = value->InputAt(0); ++ Node* const result = NodeProperties::FindProjection(node, 0); ++ if (result == nullptr || IsDefined(result)) { ++ switch (node->opcode()) { ++ case IrOpcode::kInt32AddWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kLa64Dadd, cont); ++ case IrOpcode::kInt32SubWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kLa64Dsub, cont); ++ case IrOpcode::kInt32MulWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kLa64MulOvf, cont); ++ case IrOpcode::kInt64AddWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kLa64DaddOvf, cont); ++ case IrOpcode::kInt64SubWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kLa64DsubOvf, cont); ++ default: ++ break; ++ } ++ } ++ } ++ break; ++ case IrOpcode::kWord32And: ++ case IrOpcode::kWord64And: ++ return VisitWordCompare(this, value, kLa64Tst, cont, true); ++ case IrOpcode::kStackPointerGreaterThan: ++ cont->OverwriteAndNegateIfEqual(kStackPointerGreaterThanCondition); ++ return VisitStackPointerGreaterThan(value, cont); ++ default: ++ break; ++ } ++ } ++ ++ // Continuation could not be combined with a compare, emit compare against 0. ++ EmitWordCompareZero(this, value, cont); ++} ++ ++void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { ++ La64OperandGenerator g(this); ++ InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); ++ ++ // Emit either ArchTableSwitch or ArchBinarySearchSwitch. ++ if (enable_switch_jump_table_ == kEnableSwitchJumpTable) { ++ static const size_t kMaxTableSwitchValueRange = 2 << 16; ++ size_t table_space_cost = 10 + 2 * sw.value_range(); ++ size_t table_time_cost = 3; ++ size_t lookup_space_cost = 2 + 2 * sw.case_count(); ++ size_t lookup_time_cost = sw.case_count(); ++ if (sw.case_count() > 0 && ++ table_space_cost + 3 * table_time_cost <= ++ lookup_space_cost + 3 * lookup_time_cost && ++ sw.min_value() > std::numeric_limits::min() && ++ sw.value_range() <= kMaxTableSwitchValueRange) { ++ InstructionOperand index_operand = value_operand; ++ if (sw.min_value()) { ++ index_operand = g.TempRegister(); ++ Emit(kLa64Sub, index_operand, value_operand, ++ g.TempImmediate(sw.min_value())); ++ } ++ // Generate a table lookup. ++ return EmitTableSwitch(sw, index_operand); ++ } ++ } ++ ++ // Generate a tree of conditional jumps. ++ return EmitBinarySearchSwitch(sw, value_operand); ++} ++ ++void InstructionSelector::VisitWord32Equal(Node* const node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ Int32BinopMatcher m(node); ++ if (m.right().Is(0)) { ++ return VisitWordCompareZero(m.node(), m.left().node(), &cont); ++ } ++ ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kLa64Dadd, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kLa64Dadd, &cont); ++} ++ ++void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kLa64Dsub, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kLa64Dsub, &cont); ++} ++ ++void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kLa64MulOvf, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kLa64MulOvf, &cont); ++} ++ ++void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kLa64DaddOvf, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kLa64DaddOvf, &cont); ++} ++ ++void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kLa64DsubOvf, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kLa64DsubOvf, &cont); ++} ++ ++void InstructionSelector::VisitWord64Equal(Node* const node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ Int64BinopMatcher m(node); ++ if (m.right().Is(0)) { ++ return VisitWordCompareZero(m.node(), m.left().node(), &cont); ++ } ++ ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32Equal(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64Equal(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { ++ VisitRR(this, kLa64Float64ExtractLowWord32, node); ++} ++ ++void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { ++ VisitRR(this, kLa64Float64ExtractHighWord32, node); ++} ++ ++void InstructionSelector::VisitFloat64SilenceNaN(Node* node) { ++ VisitRR(this, kLa64Float64SilenceNaN, node); ++} ++ ++void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) { ++ La64OperandGenerator g(this); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ Emit(kLa64Float64InsertLowWord32, g.DefineSameAsFirst(node), ++ g.UseRegister(left), g.UseRegister(right)); ++} ++ ++void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ++ La64OperandGenerator g(this); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ Emit(kLa64Float64InsertHighWord32, g.DefineSameAsFirst(node), ++ g.UseRegister(left), g.UseRegister(right)); ++} ++ ++void InstructionSelector::VisitMemoryBarrier(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Sync, g.NoOutput()); ++} ++ ++void InstructionSelector::VisitWord32AtomicLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ opcode = ++ load_rep.IsSigned() ? kWord32AtomicLoadInt8 : kWord32AtomicLoadUint8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsSigned() ? kWord32AtomicLoadInt16 ++ : kWord32AtomicLoadUint16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kWord32AtomicLoadWord32; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ VisitAtomicLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicStore(Node* node) { ++ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kWord8: ++ opcode = kWord32AtomicStoreWord8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kWord32AtomicStoreWord16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kWord32AtomicStoreWord32; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ VisitAtomicStore(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ opcode = kLa64Word64AtomicLoadUint8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kLa64Word64AtomicLoadUint16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kLa64Word64AtomicLoadUint32; ++ break; ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Word64AtomicLoadUint64; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ VisitAtomicLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicStore(Node* node) { ++ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kWord8: ++ opcode = kLa64Word64AtomicStoreWord8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kLa64Word64AtomicStoreWord16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kLa64Word64AtomicStoreWord32; ++ break; ++ case MachineRepresentation::kWord64: ++ opcode = kLa64Word64AtomicStoreWord64; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ VisitAtomicStore(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = kWord32AtomicExchangeInt8; ++ } else if (type == MachineType::Uint8()) { ++ opcode = kWord32AtomicExchangeUint8; ++ } else if (type == MachineType::Int16()) { ++ opcode = kWord32AtomicExchangeInt16; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kWord32AtomicExchangeUint16; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = kWord32AtomicExchangeWord32; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = kLa64Word64AtomicExchangeUint8; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kLa64Word64AtomicExchangeUint16; ++ } else if (type == MachineType::Uint32()) { ++ opcode = kLa64Word64AtomicExchangeUint32; ++ } else if (type == MachineType::Uint64()) { ++ opcode = kLa64Word64AtomicExchangeUint64; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicCompareExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = kWord32AtomicCompareExchangeInt8; ++ } else if (type == MachineType::Uint8()) { ++ opcode = kWord32AtomicCompareExchangeUint8; ++ } else if (type == MachineType::Int16()) { ++ opcode = kWord32AtomicCompareExchangeInt16; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kWord32AtomicCompareExchangeUint16; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = kWord32AtomicCompareExchangeWord32; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicCompareExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = kLa64Word64AtomicCompareExchangeUint8; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kLa64Word64AtomicCompareExchangeUint16; ++ } else if (type == MachineType::Uint32()) { ++ opcode = kLa64Word64AtomicCompareExchangeUint32; ++ } else if (type == MachineType::Uint64()) { ++ opcode = kLa64Word64AtomicCompareExchangeUint64; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicCompareExchange(this, node, opcode); ++} ++void InstructionSelector::VisitWord32AtomicBinaryOperation( ++ Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op, ++ ArchOpcode uint16_op, ArchOpcode word32_op) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = int8_op; ++ } else if (type == MachineType::Uint8()) { ++ opcode = uint8_op; ++ } else if (type == MachineType::Int16()) { ++ opcode = int16_op; ++ } else if (type == MachineType::Uint16()) { ++ opcode = uint16_op; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = word32_op; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicBinop(this, node, opcode); ++} ++ ++#define VISIT_ATOMIC_BINOP(op) \ ++ void InstructionSelector::VisitWord32Atomic##op(Node* node) { \ ++ VisitWord32AtomicBinaryOperation( \ ++ node, kWord32Atomic##op##Int8, kWord32Atomic##op##Uint8, \ ++ kWord32Atomic##op##Int16, kWord32Atomic##op##Uint16, \ ++ kWord32Atomic##op##Word32); \ ++ } ++VISIT_ATOMIC_BINOP(Add) ++VISIT_ATOMIC_BINOP(Sub) ++VISIT_ATOMIC_BINOP(And) ++VISIT_ATOMIC_BINOP(Or) ++VISIT_ATOMIC_BINOP(Xor) ++#undef VISIT_ATOMIC_BINOP ++ ++void InstructionSelector::VisitWord64AtomicBinaryOperation( ++ Node* node, ArchOpcode uint8_op, ArchOpcode uint16_op, ArchOpcode uint32_op, ++ ArchOpcode uint64_op) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = uint8_op; ++ } else if (type == MachineType::Uint16()) { ++ opcode = uint16_op; ++ } else if (type == MachineType::Uint32()) { ++ opcode = uint32_op; ++ } else if (type == MachineType::Uint64()) { ++ opcode = uint64_op; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicBinop(this, node, opcode); ++} ++ ++#define VISIT_ATOMIC_BINOP(op) \ ++ void InstructionSelector::VisitWord64Atomic##op(Node* node) { \ ++ VisitWord64AtomicBinaryOperation( \ ++ node, kLa64Word64Atomic##op##Uint8, kLa64Word64Atomic##op##Uint16, \ ++ kLa64Word64Atomic##op##Uint32, kLa64Word64Atomic##op##Uint64); \ ++ } ++VISIT_ATOMIC_BINOP(Add) ++VISIT_ATOMIC_BINOP(Sub) ++VISIT_ATOMIC_BINOP(And) ++VISIT_ATOMIC_BINOP(Or) ++VISIT_ATOMIC_BINOP(Xor) ++#undef VISIT_ATOMIC_BINOP ++ ++void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { ++ UNREACHABLE(); ++} ++ ++#define SIMD_TYPE_LIST(V) \ ++ V(F64x2) \ ++ V(F32x4) \ ++ V(I64x2) \ ++ V(I32x4) \ ++ V(I16x8) \ ++ V(I8x16) ++ ++#define SIMD_UNOP_LIST(V) \ ++ V(F64x2Abs, kLa64F64x2Abs) \ ++ V(F64x2Neg, kLa64F64x2Neg) \ ++ V(F64x2Sqrt, kLa64F64x2Sqrt) \ ++ V(F64x2Ceil, kLa64F64x2Ceil) \ ++ V(F64x2Floor, kLa64F64x2Floor) \ ++ V(F64x2Trunc, kLa64F64x2Trunc) \ ++ V(F64x2NearestInt, kLa64F64x2NearestInt) \ ++ V(I64x2Neg, kLa64I64x2Neg) \ ++ V(F32x4SConvertI32x4, kLa64F32x4SConvertI32x4) \ ++ V(F32x4UConvertI32x4, kLa64F32x4UConvertI32x4) \ ++ V(F32x4Abs, kLa64F32x4Abs) \ ++ V(F32x4Neg, kLa64F32x4Neg) \ ++ V(F32x4Sqrt, kLa64F32x4Sqrt) \ ++ V(F32x4RecipApprox, kLa64F32x4RecipApprox) \ ++ V(F32x4RecipSqrtApprox, kLa64F32x4RecipSqrtApprox) \ ++ V(F32x4Ceil, kLa64F32x4Ceil) \ ++ V(F32x4Floor, kLa64F32x4Floor) \ ++ V(F32x4Trunc, kLa64F32x4Trunc) \ ++ V(F32x4NearestInt, kLa64F32x4NearestInt) \ ++ V(I32x4SConvertF32x4, kLa64I32x4SConvertF32x4) \ ++ V(I32x4UConvertF32x4, kLa64I32x4UConvertF32x4) \ ++ V(I32x4Neg, kLa64I32x4Neg) \ ++ V(I32x4SConvertI16x8Low, kLa64I32x4SConvertI16x8Low) \ ++ V(I32x4SConvertI16x8High, kLa64I32x4SConvertI16x8High) \ ++ V(I32x4UConvertI16x8Low, kLa64I32x4UConvertI16x8Low) \ ++ V(I32x4UConvertI16x8High, kLa64I32x4UConvertI16x8High) \ ++ V(I32x4Abs, kLa64I32x4Abs) \ ++ V(I32x4BitMask, kLa64I32x4BitMask) \ ++ V(I16x8Neg, kLa64I16x8Neg) \ ++ V(I16x8SConvertI8x16Low, kLa64I16x8SConvertI8x16Low) \ ++ V(I16x8SConvertI8x16High, kLa64I16x8SConvertI8x16High) \ ++ V(I16x8UConvertI8x16Low, kLa64I16x8UConvertI8x16Low) \ ++ V(I16x8UConvertI8x16High, kLa64I16x8UConvertI8x16High) \ ++ V(I16x8Abs, kLa64I16x8Abs) \ ++ V(I16x8BitMask, kLa64I16x8BitMask) \ ++ V(I8x16Neg, kLa64I8x16Neg) \ ++ V(I8x16Abs, kLa64I8x16Abs) \ ++ V(I8x16BitMask, kLa64I8x16BitMask) \ ++ V(S128Not, kLa64S128Not) \ ++ V(V32x4AnyTrue, kLa64V32x4AnyTrue) \ ++ V(V32x4AllTrue, kLa64V32x4AllTrue) \ ++ V(V16x8AnyTrue, kLa64V16x8AnyTrue) \ ++ V(V16x8AllTrue, kLa64V16x8AllTrue) \ ++ V(V8x16AnyTrue, kLa64V8x16AnyTrue) \ ++ V(V8x16AllTrue, kLa64V8x16AllTrue) ++ ++#define SIMD_SHIFT_OP_LIST(V) \ ++ V(I64x2Shl) \ ++ V(I64x2ShrS) \ ++ V(I64x2ShrU) \ ++ V(I32x4Shl) \ ++ V(I32x4ShrS) \ ++ V(I32x4ShrU) \ ++ V(I16x8Shl) \ ++ V(I16x8ShrS) \ ++ V(I16x8ShrU) \ ++ V(I8x16Shl) \ ++ V(I8x16ShrS) \ ++ V(I8x16ShrU) ++ ++#define SIMD_BINOP_LIST(V) \ ++ V(F64x2Add, kLa64F64x2Add) \ ++ V(F64x2Sub, kLa64F64x2Sub) \ ++ V(F64x2Mul, kLa64F64x2Mul) \ ++ V(F64x2Div, kLa64F64x2Div) \ ++ V(F64x2Min, kLa64F64x2Min) \ ++ V(F64x2Max, kLa64F64x2Max) \ ++ V(F64x2Eq, kLa64F64x2Eq) \ ++ V(F64x2Ne, kLa64F64x2Ne) \ ++ V(F64x2Lt, kLa64F64x2Lt) \ ++ V(F64x2Le, kLa64F64x2Le) \ ++ V(I64x2Add, kLa64I64x2Add) \ ++ V(I64x2Sub, kLa64I64x2Sub) \ ++ V(I64x2Mul, kLa64I64x2Mul) \ ++ V(F32x4Add, kLa64F32x4Add) \ ++ V(F32x4AddHoriz, kLa64F32x4AddHoriz) \ ++ V(F32x4Sub, kLa64F32x4Sub) \ ++ V(F32x4Mul, kLa64F32x4Mul) \ ++ V(F32x4Div, kLa64F32x4Div) \ ++ V(F32x4Max, kLa64F32x4Max) \ ++ V(F32x4Min, kLa64F32x4Min) \ ++ V(F32x4Eq, kLa64F32x4Eq) \ ++ V(F32x4Ne, kLa64F32x4Ne) \ ++ V(F32x4Lt, kLa64F32x4Lt) \ ++ V(F32x4Le, kLa64F32x4Le) \ ++ V(I32x4Add, kLa64I32x4Add) \ ++ V(I32x4AddHoriz, kLa64I32x4AddHoriz) \ ++ V(I32x4Sub, kLa64I32x4Sub) \ ++ V(I32x4Mul, kLa64I32x4Mul) \ ++ V(I32x4MaxS, kLa64I32x4MaxS) \ ++ V(I32x4MinS, kLa64I32x4MinS) \ ++ V(I32x4MaxU, kLa64I32x4MaxU) \ ++ V(I32x4MinU, kLa64I32x4MinU) \ ++ V(I32x4Eq, kLa64I32x4Eq) \ ++ V(I32x4Ne, kLa64I32x4Ne) \ ++ V(I32x4GtS, kLa64I32x4GtS) \ ++ V(I32x4GeS, kLa64I32x4GeS) \ ++ V(I32x4GtU, kLa64I32x4GtU) \ ++ V(I32x4GeU, kLa64I32x4GeU) \ ++ V(I16x8Add, kLa64I16x8Add) \ ++ V(I16x8AddSaturateS, kLa64I16x8AddSaturateS) \ ++ V(I16x8AddSaturateU, kLa64I16x8AddSaturateU) \ ++ V(I16x8AddHoriz, kLa64I16x8AddHoriz) \ ++ V(I16x8Sub, kLa64I16x8Sub) \ ++ V(I16x8SubSaturateS, kLa64I16x8SubSaturateS) \ ++ V(I16x8SubSaturateU, kLa64I16x8SubSaturateU) \ ++ V(I16x8Mul, kLa64I16x8Mul) \ ++ V(I16x8MaxS, kLa64I16x8MaxS) \ ++ V(I16x8MinS, kLa64I16x8MinS) \ ++ V(I16x8MaxU, kLa64I16x8MaxU) \ ++ V(I16x8MinU, kLa64I16x8MinU) \ ++ V(I16x8Eq, kLa64I16x8Eq) \ ++ V(I16x8Ne, kLa64I16x8Ne) \ ++ V(I16x8GtS, kLa64I16x8GtS) \ ++ V(I16x8GeS, kLa64I16x8GeS) \ ++ V(I16x8GtU, kLa64I16x8GtU) \ ++ V(I16x8GeU, kLa64I16x8GeU) \ ++ V(I16x8RoundingAverageU, kLa64I16x8RoundingAverageU) \ ++ V(I16x8SConvertI32x4, kLa64I16x8SConvertI32x4) \ ++ V(I16x8UConvertI32x4, kLa64I16x8UConvertI32x4) \ ++ V(I8x16Add, kLa64I8x16Add) \ ++ V(I8x16AddSaturateS, kLa64I8x16AddSaturateS) \ ++ V(I8x16AddSaturateU, kLa64I8x16AddSaturateU) \ ++ V(I8x16Sub, kLa64I8x16Sub) \ ++ V(I8x16SubSaturateS, kLa64I8x16SubSaturateS) \ ++ V(I8x16SubSaturateU, kLa64I8x16SubSaturateU) \ ++ V(I8x16Mul, kLa64I8x16Mul) \ ++ V(I8x16MaxS, kLa64I8x16MaxS) \ ++ V(I8x16MinS, kLa64I8x16MinS) \ ++ V(I8x16MaxU, kLa64I8x16MaxU) \ ++ V(I8x16MinU, kLa64I8x16MinU) \ ++ V(I8x16Eq, kLa64I8x16Eq) \ ++ V(I8x16Ne, kLa64I8x16Ne) \ ++ V(I8x16GtS, kLa64I8x16GtS) \ ++ V(I8x16GeS, kLa64I8x16GeS) \ ++ V(I8x16GtU, kLa64I8x16GtU) \ ++ V(I8x16GeU, kLa64I8x16GeU) \ ++ V(I8x16RoundingAverageU, kLa64I8x16RoundingAverageU) \ ++ V(I8x16SConvertI16x8, kLa64I8x16SConvertI16x8) \ ++ V(I8x16UConvertI16x8, kLa64I8x16UConvertI16x8) \ ++ V(S128And, kLa64S128And) \ ++ V(S128Or, kLa64S128Or) \ ++ V(S128Xor, kLa64S128Xor) \ ++ V(S128AndNot, kLa64S128AndNot) ++ ++void InstructionSelector::VisitS128Const(Node* node) { ++ La64OperandGenerator g(this); ++ static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t); ++ uint32_t val[kUint32Immediates]; ++ memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size); ++ // If all bytes are zeros or ones, avoid emitting code for generic constants ++ bool all_zeros = !(val[0] || val[1] || val[2] || val[3]); ++ bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX && ++ val[2] == UINT32_MAX && val[3] == UINT32_MAX; ++ InstructionOperand dst = g.DefineAsRegister(node); ++ if (all_zeros) { ++ Emit(kLa64S128Zero, dst); ++ } else if (all_ones) { ++ Emit(kLa64S128AllOnes, dst); ++ } else { ++ Emit(kLa64S128Const, dst, g.UseImmediate(val[0]), g.UseImmediate(val[1]), ++ g.UseImmediate(val[2]), g.UseImmediate(val[3])); ++ } ++} ++ ++void InstructionSelector::VisitS128Zero(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64S128Zero, g.DefineAsRegister(node)); ++} ++ ++#define SIMD_VISIT_SPLAT(Type) \ ++ void InstructionSelector::Visit##Type##Splat(Node* node) { \ ++ VisitRR(this, kLa64##Type##Splat, node); \ ++ } ++SIMD_TYPE_LIST(SIMD_VISIT_SPLAT) ++#undef SIMD_VISIT_SPLAT ++ ++#define SIMD_VISIT_EXTRACT_LANE(Type, Sign) \ ++ void InstructionSelector::Visit##Type##ExtractLane##Sign(Node* node) { \ ++ VisitRRI(this, kLa64##Type##ExtractLane##Sign, node); \ ++ } ++SIMD_VISIT_EXTRACT_LANE(F64x2, ) ++SIMD_VISIT_EXTRACT_LANE(F32x4, ) ++SIMD_VISIT_EXTRACT_LANE(I64x2, ) ++SIMD_VISIT_EXTRACT_LANE(I32x4, ) ++SIMD_VISIT_EXTRACT_LANE(I16x8, U) ++SIMD_VISIT_EXTRACT_LANE(I16x8, S) ++SIMD_VISIT_EXTRACT_LANE(I8x16, U) ++SIMD_VISIT_EXTRACT_LANE(I8x16, S) ++#undef SIMD_VISIT_EXTRACT_LANE ++ ++#define SIMD_VISIT_REPLACE_LANE(Type) \ ++ void InstructionSelector::Visit##Type##ReplaceLane(Node* node) { \ ++ VisitRRIR(this, kLa64##Type##ReplaceLane, node); \ ++ } ++SIMD_TYPE_LIST(SIMD_VISIT_REPLACE_LANE) ++#undef SIMD_VISIT_REPLACE_LANE ++ ++#define SIMD_VISIT_UNOP(Name, instruction) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitRR(this, instruction, node); \ ++ } ++SIMD_UNOP_LIST(SIMD_VISIT_UNOP) ++#undef SIMD_VISIT_UNOP ++ ++#define SIMD_VISIT_SHIFT_OP(Name) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitSimdShift(this, kLa64##Name, node); \ ++ } ++SIMD_SHIFT_OP_LIST(SIMD_VISIT_SHIFT_OP) ++#undef SIMD_VISIT_SHIFT_OP ++ ++#define SIMD_VISIT_BINOP(Name, instruction) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitRRR(this, instruction, node); \ ++ } ++SIMD_BINOP_LIST(SIMD_VISIT_BINOP) ++#undef SIMD_VISIT_BINOP ++ ++void InstructionSelector::VisitS128Select(Node* node) { ++ VisitRRRR(this, kLa64S128Select, node); ++} ++ ++namespace { ++ ++struct ShuffleEntry { ++ uint8_t shuffle[kSimd128Size]; ++ ArchOpcode opcode; ++}; ++ ++static const ShuffleEntry arch_shuffles[] = { ++ {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}, ++ kLa64S32x4InterleaveRight}, ++ {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}, ++ kLa64S32x4InterleaveLeft}, ++ {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}, ++ kLa64S32x4PackEven}, ++ {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}, ++ kLa64S32x4PackOdd}, ++ {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}, ++ kLa64S32x4InterleaveEven}, ++ {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}, ++ kLa64S32x4InterleaveOdd}, ++ ++ {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}, ++ kLa64S16x8InterleaveRight}, ++ {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}, ++ kLa64S16x8InterleaveLeft}, ++ {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}, ++ kLa64S16x8PackEven}, ++ {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}, ++ kLa64S16x8PackOdd}, ++ {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}, ++ kLa64S16x8InterleaveEven}, ++ {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}, ++ kLa64S16x8InterleaveOdd}, ++ {{6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9}, kLa64S16x4Reverse}, ++ {{2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13}, kLa64S16x2Reverse}, ++ ++ {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}, ++ kLa64S8x16InterleaveRight}, ++ {{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}, ++ kLa64S8x16InterleaveLeft}, ++ {{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}, ++ kLa64S8x16PackEven}, ++ {{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, ++ kLa64S8x16PackOdd}, ++ {{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}, ++ kLa64S8x16InterleaveEven}, ++ {{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}, ++ kLa64S8x16InterleaveOdd}, ++ {{7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}, kLa64S8x8Reverse}, ++ {{3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12}, kLa64S8x4Reverse}, ++ {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}, kLa64S8x2Reverse}}; ++ ++bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table, ++ size_t num_entries, bool is_swizzle, ++ ArchOpcode* opcode) { ++ uint8_t mask = is_swizzle ? kSimd128Size - 1 : 2 * kSimd128Size - 1; ++ for (size_t i = 0; i < num_entries; ++i) { ++ const ShuffleEntry& entry = table[i]; ++ int j = 0; ++ for (; j < kSimd128Size; ++j) { ++ if ((entry.shuffle[j] & mask) != (shuffle[j] & mask)) { ++ break; ++ } ++ } ++ if (j == kSimd128Size) { ++ *opcode = entry.opcode; ++ return true; ++ } ++ } ++ return false; ++} ++ ++} // namespace ++ ++void InstructionSelector::VisitI8x16Shuffle(Node* node) { ++ uint8_t shuffle[kSimd128Size]; ++ bool is_swizzle; ++ CanonicalizeShuffle(node, shuffle, &is_swizzle); ++ uint8_t shuffle32x4[4]; ++ ArchOpcode opcode; ++ if (TryMatchArchShuffle(shuffle, arch_shuffles, arraysize(arch_shuffles), ++ is_swizzle, &opcode)) { ++ VisitRRR(this, opcode, node); ++ return; ++ } ++ Node* input0 = node->InputAt(0); ++ Node* input1 = node->InputAt(1); ++ uint8_t offset; ++ La64OperandGenerator g(this); ++ if (wasm::SimdShuffle::TryMatchConcat(shuffle, &offset)) { ++ Emit(kLa64S8x16Concat, g.DefineSameAsFirst(node), g.UseRegister(input1), ++ g.UseRegister(input0), g.UseImmediate(offset)); ++ return; ++ } ++ if (wasm::SimdShuffle::TryMatch32x4Shuffle(shuffle, shuffle32x4)) { ++ Emit(kLa64S32x4Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), ++ g.UseRegister(input1), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4))); ++ return; ++ } ++ Emit(kLa64I8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), ++ g.UseRegister(input1), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12))); ++} ++ ++void InstructionSelector::VisitI8x16Swizzle(Node* node) { ++ La64OperandGenerator g(this); ++ InstructionOperand temps[] = {g.TempSimd128Register()}; ++ // We don't want input 0 or input 1 to be the same as output, since we will ++ // modify output before do the calculation. ++ Emit(kLa64I8x16Swizzle, g.DefineAsRegister(node), ++ g.UseUniqueRegister(node->InputAt(0)), ++ g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); ++} ++ ++void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Seb, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord16ToInt32(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Seh, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Seb, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Seh, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) { ++ La64OperandGenerator g(this); ++ Emit(kLa64Shl, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0)); ++} ++ ++void InstructionSelector::VisitF32x4Pmin(Node* node) { ++ VisitUniqueRRR(this, kLa64F32x4Pmin, node); ++} ++ ++void InstructionSelector::VisitF32x4Pmax(Node* node) { ++ VisitUniqueRRR(this, kLa64F32x4Pmax, node); ++} ++ ++void InstructionSelector::VisitF64x2Pmin(Node* node) { ++ VisitUniqueRRR(this, kLa64F64x2Pmin, node); ++} ++ ++void InstructionSelector::VisitF64x2Pmax(Node* node) { ++ VisitUniqueRRR(this, kLa64F64x2Pmax, node); ++} ++ ++// static ++MachineOperatorBuilder::Flags ++InstructionSelector::SupportedMachineOperatorFlags() { ++ MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; ++ return flags | MachineOperatorBuilder::kWord32Ctz | ++ MachineOperatorBuilder::kWord64Ctz | ++ MachineOperatorBuilder::kWord32Popcnt | ++ MachineOperatorBuilder::kWord64Popcnt | ++ MachineOperatorBuilder::kWord32ShiftIsSafe | ++ MachineOperatorBuilder::kInt32DivIsSafe | ++ MachineOperatorBuilder::kUint32DivIsSafe | ++ MachineOperatorBuilder::kFloat64RoundDown | ++ MachineOperatorBuilder::kFloat32RoundDown | ++ MachineOperatorBuilder::kFloat64RoundUp | ++ MachineOperatorBuilder::kFloat32RoundUp | ++ MachineOperatorBuilder::kFloat64RoundTruncate | ++ MachineOperatorBuilder::kFloat32RoundTruncate | ++ MachineOperatorBuilder::kFloat64RoundTiesEven | ++ MachineOperatorBuilder::kFloat32RoundTiesEven; ++} ++ ++// static ++MachineOperatorBuilder::AlignmentRequirements ++InstructionSelector::AlignmentRequirements() { ++ return MachineOperatorBuilder::AlignmentRequirements:: ++ FullUnalignedAccessSupport(); ++} ++ ++#undef SIMD_BINOP_LIST ++#undef SIMD_SHIFT_OP_LIST ++#undef SIMD_UNOP_LIST ++#undef SIMD_TYPE_LIST ++#undef TRACE_UNIMPL ++#undef TRACE ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc +@@ -100,6 +100,18 @@ namespace { + #define CALLEE_SAVE_FP_REGISTERS \ + f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() + ++#elif V8_TARGET_ARCH_LOONGARCH64 ++// =========================================================================== ++// == loongarch64 ============================================================ ++// =========================================================================== ++#define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 ++#define CALLEE_SAVE_REGISTERS \ ++ s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ ++ s7.bit() | fp.bit() ++#define CALLEE_SAVE_FP_REGISTERS \ ++ f24.bit() | f25.bit() | f26.bit() | f27.bit() | f28.bit() | f29.bit() | \ ++ f30.bit() | f31.bit() ++ + #elif V8_TARGET_ARCH_PPC64 + // =========================================================================== + // == ppc & ppc64 ============================================================ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc.rej +@@ -0,0 +1,21 @@ ++--- src/3rdparty/chromium/v8/src/compiler/c-linkage.cc +++++ src/3rdparty/chromium/v8/src/compiler/c-linkage.cc ++@@ -100,6 +100,18 @@ namespace { ++ #define CALLEE_SAVE_FP_REGISTERS \ ++ f20.bit() | f22.bit() | f24.bit() | f26.bit() | f28.bit() | f30.bit() ++ +++#elif V8_TARGET_ARCH_LOONGARCH64 +++// =========================================================================== +++// == loongarch64 ============================================================ +++// =========================================================================== +++#define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 +++#define CALLEE_SAVE_REGISTERS \ +++ s0.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | \ +++ s7.bit() | fp.bit() +++#define CALLEE_SAVE_FP_REGISTERS \ +++ f24.bit() | f25.bit() | f26.bit() | f27.bit() | f28.bit() | f29.bit() | \ +++ f30.bit() | f31.bit() +++ ++ #elif V8_TARGET_ARCH_PPC64 ++ // =========================================================================== ++ // == ppc & ppc64 ============================================================ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc +@@ -1061,7 +1061,7 @@ void DebugEvaluate::VerifyTransitiveBuil + } + CHECK(!failed); + #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ +- defined(V8_TARGET_ARCH_MIPS64) ++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) + // Isolate-independent builtin calls and jumps do not emit reloc infos + // on PPC. We try to avoid using PC relative code due to performance + // issue with especially older hardwares. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc +++++ src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc ++@@ -1061,7 +1061,7 @@ void DebugEvaluate::VerifyTransitiveBuiltins(Isolate* isolate) { ++ } ++ CHECK(!failed); ++ #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ ++- defined(V8_TARGET_ARCH_MIPS64) +++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) ++ // Isolate-independent builtin calls and jumps do not emit reloc infos ++ // on PPC. We try to avoid using PC relative code due to performance ++ // issue with especially older hardwares. +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/debug/loongarch64/debug-loongarch64.cc +@@ -0,0 +1,55 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/debug/debug.h" ++#include "src/debug/liveedit.h" ++#include "src/execution/frames-inl.h" ++ ++namespace v8 { ++namespace internal { ++ ++#define __ ACCESS_MASM(masm) ++ ++void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); ++ } ++ __ MaybeDropFrames(); ++ ++ // Return to caller. ++ __ Ret(); ++} ++ ++void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { ++ // Frame is being dropped: ++ // - Drop to the target frame specified by a1. ++ // - Look up current function on the frame. ++ // - Leave the frame. ++ // - Restart the frame by calling the function. ++ __ mov(fp, a1); ++ __ Ld_d(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ ++ // Pop return address and frame. ++ __ LeaveFrame(StackFrame::INTERNAL); ++ ++ __ Ld_d(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld_hu( ++ a0, FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ mov(a2, a0); ++ ++ __ InvokeFunction(a1, a2, a0, JUMP_FUNCTION); ++} ++ ++const bool LiveEdit::kFrameDropperSupported = true; ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/deoptimizer/loongarch64/deoptimizer-loongarch64.cc +@@ -0,0 +1,241 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/register-configuration.h" ++#include "src/codegen/safepoint-table.h" ++#include "src/deoptimizer/deoptimizer.h" ++ ++namespace v8 { ++namespace internal { ++ ++const bool Deoptimizer::kSupportsFixedDeoptExitSizes = false; ++const int Deoptimizer::kNonLazyDeoptExitSize = 0; ++const int Deoptimizer::kLazyDeoptExitSize = 0; ++ ++#define __ masm-> ++ ++// This code tries to be close to ia32 code so that any changes can be ++// easily ported. ++void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, ++ Isolate* isolate, ++ DeoptimizeKind deopt_kind) { ++ NoRootArrayScope no_root_array(masm); ++ ++ // Unlike on ARM we don't save all the registers, just the useful ones. ++ // For the rest, there are gaps on the stack, so the offsets remain the same. ++ const int kNumberOfRegisters = Register::kNumRegisters; ++ ++ RegList restored_regs = kJSCallerSaved | kCalleeSaved; ++ RegList saved_regs = restored_regs | sp.bit() | ra.bit(); ++ ++ const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; ++ ++ // Save all double FPU registers before messing with them. ++ __ Sub_d(sp, sp, Operand(kDoubleRegsSize)); ++ const RegisterConfiguration* config = RegisterConfiguration::Default(); ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); ++ int offset = code * kDoubleSize; ++ __ Fst_d(fpu_reg, MemOperand(sp, offset)); ++ } ++ ++ // Push saved_regs (needed to populate FrameDescription::registers_). ++ // Leave gaps for other registers. ++ __ Sub_d(sp, sp, kNumberOfRegisters * kPointerSize); ++ for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { ++ if ((saved_regs & (1 << i)) != 0) { ++ __ St_d(ToRegister(i), MemOperand(sp, kPointerSize * i)); ++ } ++ } ++ ++ __ li(a2, Operand(ExternalReference::Create( ++ IsolateAddressId::kCEntryFPAddress, isolate))); ++ __ St_d(fp, MemOperand(a2, 0)); ++ ++ const int kSavedRegistersAreaSize = ++ (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; ++ ++ // Get the bailout is passed as kRootRegister by the caller. ++ __ mov(a2, kRootRegister); ++ ++ // Get the address of the location in the code object (a3) (return ++ // address for lazy deoptimization) and compute the fp-to-sp delta in ++ // register a4. ++ __ mov(a3, ra); ++ __ Add_d(a4, sp, Operand(kSavedRegistersAreaSize)); ++ ++ __ Sub_d(a4, fp, a4); ++ ++ // Allocate a new deoptimizer object. ++ __ PrepareCallCFunction(6, a5); ++ // Pass six arguments, according to n64 ABI. ++ __ mov(a0, zero_reg); ++ Label context_check; ++ __ Ld_d(a1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); ++ __ JumpIfSmi(a1, &context_check); ++ __ Ld_d(a0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ bind(&context_check); ++ __ li(a1, Operand(static_cast(deopt_kind))); ++ // a2: bailout id already loaded. ++ // a3: code address or 0 already loaded. ++ // a4: already has fp-to-sp delta. ++ __ li(a5, Operand(ExternalReference::isolate_address(isolate))); ++ ++ // Call Deoptimizer::New(). ++ { ++ AllowExternalCallThatCantCauseGC scope(masm); ++ __ CallCFunction(ExternalReference::new_deoptimizer_function(), 6); ++ } ++ ++ // Preserve "deoptimizer" object in register v0 and get the input ++ // frame descriptor pointer to a1 (deoptimizer->input_); ++ // Move deopt-obj to a0 for call to Deoptimizer::ComputeOutputFrames() below. ++ // TODO save a0 ++ //__ mov(a0, v0); ++ __ Ld_d(a1, MemOperand(a0, Deoptimizer::input_offset())); ++ ++ // Copy core registers into FrameDescription::registers_[kNumRegisters]. ++ DCHECK_EQ(Register::kNumRegisters, kNumberOfRegisters); ++ for (int i = 0; i < kNumberOfRegisters; i++) { ++ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); ++ if ((saved_regs & (1 << i)) != 0) { ++ __ Ld_d(a2, MemOperand(sp, i * kPointerSize)); ++ __ St_d(a2, MemOperand(a1, offset)); ++ } else if (FLAG_debug_code) { ++ __ li(a2, Operand(kDebugZapValue)); ++ __ St_d(a2, MemOperand(a1, offset)); ++ } ++ } ++ ++ int double_regs_offset = FrameDescription::double_registers_offset(); ++ // Copy FPU registers to ++ // double_registers_[DoubleRegister::kNumAllocatableRegisters] ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ int dst_offset = code * kDoubleSize + double_regs_offset; ++ int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; ++ __ Fld_d(f0, MemOperand(sp, src_offset)); ++ __ Fst_d(f0, MemOperand(a1, dst_offset)); ++ } ++ ++ // Remove the saved registers from the stack. ++ __ Add_d(sp, sp, Operand(kSavedRegistersAreaSize)); ++ ++ // Compute a pointer to the unwinding limit in register a2; that is ++ // the first stack slot not part of the input frame. ++ __ Ld_d(a2, MemOperand(a1, FrameDescription::frame_size_offset())); ++ __ Add_d(a2, a2, sp); ++ ++ // Unwind the stack down to - but not including - the unwinding ++ // limit and copy the contents of the activation frame to the input ++ // frame description. ++ __ Add_d(a3, a1, Operand(FrameDescription::frame_content_offset())); ++ Label pop_loop; ++ Label pop_loop_header; ++ __ Branch(&pop_loop_header); ++ __ bind(&pop_loop); ++ __ pop(a4); ++ __ St_d(a4, MemOperand(a3, 0)); ++ __ addi_d(a3, a3, sizeof(uint64_t)); ++ __ bind(&pop_loop_header); ++ __ BranchShort(&pop_loop, ne, a2, Operand(sp)); ++ // Compute the output frame in the deoptimizer. ++ __ push(a0); // Preserve deoptimizer object across call. ++ // a0: deoptimizer object; a1: scratch. ++ __ PrepareCallCFunction(1, a1); ++ // Call Deoptimizer::ComputeOutputFrames(). ++ { ++ AllowExternalCallThatCantCauseGC scope(masm); ++ __ CallCFunction(ExternalReference::compute_output_frames_function(), 1); ++ } ++ __ pop(a0); // Restore deoptimizer object (class Deoptimizer). ++ ++ __ Ld_d(sp, MemOperand(a0, Deoptimizer::caller_frame_top_offset())); ++ ++ // Replace the current (input) frame with the output frames. ++ Label outer_push_loop, inner_push_loop, outer_loop_header, inner_loop_header; ++ // Outer loop state: a4 = current "FrameDescription** output_", ++ // a1 = one past the last FrameDescription**. ++ __ Ld_w(a1, MemOperand(a0, Deoptimizer::output_count_offset())); ++ __ Ld_d(a4, MemOperand(a0, Deoptimizer::output_offset())); // a4 is output_. ++ __ Alsl_d(a1, a1, a4, kPointerSizeLog2, t7); ++ __ Branch(&outer_loop_header); ++ __ bind(&outer_push_loop); ++ // Inner loop state: a2 = current FrameDescription*, a3 = loop index. ++ __ Ld_d(a2, MemOperand(a4, 0)); // output_[ix] ++ __ Ld_d(a3, MemOperand(a2, FrameDescription::frame_size_offset())); ++ __ Branch(&inner_loop_header); ++ __ bind(&inner_push_loop); ++ __ Sub_d(a3, a3, Operand(sizeof(uint64_t))); ++ __ Add_d(a6, a2, Operand(a3)); ++ __ Ld_d(a7, MemOperand(a6, FrameDescription::frame_content_offset())); ++ __ push(a7); ++ __ bind(&inner_loop_header); ++ __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); ++ ++ __ Add_d(a4, a4, Operand(kPointerSize)); ++ __ bind(&outer_loop_header); ++ __ BranchShort(&outer_push_loop, lt, a4, Operand(a1)); ++ ++ __ Ld_d(a1, MemOperand(a0, Deoptimizer::input_offset())); ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); ++ int src_offset = code * kDoubleSize + double_regs_offset; ++ __ Fld_d(fpu_reg, MemOperand(a1, src_offset)); ++ } ++ ++ // Push pc and continuation from the last output frame. ++ __ Ld_d(a6, MemOperand(a2, FrameDescription::pc_offset())); ++ __ push(a6); ++ __ Ld_d(a6, MemOperand(a2, FrameDescription::continuation_offset())); ++ __ push(a6); ++ ++ // Technically restoring 'at' should work unless zero_reg is also restored ++ // but it's safer to check for this. ++ DCHECK(!(t7.bit() & restored_regs)); ++ // Restore the registers from the last output frame. ++ __ mov(t7, a2); ++ for (int i = kNumberOfRegisters - 1; i >= 0; i--) { ++ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); ++ if ((restored_regs & (1 << i)) != 0) { ++ __ Ld_d(ToRegister(i), MemOperand(t7, offset)); ++ } ++ } ++ ++ __ pop(t7); // Get continuation, leave pc on stack. ++ __ pop(ra); ++ __ Jump(t7); ++ __ stop(); ++} ++ ++// Maximum size of a table entry generated below. ++const int Deoptimizer::table_entry_size_ = 2 * kInstrSize; ++ ++Float32 RegisterValues::GetFloatRegister(unsigned n) const { ++ return Float32::FromBits( ++ static_cast(double_registers_[n].get_bits())); ++} ++ ++void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { ++ SetFrameSlot(offset, value); ++} ++ ++void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { ++ SetFrameSlot(offset, value); ++} ++ ++void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { ++ // No embedded constant pool support. ++ UNREACHABLE(); ++} ++ ++void FrameDescription::SetPc(intptr_t pc) { pc_ = pc; } ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc +@@ -1077,6 +1077,8 @@ class DebugInfoSection : public DebugSec + UNIMPLEMENTED(); + #elif V8_TARGET_ARCH_MIPS64 + UNIMPLEMENTED(); ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ UNIMPLEMENTED(); + #elif V8_TARGET_ARCH_PPC64 && V8_OS_LINUX + w->Write(DW_OP_reg31); // The frame pointer is here on PPC64. + #elif V8_TARGET_ARCH_S390 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc +++++ src/3rdparty/chromium/v8/src/diagnostics/gdb-jit.cc ++@@ -1077,6 +1077,8 @@ class DebugInfoSection : public DebugSection { ++ UNIMPLEMENTED(); ++ #elif V8_TARGET_ARCH_MIPS64 ++ UNIMPLEMENTED(); +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ UNIMPLEMENTED(); ++ #elif V8_TARGET_ARCH_PPC64 && V8_OS_LINUX ++ w->Write(DW_OP_reg31); // The frame pointer is here on PPC64. ++ #elif V8_TARGET_ARCH_S390 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/diagnostics/loongarch64/disasm-loongarch64.cc +@@ -0,0 +1,1694 @@ ++#include ++#include ++#include ++#include ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/base/platform/platform.h" ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/diagnostics/disasm.h" ++ ++namespace v8 { ++namespace internal { ++ ++//------------------------------------------------------------------------------ ++ ++// Decoder decodes and disassembles instructions into an output buffer. ++// It uses the converter to convert register names and call destinations into ++// more informative description. ++class Decoder { ++ public: ++ Decoder(const disasm::NameConverter& converter, ++ v8::internal::Vector out_buffer) ++ : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { ++ out_buffer_[out_buffer_pos_] = '\0'; ++ } ++ ++ ~Decoder() {} ++ ++ // Writes one disassembled instruction into 'buffer' (0-terminated). ++ // Returns the length of the disassembled machine instruction in bytes. ++ int InstructionDecode(byte* instruction); ++ ++ private: ++ // Bottleneck functions to print into the out_buffer. ++ void PrintChar(const char ch); ++ void Print(const char* str); ++ ++ // Printing of common values. ++ void PrintRegister(int reg); ++ void PrintFPURegister(int freg); ++ void PrintFPUStatusRegister(int freg); ++ void PrintRj(Instruction* instr); ++ void PrintRk(Instruction* instr); ++ void PrintRd(Instruction* instr); ++ void PrintFj(Instruction* instr); ++ void PrintFk(Instruction* instr); ++ void PrintFd(Instruction* instr); ++ void PrintFa(Instruction* instr); ++ void PrintSa2(Instruction* instr); ++ void PrintSa3(Instruction* instr); ++ void PrintUi5(Instruction* instr); ++ void PrintUi6(Instruction* instr); ++ void PrintUi12(Instruction* instr); ++ void PrintXi12(Instruction* instr); ++ void PrintMsbw(Instruction* instr); ++ void PrintLsbw(Instruction* instr); ++ void PrintMsbd(Instruction* instr); ++ void PrintLsbd(Instruction* instr); ++ // void PrintCond(Instruction* instr); ++ void PrintSi12(Instruction* instr); ++ void PrintSi14(Instruction* instr); ++ void PrintSi16(Instruction* instr); ++ void PrintSi20(Instruction* instr); ++ void PrintCj(Instruction* instr); ++ void PrintCd(Instruction* instr); ++ void PrintCa(Instruction* instr); ++ void PrintCode(Instruction* instr); ++ void PrintHint5(Instruction* instr); ++ void PrintHint15(Instruction* instr); ++ void PrintPCOffs16(Instruction* instr); ++ void PrintPCOffs21(Instruction* instr); ++ void PrintPCOffs26(Instruction* instr); ++ void PrintOffs16(Instruction* instr); ++ void PrintOffs21(Instruction* instr); ++ void PrintOffs26(Instruction* instr); ++ ++ // Handle formatting of instructions and their options. ++ int FormatRegister(Instruction* instr, const char* option); ++ int FormatFPURegister(Instruction* instr, const char* option); ++ int FormatOption(Instruction* instr, const char* option); ++ void Format(Instruction* instr, const char* format); ++ void Unknown(Instruction* instr); ++ int DecodeBreakInstr(Instruction* instr); ++ ++ // Each of these functions decodes one particular instruction type. ++ int InstructionDecode(Instruction* instr); ++ void DecodeTypekOp6(Instruction* instr); ++ void DecodeTypekOp7(Instruction* instr); ++ void DecodeTypekOp8(Instruction* instr); ++ void DecodeTypekOp10(Instruction* instr); ++ void DecodeTypekOp12(Instruction* instr); ++ void DecodeTypekOp14(Instruction* instr); ++ int DecodeTypekOp17(Instruction* instr); ++ void DecodeTypekOp22(Instruction* instr); ++ ++ const disasm::NameConverter& converter_; ++ v8::internal::Vector out_buffer_; ++ int out_buffer_pos_; ++ ++ DISALLOW_COPY_AND_ASSIGN(Decoder); ++}; ++ ++// Support for assertions in the Decoder formatting functions. ++#define STRING_STARTS_WITH(string, compare_string) \ ++ (strncmp(string, compare_string, strlen(compare_string)) == 0) ++ ++// Append the ch to the output buffer. ++void Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; } ++ ++// Append the str to the output buffer. ++void Decoder::Print(const char* str) { ++ char cur = *str++; ++ while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { ++ PrintChar(cur); ++ cur = *str++; ++ } ++ out_buffer_[out_buffer_pos_] = 0; ++} ++ ++// Print the register name according to the active name converter. ++void Decoder::PrintRegister(int reg) { ++ Print(converter_.NameOfCPURegister(reg)); ++} ++ ++void Decoder::PrintRj(Instruction* instr) { ++ int reg = instr->RjValue(); ++ PrintRegister(reg); ++} ++ ++void Decoder::PrintRk(Instruction* instr) { ++ int reg = instr->RkValue(); ++ PrintRegister(reg); ++} ++ ++void Decoder::PrintRd(Instruction* instr) { ++ int reg = instr->RdValue(); ++ PrintRegister(reg); ++} ++ ++// Print the FPUregister name according to the active name converter. ++void Decoder::PrintFPURegister(int freg) { ++ Print(converter_.NameOfXMMRegister(freg)); ++} ++ ++void Decoder::PrintFj(Instruction* instr) { ++ int freg = instr->FjValue(); ++ PrintFPURegister(freg); ++} ++ ++void Decoder::PrintFk(Instruction* instr) { ++ int freg = instr->FkValue(); ++ PrintFPURegister(freg); ++} ++ ++void Decoder::PrintFd(Instruction* instr) { ++ int freg = instr->FdValue(); ++ PrintFPURegister(freg); ++} ++ ++void Decoder::PrintFa(Instruction* instr) { ++ int freg = instr->FaValue(); ++ PrintFPURegister(freg); ++} ++ ++// Print the integer value of the sa field. ++void Decoder::PrintSa2(Instruction* instr) { ++ int sa = instr->Sa2Value(); ++ uint32_t opcode = (instr->InstructionBits() >> 18) << 18; ++ if (opcode == ALSL || opcode == ALSL_D) { ++ sa += 1; ++ } ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa); ++} ++ ++void Decoder::PrintSa3(Instruction* instr) { ++ int sa = instr->Sa3Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", sa); ++} ++ ++void Decoder::PrintUi5(Instruction* instr) { ++ int ui = instr->Ui5Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); ++} ++ ++void Decoder::PrintUi6(Instruction* instr) { ++ int ui = instr->Ui6Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); ++} ++ ++void Decoder::PrintUi12(Instruction* instr) { ++ int ui = instr->Ui12Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ui); ++} ++ ++void Decoder::PrintXi12(Instruction* instr) { ++ int xi = instr->Ui12Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", xi); ++} ++ ++void Decoder::PrintMsbd(Instruction* instr) { ++ int msbd = instr->MsbdValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbd); ++} ++ ++void Decoder::PrintLsbd(Instruction* instr) { ++ int lsbd = instr->LsbdValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbd); ++} ++ ++void Decoder::PrintMsbw(Instruction* instr) { ++ int msbw = instr->MsbwValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", msbw); ++} ++ ++void Decoder::PrintLsbw(Instruction* instr) { ++ int lsbw = instr->LsbwValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", lsbw); ++} ++ ++void Decoder::PrintSi12(Instruction* instr) { ++ int si = ((instr->Si12Value()) << (32 - kSi12Bits)) >> (32 - kSi12Bits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); ++} ++ ++void Decoder::PrintSi14(Instruction* instr) { ++ int si = ((instr->Si14Value()) << (32 - kSi14Bits)) >> (32 - kSi14Bits); ++ si <<= 2; ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); ++} ++ ++void Decoder::PrintSi16(Instruction* instr) { ++ int si = ((instr->Si16Value()) << (32 - kSi16Bits)) >> (32 - kSi16Bits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); ++} ++ ++void Decoder::PrintSi20(Instruction* instr) { ++ int si = ((instr->Si20Value()) << (32 - kSi20Bits)) >> (32 - kSi20Bits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", si); ++} ++ ++void Decoder::PrintCj(Instruction* instr) { ++ int cj = instr->CjValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cj); ++} ++ ++void Decoder::PrintCd(Instruction* instr) { ++ int cd = instr->CdValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", cd); ++} ++ ++void Decoder::PrintCa(Instruction* instr) { ++ int ca = instr->CaValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%u", ca); ++} ++ ++void Decoder::PrintCode(Instruction* instr) { ++ int code = instr->CodeValue(); ++ out_buffer_pos_ += ++ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", code, code); ++} ++ ++void Decoder::PrintHint5(Instruction* instr) { ++ int hint = instr->Hint5Value(); ++ out_buffer_pos_ += ++ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint); ++} ++ ++void Decoder::PrintHint15(Instruction* instr) { ++ int hint = instr->Hint15Value(); ++ out_buffer_pos_ += ++ SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x(%u)", hint, hint); ++} ++ ++void Decoder::PrintPCOffs16(Instruction* instr) { ++ int n_bits = 2; ++ int offs = instr->Offs16Value(); ++ int target = ((offs << n_bits) << (32 - kOffsLowBits - n_bits)) >> ++ (32 - kOffsLowBits - n_bits); ++ out_buffer_pos_ += SNPrintF( ++ out_buffer_ + out_buffer_pos_, "%s", ++ converter_.NameOfAddress(reinterpret_cast(instr) + target)); ++} ++ ++void Decoder::PrintPCOffs21(Instruction* instr) { ++ int n_bits = 2; ++ int offs = instr->Offs21Value(); ++ int target = ++ ((offs << n_bits) << (32 - kOffsLowBits - kOffs21HighBits - n_bits)) >> ++ (32 - kOffsLowBits - kOffs21HighBits - n_bits); ++ out_buffer_pos_ += SNPrintF( ++ out_buffer_ + out_buffer_pos_, "%s", ++ converter_.NameOfAddress(reinterpret_cast(instr) + target)); ++} ++ ++void Decoder::PrintPCOffs26(Instruction* instr) { ++ int n_bits = 2; ++ int offs = instr->Offs26Value(); ++ int target = ++ ((offs << n_bits) << (32 - kOffsLowBits - kOffs26HighBits - n_bits)) >> ++ (32 - kOffsLowBits - kOffs26HighBits - n_bits); ++ out_buffer_pos_ += SNPrintF( ++ out_buffer_ + out_buffer_pos_, "%s", ++ converter_.NameOfAddress(reinterpret_cast(instr) + target)); ++} ++ ++void Decoder::PrintOffs16(Instruction* instr) { ++ int offs = instr->Offs16Value(); ++ offs <<= (32 - kOffsLowBits); ++ offs >>= (32 - kOffsLowBits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); ++} ++ ++void Decoder::PrintOffs21(Instruction* instr) { ++ int offs = instr->Offs21Value(); ++ offs <<= (32 - kOffsLowBits - kOffs21HighBits); ++ offs >>= (32 - kOffsLowBits - kOffs21HighBits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); ++} ++ ++void Decoder::PrintOffs26(Instruction* instr) { ++ int offs = instr->Offs26Value(); ++ offs <<= (32 - kOffsLowBits - kOffs26HighBits); ++ offs >>= (32 - kOffsLowBits - kOffs26HighBits); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", offs); ++} ++ ++// Handle all register based formatting in this function to reduce the ++// complexity of FormatOption. ++int Decoder::FormatRegister(Instruction* instr, const char* format) { ++ DCHECK_EQ(format[0], 'r'); ++ if (format[1] == 'j') { // 'rj: Rj register. ++ int reg = instr->RjValue(); ++ PrintRegister(reg); ++ return 2; ++ } else if (format[1] == 'k') { // 'rk: rk register. ++ int reg = instr->RkValue(); ++ PrintRegister(reg); ++ return 2; ++ } else if (format[1] == 'd') { // 'rd: rd register. ++ int reg = instr->RdValue(); ++ PrintRegister(reg); ++ return 2; ++ } ++ UNREACHABLE(); ++ return 0; ++} ++ ++// Handle all FPUregister based formatting in this function to reduce the ++// complexity of FormatOption. ++int Decoder::FormatFPURegister(Instruction* instr, const char* format) { ++ DCHECK_EQ(format[0], 'f'); ++ if (format[1] == 'j') { // 'fj: fj register. ++ int reg = instr->FjValue(); ++ PrintFPURegister(reg); ++ return 2; ++ } else if (format[1] == 'k') { // 'fk: fk register. ++ int reg = instr->FkValue(); ++ PrintFPURegister(reg); ++ return 2; ++ } else if (format[1] == 'd') { // 'fd: fd register. ++ int reg = instr->FdValue(); ++ PrintFPURegister(reg); ++ return 2; ++ } else if (format[1] == 'a') { // 'fa: fa register. ++ int reg = instr->FaValue(); ++ PrintFPURegister(reg); ++ return 2; ++ } ++ UNREACHABLE(); ++ return 0; ++} ++ ++// FormatOption takes a formatting string and interprets it based on ++// the current instructions. The format string points to the first ++// character of the option string (the option escape has already been ++// consumed by the caller.) FormatOption returns the number of ++// characters that were consumed from the formatting string. ++int Decoder::FormatOption(Instruction* instr, const char* format) { ++ switch (format[0]) { ++ case 'c': { ++ switch (format[1]) { ++ case 'a': ++ DCHECK(STRING_STARTS_WITH(format, "ca")); ++ PrintCa(instr); ++ return 2; ++ case 'd': ++ DCHECK(STRING_STARTS_WITH(format, "cd")); ++ PrintCd(instr); ++ return 2; ++ case 'j': ++ DCHECK(STRING_STARTS_WITH(format, "cj")); ++ PrintCj(instr); ++ return 2; ++ case 'o': ++ DCHECK(STRING_STARTS_WITH(format, "code")); ++ PrintCode(instr); ++ return 4; ++ } ++ } ++ case 'f': { ++ return FormatFPURegister(instr, format); ++ } ++ case 'h': { ++ if (format[4] == '5') { ++ DCHECK(STRING_STARTS_WITH(format, "hint5")); ++ PrintHint5(instr); ++ return 5; ++ } else if (format[4] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "hint15")); ++ PrintHint15(instr); ++ return 6; ++ } ++ break; ++ } ++ case 'l': { ++ switch (format[3]) { ++ case 'w': ++ DCHECK(STRING_STARTS_WITH(format, "lsbw")); ++ PrintLsbw(instr); ++ return 4; ++ case 'd': ++ DCHECK(STRING_STARTS_WITH(format, "lsbd")); ++ PrintLsbd(instr); ++ return 4; ++ default: ++ return 0; ++ } ++ } ++ case 'm': { ++ if (format[3] == 'w') { ++ DCHECK(STRING_STARTS_WITH(format, "msbw")); ++ PrintMsbw(instr); ++ } else if (format[3] == 'd') { ++ DCHECK(STRING_STARTS_WITH(format, "msbd")); ++ PrintMsbd(instr); ++ } ++ return 4; ++ } ++ case 'o': { ++ if (format[1] == 'f') { ++ if (format[4] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "offs16")); ++ PrintOffs16(instr); ++ return 6; ++ } else if (format[4] == '2') { ++ if (format[5] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "offs21")); ++ PrintOffs21(instr); ++ return 6; ++ } else if (format[5] == '6') { ++ DCHECK(STRING_STARTS_WITH(format, "offs26")); ++ PrintOffs26(instr); ++ return 6; ++ } ++ } ++ } ++ break; ++ } ++ case 'p': { ++ if (format[6] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "pcoffs16")); ++ PrintPCOffs16(instr); ++ return 8; ++ } else if (format[6] == '2') { ++ if (format[7] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "pcoffs21")); ++ PrintPCOffs21(instr); ++ return 8; ++ } else if (format[7] == '6') { ++ DCHECK(STRING_STARTS_WITH(format, "pcoffs26")); ++ PrintPCOffs26(instr); ++ return 8; ++ } ++ } ++ break; ++ } ++ case 'r': { ++ return FormatRegister(instr, format); ++ break; ++ } ++ case 's': { ++ switch (format[1]) { ++ case 'a': ++ if (format[2] == '2') { ++ DCHECK(STRING_STARTS_WITH(format, "sa2")); ++ PrintSa2(instr); ++ } else if (format[2] == '3') { ++ DCHECK(STRING_STARTS_WITH(format, "sa3")); ++ PrintSa3(instr); ++ } ++ return 3; ++ case 'i': ++ if (format[2] == '2') { ++ DCHECK(STRING_STARTS_WITH(format, "si20")); ++ PrintSi20(instr); ++ return 4; ++ } else if (format[2] == '1') { ++ switch (format[3]) { ++ case '2': ++ DCHECK(STRING_STARTS_WITH(format, "si12")); ++ PrintSi12(instr); ++ return 4; ++ case '4': ++ DCHECK(STRING_STARTS_WITH(format, "si14")); ++ PrintSi14(instr); ++ return 4; ++ case '6': ++ DCHECK(STRING_STARTS_WITH(format, "si16")); ++ PrintSi16(instr); ++ return 4; ++ default: ++ break; ++ } ++ } ++ break; ++ default: ++ break; ++ } ++ break; ++ } ++ case 'u': { ++ if (format[2] == '5') { ++ DCHECK(STRING_STARTS_WITH(format, "ui5")); ++ PrintUi5(instr); ++ return 3; ++ } else if (format[2] == '6') { ++ DCHECK(STRING_STARTS_WITH(format, "ui6")); ++ PrintUi6(instr); ++ return 3; ++ } else if (format[2] == '1') { ++ DCHECK(STRING_STARTS_WITH(format, "ui12")); ++ PrintUi12(instr); ++ return 4; ++ } ++ break; ++ } ++ case 'x': { ++ DCHECK(STRING_STARTS_WITH(format, "xi12")); ++ PrintXi12(instr); ++ return 4; ++ } ++ default: ++ UNREACHABLE(); ++ } ++ return 0; ++} ++ ++// Format takes a formatting string for a whole instruction and prints it into ++// the output buffer. All escaped options are handed to FormatOption to be ++// parsed further. ++void Decoder::Format(Instruction* instr, const char* format) { ++ char cur = *format++; ++ while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { ++ if (cur == '\'') { // Single quote is used as the formatting escape. ++ format += FormatOption(instr, format); ++ } else { ++ out_buffer_[out_buffer_pos_++] = cur; ++ } ++ cur = *format++; ++ } ++ out_buffer_[out_buffer_pos_] = '\0'; ++} ++ ++// For currently unimplemented decodings the disassembler calls Unknown(instr) ++// which will just print "unknown" of the instruction bits. ++void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); } ++ ++int Decoder::DecodeBreakInstr(Instruction* instr) { ++ // This is already known to be BREAK instr, just extract the code. ++ /*if (instr->Bits(14, 0) == static_cast(kMaxStopCode)) { ++ // This is stop(msg). ++ Format(instr, "break, code: 'code"); ++ out_buffer_pos_ += SNPrintF( ++ out_buffer_ + out_buffer_pos_, "\n%p %08" PRIx64, ++ static_cast(reinterpret_cast(instr + kInstrSize)), ++ reinterpret_cast( ++ *reinterpret_cast(instr + kInstrSize))); ++ // Size 3: the break_ instr, plus embedded 64-bit char pointer. ++ return 3 * kInstrSize; ++ } else { ++ Format(instr, "break, code: 'code"); ++ return kInstrSize; ++ }*/ ++ Format(instr, "break code: 'code"); ++ return kInstrSize; ++} //=================================================== ++ ++void Decoder::DecodeTypekOp6(Instruction* instr) { ++ switch (instr->Bits(31, 26) << 26) { ++ case ADDU16I_D: ++ Format(instr, "addu16i.d 'rd, 'rj, 'si16"); ++ break; ++ case BEQZ: ++ Format(instr, "beqz 'rj, 'offs21 -> 'pcoffs21"); ++ break; ++ case BNEZ: ++ Format(instr, "bnez 'rj, 'offs21 -> 'pcoffs21"); ++ break; ++ case BCZ: ++ if (instr->Bit(8)) ++ Format(instr, "bcnez fcc'cj, 'offs21 -> 'pcoffs21"); ++ else ++ Format(instr, "bceqz fcc'cj, 'offs21 -> 'pcoffs21"); ++ break; ++ case JIRL: ++ Format(instr, "jirl 'rd, 'rj, 'offs16"); ++ break; ++ case B: ++ Format(instr, "b 'offs26 -> 'pcoffs26"); ++ break; ++ case BL: ++ Format(instr, "bl 'offs26 -> 'pcoffs26"); ++ break; ++ case BEQ: ++ Format(instr, "beq 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ case BNE: ++ Format(instr, "bne 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ case BLT: ++ Format(instr, "blt 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ case BGE: ++ Format(instr, "bge 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ case BLTU: ++ Format(instr, "bltu 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ case BGEU: ++ Format(instr, "bgeu 'rj, 'rd, 'offs16 -> 'pcoffs16"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Decoder::DecodeTypekOp7(Instruction* instr) { ++ switch (instr->Bits(31, 25) << 25) { ++ case LU12I_W: ++ Format(instr, "lu12i.w 'rd, 'si20"); ++ break; ++ case LU32I_D: ++ Format(instr, "lu32i.d 'rd, 'si20"); ++ break; ++ case PCADDI: ++ Format(instr, "pcaddi 'rd, 'si20"); ++ break; ++ case PCALAU12I: ++ Format(instr, "pcalau12i 'rd, 'si20"); ++ break; ++ case PCADDU12I: ++ Format(instr, "pcaddu12i 'rd, 'si20"); ++ break; ++ case PCADDU18I: ++ Format(instr, "pcaddu18i 'rd, 'si20"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Decoder::DecodeTypekOp8(Instruction* instr) { ++ switch (instr->Bits(31, 24) << 24) { ++ case LDPTR_W: ++ Format(instr, "ldptr.w 'rd, 'rj, 'si14"); ++ break; ++ case STPTR_W: ++ Format(instr, "stptr.w 'rd, 'rj, 'si14"); ++ break; ++ case LDPTR_D: ++ Format(instr, "ldptr.d 'rd, 'rj, 'si14"); ++ break; ++ case STPTR_D: ++ Format(instr, "stptr.d 'rd, 'rj, 'si14"); ++ break; ++ case LL_W: ++ Format(instr, "ll.w 'rd, 'rj, 'si14"); ++ break; ++ case SC_W: ++ Format(instr, "sc.w 'rd, 'rj, 'si14"); ++ break; ++ case LL_D: ++ Format(instr, "ll.d 'rd, 'rj, 'si14"); ++ break; ++ case SC_D: ++ Format(instr, "sc.d 'rd, 'rj, 'si14"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Decoder::DecodeTypekOp10(Instruction* instr) { ++ switch (instr->Bits(31, 22) << 22) { ++ case BSTR_W: { ++ if (instr->Bit(21) != 0) { ++ if (instr->Bit(15) == 0) { ++ Format(instr, "bstrins.w 'rd, 'rj, 'msbw, 'lsbw"); ++ } else { ++ Format(instr, "bstrpick.w 'rd, 'rj, 'msbw, 'lsbw"); ++ } ++ } ++ break; ++ } ++ case BSTRINS_D: ++ Format(instr, "bstrins.d 'rd, 'rj, 'msbd, 'lsbd"); ++ break; ++ case BSTRPICK_D: ++ Format(instr, "bstrpick.d 'rd, 'rj, 'msbd, 'lsbd"); ++ break; ++ case SLTI: ++ Format(instr, "slti 'rd, 'rj, 'si12"); ++ break; ++ case SLTUI: ++ Format(instr, "sltui 'rd, 'rj, 'si12"); ++ break; ++ case ADDI_W: ++ Format(instr, "addi.w 'rd, 'rj, 'si12"); ++ break; ++ case ADDI_D: ++ Format(instr, "addi.d 'rd, 'rj, 'si12"); ++ break; ++ case LU52I_D: ++ Format(instr, "lu52i.d 'rd, 'rj, 'si12"); ++ break; ++ case ANDI: ++ Format(instr, "andi 'rd, 'rj, 'xi12"); ++ break; ++ case ORI: ++ Format(instr, "ori 'rd, 'rj, 'xi12"); ++ break; ++ case XORI: ++ Format(instr, "xori 'rd, 'rj, 'xi12"); ++ break; ++ case LD_B: ++ Format(instr, "ld.b 'rd, 'rj, 'si12"); ++ break; ++ case LD_H: ++ Format(instr, "ld.h 'rd, 'rj, 'si12"); ++ break; ++ case LD_W: ++ Format(instr, "ld.w 'rd, 'rj, 'si12"); ++ break; ++ case LD_D: ++ Format(instr, "ld.d 'rd, 'rj, 'si12"); ++ break; ++ case ST_B: ++ Format(instr, "st.b 'rd, 'rj, 'si12"); ++ break; ++ case ST_H: ++ Format(instr, "st.h 'rd, 'rj, 'si12"); ++ break; ++ case ST_W: ++ Format(instr, "st.w 'rd, 'rj, 'si12"); ++ break; ++ case ST_D: ++ Format(instr, "st.d 'rd, 'rj, 'si12"); ++ break; ++ case LD_BU: ++ Format(instr, "ld.bu 'rd, 'rj, 'si12"); ++ break; ++ case LD_HU: ++ Format(instr, "ld.hu 'rd, 'rj, 'si12"); ++ break; ++ case LD_WU: ++ Format(instr, "ld.wu 'rd, 'rj, 'si12"); ++ break; ++ case FLD_S: ++ Format(instr, "fld.s 'fd, 'rj, 'si12"); ++ break; ++ case FST_S: ++ Format(instr, "fst.s 'fd, 'rj, 'si12"); ++ break; ++ case FLD_D: ++ Format(instr, "fld.d 'fd, 'rj, 'si12"); ++ break; ++ case FST_D: ++ Format(instr, "fst.d 'fd, 'rj, 'si12"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Decoder::DecodeTypekOp12(Instruction* instr) { ++ switch (instr->Bits(31, 20) << 20) { ++ case FMADD_S: ++ Format(instr, "fmadd.s 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FMADD_D: ++ Format(instr, "fmadd.d 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FMSUB_S: ++ Format(instr, "fmsub.s 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FMSUB_D: ++ Format(instr, "fmsub.d 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FNMADD_S: ++ Format(instr, "fnmadd.s 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FNMADD_D: ++ Format(instr, "fnmadd.d 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FNMSUB_S: ++ Format(instr, "fnmsub.s 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FNMSUB_D: ++ Format(instr, "fnmsub.d 'fd, 'fj, 'fk, 'fa"); ++ break; ++ case FCMP_COND_S: ++ switch (instr->Bits(19, 15)) { ++ case CAF: ++ Format(instr, "fcmp.caf.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SAF: ++ Format(instr, "fcmp.saf.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CLT: ++ Format(instr, "fcmp.clt.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CEQ: ++ Format(instr, "fcmp.ceq.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SEQ: ++ Format(instr, "fcmp.seq.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CLE: ++ Format(instr, "fcmp.cle.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SLE: ++ Format(instr, "fcmp.sle.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CUN: ++ Format(instr, "fcmp.cun.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SUN: ++ Format(instr, "fcmp.sun.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CULT: ++ Format(instr, "fcmp.cult.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SULT: ++ Format(instr, "fcmp.sult.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CUEQ: ++ Format(instr, "fcmp.cueq.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SUEQ: ++ Format(instr, "fcmp.sueq.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CULE: ++ Format(instr, "fcmp.cule.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SULE: ++ Format(instr, "fcmp.sule.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CNE: ++ Format(instr, "fcmp.cne.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SNE: ++ Format(instr, "fcmp.sne.s fcc'cd, 'fj, 'fk"); ++ break; ++ case COR: ++ Format(instr, "fcmp.cor.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SOR: ++ Format(instr, "fcmp.sor.s fcc'cd, 'fj, 'fk"); ++ break; ++ case CUNE: ++ Format(instr, "fcmp.cune.s fcc'cd, 'fj, 'fk"); ++ break; ++ case SUNE: ++ Format(instr, "fcmp.sune.s fcc'cd, 'fj, 'fk"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ break; ++ case FCMP_COND_D: ++ switch (instr->Bits(19, 15)) { ++ case CAF: ++ Format(instr, "fcmp.caf.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SAF: ++ Format(instr, "fcmp.saf.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CLT: ++ Format(instr, "fcmp.clt.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CEQ: ++ Format(instr, "fcmp.ceq.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SEQ: ++ Format(instr, "fcmp.seq.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CLE: ++ Format(instr, "fcmp.cle.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SLE: ++ Format(instr, "fcmp.sle.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CUN: ++ Format(instr, "fcmp.cun.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SUN: ++ Format(instr, "fcmp.sun.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CULT: ++ Format(instr, "fcmp.cult.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SULT: ++ Format(instr, "fcmp.sult.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CUEQ: ++ Format(instr, "fcmp.cueq.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SUEQ: ++ Format(instr, "fcmp.sueq.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CULE: ++ Format(instr, "fcmp.cule.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SULE: ++ Format(instr, "fcmp.sule.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CNE: ++ Format(instr, "fcmp.cne.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SNE: ++ Format(instr, "fcmp.sne.d fcc'cd, 'fj, 'fk"); ++ break; ++ case COR: ++ Format(instr, "fcmp.cor.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SOR: ++ Format(instr, "fcmp.sor.d fcc'cd, 'fj, 'fk"); ++ break; ++ case CUNE: ++ Format(instr, "fcmp.cune.d fcc'cd, 'fj, 'fk"); ++ break; ++ case SUNE: ++ Format(instr, "fcmp.sune.d fcc'cd, 'fj, 'fk"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ break; ++ case FSEL: ++ Format(instr, "fsel 'fd, 'fj, 'fk, fcc'ca"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Decoder::DecodeTypekOp14(Instruction* instr) { ++ switch (instr->Bits(31, 18) << 18) { ++ case ALSL: ++ if (instr->Bit(17)) ++ Format(instr, "alsl.wu 'rd, 'rj, 'rk, 'sa2"); ++ else ++ Format(instr, "alsl.w 'rd, 'rj, 'rk, 'sa2"); ++ break; ++ case BYTEPICK_W: ++ Format(instr, "bytepick.w 'rd, 'rj, 'rk, 'sa2"); ++ break; ++ case BYTEPICK_D: ++ Format(instr, "bytepick.d 'rd, 'rj, 'rk, 'sa3"); ++ break; ++ case ALSL_D: ++ Format(instr, "alsl.d 'rd, 'rj, 'rk, 'sa2"); ++ break; ++ case SLLI: ++ if (instr->Bit(16)) ++ Format(instr, "slli.d 'rd, 'rj, 'ui6"); ++ else ++ Format(instr, "slli.w 'rd, 'rj, 'ui5"); ++ break; ++ case SRLI: ++ if (instr->Bit(16)) ++ Format(instr, "srli.d 'rd, 'rj, 'ui6"); ++ else ++ Format(instr, "srli.w 'rd, 'rj, 'ui5"); ++ break; ++ case SRAI: ++ if (instr->Bit(16)) ++ Format(instr, "srai.d 'rd, 'rj, 'ui6"); ++ else ++ Format(instr, "srai.w 'rd, 'rj, 'ui5"); ++ break; ++ case ROTRI: ++ if (instr->Bit(16)) ++ Format(instr, "rotri.d 'rd, 'rj, 'ui6"); ++ else ++ Format(instr, "rotri.w 'rd, 'rj, 'ui5"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++int Decoder::DecodeTypekOp17(Instruction* instr) { ++ switch (instr->Bits(31, 15) << 15) { ++ case ADD_W: ++ Format(instr, "add.w 'rd, 'rj, 'rk"); ++ break; ++ case ADD_D: ++ Format(instr, "add.d 'rd, 'rj, 'rk"); ++ break; ++ case SUB_W: ++ Format(instr, "sub.w 'rd, 'rj, 'rk"); ++ break; ++ case SUB_D: ++ Format(instr, "sub.d 'rd, 'rj, 'rk"); ++ break; ++ case SLT: ++ Format(instr, "slt 'rd, 'rj, 'rk"); ++ break; ++ case SLTU: ++ Format(instr, "sltu 'rd, 'rj, 'rk"); ++ break; ++ case MASKEQZ: ++ Format(instr, "maskeqz 'rd, 'rj, 'rk"); ++ break; ++ case MASKNEZ: ++ Format(instr, "masknez 'rd, 'rj, 'rk"); ++ break; ++ case NOR: ++ Format(instr, "nor 'rd, 'rj, 'rk"); ++ break; ++ case AND: ++ Format(instr, "and 'rd, 'rj, 'rk"); ++ break; ++ case OR: ++ Format(instr, "or 'rd, 'rj, 'rk"); ++ break; ++ case XOR: ++ Format(instr, "xor 'rd, 'rj, 'rk"); ++ break; ++ case ORN: ++ Format(instr, "orn 'rd, 'rj, 'rk"); ++ break; ++ case ANDN: ++ Format(instr, "andn 'rd, 'rj, 'rk"); ++ break; ++ case SLL_W: ++ Format(instr, "sll.w 'rd, 'rj, 'rk"); ++ break; ++ case SRL_W: ++ Format(instr, "srl.w 'rd, 'rj, 'rk"); ++ break; ++ case SRA_W: ++ Format(instr, "sra.w 'rd, 'rj, 'rk"); ++ break; ++ case SLL_D: ++ Format(instr, "sll.d 'rd, 'rj, 'rk"); ++ break; ++ case SRL_D: ++ Format(instr, "srl.d 'rd, 'rj, 'rk"); ++ break; ++ case SRA_D: ++ Format(instr, "sra.d 'rd, 'rj, 'rk"); ++ break; ++ case ROTR_D: ++ Format(instr, "rotr.d 'rd, 'rj, 'rk"); ++ break; ++ case ROTR_W: ++ Format(instr, "rotr.w 'rd, 'rj, 'rk"); ++ break; ++ case MUL_W: ++ Format(instr, "mul.w 'rd, 'rj, 'rk"); ++ break; ++ case MULH_W: ++ Format(instr, "mulh.w 'rd, 'rj, 'rk"); ++ break; ++ case MULH_WU: ++ Format(instr, "mulh.wu 'rd, 'rj, 'rk"); ++ break; ++ case MUL_D: ++ Format(instr, "mul.d 'rd, 'rj, 'rk"); ++ break; ++ case MULH_D: ++ Format(instr, "mulh.d 'rd, 'rj, 'rk"); ++ break; ++ case MULH_DU: ++ Format(instr, "mulh.du 'rd, 'rj, 'rk"); ++ break; ++ case MULW_D_W: ++ Format(instr, "mulw.d.w 'rd, 'rj, 'rk"); ++ break; ++ case MULW_D_WU: ++ Format(instr, "mulw.d.wu 'rd, 'rj, 'rk"); ++ break; ++ case DIV_W: ++ Format(instr, "div.w 'rd, 'rj, 'rk"); ++ break; ++ case MOD_W: ++ Format(instr, "mod.w 'rd, 'rj, 'rk"); ++ break; ++ case DIV_WU: ++ Format(instr, "div.wu 'rd, 'rj, 'rk"); ++ break; ++ case MOD_WU: ++ Format(instr, "mod.wu 'rd, 'rj, 'rk"); ++ break; ++ case DIV_D: ++ Format(instr, "div.d 'rd, 'rj, 'rk"); ++ break; ++ case MOD_D: ++ Format(instr, "mod.d 'rd, 'rj, 'rk"); ++ break; ++ case DIV_DU: ++ Format(instr, "div.du 'rd, 'rj, 'rk"); ++ break; ++ case MOD_DU: ++ Format(instr, "mod.du 'rd, 'rj, 'rk"); ++ break; ++ case BREAK: ++ return DecodeBreakInstr(instr); ++ case FADD_S: ++ Format(instr, "fadd.s 'fd, 'fj, 'fk"); ++ break; ++ case FADD_D: ++ Format(instr, "fadd.d 'fd, 'fj, 'fk"); ++ break; ++ case FSUB_S: ++ Format(instr, "fsub.s 'fd, 'fj, 'fk"); ++ break; ++ case FSUB_D: ++ Format(instr, "fsub.d 'fd, 'fj, 'fk"); ++ break; ++ case FMUL_S: ++ Format(instr, "fmul.s 'fd, 'fj, 'fk"); ++ break; ++ case FMUL_D: ++ Format(instr, "fmul.d 'fd, 'fj, 'fk"); ++ break; ++ case FDIV_S: ++ Format(instr, "fdiv.s 'fd, 'fj, 'fk"); ++ break; ++ case FDIV_D: ++ Format(instr, "fdiv.d 'fd, 'fj, 'fk"); ++ break; ++ case FMAX_S: ++ Format(instr, "fmax.s 'fd, 'fj, 'fk"); ++ break; ++ case FMAX_D: ++ Format(instr, "fmax.d 'fd, 'fj, 'fk"); ++ break; ++ case FMIN_S: ++ Format(instr, "fmin.s 'fd, 'fj, 'fk"); ++ break; ++ case FMIN_D: ++ Format(instr, "fmin.d 'fd, 'fj, 'fk"); ++ break; ++ case FMAXA_S: ++ Format(instr, "fmaxa.s 'fd, 'fj, 'fk"); ++ break; ++ case FMAXA_D: ++ Format(instr, "fmaxa.d 'fd, 'fj, 'fk"); ++ break; ++ case FMINA_S: ++ Format(instr, "fmina.s 'fd, 'fj, 'fk"); ++ break; ++ case FMINA_D: ++ Format(instr, "fmina.d 'fd, 'fj, 'fk"); ++ break; ++ case LDX_B: ++ Format(instr, "ldx.b 'rd, 'rj, 'rk"); ++ break; ++ case LDX_H: ++ Format(instr, "ldx.h 'rd, 'rj, 'rk"); ++ break; ++ case LDX_W: ++ Format(instr, "ldx.w 'rd, 'rj, 'rk"); ++ break; ++ case LDX_D: ++ Format(instr, "ldx.d 'rd, 'rj, 'rk"); ++ break; ++ case STX_B: ++ Format(instr, "stx.b 'rd, 'rj, 'rk"); ++ break; ++ case STX_H: ++ Format(instr, "stx.h 'rd, 'rj, 'rk"); ++ break; ++ case STX_W: ++ Format(instr, "stx.w 'rd, 'rj, 'rk"); ++ break; ++ case STX_D: ++ Format(instr, "stx.d 'rd, 'rj, 'rk"); ++ break; ++ case LDX_BU: ++ Format(instr, "ldx.bu 'rd, 'rj, 'rk"); ++ break; ++ case LDX_HU: ++ Format(instr, "ldx.hu 'rd, 'rj, 'rk"); ++ break; ++ case LDX_WU: ++ Format(instr, "ldx.wu 'rd, 'rj, 'rk"); ++ break; ++ case FLDX_S: ++ Format(instr, "fldx.s 'fd, 'rj, 'rk"); ++ break; ++ case FLDX_D: ++ Format(instr, "fldx.d 'fd, 'rj, 'rk"); ++ break; ++ case FSTX_S: ++ Format(instr, "fstx.s 'fd, 'rj, 'rk"); ++ break; ++ case FSTX_D: ++ Format(instr, "fstx.d 'fd, 'rj, 'rk"); ++ break; ++ case AMSWAP_W: ++ Format(instr, "amswap.w 'rd, 'rk, 'rj"); ++ break; ++ case AMSWAP_D: ++ Format(instr, "amswap.d 'rd, 'rk, 'rj"); ++ break; ++ case AMADD_W: ++ Format(instr, "amadd.w 'rd, 'rk, 'rj"); ++ break; ++ case AMADD_D: ++ Format(instr, "amadd.d 'rd, 'rk, 'rj"); ++ break; ++ case AMAND_W: ++ Format(instr, "amand.w 'rd, 'rk, 'rj"); ++ break; ++ case AMAND_D: ++ Format(instr, "amand.d 'rd, 'rk, 'rj"); ++ break; ++ case AMOR_W: ++ Format(instr, "amor.w 'rd, 'rk, 'rj"); ++ break; ++ case AMOR_D: ++ Format(instr, "amor.d 'rd, 'rk, 'rj"); ++ break; ++ case AMXOR_W: ++ Format(instr, "amxor.w 'rd, 'rk, 'rj"); ++ break; ++ case AMXOR_D: ++ Format(instr, "amxor.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_W: ++ Format(instr, "ammax.w 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_D: ++ Format(instr, "ammax.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_W: ++ Format(instr, "ammin.w 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_D: ++ Format(instr, "ammin.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_WU: ++ Format(instr, "ammax.wu 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_DU: ++ Format(instr, "ammax.du 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_WU: ++ Format(instr, "ammin.wu 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_DU: ++ Format(instr, "ammin.du 'rd, 'rk, 'rj"); ++ break; ++ case AMSWAP_DB_W: ++ Format(instr, "amswap_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMSWAP_DB_D: ++ Format(instr, "amswap_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMADD_DB_W: ++ Format(instr, "amadd_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMADD_DB_D: ++ Format(instr, "amadd_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMAND_DB_W: ++ Format(instr, "amand_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMAND_DB_D: ++ Format(instr, "amand_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMOR_DB_W: ++ Format(instr, "amor_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMOR_DB_D: ++ Format(instr, "amor_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMXOR_DB_W: ++ Format(instr, "amxor_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMXOR_DB_D: ++ Format(instr, "amxor_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_DB_W: ++ Format(instr, "ammax_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_DB_D: ++ Format(instr, "ammax_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_DB_W: ++ Format(instr, "ammin_db.w 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_DB_D: ++ Format(instr, "ammin_db.d 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_DB_WU: ++ Format(instr, "ammax_db.wu 'rd, 'rk, 'rj"); ++ break; ++ case AMMAX_DB_DU: ++ Format(instr, "ammax_db.du 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_DB_WU: ++ Format(instr, "ammin_db.wu 'rd, 'rk, 'rj"); ++ break; ++ case AMMIN_DB_DU: ++ Format(instr, "ammin_db.du 'rd, 'rk, 'rj"); ++ break; ++ case DBAR: ++ Format(instr, "dbar 'hint15"); ++ break; ++ case IBAR: ++ Format(instr, "ibar 'hint15"); ++ break; ++ case FSCALEB_S: ++ Format(instr, "fscaleb.s 'fd, 'fj, 'fk"); ++ break; ++ case FSCALEB_D: ++ Format(instr, "fscaleb.d 'fd, 'fj, 'fk"); ++ break; ++ case FCOPYSIGN_S: ++ Format(instr, "fcopysign.s 'fd, 'fj, 'fk"); ++ break; ++ case FCOPYSIGN_D: ++ Format(instr, "fcopysign.d 'fd, 'fj, 'fk"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ return kInstrSize; ++} ++ ++void Decoder::DecodeTypekOp22(Instruction* instr) { ++ switch (instr->Bits(31, 10) << 10) { ++ case CLZ_W: ++ Format(instr, "clz.w 'rd, 'rj"); ++ break; ++ case CTZ_W: ++ Format(instr, "ctz.w 'rd, 'rj"); ++ break; ++ case CLZ_D: ++ Format(instr, "clz.d 'rd, 'rj"); ++ break; ++ case CTZ_D: ++ Format(instr, "ctz.d 'rd, 'rj"); ++ break; ++ case REVB_2H: ++ Format(instr, "revb.2h 'rd, 'rj"); ++ break; ++ case REVB_4H: ++ Format(instr, "revb.4h 'rd, 'rj"); ++ break; ++ case REVB_2W: ++ Format(instr, "revb.2w 'rd, 'rj"); ++ break; ++ case REVB_D: ++ Format(instr, "revb.d 'rd, 'rj"); ++ break; ++ case REVH_2W: ++ Format(instr, "revh.2w 'rd, 'rj"); ++ break; ++ case REVH_D: ++ Format(instr, "revh.d 'rd, 'rj"); ++ break; ++ case BITREV_4B: ++ Format(instr, "bitrev.4b 'rd, 'rj"); ++ break; ++ case BITREV_8B: ++ Format(instr, "bitrev.8b 'rd, 'rj"); ++ break; ++ case BITREV_W: ++ Format(instr, "bitrev.w 'rd, 'rj"); ++ break; ++ case BITREV_D: ++ Format(instr, "bitrev.d 'rd, 'rj"); ++ break; ++ case EXT_W_B: ++ Format(instr, "ext.w.b 'rd, 'rj"); ++ break; ++ case EXT_W_H: ++ Format(instr, "ext.w.h 'rd, 'rj"); ++ break; ++ case FABS_S: ++ Format(instr, "fabs.s 'fd, 'fj"); ++ break; ++ case FABS_D: ++ Format(instr, "fabs.d 'fd, 'fj"); ++ break; ++ case FNEG_S: ++ Format(instr, "fneg.s 'fd, 'fj"); ++ break; ++ case FNEG_D: ++ Format(instr, "fneg.d 'fd, 'fj"); ++ break; ++ case FSQRT_S: ++ Format(instr, "fsqrt.s 'fd, 'fj"); ++ break; ++ case FSQRT_D: ++ Format(instr, "fsqrt.d 'fd, 'fj"); ++ break; ++ case FMOV_S: ++ Format(instr, "fmov.s 'fd, 'fj"); ++ break; ++ case FMOV_D: ++ Format(instr, "fmov.d 'fd, 'fj"); ++ break; ++ case MOVGR2FR_W: ++ Format(instr, "movgr2fr.w 'fd, 'rj"); ++ break; ++ case MOVGR2FR_D: ++ Format(instr, "movgr2fr.d 'fd, 'rj"); ++ break; ++ case MOVGR2FRH_W: ++ Format(instr, "movgr2frh.w 'fd, 'rj"); ++ break; ++ case MOVFR2GR_S: ++ Format(instr, "movfr2gr.s 'rd, 'fj"); ++ break; ++ case MOVFR2GR_D: ++ Format(instr, "movfr2gr.d 'rd, 'fj"); ++ break; ++ case MOVFRH2GR_S: ++ Format(instr, "movfrh2gr.s 'rd, 'fj"); ++ break; ++ case MOVGR2FCSR: ++ Format(instr, "movgr2fcsr fcsr, 'rj"); ++ break; ++ case MOVFCSR2GR: ++ Format(instr, "movfcsr2gr 'rd, fcsr"); ++ break; ++ case FCVT_S_D: ++ Format(instr, "fcvt.s.d 'fd, 'fj"); ++ break; ++ case FCVT_D_S: ++ Format(instr, "fcvt.d.s 'fd, 'fj"); ++ break; ++ case FTINTRM_W_S: ++ Format(instr, "ftintrm.w.s 'fd, 'fj"); ++ break; ++ case FTINTRM_W_D: ++ Format(instr, "ftintrm.w.d 'fd, 'fj"); ++ break; ++ case FTINTRM_L_S: ++ Format(instr, "ftintrm.l.s 'fd, 'fj"); ++ break; ++ case FTINTRM_L_D: ++ Format(instr, "ftintrm.l.d 'fd, 'fj"); ++ break; ++ case FTINTRP_W_S: ++ Format(instr, "ftintrp.w.s 'fd, 'fj"); ++ break; ++ case FTINTRP_W_D: ++ Format(instr, "ftintrp.w.d 'fd, 'fj"); ++ break; ++ case FTINTRP_L_S: ++ Format(instr, "ftintrp.l.s 'fd, 'fj"); ++ break; ++ case FTINTRP_L_D: ++ Format(instr, "ftintrp.l.d 'fd, 'fj"); ++ break; ++ case FTINTRZ_W_S: ++ Format(instr, "ftintrz.w.s 'fd, 'fj"); ++ break; ++ case FTINTRZ_W_D: ++ Format(instr, "ftintrz.w.d 'fd, 'fj"); ++ break; ++ case FTINTRZ_L_S: ++ Format(instr, "ftintrz.l.s 'fd, 'fj"); ++ break; ++ case FTINTRZ_L_D: ++ Format(instr, "ftintrz.l.d 'fd, 'fj"); ++ break; ++ case FTINTRNE_W_S: ++ Format(instr, "ftintrne.w.s 'fd, 'fj"); ++ break; ++ case FTINTRNE_W_D: ++ Format(instr, "ftintrne.w.d 'fd, 'fj"); ++ break; ++ case FTINTRNE_L_S: ++ Format(instr, "ftintrne.l.s 'fd, 'fj"); ++ break; ++ case FTINTRNE_L_D: ++ Format(instr, "ftintrne.l.d 'fd, 'fj"); ++ break; ++ case FTINT_W_S: ++ Format(instr, "ftint.w.s 'fd, 'fj"); ++ break; ++ case FTINT_W_D: ++ Format(instr, "ftint.w.d 'fd, 'fj"); ++ break; ++ case FTINT_L_S: ++ Format(instr, "ftint.l.s 'fd, 'fj"); ++ break; ++ case FTINT_L_D: ++ Format(instr, "ftint.l.d 'fd, 'fj"); ++ break; ++ case FFINT_S_W: ++ Format(instr, "ffint.s.w 'fd, 'fj"); ++ break; ++ case FFINT_S_L: ++ Format(instr, "ffint.s.l 'fd, 'fj"); ++ break; ++ case FFINT_D_W: ++ Format(instr, "ffint.d.w 'fd, 'fj"); ++ break; ++ case FFINT_D_L: ++ Format(instr, "ffint.d.l 'fd, 'fj"); ++ break; ++ case FRINT_S: ++ Format(instr, "frint.s 'fd, 'fj"); ++ break; ++ case FRINT_D: ++ Format(instr, "frint.d 'fd, 'fj"); ++ break; ++ case MOVFR2CF: ++ Format(instr, "movfr2cf fcc'cd, 'fj"); ++ break; ++ case MOVCF2FR: ++ Format(instr, "movcf2fr 'fd, fcc'cj"); ++ break; ++ case MOVGR2CF: ++ Format(instr, "movgr2cf fcc'cd, 'rj"); ++ break; ++ case MOVCF2GR: ++ Format(instr, "movcf2gr 'rd, fcc'cj"); ++ break; ++ case FRECIP_S: ++ Format(instr, "frecip.s 'fd, 'fj"); ++ break; ++ case FRECIP_D: ++ Format(instr, "frecip.d 'fd, 'fj"); ++ break; ++ case FRSQRT_S: ++ Format(instr, "frsqrt.s 'fd, 'fj"); ++ break; ++ case FRSQRT_D: ++ Format(instr, "frsqrt.d 'fd, 'fj"); ++ break; ++ case FCLASS_S: ++ Format(instr, "fclass.s 'fd, 'fj"); ++ break; ++ case FCLASS_D: ++ Format(instr, "fclass.d 'fd, 'fj"); ++ break; ++ case FLOGB_S: ++ Format(instr, "flogb.s 'fd, 'fj"); ++ break; ++ case FLOGB_D: ++ Format(instr, "flogb.d 'fd, 'fj"); ++ break; ++ case CLO_W: ++ Format(instr, "clo.w 'rd, 'rj"); ++ break; ++ case CTO_W: ++ Format(instr, "cto.w 'rd, 'rj"); ++ break; ++ case CLO_D: ++ Format(instr, "clo.d 'rd, 'rj"); ++ break; ++ case CTO_D: ++ Format(instr, "cto.d 'rd, 'rj"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++int Decoder::InstructionDecode(byte* instr_ptr) { ++ Instruction* instr = Instruction::At(instr_ptr); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", ++ instr->InstructionBits()); ++ switch (instr->InstructionType()) { ++ case Instruction::kOp6Type: { ++ DecodeTypekOp6(instr); ++ break; ++ } ++ case Instruction::kOp7Type: { ++ DecodeTypekOp7(instr); ++ break; ++ } ++ case Instruction::kOp8Type: { ++ DecodeTypekOp8(instr); ++ break; ++ } ++ case Instruction::kOp10Type: { ++ DecodeTypekOp10(instr); ++ break; ++ } ++ case Instruction::kOp12Type: { ++ DecodeTypekOp12(instr); ++ break; ++ } ++ case Instruction::kOp14Type: { ++ DecodeTypekOp14(instr); ++ break; ++ } ++ case Instruction::kOp17Type: { ++ return DecodeTypekOp17(instr); ++ } ++ case Instruction::kOp22Type: { ++ DecodeTypekOp22(instr); ++ break; ++ } ++ case Instruction::kUnsupported: { ++ Format(instr, "UNSUPPORTED"); ++ break; ++ } ++ default: { ++ Format(instr, "UNSUPPORTED"); ++ break; ++ } ++ } ++ return kInstrSize; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++//------------------------------------------------------------------------------ ++ ++namespace disasm { ++ ++const char* NameConverter::NameOfAddress(byte* addr) const { ++ v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast(addr)); ++ return tmp_buffer_.begin(); ++} ++ ++const char* NameConverter::NameOfConstant(byte* addr) const { ++ return NameOfAddress(addr); ++} ++ ++const char* NameConverter::NameOfCPURegister(int reg) const { ++ return v8::internal::Registers::Name(reg); ++} ++ ++const char* NameConverter::NameOfXMMRegister(int reg) const { ++ return v8::internal::FPURegisters::Name(reg); ++} ++ ++const char* NameConverter::NameOfByteCPURegister(int reg) const { ++ UNREACHABLE(); ++ return "nobytereg"; ++} ++ ++const char* NameConverter::NameInCode(byte* addr) const { ++ // The default name converter is called for unknown code. So we will not try ++ // to access any memory. ++ return ""; ++} ++ ++//------------------------------------------------------------------------------ ++ ++int Disassembler::InstructionDecode(v8::internal::Vector buffer, ++ byte* instruction) { ++ v8::internal::Decoder d(converter_, buffer); ++ return d.InstructionDecode(instruction); ++} ++ ++int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; } ++ ++void Disassembler::Disassemble(FILE* f, byte* begin, byte* end, ++ UnimplementedOpcodeAction unimplemented_action) { ++ NameConverter converter; ++ Disassembler d(converter, unimplemented_action); ++ for (byte* pc = begin; pc < end;) { ++ v8::internal::EmbeddedVector buffer; ++ buffer[0] = '\0'; ++ byte* prev_pc = pc; ++ pc += d.InstructionDecode(buffer, pc); ++ v8::internal::PrintF(f, "%p %08x %s\n", static_cast(prev_pc), ++ *reinterpret_cast(prev_pc), buffer.begin()); ++ } ++} ++ ++#undef STRING_STARTS_WITH ++ ++} // namespace disasm ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h +@@ -83,6 +83,7 @@ class PerfJitLogger : public CodeEventLo + static const uint32_t kElfMachARM = 40; + static const uint32_t kElfMachMIPS = 8; + static const uint32_t kElfMachMIPS64 = 8; ++ static const uint32_t kElfMachLA64 = 258; + static const uint32_t kElfMachARM64 = 183; + static const uint32_t kElfMachS390x = 22; + static const uint32_t kElfMachPPC64 = 21; +@@ -98,6 +99,8 @@ class PerfJitLogger : public CodeEventLo + return kElfMachMIPS; + #elif V8_TARGET_ARCH_MIPS64 + return kElfMachMIPS64; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ return kElfMachLA64; + #elif V8_TARGET_ARCH_ARM64 + return kElfMachARM64; + #elif V8_TARGET_ARCH_S390X +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h.rej +@@ -0,0 +1,19 @@ ++--- src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h +++++ src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h ++@@ -83,6 +83,7 @@ class PerfJitLogger : public CodeEventLogger { ++ static const uint32_t kElfMachARM = 40; ++ static const uint32_t kElfMachMIPS = 8; ++ static const uint32_t kElfMachMIPS64 = 8; +++ static const uint32_t kElfMachLA64 = 258; ++ static const uint32_t kElfMachARM64 = 183; ++ static const uint32_t kElfMachS390x = 22; ++ static const uint32_t kElfMachPPC64 = 21; ++@@ -98,6 +99,8 @@ class PerfJitLogger : public CodeEventLogger { ++ return kElfMachMIPS; ++ #elif V8_TARGET_ARCH_MIPS64 ++ return kElfMachMIPS64; +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ return kElfMachLA64; ++ #elif V8_TARGET_ARCH_ARM64 ++ return kElfMachARM64; ++ #elif V8_TARGET_ARCH_S390X +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/execution/frame-constants.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/frame-constants.h +@@ -354,6 +354,8 @@ inline static int FrameSlotToFPOffset(in + #include "src/execution/mips/frame-constants-mips.h" // NOLINT + #elif V8_TARGET_ARCH_MIPS64 + #include "src/execution/mips64/frame-constants-mips64.h" // NOLINT ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/execution/loongarch64/frame-constants-loongarch64.h" // NOLINT + #elif V8_TARGET_ARCH_S390 + #include "src/execution/s390/frame-constants-s390.h" // NOLINT + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/frame-constants.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/execution/frame-constants.h +++++ src/3rdparty/chromium/v8/src/execution/frame-constants.h ++@@ -354,6 +354,8 @@ inline static int FrameSlotToFPOffset(int slot) { ++ #include "src/execution/mips/frame-constants-mips.h" // NOLINT ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/execution/mips64/frame-constants-mips64.h" // NOLINT +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/execution/loongarch64/frame-constants-loongarch64.h" // NOLINT ++ #elif V8_TARGET_ARCH_S390 ++ #include "src/execution/s390/frame-constants-s390.h" // NOLINT ++ #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.cc +@@ -0,0 +1,32 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/execution/loongarch64/frame-constants-loongarch64.h" ++ ++#include "src/codegen/loongarch64/assembler-loongarch64-inl.h" ++#include "src/execution/frame-constants.h" ++#include "src/execution/frames.h" ++ ++namespace v8 { ++namespace internal { ++ ++Register JavaScriptFrame::fp_register() { return v8::internal::fp; } ++Register JavaScriptFrame::context_register() { return cp; } ++Register JavaScriptFrame::constant_pool_pointer_register() { UNREACHABLE(); } ++ ++int InterpreterFrameConstants::RegisterStackSlotCount(int register_count) { ++ return register_count; ++} ++ ++int BuiltinContinuationFrameConstants::PaddingSlotCount(int register_count) { ++ USE(register_count); ++ return 0; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/loongarch64/frame-constants-loongarch64.h +@@ -0,0 +1,77 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ ++#define V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ ++ ++#include "src/base/bits.h" ++#include "src/base/macros.h" ++#include "src/execution/frame-constants.h" ++ ++namespace v8 { ++namespace internal { ++ ++class EntryFrameConstants : public AllStatic { ++ public: ++ // This is the offset to where JSEntry pushes the current value of ++ // Isolate::c_entry_fp onto the stack. ++ static constexpr int kCallerFPOffset = -3 * kSystemPointerSize; ++}; ++ ++class WasmCompileLazyFrameConstants : public TypedFrameConstants { ++ public: ++ static constexpr int kNumberOfSavedGpParamRegs = 7; ++ static constexpr int kNumberOfSavedFpParamRegs = 7; ++ static constexpr int kNumberOfSavedAllParamRegs = 14; ++ ++ // FP-relative. ++ // See Generate_WasmCompileLazy in builtins-mips64.cc. ++ static constexpr int kWasmInstanceOffset = ++ TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs); ++ static constexpr int kFixedFrameSizeFromFp = ++ TypedFrameConstants::kFixedFrameSizeFromFp + ++ kNumberOfSavedGpParamRegs * kPointerSize + ++ kNumberOfSavedFpParamRegs * kDoubleSize; ++}; ++ ++// Frame constructed by the {WasmDebugBreak} builtin. ++// After pushing the frame type marker, the builtin pushes all Liftoff cache ++// registers (see liftoff-assembler-defs.h). ++class WasmDebugBreakFrameConstants : public TypedFrameConstants { ++ public: ++ // {a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, t3, t4, t5, t6, t7, t8} ++ static constexpr uint32_t kPushedGpRegs = 0b111111111111111110000; ++ // {f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26} ++ static constexpr uint32_t kPushedFpRegs = 0b101010101010101010101010101; ++ ++ static constexpr int kNumPushedGpRegisters = ++ base::bits::CountPopulation(kPushedGpRegs); ++ static constexpr int kNumPushedFpRegisters = ++ base::bits::CountPopulation(kPushedFpRegs); ++ ++ static constexpr int kLastPushedGpRegisterOffset = ++ -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; ++ static constexpr int kLastPushedFpRegisterOffset = ++ kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize; ++ ++ // Offsets are fp-relative. ++ static int GetPushedGpRegisterOffset(int reg_code) { ++ DCHECK_NE(0, kPushedGpRegs & (1 << reg_code)); ++ uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1); ++ return kLastPushedGpRegisterOffset + ++ base::bits::CountPopulation(lower_regs) * kSystemPointerSize; ++ } ++ ++ static int GetPushedFpRegisterOffset(int reg_code) { ++ DCHECK_NE(0, kPushedFpRegs & (1 << reg_code)); ++ uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1); ++ return kLastPushedFpRegisterOffset + ++ base::bits::CountPopulation(lower_regs) * kDoubleSize; ++ } ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_EXECUTION_LA64_FRAME_CONSTANTS_LOONGARCH64_H_ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.cc +@@ -0,0 +1,5564 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Only build the simulator if not compiling for real LA64 hardware. ++#if defined(USE_SIMULATOR) ++ ++#include "src/execution/loongarch64/simulator-loongarch64.h" ++ ++#include ++#include ++#include ++ ++#include ++ ++#include "src/base/bits.h" ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/la64/constants-la64.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/diagnostics/disasm.h" ++#include "src/heap/combined-heap.h" ++#include "src/runtime/runtime-utils.h" ++#include "src/utils/ostreams.h" ++#include "src/utils/vector.h" ++ ++namespace v8 { ++namespace internal { ++ ++DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor, ++ Simulator::GlobalMonitor::Get) ++ ++// #define PRINT_SIM_LOG ++ ++// Util functions. ++inline bool HaveSameSign(int64_t a, int64_t b) { return ((a ^ b) >= 0); } ++ ++uint32_t get_fcsr_condition_bit(uint32_t cc) { ++ if (cc == 0) { ++ return 23; ++ } else { ++ return 24 + cc; ++ } ++} ++ ++static int64_t MultiplyHighSigned(int64_t u, int64_t v) { ++ uint64_t u0, v0, w0; ++ int64_t u1, v1, w1, w2, t; ++ ++ u0 = u & 0xFFFFFFFFL; ++ u1 = u >> 32; ++ v0 = v & 0xFFFFFFFFL; ++ v1 = v >> 32; ++ ++ w0 = u0 * v0; ++ t = u1 * v0 + (w0 >> 32); ++ w1 = t & 0xFFFFFFFFL; ++ w2 = t >> 32; ++ w1 = u0 * v1 + w1; ++ ++ return u1 * v1 + w2 + (w1 >> 32); ++} ++ ++static uint64_t MultiplyHighUnsigned(uint64_t u, uint64_t v) { ++ uint64_t u0, v0, w0; ++ uint64_t u1, v1, w1, w2, t; ++ ++ u0 = u & 0xFFFFFFFFL; ++ u1 = u >> 32; ++ v0 = v & 0xFFFFFFFFL; ++ v1 = v >> 32; ++ ++ w0 = u0 * v0; ++ t = u1 * v0 + (w0 >> 32); ++ w1 = t & 0xFFFFFFFFL; ++ w2 = t >> 32; ++ w1 = u0 * v1 + w1; ++ ++ return u1 * v1 + w2 + (w1 >> 32); ++} ++ ++#ifdef PRINT_SIM_LOG ++inline void printf_instr(const char* _Format, ...) { ++ va_list varList; ++ va_start(varList, _Format); ++ vprintf(_Format, varList); ++ va_end(varList); ++} ++#else ++#define printf_instr(...) ++#endif ++ ++// This macro provides a platform independent use of sscanf. The reason for ++// SScanF not being implemented in a platform independent was through ++// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time ++// Library does not provide vsscanf. ++#define SScanF sscanf // NOLINT ++ ++// The La64Debugger class is used by the simulator while debugging simulated ++// code. ++class La64Debugger { ++ public: ++ explicit La64Debugger(Simulator* sim) : sim_(sim) {} ++ ++ void Stop(Instruction* instr); ++ void Debug(); ++ // Print all registers with a nice formatting. ++ void PrintAllRegs(); ++ void PrintAllRegsIncludingFPU(); ++ ++ private: ++ // We set the breakpoint code to 0xFFFF to easily recognize it. ++ static const Instr kBreakpointInstr = BREAK | 0xFFFF; ++ static const Instr kNopInstr = 0x0; ++ ++ Simulator* sim_; ++ ++ int64_t GetRegisterValue(int regnum); ++ int64_t GetFPURegisterValue(int regnum); ++ float GetFPURegisterValueFloat(int regnum); ++ double GetFPURegisterValueDouble(int regnum); ++ bool GetValue(const char* desc, int64_t* value); ++ ++ // Set or delete a breakpoint. Returns true if successful. ++ bool SetBreakpoint(Instruction* breakpc); ++ bool DeleteBreakpoint(Instruction* breakpc); ++ ++ // Undo and redo all breakpoints. This is needed to bracket disassembly and ++ // execution to skip past breakpoints when run from the debugger. ++ void UndoBreakpoints(); ++ void RedoBreakpoints(); ++}; ++ ++inline void UNSUPPORTED() { printf("Sim: Unsupported instruction.\n"); } ++ ++void La64Debugger::Stop(Instruction* instr) { ++ // Get the stop code. ++ uint32_t code = instr->Bits(25, 6); ++ PrintF("Simulator hit (%u)\n", code); ++ Debug(); ++} ++ ++int64_t La64Debugger::GetRegisterValue(int regnum) { ++ if (regnum == kNumSimuRegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_register(regnum); ++ } ++} ++ ++int64_t La64Debugger::GetFPURegisterValue(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register(regnum); ++ } ++} ++ ++float La64Debugger::GetFPURegisterValueFloat(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register_float(regnum); ++ } ++} ++ ++double La64Debugger::GetFPURegisterValueDouble(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register_double(regnum); ++ } ++} ++ ++bool La64Debugger::GetValue(const char* desc, int64_t* value) { ++ int regnum = Registers::Number(desc); ++ int fpuregnum = FPURegisters::Number(desc); ++ ++ if (regnum != kInvalidRegister) { ++ *value = GetRegisterValue(regnum); ++ return true; ++ } else if (fpuregnum != kInvalidFPURegister) { ++ *value = GetFPURegisterValue(fpuregnum); ++ return true; ++ } else if (strncmp(desc, "0x", 2) == 0) { ++ return SScanF(desc + 2, "%" SCNx64, reinterpret_cast(value)) == ++ 1; ++ } else { ++ return SScanF(desc, "%" SCNu64, reinterpret_cast(value)) == 1; ++ } ++ return false; ++} ++ ++bool La64Debugger::SetBreakpoint(Instruction* breakpc) { ++ // Check if a breakpoint can be set. If not return without any side-effects. ++ if (sim_->break_pc_ != nullptr) { ++ return false; ++ } ++ ++ // Set the breakpoint. ++ sim_->break_pc_ = breakpc; ++ sim_->break_instr_ = breakpc->InstructionBits(); ++ // Not setting the breakpoint instruction in the code itself. It will be set ++ // when the debugger shell continues. ++ return true; ++} ++ ++bool La64Debugger::DeleteBreakpoint(Instruction* breakpc) { ++ if (sim_->break_pc_ != nullptr) { ++ sim_->break_pc_->SetInstructionBits(sim_->break_instr_); ++ } ++ ++ sim_->break_pc_ = nullptr; ++ sim_->break_instr_ = 0; ++ return true; ++} ++ ++void La64Debugger::UndoBreakpoints() { ++ if (sim_->break_pc_ != nullptr) { ++ sim_->break_pc_->SetInstructionBits(sim_->break_instr_); ++ } ++} ++ ++void La64Debugger::RedoBreakpoints() { ++ if (sim_->break_pc_ != nullptr) { ++ sim_->break_pc_->SetInstructionBits(kBreakpointInstr); ++ } ++} ++ ++void La64Debugger::PrintAllRegs() { ++#define REG_INFO(n) Registers::Name(n), GetRegisterValue(n), GetRegisterValue(n) ++ ++ PrintF("\n"); ++ // at, v0, a0. ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 ++ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", ++ REG_INFO(1), REG_INFO(2), REG_INFO(4)); ++ // v1, a1. ++ PrintF("%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \n", ++ "", REG_INFO(3), REG_INFO(5)); ++ // a2. ++ PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "", ++ REG_INFO(6)); ++ // a3. ++ PrintF("%34s\t%34s\t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", "", "", ++ REG_INFO(7)); ++ PrintF("\n"); ++ // a4-t3, s0-s7 ++ for (int i = 0; i < 8; i++) { ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \n", ++ REG_INFO(8 + i), REG_INFO(16 + i)); ++ } ++ PrintF("\n"); ++ // t8, k0, LO. ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", ++ REG_INFO(24), REG_INFO(26), REG_INFO(32)); ++ // t9, k1, HI. ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", ++ REG_INFO(25), REG_INFO(27), REG_INFO(33)); ++ // sp, fp, gp. ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \t%3s: 0x%016" PRIx64 " %14" PRId64 " \n", ++ REG_INFO(29), REG_INFO(30), REG_INFO(28)); ++ // pc. ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \n", ++ REG_INFO(31), REG_INFO(34)); ++ ++#undef REG_INFO ++} ++ ++void La64Debugger::PrintAllRegsIncludingFPU() { ++#define FPU_REG_INFO(n) \ ++ FPURegisters::Name(n), GetFPURegisterValue(n), GetFPURegisterValueDouble(n) ++ ++ PrintAllRegs(); ++ ++ PrintF("\n\n"); ++ // f0, f1, f2, ... f31. ++ // TODO(plind): consider printing 2 columns for space efficiency. ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(0)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(1)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(2)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(3)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(4)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(5)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(6)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(7)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(8)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(9)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(10)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(11)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(12)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(13)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(14)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(15)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(16)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(17)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(18)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(19)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(20)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(21)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(22)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(23)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(24)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(25)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(26)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(27)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(28)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(29)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(30)); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", FPU_REG_INFO(31)); ++ ++#undef FPU_REG_INFO ++} ++ ++void La64Debugger::Debug() { ++ intptr_t last_pc = -1; ++ bool done = false; ++ ++#define COMMAND_SIZE 63 ++#define ARG_SIZE 255 ++ ++#define STR(a) #a ++#define XSTR(a) STR(a) ++ ++ char cmd[COMMAND_SIZE + 1]; ++ char arg1[ARG_SIZE + 1]; ++ char arg2[ARG_SIZE + 1]; ++ char* argv[3] = {cmd, arg1, arg2}; ++ ++ // Make sure to have a proper terminating character if reaching the limit. ++ cmd[COMMAND_SIZE] = 0; ++ arg1[ARG_SIZE] = 0; ++ arg2[ARG_SIZE] = 0; ++ ++ // Undo all set breakpoints while running in the debugger shell. This will ++ // make them invisible to all commands. ++ UndoBreakpoints(); ++ ++ while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) { ++ if (last_pc != sim_->get_pc()) { ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ dasm.InstructionDecode(buffer, reinterpret_cast(sim_->get_pc())); ++ PrintF(" 0x%016" PRIx64 " %s\n", sim_->get_pc(), buffer.begin()); ++ last_pc = sim_->get_pc(); ++ } ++ char* line = ReadLine("sim> "); ++ if (line == nullptr) { ++ break; ++ } else { ++ char* last_input = sim_->last_debugger_input(); ++ if (strcmp(line, "\n") == 0 && last_input != nullptr) { ++ line = last_input; ++ } else { ++ // Ownership is transferred to sim_; ++ sim_->set_last_debugger_input(line); ++ } ++ // Use sscanf to parse the individual parts of the command line. At the ++ // moment no command expects more than two parameters. ++ int argc = SScanF(line, ++ "%" XSTR(COMMAND_SIZE) "s " ++ "%" XSTR(ARG_SIZE) "s " ++ "%" XSTR(ARG_SIZE) "s", ++ cmd, arg1, arg2); ++ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { ++ Instruction* instr = reinterpret_cast(sim_->get_pc()); ++ if (!(instr->IsTrap()) || ++ instr->InstructionBits() == rtCallRedirInstr) { ++ sim_->InstructionDecode( ++ reinterpret_cast(sim_->get_pc())); ++ } else { ++ // Allow si to jump over generated breakpoints. ++ PrintF("/!\\ Jumping over generated breakpoint.\n"); ++ sim_->set_pc(sim_->get_pc() + kInstrSize); ++ } ++ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { ++ // Execute the one instruction we broke at with breakpoints disabled. ++ sim_->InstructionDecode(reinterpret_cast(sim_->get_pc())); ++ // Leave the debugger shell. ++ done = true; ++ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { ++ if (argc == 2) { ++ int64_t value; ++ double dvalue; ++ if (strcmp(arg1, "all") == 0) { ++ PrintAllRegs(); ++ } else if (strcmp(arg1, "allf") == 0) { ++ PrintAllRegsIncludingFPU(); ++ } else { ++ int regnum = Registers::Number(arg1); ++ int fpuregnum = FPURegisters::Number(arg1); ++ ++ if (regnum != kInvalidRegister) { ++ value = GetRegisterValue(regnum); ++ PrintF("%s: 0x%08" PRIx64 " %" PRId64 " \n", arg1, value, ++ value); ++ } else if (fpuregnum != kInvalidFPURegister) { ++ value = GetFPURegisterValue(fpuregnum); ++ dvalue = GetFPURegisterValueDouble(fpuregnum); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", ++ FPURegisters::Name(fpuregnum), value, dvalue); ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } ++ } else { ++ if (argc == 3) { ++ if (strcmp(arg2, "single") == 0) { ++ int64_t value; ++ float fvalue; ++ int fpuregnum = FPURegisters::Number(arg1); ++ ++ if (fpuregnum != kInvalidFPURegister) { ++ value = GetFPURegisterValue(fpuregnum); ++ value &= 0xFFFFFFFFUL; ++ fvalue = GetFPURegisterValueFloat(fpuregnum); ++ PrintF("%s: 0x%08" PRIx64 " %11.4e\n", arg1, value, fvalue); ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } else { ++ PrintF("print single\n"); ++ } ++ } else { ++ PrintF("print or print single\n"); ++ } ++ } ++ } else if ((strcmp(cmd, "po") == 0) || ++ (strcmp(cmd, "printobject") == 0)) { ++ if (argc == 2) { ++ int64_t value; ++ StdoutStream os; ++ if (GetValue(arg1, &value)) { ++ Object obj(value); ++ os << arg1 << ": \n"; ++#ifdef DEBUG ++ obj.Print(os); ++ os << "\n"; ++#else ++ os << Brief(obj) << "\n"; ++#endif ++ } else { ++ os << arg1 << " unrecognized\n"; ++ } ++ } else { ++ PrintF("printobject \n"); ++ } ++ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 || ++ strcmp(cmd, "dump") == 0) { ++ int64_t* cur = nullptr; ++ int64_t* end = nullptr; ++ int next_arg = 1; ++ ++ if (strcmp(cmd, "stack") == 0) { ++ cur = reinterpret_cast(sim_->get_register(Simulator::sp)); ++ } else { // Command "mem". ++ int64_t value; ++ if (!GetValue(arg1, &value)) { ++ PrintF("%s unrecognized\n", arg1); ++ continue; ++ } ++ cur = reinterpret_cast(value); ++ next_arg++; ++ } ++ ++ int64_t words; ++ if (argc == next_arg) { ++ words = 10; ++ } else { ++ if (!GetValue(argv[next_arg], &words)) { ++ words = 10; ++ } ++ } ++ end = cur + words; ++ ++ bool skip_obj_print = (strcmp(cmd, "dump") == 0); ++ while (cur < end) { ++ PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ", ++ reinterpret_cast(cur), *cur, *cur); ++ Object obj(*cur); ++ Heap* current_heap = sim_->isolate_->heap(); ++ if (!skip_obj_print) { ++ if (obj.IsSmi() || ++ IsValidHeapObject(current_heap, HeapObject::cast(obj))) { ++ PrintF(" ("); ++ if (obj.IsSmi()) { ++ PrintF("smi %d", Smi::ToInt(obj)); ++ } else { ++ obj.ShortPrint(); ++ } ++ PrintF(")"); ++ } ++ } ++ PrintF("\n"); ++ cur++; ++ } ++ ++ } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0) || ++ (strcmp(cmd, "di") == 0)) { ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ ++ byte* cur = nullptr; ++ byte* end = nullptr; ++ ++ if (argc == 1) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ end = cur + (10 * kInstrSize); ++ } else if (argc == 2) { ++ int regnum = Registers::Number(arg1); ++ if (regnum != kInvalidRegister || strncmp(arg1, "0x", 2) == 0) { ++ // The argument is an address or a register name. ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(value); ++ // Disassemble 10 instructions at . ++ end = cur + (10 * kInstrSize); ++ } ++ } else { ++ // The argument is the number of instructions. ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ // Disassemble instructions. ++ end = cur + (value * kInstrSize); ++ } ++ } ++ } else { ++ int64_t value1; ++ int64_t value2; ++ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { ++ cur = reinterpret_cast(value1); ++ end = cur + (value2 * kInstrSize); ++ } ++ } ++ ++ while (cur < end) { ++ dasm.InstructionDecode(buffer, cur); ++ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), ++ buffer.begin()); ++ cur += kInstrSize; ++ } ++ } else if (strcmp(cmd, "gdb") == 0) { ++ PrintF("relinquishing control to gdb\n"); ++ v8::base::OS::DebugBreak(); ++ PrintF("regaining control from gdb\n"); ++ } else if (strcmp(cmd, "break") == 0) { ++ if (argc == 2) { ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ if (!SetBreakpoint(reinterpret_cast(value))) { ++ PrintF("setting breakpoint failed\n"); ++ } ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } else { ++ PrintF("break
\n"); ++ } ++ } else if (strcmp(cmd, "del") == 0) { ++ if (!DeleteBreakpoint(nullptr)) { ++ PrintF("deleting breakpoint failed\n"); ++ } ++ } else if (strcmp(cmd, "flags") == 0) { ++ PrintF("No flags on LA64 !\n"); ++ } else if (strcmp(cmd, "stop") == 0) { ++ int64_t value; ++ intptr_t stop_pc = sim_->get_pc() - 2 * kInstrSize; ++ Instruction* stop_instr = reinterpret_cast(stop_pc); ++ Instruction* msg_address = ++ reinterpret_cast(stop_pc + kInstrSize); ++ if ((argc == 2) && (strcmp(arg1, "unstop") == 0)) { ++ // Remove the current stop. ++ if (sim_->IsStopInstruction(stop_instr)) { ++ stop_instr->SetInstructionBits(kNopInstr); ++ msg_address->SetInstructionBits(kNopInstr); ++ } else { ++ PrintF("Not at debugger stop.\n"); ++ } ++ } else if (argc == 3) { ++ // Print information about all/the specified breakpoint(s). ++ if (strcmp(arg1, "info") == 0) { ++ if (strcmp(arg2, "all") == 0) { ++ PrintF("Stop information:\n"); ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->PrintStopInfo(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->PrintStopInfo(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } else if (strcmp(arg1, "enable") == 0) { ++ // Enable all/the specified breakpoint(s). ++ if (strcmp(arg2, "all") == 0) { ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->EnableStop(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->EnableStop(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } else if (strcmp(arg1, "disable") == 0) { ++ // Disable all/the specified breakpoint(s). ++ if (strcmp(arg2, "all") == 0) { ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->DisableStop(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->DisableStop(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } ++ } else { ++ PrintF("Wrong usage. Use help command for more information.\n"); ++ } ++ } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) { ++ // Print registers and disassemble. ++ PrintAllRegs(); ++ PrintF("\n"); ++ ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ ++ byte* cur = nullptr; ++ byte* end = nullptr; ++ ++ if (argc == 1) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ end = cur + (10 * kInstrSize); ++ } else if (argc == 2) { ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(value); ++ // no length parameter passed, assume 10 instructions ++ end = cur + (10 * kInstrSize); ++ } ++ } else { ++ int64_t value1; ++ int64_t value2; ++ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { ++ cur = reinterpret_cast(value1); ++ end = cur + (value2 * kInstrSize); ++ } ++ } ++ ++ while (cur < end) { ++ dasm.InstructionDecode(buffer, cur); ++ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), ++ buffer.begin()); ++ cur += kInstrSize; ++ } ++ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { ++ PrintF("cont\n"); ++ PrintF(" continue execution (alias 'c')\n"); ++ PrintF("stepi\n"); ++ PrintF(" step one instruction (alias 'si')\n"); ++ PrintF("print \n"); ++ PrintF(" print register content (alias 'p')\n"); ++ PrintF(" use register name 'all' to print all registers\n"); ++ PrintF("printobject \n"); ++ PrintF(" print an object from a register (alias 'po')\n"); ++ PrintF("stack []\n"); ++ PrintF(" dump stack content, default dump 10 words)\n"); ++ PrintF("mem
[]\n"); ++ PrintF(" dump memory content, default dump 10 words)\n"); ++ PrintF("dump []\n"); ++ PrintF( ++ " dump memory content without pretty printing JS objects, default " ++ "dump 10 words)\n"); ++ PrintF("flags\n"); ++ PrintF(" print flags\n"); ++ PrintF("disasm []\n"); ++ PrintF("disasm [
]\n"); ++ PrintF("disasm [[
] ]\n"); ++ PrintF(" disassemble code, default is 10 instructions\n"); ++ PrintF(" from pc (alias 'di')\n"); ++ PrintF("gdb\n"); ++ PrintF(" enter gdb\n"); ++ PrintF("break
\n"); ++ PrintF(" set a break point on the address\n"); ++ PrintF("del\n"); ++ PrintF(" delete the breakpoint\n"); ++ PrintF("stop feature:\n"); ++ PrintF(" Description:\n"); ++ PrintF(" Stops are debug instructions inserted by\n"); ++ PrintF(" the Assembler::stop() function.\n"); ++ PrintF(" When hitting a stop, the Simulator will\n"); ++ PrintF(" stop and give control to the Debugger.\n"); ++ PrintF(" All stop codes are watched:\n"); ++ PrintF(" - They can be enabled / disabled: the Simulator\n"); ++ PrintF(" will / won't stop when hitting them.\n"); ++ PrintF(" - The Simulator keeps track of how many times they \n"); ++ PrintF(" are met. (See the info command.) Going over a\n"); ++ PrintF(" disabled stop still increases its counter. \n"); ++ PrintF(" Commands:\n"); ++ PrintF(" stop info all/ : print infos about number \n"); ++ PrintF(" or all stop(s).\n"); ++ PrintF(" stop enable/disable all/ : enables / disables\n"); ++ PrintF(" all or number stop(s)\n"); ++ PrintF(" stop unstop\n"); ++ PrintF(" ignore the stop instruction at the current location\n"); ++ PrintF(" from now on\n"); ++ } else { ++ PrintF("Unknown command: %s\n", cmd); ++ } ++ } ++ } ++ ++ // Add all the breakpoints back to stop execution and enter the debugger ++ // shell when hit. ++ RedoBreakpoints(); ++ ++#undef COMMAND_SIZE ++#undef ARG_SIZE ++ ++#undef STR ++#undef XSTR ++} ++ ++bool Simulator::ICacheMatch(void* one, void* two) { ++ DCHECK_EQ(reinterpret_cast(one) & CachePage::kPageMask, 0); ++ DCHECK_EQ(reinterpret_cast(two) & CachePage::kPageMask, 0); ++ return one == two; ++} ++ ++static uint32_t ICacheHash(void* key) { ++ return static_cast(reinterpret_cast(key)) >> 2; ++} ++ ++static bool AllOnOnePage(uintptr_t start, size_t size) { ++ intptr_t start_page = (start & ~CachePage::kPageMask); ++ intptr_t end_page = ((start + size) & ~CachePage::kPageMask); ++ return start_page == end_page; ++} ++ ++void Simulator::set_last_debugger_input(char* input) { ++ DeleteArray(last_debugger_input_); ++ last_debugger_input_ = input; ++} ++ ++void Simulator::SetRedirectInstruction(Instruction* instruction) { ++ instruction->SetInstructionBits(rtCallRedirInstr); ++} ++ ++void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, ++ void* start_addr, size_t size) { ++ int64_t start = reinterpret_cast(start_addr); ++ int64_t intra_line = (start & CachePage::kLineMask); ++ start -= intra_line; ++ size += intra_line; ++ size = ((size - 1) | CachePage::kLineMask) + 1; ++ int offset = (start & CachePage::kPageMask); ++ while (!AllOnOnePage(start, size - 1)) { ++ int bytes_to_flush = CachePage::kPageSize - offset; ++ FlushOnePage(i_cache, start, bytes_to_flush); ++ start += bytes_to_flush; ++ size -= bytes_to_flush; ++ DCHECK_EQ((int64_t)0, start & CachePage::kPageMask); ++ offset = 0; ++ } ++ if (size != 0) { ++ FlushOnePage(i_cache, start, size); ++ } ++} ++ ++CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, ++ void* page) { ++ base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); ++ if (entry->value == nullptr) { ++ CachePage* new_page = new CachePage(); ++ entry->value = new_page; ++ } ++ return reinterpret_cast(entry->value); ++} ++ ++// Flush from start up to and not including start + size. ++void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, ++ intptr_t start, size_t size) { ++ DCHECK_LE(size, CachePage::kPageSize); ++ DCHECK(AllOnOnePage(start, size - 1)); ++ DCHECK_EQ(start & CachePage::kLineMask, 0); ++ DCHECK_EQ(size & CachePage::kLineMask, 0); ++ void* page = reinterpret_cast(start & (~CachePage::kPageMask)); ++ int offset = (start & CachePage::kPageMask); ++ CachePage* cache_page = GetCachePage(i_cache, page); ++ char* valid_bytemap = cache_page->ValidityByte(offset); ++ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); ++} ++ ++void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, ++ Instruction* instr) { ++ int64_t address = reinterpret_cast(instr); ++ void* page = reinterpret_cast(address & (~CachePage::kPageMask)); ++ void* line = reinterpret_cast(address & (~CachePage::kLineMask)); ++ int offset = (address & CachePage::kPageMask); ++ CachePage* cache_page = GetCachePage(i_cache, page); ++ char* cache_valid_byte = cache_page->ValidityByte(offset); ++ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); ++ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); ++ if (cache_hit) { ++ // Check that the data in memory matches the contents of the I-cache. ++ CHECK_EQ(0, memcmp(reinterpret_cast(instr), ++ cache_page->CachedData(offset), kInstrSize)); ++ } else { ++ // Cache miss. Load memory into the cache. ++ memcpy(cached_line, line, CachePage::kLineLength); ++ *cache_valid_byte = CachePage::LINE_VALID; ++ } ++} ++ ++Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { ++ // Set up simulator support first. Some of this information is needed to ++ // setup the architecture state. ++ stack_size_ = FLAG_sim_stack_size * KB; ++ stack_ = reinterpret_cast(malloc(stack_size_)); ++ pc_modified_ = false; ++ icount_ = 0; ++ break_count_ = 0; ++ break_pc_ = nullptr; ++ break_instr_ = 0; ++ ++ // Set up architecture state. ++ // All registers are initialized to zero to start with. ++ for (int i = 0; i < kNumSimuRegisters; i++) { ++ registers_[i] = 0; ++ } ++ for (int i = 0; i < kNumFPURegisters; i++) { ++ FPUregisters_[i] = 0; ++ } ++ for (int i = 0; i < kNumCFRegisters; i++) { ++ CFregisters_[i] = 0; ++ } ++ ++ FCSR_ = 0; ++ ++ // The sp is initialized to point to the bottom (high address) of the ++ // allocated stack area. To be safe in potential stack underflows we leave ++ // some buffer below. ++ registers_[sp] = reinterpret_cast(stack_) + stack_size_ - 64; ++ // The ra and pc are initialized to a known bad value that will cause an ++ // access violation if the simulator ever tries to execute it. ++ registers_[pc] = bad_ra; ++ registers_[ra] = bad_ra; ++ ++ last_debugger_input_ = nullptr; ++} ++ ++Simulator::~Simulator() { ++ GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_); ++ free(stack_); ++} ++ ++// Get the active Simulator for the current thread. ++Simulator* Simulator::current(Isolate* isolate) { ++ v8::internal::Isolate::PerIsolateThreadData* isolate_data = ++ isolate->FindOrAllocatePerThreadDataForThisThread(); ++ DCHECK_NOT_NULL(isolate_data); ++ ++ Simulator* sim = isolate_data->simulator(); ++ if (sim == nullptr) { ++ // TODO(146): delete the simulator object when a thread/isolate goes away. ++ sim = new Simulator(isolate); ++ isolate_data->set_simulator(sim); ++ } ++ return sim; ++} ++ ++// Sets the register in the architecture state. It will also deal with updating ++// Simulator internal state for special registers such as PC. ++void Simulator::set_register(int reg, int64_t value) { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ if (reg == pc) { ++ pc_modified_ = true; ++ } ++ ++ // Zero register always holds 0. ++ registers_[reg] = (reg == 0) ? 0 : value; ++} ++ ++void Simulator::set_dw_register(int reg, const int* dbl) { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ registers_[reg] = dbl[1]; ++ registers_[reg] = registers_[reg] << 32; ++ registers_[reg] += dbl[0]; ++} ++ ++void Simulator::set_fpu_register(int fpureg, int64_t value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ FPUregisters_[fpureg] = value; ++} ++ ++void Simulator::set_fpu_register_word(int fpureg, int32_t value) { ++ // Set ONLY lower 32-bits, leaving upper bits untouched. ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ int32_t* pword; ++ pword = reinterpret_cast(&FPUregisters_[fpureg]); ++ ++ *pword = value; ++} ++ ++void Simulator::set_fpu_register_hi_word(int fpureg, int32_t value) { ++ // Set ONLY upper 32-bits, leaving lower bits untouched. ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ int32_t* phiword; ++ phiword = (reinterpret_cast(&FPUregisters_[fpureg])) + 1; ++ ++ *phiword = value; ++} ++ ++void Simulator::set_fpu_register_float(int fpureg, float value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ *bit_cast(&FPUregisters_[fpureg]) = value; ++} ++ ++void Simulator::set_fpu_register_double(int fpureg, double value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ *bit_cast(&FPUregisters_[fpureg]) = value; ++} ++ ++void Simulator::set_cf_register(int cfreg, bool value) { ++ DCHECK((cfreg >= 0) && (cfreg < kNumCFRegisters)); ++ CFregisters_[cfreg] = value; ++} ++ ++// Get the register from the architecture state. This function does handle ++// the special case of accessing the PC register. ++int64_t Simulator::get_register(int reg) const { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ if (reg == 0) ++ return 0; ++ else ++ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); ++} ++ ++double Simulator::get_double_from_register_pair(int reg) { ++ // TODO(plind): bad ABI stuff, refactor or remove. ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ ++ double dm_val = 0.0; ++ // Read the bits from the unsigned integer register_[] array ++ // into the double precision floating point value and return it. ++ char buffer[sizeof(registers_[0])]; ++ memcpy(buffer, ®isters_[reg], sizeof(registers_[0])); ++ memcpy(&dm_val, buffer, sizeof(registers_[0])); ++ return (dm_val); ++} ++ ++int64_t Simulator::get_fpu_register(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return FPUregisters_[fpureg]; ++} ++ ++int32_t Simulator::get_fpu_register_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); ++} ++ ++int32_t Simulator::get_fpu_register_signed_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); ++} ++ ++int32_t Simulator::get_fpu_register_hi_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast((FPUregisters_[fpureg] >> 32) & 0xFFFFFFFF); ++} ++ ++float Simulator::get_fpu_register_float(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return *bit_cast(const_cast(&FPUregisters_[fpureg])); ++} ++ ++double Simulator::get_fpu_register_double(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return *bit_cast(&FPUregisters_[fpureg]); ++} ++ ++bool Simulator::get_cf_register(int cfreg) const { ++ DCHECK((cfreg >= 0) && (cfreg < kNumCFRegisters)); ++ return CFregisters_[cfreg]; ++} ++ ++// Runtime FP routines take up to two double arguments and zero ++// or one integer arguments. All are constructed here, ++// from a0-a3 or fa0 and fa1 (n64). ++void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { ++ const int fparg2 = f1; ++ *x = get_fpu_register_double(f0); ++ *y = get_fpu_register_double(fparg2); ++ *z = static_cast(get_register(a2)); ++} ++ ++// The return value is either in v0/v1 or f0. ++void Simulator::SetFpResult(const double& result) { ++ set_fpu_register_double(0, result); ++} ++ ++// Helper functions for setting and testing the FCSR register's bits. ++void Simulator::set_fcsr_bit(uint32_t cc, bool value) { ++ if (value) { ++ FCSR_ |= (1 << cc); ++ } else { ++ FCSR_ &= ~(1 << cc); ++ } ++} ++ ++bool Simulator::test_fcsr_bit(uint32_t cc) { return FCSR_ & (1 << cc); } ++ ++void Simulator::set_fcsr_rounding_mode(FPURoundingMode mode) { ++ FCSR_ |= mode & kFPURoundingModeMask; ++} ++ ++unsigned int Simulator::get_fcsr_rounding_mode() { ++ return FCSR_ & kFPURoundingModeMask; ++} ++ ++// Sets the rounding error codes in FCSR based on the result of the rounding. ++// Returns true if the operation was invalid. ++bool Simulator::set_fcsr_round_error(double original, double rounded) { ++ bool ret = false; ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ ++ if (!std::isfinite(original) || !std::isfinite(rounded)) { ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ if (original != rounded) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ ++ if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) { ++ set_fcsr_bit(kFCSRUnderflowFlagBit, true); ++ ret = true; ++ } ++ ++ if (rounded > max_int32 || rounded < min_int32) { ++ set_fcsr_bit(kFCSROverflowFlagBit, true); ++ // The reference is not really clear but it seems this is required: ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ return ret; ++} ++ ++// Sets the rounding error codes in FCSR based on the result of the rounding. ++// Returns true if the operation was invalid. ++bool Simulator::set_fcsr_round64_error(double original, double rounded) { ++ bool ret = false; ++ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, ++ // loading the most accurate representation into max_int64, which is 2^63. ++ double max_int64 = std::numeric_limits::max(); ++ double min_int64 = std::numeric_limits::min(); ++ ++ if (!std::isfinite(original) || !std::isfinite(rounded)) { ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ if (original != rounded) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ ++ if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) { ++ set_fcsr_bit(kFCSRUnderflowFlagBit, true); ++ ret = true; ++ } ++ ++ if (rounded >= max_int64 || rounded < min_int64) { ++ set_fcsr_bit(kFCSROverflowFlagBit, true); ++ // The reference is not really clear but it seems this is required: ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ return ret; ++} ++ ++// Sets the rounding error codes in FCSR based on the result of the rounding. ++// Returns true if the operation was invalid. ++bool Simulator::set_fcsr_round_error(float original, float rounded) { ++ bool ret = false; ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ ++ if (!std::isfinite(original) || !std::isfinite(rounded)) { ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ if (original != rounded) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ ++ if (rounded < FLT_MIN && rounded > -FLT_MIN && rounded != 0) { ++ set_fcsr_bit(kFCSRUnderflowFlagBit, true); ++ ret = true; ++ } ++ ++ if (rounded > max_int32 || rounded < min_int32) { ++ set_fcsr_bit(kFCSROverflowFlagBit, true); ++ // The reference is not really clear but it seems this is required: ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ return ret; ++} ++ ++void Simulator::set_fpu_register_word_invalid_result(float original, ++ float rounded) { ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register_word(fd_reg(), 0); ++ } else if (rounded > max_int32) { ++ set_fpu_register_word(fd_reg(), kFPUInvalidResult); ++ } else if (rounded < min_int32) { ++ set_fpu_register_word(fd_reg(), kFPUInvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::set_fpu_register_invalid_result(float original, float rounded) { ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register(fd_reg(), 0); ++ } else if (rounded > max_int32) { ++ set_fpu_register(fd_reg(), kFPUInvalidResult); ++ } else if (rounded < min_int32) { ++ set_fpu_register(fd_reg(), kFPUInvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::set_fpu_register_invalid_result64(float original, ++ float rounded) { ++ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, ++ // loading the most accurate representation into max_int64, which is 2^63. ++ double max_int64 = std::numeric_limits::max(); ++ double min_int64 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register(fd_reg(), 0); ++ } else if (rounded >= max_int64) { ++ set_fpu_register(fd_reg(), kFPU64InvalidResult); ++ } else if (rounded < min_int64) { ++ set_fpu_register(fd_reg(), kFPU64InvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::set_fpu_register_word_invalid_result(double original, ++ double rounded) { ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register_word(fd_reg(), 0); ++ } else if (rounded > max_int32) { ++ set_fpu_register_word(fd_reg(), kFPUInvalidResult); ++ } else if (rounded < min_int32) { ++ set_fpu_register_word(fd_reg(), kFPUInvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::set_fpu_register_invalid_result(double original, ++ double rounded) { ++ double max_int32 = std::numeric_limits::max(); ++ double min_int32 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register(fd_reg(), 0); ++ } else if (rounded > max_int32) { ++ set_fpu_register(fd_reg(), kFPUInvalidResult); ++ } else if (rounded < min_int32) { ++ set_fpu_register(fd_reg(), kFPUInvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::set_fpu_register_invalid_result64(double original, ++ double rounded) { ++ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, ++ // loading the most accurate representation into max_int64, which is 2^63. ++ double max_int64 = std::numeric_limits::max(); ++ double min_int64 = std::numeric_limits::min(); ++ if (std::isnan(original)) { ++ set_fpu_register(fd_reg(), 0); ++ } else if (rounded >= max_int64) { ++ set_fpu_register(fd_reg(), kFPU64InvalidResult); ++ } else if (rounded < min_int64) { ++ set_fpu_register(fd_reg(), kFPU64InvalidResultNegative); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++// Sets the rounding error codes in FCSR based on the result of the rounding. ++// Returns true if the operation was invalid. ++bool Simulator::set_fcsr_round64_error(float original, float rounded) { ++ bool ret = false; ++ // The value of INT64_MAX (2^63-1) can't be represented as double exactly, ++ // loading the most accurate representation into max_int64, which is 2^63. ++ double max_int64 = std::numeric_limits::max(); ++ double min_int64 = std::numeric_limits::min(); ++ ++ if (!std::isfinite(original) || !std::isfinite(rounded)) { ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ if (original != rounded) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ ++ if (rounded < FLT_MIN && rounded > -FLT_MIN && rounded != 0) { ++ set_fcsr_bit(kFCSRUnderflowFlagBit, true); ++ ret = true; ++ } ++ ++ if (rounded >= max_int64 || rounded < min_int64) { ++ set_fcsr_bit(kFCSROverflowFlagBit, true); ++ // The reference is not really clear but it seems this is required: ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ ret = true; ++ } ++ ++ return ret; ++} ++ ++// For ftint instructions only ++void Simulator::round_according_to_fcsr(double toRound, double* rounded, ++ int32_t* rounded_int) { ++ // 0 RN (round to nearest): Round a result to the nearest ++ // representable value; if the result is exactly halfway between ++ // two representable values, round to zero. ++ ++ // 1 RZ (round toward zero): Round a result to the closest ++ // representable value whose absolute value is less than or ++ // equal to the infinitely accurate result. ++ ++ // 2 RP (round up, or toward +infinity): Round a result to the ++ // next representable value up. ++ ++ // 3 RN (round down, or toward −infinity): Round a result to ++ // the next representable value down. ++ // switch ((FCSR_ >> 8) & 3) { ++ switch (FCSR_ & kFPURoundingModeMask) { ++ case kRoundToNearest: ++ *rounded = std::floor(toRound + 0.5); ++ *rounded_int = static_cast(*rounded); ++ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ *rounded_int -= 1; ++ *rounded -= 1.; ++ } ++ break; ++ case kRoundToZero: ++ *rounded = trunc(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToPlusInf: ++ *rounded = std::ceil(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToMinusInf: ++ *rounded = std::floor(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ } ++} ++ ++void Simulator::round64_according_to_fcsr(double toRound, double* rounded, ++ int64_t* rounded_int) { ++ // 0 RN (round to nearest): Round a result to the nearest ++ // representable value; if the result is exactly halfway between ++ // two representable values, round to zero. ++ ++ // 1 RZ (round toward zero): Round a result to the closest ++ // representable value whose absolute value is less than or. ++ // equal to the infinitely accurate result. ++ ++ // 2 RP (round up, or toward +infinity): Round a result to the ++ // next representable value up. ++ ++ // 3 RN (round down, or toward −infinity): Round a result to ++ // the next representable value down. ++ switch (FCSR_ & kFPURoundingModeMask) { ++ case kRoundToNearest: ++ *rounded = std::floor(toRound + 0.5); ++ *rounded_int = static_cast(*rounded); ++ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ *rounded_int -= 1; ++ *rounded -= 1.; ++ } ++ break; ++ case kRoundToZero: ++ *rounded = std::trunc(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToPlusInf: ++ *rounded = std::ceil(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToMinusInf: ++ *rounded = std::floor(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ } ++} ++ ++void Simulator::round_according_to_fcsr(float toRound, float* rounded, ++ int32_t* rounded_int) { ++ // 0 RN (round to nearest): Round a result to the nearest ++ // representable value; if the result is exactly halfway between ++ // two representable values, round to zero. ++ ++ // 1 RZ (round toward zero): Round a result to the closest ++ // representable value whose absolute value is less than or ++ // equal to the infinitely accurate result. ++ ++ // 2 RP (round up, or toward +infinity): Round a result to the ++ // next representable value up. ++ ++ // 3 RN (round down, or toward −infinity): Round a result to ++ // the next representable value down. ++ switch (FCSR_ & kFPURoundingModeMask) { ++ case kRoundToNearest: ++ *rounded = std::floor(toRound + 0.5); ++ *rounded_int = static_cast(*rounded); ++ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ *rounded_int -= 1; ++ *rounded -= 1.f; ++ } ++ break; ++ case kRoundToZero: ++ *rounded = std::trunc(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToPlusInf: ++ *rounded = std::ceil(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToMinusInf: ++ *rounded = std::floor(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ } ++} ++ ++void Simulator::round64_according_to_fcsr(float toRound, float* rounded, ++ int64_t* rounded_int) { ++ // 0 RN (round to nearest): Round a result to the nearest ++ // representable value; if the result is exactly halfway between ++ // two representable values, round to zero. ++ ++ // 1 RZ (round toward zero): Round a result to the closest ++ // representable value whose absolute value is less than or. ++ // equal to the infinitely accurate result. ++ ++ // 2 RP (round up, or toward +infinity): Round a result to the ++ // next representable value up. ++ ++ // 3 RN (round down, or toward −infinity): Round a result to ++ // the next representable value down. ++ switch (FCSR_ & kFPURoundingModeMask) { ++ case kRoundToNearest: ++ *rounded = std::floor(toRound + 0.5); ++ *rounded_int = static_cast(*rounded); ++ if ((*rounded_int & 1) != 0 && *rounded_int - toRound == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ *rounded_int -= 1; ++ *rounded -= 1.f; ++ } ++ break; ++ case kRoundToZero: ++ *rounded = trunc(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToPlusInf: ++ *rounded = std::ceil(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ case kRoundToMinusInf: ++ *rounded = std::floor(toRound); ++ *rounded_int = static_cast(*rounded); ++ break; ++ } ++} ++ ++// Raw access to the PC register. ++void Simulator::set_pc(int64_t value) { ++ pc_modified_ = true; ++ registers_[pc] = value; ++} ++ ++bool Simulator::has_bad_pc() const { ++ return ((registers_[pc] == bad_ra) || (registers_[pc] == end_sim_pc)); ++} ++ ++// Raw access to the PC register without the special adjustment when reading. ++int64_t Simulator::get_pc() const { return registers_[pc]; } ++ ++// TODO(plind): refactor this messy debug code when we do unaligned access. ++void Simulator::DieOrDebug() { ++ if ((1)) { // Flag for this was removed. ++ La64Debugger dbg(this); ++ dbg.Debug(); ++ } else { ++ base::OS::Abort(); ++ } ++} ++ ++void Simulator::TraceRegWr(int64_t value, TraceType t) { ++ if (::v8::internal::FLAG_trace_sim) { ++ union { ++ int64_t fmt_int64; ++ int32_t fmt_int32[2]; ++ float fmt_float[2]; ++ double fmt_double; ++ } v; ++ v.fmt_int64 = value; ++ ++ switch (t) { ++ case WORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 ++ " uint32:%" PRIu32, ++ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0]); ++ break; ++ case DWORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 ++ " uint64:%" PRIu64, ++ value, icount_, value, value); ++ break; ++ case FLOAT: ++ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e", ++ v.fmt_int64, icount_, v.fmt_float[0]); ++ break; ++ case DOUBLE: ++ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") dbl:%e", ++ v.fmt_int64, icount_, v.fmt_double); ++ break; ++ case FLOAT_DOUBLE: ++ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e dbl:%e", ++ v.fmt_int64, icount_, v.fmt_float[0], v.fmt_double); ++ break; ++ case WORD_DWORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 ++ " uint32:%" PRIu32 " int64:%" PRId64 " uint64:%" PRIu64, ++ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0], ++ v.fmt_int64, v.fmt_int64); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++// TODO(plind): consider making icount_ printing a flag option. ++void Simulator::TraceMemRd(int64_t addr, int64_t value, TraceType t) { ++ if (::v8::internal::FLAG_trace_sim) { ++ union { ++ int64_t fmt_int64; ++ int32_t fmt_int32[2]; ++ float fmt_float[2]; ++ double fmt_double; ++ } v; ++ v.fmt_int64 = value; ++ ++ switch (t) { ++ case WORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 ++ ") int32:%" PRId32 " uint32:%" PRIu32, ++ v.fmt_int64, addr, icount_, v.fmt_int32[0], v.fmt_int32[0]); ++ break; ++ case DWORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 ++ ") int64:%" PRId64 " uint64:%" PRIu64, ++ value, addr, icount_, value, value); ++ break; ++ case FLOAT: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 ++ ") flt:%e", ++ v.fmt_int64, addr, icount_, v.fmt_float[0]); ++ break; ++ case DOUBLE: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 ++ ") dbl:%e", ++ v.fmt_int64, addr, icount_, v.fmt_double); ++ break; ++ case FLOAT_DOUBLE: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " <-- [%016" PRIx64 "] (%" PRId64 ++ ") flt:%e dbl:%e", ++ v.fmt_int64, addr, icount_, v.fmt_float[0], v.fmt_double); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++void Simulator::TraceMemWr(int64_t addr, int64_t value, TraceType t) { ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (t) { ++ case BYTE: ++ SNPrintF(trace_buf_, ++ " %02" PRIx8 " --> [%016" PRIx64 "] (%" PRId64 ++ ")", ++ static_cast(value), addr, icount_); ++ break; ++ case HALF: ++ SNPrintF(trace_buf_, ++ " %04" PRIx16 " --> [%016" PRIx64 "] (%" PRId64 ++ ")", ++ static_cast(value), addr, icount_); ++ break; ++ case WORD: ++ SNPrintF(trace_buf_, ++ " %08" PRIx32 " --> [%016" PRIx64 "] (%" PRId64 ")", ++ static_cast(value), addr, icount_); ++ break; ++ case DWORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " --> [%016" PRIx64 "] (%" PRId64 " )", ++ value, addr, icount_); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++template ++void Simulator::TraceMemRd(int64_t addr, T value) { ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (sizeof(T)) { ++ case 1: ++ SNPrintF(trace_buf_, ++ "%08" PRIx8 " <-- [%08" PRIx64 "] (%" PRIu64 ++ ") int8:%" PRId8 " uint8:%" PRIu8, ++ static_cast(value), addr, icount_, ++ static_cast(value), static_cast(value)); ++ break; ++ case 2: ++ SNPrintF(trace_buf_, ++ "%08" PRIx16 " <-- [%08" PRIx64 "] (%" PRIu64 ++ ") int16:%" PRId16 " uint16:%" PRIu16, ++ static_cast(value), addr, icount_, ++ static_cast(value), static_cast(value)); ++ break; ++ case 4: ++ SNPrintF(trace_buf_, ++ "%08" PRIx32 " <-- [%08" PRIx64 "] (%" PRIu64 ++ ") int32:%" PRId32 " uint32:%" PRIu32, ++ static_cast(value), addr, icount_, ++ static_cast(value), static_cast(value)); ++ break; ++ case 8: ++ SNPrintF(trace_buf_, ++ "%08" PRIx64 " <-- [%08" PRIx64 "] (%" PRIu64 ++ ") int64:%" PRId64 " uint64:%" PRIu64, ++ static_cast(value), addr, icount_, ++ static_cast(value), static_cast(value)); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++template ++void Simulator::TraceMemWr(int64_t addr, T value) { ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (sizeof(T)) { ++ case 1: ++ SNPrintF(trace_buf_, ++ " %02" PRIx8 " --> [%08" PRIx64 "] (%" PRIu64 ")", ++ static_cast(value), addr, icount_); ++ break; ++ case 2: ++ SNPrintF(trace_buf_, ++ " %04" PRIx16 " --> [%08" PRIx64 "] (%" PRIu64 ")", ++ static_cast(value), addr, icount_); ++ break; ++ case 4: ++ SNPrintF(trace_buf_, ++ "%08" PRIx32 " --> [%08" PRIx64 "] (%" PRIu64 ")", ++ static_cast(value), addr, icount_); ++ break; ++ case 8: ++ SNPrintF(trace_buf_, ++ "%16" PRIx64 " --> [%08" PRIx64 "] (%" PRIu64 ")", ++ static_cast(value), addr, icount_); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++// TODO(plind): sign-extend and zero-extend not implmented properly ++// on all the ReadXX functions, I don't think re-interpret cast does it. ++int32_t Simulator::ReadW(int64_t addr, Instruction* instr, TraceType t) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ /* if ((addr & 0x3) == 0)*/ { ++ local_monitor_.NotifyLoad(); ++ int32_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr), t); ++ return *ptr; ++ } ++ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, ++ // reinterpret_cast(instr)); ++ // DieOrDebug(); ++ // return 0; ++} ++ ++uint32_t Simulator::ReadWU(int64_t addr, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ // if ((addr & 0x3) == 0) { ++ local_monitor_.NotifyLoad(); ++ uint32_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr), WORD); ++ return *ptr; ++ // } ++ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, ++ // reinterpret_cast(instr)); ++ // DieOrDebug(); ++ // return 0; ++} ++ ++void Simulator::WriteW(int64_t addr, int32_t value, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ /*if ((addr & 0x3) == 0)*/ { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, WORD); ++ int* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ return; ++ } ++ // PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, ++ // reinterpret_cast(instr)); ++ // DieOrDebug(); ++} ++ ++void Simulator::WriteConditionalW(int64_t addr, int32_t value, ++ Instruction* instr, int32_t rk_reg) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ if ((addr & 0x3) == 0) { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) && ++ GlobalMonitor::Get()->NotifyStoreConditional_Locked( ++ addr, &global_monitor_thread_)) { ++ local_monitor_.NotifyStore(); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, WORD); ++ int* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ set_register(rk_reg, 1); ++ } else { ++ set_register(rk_reg, 0); ++ } ++ return; ++ } ++ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, ++ reinterpret_cast(instr)); ++ DieOrDebug(); ++} ++ ++int64_t Simulator::Read2W(int64_t addr, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ /* if ((addr & kPointerAlignmentMask) == 0)*/ { ++ local_monitor_.NotifyLoad(); ++ int64_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, *ptr); ++ return *ptr; ++ } ++ // PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, ++ // reinterpret_cast(instr)); ++ // DieOrDebug(); ++ // return 0; ++} ++ ++void Simulator::Write2W(int64_t addr, int64_t value, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ "\n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ /*if ((addr & kPointerAlignmentMask) == 0)*/ { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, DWORD); ++ int64_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ return; ++ } ++ // PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, ++ // reinterpret_cast(instr)); ++ // DieOrDebug(); ++} ++ ++void Simulator::WriteConditional2W(int64_t addr, int64_t value, ++ Instruction* instr, int32_t rk_reg) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ "\n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ if ((addr & kPointerAlignmentMask) == 0) { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ if (local_monitor_.NotifyStoreConditional(addr, ++ TransactionSize::DoubleWord) && ++ GlobalMonitor::Get()->NotifyStoreConditional_Locked( ++ addr, &global_monitor_thread_)) { ++ local_monitor_.NotifyStore(); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, DWORD); ++ int64_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ set_register(rk_reg, 1); ++ } else { ++ set_register(rk_reg, 0); ++ } ++ return; ++ } ++ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, ++ reinterpret_cast(instr)); ++ DieOrDebug(); ++} ++ ++double Simulator::ReadD(int64_t addr, Instruction* instr) { ++ /*if ((addr & kDoubleAlignmentMask) == 0)*/ { ++ local_monitor_.NotifyLoad(); ++ double* ptr = reinterpret_cast(addr); ++ return *ptr; ++ } ++ // PrintF("Unaligned (double) read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR ++ // "\n", ++ // addr, reinterpret_cast(instr)); ++ // base::OS::Abort(); ++ // return 0; ++} ++ ++void Simulator::WriteD(int64_t addr, double value, Instruction* instr) { ++ /*if ((addr & kDoubleAlignmentMask) == 0)*/ { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ double* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ return; ++ } ++ // PrintF("Unaligned (double) write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR ++ // "\n", ++ // addr, reinterpret_cast(instr)); ++ // DieOrDebug(); ++} ++ ++uint16_t Simulator::ReadHU(int64_t addr, Instruction* instr) { ++ // if ((addr & 1) == 0) { ++ local_monitor_.NotifyLoad(); ++ uint16_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr)); ++ return *ptr; ++ // } ++ // PrintF("Unaligned unsigned halfword read at 0x%08" PRIx64 ++ // " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, reinterpret_cast(instr)); ++ // DieOrDebug(); ++ // return 0; ++} ++ ++int16_t Simulator::ReadH(int64_t addr, Instruction* instr) { ++ // if ((addr & 1) == 0) { ++ local_monitor_.NotifyLoad(); ++ int16_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr)); ++ return *ptr; ++ // } ++ // PrintF("Unaligned signed halfword read at 0x%08" PRIx64 ++ // " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, reinterpret_cast(instr)); ++ // DieOrDebug(); ++ // return 0; ++} ++ ++void Simulator::WriteH(int64_t addr, uint16_t value, Instruction* instr) { ++ // if ((addr & 1) == 0) { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, HALF); ++ uint16_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ return; ++ // } ++ // PrintF("Unaligned unsigned halfword write at 0x%08" PRIx64 ++ // " , pc=0x%08" V8PRIxPTR "\n", ++ // addr, reinterpret_cast(instr)); ++ // DieOrDebug(); ++} ++ ++void Simulator::WriteH(int64_t addr, int16_t value, Instruction* instr) { ++ // if ((addr & 1) == 0) { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, HALF); ++ int16_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ return; ++ // } ++ // PrintF("Unaligned halfword write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR ++ // "\n", ++ // addr, reinterpret_cast(instr)); ++ // DieOrDebug(); ++} ++ ++uint32_t Simulator::ReadBU(int64_t addr) { ++ local_monitor_.NotifyLoad(); ++ uint8_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr)); ++ return *ptr & 0xFF; ++} ++ ++int32_t Simulator::ReadB(int64_t addr) { ++ local_monitor_.NotifyLoad(); ++ int8_t* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, static_cast(*ptr)); ++ return *ptr; ++} ++ ++void Simulator::WriteB(int64_t addr, uint8_t value) { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, BYTE); ++ uint8_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++} ++ ++void Simulator::WriteB(int64_t addr, int8_t value) { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ TraceMemWr(addr, value, BYTE); ++ int8_t* ptr = reinterpret_cast(addr); ++ *ptr = value; ++} ++ ++template ++T Simulator::ReadMem(int64_t addr, Instruction* instr) { ++ int alignment_mask = (1 << sizeof(T)) - 1; ++ if ((addr & alignment_mask) == 0) { ++ local_monitor_.NotifyLoad(); ++ T* ptr = reinterpret_cast(addr); ++ TraceMemRd(addr, *ptr); ++ return *ptr; ++ } ++ PrintF("Unaligned read of type sizeof(%ld) at 0x%08lx, pc=0x%08" V8PRIxPTR ++ "\n", ++ sizeof(T), addr, reinterpret_cast(instr)); ++ base::OS::Abort(); ++ return 0; ++} ++ ++template ++void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) { ++ int alignment_mask = (1 << sizeof(T)) - 1; ++ if ((addr & alignment_mask) == 0) { ++ local_monitor_.NotifyStore(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ T* ptr = reinterpret_cast(addr); ++ *ptr = value; ++ TraceMemWr(addr, value); ++ return; ++ } ++ PrintF("Unaligned write of type sizeof(%ld) at 0x%08lx, pc=0x%08" V8PRIxPTR ++ "\n", ++ sizeof(T), addr, reinterpret_cast(instr)); ++ base::OS::Abort(); ++} ++ ++// Returns the limit of the stack area to enable checking for stack overflows. ++uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { ++ // The simulator uses a separate JS stack. If we have exhausted the C stack, ++ // we also drop down the JS limit to reflect the exhaustion on the JS stack. ++ if (GetCurrentStackPosition() < c_limit) { ++ return reinterpret_cast(get_sp()); ++ } ++ ++ // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes ++ // to prevent overrunning the stack when pushing values. ++ return reinterpret_cast(stack_) + 1024; ++} ++ ++// Unsupported instructions use Format to print an error and stop execution. ++void Simulator::Format(Instruction* instr, const char* format) { ++ PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR " : %s\n", ++ reinterpret_cast(instr), format); ++ UNIMPLEMENTED(); ++} ++ ++// Calls into the V8 runtime are based on this very simple interface. ++// Note: To be able to return two values from some calls the code in runtime.cc ++// uses the ObjectPair which is essentially two 32-bit values stuffed into a ++// 64-bit value. With the code below we assume that all runtime calls return ++// 64 bits of result. If they don't, the v1 result register contains a bogus ++// value, which is fine because it is caller-saved. ++ ++using SimulatorRuntimeCall = ObjectPair (*)(int64_t arg0, int64_t arg1, ++ int64_t arg2, int64_t arg3, ++ int64_t arg4, int64_t arg5, ++ int64_t arg6, int64_t arg7, ++ int64_t arg8, int64_t arg9); ++ ++// These prototypes handle the four types of FP calls. ++using SimulatorRuntimeCompareCall = int64_t (*)(double darg0, double darg1); ++using SimulatorRuntimeFPFPCall = double (*)(double darg0, double darg1); ++using SimulatorRuntimeFPCall = double (*)(double darg0); ++using SimulatorRuntimeFPIntCall = double (*)(double darg0, int32_t arg0); ++ ++// This signature supports direct call in to API function native callback ++// (refer to InvocationCallback in v8.h). ++using SimulatorRuntimeDirectApiCall = void (*)(int64_t arg0); ++using SimulatorRuntimeProfilingApiCall = void (*)(int64_t arg0, void* arg1); ++ ++// This signature supports direct call to accessor getter callback. ++using SimulatorRuntimeDirectGetterCall = void (*)(int64_t arg0, int64_t arg1); ++using SimulatorRuntimeProfilingGetterCall = void (*)(int64_t arg0, int64_t arg1, ++ void* arg2); ++ ++// Software interrupt instructions are used by the simulator to call into the ++// C-based V8 runtime. They are also used for debugging with simulator. ++void Simulator::SoftwareInterrupt() { ++ int32_t opcode_hi15 = instr_.Bits(31, 17); ++ CHECK_EQ(opcode_hi15, 0x15); ++ uint32_t code = instr_.Bits(14, 0); ++ // We first check if we met a call_rt_redirected. ++ if (instr_.InstructionBits() == rtCallRedirInstr) { ++ Redirection* redirection = Redirection::FromInstruction(instr_.instr()); ++ ++ int64_t* stack_pointer = reinterpret_cast(get_register(sp)); ++ ++ int64_t arg0 = get_register(a0); ++ int64_t arg1 = get_register(a1); ++ int64_t arg2 = get_register(a2); ++ int64_t arg3 = get_register(a3); ++ int64_t arg4 = get_register(a4); ++ int64_t arg5 = get_register(a5); ++ int64_t arg6 = get_register(a6); ++ int64_t arg7 = get_register(a7); ++ int64_t arg8 = stack_pointer[0]; ++ int64_t arg9 = stack_pointer[1]; ++ STATIC_ASSERT(kMaxCParameters == 10); ++ ++ bool fp_call = ++ (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); ++ ++ { ++ // With the hard floating point calling convention, double ++ // arguments are passed in FPU registers. Fetch the arguments ++ // from there and call the builtin using soft floating point ++ // convention. ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_FP_FP_CALL: ++ case ExternalReference::BUILTIN_COMPARE_CALL: ++ arg0 = get_fpu_register(f0); ++ arg1 = get_fpu_register(f1); ++ arg2 = get_fpu_register(f2); ++ arg3 = get_fpu_register(f3); ++ break; ++ case ExternalReference::BUILTIN_FP_CALL: ++ arg0 = get_fpu_register(f0); ++ arg1 = get_fpu_register(f1); ++ break; ++ case ExternalReference::BUILTIN_FP_INT_CALL: ++ arg0 = get_fpu_register(f0); ++ arg1 = get_fpu_register(f1); ++ arg2 = get_register(a2); ++ break; ++ default: ++ break; ++ } ++ } ++ ++ // This is dodgy but it works because the C entry stubs are never moved. ++ // See comment in codegen-arm.cc and bug 1242173. ++ int64_t saved_ra = get_register(ra); ++ ++ intptr_t external = ++ reinterpret_cast(redirection->external_function()); ++ ++ // Based on CpuFeatures::IsSupported(FPU), La64 will use either hardware ++ // FPU, or gcc soft-float routines. Hardware FPU is simulated in this ++ // simulator. Soft-float has additional abstraction of ExternalReference, ++ // to support serialization. ++ if (fp_call) { ++ double dval0, dval1; // one or two double parameters ++ int32_t ival; // zero or one integer parameters ++ int64_t iresult = 0; // integer return value ++ double dresult = 0; // double return value ++ GetFpArgs(&dval0, &dval1, &ival); ++ SimulatorRuntimeCall generic_target = ++ reinterpret_cast(external); ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_FP_FP_CALL: ++ case ExternalReference::BUILTIN_COMPARE_CALL: ++ PrintF("Call to host function at %p with args %f, %f", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0, dval1); ++ break; ++ case ExternalReference::BUILTIN_FP_CALL: ++ PrintF("Call to host function at %p with arg %f", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0); ++ break; ++ case ExternalReference::BUILTIN_FP_INT_CALL: ++ PrintF("Call to host function at %p with args %f, %d", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0, ival); ++ break; ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ } ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_COMPARE_CALL: { ++ SimulatorRuntimeCompareCall target = ++ reinterpret_cast(external); ++ iresult = target(dval0, dval1); ++ set_register(v0, static_cast(iresult)); ++ // set_register(v1, static_cast(iresult >> 32)); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_FP_CALL: { ++ SimulatorRuntimeFPFPCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0, dval1); ++ SetFpResult(dresult); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_CALL: { ++ SimulatorRuntimeFPCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0); ++ SetFpResult(dresult); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_INT_CALL: { ++ SimulatorRuntimeFPIntCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0, ival); ++ SetFpResult(dresult); ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_COMPARE_CALL: ++ PrintF("Returned %08x\n", static_cast(iresult)); ++ break; ++ case ExternalReference::BUILTIN_FP_FP_CALL: ++ case ExternalReference::BUILTIN_FP_CALL: ++ case ExternalReference::BUILTIN_FP_INT_CALL: ++ PrintF("Returned %f\n", dresult); ++ break; ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ } ++ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " \n", ++ reinterpret_cast(external), arg0); ++ } ++ SimulatorRuntimeDirectApiCall target = ++ reinterpret_cast(external); ++ target(arg0); ++ } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " \n", ++ reinterpret_cast(external), arg0, arg1); ++ } ++ SimulatorRuntimeProfilingApiCall target = ++ reinterpret_cast(external); ++ target(arg0, Redirection::ReverseRedirection(arg1)); ++ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " \n", ++ reinterpret_cast(external), arg0, arg1); ++ } ++ SimulatorRuntimeDirectGetterCall target = ++ reinterpret_cast(external); ++ target(arg0, arg1); ++ } else if (redirection->type() == ++ ExternalReference::PROFILING_GETTER_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " %08" PRIx64 " \n", ++ reinterpret_cast(external), arg0, arg1, arg2); ++ } ++ SimulatorRuntimeProfilingGetterCall target = ++ reinterpret_cast(external); ++ target(arg0, arg1, Redirection::ReverseRedirection(arg2)); ++ } else { ++ DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || ++ redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); ++ SimulatorRuntimeCall target = ++ reinterpret_cast(external); ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF( ++ "Call to host function at %p " ++ "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 ++ " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 ++ " , %08" PRIx64 " , %08" PRIx64 " \n", ++ reinterpret_cast(FUNCTION_ADDR(target)), arg0, arg1, arg2, ++ arg3, arg4, arg5, arg6, arg7, arg8, arg9); ++ } ++ ObjectPair result = ++ target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); ++ set_register(v0, (int64_t)(result.x)); ++ set_register(v1, (int64_t)(result.y)); ++ } ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(v1), ++ get_register(v0)); ++ } ++ set_register(ra, saved_ra); ++ set_pc(get_register(ra)); ++ ++ } else if (code <= kMaxStopCode) { ++ if (IsWatchpoint(code)) { ++ PrintWatchpoint(code); ++ } else { ++ IncreaseStopCounter(code); ++ HandleStop(code, instr_.instr()); ++ } ++ } else { ++ // All remaining break_ codes, and all traps are handled here. ++ La64Debugger dbg(this); ++ dbg.Debug(); ++ } ++} ++ ++// Stop helper functions. ++bool Simulator::IsWatchpoint(uint64_t code) { ++ return (code <= kMaxWatchpointCode); ++} ++ ++void Simulator::PrintWatchpoint(uint64_t code) { ++ La64Debugger dbg(this); ++ ++break_count_; ++ PrintF("\n---- break %" PRId64 " marker: %3d (instr count: %8" PRId64 ++ " ) ----------" ++ "----------------------------------", ++ code, break_count_, icount_); ++ dbg.PrintAllRegs(); // Print registers and continue running. ++} ++ ++void Simulator::HandleStop(uint64_t code, Instruction* instr) { ++ // Stop if it is enabled, otherwise go on jumping over the stop ++ // and the message address. ++ if (IsEnabledStop(code)) { ++ La64Debugger dbg(this); ++ dbg.Stop(instr); ++ } ++} ++ ++bool Simulator::IsStopInstruction(Instruction* instr) { ++ int32_t opcode_hi15 = instr->Bits(31, 17); ++ uint32_t code = static_cast(instr->Bits(14, 0)); ++ return (opcode_hi15 == 0x15) && code > kMaxWatchpointCode && ++ code <= kMaxStopCode; ++} ++ ++bool Simulator::IsEnabledStop(uint64_t code) { ++ DCHECK_LE(code, kMaxStopCode); ++ DCHECK_GT(code, kMaxWatchpointCode); ++ return !(watched_stops_[code].count & kStopDisabledBit); ++} ++ ++void Simulator::EnableStop(uint64_t code) { ++ if (!IsEnabledStop(code)) { ++ watched_stops_[code].count &= ~kStopDisabledBit; ++ } ++} ++ ++void Simulator::DisableStop(uint64_t code) { ++ if (IsEnabledStop(code)) { ++ watched_stops_[code].count |= kStopDisabledBit; ++ } ++} ++ ++void Simulator::IncreaseStopCounter(uint64_t code) { ++ DCHECK_LE(code, kMaxStopCode); ++ if ((watched_stops_[code].count & ~(1 << 31)) == 0x7FFFFFFF) { ++ PrintF("Stop counter for code %" PRId64 ++ " has overflowed.\n" ++ "Enabling this code and reseting the counter to 0.\n", ++ code); ++ watched_stops_[code].count = 0; ++ EnableStop(code); ++ } else { ++ watched_stops_[code].count++; ++ } ++} ++ ++// Print a stop status. ++void Simulator::PrintStopInfo(uint64_t code) { ++ if (code <= kMaxWatchpointCode) { ++ PrintF("That is a watchpoint, not a stop.\n"); ++ return; ++ } else if (code > kMaxStopCode) { ++ PrintF("Code too large, only %u stops can be used\n", kMaxStopCode + 1); ++ return; ++ } ++ const char* state = IsEnabledStop(code) ? "Enabled" : "Disabled"; ++ int32_t count = watched_stops_[code].count & ~kStopDisabledBit; ++ // Don't print the state of unused breakpoints. ++ if (count != 0) { ++ if (watched_stops_[code].desc) { ++ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i, \t%s\n", ++ code, code, state, count, watched_stops_[code].desc); ++ } else { ++ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i\n", code, ++ code, state, count); ++ } ++ } ++} ++ ++void Simulator::SignalException(Exception e) { ++ FATAL("Error: Exception %i raised.", static_cast(e)); ++} ++ ++template ++static T FPAbs(T a); ++ ++template <> ++double FPAbs(double a) { ++ return fabs(a); ++} ++ ++template <> ++float FPAbs(float a) { ++ return fabsf(a); ++} ++ ++template ++static bool FPUProcessNaNsAndZeros(T a, T b, MaxMinKind kind, T* result) { ++ if (std::isnan(a) && std::isnan(b)) { ++ *result = a; ++ } else if (std::isnan(a)) { ++ *result = b; ++ } else if (std::isnan(b)) { ++ *result = a; ++ } else if (b == a) { ++ // Handle -0.0 == 0.0 case. ++ // std::signbit() returns int 0 or 1 so subtracting MaxMinKind::kMax ++ // negates the result. ++ *result = std::signbit(b) - static_cast(kind) ? b : a; ++ } else { ++ return false; ++ } ++ return true; ++} ++ ++template ++static T FPUMin(T a, T b) { ++ T result; ++ if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { ++ return result; ++ } else { ++ return b < a ? b : a; ++ } ++} ++ ++template ++static T FPUMax(T a, T b) { ++ T result; ++ if (FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMax, &result)) { ++ return result; ++ } else { ++ return b > a ? b : a; ++ } ++} ++ ++template ++static T FPUMinA(T a, T b) { ++ T result; ++ if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { ++ if (FPAbs(a) < FPAbs(b)) { ++ result = a; ++ } else if (FPAbs(b) < FPAbs(a)) { ++ result = b; ++ } else { ++ result = a < b ? a : b; ++ } ++ } ++ return result; ++} ++ ++template ++static T FPUMaxA(T a, T b) { ++ T result; ++ if (!FPUProcessNaNsAndZeros(a, b, MaxMinKind::kMin, &result)) { ++ if (FPAbs(a) > FPAbs(b)) { ++ result = a; ++ } else if (FPAbs(b) > FPAbs(a)) { ++ result = b; ++ } else { ++ result = a > b ? a : b; ++ } ++ } ++ return result; ++} ++ ++enum class KeepSign : bool { no = false, yes }; ++ ++template ::value, ++ int>::type = 0> ++T FPUCanonalizeNaNArg(T result, T arg, KeepSign keepSign = KeepSign::no) { ++ DCHECK(std::isnan(arg)); ++ T qNaN = std::numeric_limits::quiet_NaN(); ++ if (keepSign == KeepSign::yes) { ++ return std::copysign(qNaN, result); ++ } ++ return qNaN; ++} ++ ++template ++T FPUCanonalizeNaNArgs(T result, KeepSign keepSign, T first) { ++ if (std::isnan(first)) { ++ return FPUCanonalizeNaNArg(result, first, keepSign); ++ } ++ return result; ++} ++ ++template ++T FPUCanonalizeNaNArgs(T result, KeepSign keepSign, T first, Args... args) { ++ if (std::isnan(first)) { ++ return FPUCanonalizeNaNArg(result, first, keepSign); ++ } ++ return FPUCanonalizeNaNArgs(result, keepSign, args...); ++} ++ ++template ++T FPUCanonalizeOperation(Func f, T first, Args... args) { ++ return FPUCanonalizeOperation(f, KeepSign::no, first, args...); ++} ++ ++template ++T FPUCanonalizeOperation(Func f, KeepSign keepSign, T first, Args... args) { ++ T result = f(first, args...); ++ if (std::isnan(result)) { ++ result = FPUCanonalizeNaNArgs(result, keepSign, first, args...); ++ } ++ return result; ++} ++ ++// Handle execution based on instruction types. ++void Simulator::DecodeTypeOp6() { ++ int64_t alu_out; ++ // Next pc. ++ int64_t next_pc = bad_ra; ++ ++ // Branch instructions common part. ++ auto BranchAndLinkHelper = [this, &next_pc]() { ++ int64_t current_pc = get_pc(); ++ set_register(ra, current_pc + kInstrSize); ++ int32_t offs26_low16 = ++ static_cast(instr_.Bits(25, 10) << 16) >> 16; ++ int32_t offs26_high10 = static_cast(instr_.Bits(9, 0) << 22) >> 6; ++ int32_t offs26 = offs26_low16 | offs26_high10; ++ next_pc = current_pc + (offs26 << 2); ++ printf_instr("Offs26: %08x\n", offs26); ++ set_pc(next_pc); ++ }; ++ ++ auto BranchOff16Helper = [this, &next_pc](bool do_branch) { ++ int64_t current_pc = get_pc(); ++ int32_t offs16 = static_cast(instr_.Bits(25, 10) << 16) >> 16; ++ printf_instr("Offs16: %08x\n", offs16); ++ int32_t offs = do_branch ? (offs16 << 2) : kInstrSize; ++ next_pc = current_pc + offs; ++ set_pc(next_pc); ++ }; ++ ++ auto BranchOff21Helper = [this, &next_pc](bool do_branch) { ++ int64_t current_pc = get_pc(); ++ int32_t offs21_low16 = ++ static_cast(instr_.Bits(25, 10) << 16) >> 16; ++ int32_t offs21_high5 = static_cast(instr_.Bits(4, 0) << 27) >> 11; ++ int32_t offs = offs21_low16 | offs21_high5; ++ printf_instr("Offs21: %08x\n", offs); ++ offs = do_branch ? (offs << 2) : kInstrSize; ++ next_pc = current_pc + offs; ++ set_pc(next_pc); ++ }; ++ ++ auto BranchOff26Helper = [this, &next_pc]() { ++ int64_t current_pc = get_pc(); ++ int32_t offs26_low16 = ++ static_cast(instr_.Bits(25, 10) << 16) >> 16; ++ int32_t offs26_high10 = static_cast(instr_.Bits(9, 0) << 22) >> 6; ++ int32_t offs26 = offs26_low16 | offs26_high10; ++ next_pc = current_pc + (offs26 << 2); ++ printf_instr("Offs26: %08x\n", offs26); ++ set_pc(next_pc); ++ }; ++ ++ auto JumpOff16Helper = [this, &next_pc]() { ++ int32_t offs16 = static_cast(instr_.Bits(25, 10) << 16) >> 16; ++ printf_instr("JIRL\t %s: %016lx, %s: %016lx, offs16: %x\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), offs16); ++ set_register(rd_reg(), get_pc() + kInstrSize); ++ next_pc = rj() + (offs16 << 2); ++ set_pc(next_pc); ++ }; ++ ++ switch (instr_.Bits(31, 26) << 26) { ++ case ADDU16I_D: { ++ printf_instr("ADDU16I_D\t %s: %016lx, %s: %016lx, si16: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si16()); ++ int32_t si16_upper = static_cast(si16()) << 16; ++ alu_out = static_cast(si16_upper) + rj(); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BEQZ: ++ printf_instr("BEQZ\t %s: %016lx, ", Registers::Name(rj_reg()), rj()); ++ BranchOff21Helper(rj() == 0); ++ break; ++ case BNEZ: ++ printf_instr("BNEZ\t %s: %016lx, ", Registers::Name(rj_reg()), rj()); ++ BranchOff21Helper(rj() != 0); ++ break; ++ case BCZ: { ++ if (instr_.Bits(9, 8) == 0b00) { ++ // BCEQZ ++ printf_instr("BCEQZ\t fcc%d: %s, ", cj_reg(), cj() ? "True" : "False"); ++ BranchOff21Helper(cj() == false); ++ } else if (instr_.Bits(9, 8) == 0b01) { ++ // BCNEZ ++ printf_instr("BCNEZ\t fcc%d: %s, ", cj_reg(), cj() ? "True" : "False"); ++ BranchOff21Helper(cj() == true); ++ } else { ++ UNREACHABLE(); ++ } ++ break; ++ } ++ case JIRL: ++ JumpOff16Helper(); ++ break; ++ case B: ++ printf_instr("B\t "); ++ BranchOff26Helper(); ++ break; ++ case BL: ++ printf_instr("BL\t "); ++ BranchAndLinkHelper(); ++ break; ++ case BEQ: ++ printf_instr("BEQ\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj() == rd()); ++ break; ++ case BNE: ++ printf_instr("BNE\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj() != rd()); ++ break; ++ case BLT: ++ printf_instr("BLT\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj() < rd()); ++ break; ++ case BGE: ++ printf_instr("BGE\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj() >= rd()); ++ break; ++ case BLTU: ++ printf_instr("BLTU\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj_u() < rd_u()); ++ break; ++ case BGEU: ++ printf_instr("BGEU\t %s: %016lx, %s, %016lx, ", Registers::Name(rj_reg()), ++ rj(), Registers::Name(rd_reg()), rd()); ++ BranchOff16Helper(rj_u() >= rd_u()); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp7() { ++ int64_t alu_out; ++ ++ switch (instr_.Bits(31, 25) << 25) { ++ case LU12I_W: { ++ printf_instr("LU12I_W\t %s: %016lx, si20: %d\n", ++ Registers::Name(rd_reg()), rd(), si20()); ++ int32_t si20_upper = static_cast(si20() << 12); ++ SetResult(rd_reg(), static_cast(si20_upper)); ++ break; ++ } ++ case LU32I_D: { ++ printf_instr("LU32I_D\t %s: %016lx, si20: %d\n", ++ Registers::Name(rd_reg()), rd(), si20()); ++ int32_t si20_signExtend = static_cast(si20() << 12) >> 12; ++ int64_t lower_32bit_mask = 0xFFFFFFFF; ++ alu_out = (static_cast(si20_signExtend) << 32) | ++ (rd() & lower_32bit_mask); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case PCADDI: { ++ printf_instr("PCADDI\t %s: %016lx, si20: %d\n", Registers::Name(rd_reg()), ++ rd(), si20()); ++ int32_t si20_signExtend = static_cast(si20() << 12) >> 10; ++ int64_t current_pc = get_pc(); ++ alu_out = static_cast(si20_signExtend) + current_pc; ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case PCALAU12I: { ++ printf_instr("PCALAU12I\t %s: %016lx, si20: %d\n", ++ Registers::Name(rd_reg()), rd(), si20()); ++ int32_t si20_signExtend = static_cast(si20() << 12); ++ int64_t current_pc = get_pc(); ++ int64_t clear_lower12bit_mask = 0xFFFFFFFFFFFFF000; ++ alu_out = static_cast(si20_signExtend) + current_pc; ++ SetResult(rd_reg(), alu_out & clear_lower12bit_mask); ++ break; ++ } ++ case PCADDU12I: { ++ printf_instr("PCADDU12I\t %s: %016lx, si20: %d\n", ++ Registers::Name(rd_reg()), rd(), si20()); ++ int32_t si20_signExtend = static_cast(si20() << 12); ++ int64_t current_pc = get_pc(); ++ alu_out = static_cast(si20_signExtend) + current_pc; ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case PCADDU18I: { ++ printf_instr("PCADDU18I\t %s: %016lx, si20: %d\n", ++ Registers::Name(rd_reg()), rd(), si20()); ++ int64_t si20_signExtend = (static_cast(si20()) << 44) >> 26; ++ int64_t current_pc = get_pc(); ++ alu_out = si20_signExtend + current_pc; ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp8() { ++ int64_t addr = 0x0; ++ int64_t si14_se = (static_cast(si14()) << 50) >> 48; ++ ++ switch (instr_.Bits(31, 24) << 24) { ++ case LDPTR_W: ++ printf_instr("LDPTR_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ set_register(rd_reg(), ReadW(rj() + si14_se, instr_.instr())); ++ break; ++ case STPTR_W: ++ printf_instr("STPTR_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ WriteW(rj() + si14_se, static_cast(rd()), instr_.instr()); ++ break; ++ case LDPTR_D: ++ printf_instr("LDPTR_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ set_register(rd_reg(), Read2W(rj() + si14_se, instr_.instr())); ++ break; ++ case STPTR_D: ++ printf_instr("STPTR_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ Write2W(rj() + si14_se, rd(), instr_.instr()); ++ break; ++ case LL_W: { ++ printf_instr("LL_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ addr = si14_se + rj(); ++ set_register(rd_reg(), ReadW(addr, instr_.instr())); ++ local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, ++ &global_monitor_thread_); ++ break; ++ } ++ case SC_W: { ++ printf_instr("SC_W\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ addr = si14_se + rj(); ++ WriteConditionalW(addr, static_cast(rd()), instr_.instr(), ++ rd_reg()); ++ break; ++ } ++ case LL_D: { ++ printf_instr("LL_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ addr = si14_se + rj(); ++ set_register(rd_reg(), Read2W(addr, instr_.instr())); ++ local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, ++ &global_monitor_thread_); ++ break; ++ } ++ case SC_D: { ++ printf_instr("SC_D\t %s: %016lx, %s: %016lx, si14: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si14_se); ++ addr = si14_se + rj(); ++ WriteConditional2W(addr, rd(), instr_.instr(), rd_reg()); ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp10() { ++ int64_t alu_out = 0x0; ++ int64_t si12_se = (static_cast(si12()) << 52) >> 52; ++ uint64_t si12_ze = (static_cast(ui12()) << 52) >> 52; ++ ++ switch (instr_.Bits(31, 22) << 22) { ++ case BSTR_W: { ++ CHECK_EQ(instr_.Bit(21), 1); ++ uint8_t lsbw_ = lsbw(); ++ uint8_t msbw_ = msbw(); ++ CHECK_LE(lsbw_, msbw_); ++ uint8_t size = msbw_ - lsbw_ + 1; ++ uint64_t mask = (1ULL << size) - 1; ++ if (instr_.Bit(15) == 0) { ++ // BSTRINS_W ++ printf_instr( ++ "BSTRINS_W\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), ++ msbw_, lsbw_); ++ alu_out = static_cast((rd_u() & ~(mask << lsbw_)) | ++ ((rj_u() & mask) << lsbw_)); ++ } else { ++ // BSTRPICK_W ++ printf_instr( ++ "BSTRPICK_W\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), ++ msbw_, lsbw_); ++ alu_out = static_cast((rj_u() & (mask << lsbw_)) >> lsbw_); ++ } ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BSTRINS_D: { ++ uint8_t lsbd_ = lsbd(); ++ uint8_t msbd_ = msbd(); ++ CHECK_LE(lsbd_, msbd_); ++ printf_instr( ++ "BSTRINS_D\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), ++ msbd_, lsbd_); ++ uint8_t size = msbd_ - lsbd_ + 1; ++ if (size < 64) { ++ uint64_t mask = (1ULL << size) - 1; ++ alu_out = (rd_u() & ~(mask << lsbd_)) | ((rj_u() & mask) << lsbd_); ++ SetResult(rd_reg(), alu_out); ++ } else if (size == 64) { ++ SetResult(rd_reg(), rj()); ++ } ++ break; ++ } ++ case BSTRPICK_D: { ++ uint8_t lsbd_ = lsbd(); ++ uint8_t msbd_ = msbd(); ++ CHECK_LE(lsbd_, msbd_); ++ printf_instr( ++ "BSTRPICK_D\t %s: %016lx, %s: %016lx, msbw: %02x, lsbw: %02x\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), rj(), ++ msbd_, lsbd_); ++ uint8_t size = msbd_ - lsbd_ + 1; ++ if (size < 64) { ++ uint64_t mask = (1ULL << size) - 1; ++ alu_out = (rj_u() & (mask << lsbd_)) >> lsbd_; ++ SetResult(rd_reg(), alu_out); ++ } else if (size == 64) { ++ SetResult(rd_reg(), rj()); ++ } ++ break; ++ } ++ case SLTI: ++ printf_instr("SLTI\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_se); ++ SetResult(rd_reg(), rj() < si12_se ? 1 : 0); ++ break; ++ case SLTUI: ++ printf_instr("SLTUI\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_se); ++ SetResult(rd_reg(), rj_u() < static_cast(si12_se) ? 1 : 0); ++ break; ++ case ADDI_W: { ++ printf_instr("ADDI_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_se); ++ int32_t alu32_out = ++ static_cast(rj()) + static_cast(si12_se); ++ SetResult(rd_reg(), alu32_out); ++ break; ++ } ++ case ADDI_D: ++ printf_instr("ADDI_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_se); ++ SetResult(rd_reg(), rj() + si12_se); ++ break; ++ case LU52I_D: { ++ printf_instr("LU52I_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_se); ++ int64_t si12_se = static_cast(si12()) << 52; ++ uint64_t mask = (1ULL << 52) - 1; ++ alu_out = si12_se + (rj() & mask); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case ANDI: ++ printf_instr("ANDI\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ SetResult(rd_reg(), rj() & si12_ze); ++ break; ++ case ORI: ++ printf_instr("ORI\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ SetResult(rd_reg(), rj_u() | si12_ze); ++ break; ++ case XORI: ++ printf_instr("XORI\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ SetResult(rd_reg(), rj_u() ^ si12_ze); ++ break; ++ case LD_B: ++ printf_instr("LD_B\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadB(rj() + si12_se)); ++ break; ++ case LD_H: ++ printf_instr("LD_H\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadH(rj() + si12_se, instr_.instr())); ++ break; ++ case LD_W: ++ printf_instr("LD_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadW(rj() + si12_se, instr_.instr())); ++ break; ++ case LD_D: ++ printf_instr("LD_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), Read2W(rj() + si12_se, instr_.instr())); ++ break; ++ case ST_B: ++ printf_instr("ST_B\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ WriteB(rj() + si12_se, static_cast(rd())); ++ break; ++ case ST_H: ++ printf_instr("ST_H\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ WriteH(rj() + si12_se, static_cast(rd()), instr_.instr()); ++ break; ++ case ST_W: ++ printf_instr("ST_W\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ WriteW(rj() + si12_se, static_cast(rd()), instr_.instr()); ++ break; ++ case ST_D: ++ printf_instr("ST_D\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ Write2W(rj() + si12_se, rd(), instr_.instr()); ++ break; ++ case LD_BU: ++ printf_instr("LD_BU\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadBU(rj() + si12_se)); ++ break; ++ case LD_HU: ++ printf_instr("LD_HU\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadHU(rj() + si12_se, instr_.instr())); ++ break; ++ case LD_WU: ++ printf_instr("LD_WU\t %s: %016lx, %s: %016lx, si12: %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), si12_ze); ++ set_register(rd_reg(), ReadWU(rj() + si12_se, instr_.instr())); ++ break; ++ case FLD_S: { ++ printf_instr("FLD_S\t %s: %016f, %s: %016lx, si12: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ Registers::Name(rj_reg()), rj(), si12_ze); ++ set_fpu_register(fd_reg(), kFPUInvalidResult); // Trash upper 32 bits. ++ set_fpu_register_word( ++ fd_reg(), ReadW(rj() + si12_se, instr_.instr(), FLOAT_DOUBLE)); ++ break; ++ } ++ case FST_S: { ++ printf_instr("FST_S\t %s: %016f, %s: %016lx, si12: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ Registers::Name(rj_reg()), rj(), si12_ze); ++ int32_t alu_out_32 = static_cast(get_fpu_register(fd_reg())); ++ WriteW(rj() + si12_se, alu_out_32, instr_.instr()); ++ break; ++ } ++ case FLD_D: { ++ printf_instr("FLD_D\t %s: %016f, %s: %016lx, si12: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj(), si12_ze); ++ set_fpu_register_double(fd_reg(), ReadD(rj() + si12_se, instr_.instr())); ++ TraceMemRd(rj() + si12_se, get_fpu_register(fd_reg()), DOUBLE); ++ break; ++ } ++ case FST_D: { ++ printf_instr("FST_D\t %s: %016f, %s: %016lx, si12: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj(), si12_ze); ++ WriteD(rj() + si12_se, get_fpu_register_double(fd_reg()), instr_.instr()); ++ TraceMemWr(rj() + si12_se, get_fpu_register(fd_reg()), DWORD); ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp12() { ++ switch (instr_.Bits(31, 20) << 20) { ++ case FMADD_S: ++ printf_instr("FMADD_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fk_reg()), fk_float(), ++ FPURegisters::Name(fa_reg()), fa_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), std::fma(fj_float(), fk_float(), fa_float())); ++ break; ++ case FMADD_D: ++ printf_instr("FMADD_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fk_reg()), fk_double(), ++ FPURegisters::Name(fa_reg()), fa_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), ++ std::fma(fj_double(), fk_double(), fa_double())); ++ break; ++ case FMSUB_S: ++ printf_instr("FMSUB_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fk_reg()), fk_float(), ++ FPURegisters::Name(fa_reg()), fa_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), ++ std::fma(fj_float(), fk_float(), -fa_float())); ++ break; ++ case FMSUB_D: ++ printf_instr("FMSUB_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fk_reg()), fk_double(), ++ FPURegisters::Name(fa_reg()), fa_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), ++ std::fma(fj_double(), fk_double(), -fa_double())); ++ break; ++ case FNMADD_S: ++ printf_instr("FNMADD_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fk_reg()), fk_float(), ++ FPURegisters::Name(fa_reg()), fa_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), ++ std::fma(-fj_float(), fk_float(), -fa_float())); ++ break; ++ case FNMADD_D: ++ printf_instr("FNMADD_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fk_reg()), fk_double(), ++ FPURegisters::Name(fa_reg()), fa_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), ++ std::fma(-fj_double(), fk_double(), -fa_double())); ++ break; ++ case FNMSUB_S: ++ printf_instr("FNMSUB_S\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fk_reg()), fk_float(), ++ FPURegisters::Name(fa_reg()), fa_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), ++ std::fma(-fj_float(), fk_float(), fa_float())); ++ break; ++ case FNMSUB_D: ++ printf_instr("FNMSUB_D\t %s: %016f, %s: %016f, %s: %016f %s: %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fk_reg()), fk_double(), ++ FPURegisters::Name(fa_reg()), fa_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), ++ std::fma(-fj_double(), fk_double(), fa_double())); ++ break; ++ case FCMP_COND_S: { ++ CHECK_EQ(instr_.Bits(4, 3), 0); ++ float fj = fj_float(); ++ float fk = fk_float(); ++ switch (cond()) { ++ case CAF: { ++ printf_instr("FCMP_CAF_S fcc%d\n", cd_reg()); ++ set_cf_register(cd_reg(), false); ++ break; ++ } ++ case CUN: { ++ printf_instr("FCMP_CUN_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CEQ: { ++ printf_instr("FCMP_CEQ_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj == fk); ++ break; ++ } ++ case CUEQ: { ++ printf_instr("FCMP_CUEQ_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj == fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CLT: { ++ printf_instr("FCMP_CLT_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj < fk); ++ break; ++ } ++ case CULT: { ++ printf_instr("FCMP_CULT_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj < fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CLE: { ++ printf_instr("FCMP_CLE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj <= fk); ++ break; ++ } ++ case CULE: { ++ printf_instr("FCMP_CULE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj <= fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CNE: { ++ printf_instr("FCMP_CNE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), (fj < fk) || (fj > fk)); ++ break; ++ } ++ case COR: { ++ printf_instr("FCMP_COR_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), !std::isnan(fj) && !std::isnan(fk)); ++ break; ++ } ++ case CUNE: { ++ printf_instr("FCMP_CUNE_S fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj != fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case SAF: ++ case SUN: ++ case SEQ: ++ case SUEQ: ++ case SLT: ++ case SULT: ++ case SLE: ++ case SULE: ++ case SNE: ++ case SOR: ++ case SUNE: ++ UNIMPLEMENTED(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ break; ++ } ++ case FCMP_COND_D: { ++ CHECK_EQ(instr_.Bits(4, 3), 0); ++ double fj = fj_double(); ++ double fk = fk_double(); ++ switch (cond()) { ++ case CAF: { ++ printf_instr("FCMP_CAF_D fcc%d\n", cd_reg()); ++ set_cf_register(cd_reg(), false); ++ break; ++ } ++ case CUN: { ++ printf_instr("FCMP_CUN_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CEQ: { ++ printf_instr("FCMP_CEQ_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj == fk); ++ break; ++ } ++ case CUEQ: { ++ printf_instr("FCMP_CUEQ_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj == fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CLT: { ++ printf_instr("FCMP_CLT_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj < fk); ++ break; ++ } ++ case CULT: { ++ printf_instr("FCMP_CULT_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj < fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CLE: { ++ printf_instr("FCMP_CLE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), fj <= fk); ++ break; ++ } ++ case CULE: { ++ printf_instr("FCMP_CULE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj <= fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case CNE: { ++ printf_instr("FCMP_CNE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), (fj < fk) || (fj > fk)); ++ break; ++ } ++ case COR: { ++ printf_instr("FCMP_COR_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), !std::isnan(fj) && !std::isnan(fk)); ++ break; ++ } ++ case CUNE: { ++ printf_instr("FCMP_CUNE_D fcc%d, %s: %016f, %s: %016f\n", cd_reg(), ++ FPURegisters::Name(fj_reg()), fj, ++ FPURegisters::Name(fk_reg()), fk); ++ set_cf_register(cd_reg(), ++ (fj != fk) || std::isnan(fj) || std::isnan(fk)); ++ break; ++ } ++ case SAF: ++ case SUN: ++ case SEQ: ++ case SUEQ: ++ case SLT: ++ case SULT: ++ case SLE: ++ case SULE: ++ case SNE: ++ case SOR: ++ case SUNE: ++ UNIMPLEMENTED(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ break; ++ } ++ case FSEL: { ++ CHECK_EQ(instr_.Bits(19, 18), 0); ++ printf_instr("FSEL fcc%d, %s: %016f, %s: %016f, %s: %016f\n", ca_reg(), ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ if (ca() == 0) { ++ SetFPUDoubleResult(fd_reg(), fj_double()); ++ } else { ++ SetFPUDoubleResult(fd_reg(), fk_double()); ++ } ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp14() { ++ int64_t alu_out = 0x0; ++ int32_t alu32_out = 0x0; ++ ++ switch (instr_.Bits(31, 18) << 18) { ++ case ALSL: { ++ uint8_t sa = sa2() + 1; ++ alu32_out = ++ (static_cast(rj()) << sa) + static_cast(rk()); ++ if (instr_.Bit(17) == 0) { ++ // ALSL_W ++ printf_instr("ALSL_W\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk(), sa2()); ++ SetResult(rd_reg(), alu32_out); ++ } else { ++ // ALSL_WU ++ printf_instr("ALSL_WU\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk(), sa2()); ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ } ++ break; ++ } ++ case BYTEPICK_W: { ++ CHECK_EQ(instr_.Bit(17), 0); ++ printf_instr("BYTEPICK_W\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk(), sa2()); ++ uint8_t sa = sa2() * 8; ++ if (sa == 0) { ++ alu32_out = static_cast(rk()); ++ } else { ++ int32_t mask = (1 << 31) >> (sa - 1); ++ int32_t rk_hi = (static_cast(rk()) & (~mask)) << sa; ++ int32_t rj_lo = (static_cast(rj()) & mask) >> (32 - sa); ++ alu32_out = rk_hi | rj_lo; ++ } ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ break; ++ } ++ case BYTEPICK_D: { ++ printf_instr("BYTEPICK_D\t %s: %016lx, %s: %016lx, %s: %016lx, sa3: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk(), sa3()); ++ uint8_t sa = sa3() * 8; ++ if (sa == 0) { ++ alu_out = rk(); ++ } else { ++ int64_t mask = (1ULL << 63) >> (sa - 1); ++ int64_t rk_hi = (rk() & (~mask)) << sa; ++ int64_t rj_lo = (rj() & mask) >> (64 - sa); ++ alu_out = rk_hi | rj_lo; ++ } ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case ALSL_D: { ++ printf_instr("ALSL_D\t %s: %016lx, %s: %016lx, %s: %016lx, sa2: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk(), sa2()); ++ CHECK_EQ(instr_.Bit(17), 0); ++ uint8_t sa = sa2() + 1; ++ alu_out = (rj() << sa) + rk(); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case SLLI: { ++ DCHECK_EQ(instr_.Bit(17), 0); ++ if (instr_.Bits(17, 15) == 0b001) { ++ // SLLI_W ++ printf_instr("SLLI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui5()); ++ alu32_out = static_cast(rj()) << ui5(); ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ } else if ((instr_.Bits(17, 16) == 0b01)) { ++ // SLLI_D ++ printf_instr("SLLI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui6()); ++ SetResult(rd_reg(), rj() << ui6()); ++ } ++ break; ++ } ++ case SRLI: { ++ DCHECK_EQ(instr_.Bit(17), 0); ++ if (instr_.Bits(17, 15) == 0b001) { ++ // SRLI_W ++ printf_instr("SRLI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui5()); ++ alu32_out = static_cast(rj()) >> ui5(); ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ } else if (instr_.Bits(17, 16) == 0b01) { ++ // SRLI_D ++ printf_instr("SRLI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui6()); ++ SetResult(rd_reg(), rj_u() >> ui6()); ++ } ++ break; ++ } ++ case SRAI: { ++ DCHECK_EQ(instr_.Bit(17), 0); ++ if (instr_.Bits(17, 15) == 0b001) { ++ // SRAI_W ++ printf_instr("SRAI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui5()); ++ alu32_out = static_cast(rj()) >> ui5(); ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ } else if (instr_.Bits(17, 16) == 0b01) { ++ // SRAI_D ++ printf_instr("SRAI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui6()); ++ SetResult(rd_reg(), rj() >> ui6()); ++ } ++ break; ++ } ++ case ROTRI: { ++ DCHECK_EQ(instr_.Bit(17), 0); ++ if (instr_.Bits(17, 15) == 0b001) { ++ // ROTRI_W ++ printf_instr("ROTRI_W\t %s: %016lx, %s: %016lx, ui5: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui5()); ++ alu32_out = static_cast( ++ base::bits::RotateRight32(static_cast(rj_u()), ++ static_cast(ui5()))); ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ } else if (instr_.Bits(17, 16) == 0b01) { ++ // ROTRI_D ++ printf_instr("ROTRI_D\t %s: %016lx, %s: %016lx, ui6: %d\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), ui6()); ++ alu_out = ++ static_cast(base::bits::RotateRight64(rj_u(), ui6())); ++ SetResult(rd_reg(), alu_out); ++ printf_instr("ROTRI, %s, %s, %d\n", Registers::Name(rd_reg()), ++ Registers::Name(rj_reg()), ui6()); ++ } ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp17() { ++ int64_t alu_out; ++ ++ switch (instr_.Bits(31, 15) << 15) { ++ case ADD_W: { ++ printf_instr("ADD_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int32_t alu32_out = static_cast(rj() + rk()); ++ // Sign-extend result of 32bit operation into 64bit register. ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ break; ++ } ++ case ADD_D: ++ printf_instr("ADD_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() + rk()); ++ break; ++ case SUB_W: { ++ printf_instr("SUB_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int32_t alu32_out = static_cast(rj() - rk()); ++ // Sign-extend result of 32bit operation into 64bit register. ++ SetResult(rd_reg(), static_cast(alu32_out)); ++ break; ++ } ++ case SUB_D: ++ printf_instr("SUB_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() - rk()); ++ break; ++ case SLT: ++ printf_instr("SLT\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() < rk() ? 1 : 0); ++ break; ++ case SLTU: ++ printf_instr("SLTU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj_u() < rk_u() ? 1 : 0); ++ break; ++ case MASKEQZ: ++ printf_instr("MASKEQZ\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rk() == 0 ? rj() : 0); ++ break; ++ case MASKNEZ: ++ printf_instr("MASKNEZ\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rk() != 0 ? rj() : 0); ++ break; ++ case NOR: ++ printf_instr("NOR\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), ~(rj() | rk())); ++ break; ++ case AND: ++ printf_instr("AND\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() & rk()); ++ break; ++ case OR: ++ printf_instr("OR\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() | rk()); ++ break; ++ case XOR: ++ printf_instr("XOR\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() ^ rk()); ++ break; ++ case ORN: ++ printf_instr("ORN\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() | (~rk())); ++ break; ++ case ANDN: ++ printf_instr("ANDN\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() & (~rk())); ++ break; ++ case SLL_W: ++ printf_instr("SLL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), (int32_t)rj() << (rk_u() % 32)); ++ break; ++ case SRL_W: { ++ printf_instr("SRL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ alu_out = static_cast((uint32_t)rj_u() >> (rk_u() % 32)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case SRA_W: ++ printf_instr("SRA_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), (int32_t)rj() >> (rk_u() % 32)); ++ break; ++ case SLL_D: ++ printf_instr("SLL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() << (rk_u() % 64)); ++ break; ++ case SRL_D: { ++ printf_instr("SRL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ alu_out = static_cast(rj_u() >> (rk_u() % 64)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case SRA_D: ++ printf_instr("SRA_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() >> (rk_u() % 64)); ++ break; ++ case ROTR_W: { ++ printf_instr("ROTR_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ alu_out = static_cast( ++ base::bits::RotateRight32(static_cast(rj_u()), ++ static_cast(rk_u() % 32))); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case ROTR_D: { ++ printf_instr("ROTR_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ alu_out = static_cast( ++ base::bits::RotateRight64((rj_u()), (rk_u() % 64))); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case MUL_W: { ++ printf_instr("MUL_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ alu_out = static_cast(rj()) * static_cast(rk()); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case MULH_W: { ++ printf_instr("MULH_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int32_t rj_lo = static_cast(rj()); ++ int32_t rk_lo = static_cast(rk()); ++ alu_out = static_cast(rj_lo) * static_cast(rk_lo); ++ SetResult(rd_reg(), alu_out >> 32); ++ break; ++ } ++ case MULH_WU: { ++ printf_instr("MULH_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ uint32_t rj_lo = static_cast(rj_u()); ++ uint32_t rk_lo = static_cast(rk_u()); ++ alu_out = static_cast(rj_lo) * static_cast(rk_lo); ++ SetResult(rd_reg(), alu_out >> 32); ++ break; ++ } ++ case MUL_D: ++ printf_instr("MUL_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), rj() * rk()); ++ break; ++ case MULH_D: ++ printf_instr("MULH_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), MultiplyHighSigned(rj(), rk())); ++ break; ++ case MULH_DU: ++ printf_instr("MULH_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ SetResult(rd_reg(), MultiplyHighUnsigned(rj_u(), rk_u())); ++ break; ++ case MULW_D_W: { ++ printf_instr("MULW_D_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int64_t rj_i32 = static_cast(rj()); ++ int64_t rk_i32 = static_cast(rk()); ++ SetResult(rd_reg(), rj_i32 * rk_i32); ++ break; ++ } ++ case MULW_D_WU: { ++ printf_instr("MULW_D_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ uint64_t rj_u32 = static_cast(rj_u()); ++ uint64_t rk_u32 = static_cast(rk_u()); ++ SetResult(rd_reg(), rj_u32 * rk_u32); ++ break; ++ } ++ case DIV_W: { ++ printf_instr("DIV_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int32_t rj_i32 = static_cast(rj()); ++ int32_t rk_i32 = static_cast(rk()); ++ if (rj_i32 == INT_MIN && rk_i32 == -1) { ++ SetResult(rd_reg(), INT_MIN); ++ } else if (rk_i32 != 0) { ++ SetResult(rd_reg(), rj_i32 / rk_i32); ++ } ++ break; ++ } ++ case MOD_W: { ++ printf_instr("MOD_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ int32_t rj_i32 = static_cast(rj()); ++ int32_t rk_i32 = static_cast(rk()); ++ if (rj_i32 == INT_MIN && rk_i32 == -1) { ++ SetResult(rd_reg(), 0); ++ } else if (rk_i32 != 0) { ++ SetResult(rd_reg(), rj_i32 % rk_i32); ++ } ++ break; ++ } ++ case DIV_WU: { ++ printf_instr("DIV_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ uint32_t rj_u32 = static_cast(rj()); ++ uint32_t rk_u32 = static_cast(rk()); ++ if (rk_u32 != 0) { ++ SetResult(rd_reg(), static_cast(rj_u32 / rk_u32)); ++ } ++ break; ++ } ++ case MOD_WU: { ++ printf_instr("MOD_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ uint32_t rj_u32 = static_cast(rj()); ++ uint32_t rk_u32 = static_cast(rk()); ++ if (rk_u32 != 0) { ++ SetResult(rd_reg(), static_cast(rj_u32 % rk_u32)); ++ } ++ break; ++ } ++ case DIV_D: { ++ printf_instr("DIV_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ if (rj() == LONG_MIN && rk() == -1) { ++ SetResult(rd_reg(), LONG_MIN); ++ } else if (rk() != 0) { ++ SetResult(rd_reg(), rj() / rk()); ++ } ++ break; ++ } ++ case MOD_D: { ++ printf_instr("MOD_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ if (rj() == LONG_MIN && rk() == -1) { ++ SetResult(rd_reg(), 0); ++ } else if (rk() != 0) { ++ SetResult(rd_reg(), rj() % rk()); ++ } ++ break; ++ } ++ case DIV_DU: { ++ printf_instr("DIV_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ if (rk_u() != 0) { ++ SetResult(rd_reg(), static_cast(rj_u() / rk_u())); ++ } ++ break; ++ } ++ case MOD_DU: { ++ printf_instr("MOD_DU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ if (rk_u() != 0) { ++ SetResult(rd_reg(), static_cast(rj_u() % rk_u())); ++ } ++ break; ++ } ++ case BREAK: ++ printf_instr("BREAK\t code: %x\n", instr_.Bits(14, 0)); ++ SoftwareInterrupt(); ++ break; ++ case FADD_S: { ++ printf_instr("FADD_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult( ++ fd_reg(), ++ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs + rhs; }, ++ fj_float(), fk_float())); ++ break; ++ } ++ case FADD_D: { ++ printf_instr("FADD_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), ++ FPUCanonalizeOperation( ++ [](double lhs, double rhs) { return lhs + rhs; }, ++ fj_double(), fk_double())); ++ break; ++ } ++ case FSUB_S: { ++ printf_instr("FSUB_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult( ++ fd_reg(), ++ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs - rhs; }, ++ fj_float(), fk_float())); ++ break; ++ } ++ case FSUB_D: { ++ printf_instr("FSUB_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), ++ FPUCanonalizeOperation( ++ [](double lhs, double rhs) { return lhs - rhs; }, ++ fj_double(), fk_double())); ++ break; ++ } ++ case FMUL_S: { ++ printf_instr("FMUL_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult( ++ fd_reg(), ++ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs * rhs; }, ++ fj_float(), fk_float())); ++ break; ++ } ++ case FMUL_D: { ++ printf_instr("FMUL_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), ++ FPUCanonalizeOperation( ++ [](double lhs, double rhs) { return lhs * rhs; }, ++ fj_double(), fk_double())); ++ break; ++ } ++ case FDIV_S: { ++ printf_instr("FDIV_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult( ++ fd_reg(), ++ FPUCanonalizeOperation([](float lhs, float rhs) { return lhs / rhs; }, ++ fj_float(), fk_float())); ++ break; ++ } ++ case FDIV_D: { ++ printf_instr("FDIV_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), ++ FPUCanonalizeOperation( ++ [](double lhs, double rhs) { return lhs / rhs; }, ++ fj_double(), fk_double())); ++ break; ++ } ++ case FMAX_S: ++ printf_instr("FMAX_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult(fd_reg(), FPUMax(fk_float(), fj_float())); ++ break; ++ case FMAX_D: ++ printf_instr("FMAX_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), FPUMax(fk_double(), fj_double())); ++ break; ++ case FMIN_S: ++ printf_instr("FMIN_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult(fd_reg(), FPUMin(fk_float(), fj_float())); ++ break; ++ case FMIN_D: ++ printf_instr("FMIN_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), FPUMin(fk_double(), fj_double())); ++ break; ++ case FMAXA_S: ++ printf_instr("FMAXA_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult(fd_reg(), FPUMaxA(fk_float(), fj_float())); ++ break; ++ case FMAXA_D: ++ printf_instr("FMAXA_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), FPUMaxA(fk_double(), fj_double())); ++ break; ++ case FMINA_S: ++ printf_instr("FMINA_S\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float(), ++ FPURegisters::Name(fk_reg()), fk_float()); ++ SetFPUFloatResult(fd_reg(), FPUMinA(fk_float(), fj_float())); ++ break; ++ case FMINA_D: ++ printf_instr("FMINA_D\t %s: %016f, %s, %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double(), ++ FPURegisters::Name(fk_reg()), fk_double()); ++ SetFPUDoubleResult(fd_reg(), FPUMinA(fk_double(), fj_double())); ++ break; ++ case LDX_B: ++ printf_instr("LDX_B\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadB(rj() + rk())); ++ break; ++ case LDX_H: ++ printf_instr("LDX_H\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadH(rj() + rk(), instr_.instr())); ++ break; ++ case LDX_W: ++ printf_instr("LDX_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadW(rj() + rk(), instr_.instr())); ++ break; ++ case LDX_D: ++ printf_instr("LDX_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), Read2W(rj() + rk(), instr_.instr())); ++ break; ++ case STX_B: ++ printf_instr("STX_B\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ WriteB(rj() + rk(), static_cast(rd())); ++ break; ++ case STX_H: ++ printf_instr("STX_H\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ WriteH(rj() + rk(), static_cast(rd()), instr_.instr()); ++ break; ++ case STX_W: ++ printf_instr("STX_W\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ WriteW(rj() + rk(), static_cast(rd()), instr_.instr()); ++ break; ++ case STX_D: ++ printf_instr("STX_D\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ Write2W(rj() + rk(), rd(), instr_.instr()); ++ break; ++ case LDX_BU: ++ printf_instr("LDX_BU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadBU(rj() + rk())); ++ break; ++ case LDX_HU: ++ printf_instr("LDX_HU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadHU(rj() + rk(), instr_.instr())); ++ break; ++ case LDX_WU: ++ printf_instr("LDX_WU\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj(), Registers::Name(rk_reg()), rk()); ++ set_register(rd_reg(), ReadWU(rj() + rk(), instr_.instr())); ++ break; ++ case FLDX_S: ++ printf_instr("FLDX_S\t %s: %016f, %s: %016lx, %s: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), ++ rk()); ++ set_fpu_register(fd_reg(), kFPUInvalidResult); // Trash upper 32 bits. ++ set_fpu_register_word(fd_reg(), ++ ReadW(rj() + rk(), instr_.instr(), FLOAT_DOUBLE)); ++ break; ++ case FLDX_D: ++ printf_instr("FLDX_D\t %s: %016f, %s: %016lx, %s: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), ++ rk()); ++ set_fpu_register_double(fd_reg(), ReadD(rj() + rk(), instr_.instr())); ++ break; ++ case FSTX_S: ++ printf_instr("FSTX_S\t %s: %016f, %s: %016lx, %s: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), ++ rk()); ++ WriteW(rj() + rk(), static_cast(get_fpu_register(fd_reg())), ++ instr_.instr()); ++ break; ++ case FSTX_D: ++ printf_instr("FSTX_D\t %s: %016f, %s: %016lx, %s: %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj(), Registers::Name(rk_reg()), ++ rk()); ++ WriteD(rj() + rk(), get_fpu_register_double(fd_reg()), instr_.instr()); ++ break; ++ case AMSWAP_W: ++ printf("Sim UNIMPLEMENTED: AMSWAP_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMSWAP_D: ++ printf("Sim UNIMPLEMENTED: AMSWAP_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMADD_W: ++ printf("Sim UNIMPLEMENTED: AMADD_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMADD_D: ++ printf("Sim UNIMPLEMENTED: AMADD_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMAND_W: ++ printf("Sim UNIMPLEMENTED: AMAND_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMAND_D: ++ printf("Sim UNIMPLEMENTED: AMAND_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMOR_W: ++ printf("Sim UNIMPLEMENTED: AMOR_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMOR_D: ++ printf("Sim UNIMPLEMENTED: AMOR_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMXOR_W: ++ printf("Sim UNIMPLEMENTED: AMXOR_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMXOR_D: ++ printf("Sim UNIMPLEMENTED: AMXOR_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_W: ++ printf("Sim UNIMPLEMENTED: AMMAX_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_D: ++ printf("Sim UNIMPLEMENTED: AMMAX_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_W: ++ printf("Sim UNIMPLEMENTED: AMMIN_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_D: ++ printf("Sim UNIMPLEMENTED: AMMIN_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_WU: ++ printf("Sim UNIMPLEMENTED: AMMAX_WU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_DU: ++ printf("Sim UNIMPLEMENTED: AMMAX_DU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_WU: ++ printf("Sim UNIMPLEMENTED: AMMIN_WU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_DU: ++ printf("Sim UNIMPLEMENTED: AMMIN_DU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMSWAP_DB_W: { ++ printf_instr("AMSWAP_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int32_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), ReadW(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditionalW(rj(), static_cast(rk()), instr_.instr(), ++ rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMSWAP_DB_D: { ++ printf_instr("AMSWAP_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int64_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), Read2W(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditional2W(rj(), rk(), instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMADD_DB_W: { ++ printf_instr("AMADD_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int32_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), ReadW(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditionalW(rj(), ++ static_cast(static_cast(rk()) + ++ static_cast(rd())), ++ instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMADD_DB_D: { ++ printf_instr("AMADD_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int64_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), Read2W(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditional2W(rj(), rk() + rd(), instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMAND_DB_W: { ++ printf_instr("AMAND_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int32_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), ReadW(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditionalW(rj(), ++ static_cast(static_cast(rk()) & ++ static_cast(rd())), ++ instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMAND_DB_D: { ++ printf_instr("AMAND_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int64_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), Read2W(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditional2W(rj(), rk() & rd(), instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMOR_DB_W: { ++ printf_instr("AMOR_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int32_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), ReadW(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditionalW(rj(), ++ static_cast(static_cast(rk()) | ++ static_cast(rd())), ++ instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMOR_DB_D: { ++ printf_instr("AMOR_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int64_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), Read2W(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditional2W(rj(), rk() | rd(), instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMXOR_DB_W: { ++ printf_instr("AMXOR_DB_W:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int32_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), ReadW(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditionalW(rj(), ++ static_cast(static_cast(rk()) ^ ++ static_cast(rd())), ++ instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMXOR_DB_D: { ++ printf_instr("AMXOR_DB_D:\t %s: %016lx, %s, %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rk_reg()), ++ rk(), Registers::Name(rj_reg()), rj()); ++ int64_t rdvalue; ++ do { ++ { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ set_register(rd_reg(), Read2W(rj(), instr_.instr())); ++ local_monitor_.NotifyLoadLinked(rj(), TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked( ++ rj(), &global_monitor_thread_); ++ } ++ rdvalue = get_register(rd_reg()); ++ WriteConditional2W(rj(), rk() ^ rd(), instr_.instr(), rd_reg()); ++ } while (!get_register(rd_reg())); ++ set_register(rd_reg(), rdvalue); ++ } break; ++ case AMMAX_DB_W: ++ printf("Sim UNIMPLEMENTED: AMMAX_DB_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_DB_D: ++ printf("Sim UNIMPLEMENTED: AMMAX_DB_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_DB_W: ++ printf("Sim UNIMPLEMENTED: AMMIN_DB_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_DB_D: ++ printf("Sim UNIMPLEMENTED: AMMIN_DB_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_DB_WU: ++ printf("Sim UNIMPLEMENTED: AMMAX_DB_WU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMAX_DB_DU: ++ printf("Sim UNIMPLEMENTED: AMMAX_DB_DU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_DB_WU: ++ printf("Sim UNIMPLEMENTED: AMMIN_DB_WU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case AMMIN_DB_DU: ++ printf("Sim UNIMPLEMENTED: AMMIN_DB_DU\n"); ++ UNIMPLEMENTED(); ++ break; ++ case DBAR: ++ printf_instr("DBAR\n"); ++ break; ++ case IBAR: ++ printf("Sim UNIMPLEMENTED: IBAR\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FSCALEB_S: ++ printf("Sim UNIMPLEMENTED: FSCALEB_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FSCALEB_D: ++ printf("Sim UNIMPLEMENTED: FSCALEB_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FCOPYSIGN_S: ++ printf("Sim UNIMPLEMENTED: FCOPYSIGN_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FCOPYSIGN_D: ++ printf("Sim UNIMPLEMENTED: FCOPYSIGN_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void Simulator::DecodeTypeOp22() { ++ int64_t alu_out; ++ ++ switch (instr_.Bits(31, 10) << 10) { ++ case CLZ_W: { ++ printf_instr("CLZ_W\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ alu_out = base::bits::CountLeadingZeros32(static_cast(rj_u())); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case CTZ_W: { ++ printf_instr("CTZ_W\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ alu_out = base::bits::CountTrailingZeros32(static_cast(rj_u())); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case CLZ_D: { ++ printf_instr("CLZ_D\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ alu_out = base::bits::CountLeadingZeros64(static_cast(rj_u())); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case CTZ_D: { ++ printf_instr("CTZ_D\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ alu_out = base::bits::CountTrailingZeros64(static_cast(rj_u())); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVB_2H: { ++ printf_instr("REVB_2H\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint32_t input = static_cast(rj()); ++ uint64_t output = 0; ++ ++ uint32_t mask = 0xFF000000; ++ for (int i = 0; i < 4; i++) { ++ uint32_t tmp = mask & input; ++ if (i % 2 == 0) { ++ tmp = tmp >> 8; ++ } else { ++ tmp = tmp << 8; ++ } ++ output = output | tmp; ++ mask = mask >> 8; ++ } ++ ++ alu_out = static_cast(static_cast(output)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVB_4H: { ++ printf_instr("REVB_4H\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ ++ uint64_t mask = 0xFF00000000000000; ++ for (int i = 0; i < 8; i++) { ++ uint64_t tmp = mask & input; ++ if (i % 2 == 0) { ++ tmp = tmp >> 8; ++ } else { ++ tmp = tmp << 8; ++ } ++ output = output | tmp; ++ mask = mask >> 8; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVB_2W: { ++ printf_instr("REVB_2W\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ ++ uint64_t mask = 0xFF000000FF000000; ++ for (int i = 0; i < 4; i++) { ++ uint64_t tmp = mask & input; ++ if (i <= 1) { ++ tmp = tmp >> (24 - i * 16); ++ } else { ++ tmp = tmp << (i * 16 - 24); ++ } ++ output = output | tmp; ++ mask = mask >> 8; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVB_D: { ++ printf_instr("REVB_D\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ ++ uint64_t mask = 0xFF00000000000000; ++ for (int i = 0; i < 8; i++) { ++ uint64_t tmp = mask & input; ++ if (i <= 3) { ++ tmp = tmp >> (56 - i * 16); ++ } else { ++ tmp = tmp << (i * 16 - 56); ++ } ++ output = output | tmp; ++ mask = mask >> 8; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVH_2W: { ++ printf_instr("REVH_2W\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ ++ uint64_t mask = 0xFFFF000000000000; ++ for (int i = 0; i < 4; i++) { ++ uint64_t tmp = mask & input; ++ if (i % 2 == 0) { ++ tmp = tmp >> 16; ++ } else { ++ tmp = tmp << 16; ++ } ++ output = output | tmp; ++ mask = mask >> 16; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case REVH_D: { ++ printf_instr("REVH_D\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ ++ uint64_t mask = 0xFFFF000000000000; ++ for (int i = 0; i < 4; i++) { ++ uint64_t tmp = mask & input; ++ if (i <= 1) { ++ tmp = tmp >> (48 - i * 32); ++ } else { ++ tmp = tmp << (i * 32 - 48); ++ } ++ output = output | tmp; ++ mask = mask >> 16; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BITREV_4B: { ++ printf_instr("BITREV_4B\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint32_t input = static_cast(rj()); ++ uint32_t output = 0; ++ uint8_t i_byte, o_byte; ++ ++ // Reverse the bit in byte for each individual byte ++ for (int i = 0; i < 4; i++) { ++ output = output >> 8; ++ i_byte = input & 0xFF; ++ ++ // Fast way to reverse bits in byte ++ // Devised by Sean Anderson, July 13, 2001 ++ o_byte = static_cast(((i_byte * 0x0802LU & 0x22110LU) | ++ (i_byte * 0x8020LU & 0x88440LU)) * ++ 0x10101LU >> ++ 16); ++ ++ output = output | (static_cast(o_byte << 24)); ++ input = input >> 8; ++ } ++ ++ alu_out = static_cast(static_cast(output)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BITREV_8B: { ++ printf_instr("BITREV_8B\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint64_t input = rj_u(); ++ uint64_t output = 0; ++ uint8_t i_byte, o_byte; ++ ++ // Reverse the bit in byte for each individual byte ++ for (int i = 0; i < 8; i++) { ++ output = output >> 8; ++ i_byte = input & 0xFF; ++ ++ // Fast way to reverse bits in byte ++ // Devised by Sean Anderson, July 13, 2001 ++ o_byte = static_cast(((i_byte * 0x0802LU & 0x22110LU) | ++ (i_byte * 0x8020LU & 0x88440LU)) * ++ 0x10101LU >> ++ 16); ++ ++ output = output | (static_cast(o_byte) << 56); ++ input = input >> 8; ++ } ++ ++ alu_out = static_cast(output); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BITREV_W: { ++ printf_instr("BITREV_W\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint32_t input = static_cast(rj()); ++ uint32_t output = 0; ++ output = base::bits::ReverseBits(input); ++ alu_out = static_cast(static_cast(output)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case BITREV_D: { ++ printf_instr("BITREV_D\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ alu_out = static_cast(base::bits::ReverseBits(rj_u())); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case EXT_W_B: { ++ printf_instr("EXT_W_B\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint8_t input = static_cast(rj()); ++ alu_out = static_cast(static_cast(input)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case EXT_W_H: { ++ printf_instr("EXT_W_H\t %s: %016lx, %s, %016lx\n", ++ Registers::Name(rd_reg()), rd(), Registers::Name(rj_reg()), ++ rj()); ++ uint16_t input = static_cast(rj()); ++ alu_out = static_cast(static_cast(input)); ++ SetResult(rd_reg(), alu_out); ++ break; ++ } ++ case FABS_S: ++ printf_instr("FABS_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), std::abs(fj_float())); ++ break; ++ case FABS_D: ++ printf_instr("FABS_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), std::abs(fj_double())); ++ break; ++ case FNEG_S: ++ printf_instr("FNEG_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), -fj_float()); ++ break; ++ case FNEG_D: ++ printf_instr("FNEG_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUDoubleResult(fd_reg(), -fj_double()); ++ break; ++ case FSQRT_S: { ++ printf_instr("FSQRT_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ if (fj_float() >= 0) { ++ SetFPUFloatResult(fd_reg(), std::sqrt(fj_float())); ++ } else { ++ SetFPUFloatResult(fd_reg(), std::sqrt(-1)); // qnan ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ } ++ break; ++ } ++ case FSQRT_D: { ++ printf_instr("FSQRT_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ if (fj_double() >= 0) { ++ SetFPUDoubleResult(fd_reg(), std::sqrt(fj_double())); ++ } else { ++ SetFPUDoubleResult(fd_reg(), std::sqrt(-1)); // qnan ++ set_fcsr_bit(kFCSRInvalidOpFlagBit, true); ++ } ++ break; ++ } ++ case FMOV_S: ++ printf_instr("FMOV_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUFloatResult(fd_reg(), fj_float()); ++ break; ++ case FMOV_D: ++ printf_instr("FMOV_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_float(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUDoubleResult(fd_reg(), fj_double()); ++ break; ++ case MOVGR2FR_W: { ++ printf_instr("MOVGR2FR_W\t %s: %016f, %s, %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj()); ++ set_fpu_register_word(fd_reg(), static_cast(rj())); ++ TraceRegWr(get_fpu_register(fd_reg()), FLOAT_DOUBLE); ++ break; ++ } ++ case MOVGR2FR_D: ++ printf_instr("MOVGR2FR_D\t %s: %016f, %s, %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj()); ++ SetFPUResult2(fd_reg(), rj()); ++ break; ++ case MOVGR2FRH_W: { ++ printf_instr("MOVGR2FRH_W\t %s: %016f, %s, %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ Registers::Name(rj_reg()), rj()); ++ set_fpu_register_hi_word(fd_reg(), static_cast(rj())); ++ TraceRegWr(get_fpu_register(fd_reg()), DOUBLE); ++ break; ++ } ++ case MOVFR2GR_S: { ++ printf_instr("MOVFR2GR_S\t %s: %016lx, %s, %016f\n", ++ Registers::Name(rd_reg()), rd(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ set_register(rd_reg(), ++ static_cast(get_fpu_register_word(fj_reg()))); ++ TraceRegWr(get_register(rd_reg()), WORD_DWORD); ++ break; ++ } ++ case MOVFR2GR_D: ++ printf_instr("MOVFR2GR_D\t %s: %016lx, %s, %016f\n", ++ Registers::Name(rd_reg()), rd(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetResult(rd_reg(), get_fpu_register(fj_reg())); ++ break; ++ case MOVFRH2GR_S: ++ printf_instr("MOVFRH2GR_S\t %s: %016lx, %s, %016f\n", ++ Registers::Name(rd_reg()), rd(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetResult(rd_reg(), get_fpu_register_hi_word(fj_reg())); ++ break; ++ case MOVGR2FCSR: { ++ printf_instr("MOVGR2FCSR\t fcsr: %016x, %s, %016lx\n", FCSR_, ++ Registers::Name(rj_reg()), rj()); ++ // fcsr could be 0-3 ++ CHECK_LT(rd_reg(), 4); ++ FCSR_ = static_cast(rj()); ++ TraceRegWr(FCSR_); ++ break; ++ } ++ case MOVFCSR2GR: { ++ printf_instr("MOVFCSR2GR\t %s, %016lx, FCSR: %016x\n", ++ Registers::Name(rd_reg()), rd(), FCSR_); ++ // fcsr could be 0-3 ++ CHECK_LT(rj_reg(), 4); ++ SetResult(rd_reg(), FCSR_); ++ break; ++ } ++ case FCVT_S_D: ++ printf_instr("FCVT_S_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ SetFPUFloatResult(fd_reg(), static_cast(fj_double())); ++ break; ++ case FCVT_D_S: ++ printf_instr("FCVT_D_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ SetFPUDoubleResult(fd_reg(), static_cast(fj_float())); ++ break; ++ case FTINTRM_W_S: { ++ printf_instr("FTINTRM_W_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::floor(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRM_W_D: { ++ printf_instr("FTINTRM_W_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::floor(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRM_L_S: { ++ printf_instr("FTINTRM_L_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::floor(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRM_L_D: { ++ printf_instr("FTINTRM_L_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::floor(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRP_W_S: { ++ printf_instr("FTINTRP_W_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::ceil(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRP_W_D: { ++ printf_instr("FTINTRP_W_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::ceil(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRP_L_S: { ++ printf_instr("FTINTRP_L_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::ceil(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRP_L_D: { ++ printf_instr("FTINTRP_L_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::ceil(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRZ_W_S: { ++ printf_instr("FTINTRZ_W_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::trunc(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRZ_W_D: { ++ printf_instr("FTINTRZ_W_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::trunc(fj); ++ int32_t result = static_cast(rounded); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRZ_L_S: { ++ printf_instr("FTINTRZ_L_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::trunc(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRZ_L_D: { ++ printf_instr("FTINTRZ_L_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::trunc(fj); ++ int64_t result = static_cast(rounded); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRNE_W_S: { ++ printf_instr("FTINTRNE_W_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::floor(fj + 0.5); ++ int32_t result = static_cast(rounded); ++ if ((result & 1) != 0 && result - fj == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ result--; ++ } ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRNE_W_D: { ++ printf_instr("FTINTRNE_W_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::floor(fj + 0.5); ++ int32_t result = static_cast(rounded); ++ if ((result & 1) != 0 && result - fj == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ result--; ++ } ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRNE_L_S: { ++ printf_instr("FTINTRNE_L_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded = std::floor(fj + 0.5); ++ int64_t result = static_cast(rounded); ++ if ((result & 1) != 0 && result - fj == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ result--; ++ } ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINTRNE_L_D: { ++ printf_instr("FTINTRNE_L_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded = std::floor(fj + 0.5); ++ int64_t result = static_cast(rounded); ++ if ((result & 1) != 0 && result - fj == 0.5) { ++ // If the number is halfway between two integers, ++ // round to the even one. ++ result--; ++ } ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINT_W_S: { ++ printf_instr("FTINT_W_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded; ++ int32_t result; ++ round_according_to_fcsr(fj, &rounded, &result); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINT_W_D: { ++ printf_instr("FTINT_W_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded; ++ int32_t result; ++ round_according_to_fcsr(fj, &rounded, &result); ++ SetFPUWordResult(fd_reg(), result); ++ if (set_fcsr_round_error(fj, rounded)) { ++ set_fpu_register_word_invalid_result(fj, rounded); ++ } ++ break; ++ } ++ case FTINT_L_S: { ++ printf_instr("FTINT_L_S\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float rounded; ++ int64_t result; ++ round64_according_to_fcsr(fj, &rounded, &result); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FTINT_L_D: { ++ printf_instr("FTINT_L_D\t %s: %016f, %s, %016f\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double rounded; ++ int64_t result; ++ round64_according_to_fcsr(fj, &rounded, &result); ++ SetFPUResult(fd_reg(), result); ++ if (set_fcsr_round64_error(fj, rounded)) { ++ set_fpu_register_invalid_result64(fj, rounded); ++ } ++ break; ++ } ++ case FFINT_S_W: { ++ alu_out = get_fpu_register_signed_word(fj_reg()); ++ printf_instr("FFINT_S_W\t %s: %016f, %s, %016x\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), (int)alu_out); ++ SetFPUFloatResult(fd_reg(), static_cast(alu_out)); ++ break; ++ } ++ case FFINT_S_L: { ++ alu_out = get_fpu_register(fj_reg()); ++ printf_instr("FFINT_S_L\t %s: %016f, %s, %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), alu_out); ++ SetFPUFloatResult(fd_reg(), static_cast(alu_out)); ++ break; ++ } ++ case FFINT_D_W: { ++ alu_out = get_fpu_register_signed_word(fj_reg()); ++ printf_instr("FFINT_D_W\t %s: %016f, %s, %016x\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), (int)alu_out); ++ SetFPUDoubleResult(fd_reg(), static_cast(alu_out)); ++ break; ++ } ++ case FFINT_D_L: { ++ alu_out = get_fpu_register(fj_reg()); ++ printf_instr("FFINT_D_L\t %s: %016f, %s, %016lx\n", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), alu_out); ++ SetFPUDoubleResult(fd_reg(), static_cast(alu_out)); ++ break; ++ } ++ case FRINT_S: { ++ printf_instr("FRINT_S\t %s: %016f, %s, %016f mode : ", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_float()); ++ float fj = fj_float(); ++ float result, temp_result; ++ double temp; ++ float upper = std::ceil(fj); ++ float lower = std::floor(fj); ++ switch (get_fcsr_rounding_mode()) { ++ case kRoundToNearest: ++ printf_instr(" kRoundToNearest\n"); ++ if (upper - fj < fj - lower) { ++ result = upper; ++ } else if (upper - fj > fj - lower) { ++ result = lower; ++ } else { ++ temp_result = upper / 2; ++ float reminder = std::modf(temp_result, &temp); ++ if (reminder == 0) { ++ result = upper; ++ } else { ++ result = lower; ++ } ++ } ++ break; ++ case kRoundToZero: ++ printf_instr(" kRoundToZero\n"); ++ result = (fj > 0 ? lower : upper); ++ break; ++ case kRoundToPlusInf: ++ printf_instr(" kRoundToPlusInf\n"); ++ result = upper; ++ break; ++ case kRoundToMinusInf: ++ printf_instr(" kRoundToMinusInf\n"); ++ result = lower; ++ break; ++ } ++ SetFPUFloatResult(fd_reg(), result); ++ if (result != fj) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ break; ++ } ++ case FRINT_D: { ++ printf_instr("FRINT_D\t %s: %016f, %s, %016f mode : ", ++ FPURegisters::Name(fd_reg()), fd_double(), ++ FPURegisters::Name(fj_reg()), fj_double()); ++ double fj = fj_double(); ++ double result, temp, temp_result; ++ double upper = std::ceil(fj); ++ double lower = std::floor(fj); ++ switch (get_fcsr_rounding_mode()) { ++ case kRoundToNearest: ++ printf_instr(" kRoundToNearest\n"); ++ if (upper - fj < fj - lower) { ++ result = upper; ++ } else if (upper - fj > fj - lower) { ++ result = lower; ++ } else { ++ temp_result = upper / 2; ++ double reminder = std::modf(temp_result, &temp); ++ if (reminder == 0) { ++ result = upper; ++ } else { ++ result = lower; ++ } ++ } ++ break; ++ case kRoundToZero: ++ printf_instr(" kRoundToZero\n"); ++ result = (fj > 0 ? lower : upper); ++ break; ++ case kRoundToPlusInf: ++ printf_instr(" kRoundToPlusInf\n"); ++ result = upper; ++ break; ++ case kRoundToMinusInf: ++ printf_instr(" kRoundToMinusInf\n"); ++ result = lower; ++ break; ++ } ++ SetFPUDoubleResult(fd_reg(), result); ++ if (result != fj) { ++ set_fcsr_bit(kFCSRInexactFlagBit, true); ++ } ++ break; ++ } ++ case MOVFR2CF: ++ printf("Sim UNIMPLEMENTED: MOVFR2CF\n"); ++ UNIMPLEMENTED(); ++ break; ++ case MOVCF2FR: ++ printf("Sim UNIMPLEMENTED: MOVCF2FR\n"); ++ UNIMPLEMENTED(); ++ break; ++ case MOVGR2CF: ++ printf_instr("MOVGR2CF\t FCC%d, %s: %016lx\n", cd_reg(), ++ Registers::Name(rj_reg()), rj()); ++ set_cf_register(cd_reg(), rj() & 1); ++ break; ++ case MOVCF2GR: ++ printf_instr("MOVCF2GR\t %s: %016lx, FCC%d\n", Registers::Name(rd_reg()), ++ rd(), cj_reg()); ++ SetResult(rd_reg(), cj()); ++ break; ++ case FRECIP_S: ++ printf("Sim UNIMPLEMENTED: FRECIP_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FRECIP_D: ++ printf("Sim UNIMPLEMENTED: FRECIP_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FRSQRT_S: ++ printf("Sim UNIMPLEMENTED: FRSQRT_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FRSQRT_D: ++ printf("Sim UNIMPLEMENTED: FRSQRT_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FCLASS_S: ++ printf("Sim UNIMPLEMENTED: FCLASS_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FCLASS_D: ++ printf("Sim UNIMPLEMENTED: FCLASS_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FLOGB_S: ++ printf("Sim UNIMPLEMENTED: FLOGB_S\n"); ++ UNIMPLEMENTED(); ++ break; ++ case FLOGB_D: ++ printf("Sim UNIMPLEMENTED: FLOGB_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case CLO_W: ++ printf("Sim UNIMPLEMENTED: CLO_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case CTO_W: ++ printf("Sim UNIMPLEMENTED: CTO_W\n"); ++ UNIMPLEMENTED(); ++ break; ++ case CLO_D: ++ printf("Sim UNIMPLEMENTED: CLO_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ case CTO_D: ++ printf("Sim UNIMPLEMENTED: CTO_D\n"); ++ UNIMPLEMENTED(); ++ break; ++ // Unimplemented opcodes raised an error in the configuration step before, ++ // so we can use the default here to set the destination register in common ++ // cases. ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++// Executes the current instruction. ++void Simulator::InstructionDecode(Instruction* instr) { ++ if (v8::internal::FLAG_check_icache) { ++ CheckICache(i_cache(), instr); ++ } ++ pc_modified_ = false; ++ ++ v8::internal::EmbeddedVector buffer; ++ ++ if (::v8::internal::FLAG_trace_sim) { ++ SNPrintF(trace_buf_, " "); ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ dasm.InstructionDecode(buffer, reinterpret_cast(instr)); ++ } ++ ++ static int instr_count = 0; ++ USE(instr_count); ++ instr_ = instr; ++ printf_instr("\nInstr%3d: %08x, PC: %016lx\t", instr_count++, ++ instr_.Bits(31, 0), get_pc()); ++ switch (instr_.InstructionType()) { ++ case Instruction::kOp6Type: ++ DecodeTypeOp6(); ++ break; ++ case Instruction::kOp7Type: ++ DecodeTypeOp7(); ++ break; ++ case Instruction::kOp8Type: ++ DecodeTypeOp8(); ++ break; ++ case Instruction::kOp10Type: ++ DecodeTypeOp10(); ++ break; ++ case Instruction::kOp12Type: ++ DecodeTypeOp12(); ++ break; ++ case Instruction::kOp14Type: ++ DecodeTypeOp14(); ++ break; ++ case Instruction::kOp17Type: ++ DecodeTypeOp17(); ++ break; ++ case Instruction::kOp22Type: ++ DecodeTypeOp22(); ++ break; ++ default: { ++ printf("instr_: %x\n", instr_.Bits(31, 0)); ++ UNREACHABLE(); ++ } ++ } ++ ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF(" 0x%08" PRIxPTR " %-44s %s\n", ++ reinterpret_cast(instr), buffer.begin(), ++ trace_buf_.begin()); ++ } ++ ++ if (!pc_modified_) { ++ set_register(pc, reinterpret_cast(instr) + kInstrSize); ++ } ++} ++ ++void Simulator::Execute() { ++ // Get the PC to simulate. Cannot use the accessor here as we need the ++ // raw PC value and not the one used as input to arithmetic instructions. ++ int64_t program_counter = get_pc(); ++ if (::v8::internal::FLAG_stop_sim_at == 0) { ++ // Fast version of the dispatch loop without checking whether the simulator ++ // should be stopping at a particular executed instruction. ++ while (program_counter != end_sim_pc) { ++ Instruction* instr = reinterpret_cast(program_counter); ++ icount_++; ++ InstructionDecode(instr); ++ program_counter = get_pc(); ++ } ++ } else { ++ // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when ++ // we reach the particular instruction count. ++ while (program_counter != end_sim_pc) { ++ Instruction* instr = reinterpret_cast(program_counter); ++ icount_++; ++ if (icount_ == static_cast(::v8::internal::FLAG_stop_sim_at)) { ++ La64Debugger dbg(this); ++ dbg.Debug(); ++ } else { ++ InstructionDecode(instr); ++ } ++ program_counter = get_pc(); ++ } ++ } ++} ++ ++void Simulator::CallInternal(Address entry) { ++ // Adjust JS-based stack limit to C-based stack limit. ++ isolate_->stack_guard()->AdjustStackLimitForSimulator(); ++ ++ // Prepare to execute the code at entry. ++ set_register(pc, static_cast(entry)); ++ // Put down marker for end of simulation. The simulator will stop simulation ++ // when the PC reaches this value. By saving the "end simulation" value into ++ // the LR the simulation stops when returning to this call point. ++ set_register(ra, end_sim_pc); ++ ++ // Remember the values of callee-saved registers. ++ int64_t s0_val = get_register(s0); ++ int64_t s1_val = get_register(s1); ++ int64_t s2_val = get_register(s2); ++ int64_t s3_val = get_register(s3); ++ int64_t s4_val = get_register(s4); ++ int64_t s5_val = get_register(s5); ++ int64_t s6_val = get_register(s6); ++ int64_t s7_val = get_register(s7); ++ int64_t s8_val = get_register(s8); ++ int64_t gp_val = get_register(gp); ++ int64_t sp_val = get_register(sp); ++ int64_t tp_val = get_register(tp); ++ int64_t fp_val = get_register(fp); ++ ++ // Set up the callee-saved registers with a known value. To be able to check ++ // that they are preserved properly across JS execution. ++ int64_t callee_saved_value = icount_; ++ set_register(s0, callee_saved_value); ++ set_register(s1, callee_saved_value); ++ set_register(s2, callee_saved_value); ++ set_register(s3, callee_saved_value); ++ set_register(s4, callee_saved_value); ++ set_register(s5, callee_saved_value); ++ set_register(s6, callee_saved_value); ++ set_register(s7, callee_saved_value); ++ set_register(s8, callee_saved_value); ++ set_register(gp, callee_saved_value); ++ set_register(tp, callee_saved_value); ++ set_register(fp, callee_saved_value); ++ ++ // Start the simulation. ++ Execute(); ++ ++ // Check that the callee-saved registers have been preserved. ++ CHECK_EQ(callee_saved_value, get_register(s0)); ++ CHECK_EQ(callee_saved_value, get_register(s1)); ++ CHECK_EQ(callee_saved_value, get_register(s2)); ++ CHECK_EQ(callee_saved_value, get_register(s3)); ++ CHECK_EQ(callee_saved_value, get_register(s4)); ++ CHECK_EQ(callee_saved_value, get_register(s5)); ++ CHECK_EQ(callee_saved_value, get_register(s6)); ++ CHECK_EQ(callee_saved_value, get_register(s7)); ++ CHECK_EQ(callee_saved_value, get_register(s8)); ++ CHECK_EQ(callee_saved_value, get_register(gp)); ++ CHECK_EQ(callee_saved_value, get_register(tp)); ++ CHECK_EQ(callee_saved_value, get_register(fp)); ++ ++ // Restore callee-saved registers with the original value. ++ set_register(s0, s0_val); ++ set_register(s1, s1_val); ++ set_register(s2, s2_val); ++ set_register(s3, s3_val); ++ set_register(s4, s4_val); ++ set_register(s5, s5_val); ++ set_register(s6, s6_val); ++ set_register(s7, s7_val); ++ set_register(s8, s8_val); ++ set_register(gp, gp_val); ++ set_register(sp, sp_val); ++ set_register(tp, tp_val); ++ set_register(fp, fp_val); ++} ++ ++intptr_t Simulator::CallImpl(Address entry, int argument_count, ++ const intptr_t* arguments) { ++ constexpr int kRegisterPassedArguments = 8; ++ // Set up arguments. ++ ++ int reg_arg_count = std::min(kRegisterPassedArguments, argument_count); ++ if (reg_arg_count > 0) set_register(a0, arguments[0]); ++ if (reg_arg_count > 1) set_register(a1, arguments[1]); ++ if (reg_arg_count > 2) set_register(a2, arguments[2]); ++ if (reg_arg_count > 3) set_register(a3, arguments[3]); ++ if (reg_arg_count > 4) set_register(a4, arguments[4]); ++ if (reg_arg_count > 5) set_register(a5, arguments[5]); ++ if (reg_arg_count > 6) set_register(a6, arguments[6]); ++ if (reg_arg_count > 7) set_register(a7, arguments[7]); ++ ++ // Remaining arguments passed on stack. ++ int64_t original_stack = get_register(sp); ++ // Compute position of stack on entry to generated code. ++ int stack_args_count = argument_count - reg_arg_count; ++ int stack_args_size = stack_args_count * sizeof(*arguments) + kCArgsSlotsSize; ++ int64_t entry_stack = original_stack - stack_args_size; ++ ++ if (base::OS::ActivationFrameAlignment() != 0) { ++ entry_stack &= -base::OS::ActivationFrameAlignment(); ++ } ++ // Store remaining arguments on stack, from low to high memory. ++ intptr_t* stack_argument = reinterpret_cast(entry_stack); ++ memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count, ++ stack_args_count * sizeof(*arguments)); ++ set_register(sp, entry_stack); ++ ++ CallInternal(entry); ++ ++ // Pop stack passed arguments. ++ CHECK_EQ(entry_stack, get_register(sp)); ++ set_register(sp, original_stack); ++ ++ return get_register(v0); ++} ++ ++double Simulator::CallFP(Address entry, double d0, double d1) { ++ const FPURegister fparg2 = f1; ++ set_fpu_register_double(f0, d0); ++ set_fpu_register_double(fparg2, d1); ++ CallInternal(entry); ++ return get_fpu_register_double(f0); ++} ++ ++uintptr_t Simulator::PushAddress(uintptr_t address) { ++ int64_t new_sp = get_register(sp) - sizeof(uintptr_t); ++ uintptr_t* stack_slot = reinterpret_cast(new_sp); ++ *stack_slot = address; ++ set_register(sp, new_sp); ++ return new_sp; ++} ++ ++uintptr_t Simulator::PopAddress() { ++ int64_t current_sp = get_register(sp); ++ uintptr_t* stack_slot = reinterpret_cast(current_sp); ++ uintptr_t address = *stack_slot; ++ set_register(sp, current_sp + sizeof(uintptr_t)); ++ return address; ++} ++ ++Simulator::LocalMonitor::LocalMonitor() ++ : access_state_(MonitorAccess::Open), ++ tagged_addr_(0), ++ size_(TransactionSize::None) {} ++ ++void Simulator::LocalMonitor::Clear() { ++ access_state_ = MonitorAccess::Open; ++ tagged_addr_ = 0; ++ size_ = TransactionSize::None; ++} ++ ++void Simulator::LocalMonitor::NotifyLoad() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non linked load could clear the local monitor. As a result, it's ++ // most strict to unconditionally clear the local monitor on load. ++ Clear(); ++ } ++} ++ ++void Simulator::LocalMonitor::NotifyLoadLinked(uintptr_t addr, ++ TransactionSize size) { ++ access_state_ = MonitorAccess::RMW; ++ tagged_addr_ = addr; ++ size_ = size; ++} ++ ++void Simulator::LocalMonitor::NotifyStore() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non exclusive store could clear the local monitor. As a result, it's ++ // most strict to unconditionally clear the local monitor on store. ++ Clear(); ++ } ++} ++ ++bool Simulator::LocalMonitor::NotifyStoreConditional(uintptr_t addr, ++ TransactionSize size) { ++ if (access_state_ == MonitorAccess::RMW) { ++ if (addr == tagged_addr_ && size_ == size) { ++ Clear(); ++ return true; ++ } else { ++ return false; ++ } ++ } else { ++ DCHECK(access_state_ == MonitorAccess::Open); ++ return false; ++ } ++} ++ ++Simulator::GlobalMonitor::LinkedAddress::LinkedAddress() ++ : access_state_(MonitorAccess::Open), ++ tagged_addr_(0), ++ next_(nullptr), ++ prev_(nullptr), ++ failure_counter_(0) {} ++ ++void Simulator::GlobalMonitor::LinkedAddress::Clear_Locked() { ++ access_state_ = MonitorAccess::Open; ++ tagged_addr_ = 0; ++} ++ ++void Simulator::GlobalMonitor::LinkedAddress::NotifyLoadLinked_Locked( ++ uintptr_t addr) { ++ access_state_ = MonitorAccess::RMW; ++ tagged_addr_ = addr; ++} ++ ++void Simulator::GlobalMonitor::LinkedAddress::NotifyStore_Locked() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non exclusive store could clear the global monitor. As a result, it's ++ // most strict to unconditionally clear global monitors on store. ++ Clear_Locked(); ++ } ++} ++ ++bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked( ++ uintptr_t addr, bool is_requesting_thread) { ++ if (access_state_ == MonitorAccess::RMW) { ++ if (is_requesting_thread) { ++ if (addr == tagged_addr_) { ++ Clear_Locked(); ++ // Introduce occasional sc/scd failures. This is to simulate the ++ // behavior of hardware, which can randomly fail due to background ++ // cache evictions. ++ if (failure_counter_++ >= kMaxFailureCounter) { ++ failure_counter_ = 0; ++ return false; ++ } else { ++ return true; ++ } ++ } ++ } else if ((addr & kExclusiveTaggedAddrMask) == ++ (tagged_addr_ & kExclusiveTaggedAddrMask)) { ++ // Check the masked addresses when responding to a successful lock by ++ // another thread so the implementation is more conservative (i.e. the ++ // granularity of locking is as large as possible.) ++ Clear_Locked(); ++ return false; ++ } ++ } ++ return false; ++} ++ ++void Simulator::GlobalMonitor::NotifyLoadLinked_Locked( ++ uintptr_t addr, LinkedAddress* linked_address) { ++ linked_address->NotifyLoadLinked_Locked(addr); ++ PrependProcessor_Locked(linked_address); ++} ++ ++void Simulator::GlobalMonitor::NotifyStore_Locked( ++ LinkedAddress* linked_address) { ++ // Notify each thread of the store operation. ++ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { ++ iter->NotifyStore_Locked(); ++ } ++} ++ ++bool Simulator::GlobalMonitor::NotifyStoreConditional_Locked( ++ uintptr_t addr, LinkedAddress* linked_address) { ++ DCHECK(IsProcessorInLinkedList_Locked(linked_address)); ++ if (linked_address->NotifyStoreConditional_Locked(addr, true)) { ++ // Notify the other processors that this StoreConditional succeeded. ++ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { ++ if (iter != linked_address) { ++ iter->NotifyStoreConditional_Locked(addr, false); ++ } ++ } ++ return true; ++ } else { ++ return false; ++ } ++} ++ ++bool Simulator::GlobalMonitor::IsProcessorInLinkedList_Locked( ++ LinkedAddress* linked_address) const { ++ return head_ == linked_address || linked_address->next_ || ++ linked_address->prev_; ++} ++ ++void Simulator::GlobalMonitor::PrependProcessor_Locked( ++ LinkedAddress* linked_address) { ++ if (IsProcessorInLinkedList_Locked(linked_address)) { ++ return; ++ } ++ ++ if (head_) { ++ head_->prev_ = linked_address; ++ } ++ linked_address->prev_ = nullptr; ++ linked_address->next_ = head_; ++ head_ = linked_address; ++} ++ ++void Simulator::GlobalMonitor::RemoveLinkedAddress( ++ LinkedAddress* linked_address) { ++ base::MutexGuard lock_guard(&mutex); ++ if (!IsProcessorInLinkedList_Locked(linked_address)) { ++ return; ++ } ++ ++ if (linked_address->prev_) { ++ linked_address->prev_->next_ = linked_address->next_; ++ } else { ++ head_ = linked_address->next_; ++ } ++ if (linked_address->next_) { ++ linked_address->next_->prev_ = linked_address->prev_; ++ } ++ linked_address->prev_ = nullptr; ++ linked_address->next_ = nullptr; ++} ++ ++#undef SScanF ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // USE_SIMULATOR +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/loongarch64/simulator-loongarch64.h +@@ -0,0 +1,646 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Declares a Simulator for loongisa instructions if we are not generating a ++// native loongisa binary. This Simulator allows us to run and debug loongisa ++// code generation on regular desktop machines. V8 calls into generated code via ++// the GeneratedCode wrapper, which will start execution in the Simulator or ++// forwards to the real entry on a loongisa HW platform. ++ ++#ifndef V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ ++#define V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ ++ ++// globals.h defines USE_SIMULATOR. ++#include "src/common/globals.h" ++ ++template ++int Compare(const T& a, const T& b) { ++ if (a == b) ++ return 0; ++ else if (a < b) ++ return -1; ++ else ++ return 1; ++} ++ ++// Returns the negative absolute value of its argument. ++template ::value>::type> ++T Nabs(T a) { ++ return a < 0 ? a : -a; ++} ++ ++#if defined(USE_SIMULATOR) ++// Running with a simulator. ++ ++#include "src/base/hashmap.h" ++#include "src/codegen/assembler.h" ++#include "src/codegen/loongarch64/constants-loongarch64.h" ++#include "src/execution/simulator-base.h" ++#include "src/utils/allocation.h" ++ ++namespace v8 { ++namespace internal { ++ ++// ----------------------------------------------------------------------------- ++// Utility functions ++ ++class CachePage { ++ public: ++ static const int LINE_VALID = 0; ++ static const int LINE_INVALID = 1; ++ ++ static const int kPageShift = 12; ++ static const int kPageSize = 1 << kPageShift; ++ static const int kPageMask = kPageSize - 1; ++ static const int kLineShift = 2; // The cache line is only 4 bytes right now. ++ static const int kLineLength = 1 << kLineShift; ++ static const int kLineMask = kLineLength - 1; ++ ++ CachePage() { memset(&validity_map_, LINE_INVALID, sizeof(validity_map_)); } ++ ++ char* ValidityByte(int offset) { ++ return &validity_map_[offset >> kLineShift]; ++ } ++ ++ char* CachedData(int offset) { return &data_[offset]; } ++ ++ private: ++ char data_[kPageSize]; // The cached data. ++ static const int kValidityMapSize = kPageSize >> kLineShift; ++ char validity_map_[kValidityMapSize]; // One byte per line. ++}; ++ ++class SimInstructionBase : public InstructionBase { ++ public: ++ Type InstructionType() const { return type_; } ++ inline Instruction* instr() const { return instr_; } ++ inline int32_t operand() const { return operand_; } ++ ++ protected: ++ SimInstructionBase() : operand_(-1), instr_(nullptr), type_(kUnsupported) {} ++ explicit SimInstructionBase(Instruction* instr) {} ++ ++ int32_t operand_; ++ Instruction* instr_; ++ Type type_; ++ ++ private: ++ DISALLOW_ASSIGN(SimInstructionBase); ++}; ++ ++class SimInstruction : public InstructionGetters { ++ public: ++ SimInstruction() {} ++ ++ explicit SimInstruction(Instruction* instr) { *this = instr; } ++ ++ SimInstruction& operator=(Instruction* instr) { ++ operand_ = *reinterpret_cast(instr); ++ instr_ = instr; ++ type_ = InstructionBase::InstructionType(); ++ DCHECK(reinterpret_cast(&operand_) == this); ++ return *this; ++ } ++}; ++ ++class Simulator : public SimulatorBase { ++ public: ++ friend class La64Debugger; ++ ++ // Registers are declared in order. ++ enum Register { ++ no_reg = -1, ++ zero_reg = 0, ++ ra, ++ gp, ++ sp, ++ a0, ++ a1, ++ a2, ++ a3, ++ a4, ++ a5, ++ a6, ++ a7, ++ t0, ++ t1, ++ t2, ++ t3, ++ t4, ++ t5, ++ t6, ++ t7, ++ t8, ++ tp, ++ fp, ++ s0, ++ s1, ++ s2, ++ s3, ++ s4, ++ s5, ++ s6, ++ s7, ++ s8, ++ pc, // pc must be the last register. ++ kNumSimuRegisters, ++ // aliases ++ v0 = a0, ++ v1 = a1 ++ }; ++ ++ // Condition flag registers. ++ enum CFRegister { ++ fcc0, ++ fcc1, ++ fcc2, ++ fcc3, ++ fcc4, ++ fcc5, ++ fcc6, ++ fcc7, ++ kNumCFRegisters ++ }; ++ ++ // Floating point registers. ++ enum FPURegister { ++ f0, ++ f1, ++ f2, ++ f3, ++ f4, ++ f5, ++ f6, ++ f7, ++ f8, ++ f9, ++ f10, ++ f11, ++ f12, ++ f13, ++ f14, ++ f15, ++ f16, ++ f17, ++ f18, ++ f19, ++ f20, ++ f21, ++ f22, ++ f23, ++ f24, ++ f25, ++ f26, ++ f27, ++ f28, ++ f29, ++ f30, ++ f31, ++ kNumFPURegisters ++ }; ++ ++ explicit Simulator(Isolate* isolate); ++ ~Simulator(); ++ ++ // The currently executing Simulator instance. Potentially there can be one ++ // for each native thread. ++ V8_EXPORT_PRIVATE static Simulator* current(v8::internal::Isolate* isolate); ++ ++ // Accessors for register state. Reading the pc value adheres to the LA64 ++ // architecture specification and is off by a 8 from the currently executing ++ // instruction. ++ void set_register(int reg, int64_t value); ++ void set_register_word(int reg, int32_t value); ++ void set_dw_register(int dreg, const int* dbl); ++ int64_t get_register(int reg) const; ++ double get_double_from_register_pair(int reg); ++ // Same for FPURegisters. ++ void set_fpu_register(int fpureg, int64_t value); ++ void set_fpu_register_word(int fpureg, int32_t value); ++ void set_fpu_register_hi_word(int fpureg, int32_t value); ++ void set_fpu_register_float(int fpureg, float value); ++ void set_fpu_register_double(int fpureg, double value); ++ void set_fpu_register_invalid_result64(float original, float rounded); ++ void set_fpu_register_invalid_result(float original, float rounded); ++ void set_fpu_register_word_invalid_result(float original, float rounded); ++ void set_fpu_register_invalid_result64(double original, double rounded); ++ void set_fpu_register_invalid_result(double original, double rounded); ++ void set_fpu_register_word_invalid_result(double original, double rounded); ++ int64_t get_fpu_register(int fpureg) const; ++ int32_t get_fpu_register_word(int fpureg) const; ++ int32_t get_fpu_register_signed_word(int fpureg) const; ++ int32_t get_fpu_register_hi_word(int fpureg) const; ++ float get_fpu_register_float(int fpureg) const; ++ double get_fpu_register_double(int fpureg) const; ++ void set_cf_register(int cfreg, bool value); ++ bool get_cf_register(int cfreg) const; ++ void set_fcsr_rounding_mode(FPURoundingMode mode); ++ unsigned int get_fcsr_rounding_mode(); ++ void set_fcsr_bit(uint32_t cc, bool value); ++ bool test_fcsr_bit(uint32_t cc); ++ bool set_fcsr_round_error(double original, double rounded); ++ bool set_fcsr_round64_error(double original, double rounded); ++ bool set_fcsr_round_error(float original, float rounded); ++ bool set_fcsr_round64_error(float original, float rounded); ++ void round_according_to_fcsr(double toRound, double* rounded, ++ int32_t* rounded_int); ++ void round64_according_to_fcsr(double toRound, double* rounded, ++ int64_t* rounded_int); ++ void round_according_to_fcsr(float toRound, float* rounded, ++ int32_t* rounded_int); ++ void round64_according_to_fcsr(float toRound, float* rounded, ++ int64_t* rounded_int); ++ // Special case of set_register and get_register to access the raw PC value. ++ void set_pc(int64_t value); ++ int64_t get_pc() const; ++ ++ Address get_sp() const { return static_cast
(get_register(sp)); } ++ ++ // Accessor to the internal simulator stack area. ++ uintptr_t StackLimit(uintptr_t c_limit) const; ++ ++ // Executes LA64 instructions until the PC reaches end_sim_pc. ++ void Execute(); ++ ++ template ++ Return Call(Address entry, Args... args) { ++ return VariadicCall(this, &Simulator::CallImpl, entry, args...); ++ } ++ ++ // Alternative: call a 2-argument double function. ++ double CallFP(Address entry, double d0, double d1); ++ ++ // Push an address onto the JS stack. ++ uintptr_t PushAddress(uintptr_t address); ++ ++ // Pop an address from the JS stack. ++ uintptr_t PopAddress(); ++ ++ // Debugger input. ++ void set_last_debugger_input(char* input); ++ char* last_debugger_input() { return last_debugger_input_; } ++ ++ // Redirection support. ++ static void SetRedirectInstruction(Instruction* instruction); ++ ++ // ICache checking. ++ static bool ICacheMatch(void* one, void* two); ++ static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, ++ size_t size); ++ ++ // Returns true if pc register contains one of the 'special_values' defined ++ // below (bad_ra, end_sim_pc). ++ bool has_bad_pc() const; ++ ++ private: ++ enum special_values { ++ // Known bad pc value to ensure that the simulator does not execute ++ // without being properly setup. ++ bad_ra = -1, ++ // A pc value used to signal the simulator to stop execution. Generally ++ // the ra is set to this value on transition from native C code to ++ // simulated execution, so that the simulator can "return" to the native ++ // C code. ++ end_sim_pc = -2, ++ // Unpredictable value. ++ Unpredictable = 0xbadbeaf ++ }; ++ ++ V8_EXPORT_PRIVATE intptr_t CallImpl(Address entry, int argument_count, ++ const intptr_t* arguments); ++ ++ // Unsupported instructions use Format to print an error and stop execution. ++ void Format(Instruction* instr, const char* format); ++ ++ // Helpers for data value tracing. ++ enum TraceType { ++ BYTE, ++ HALF, ++ WORD, ++ DWORD, ++ FLOAT, ++ DOUBLE, ++ FLOAT_DOUBLE, ++ WORD_DWORD ++ }; ++ ++ // Read and write memory. ++ inline uint32_t ReadBU(int64_t addr); ++ inline int32_t ReadB(int64_t addr); ++ inline void WriteB(int64_t addr, uint8_t value); ++ inline void WriteB(int64_t addr, int8_t value); ++ ++ inline uint16_t ReadHU(int64_t addr, Instruction* instr); ++ inline int16_t ReadH(int64_t addr, Instruction* instr); ++ // Note: Overloaded on the sign of the value. ++ inline void WriteH(int64_t addr, uint16_t value, Instruction* instr); ++ inline void WriteH(int64_t addr, int16_t value, Instruction* instr); ++ ++ inline uint32_t ReadWU(int64_t addr, Instruction* instr); ++ inline int32_t ReadW(int64_t addr, Instruction* instr, TraceType t = WORD); ++ inline void WriteW(int64_t addr, int32_t value, Instruction* instr); ++ void WriteConditionalW(int64_t addr, int32_t value, Instruction* instr, ++ int32_t rt_reg); ++ inline int64_t Read2W(int64_t addr, Instruction* instr); ++ inline void Write2W(int64_t addr, int64_t value, Instruction* instr); ++ inline void WriteConditional2W(int64_t addr, int64_t value, ++ Instruction* instr, int32_t rt_reg); ++ ++ inline double ReadD(int64_t addr, Instruction* instr); ++ inline void WriteD(int64_t addr, double value, Instruction* instr); ++ ++ template ++ T ReadMem(int64_t addr, Instruction* instr); ++ template ++ void WriteMem(int64_t addr, T value, Instruction* instr); ++ ++ // Helper for debugging memory access. ++ inline void DieOrDebug(); ++ ++ void TraceRegWr(int64_t value, TraceType t = DWORD); ++ void TraceMemWr(int64_t addr, int64_t value, TraceType t); ++ void TraceMemRd(int64_t addr, int64_t value, TraceType t = DWORD); ++ template ++ void TraceMemRd(int64_t addr, T value); ++ template ++ void TraceMemWr(int64_t addr, T value); ++ ++ SimInstruction instr_; ++ ++ // Executing is handled based on the instruction type. ++ void DecodeTypeOp6(); ++ void DecodeTypeOp7(); ++ void DecodeTypeOp8(); ++ void DecodeTypeOp10(); ++ void DecodeTypeOp12(); ++ void DecodeTypeOp14(); ++ void DecodeTypeOp17(); ++ void DecodeTypeOp22(); ++ ++ inline int32_t rj_reg() const { return instr_.RjValue(); } ++ inline int64_t rj() const { return get_register(rj_reg()); } ++ inline uint64_t rj_u() const { ++ return static_cast(get_register(rj_reg())); ++ } ++ inline int32_t rk_reg() const { return instr_.RkValue(); } ++ inline int64_t rk() const { return get_register(rk_reg()); } ++ inline uint64_t rk_u() const { ++ return static_cast(get_register(rk_reg())); ++ } ++ inline int32_t rd_reg() const { return instr_.RdValue(); } ++ inline int64_t rd() const { return get_register(rd_reg()); } ++ inline uint64_t rd_u() const { ++ return static_cast(get_register(rd_reg())); ++ } ++ inline int32_t fa_reg() const { return instr_.FaValue(); } ++ inline float fa_float() const { return get_fpu_register_float(fa_reg()); } ++ inline double fa_double() const { return get_fpu_register_double(fa_reg()); } ++ inline int32_t fj_reg() const { return instr_.FjValue(); } ++ inline float fj_float() const { return get_fpu_register_float(fj_reg()); } ++ inline double fj_double() const { return get_fpu_register_double(fj_reg()); } ++ inline int32_t fk_reg() const { return instr_.FkValue(); } ++ inline float fk_float() const { return get_fpu_register_float(fk_reg()); } ++ inline double fk_double() const { return get_fpu_register_double(fk_reg()); } ++ inline int32_t fd_reg() const { return instr_.FdValue(); } ++ inline float fd_float() const { return get_fpu_register_float(fd_reg()); } ++ inline double fd_double() const { return get_fpu_register_double(fd_reg()); } ++ inline int32_t cj_reg() const { return instr_.CjValue(); } ++ inline bool cj() const { return get_cf_register(cj_reg()); } ++ inline int32_t cd_reg() const { return instr_.CdValue(); } ++ inline bool cd() const { return get_cf_register(cd_reg()); } ++ inline int32_t ca_reg() const { return instr_.CaValue(); } ++ inline bool ca() const { return get_cf_register(ca_reg()); } ++ inline uint32_t sa2() const { return instr_.Sa2Value(); } ++ inline uint32_t sa3() const { return instr_.Sa3Value(); } ++ inline uint32_t ui5() const { return instr_.Ui5Value(); } ++ inline uint32_t ui6() const { return instr_.Ui6Value(); } ++ inline uint32_t lsbw() const { return instr_.LsbwValue(); } ++ inline uint32_t msbw() const { return instr_.MsbwValue(); } ++ inline uint32_t lsbd() const { return instr_.LsbdValue(); } ++ inline uint32_t msbd() const { return instr_.MsbdValue(); } ++ inline uint32_t cond() const { return instr_.CondValue(); } ++ inline int32_t si12() const { return (instr_.Si12Value() << 20) >> 20; } ++ inline uint32_t ui12() const { return instr_.Ui12Value(); } ++ inline int32_t si14() const { return (instr_.Si14Value() << 18) >> 18; } ++ inline int32_t si16() const { return (instr_.Si16Value() << 16) >> 16; } ++ inline int32_t si20() const { return (instr_.Si20Value() << 12) >> 12; } ++ ++ inline void SetResult(const int32_t rd_reg, const int64_t alu_out) { ++ set_register(rd_reg, alu_out); ++ TraceRegWr(alu_out); ++ } ++ ++ inline void SetFPUWordResult(int32_t fd_reg, int32_t alu_out) { ++ set_fpu_register_word(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg), WORD); ++ } ++ ++ inline void SetFPUWordResult2(int32_t fd_reg, int32_t alu_out) { ++ set_fpu_register_word(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg)); ++ } ++ ++ inline void SetFPUResult(int32_t fd_reg, int64_t alu_out) { ++ set_fpu_register(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg)); ++ } ++ ++ inline void SetFPUResult2(int32_t fd_reg, int64_t alu_out) { ++ set_fpu_register(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg), DOUBLE); ++ } ++ ++ inline void SetFPUFloatResult(int32_t fd_reg, float alu_out) { ++ set_fpu_register_float(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg), FLOAT); ++ } ++ ++ inline void SetFPUDoubleResult(int32_t fd_reg, double alu_out) { ++ set_fpu_register_double(fd_reg, alu_out); ++ TraceRegWr(get_fpu_register(fd_reg), DOUBLE); ++ } ++ ++ // Used for breakpoints. ++ void SoftwareInterrupt(); ++ ++ // Stop helper functions. ++ bool IsWatchpoint(uint64_t code); ++ void PrintWatchpoint(uint64_t code); ++ void HandleStop(uint64_t code, Instruction* instr); ++ bool IsStopInstruction(Instruction* instr); ++ bool IsEnabledStop(uint64_t code); ++ void EnableStop(uint64_t code); ++ void DisableStop(uint64_t code); ++ void IncreaseStopCounter(uint64_t code); ++ void PrintStopInfo(uint64_t code); ++ ++ // Executes one instruction. ++ void InstructionDecode(Instruction* instr); ++ // Execute one instruction placed in a branch delay slot. ++ ++ // ICache. ++ static void CheckICache(base::CustomMatcherHashMap* i_cache, ++ Instruction* instr); ++ static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, ++ size_t size); ++ static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, ++ void* page); ++ ++ enum Exception { ++ none, ++ kIntegerOverflow, ++ kIntegerUnderflow, ++ kDivideByZero, ++ kNumExceptions ++ }; ++ ++ // Exceptions. ++ void SignalException(Exception e); ++ ++ // Handle arguments and return value for runtime FP functions. ++ void GetFpArgs(double* x, double* y, int32_t* z); ++ void SetFpResult(const double& result); ++ ++ void CallInternal(Address entry); ++ ++ // Architecture state. ++ // Registers. ++ int64_t registers_[kNumSimuRegisters]; ++ // Floating point Registers. ++ int64_t FPUregisters_[kNumFPURegisters]; ++ // Condition flags Registers. ++ bool CFregisters_[kNumCFRegisters]; ++ // FPU control register. ++ uint32_t FCSR_; ++ ++ // Simulator support. ++ // Allocate 1MB for stack. ++ size_t stack_size_; ++ char* stack_; ++ bool pc_modified_; ++ int64_t icount_; ++ int break_count_; ++ EmbeddedVector trace_buf_; ++ ++ // Debugger input. ++ char* last_debugger_input_; ++ ++ v8::internal::Isolate* isolate_; ++ ++ // Registered breakpoints. ++ Instruction* break_pc_; ++ Instr break_instr_; ++ ++ // Stop is disabled if bit 31 is set. ++ static const uint32_t kStopDisabledBit = 1 << 31; ++ ++ // A stop is enabled, meaning the simulator will stop when meeting the ++ // instruction, if bit 31 of watched_stops_[code].count is unset. ++ // The value watched_stops_[code].count & ~(1 << 31) indicates how many times ++ // the breakpoint was hit or gone through. ++ struct StopCountAndDesc { ++ uint32_t count; ++ char* desc; ++ }; ++ StopCountAndDesc watched_stops_[kMaxStopCode + 1]; ++ ++ // Synchronization primitives. ++ enum class MonitorAccess { ++ Open, ++ RMW, ++ }; ++ ++ enum class TransactionSize { ++ None = 0, ++ Word = 4, ++ DoubleWord = 8, ++ }; ++ ++ // The least-significant bits of the address are ignored. The number of bits ++ // is implementation-defined, between 3 and minimum page size. ++ static const uintptr_t kExclusiveTaggedAddrMask = ~((1 << 3) - 1); ++ ++ class LocalMonitor { ++ public: ++ LocalMonitor(); ++ ++ // These functions manage the state machine for the local monitor, but do ++ // not actually perform loads and stores. NotifyStoreConditional only ++ // returns true if the store conditional is allowed; the global monitor will ++ // still have to be checked to see whether the memory should be updated. ++ void NotifyLoad(); ++ void NotifyLoadLinked(uintptr_t addr, TransactionSize size); ++ void NotifyStore(); ++ bool NotifyStoreConditional(uintptr_t addr, TransactionSize size); ++ ++ private: ++ void Clear(); ++ ++ MonitorAccess access_state_; ++ uintptr_t tagged_addr_; ++ TransactionSize size_; ++ }; ++ ++ class GlobalMonitor { ++ public: ++ class LinkedAddress { ++ public: ++ LinkedAddress(); ++ ++ private: ++ friend class GlobalMonitor; ++ // These functions manage the state machine for the global monitor, but do ++ // not actually perform loads and stores. ++ void Clear_Locked(); ++ void NotifyLoadLinked_Locked(uintptr_t addr); ++ void NotifyStore_Locked(); ++ bool NotifyStoreConditional_Locked(uintptr_t addr, ++ bool is_requesting_thread); ++ ++ MonitorAccess access_state_; ++ uintptr_t tagged_addr_; ++ LinkedAddress* next_; ++ LinkedAddress* prev_; ++ // A scd can fail due to background cache evictions. Rather than ++ // simulating this, we'll just occasionally introduce cases where an ++ // store conditional fails. This will happen once after every ++ // kMaxFailureCounter exclusive stores. ++ static const int kMaxFailureCounter = 5; ++ int failure_counter_; ++ }; ++ ++ // Exposed so it can be accessed by Simulator::{Read,Write}Ex*. ++ base::Mutex mutex; ++ ++ void NotifyLoadLinked_Locked(uintptr_t addr, LinkedAddress* linked_address); ++ void NotifyStore_Locked(LinkedAddress* linked_address); ++ bool NotifyStoreConditional_Locked(uintptr_t addr, ++ LinkedAddress* linked_address); ++ ++ // Called when the simulator is destroyed. ++ void RemoveLinkedAddress(LinkedAddress* linked_address); ++ ++ static GlobalMonitor* Get(); ++ ++ private: ++ // Private constructor. Call {GlobalMonitor::Get()} to get the singleton. ++ GlobalMonitor() = default; ++ friend class base::LeakyObject; ++ ++ bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const; ++ void PrependProcessor_Locked(LinkedAddress* linked_address); ++ ++ LinkedAddress* head_ = nullptr; ++ }; ++ ++ LocalMonitor local_monitor_; ++ GlobalMonitor::LinkedAddress global_monitor_thread_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // defined(USE_SIMULATOR) ++#endif // V8_EXECUTION_LA64_SIMULATOR_LOONGARCH64_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/execution/simulator-base.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/simulator-base.h +@@ -89,7 +89,7 @@ class SimulatorBase { + static typename std::enable_if::value, intptr_t>::type + ConvertArg(T arg) { + static_assert(sizeof(T) <= sizeof(intptr_t), "type bigger than ptrsize"); +-#if V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + // The MIPS64 calling convention is to sign extend all values, even unsigned + // ones. + using signed_t = typename std::make_signed::type; +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/simulator-base.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/execution/simulator-base.h +++++ src/3rdparty/chromium/v8/src/execution/simulator-base.h ++@@ -89,7 +89,7 @@ class SimulatorBase { ++ static typename std::enable_if::value, intptr_t>::type ++ ConvertArg(T arg) { ++ static_assert(sizeof(T) <= sizeof(intptr_t), "type bigger than ptrsize"); ++-#if V8_TARGET_ARCH_MIPS64 +++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 ++ // The MIPS64 calling convention is to sign extend all values, even unsigned ++ // ones. ++ using signed_t = typename std::make_signed::type; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/execution/simulator.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/simulator.h +@@ -24,6 +24,8 @@ + #include "src/execution/mips/simulator-mips.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/execution/mips64/simulator-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/execution/loongarch64/simulator-loongarch64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/execution/s390/simulator-s390.h" + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/execution/simulator.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/execution/simulator.h +++++ src/3rdparty/chromium/v8/src/execution/simulator.h ++@@ -24,6 +24,8 @@ ++ #include "src/execution/mips/simulator-mips.h" ++ #elif V8_TARGET_ARCH_MIPS64 ++ #include "src/execution/mips64/simulator-mips64.h" +++#elif V8_TARGET_ARCH_LOONGARCH64 +++#include "src/execution/loongarch64/simulator-loongarch64.h" ++ #elif V8_TARGET_ARCH_S390 ++ #include "src/execution/s390/simulator-s390.h" ++ #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/flags/flag-definitions.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/flags/flag-definitions.h +@@ -1372,7 +1372,7 @@ DEFINE_BOOL(check_icache, false, + "Check icache flushes in ARM and MIPS simulator") + DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions") + #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) || \ +- defined(V8_TARGET_ARCH_PPC64) ++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_LOONGARCH64) + DEFINE_INT(sim_stack_alignment, 16, + "Stack alignment in bytes in simulator. This must be a power of two " + "and it must be at least 16. 16 is default.") +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/flags/flag-definitions.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/flags/flag-definitions.h +++++ src/3rdparty/chromium/v8/src/flags/flag-definitions.h ++@@ -1372,7 +1372,7 @@ DEFINE_BOOL(check_icache, false, ++ "Check icache flushes in ARM and MIPS simulator") ++ DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions") ++ #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) || \ ++- defined(V8_TARGET_ARCH_PPC64) +++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_LOONGARCH64) ++ DEFINE_INT(sim_stack_alignment, 16, ++ "Stack alignment in bytes in simulator. This must be a power of two " ++ "and it must be at least 16. 16 is default.") +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/heap/base/asm/loongarch64/push_registers_asm.cc +@@ -0,0 +1,48 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Push all callee-saved registers to get them on the stack for conservative ++// stack scanning. ++// ++// See asm/x64/push_registers_clang.cc for why the function is not generated ++// using clang. ++// ++// Do not depend on V8_TARGET_OS_* defines as some embedders may override the ++// GN toolchain (e.g. ChromeOS) and not provide them. ++asm(".text \n" ++ ".global PushAllRegistersAndIterateStack \n" ++ ".type PushAllRegistersAndIterateStack, %function \n" ++ ".hidden PushAllRegistersAndIterateStack \n" ++ "PushAllRegistersAndIterateStack: \n" ++ // Push all callee-saved registers and save return address. ++ " addi.d $sp, $sp, -96 \n" ++ " st.d $ra, $sp, 88 \n" ++ " st.d $s8, $sp, 80 \n" ++ " st.d $sp, $sp, 72 \n" ++ " st.d $fp, $sp, 64 \n" ++ " st.d $s7, $sp, 56 \n" ++ " st.d $s6, $sp, 48 \n" ++ " st.d $s5, $sp, 40 \n" ++ " st.d $s4, $sp, 32 \n" ++ " st.d $s3, $sp, 24 \n" ++ " st.d $s2, $sp, 16 \n" ++ " st.d $s1, $sp, 8 \n" ++ " st.d $s0, $sp, 0 \n" ++ // Maintain frame pointer. ++ " addi.d $s8, $sp, 0 \n" ++ // Pass 1st parameter (a0) unchanged (Stack*). ++ // Pass 2nd parameter (a1) unchanged (StackVisitor*). ++ // Save 3rd parameter (a2; IterateStackCallback). ++ " addi.d $a3, $a2, 0 \n" ++ // Call the callback. ++ // Pass 3rd parameter as sp (stack pointer). ++ " addi.d $a2, $sp, 0 \n" ++ " jirl $ra, $a3, 0 \n" ++ // Load return address. ++ " ld.d $ra, $sp, 88 \n" ++ // Restore frame pointer. ++ " ld.d $s8, $sp, 80 \n" ++ // Discard all callee-saved registers. ++ " addi.d $sp, $sp, 96 \n" ++ " jirl $zero, $ra, 0 \n"); +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc +@@ -1348,7 +1348,7 @@ void InterpreterAssembler::TraceBytecode + + // static + bool InterpreterAssembler::TargetSupportsUnalignedAccess() { +-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + return false; + #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390 || \ + V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC || \ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc +++++ src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc ++@@ -1348,7 +1348,7 @@ void InterpreterAssembler::TraceBytecodeDispatch(TNode target_bytecode) { ++ ++ // static ++ bool InterpreterAssembler::TargetSupportsUnalignedAccess() { ++-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 ++ return false; ++ #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390 || \ ++ V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC || \ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/libsampler/sampler.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/libsampler/sampler.cc +@@ -415,6 +415,10 @@ void SignalHandler::FillRegisterState(vo + state->pc = reinterpret_cast(mcontext.pc); + state->sp = reinterpret_cast(mcontext.gregs[29]); + state->fp = reinterpret_cast(mcontext.gregs[30]); ++#elif V8_HOST_ARCH_LOONGARCH64 ++ state->pc = reinterpret_cast(mcontext.__pc); ++ state->sp = reinterpret_cast(mcontext.__gregs[3]); ++ state->fp = reinterpret_cast(mcontext.__gregs[22]); + #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 + #if V8_LIBC_GLIBC + state->pc = reinterpret_cast(ucontext->uc_mcontext.regs->nip); +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/libsampler/sampler.cc.rej +@@ -0,0 +1,13 @@ ++--- src/3rdparty/chromium/v8/src/libsampler/sampler.cc +++++ src/3rdparty/chromium/v8/src/libsampler/sampler.cc ++@@ -415,6 +415,10 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) { ++ state->pc = reinterpret_cast(mcontext.pc); ++ state->sp = reinterpret_cast(mcontext.gregs[29]); ++ state->fp = reinterpret_cast(mcontext.gregs[30]); +++#elif V8_HOST_ARCH_LOONGARCH64 +++ state->pc = reinterpret_cast(mcontext.__pc); +++ state->sp = reinterpret_cast(mcontext.__gregs[3]); +++ state->fp = reinterpret_cast(mcontext.__gregs[22]); ++ #elif V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 ++ #if V8_LIBC_GLIBC ++ state->pc = reinterpret_cast(ucontext->uc_mcontext.regs->nip); +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/logging/log.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/logging/log.cc +@@ -590,6 +590,8 @@ void LowLevelLogger::LogCodeInfo() { + const char arch[] = "ppc64"; + #elif V8_TARGET_ARCH_MIPS + const char arch[] = "mips"; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ const char arch[] = "la64"; + #elif V8_TARGET_ARCH_ARM64 + const char arch[] = "arm64"; + #elif V8_TARGET_ARCH_S390 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/logging/log.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/logging/log.cc +++++ src/3rdparty/chromium/v8/src/logging/log.cc ++@@ -590,6 +590,8 @@ void LowLevelLogger::LogCodeInfo() { ++ const char arch[] = "ppc64"; ++ #elif V8_TARGET_ARCH_MIPS ++ const char arch[] = "mips"; +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ const char arch[] = "la64"; ++ #elif V8_TARGET_ARCH_ARM64 ++ const char arch[] = "arm64"; ++ #elif V8_TARGET_ARCH_S390 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/objects/backing-store.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/backing-store.cc +@@ -29,7 +29,7 @@ constexpr bool kUseGuardRegions = true; + constexpr bool kUseGuardRegions = false; + #endif + +-#if V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + // MIPS64 has a user space of 2^40 bytes on most processors, + // address space limits needs to be smaller. + constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/backing-store.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/objects/backing-store.cc +++++ src/3rdparty/chromium/v8/src/objects/backing-store.cc ++@@ -29,7 +29,7 @@ constexpr bool kUseGuardRegions = true; ++ constexpr bool kUseGuardRegions = false; ++ #endif ++ ++-#if V8_TARGET_ARCH_MIPS64 +++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 ++ // MIPS64 has a user space of 2^40 bytes on most processors, ++ // address space limits needs to be smaller. ++ constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/objects/code.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/code.cc +@@ -234,7 +234,7 @@ bool Code::IsIsolateIndependent(Isolate* + RelocInfo::ModeMask(RelocInfo::WASM_STUB_CALL))); + + #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ +- defined(V8_TARGET_ARCH_MIPS64) ++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) + return RelocIterator(*this, kModeMask).done(); + #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ + defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/code.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/objects/code.cc +++++ src/3rdparty/chromium/v8/src/objects/code.cc ++@@ -234,7 +234,7 @@ bool Code::IsIsolateIndependent(Isolate* isolate) { ++ RelocInfo::ModeMask(RelocInfo::WASM_STUB_CALL))); ++ ++ #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ ++- defined(V8_TARGET_ARCH_MIPS64) +++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_LOONGARCH64) ++ return RelocIterator(*this, kModeMask).done(); ++ #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ ++ defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/objects/code.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/code.h +@@ -447,6 +447,8 @@ class Code : public HeapObject { + static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; + #elif V8_TARGET_ARCH_MIPS64 + static constexpr int kHeaderPaddingSize = 28; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ static constexpr int kHeaderPaddingSize = 28; + #elif V8_TARGET_ARCH_X64 + static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; + #elif V8_TARGET_ARCH_ARM +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/objects/code.h.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/objects/code.h +++++ src/3rdparty/chromium/v8/src/objects/code.h ++@@ -447,6 +447,8 @@ class Code : public HeapObject { ++ static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; ++ #elif V8_TARGET_ARCH_MIPS64 ++ static constexpr int kHeaderPaddingSize = 28; +++#elif V8_TARGET_ARCH_LOONGARCH64 +++ static constexpr int kHeaderPaddingSize = 28; ++ #elif V8_TARGET_ARCH_X64 ++ static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; ++ #elif V8_TARGET_ARCH_ARM +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc +@@ -105,7 +105,7 @@ bool SimulatorHelper::FillRegisters(Isol + state->sp = reinterpret_cast(simulator->sp()); + state->fp = reinterpret_cast(simulator->fp()); + state->lr = reinterpret_cast(simulator->lr()); +-#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + if (!simulator->has_bad_pc()) { + state->pc = reinterpret_cast(simulator->get_pc()); + } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc.rej +@@ -0,0 +1,11 @@ ++--- src/3rdparty/chromium/v8/src/profiler/tick-sample.cc +++++ src/3rdparty/chromium/v8/src/profiler/tick-sample.cc ++@@ -105,7 +105,7 @@ bool SimulatorHelper::FillRegisters(Isolate* isolate, ++ state->sp = reinterpret_cast(simulator->sp()); ++ state->fp = reinterpret_cast(simulator->fp()); ++ state->lr = reinterpret_cast(simulator->lr()); ++-#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 +++#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 ++ if (!simulator->has_bad_pc()) { ++ state->pc = reinterpret_cast(simulator->get_pc()); ++ } +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc +@@ -0,0 +1,1255 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_LOONGARCH64 ++ ++#include "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h" ++ ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/logging/log.h" ++#include "src/objects/objects-inl.h" ++#include "src/regexp/regexp-macro-assembler.h" ++#include "src/regexp/regexp-stack.h" ++#include "src/snapshot/embedded/embedded-data.h" ++#include "src/strings/unicode.h" ++ ++namespace v8 { ++namespace internal { ++ ++/* clang-format off ++ * ++ * This assembler uses the following register assignment convention ++ * - t3 : Temporarily stores the index of capture start after a matching pass ++ * for a global regexp. ++ * - a5 : Pointer to current Code object including heap object tag. ++ * - a6 : Current position in input, as negative offset from end of string. ++ * Please notice that this is the byte offset, not the character offset! ++ * - a7 : Currently loaded character. Must be loaded using ++ * LoadCurrentCharacter before using any of the dispatch methods. ++ * - t0 : Points to tip of backtrack stack ++ * - t1 : Unused. ++ * - t2 : End of input (points to byte after last character in input). ++ * - fp : Frame pointer. Used to access arguments, local variables and ++ * RegExp registers. ++ * - sp : Points to tip of C stack. ++ * ++ * The remaining registers are free for computations. ++ * Each call to a public method should retain this convention. ++ * ++ * TODO(plind): O32 documented here with intent of having single 32/64 codebase ++ * in the future. ++ * ++ * The O32 stack will have the following structure: ++ * ++ * - fp[72] Isolate* isolate (address of the current isolate) ++ * - fp[68] direct_call (if 1, direct call from JavaScript code, ++ * if 0, call through the runtime system). ++ * - fp[64] stack_area_base (High end of the memory area to use as ++ * backtracking stack). ++ * - fp[60] capture array size (may fit multiple sets of matches) ++ * - fp[44..59] MIPS O32 four argument slots ++ * - fp[40] int* capture_array (int[num_saved_registers_], for output). ++ * --- sp when called --- ++ * - fp[36] return address (lr). ++ * - fp[32] old frame pointer (r11). ++ * - fp[0..31] backup of registers s0..s7. ++ * --- frame pointer ---- ++ * - fp[-4] end of input (address of end of string). ++ * - fp[-8] start of input (address of first character in string). ++ * - fp[-12] start index (character index of start). ++ * - fp[-16] void* input_string (location of a handle containing the string). ++ * - fp[-20] success counter (only for global regexps to count matches). ++ * - fp[-24] Offset of location before start of input (effectively character ++ * string start - 1). Used to initialize capture registers to a ++ * non-position. ++ * - fp[-28] At start (if 1, we are starting at the start of the ++ * string, otherwise 0) ++ * - fp[-32] register 0 (Only positions must be stored in the first ++ * - register 1 num_saved_registers_ registers) ++ * - ... ++ * - register num_registers-1 ++ * --- sp --- ++ * ++ * ++ * The N64 stack will have the following structure: ++ * ++ * - fp[80] Isolate* isolate (address of the current isolate) kIsolate ++ * kStackFrameHeader ++ * --- sp when called --- ++ * - fp[72] ra Return from RegExp code (ra). kReturnAddress ++ * - fp[64] s9, old-fp Old fp, callee saved(s9). ++ * - fp[0..63] s0..s7 Callee-saved registers s0..s7. ++ * --- frame pointer ---- ++ * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall ++ * - fp[-16] stack_base (Top of backtracking stack). kStackHighEnd ++ * - fp[-24] capture array size (may fit multiple sets of matches) kNumOutputRegisters ++ * - fp[-32] int* capture_array (int[num_saved_registers_], for output). kRegisterOutput ++ * - fp[-40] end of input (address of end of string). kInputEnd ++ * - fp[-48] start of input (address of first character in string). kInputStart ++ * - fp[-56] start index (character index of start). kStartIndex ++ * - fp[-64] void* input_string (location of a handle containing the string). kInputString ++ * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures ++ * - fp[-80] Offset of location before start of input (effectively character kStringStartMinusOne ++ * position -1). Used to initialize capture registers to a ++ * non-position. ++ * --------- The following output registers are 32-bit values. --------- ++ * - fp[-88] register 0 (Only positions must be stored in the first kRegisterZero ++ * - register 1 num_saved_registers_ registers) ++ * - ... ++ * - register num_registers-1 ++ * --- sp --- ++ * ++ * The first num_saved_registers_ registers are initialized to point to ++ * "character -1" in the string (i.e., char_size() bytes before the first ++ * character of the string). The remaining registers start out as garbage. ++ * ++ * The data up to the return address must be placed there by the calling ++ * code and the remaining arguments are passed in registers, e.g. by calling the ++ * code entry as cast to a function with the signature: ++ * int (*match)(String input_string, ++ * int start_index, ++ * Address start, ++ * Address end, ++ * int* capture_output_array, ++ * int num_capture_registers, ++ * byte* stack_area_base, ++ * bool direct_call = false, ++ * Isolate* isolate); ++ * The call is performed by NativeRegExpMacroAssembler::Execute() ++ * (in regexp-macro-assembler.cc) via the GeneratedCode wrapper. ++ * ++ * clang-format on ++ */ ++ ++#define __ ACCESS_MASM(masm_) ++ ++const int RegExpMacroAssemblerLA64::kRegExpCodeSize; ++ ++RegExpMacroAssemblerLA64::RegExpMacroAssemblerLA64(Isolate* isolate, Zone* zone, ++ Mode mode, ++ int registers_to_save) ++ : NativeRegExpMacroAssembler(isolate, zone), ++ masm_(new MacroAssembler(isolate, CodeObjectRequired::kYes, ++ NewAssemblerBuffer(kRegExpCodeSize))), ++ mode_(mode), ++ num_registers_(registers_to_save), ++ num_saved_registers_(registers_to_save), ++ entry_label_(), ++ start_label_(), ++ success_label_(), ++ backtrack_label_(), ++ exit_label_(), ++ internal_failure_label_() { ++ masm_->set_root_array_available(false); ++ ++ DCHECK_EQ(0, registers_to_save % 2); ++ __ jmp(&entry_label_); // We'll write the entry code later. ++ // If the code gets too big or corrupted, an internal exception will be ++ // raised, and we will exit right away. ++ __ bind(&internal_failure_label_); ++ __ li(a0, Operand(FAILURE)); ++ __ Ret(); ++ __ bind(&start_label_); // And then continue from here. ++} ++ ++RegExpMacroAssemblerLA64::~RegExpMacroAssemblerLA64() { ++ delete masm_; ++ // Unuse labels in case we throw away the assembler without calling GetCode. ++ entry_label_.Unuse(); ++ start_label_.Unuse(); ++ success_label_.Unuse(); ++ backtrack_label_.Unuse(); ++ exit_label_.Unuse(); ++ check_preempt_label_.Unuse(); ++ stack_overflow_label_.Unuse(); ++ internal_failure_label_.Unuse(); ++} ++ ++int RegExpMacroAssemblerLA64::stack_limit_slack() { ++ return RegExpStack::kStackLimitSlack; ++} ++ ++void RegExpMacroAssemblerLA64::AdvanceCurrentPosition(int by) { ++ if (by != 0) { ++ __ Add_d(current_input_offset(), current_input_offset(), ++ Operand(by * char_size())); ++ } ++} ++ ++void RegExpMacroAssemblerLA64::AdvanceRegister(int reg, int by) { ++ DCHECK_LE(0, reg); ++ DCHECK_GT(num_registers_, reg); ++ if (by != 0) { ++ __ Ld_d(a0, register_location(reg)); ++ __ Add_d(a0, a0, Operand(by)); ++ __ St_d(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerLA64::Backtrack() { ++ CheckPreemption(); ++ if (has_backtrack_limit()) { ++ Label next; ++ __ Ld_d(a0, MemOperand(frame_pointer(), kBacktrackCount)); ++ __ Add_d(a0, a0, Operand(1)); ++ __ St_d(a0, MemOperand(frame_pointer(), kBacktrackCount)); ++ __ Branch(&next, ne, a0, Operand(backtrack_limit())); ++ ++ // Exceeded limits are treated as a failed match. ++ Fail(); ++ ++ __ bind(&next); ++ } ++ // Pop Code offset from backtrack stack, add Code and jump to location. ++ Pop(a0); ++ __ Add_d(a0, a0, code_pointer()); ++ __ Jump(a0); ++} ++ ++void RegExpMacroAssemblerLA64::Bind(Label* label) { __ bind(label); } ++ ++void RegExpMacroAssemblerLA64::CheckCharacter(uint32_t c, Label* on_equal) { ++ BranchOrBacktrack(on_equal, eq, current_character(), Operand(c)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckCharacterGT(uc16 limit, Label* on_greater) { ++ BranchOrBacktrack(on_greater, gt, current_character(), Operand(limit)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckAtStart(int cp_offset, Label* on_at_start) { ++ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add_d(a0, current_input_offset(), ++ Operand(-char_size() + cp_offset * char_size())); ++ BranchOrBacktrack(on_at_start, eq, a0, Operand(a1)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotAtStart(int cp_offset, ++ Label* on_not_at_start) { ++ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add_d(a0, current_input_offset(), ++ Operand(-char_size() + cp_offset * char_size())); ++ BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckCharacterLT(uc16 limit, Label* on_less) { ++ BranchOrBacktrack(on_less, lt, current_character(), Operand(limit)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckGreedyLoop(Label* on_equal) { ++ Label backtrack_non_equal; ++ __ Ld_w(a0, MemOperand(backtrack_stackpointer(), 0)); ++ __ Branch(&backtrack_non_equal, ne, current_input_offset(), Operand(a0)); ++ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), ++ Operand(kIntSize)); ++ __ bind(&backtrack_non_equal); ++ BranchOrBacktrack(on_equal, eq, current_input_offset(), Operand(a0)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotBackReferenceIgnoreCase( ++ int start_reg, bool read_backward, bool unicode, Label* on_no_match) { ++ Label fallthrough; ++ __ Ld_d(a0, register_location(start_reg)); // Index of start of capture. ++ __ Ld_d(a1, register_location(start_reg + 1)); // Index of end of capture. ++ __ Sub_d(a1, a1, a0); // Length of capture. ++ ++ // At this point, the capture registers are either both set or both cleared. ++ // If the capture length is zero, then the capture is either empty or cleared. ++ // Fall through in both cases. ++ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); ++ ++ if (read_backward) { ++ __ Ld_d(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add_d(t1, t1, a1); ++ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); ++ } else { ++ __ Add_d(t1, a1, current_input_offset()); ++ // Check that there are enough characters left in the input. ++ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); ++ } ++ ++ if (mode_ == LATIN1) { ++ Label success; ++ Label fail; ++ Label loop_check; ++ ++ // a0 - offset of start of capture. ++ // a1 - length of capture. ++ __ Add_d(a0, a0, Operand(end_of_input_address())); ++ __ Add_d(a2, end_of_input_address(), Operand(current_input_offset())); ++ if (read_backward) { ++ __ Sub_d(a2, a2, Operand(a1)); ++ } ++ __ Add_d(a1, a0, Operand(a1)); ++ ++ // a0 - Address of start of capture. ++ // a1 - Address of end of capture. ++ // a2 - Address of current input position. ++ ++ Label loop; ++ __ bind(&loop); ++ __ Ld_bu(a3, MemOperand(a0, 0)); ++ __ addi_d(a0, a0, char_size()); ++ __ Ld_bu(a4, MemOperand(a2, 0)); ++ __ addi_d(a2, a2, char_size()); ++ ++ __ Branch(&loop_check, eq, a4, Operand(a3)); ++ ++ // Mismatch, try case-insensitive match (converting letters to lower-case). ++ __ Or(a3, a3, Operand(0x20)); // Convert capture character to lower-case. ++ __ Or(a4, a4, Operand(0x20)); // Also convert input character. ++ __ Branch(&fail, ne, a4, Operand(a3)); ++ __ Sub_d(a3, a3, Operand('a')); ++ __ Branch(&loop_check, ls, a3, Operand('z' - 'a')); ++ // Latin-1: Check for values in range [224,254] but not 247. ++ __ Sub_d(a3, a3, Operand(224 - 'a')); ++ // Weren't Latin-1 letters. ++ __ Branch(&fail, hi, a3, Operand(254 - 224)); ++ // Check for 247. ++ __ Branch(&fail, eq, a3, Operand(247 - 224)); ++ ++ __ bind(&loop_check); ++ __ Branch(&loop, lt, a0, Operand(a1)); ++ __ jmp(&success); ++ ++ __ bind(&fail); ++ GoTo(on_no_match); ++ ++ __ bind(&success); ++ // Compute new value of character position after the matched part. ++ __ Sub_d(current_input_offset(), a2, end_of_input_address()); ++ if (read_backward) { ++ __ Ld_d(t1, register_location(start_reg)); // Index of start of capture. ++ __ Ld_d(a2, ++ register_location(start_reg + 1)); // Index of end of capture. ++ __ Add_d(current_input_offset(), current_input_offset(), Operand(t1)); ++ __ Sub_d(current_input_offset(), current_input_offset(), Operand(a2)); ++ } ++ } else { ++ DCHECK(mode_ == UC16); ++ // Put regexp engine registers on stack. ++ RegList regexp_registers_to_retain = current_input_offset().bit() | ++ current_character().bit() | ++ backtrack_stackpointer().bit(); ++ __ MultiPush(regexp_registers_to_retain); ++ ++ int argument_count = 4; ++ __ PrepareCallCFunction(argument_count, a2); ++ ++ // a0 - offset of start of capture. ++ // a1 - length of capture. ++ ++ // Put arguments into arguments registers. ++ // Parameters are ++ // a0: Address byte_offset1 - Address captured substring's start. ++ // a1: Address byte_offset2 - Address of current character position. ++ // a2: size_t byte_length - length of capture in bytes(!). ++ // a3: Isolate* isolate. ++ ++ // Address of start of capture. ++ __ Add_d(a0, a0, Operand(end_of_input_address())); ++ // Length of capture. ++ __ mov(a2, a1); ++ // Save length in callee-save register for use on return. ++ __ mov(s3, a1); ++ // Address of current input position. ++ __ Add_d(a1, current_input_offset(), Operand(end_of_input_address())); ++ if (read_backward) { ++ __ Sub_d(a1, a1, Operand(s3)); ++ } ++ // Isolate. ++ __ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate()))); ++ ++ { ++ AllowExternalCallThatCantCauseGC scope(masm_); ++ ExternalReference function = ++ unicode ? ExternalReference::re_case_insensitive_compare_unicode( ++ isolate()) ++ : ExternalReference::re_case_insensitive_compare_non_unicode( ++ isolate()); ++ __ CallCFunction(function, argument_count); ++ } ++ ++ // Restore regexp engine registers. ++ __ MultiPop(regexp_registers_to_retain); ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ ++ // Check if function returned non-zero for success or zero for failure. ++ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); ++ // On success, increment position by length of capture. ++ if (read_backward) { ++ __ Sub_d(current_input_offset(), current_input_offset(), Operand(s3)); ++ } else { ++ __ Add_d(current_input_offset(), current_input_offset(), Operand(s3)); ++ } ++ } ++ ++ __ bind(&fallthrough); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotBackReference(int start_reg, ++ bool read_backward, ++ Label* on_no_match) { ++ Label fallthrough; ++ ++ // Find length of back-referenced capture. ++ __ Ld_d(a0, register_location(start_reg)); ++ __ Ld_d(a1, register_location(start_reg + 1)); ++ __ Sub_d(a1, a1, a0); // Length to check. ++ ++ // At this point, the capture registers are either both set or both cleared. ++ // If the capture length is zero, then the capture is either empty or cleared. ++ // Fall through in both cases. ++ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); ++ ++ if (read_backward) { ++ __ Ld_d(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add_d(t1, t1, a1); ++ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); ++ } else { ++ __ Add_d(t1, a1, current_input_offset()); ++ // Check that there are enough characters left in the input. ++ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); ++ } ++ ++ // Compute pointers to match string and capture string. ++ __ Add_d(a0, a0, Operand(end_of_input_address())); ++ __ Add_d(a2, end_of_input_address(), Operand(current_input_offset())); ++ if (read_backward) { ++ __ Sub_d(a2, a2, Operand(a1)); ++ } ++ __ Add_d(a1, a1, Operand(a0)); ++ ++ Label loop; ++ __ bind(&loop); ++ if (mode_ == LATIN1) { ++ __ Ld_bu(a3, MemOperand(a0, 0)); ++ __ addi_d(a0, a0, char_size()); ++ __ Ld_bu(a4, MemOperand(a2, 0)); ++ __ addi_d(a2, a2, char_size()); ++ } else { ++ DCHECK(mode_ == UC16); ++ __ Ld_hu(a3, MemOperand(a0, 0)); ++ __ addi_d(a0, a0, char_size()); ++ __ Ld_hu(a4, MemOperand(a2, 0)); ++ __ addi_d(a2, a2, char_size()); ++ } ++ BranchOrBacktrack(on_no_match, ne, a3, Operand(a4)); ++ __ Branch(&loop, lt, a0, Operand(a1)); ++ ++ // Move current character position to position after match. ++ __ Sub_d(current_input_offset(), a2, end_of_input_address()); ++ if (read_backward) { ++ __ Ld_d(t1, register_location(start_reg)); // Index of start of capture. ++ __ Ld_d(a2, register_location(start_reg + 1)); // Index of end of capture. ++ __ Add_d(current_input_offset(), current_input_offset(), Operand(t1)); ++ __ Sub_d(current_input_offset(), current_input_offset(), Operand(a2)); ++ } ++ __ bind(&fallthrough); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotCharacter(uint32_t c, ++ Label* on_not_equal) { ++ BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckCharacterAfterAnd(uint32_t c, uint32_t mask, ++ Label* on_equal) { ++ __ And(a0, current_character(), Operand(mask)); ++ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); ++ BranchOrBacktrack(on_equal, eq, a0, rhs); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotCharacterAfterAnd(uint32_t c, ++ uint32_t mask, ++ Label* on_not_equal) { ++ __ And(a0, current_character(), Operand(mask)); ++ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); ++ BranchOrBacktrack(on_not_equal, ne, a0, rhs); ++} ++ ++void RegExpMacroAssemblerLA64::CheckNotCharacterAfterMinusAnd( ++ uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { ++ DCHECK_GT(String::kMaxUtf16CodeUnit, minus); ++ __ Sub_d(a0, current_character(), Operand(minus)); ++ __ And(a0, a0, Operand(mask)); ++ BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckCharacterInRange(uc16 from, uc16 to, ++ Label* on_in_range) { ++ __ Sub_d(a0, current_character(), Operand(from)); ++ // Unsigned lower-or-same condition. ++ BranchOrBacktrack(on_in_range, ls, a0, Operand(to - from)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckCharacterNotInRange( ++ uc16 from, uc16 to, Label* on_not_in_range) { ++ __ Sub_d(a0, current_character(), Operand(from)); ++ // Unsigned higher condition. ++ BranchOrBacktrack(on_not_in_range, hi, a0, Operand(to - from)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckBitInTable(Handle table, ++ Label* on_bit_set) { ++ __ li(a0, Operand(table)); ++ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { ++ __ And(a1, current_character(), Operand(kTableSize - 1)); ++ __ Add_d(a0, a0, a1); ++ } else { ++ __ Add_d(a0, a0, current_character()); ++ } ++ ++ __ Ld_bu(a0, FieldMemOperand(a0, ByteArray::kHeaderSize)); ++ BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg)); ++} ++ ++bool RegExpMacroAssemblerLA64::CheckSpecialCharacterClass(uc16 type, ++ Label* on_no_match) { ++ // Range checks (c in min..max) are generally implemented by an unsigned ++ // (c - min) <= (max - min) check. ++ switch (type) { ++ case 's': ++ // Match space-characters. ++ if (mode_ == LATIN1) { ++ // One byte space characters are '\t'..'\r', ' ' and \u00a0. ++ Label success; ++ __ Branch(&success, eq, current_character(), Operand(' ')); ++ // Check range 0x09..0x0D. ++ __ Sub_d(a0, current_character(), Operand('\t')); ++ __ Branch(&success, ls, a0, Operand('\r' - '\t')); ++ // \u00a0 (NBSP). ++ BranchOrBacktrack(on_no_match, ne, a0, Operand(0x00A0 - '\t')); ++ __ bind(&success); ++ return true; ++ } ++ return false; ++ case 'S': ++ // The emitted code for generic character classes is good enough. ++ return false; ++ case 'd': ++ // Match Latin1 digits ('0'..'9'). ++ __ Sub_d(a0, current_character(), Operand('0')); ++ BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0')); ++ return true; ++ case 'D': ++ // Match non Latin1-digits. ++ __ Sub_d(a0, current_character(), Operand('0')); ++ BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0')); ++ return true; ++ case '.': { ++ // Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). ++ __ Xor(a0, current_character(), Operand(0x01)); ++ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. ++ __ Sub_d(a0, a0, Operand(0x0B)); ++ BranchOrBacktrack(on_no_match, ls, a0, Operand(0x0C - 0x0B)); ++ if (mode_ == UC16) { ++ // Compare original value to 0x2028 and 0x2029, using the already ++ // computed (current_char ^ 0x01 - 0x0B). I.e., check for ++ // 0x201D (0x2028 - 0x0B) or 0x201E. ++ __ Sub_d(a0, a0, Operand(0x2028 - 0x0B)); ++ BranchOrBacktrack(on_no_match, ls, a0, Operand(1)); ++ } ++ return true; ++ } ++ case 'n': { ++ // Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). ++ __ Xor(a0, current_character(), Operand(0x01)); ++ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. ++ __ Sub_d(a0, a0, Operand(0x0B)); ++ if (mode_ == LATIN1) { ++ BranchOrBacktrack(on_no_match, hi, a0, Operand(0x0C - 0x0B)); ++ } else { ++ Label done; ++ BranchOrBacktrack(&done, ls, a0, Operand(0x0C - 0x0B)); ++ // Compare original value to 0x2028 and 0x2029, using the already ++ // computed (current_char ^ 0x01 - 0x0B). I.e., check for ++ // 0x201D (0x2028 - 0x0B) or 0x201E. ++ __ Sub_d(a0, a0, Operand(0x2028 - 0x0B)); ++ BranchOrBacktrack(on_no_match, hi, a0, Operand(1)); ++ __ bind(&done); ++ } ++ return true; ++ } ++ case 'w': { ++ if (mode_ != LATIN1) { ++ // Table is 256 entries, so all Latin1 characters can be tested. ++ BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z')); ++ } ++ ExternalReference map = ++ ExternalReference::re_word_character_map(isolate()); ++ __ li(a0, Operand(map)); ++ __ Add_d(a0, a0, current_character()); ++ __ Ld_bu(a0, MemOperand(a0, 0)); ++ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); ++ return true; ++ } ++ case 'W': { ++ Label done; ++ if (mode_ != LATIN1) { ++ // Table is 256 entries, so all Latin1 characters can be tested. ++ __ Branch(&done, hi, current_character(), Operand('z')); ++ } ++ ExternalReference map = ++ ExternalReference::re_word_character_map(isolate()); ++ __ li(a0, Operand(map)); ++ __ Add_d(a0, a0, current_character()); ++ __ Ld_bu(a0, MemOperand(a0, 0)); ++ BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); ++ if (mode_ != LATIN1) { ++ __ bind(&done); ++ } ++ return true; ++ } ++ case '*': ++ // Match any character. ++ return true; ++ // No custom implementation (yet): s(UC16), S(UC16). ++ default: ++ return false; ++ } ++} ++ ++void RegExpMacroAssemblerLA64::Fail() { ++ __ li(a0, Operand(FAILURE)); ++ __ jmp(&exit_label_); ++} ++ ++Handle RegExpMacroAssemblerLA64::GetCode(Handle source) { ++ Label return_v0; ++ if (0 /* todo masm_->has_exception()*/) { ++ // If the code gets corrupted due to long regular expressions and lack of ++ // space on trampolines, an internal exception flag is set. If this case ++ // is detected, we will jump into exit sequence right away. ++ //__ bind_to(&entry_label_, internal_failure_label_.pos()); ++ } else { ++ // Finalize code - write the entry point code now we know how many ++ // registers we need. ++ ++ // Entry code: ++ __ bind(&entry_label_); ++ ++ // Tell the system that we have a stack frame. Because the type is MANUAL, ++ // no is generated. ++ FrameScope scope(masm_, StackFrame::MANUAL); ++ ++ // Actually emit code to start a new stack frame. ++ // Push arguments ++ // Save callee-save registers. ++ // Start new stack frame. ++ // Store link register in existing stack-cell. ++ // Order here should correspond to order of offset constants in header file. ++ // TODO(plind): we save s0..s7, but ONLY use s3 here - use the regs ++ // or dont save. ++ RegList registers_to_retain = s0.bit() | s1.bit() | s2.bit() | s3.bit() | ++ s4.bit() | s5.bit() | s6.bit() | s7.bit(); ++ RegList argument_registers = a0.bit() | a1.bit() | a2.bit() | a3.bit(); ++ ++ argument_registers |= a4.bit() | a5.bit() | a6.bit() | a7.bit(); ++ ++ __ MultiPush(ra.bit(), fp.bit(), argument_registers | registers_to_retain); ++ // Set frame pointer in space for it if this is not a direct call ++ // from generated code. ++ // TODO(plind): this 8 is the # of argument regs, should have definition. ++ __ Add_d(frame_pointer(), sp, Operand(8 * kPointerSize)); ++ STATIC_ASSERT(kSuccessfulCaptures == kInputString - kSystemPointerSize); ++ __ mov(a0, zero_reg); ++ __ push(a0); // Make room for success counter and initialize it to 0. ++ STATIC_ASSERT(kStringStartMinusOne == ++ kSuccessfulCaptures - kSystemPointerSize); ++ __ push(a0); // Make room for "string start - 1" constant. ++ STATIC_ASSERT(kBacktrackCount == kStringStartMinusOne - kSystemPointerSize); ++ __ push(a0); // The backtrack counter ++ ++ // Check if we have space on the stack for registers. ++ Label stack_limit_hit; ++ Label stack_ok; ++ ++ ExternalReference stack_limit = ++ ExternalReference::address_of_jslimit(masm_->isolate()); ++ __ li(a0, Operand(stack_limit)); ++ __ Ld_d(a0, MemOperand(a0, 0)); ++ __ Sub_d(a0, sp, a0); ++ // Handle it if the stack pointer is already below the stack limit. ++ __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg)); ++ // Check if there is room for the variable number of registers above ++ // the stack limit. ++ __ Branch(&stack_ok, hs, a0, extra_space_for_variables); ++ // Exit with OutOfMemory exception. There is not enough space on the stack ++ // for our working registers. ++ __ li(a0, Operand(EXCEPTION)); ++ __ jmp(&return_v0); ++ ++ __ bind(&stack_limit_hit); ++ CallCheckStackGuardState(a0, extra_space_for_variables); ++ // If returned value is non-zero, we exit with the returned value as result. ++ __ Branch(&return_v0, ne, a0, Operand(zero_reg)); ++ ++ __ bind(&stack_ok); ++ // Allocate space on stack for registers. ++ __ Sub_d(sp, sp, Operand(num_registers_ * kPointerSize)); ++ // Load string end. ++ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ // Load input start. ++ __ Ld_d(a0, MemOperand(frame_pointer(), kInputStart)); ++ // Find negative length (offset of start relative to end). ++ __ Sub_d(current_input_offset(), a0, end_of_input_address()); ++ // Set a0 to address of char before start of the input string ++ // (effectively string position -1). ++ __ Ld_d(a1, MemOperand(frame_pointer(), kStartIndex)); ++ __ Sub_d(a0, current_input_offset(), Operand(char_size())); ++ __ slli_d(t1, a1, (mode_ == UC16) ? 1 : 0); ++ __ Sub_d(a0, a0, t1); ++ // Store this value in a local variable, for use when clearing ++ // position registers. ++ __ St_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ ++ // Initialize code pointer register ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ ++ Label load_char_start_regexp, start_regexp; ++ // Load newline if index is at start, previous character otherwise. ++ __ Branch(&load_char_start_regexp, ne, a1, Operand(zero_reg)); ++ __ li(current_character(), Operand('\n')); ++ __ jmp(&start_regexp); ++ ++ // Global regexp restarts matching here. ++ __ bind(&load_char_start_regexp); ++ // Load previous char as initial value of current character register. ++ LoadCurrentCharacterUnchecked(-1, 1); ++ __ bind(&start_regexp); ++ ++ // Initialize on-stack registers. ++ if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. ++ // Fill saved registers with initial value = start offset - 1. ++ if (num_saved_registers_ > 8) { ++ // Address of register 0. ++ __ Add_d(a1, frame_pointer(), Operand(kRegisterZero)); ++ __ li(a2, Operand(num_saved_registers_)); ++ Label init_loop; ++ __ bind(&init_loop); ++ __ St_d(a0, MemOperand(a1, 0)); ++ __ Add_d(a1, a1, Operand(-kPointerSize)); ++ __ Sub_d(a2, a2, Operand(1)); ++ __ Branch(&init_loop, ne, a2, Operand(zero_reg)); ++ } else { ++ for (int i = 0; i < num_saved_registers_; i++) { ++ __ St_d(a0, register_location(i)); ++ } ++ } ++ } ++ ++ // Initialize backtrack stack pointer. ++ __ Ld_d(backtrack_stackpointer(), ++ MemOperand(frame_pointer(), kStackHighEnd)); ++ ++ __ jmp(&start_label_); ++ ++ // Exit code: ++ if (success_label_.is_linked()) { ++ // Save captures when successful. ++ __ bind(&success_label_); ++ if (num_saved_registers_ > 0) { ++ // Copy captures to output. ++ __ Ld_d(a1, MemOperand(frame_pointer(), kInputStart)); ++ __ Ld_d(a0, MemOperand(frame_pointer(), kRegisterOutput)); ++ __ Ld_d(a2, MemOperand(frame_pointer(), kStartIndex)); ++ __ Sub_d(a1, end_of_input_address(), a1); ++ // a1 is length of input in bytes. ++ if (mode_ == UC16) { ++ __ srli_d(a1, a1, 1); ++ } ++ // a1 is length of input in characters. ++ __ Add_d(a1, a1, Operand(a2)); ++ // a1 is length of string in characters. ++ ++ DCHECK_EQ(0, num_saved_registers_ % 2); ++ // Always an even number of capture registers. This allows us to ++ // unroll the loop once to add an operation between a load of a register ++ // and the following use of that register. ++ for (int i = 0; i < num_saved_registers_; i += 2) { ++ __ Ld_d(a2, register_location(i)); ++ __ Ld_d(a3, register_location(i + 1)); ++ if (i == 0 && global_with_zero_length_check()) { ++ // Keep capture start in a4 for the zero-length check later. ++ __ mov(t3, a2); ++ } ++ if (mode_ == UC16) { ++ __ srai_d(a2, a2, 1); ++ __ Add_d(a2, a2, a1); ++ __ srai_d(a3, a3, 1); ++ __ Add_d(a3, a3, a1); ++ } else { ++ __ Add_d(a2, a1, Operand(a2)); ++ __ Add_d(a3, a1, Operand(a3)); ++ } ++ // V8 expects the output to be an int32_t array. ++ __ St_w(a2, MemOperand(a0, 0)); ++ __ Add_d(a0, a0, kIntSize); ++ __ St_w(a3, MemOperand(a0, 0)); ++ __ Add_d(a0, a0, kIntSize); ++ } ++ } ++ ++ if (global()) { ++ // Restart matching if the regular expression is flagged as global. ++ __ Ld_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ __ Ld_d(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); ++ __ Ld_d(a2, MemOperand(frame_pointer(), kRegisterOutput)); ++ // Increment success counter. ++ __ Add_d(a0, a0, 1); ++ __ St_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ // Capture results have been stored, so the number of remaining global ++ // output registers is reduced by the number of stored captures. ++ __ Sub_d(a1, a1, num_saved_registers_); ++ // Check whether we have enough room for another set of capture results. ++ //__ mov(v0, a0); ++ __ Branch(&return_v0, lt, a1, Operand(num_saved_registers_)); ++ ++ __ St_d(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); ++ // Advance the location for output. ++ __ Add_d(a2, a2, num_saved_registers_ * kIntSize); ++ __ St_d(a2, MemOperand(frame_pointer(), kRegisterOutput)); ++ ++ // Prepare a0 to initialize registers with its value in the next run. ++ __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ ++ if (global_with_zero_length_check()) { ++ // Special case for zero-length matches. ++ // t3: capture start index ++ // Not a zero-length match, restart. ++ __ Branch(&load_char_start_regexp, ne, current_input_offset(), ++ Operand(t3)); ++ // Offset from the end is zero if we already reached the end. ++ __ Branch(&exit_label_, eq, current_input_offset(), ++ Operand(zero_reg)); ++ // Advance current position after a zero-length match. ++ Label advance; ++ __ bind(&advance); ++ __ Add_d(current_input_offset(), current_input_offset(), ++ Operand((mode_ == UC16) ? 2 : 1)); ++ if (global_unicode()) CheckNotInSurrogatePair(0, &advance); ++ } ++ ++ __ Branch(&load_char_start_regexp); ++ } else { ++ __ li(a0, Operand(SUCCESS)); ++ } ++ } ++ // Exit and return v0. ++ __ bind(&exit_label_); ++ if (global()) { ++ __ Ld_d(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ } ++ ++ __ bind(&return_v0); ++ // Skip sp past regexp registers and local variables.. ++ __ mov(sp, frame_pointer()); ++ // Restore registers s0..s7 and return (restoring ra to pc). ++ __ MultiPop(ra.bit(), fp.bit(), registers_to_retain); ++ __ Ret(); ++ ++ // Backtrack code (branch target for conditional backtracks). ++ if (backtrack_label_.is_linked()) { ++ __ bind(&backtrack_label_); ++ Backtrack(); ++ } ++ ++ Label exit_with_exception; ++ ++ // Preempt-code. ++ if (check_preempt_label_.is_linked()) { ++ SafeCallTarget(&check_preempt_label_); ++ // Put regexp engine registers on stack. ++ RegList regexp_registers_to_retain = current_input_offset().bit() | ++ current_character().bit() | ++ backtrack_stackpointer().bit(); ++ __ MultiPush(regexp_registers_to_retain); ++ CallCheckStackGuardState(a0); ++ __ MultiPop(regexp_registers_to_retain); ++ // If returning non-zero, we should end execution with the given ++ // result as return value. ++ __ Branch(&return_v0, ne, a0, Operand(zero_reg)); ++ ++ // String might have moved: Reload end of string from frame. ++ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ SafeReturn(); ++ } ++ ++ // Backtrack stack overflow code. ++ if (stack_overflow_label_.is_linked()) { ++ SafeCallTarget(&stack_overflow_label_); ++ // Reached if the backtrack-stack limit has been hit. ++ // Put regexp engine registers on stack first. ++ RegList regexp_registers = ++ current_input_offset().bit() | current_character().bit(); ++ __ MultiPush(regexp_registers); ++ ++ // Call GrowStack(backtrack_stackpointer(), &stack_base) ++ static const int num_arguments = 3; ++ __ PrepareCallCFunction(num_arguments, a0); ++ __ mov(a0, backtrack_stackpointer()); ++ __ Add_d(a1, frame_pointer(), Operand(kStackHighEnd)); ++ __ li(a2, Operand(ExternalReference::isolate_address(masm_->isolate()))); ++ ExternalReference grow_stack = ++ ExternalReference::re_grow_stack(masm_->isolate()); ++ __ CallCFunction(grow_stack, num_arguments); ++ // Restore regexp registers. ++ __ MultiPop(regexp_registers); ++ // If return nullptr, we have failed to grow the stack, and ++ // must exit with a stack-overflow exception. ++ __ Branch(&exit_with_exception, eq, a0, Operand(zero_reg)); ++ // Otherwise use return value as new stack pointer. ++ __ mov(backtrack_stackpointer(), a0); ++ // Restore saved registers and continue. ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ __ Ld_d(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ SafeReturn(); ++ } ++ ++ if (exit_with_exception.is_linked()) { ++ // If any of the code above needed to exit with an exception. ++ __ bind(&exit_with_exception); ++ // Exit with Result EXCEPTION(-1) to signal thrown exception. ++ __ li(a0, Operand(EXCEPTION)); ++ __ jmp(&return_v0); ++ } ++ } ++ ++ CodeDesc code_desc; ++ masm_->GetCode(isolate(), &code_desc); ++ Handle code = ++ Factory::CodeBuilder(isolate(), code_desc, CodeKind::REGEXP) ++ .set_self_reference(masm_->CodeObject()) ++ .Build(); ++ LOG(masm_->isolate(), ++ RegExpCodeCreateEvent(Handle::cast(code), source)); ++ return Handle::cast(code); ++} ++ ++void RegExpMacroAssemblerLA64::GoTo(Label* to) { ++ if (to == nullptr) { ++ Backtrack(); ++ return; ++ } ++ __ jmp(to); ++ return; ++} ++ ++void RegExpMacroAssemblerLA64::IfRegisterGE(int reg, int comparand, ++ Label* if_ge) { ++ __ Ld_d(a0, register_location(reg)); ++ BranchOrBacktrack(if_ge, ge, a0, Operand(comparand)); ++} ++ ++void RegExpMacroAssemblerLA64::IfRegisterLT(int reg, int comparand, ++ Label* if_lt) { ++ __ Ld_d(a0, register_location(reg)); ++ BranchOrBacktrack(if_lt, lt, a0, Operand(comparand)); ++} ++ ++void RegExpMacroAssemblerLA64::IfRegisterEqPos(int reg, Label* if_eq) { ++ __ Ld_d(a0, register_location(reg)); ++ BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset())); ++} ++ ++RegExpMacroAssembler::IrregexpImplementation ++RegExpMacroAssemblerLA64::Implementation() { ++ return kLA64Implementation; ++} ++ ++void RegExpMacroAssemblerLA64::PopCurrentPosition() { ++ Pop(current_input_offset()); ++} ++ ++void RegExpMacroAssemblerLA64::PopRegister(int register_index) { ++ Pop(a0); ++ __ St_d(a0, register_location(register_index)); ++} ++ ++void RegExpMacroAssemblerLA64::PushBacktrack(Label* label) { ++ if (label->is_bound()) { ++ int target = label->pos(); ++ __ li(a0, Operand(target + Code::kHeaderSize - kHeapObjectTag)); ++ } else { ++ // TODO: Optimize like arm64 without ld_wu? ++ Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); ++ Label after_constant; ++ __ Branch(&after_constant); ++ int offset = masm_->pc_offset(); ++ int cp_offset = offset + Code::kHeaderSize - kHeapObjectTag; ++ //__ emit(0); ++ __ nop(); ++ masm_->label_at_put(label, offset); ++ __ bind(&after_constant); ++ if (is_int12(cp_offset)) { ++ __ Ld_wu(a0, MemOperand(code_pointer(), cp_offset)); ++ } else { ++ __ Add_d(a0, code_pointer(), cp_offset); ++ __ Ld_wu(a0, MemOperand(a0, 0)); ++ } ++ } ++ Push(a0); ++ CheckStackLimit(); ++} ++ ++void RegExpMacroAssemblerLA64::PushCurrentPosition() { ++ Push(current_input_offset()); ++} ++ ++void RegExpMacroAssemblerLA64::PushRegister(int register_index, ++ StackCheckFlag check_stack_limit) { ++ __ Ld_d(a0, register_location(register_index)); ++ Push(a0); ++ if (check_stack_limit) CheckStackLimit(); ++} ++ ++void RegExpMacroAssemblerLA64::ReadCurrentPositionFromRegister(int reg) { ++ __ Ld_d(current_input_offset(), register_location(reg)); ++} ++ ++void RegExpMacroAssemblerLA64::ReadStackPointerFromRegister(int reg) { ++ __ Ld_d(backtrack_stackpointer(), register_location(reg)); ++ __ Ld_d(a0, MemOperand(frame_pointer(), kStackHighEnd)); ++ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0)); ++} ++ ++void RegExpMacroAssemblerLA64::SetCurrentPositionFromEnd(int by) { ++ Label after_position; ++ __ Branch(&after_position, ge, current_input_offset(), ++ Operand(-by * char_size())); ++ __ li(current_input_offset(), -by * char_size()); ++ // On RegExp code entry (where this operation is used), the character before ++ // the current position is expected to be already loaded. ++ // We have advanced the position, so it's safe to read backwards. ++ LoadCurrentCharacterUnchecked(-1, 1); ++ __ bind(&after_position); ++} ++ ++void RegExpMacroAssemblerLA64::SetRegister(int register_index, int to) { ++ DCHECK(register_index >= num_saved_registers_); // Reserved for positions! ++ __ li(a0, Operand(to)); ++ __ St_d(a0, register_location(register_index)); ++} ++ ++bool RegExpMacroAssemblerLA64::Succeed() { ++ __ jmp(&success_label_); ++ return global(); ++} ++ ++void RegExpMacroAssemblerLA64::WriteCurrentPositionToRegister(int reg, ++ int cp_offset) { ++ if (cp_offset == 0) { ++ __ St_d(current_input_offset(), register_location(reg)); ++ } else { ++ __ Add_d(a0, current_input_offset(), Operand(cp_offset * char_size())); ++ __ St_d(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerLA64::ClearRegisters(int reg_from, int reg_to) { ++ DCHECK(reg_from <= reg_to); ++ __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ for (int reg = reg_from; reg <= reg_to; reg++) { ++ __ St_d(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerLA64::WriteStackPointerToRegister(int reg) { ++ __ Ld_d(a1, MemOperand(frame_pointer(), kStackHighEnd)); ++ __ Sub_d(a0, backtrack_stackpointer(), a1); ++ __ St_d(a0, register_location(reg)); ++} ++ ++bool RegExpMacroAssemblerLA64::CanReadUnaligned() { return false; } ++ ++// Private methods: ++ ++void RegExpMacroAssemblerLA64::CallCheckStackGuardState(Register scratch, ++ Operand extra_space) { ++ DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); ++ DCHECK(!masm_->options().isolate_independent_code); ++ ++ int stack_alignment = base::OS::ActivationFrameAlignment(); ++ ++ // Align the stack pointer and save the original sp value on the stack. ++ __ mov(scratch, sp); ++ __ Sub_d(sp, sp, Operand(kPointerSize)); ++ DCHECK(base::bits::IsPowerOfTwo(stack_alignment)); ++ __ And(sp, sp, Operand(-stack_alignment)); ++ __ St_d(scratch, MemOperand(sp, 0)); ++ // Extra space for variables. ++ __ li(a3, extra_space); ++ // RegExp code frame pointer. ++ __ mov(a2, frame_pointer()); ++ // Code of self. ++ __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ ++ // We need to make room for the return address on the stack. ++ DCHECK(IsAligned(stack_alignment, kPointerSize)); ++ __ Sub_d(sp, sp, Operand(stack_alignment)); ++ ++ ++ // a0 will point to the return address, placed by DirectCEntry. ++ __ mov(a0, sp); ++ ++ ExternalReference stack_guard_check = ++ ExternalReference::re_check_stack_guard_state(masm_->isolate()); ++ __ li(t7, Operand(stack_guard_check)); ++ ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ CHECK(Builtins::IsIsolateIndependent(Builtins::kDirectCEntry)); ++ Address entry = d.InstructionStartOfBuiltin(Builtins::kDirectCEntry); ++ __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ __ Call(kScratchReg); ++ ++ __ Ld_d(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize)); ++ ++ __ li(code_pointer(), Operand(masm_->CodeObject())); ++} ++ ++// Helper function for reading a value out of a stack frame. ++template ++static T& frame_entry(Address re_frame, int frame_offset) { ++ return reinterpret_cast(Memory(re_frame + frame_offset)); ++} ++ ++template ++static T* frame_entry_address(Address re_frame, int frame_offset) { ++ return reinterpret_cast(re_frame + frame_offset); ++} ++ ++int64_t RegExpMacroAssemblerLA64::CheckStackGuardState(Address* return_address, ++ Address raw_code, ++ Address re_frame, ++ uintptr_t extra_space) { ++ Code re_code = Code::cast(Object(raw_code)); ++ return NativeRegExpMacroAssembler::CheckStackGuardState( ++ frame_entry(re_frame, kIsolate), ++ static_cast(frame_entry(re_frame, kStartIndex)), ++ static_cast( ++ frame_entry(re_frame, kDirectCall)), ++ return_address, re_code, ++ frame_entry_address
(re_frame, kInputString), ++ frame_entry_address(re_frame, kInputStart), ++ frame_entry_address(re_frame, kInputEndOffset), ++ extra_space); ++} ++ ++MemOperand RegExpMacroAssemblerLA64::register_location(int register_index) { ++ DCHECK(register_index < (1 << 30)); ++ if (num_registers_ <= register_index) { ++ num_registers_ = register_index + 1; ++ } ++ return MemOperand(frame_pointer(), ++ kRegisterZero - register_index * kPointerSize); ++} ++ ++void RegExpMacroAssemblerLA64::CheckPosition(int cp_offset, ++ Label* on_outside_input) { ++ if (cp_offset >= 0) { ++ BranchOrBacktrack(on_outside_input, ge, current_input_offset(), ++ Operand(-cp_offset * char_size())); ++ } else { ++ __ Ld_d(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add_d(a0, current_input_offset(), Operand(cp_offset * char_size())); ++ BranchOrBacktrack(on_outside_input, le, a0, Operand(a1)); ++ } ++} ++ ++void RegExpMacroAssemblerLA64::BranchOrBacktrack(Label* to, Condition condition, ++ Register rs, ++ const Operand& rt) { ++ if (condition == al) { // Unconditional. ++ if (to == nullptr) { ++ Backtrack(); ++ return; ++ } ++ __ jmp(to); ++ return; ++ } ++ if (to == nullptr) { ++ __ Branch(&backtrack_label_, condition, rs, rt); ++ return; ++ } ++ __ Branch(to, condition, rs, rt); ++} ++ ++void RegExpMacroAssemblerLA64::SafeCall(Label* to, Condition cond, Register rs, ++ const Operand& rt) { ++ __ Branch(to, cond, rs, rt, true); ++} ++ ++void RegExpMacroAssemblerLA64::SafeReturn() { ++ __ pop(ra); ++ __ Add_d(t1, ra, Operand(masm_->CodeObject())); ++ __ Jump(t1); ++} ++ ++void RegExpMacroAssemblerLA64::SafeCallTarget(Label* name) { ++ __ bind(name); ++ __ Sub_d(ra, ra, Operand(masm_->CodeObject())); ++ __ push(ra); ++} ++ ++void RegExpMacroAssemblerLA64::Push(Register source) { ++ DCHECK(source != backtrack_stackpointer()); ++ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), ++ Operand(-kIntSize)); ++ __ St_w(source, MemOperand(backtrack_stackpointer(), 0)); ++} ++ ++void RegExpMacroAssemblerLA64::Pop(Register target) { ++ DCHECK(target != backtrack_stackpointer()); ++ __ Ld_w(target, MemOperand(backtrack_stackpointer(), 0)); ++ __ Add_d(backtrack_stackpointer(), backtrack_stackpointer(), kIntSize); ++} ++ ++void RegExpMacroAssemblerLA64::CheckPreemption() { ++ // Check for preemption. ++ ExternalReference stack_limit = ++ ExternalReference::address_of_jslimit(masm_->isolate()); ++ Operand extra_space_for_variables(num_registers_ * kSystemPointerSize); ++ __ li(a0, Operand(stack_limit)); ++ __ Ld_d(a0, MemOperand(a0, 0)); ++ SafeCall(&check_preempt_label_, ls, sp, Operand(a0)); ++} ++ ++void RegExpMacroAssemblerLA64::CheckStackLimit() { ++ ExternalReference stack_limit = ++ ExternalReference::address_of_regexp_stack_limit_address( ++ masm_->isolate()); ++ ++ __ li(a0, Operand(stack_limit)); ++ __ Ld_d(a0, MemOperand(a0, 0)); ++ SafeCall(&stack_overflow_label_, ls, backtrack_stackpointer(), Operand(a0)); ++} ++ ++void RegExpMacroAssemblerLA64::LoadCurrentCharacterUnchecked(int cp_offset, ++ int characters) { ++ Register offset = current_input_offset(); ++ if (cp_offset != 0) { ++ // t3 is not being used to store the capture start index at this point. ++ __ Add_d(t3, current_input_offset(), Operand(cp_offset * char_size())); ++ offset = t3; ++ } ++ // We assume that we cannot do unaligned loads on LA64, so this function ++ // must only be used to load a single character at a time. ++ DCHECK_EQ(1, characters); ++ __ Add_d(t1, end_of_input_address(), Operand(offset)); ++ if (mode_ == LATIN1) { ++ __ Ld_bu(current_character(), MemOperand(t1, 0)); ++ } else { ++ DCHECK(mode_ == UC16); ++ __ Ld_hu(current_character(), MemOperand(t1, 0)); ++ } ++} ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++ ++#endif //V8_TARGET_ARCH_LOONGARCH64 +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h +@@ -0,0 +1,211 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ ++#define V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ ++ ++#include "src/codegen/loongarch64/assembler-loongarch64.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/regexp/regexp-macro-assembler.h" ++ ++namespace v8 { ++namespace internal { ++ ++class V8_EXPORT_PRIVATE RegExpMacroAssemblerLA64 ++ : public NativeRegExpMacroAssembler { ++ public: ++ RegExpMacroAssemblerLA64(Isolate* isolate, Zone* zone, Mode mode, ++ int registers_to_save); ++ virtual ~RegExpMacroAssemblerLA64(); ++ virtual int stack_limit_slack(); ++ virtual void AdvanceCurrentPosition(int by); ++ virtual void AdvanceRegister(int reg, int by); ++ virtual void Backtrack(); ++ virtual void Bind(Label* label); ++ virtual void CheckAtStart(int cp_offset, Label* on_at_start); ++ virtual void CheckCharacter(uint32_t c, Label* on_equal); ++ virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, ++ Label* on_equal); ++ virtual void CheckCharacterGT(uc16 limit, Label* on_greater); ++ virtual void CheckCharacterLT(uc16 limit, Label* on_less); ++ // A "greedy loop" is a loop that is both greedy and with a simple ++ // body. It has a particularly simple implementation. ++ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); ++ virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start); ++ virtual void CheckNotBackReference(int start_reg, bool read_backward, ++ Label* on_no_match); ++ virtual void CheckNotBackReferenceIgnoreCase(int start_reg, ++ bool read_backward, bool unicode, ++ Label* on_no_match); ++ virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); ++ virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, ++ Label* on_not_equal); ++ virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask, ++ Label* on_not_equal); ++ virtual void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range); ++ virtual void CheckCharacterNotInRange(uc16 from, uc16 to, ++ Label* on_not_in_range); ++ virtual void CheckBitInTable(Handle table, Label* on_bit_set); ++ ++ // Checks whether the given offset from the current position is before ++ // the end of the string. ++ virtual void CheckPosition(int cp_offset, Label* on_outside_input); ++ virtual bool CheckSpecialCharacterClass(uc16 type, Label* on_no_match); ++ virtual void Fail(); ++ virtual Handle GetCode(Handle source); ++ virtual void GoTo(Label* label); ++ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); ++ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); ++ virtual void IfRegisterEqPos(int reg, Label* if_eq); ++ virtual IrregexpImplementation Implementation(); ++ virtual void LoadCurrentCharacterUnchecked(int cp_offset, ++ int character_count); ++ virtual void PopCurrentPosition(); ++ virtual void PopRegister(int register_index); ++ virtual void PushBacktrack(Label* label); ++ virtual void PushCurrentPosition(); ++ virtual void PushRegister(int register_index, ++ StackCheckFlag check_stack_limit); ++ virtual void ReadCurrentPositionFromRegister(int reg); ++ virtual void ReadStackPointerFromRegister(int reg); ++ virtual void SetCurrentPositionFromEnd(int by); ++ virtual void SetRegister(int register_index, int to); ++ virtual bool Succeed(); ++ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); ++ virtual void ClearRegisters(int reg_from, int reg_to); ++ virtual void WriteStackPointerToRegister(int reg); ++ virtual bool CanReadUnaligned(); ++ ++ // Called from RegExp if the stack-guard is triggered. ++ // If the code object is relocated, the return address is fixed before ++ // returning. ++ // {raw_code} is an Address because this is called via ExternalReference. ++ static int64_t CheckStackGuardState(Address* return_address, Address raw_code, ++ Address re_frame, uintptr_t extra_space); ++ ++ void print_regexp_frame_constants(); ++ ++ private: ++ // Offsets from frame_pointer() of function parameters and stored registers. ++ static const int kFramePointer = 0; ++ ++ // Above the frame pointer - Stored registers and stack passed parameters. ++ // Registers s0 to s7, fp, and ra. ++ static const int kStoredRegisters = kFramePointer; ++ // Return address (stored from link register, read into pc on return). ++ ++ // TODO(plind): This 9 - is 8 s-regs (s0..s7) plus fp. ++ ++ static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize; ++ // Stack frame header. ++ static const int kStackFrameHeader = kReturnAddress; ++ // Stack parameters placed by caller. ++ static const int kIsolate = kStackFrameHeader + kPointerSize; ++ ++ // Below the frame pointer. ++ // Register parameters stored by setup code. ++ static const int kDirectCall = kFramePointer - kPointerSize; ++ static const int kStackHighEnd = kDirectCall - kPointerSize; ++ static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; ++ static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; ++ static const int kInputEnd = kRegisterOutput - kPointerSize; ++ static const int kInputStart = kInputEnd - kPointerSize; ++ static const int kStartIndex = kInputStart - kPointerSize; ++ static const int kInputString = kStartIndex - kPointerSize; ++ // When adding local variables remember to push space for them in ++ // the frame in GetCode. ++ static const int kSuccessfulCaptures = kInputString - kPointerSize; ++ static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize; ++ static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize; ++ // First register address. Following registers are below it on the stack. ++ static const int kRegisterZero = kBacktrackCount - kSystemPointerSize; ++ ++ // Initial size of code buffer. ++ static const int kRegExpCodeSize = 1024; ++ ++ // Check whether preemption has been requested. ++ void CheckPreemption(); ++ ++ // Check whether we are exceeding the stack limit on the backtrack stack. ++ void CheckStackLimit(); ++ ++ // Generate a call to CheckStackGuardState. ++ void CallCheckStackGuardState(Register scratch, ++ Operand extra_space = Operand(0)); ++ // The ebp-relative location of a regexp register. ++ MemOperand register_location(int register_index); ++ ++ // Register holding the current input position as negative offset from ++ // the end of the string. ++ inline Register current_input_offset() { return a6; } ++ ++ // The register containing the current character after LoadCurrentCharacter. ++ inline Register current_character() { return a7; } ++ ++ // Register holding address of the end of the input string. ++ inline Register end_of_input_address() { return t2; } ++ ++ // Register holding the frame address. Local variables, parameters and ++ // regexp registers are addressed relative to this. ++ inline Register frame_pointer() { return fp; } ++ ++ // The register containing the backtrack stack top. Provides a meaningful ++ // name to the register. ++ inline Register backtrack_stackpointer() { return t0; } ++ ++ // Register holding pointer to the current code object. ++ inline Register code_pointer() { return a5; } ++ ++ // Byte size of chars in the string to match (decided by the Mode argument). ++ inline int char_size() { return static_cast(mode_); } ++ ++ // Equivalent to a conditional branch to the label, unless the label ++ // is nullptr, in which case it is a conditional Backtrack. ++ void BranchOrBacktrack(Label* to, Condition condition, Register rs, ++ const Operand& rt); ++ ++ // Call and return internally in the generated code in a way that ++ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) ++ inline void SafeCall(Label* to, Condition cond, Register rs, ++ const Operand& rt); ++ inline void SafeReturn(); ++ inline void SafeCallTarget(Label* name); ++ ++ // Pushes the value of a register on the backtrack stack. Decrements the ++ // stack pointer by a word size and stores the register's value there. ++ inline void Push(Register source); ++ ++ // Pops a value from the backtrack stack. Reads the word at the stack pointer ++ // and increments it by a word size. ++ inline void Pop(Register target); ++ ++ Isolate* isolate() const { return masm_->isolate(); } ++ ++ MacroAssembler* masm_; ++ ++ // Which mode to generate code for (Latin1 or UC16). ++ Mode mode_; ++ ++ // One greater than maximal register index actually used. ++ int num_registers_; ++ ++ // Number of registers to output at the end (the saved registers ++ // are always 0..num_saved_registers_-1). ++ int num_saved_registers_; ++ ++ // Labels used internally. ++ Label entry_label_; ++ Label start_label_; ++ Label success_label_; ++ Label backtrack_label_; ++ Label exit_label_; ++ Label check_preempt_label_; ++ Label stack_overflow_label_; ++ Label internal_failure_label_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_REGEXP_LOONGARCH64_REGEXP_MACRO_ASSEMBLER_LOONGARCH64_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h +@@ -21,6 +21,8 @@ + #include "src/regexp/mips/regexp-macro-assembler-mips.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/regexp/s390/regexp-macro-assembler-s390.h" + #else +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-tracer.cc +@@ -15,7 +15,7 @@ RegExpMacroAssemblerTracer::RegExpMacroA + : RegExpMacroAssembler(isolate, assembler->zone()), assembler_(assembler) { + IrregexpImplementation type = assembler->Implementation(); + DCHECK_LT(type, 9); +- const char* impl_names[] = {"IA32", "ARM", "ARM64", "MIPS", "S390", ++ const char* impl_names[] = {"IA32", "ARM", "ARM64", "MIPS", "LA64", "S390", + "PPC", "X64", "X87", "Bytecode"}; + PrintF("RegExpMacroAssembler%s();\n", impl_names[type]); + } +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h +@@ -44,6 +44,7 @@ class RegExpMacroAssembler { + kARMImplementation, + kARM64Implementation, + kMIPSImplementation, ++ kLA64Implementation, + kS390Implementation, + kPPCImplementation, + kX64Implementation, +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/regexp.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/regexp.cc +@@ -815,6 +815,9 @@ bool RegExpImpl::Compile(Isolate* isolat + #elif V8_TARGET_ARCH_MIPS64 + macro_assembler.reset(new RegExpMacroAssemblerMIPS(isolate, zone, mode, + output_register_count)); ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ macro_assembler.reset(new RegExpMacroAssemblerLA64(isolate, zone, mode, ++ output_register_count)); + #else + #error "Unsupported architecture" + #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc +@@ -19,7 +19,8 @@ namespace internal { + + // Other platforms have CSA support, see builtins-sharedarraybuffer-gen.h. + #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ +- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ ++ V8_TARGET_ARCH_LOONGARCH64 + + namespace { + +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/snapshot/deserializer.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/snapshot/deserializer.h +@@ -30,6 +30,7 @@ class Object; + // Used for platforms with embedded constant pools to trigger deserialization + // of objects found in code. + #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ ++ defined(V8_TARGET_ARCH_LOONGARCH64) || \ + defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ + defined(V8_TARGET_ARCH_PPC64) || V8_EMBEDDED_CONSTANT_POOL + #define V8_CODE_EMBEDS_OBJECT_POINTER 1 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc +@@ -151,7 +151,8 @@ int PlatformEmbeddedFileWriterGeneric::I + + DataDirective PlatformEmbeddedFileWriterGeneric::ByteChunkDataDirective() + const { +-#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) ++#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ ++ defined(V8_TARGET_ARCH_LOONGARCH64) + // MIPS uses a fixed 4 byte instruction set, using .long + // to prevent any unnecessary padding. + return kLong; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h +@@ -46,6 +46,14 @@ constexpr RegList kLiftoffAssemblerGpCac + constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( + f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26); + ++#elif V8_TARGET_ARCH_LOONGARCH64 ++/*todo*/ ++constexpr RegList kLiftoffAssemblerGpCacheRegs = ++ Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); ++ ++constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( ++ f0, f2, f4, f6, f8, f10, f12, f14, f16, f18, f20, f22, f24, f26); ++ + #elif V8_TARGET_ARCH_ARM + + // r7: cp, r10: root, r11: fp, r12: ip, r13: sp, r14: lr, r15: pc. +@@ -90,7 +98,7 @@ constexpr Condition kUnsignedLessEqual = + constexpr Condition kUnsignedGreaterThan = above; + constexpr Condition kUnsignedGreaterEqual = above_equal; + +-#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONGARCH64 + + constexpr Condition kEqual = eq; + constexpr Condition kUnequal = ne; +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h +@@ -1351,6 +1351,8 @@ class LiftoffStackSlots { + #include "src/wasm/baseline/mips/liftoff-assembler-mips.h" + #elif V8_TARGET_ARCH_MIPS64 + #include "src/wasm/baseline/mips64/liftoff-assembler-mips64.h" ++#elif V8_TARGET_ARCH_LOONGARCH64 ++#include "src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/wasm/baseline/s390/liftoff-assembler-s390.h" + #else +--- /dev/null ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/baseline/loongarch64/liftoff-assembler-loongarch64.h +@@ -0,0 +1,2080 @@ ++// Copyright 2017 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ ++#define V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ ++ ++#include "src/wasm/baseline/liftoff-assembler.h" ++ ++namespace v8 { ++namespace internal { ++namespace wasm { ++ ++namespace liftoff { ++ ++// Liftoff Frames. ++// ++// slot Frame ++// +--------------------+--------------------------- ++// n+4 | optional padding slot to keep the stack 16 byte aligned. ++// n+3 | parameter n | ++// ... | ... | ++// 4 | parameter 1 | or parameter 2 ++// 3 | parameter 0 | or parameter 1 ++// 2 | (result address) | or parameter 0 ++// -----+--------------------+--------------------------- ++// 1 | return addr (ra) | ++// 0 | previous frame (fp)| ++// -----+--------------------+ <-- frame ptr (fp) ++// -1 | 0xa: WASM | ++// -2 | instance | ++// -----+--------------------+--------------------------- ++// -3 | slot 0 | ^ ++// -4 | slot 1 | | ++// | | Frame slots ++// | | | ++// | | v ++// | optional padding slot to keep the stack 16 byte aligned. ++// -----+--------------------+ <-- stack ptr (sp) ++// ++ ++// fp-8 holds the stack marker, fp-16 is the instance parameter. ++constexpr int kInstanceOffset = 16; ++ ++inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); } ++ ++inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } ++ ++inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr, ++ Register offset, uint32_t offset_imm) { ++ if (is_uint31(offset_imm)) { ++ if (offset == no_reg) return MemOperand(addr, offset_imm); ++ assm->add_d(kScratchReg, addr, offset); ++ return MemOperand(kScratchReg, offset_imm); ++ } ++ // Offset immediate does not fit in 31 bits. ++ assm->li(kScratchReg, Operand(offset_imm)); ++ assm->add_d(kScratchReg, kScratchReg, addr); ++ if (offset != no_reg) { ++ assm->add_d(kScratchReg, kScratchReg, offset); ++ } ++ return MemOperand(kScratchReg, 0); ++} ++ ++inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, ++ ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->Ld_w(dst.gp(), src); ++ break; ++ case ValueType::kI64: ++ assm->Ld_d(dst.gp(), src); ++ break; ++ case ValueType::kF32: ++ assm->Fld_s(dst.fp(), src); ++ break; ++ case ValueType::kF64: ++ assm->Fld_d(dst.fp(), src); ++ break; ++ case ValueType::kS128: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++inline void Store(LiftoffAssembler* assm, Register base, int32_t offset, ++ LiftoffRegister src, ValueType type) { ++ MemOperand dst(base, offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->St_w(src.gp(), dst); ++ break; ++ case ValueType::kI64: ++ assm->St_d(src.gp(), dst); ++ break; ++ case ValueType::kF32: ++ assm->Fst_s(src.fp(), dst); ++ break; ++ case ValueType::kF64: ++ assm->Fst_d(src.fp(), dst); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->addi_d(sp, sp, -kSystemPointerSize); ++ assm->St_w(reg.gp(), MemOperand(sp, 0)); ++ break; ++ case ValueType::kI64: ++ assm->push(reg.gp()); ++ break; ++ case ValueType::kF32: ++ assm->addi_d(sp, sp, -kSystemPointerSize); ++ assm->Fst_s(reg.fp(), MemOperand(sp, 0)); ++ break; ++ case ValueType::kF64: ++ assm->addi_d(sp, sp, -kSystemPointerSize); ++ assm->Fst_d(reg.fp(), MemOperand(sp, 0)); ++ break; ++ case ValueType::kS128: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++} // namespace liftoff ++ ++int LiftoffAssembler::PrepareStackFrame() { ++ int offset = pc_offset(); ++ // When constant that represents size of stack frame can't be represented ++ // as 16bit we need three instructions to add it to sp, so we reserve space ++ // for this case. ++ addi_d(sp, sp, 0); ++ nop(); ++ nop(); ++ return offset; ++} ++ ++void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params, ++ int stack_param_delta) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ ++ // Push the return address and frame pointer to complete the stack frame. ++ Ld_d(scratch, MemOperand(fp, 8)); ++ Push(scratch); ++ Ld_d(scratch, MemOperand(fp, 0)); ++ Push(scratch); ++ ++ // Shift the whole frame upwards. ++ int slot_count = num_callee_stack_params + 2; ++ for (int i = slot_count - 1; i >= 0; --i) { ++ Ld_d(scratch, MemOperand(sp, i * 8)); ++ St_d(scratch, MemOperand(fp, (i - stack_param_delta) * 8)); ++ } ++ ++ // Set the new stack and frame pointer. ++ addi_d(sp, fp, -stack_param_delta * 8); ++ Pop(ra, fp); ++} ++ ++void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) { ++ // We can't run out of space, just pass anything big enough to not cause the ++ // assembler to try to grow the buffer. ++ constexpr int kAvailableSpace = 256; ++ TurboAssembler patching_assembler( ++ nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, ++ ExternalAssemblerBuffer(buffer_start_ + offset, kAvailableSpace)); ++ // If bytes can be represented as 16bit, daddiu will be generated and two ++ // nops will stay untouched. Otherwise, lui-ori sequence will load it to ++ // register and, as third instruction, daddu will be generated. ++ patching_assembler.Add_d(sp, sp, Operand(-frame_size)); ++} ++ ++void LiftoffAssembler::FinishCode() {} ++ ++void LiftoffAssembler::AbortCompilation() {} ++ ++// static ++constexpr int LiftoffAssembler::StaticStackFrameSize() { ++ return liftoff::kInstanceOffset; ++} ++ ++int LiftoffAssembler::SlotSizeForType(ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kS128: ++ return type.element_size_bytes(); ++ default: ++ return kStackSlotSize; ++ } ++} ++ ++bool LiftoffAssembler::NeedsAlignment(ValueType type) { ++ return type.kind() == ValueType::kS128 || type.is_reference_type(); ++} ++ ++void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value, ++ RelocInfo::Mode rmode) { ++ switch (value.type().kind()) { ++ case ValueType::kI32: ++ TurboAssembler::li(reg.gp(), Operand(value.to_i32(), rmode)); ++ break; ++ case ValueType::kI64: ++ TurboAssembler::li(reg.gp(), Operand(value.to_i64(), rmode)); ++ break; ++ case ValueType::kF32: ++ TurboAssembler::Move(reg.fp(), value.to_f32_boxed().get_bits()); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::Move(reg.fp(), value.to_f64_boxed().get_bits()); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, ++ int size) { ++ DCHECK_LE(offset, kMaxInt); ++ Ld_d(dst, liftoff::GetInstanceOperand()); ++ DCHECK(size == 4 || size == 8); ++ if (size == 4) { ++ Ld_w(dst, MemOperand(dst, offset)); ++ } else { ++ Ld_d(dst, MemOperand(dst, offset)); ++ } ++} ++ ++void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, ++ uint32_t offset) { ++ LoadFromInstance(dst, offset, kTaggedSize); ++} ++ ++void LiftoffAssembler::SpillInstance(Register instance) { ++ St_d(instance, liftoff::GetInstanceOperand()); ++} ++ ++void LiftoffAssembler::FillInstanceInto(Register dst) { ++ Ld_d(dst, liftoff::GetInstanceOperand()); ++} ++ ++void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, ++ Register offset_reg, ++ int32_t offset_imm, ++ LiftoffRegList pinned) { ++ DCHECK_GE(offset_imm, 0); ++ STATIC_ASSERT(kTaggedSize == kInt64Size); ++ Load(LiftoffRegister(dst), src_addr, offset_reg, ++ static_cast(offset_imm), LoadType::kI64Load, pinned); ++} ++ ++void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, int32_t offset_imm, ++ LiftoffRegister src, ++ LiftoffRegList pinned) { ++ bailout(kRefTypes, "GlobalSet"); ++} ++ ++void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, LiftoffRegList pinned, ++ uint32_t* protected_load_pc, bool is_load_mem) { ++ MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm); ++ ++ if (protected_load_pc) *protected_load_pc = pc_offset(); ++ switch (type.value()) { ++ case LoadType::kI32Load8U: ++ case LoadType::kI64Load8U: ++ Ld_bu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load8S: ++ case LoadType::kI64Load8S: ++ Ld_b(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load16U: ++ case LoadType::kI64Load16U: ++ TurboAssembler::Ld_hu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load16S: ++ case LoadType::kI64Load16S: ++ TurboAssembler::Ld_h(dst.gp(), src_op); ++ break; ++ case LoadType::kI64Load32U: ++ TurboAssembler::Ld_wu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load: ++ case LoadType::kI64Load32S: ++ TurboAssembler::Ld_w(dst.gp(), src_op); ++ break; ++ case LoadType::kI64Load: ++ TurboAssembler::Ld_d(dst.gp(), src_op); ++ break; ++ case LoadType::kF32Load: ++ TurboAssembler::Fld_s(dst.fp(), src_op); ++ break; ++ case LoadType::kF64Load: ++ TurboAssembler::Fld_d(dst.fp(), src_op); ++ break; ++ case LoadType::kS128Load: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister src, ++ StoreType type, LiftoffRegList pinned, ++ uint32_t* protected_store_pc, bool is_store_mem) { ++ MemOperand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm); ++ ++ if (protected_store_pc) *protected_store_pc = pc_offset(); ++ switch (type.value()) { ++ case StoreType::kI32Store8: ++ case StoreType::kI64Store8: ++ St_b(src.gp(), dst_op); ++ break; ++ case StoreType::kI32Store16: ++ case StoreType::kI64Store16: ++ TurboAssembler::St_h(src.gp(), dst_op); ++ break; ++ case StoreType::kI32Store: ++ case StoreType::kI64Store32: ++ TurboAssembler::St_w(src.gp(), dst_op); ++ break; ++ case StoreType::kI64Store: ++ TurboAssembler::St_d(src.gp(), dst_op); ++ break; ++ case StoreType::kF32Store: ++ TurboAssembler::Fst_s(src.fp(), dst_op); ++ break; ++ case StoreType::kF64Store: ++ TurboAssembler::Fst_d(src.fp(), dst_op); ++ break; ++ case StoreType::kS128Store: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, LiftoffRegList pinned) { ++ bailout(kAtomics, "AtomicLoad"); ++} ++ ++void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister src, ++ StoreType type, LiftoffRegList pinned) { ++ bailout(kAtomics, "AtomicStore"); ++} ++ ++void LiftoffAssembler::AtomicAdd(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicAdd"); ++} ++ ++void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicSub"); ++} ++ ++void LiftoffAssembler::AtomicAnd(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicAnd"); ++} ++ ++void LiftoffAssembler::AtomicOr(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicOr"); ++} ++ ++void LiftoffAssembler::AtomicXor(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicXor"); ++} ++ ++void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, ++ LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicExchange"); ++} ++ ++void LiftoffAssembler::AtomicCompareExchange( ++ Register dst_addr, Register offset_reg, uint32_t offset_imm, ++ LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result, ++ StoreType type) { ++ bailout(kAtomics, "AtomicCompareExchange"); ++} ++ ++void LiftoffAssembler::AtomicFence() { dbar(0); } ++ ++void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, ++ uint32_t caller_slot_idx, ++ ValueType type) { ++ MemOperand src(fp, kSystemPointerSize * (caller_slot_idx + 1)); ++ liftoff::Load(this, dst, src, type); ++} ++ ++void LiftoffAssembler::StoreCallerFrameSlot(LiftoffRegister src, ++ uint32_t caller_slot_idx, ++ ValueType type) { ++ int32_t offset = kSystemPointerSize * (caller_slot_idx + 1); ++ liftoff::Store(this, fp, offset, src, type); ++} ++ ++void LiftoffAssembler::LoadReturnStackSlot(LiftoffRegister dst, int offset, ++ ValueType type) { ++ liftoff::Load(this, dst, MemOperand(sp, offset), type); ++} ++ ++void LiftoffAssembler::MoveStackValue(uint32_t dst_offset, uint32_t src_offset, ++ ValueType type) { ++ DCHECK_NE(dst_offset, src_offset); ++ LiftoffRegister reg = GetUnusedRegister(reg_class_for(type), {}); ++ Fill(reg, src_offset, type); ++ Spill(dst_offset, reg, type); ++} ++ ++void LiftoffAssembler::Move(Register dst, Register src, ValueType type) { ++ DCHECK_NE(dst, src); ++ // TODO(ksreten): Handle different sizes here. ++ TurboAssembler::Move(dst, src); ++} ++ ++void LiftoffAssembler::Move(DoubleRegister dst, DoubleRegister src, ++ ValueType type) { ++ DCHECK_NE(dst, src); ++ if (type != kWasmS128) { ++ TurboAssembler::Move(dst, src); ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Spill(int offset, LiftoffRegister reg, ValueType type) { ++ RecordUsedSpillOffset(offset); ++ MemOperand dst = liftoff::GetStackSlot(offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ St_w(reg.gp(), dst); ++ break; ++ case ValueType::kI64: ++ case ValueType::kRef: ++ case ValueType::kOptRef: ++ St_d(reg.gp(), dst); ++ break; ++ case ValueType::kF32: ++ Fst_s(reg.fp(), dst); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::Fst_d(reg.fp(), dst); ++ break; ++ case ValueType::kS128: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Spill(int offset, WasmValue value) { ++ RecordUsedSpillOffset(offset); ++ MemOperand dst = liftoff::GetStackSlot(offset); ++ switch (value.type().kind()) { ++ case ValueType::kI32: { ++ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); ++ TurboAssembler::li(tmp.gp(), Operand(value.to_i32())); ++ St_w(tmp.gp(), dst); ++ break; ++ } ++ case ValueType::kI64: ++ case ValueType::kRef: ++ case ValueType::kOptRef: { ++ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); ++ TurboAssembler::li(tmp.gp(), value.to_i64()); ++ St_d(tmp.gp(), dst); ++ break; ++ } ++ default: ++ // kWasmF32 and kWasmF64 are unreachable, since those ++ // constants are not tracked. ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Fill(LiftoffRegister reg, int offset, ValueType type) { ++ MemOperand src = liftoff::GetStackSlot(offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ Ld_w(reg.gp(), src); ++ break; ++ case ValueType::kI64: ++ case ValueType::kRef: ++ case ValueType::kOptRef: ++ Ld_d(reg.gp(), src); ++ break; ++ case ValueType::kF32: ++ Fld_s(reg.fp(), src); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::Fld_d(reg.fp(), src); ++ break; ++ case ValueType::kS128: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::FillI64Half(Register, int offset, RegPairHalf) { ++ UNREACHABLE(); ++} ++ ++void LiftoffAssembler::FillStackSlotsWithZero(int start, int size) { ++ DCHECK_LT(0, size); ++ RecordUsedSpillOffset(start + size); ++ ++ if (size <= 12 * kStackSlotSize) { ++ // Special straight-line code for up to 12 slots. Generates one ++ // instruction per slot (<= 12 instructions total). ++ uint32_t remainder = size; ++ for (; remainder >= kStackSlotSize; remainder -= kStackSlotSize) { ++ St_d(zero_reg, liftoff::GetStackSlot(start + remainder)); ++ } ++ DCHECK(remainder == 4 || remainder == 0); ++ if (remainder) { ++ St_w(zero_reg, liftoff::GetStackSlot(start + remainder)); ++ } ++ } else { ++ // General case for bigger counts (12 instructions). ++ // Use a0 for start address (inclusive), a1 for end address (exclusive). ++ Push(a1, a0); ++ Add_d(a0, fp, Operand(-start - size)); ++ Add_d(a1, fp, Operand(-start)); ++ ++ Label loop; ++ bind(&loop); ++ St_d(zero_reg, MemOperand(a0, 0)); ++ addi_d(a0, a0, kSystemPointerSize); ++ BranchShort(&loop, ne, a0, Operand(a1)); ++ ++ Pop(a1, a0); ++ } ++} ++ ++void LiftoffAssembler::emit_i64_clz(LiftoffRegister dst, LiftoffRegister src) { ++ TurboAssembler::Clz_d(dst.gp(), src.gp()); ++} ++ ++void LiftoffAssembler::emit_i64_ctz(LiftoffRegister dst, LiftoffRegister src) { ++ TurboAssembler::Ctz_d(dst.gp(), src.gp()); ++} ++ ++bool LiftoffAssembler::emit_i64_popcnt(LiftoffRegister dst, ++ LiftoffRegister src) { ++ TurboAssembler::Popcnt_d(dst.gp(), src.gp()); ++ return true; ++} ++ ++void LiftoffAssembler::emit_i32_mul(Register dst, Register lhs, Register rhs) { ++ TurboAssembler::Mul_w(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero, ++ Label* trap_div_unrepresentable) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ ++ // Check if lhs == kMinInt and rhs == -1, since this case is unrepresentable. ++ TurboAssembler::li(kScratchReg, 1); ++ TurboAssembler::li(kScratchReg2, 1); ++ TurboAssembler::LoadZeroOnCondition(kScratchReg, lhs, Operand(kMinInt), eq); ++ TurboAssembler::LoadZeroOnCondition(kScratchReg2, rhs, Operand(-1), eq); ++ add_d(kScratchReg, kScratchReg, kScratchReg2); ++ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, ++ Operand(zero_reg)); ++ ++ TurboAssembler::Div_w(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Div_wu(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Mod_w(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_remu(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Mod_wu(dst, lhs, rhs); ++} ++ ++#define I32_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name(Register dst, Register lhs, \ ++ Register rhs) { \ ++ instruction(dst, lhs, rhs); \ ++ } ++ ++// clang-format off ++I32_BINOP(add, add_w) ++I32_BINOP(sub, sub_w) ++I32_BINOP(and, and_) ++I32_BINOP(or, or_) ++I32_BINOP(xor, xor_) ++// clang-format on ++ ++#undef I32_BINOP ++ ++#define I32_BINOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register lhs, \ ++ int32_t imm) { \ ++ instruction(dst, lhs, imm); \ ++ } ++ ++// clang-format off ++I32_BINOP_I(add, Add_w) ++I32_BINOP_I(and, And) ++I32_BINOP_I(or, Or) ++I32_BINOP_I(xor, Xor) ++// clang-format on ++ ++#undef I32_BINOP_I ++ ++void LiftoffAssembler::emit_i32_clz(Register dst, Register src) { ++ TurboAssembler::Clz_w(dst, src); ++} ++ ++void LiftoffAssembler::emit_i32_ctz(Register dst, Register src) { ++ TurboAssembler::Ctz_w(dst, src); ++} ++ ++bool LiftoffAssembler::emit_i32_popcnt(Register dst, Register src) { ++ TurboAssembler::Popcnt_w(dst, src); ++ return true; ++} ++ ++#define I32_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name(Register dst, Register src, \ ++ Register amount) { \ ++ instruction(dst, src, amount); \ ++ } ++#define I32_SHIFTOP_I(name, instruction, instruction1) \ ++ I32_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register src, \ ++ int amount) { \ ++ instruction1(dst, src, amount & 0x1f); \ ++ } ++ ++I32_SHIFTOP_I(shl, sll_w, slli_w) ++I32_SHIFTOP_I(sar, sra_w, srai_w) ++I32_SHIFTOP_I(shr, srl_w, srli_w) ++ ++#undef I32_SHIFTOP ++#undef I32_SHIFTOP_I ++ ++void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ TurboAssembler::Mul_d(dst.gp(), lhs.gp(), rhs.gp()); ++} ++ ++bool LiftoffAssembler::emit_i64_divs(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero, ++ Label* trap_div_unrepresentable) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ ++ // Check if lhs == MinInt64 and rhs == -1, since this case is unrepresentable. ++ TurboAssembler::li(kScratchReg, 1); ++ TurboAssembler::li(kScratchReg2, 1); ++ TurboAssembler::LoadZeroOnCondition( ++ kScratchReg, lhs.gp(), Operand(std::numeric_limits::min()), eq); ++ TurboAssembler::LoadZeroOnCondition(kScratchReg2, rhs.gp(), Operand(-1), eq); ++ add_d(kScratchReg, kScratchReg, kScratchReg2); ++ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, ++ Operand(zero_reg)); ++ ++ TurboAssembler::Div_d(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_divu(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Div_du(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_rems(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Mod_d(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_remu(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Mod_du(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++#define I64_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name( \ ++ LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ ++ instruction(dst.gp(), lhs.gp(), rhs.gp()); \ ++ } ++ ++// clang-format off ++I64_BINOP(add, Add_d) ++I64_BINOP(sub, Sub_d) ++I64_BINOP(and, and_) ++I64_BINOP(or, or_) ++I64_BINOP(xor, xor_) ++// clang-format on ++ ++#undef I64_BINOP ++ ++#define I64_BINOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name##i( \ ++ LiftoffRegister dst, LiftoffRegister lhs, int32_t imm) { \ ++ instruction(dst.gp(), lhs.gp(), imm); \ ++ } ++ ++// clang-format off ++I64_BINOP_I(add, addi_d) ++I64_BINOP_I(and, And) ++I64_BINOP_I(or, Or) ++I64_BINOP_I(xor, Xor) ++// clang-format on ++ ++#undef I64_BINOP_I ++ ++#define I64_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name( \ ++ LiftoffRegister dst, LiftoffRegister src, Register amount) { \ ++ instruction(dst.gp(), src.gp(), amount); \ ++ } ++#define I64_SHIFTOP_I(name, instruction, instructioni) \ ++ I64_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name##i(LiftoffRegister dst, \ ++ LiftoffRegister src, int amount) { \ ++ instructioni(dst.gp(), src.gp(), amount & 63); \ ++ } ++ ++I64_SHIFTOP_I(shl, sll_d, slli_d) ++I64_SHIFTOP_I(sar, sra_d, srai_d) ++I64_SHIFTOP_I(shr, srl_d, srli_d) ++ ++#undef I64_SHIFTOP ++#undef I64_SHIFTOP_I ++ ++void LiftoffAssembler::emit_u32_to_intptr(Register dst, Register src) { ++ bstrpick_d(dst, src, 31, 0); ++} ++ ++void LiftoffAssembler::emit_f32_neg(DoubleRegister dst, DoubleRegister src) { ++ TurboAssembler::Neg_s(dst, src); ++} ++ ++void LiftoffAssembler::emit_f64_neg(DoubleRegister dst, DoubleRegister src) { ++ TurboAssembler::Neg_d(dst, src); ++} ++ ++void LiftoffAssembler::emit_f32_min(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label ool, done; ++ TurboAssembler::Float32Min(dst, lhs, rhs, &ool); ++ Branch(&done); ++ ++ bind(&ool); ++ TurboAssembler::Float32MinOutOfLine(dst, lhs, rhs); ++ bind(&done); ++} ++ ++void LiftoffAssembler::emit_f32_max(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label ool, done; ++ TurboAssembler::Float32Max(dst, lhs, rhs, &ool); ++ Branch(&done); ++ ++ bind(&ool); ++ TurboAssembler::Float32MaxOutOfLine(dst, lhs, rhs); ++ bind(&done); ++} ++ ++void LiftoffAssembler::emit_f32_copysign(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ bailout(kComplexOperation, "f32_copysign"); ++} ++ ++void LiftoffAssembler::emit_f64_min(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label ool, done; ++ TurboAssembler::Float64Min(dst, lhs, rhs, &ool); ++ Branch(&done); ++ ++ bind(&ool); ++ TurboAssembler::Float64MinOutOfLine(dst, lhs, rhs); ++ bind(&done); ++} ++ ++void LiftoffAssembler::emit_f64_max(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label ool, done; ++ TurboAssembler::Float64Max(dst, lhs, rhs, &ool); ++ Branch(&done); ++ ++ bind(&ool); ++ TurboAssembler::Float64MaxOutOfLine(dst, lhs, rhs); ++ bind(&done); ++} ++ ++void LiftoffAssembler::emit_f64_copysign(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ bailout(kComplexOperation, "f64_copysign"); ++} ++ ++#define FP_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister lhs, \ ++ DoubleRegister rhs) { \ ++ instruction(dst, lhs, rhs); \ ++ } ++#define FP_UNOP(name, instruction) \ ++ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ ++ instruction(dst, src); \ ++ } ++#define FP_UNOP_RETURN_TRUE(name, instruction) \ ++ bool LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ ++ instruction(dst, src); \ ++ return true; \ ++ } ++ ++FP_BINOP(f32_add, fadd_s) ++FP_BINOP(f32_sub, fsub_s) ++FP_BINOP(f32_mul, fmul_s) ++FP_BINOP(f32_div, fdiv_s) ++FP_UNOP(f32_abs, fabs_s) ++FP_UNOP_RETURN_TRUE(f32_ceil, Ceil_s) ++FP_UNOP_RETURN_TRUE(f32_floor, Floor_s) ++FP_UNOP_RETURN_TRUE(f32_trunc, Trunc_s) ++FP_UNOP_RETURN_TRUE(f32_nearest_int, Round_s) ++FP_UNOP(f32_sqrt, fsqrt_s) ++FP_BINOP(f64_add, fadd_d) ++FP_BINOP(f64_sub, fsub_d) ++FP_BINOP(f64_mul, fmul_d) ++FP_BINOP(f64_div, fdiv_d) ++FP_UNOP(f64_abs, fabs_d) ++FP_UNOP_RETURN_TRUE(f64_ceil, Ceil_d) ++FP_UNOP_RETURN_TRUE(f64_floor, Floor_d) ++FP_UNOP_RETURN_TRUE(f64_trunc, Trunc_d) ++FP_UNOP_RETURN_TRUE(f64_nearest_int, Round_d) ++FP_UNOP(f64_sqrt, fsqrt_d) ++ ++#undef FP_BINOP ++#undef FP_UNOP ++#undef FP_UNOP_RETURN_TRUE ++ ++bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ++ LiftoffRegister dst, ++ LiftoffRegister src, Label* trap) { ++ switch (opcode) { ++ case kExprI32ConvertI64: ++ TurboAssembler::bstrpick_w(dst.gp(), src.gp(), 31, 0); ++ return true; ++ case kExprI32SConvertF32: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); ++ ftintrz_w_s(kScratchDoubleReg, rounded.fp()); ++ movfr2gr_s(dst.gp(), kScratchDoubleReg); ++ // Avoid INT32_MAX as an overflow indicator and use INT32_MIN instead, ++ // because INT32_MIN allows easier out-of-bounds detection. ++ TurboAssembler::Add_w(kScratchReg, dst.gp(), 1); ++ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); ++ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); ++ ++ // Checking if trap. ++ movgr2fr_w(kScratchDoubleReg, dst.gp()); ++ ffint_s_w(converted_back.fp(), kScratchDoubleReg); ++ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI32UConvertF32: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); ++ TurboAssembler::Ftintrz_uw_s(dst.gp(), rounded.fp(), kScratchDoubleReg); ++ // Avoid UINT32_MAX as an overflow indicator and use 0 instead, ++ // because 0 allows easier out-of-bounds detection. ++ TurboAssembler::Add_w(kScratchReg, dst.gp(), 1); ++ TurboAssembler::Movz(dst.gp(), zero_reg, kScratchReg); ++ ++ // Checking if trap. ++ TurboAssembler::Ffint_d_uw(converted_back.fp(), dst.gp()); ++ fcvt_s_d(converted_back.fp(), converted_back.fp()); ++ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI32SConvertF64: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); ++ ftintrz_w_d(kScratchDoubleReg, rounded.fp()); ++ movfr2gr_s(dst.gp(), kScratchDoubleReg); ++ ++ // Checking if trap. ++ ffint_d_w(converted_back.fp(), kScratchDoubleReg); ++ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI32UConvertF64: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); ++ TurboAssembler::Ftintrz_uw_d(dst.gp(), rounded.fp(), kScratchDoubleReg); ++ ++ // Checking if trap. ++ TurboAssembler::Ffint_d_uw(converted_back.fp(), dst.gp()); ++ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI32ReinterpretF32: ++ TurboAssembler::FmoveLow(dst.gp(), src.fp()); ++ return true; ++ case kExprI64SConvertI32: ++ slli_w(dst.gp(), src.gp(), 0); ++ return true; ++ case kExprI64UConvertI32: ++ TurboAssembler::bstrpick_d(dst.gp(), src.gp(), 31, 0); ++ return true; ++ case kExprI64SConvertF32: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_s(rounded.fp(), src.fp()); ++ ftintrz_l_s(kScratchDoubleReg, rounded.fp()); ++ movfr2gr_d(dst.gp(), kScratchDoubleReg); ++ // Avoid INT64_MAX as an overflow indicator and use INT64_MIN instead, ++ // because INT64_MIN allows easier out-of-bounds detection. ++ TurboAssembler::Add_d(kScratchReg, dst.gp(), 1); ++ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); ++ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); ++ ++ // Checking if trap. ++ movgr2fr_d(kScratchDoubleReg, dst.gp()); ++ ffint_s_l(converted_back.fp(), kScratchDoubleReg); ++ TurboAssembler::CompareF32(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI64UConvertF32: { ++ // Real conversion. ++ TurboAssembler::Ftintrz_ul_s(dst.gp(), src.fp(), kScratchDoubleReg, ++ kScratchReg); ++ ++ // Checking if trap. ++ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); ++ return true; ++ } ++ case kExprI64SConvertF64: { ++ LiftoffRegister rounded = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src)); ++ LiftoffRegister converted_back = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(src, rounded)); ++ ++ // Real conversion. ++ TurboAssembler::Trunc_d(rounded.fp(), src.fp()); ++ ftintrz_l_d(kScratchDoubleReg, rounded.fp()); ++ movfr2gr_d(dst.gp(), kScratchDoubleReg); ++ // Avoid INT64_MAX as an overflow indicator and use INT64_MIN instead, ++ // because INT64_MIN allows easier out-of-bounds detection. ++ TurboAssembler::Add_d(kScratchReg, dst.gp(), 1); ++ TurboAssembler::Slt(kScratchReg2, kScratchReg, dst.gp()); ++ TurboAssembler::Movn(dst.gp(), kScratchReg, kScratchReg2); ++ ++ // Checking if trap. ++ movgr2fr_d(kScratchDoubleReg, dst.gp()); ++ ffint_d_l(converted_back.fp(), kScratchDoubleReg); ++ TurboAssembler::CompareF64(rounded.fp(), converted_back.fp(), CEQ); ++ TurboAssembler::BranchFalseF(trap); ++ return true; ++ } ++ case kExprI64UConvertF64: { ++ // Real conversion. ++ TurboAssembler::Ftintrz_ul_d(dst.gp(), src.fp(), kScratchDoubleReg, ++ kScratchReg); ++ ++ // Checking if trap. ++ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); ++ return true; ++ } ++ case kExprI64ReinterpretF64: ++ movfr2gr_d(dst.gp(), src.fp()); ++ return true; ++ case kExprF32SConvertI32: { ++ LiftoffRegister scratch = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst)); ++ movgr2fr_w(scratch.fp(), src.gp()); ++ ffint_s_w(dst.fp(), scratch.fp()); ++ return true; ++ } ++ case kExprF32UConvertI32: ++ TurboAssembler::Ffint_s_uw(dst.fp(), src.gp()); ++ return true; ++ case kExprF32ConvertF64: ++ fcvt_s_d(dst.fp(), src.fp()); ++ return true; ++ case kExprF32ReinterpretI32: ++ TurboAssembler::FmoveLow(dst.fp(), src.gp()); ++ return true; ++ case kExprF64SConvertI32: { ++ LiftoffRegister scratch = ++ GetUnusedRegister(kFpReg, LiftoffRegList::ForRegs(dst)); ++ movgr2fr_w(scratch.fp(), src.gp()); ++ ffint_d_w(dst.fp(), scratch.fp()); ++ return true; ++ } ++ case kExprF64UConvertI32: ++ TurboAssembler::Ffint_d_uw(dst.fp(), src.gp()); ++ return true; ++ case kExprF64ConvertF32: ++ fcvt_d_s(dst.fp(), src.fp()); ++ return true; ++ case kExprF64ReinterpretI64: ++ movgr2fr_d(dst.fp(), src.gp()); ++ return true; ++ case kExprI32SConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF32"); ++ return true; ++ case kExprI32UConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF32"); ++ return true; ++ case kExprI32SConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF64"); ++ return true; ++ case kExprI32UConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF64"); ++ return true; ++ case kExprI64SConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF32"); ++ return true; ++ case kExprI64UConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF32"); ++ return true; ++ case kExprI64SConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF64"); ++ return true; ++ case kExprI64UConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF64"); ++ return true; ++ default: ++ return false; ++ } ++} ++ ++void LiftoffAssembler::emit_i32_signextend_i8(Register dst, Register src) { ++ bailout(kComplexOperation, "i32_signextend_i8"); ++} ++ ++void LiftoffAssembler::emit_i32_signextend_i16(Register dst, Register src) { ++ bailout(kComplexOperation, "i32_signextend_i16"); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i8(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kComplexOperation, "i64_signextend_i8"); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i16(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kComplexOperation, "i64_signextend_i16"); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i32(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kComplexOperation, "i64_signextend_i32"); ++} ++ ++void LiftoffAssembler::emit_jump(Label* label) { ++ TurboAssembler::Branch(label); ++} ++ ++void LiftoffAssembler::emit_jump(Register target) { ++ TurboAssembler::Jump(target); ++} ++ ++void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, ++ ValueType type, Register lhs, ++ Register rhs) { ++ if (rhs != no_reg) { ++ TurboAssembler::Branch(label, cond, lhs, Operand(rhs)); ++ } else { ++ TurboAssembler::Branch(label, cond, lhs, Operand(zero_reg)); ++ } ++} ++ ++void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { ++ sltui(dst, src, 1); ++} ++ ++void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, ++ Register lhs, Register rhs) { ++ Register tmp = dst; ++ if (dst == lhs || dst == rhs) { ++ tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp(); ++ } ++ // Write 1 as result. ++ TurboAssembler::li(tmp, 1); ++ ++ // If negative condition is true, write 0 as result. ++ Condition neg_cond = NegateCondition(cond); ++ TurboAssembler::LoadZeroOnCondition(tmp, lhs, Operand(rhs), neg_cond); ++ ++ // If tmp != dst, result will be moved. ++ TurboAssembler::Move(dst, tmp); ++} ++ ++void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { ++ sltui(dst, src.gp(), 1); ++} ++ ++void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ Register tmp = dst; ++ if (dst == lhs.gp() || dst == rhs.gp()) { ++ tmp = GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(lhs, rhs)).gp(); ++ } ++ // Write 1 as result. ++ TurboAssembler::li(tmp, 1); ++ ++ // If negative condition is true, write 0 as result. ++ Condition neg_cond = NegateCondition(cond); ++ TurboAssembler::LoadZeroOnCondition(tmp, lhs.gp(), Operand(rhs.gp()), ++ neg_cond); ++ ++ // If tmp != dst, result will be moved. ++ TurboAssembler::Move(dst, tmp); ++} ++ ++namespace liftoff { ++ ++inline FPUCondition ConditionToConditionCmpFPU(Condition condition, ++ bool* predicate) { ++ switch (condition) { ++ case kEqual: ++ *predicate = true; ++ return CEQ; ++ case kUnequal: ++ *predicate = false; ++ return CEQ; ++ case kUnsignedLessThan: ++ *predicate = true; ++ return CLT; ++ case kUnsignedGreaterEqual: ++ *predicate = false; ++ return CLT; ++ case kUnsignedLessEqual: ++ *predicate = true; ++ return CLE; ++ case kUnsignedGreaterThan: ++ *predicate = false; ++ return CLE; ++ default: ++ *predicate = true; ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++inline void EmitAnyTrue(LiftoffAssembler* assm, LiftoffRegister dst, ++ LiftoffRegister src) {} ++} // namespace liftoff ++ ++void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, ++ DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label not_nan, cont; ++ TurboAssembler::CompareIsNanF32(lhs, rhs); ++ TurboAssembler::BranchFalseF(¬_nan); ++ // If one of the operands is NaN, return 1 for f32.ne, else 0. ++ if (cond == ne) { ++ TurboAssembler::li(dst, 1); ++ } else { ++ TurboAssembler::Move(dst, zero_reg); ++ } ++ TurboAssembler::Branch(&cont); ++ ++ bind(¬_nan); ++ ++ TurboAssembler::li(dst, 1); ++ bool predicate; ++ FPUCondition fcond = liftoff::ConditionToConditionCmpFPU(cond, &predicate); ++ TurboAssembler::CompareF32(lhs, rhs, fcond); ++ if (predicate) { ++ TurboAssembler::LoadZeroIfNotFPUCondition(dst); ++ } else { ++ TurboAssembler::LoadZeroIfFPUCondition(dst); ++ } ++ ++ bind(&cont); ++} ++ ++void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ++ DoubleRegister lhs, ++ DoubleRegister rhs) { ++ Label not_nan, cont; ++ TurboAssembler::CompareIsNanF64(lhs, rhs); ++ TurboAssembler::BranchFalseF(¬_nan); ++ // If one of the operands is NaN, return 1 for f64.ne, else 0. ++ if (cond == ne) { ++ TurboAssembler::li(dst, 1); ++ } else { ++ TurboAssembler::Move(dst, zero_reg); ++ } ++ TurboAssembler::Branch(&cont); ++ ++ bind(¬_nan); ++ ++ TurboAssembler::li(dst, 1); ++ bool predicate; ++ FPUCondition fcond = liftoff::ConditionToConditionCmpFPU(cond, &predicate); ++ TurboAssembler::CompareF64(lhs, rhs, fcond); ++ if (predicate) { ++ TurboAssembler::LoadZeroIfNotFPUCondition(dst); ++ } else { ++ TurboAssembler::LoadZeroIfFPUCondition(dst); ++ } ++ ++ bind(&cont); ++} ++ ++bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition, ++ LiftoffRegister true_value, ++ LiftoffRegister false_value, ++ ValueType type) { ++ return false; ++} ++ ++void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, ++ LoadTransformationKind transform, ++ uint32_t* protected_load_pc) {} ++ ++void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ const uint8_t shuffle[16], ++ bool is_swizzle) {} ++ ++void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i64x2_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_lt(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_le(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_lt(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_s128_const(LiftoffRegister dst, ++ const uint8_t imms[16]) { ++ bailout(kSimd, "emit_s128_const"); ++} ++ ++void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) { ++} ++ ++void LiftoffAssembler::emit_s128_and(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_s128_or(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_s128_xor(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_s128_and_not(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_s128_select(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ LiftoffRegister mask) {} ++ ++void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_add_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_add_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_sub_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_sub_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_add_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_add_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_sub_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_sub_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i64x2_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_abs(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_sqrt(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f32x4_ceil(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f32x4_floor(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f32x4_trunc(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f32x4_nearest_int(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_div(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_min(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_max(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_pmin(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f32x4_pmax(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_abs(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f64x2_sqrt(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f64x2_ceil(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f64x2_floor(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f64x2_trunc(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++bool LiftoffAssembler::emit_f64x2_nearest_int(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_div(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_min(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_max(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_pmin(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_f64x2_pmax(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_f32x4(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_f32x4(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_sconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_f32x4_uconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_sconvert_i16x8(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_uconvert_i16x8(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i8x16_low(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i8x16_high(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i8x16_low(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i8x16_high(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_i16x8_low(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_i16x8_high(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_i16x8_low(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_i16x8_high(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_rounding_average_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i16x8_rounding_average_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) {} ++ ++void LiftoffAssembler::emit_i8x16_abs(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i16x8_abs(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst, ++ LiftoffRegister src) {} ++ ++void LiftoffAssembler::emit_i8x16_extract_lane_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i8x16_extract_lane_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i16x8_extract_lane_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i16x8_extract_lane_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i32x4_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i64x2_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_f32x4_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_f64x2_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) {} ++ ++void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) { ++ TurboAssembler::Ld_d(limit_address, MemOperand(limit_address, 0)); ++ TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address)); ++} ++ ++void LiftoffAssembler::CallTrapCallbackForTesting() { ++ PrepareCallCFunction(0, GetUnusedRegister(kGpReg, {}).gp()); ++ CallCFunction(ExternalReference::wasm_call_trap_callback_for_testing(), 0); ++} ++ ++void LiftoffAssembler::AssertUnreachable(AbortReason reason) { ++ if (emit_debug_code()) Abort(reason); ++} ++ ++void LiftoffAssembler::PushRegisters(LiftoffRegList regs) { ++ LiftoffRegList gp_regs = regs & kGpCacheRegList; ++ unsigned num_gp_regs = gp_regs.GetNumRegsSet(); ++ if (num_gp_regs) { ++ unsigned offset = num_gp_regs * kSystemPointerSize; ++ addi_d(sp, sp, -offset); ++ while (!gp_regs.is_empty()) { ++ LiftoffRegister reg = gp_regs.GetFirstRegSet(); ++ offset -= kSystemPointerSize; ++ St_d(reg.gp(), MemOperand(sp, offset)); ++ gp_regs.clear(reg); ++ } ++ DCHECK_EQ(offset, 0); ++ } ++ LiftoffRegList fp_regs = regs & kFpCacheRegList; ++ unsigned num_fp_regs = fp_regs.GetNumRegsSet(); ++ if (num_fp_regs) { ++ unsigned slot_size = /*IsEnabled(MIPS_SIMD) ? 16 :*/ 8; ++ addi_d(sp, sp, -(num_fp_regs * slot_size)); ++ unsigned offset = 0; ++ while (!fp_regs.is_empty()) { ++ LiftoffRegister reg = fp_regs.GetFirstRegSet(); ++ if (0 /*IsEnabled(MIPS_SIMD)*/) { ++ // TurboAssembler::st_d(reg.fp().toW(), MemOperand(sp, offset)); ++ } else { ++ TurboAssembler::Fst_d(reg.fp(), MemOperand(sp, offset)); ++ } ++ fp_regs.clear(reg); ++ offset += slot_size; ++ } ++ DCHECK_EQ(offset, num_fp_regs * slot_size); ++ } ++} ++ ++void LiftoffAssembler::PopRegisters(LiftoffRegList regs) { ++ LiftoffRegList fp_regs = regs & kFpCacheRegList; ++ unsigned fp_offset = 0; ++ while (!fp_regs.is_empty()) { ++ LiftoffRegister reg = fp_regs.GetFirstRegSet(); ++ if (0 /*IsEnabled(MIPS_SIMD)*/) { ++ // TurboAssembler::ld_d(reg.fp().toW(), MemOperand(sp, fp_offset)); ++ } else { ++ TurboAssembler::Fld_d(reg.fp(), MemOperand(sp, fp_offset)); ++ } ++ fp_regs.clear(reg); ++ fp_offset += (/*IsEnabled(MIPS_SIMD) ? 16 :*/ 8); ++ } ++ if (fp_offset) addi_d(sp, sp, fp_offset); ++ LiftoffRegList gp_regs = regs & kGpCacheRegList; ++ unsigned gp_offset = 0; ++ while (!gp_regs.is_empty()) { ++ LiftoffRegister reg = gp_regs.GetLastRegSet(); ++ Ld_d(reg.gp(), MemOperand(sp, gp_offset)); ++ gp_regs.clear(reg); ++ gp_offset += kSystemPointerSize; ++ } ++ addi_d(sp, sp, gp_offset); ++} ++ ++void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) { ++ DCHECK_LT(num_stack_slots, ++ (1 << 16) / kSystemPointerSize); // 16 bit immediate ++ TurboAssembler::DropAndRet(static_cast(num_stack_slots)); ++} ++ ++void LiftoffAssembler::CallC(const wasm::FunctionSig* sig, ++ const LiftoffRegister* args, ++ const LiftoffRegister* rets, ++ ValueType out_argument_type, int stack_bytes, ++ ExternalReference ext_ref) { ++ addi_d(sp, sp, -stack_bytes); ++ ++ int arg_bytes = 0; ++ for (ValueType param_type : sig->parameters()) { ++ liftoff::Store(this, sp, arg_bytes, *args++, param_type); ++ arg_bytes += param_type.element_size_bytes(); ++ } ++ DCHECK_LE(arg_bytes, stack_bytes); ++ ++ // Pass a pointer to the buffer with the arguments to the C function. ++ // On mips, the first argument is passed in {a0}. ++ constexpr Register kFirstArgReg = a0; ++ mov(kFirstArgReg, sp); ++ ++ // Now call the C function. ++ constexpr int kNumCCallArgs = 1; ++ PrepareCallCFunction(kNumCCallArgs, kScratchReg); ++ CallCFunction(ext_ref, kNumCCallArgs); ++ ++ // Move return value to the right register. ++ const LiftoffRegister* next_result_reg = rets; ++ if (sig->return_count() > 0) { ++ DCHECK_EQ(1, sig->return_count()); ++ constexpr Register kReturnReg = a0; ++ if (kReturnReg != next_result_reg->gp()) { ++ Move(*next_result_reg, LiftoffRegister(kReturnReg), sig->GetReturn(0)); ++ } ++ ++next_result_reg; ++ } ++ ++ // Load potential output value from the buffer on the stack. ++ if (out_argument_type != kWasmStmt) { ++ liftoff::Load(this, *next_result_reg, MemOperand(sp, 0), out_argument_type); ++ } ++ ++ addi_d(sp, sp, stack_bytes); ++} ++ ++void LiftoffAssembler::CallNativeWasmCode(Address addr) { ++ Call(addr, RelocInfo::WASM_CALL); ++} ++ ++void LiftoffAssembler::TailCallNativeWasmCode(Address addr) { ++ Jump(addr, RelocInfo::WASM_CALL); ++} ++ ++void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig, ++ compiler::CallDescriptor* call_descriptor, ++ Register target) { ++ if (target == no_reg) { ++ pop(kScratchReg); ++ Call(kScratchReg); ++ } else { ++ Call(target); ++ } ++} ++ ++void LiftoffAssembler::TailCallIndirect(Register target) { ++ if (target == no_reg) { ++ Pop(kScratchReg); ++ Jump(kScratchReg); ++ } else { ++ Jump(target); ++ } ++} ++ ++void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) { ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched at relocation. ++ Call(static_cast
(sid), RelocInfo::WASM_STUB_CALL); ++} ++ ++void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) { ++ addi_d(sp, sp, -size); ++ TurboAssembler::Move(addr, sp); ++} ++ ++void LiftoffAssembler::DeallocateStackSlot(uint32_t size) { ++ addi_d(sp, sp, size); ++} ++ ++void LiftoffStackSlots::Construct() { ++ for (auto& slot : slots_) { ++ const LiftoffAssembler::VarState& src = slot.src_; ++ switch (src.loc()) { ++ case LiftoffAssembler::VarState::kStack: ++ if (src.type() != kWasmS128) { ++ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); ++ asm_->push(kScratchReg); ++ } else { ++ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_ - 8)); ++ asm_->push(kScratchReg); ++ asm_->Ld_d(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); ++ asm_->push(kScratchReg); ++ } ++ break; ++ case LiftoffAssembler::VarState::kRegister: ++ liftoff::push(asm_, src.reg(), src.type()); ++ break; ++ case LiftoffAssembler::VarState::kIntConst: { ++ asm_->li(kScratchReg, Operand(src.i32_const())); ++ asm_->push(kScratchReg); ++ break; ++ } ++ } ++ } ++} ++ ++} // namespace wasm ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_WASM_BASELINE_LOONGARCH64_LIFTOFF_ASSEMBLER_LOONGARCH64_H_ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc +@@ -268,6 +268,37 @@ void JumpTableAssembler::NopBytes(int by + } + } + ++#elif V8_TARGET_ARCH_LOONGARCH64 ++void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, ++ Address lazy_compile_target) { ++ DCHECK(is_int32(func_index)); ++ int start = pc_offset(); ++ li(kWasmCompileLazyFuncIndexRegister, (int32_t)func_index); // max. 2 instr ++ // Jump produces max. 3 instructions for 32-bit platform ++ // and max. 4 instructions for 64-bit platform. ++ Jump(lazy_compile_target, RelocInfo::NONE); ++ int nop_bytes = start + kLazyCompileTableSlotSize - pc_offset(); ++ DCHECK_EQ(nop_bytes % kInstrSize, 0); ++ for (int i = 0; i < nop_bytes; i += kInstrSize) nop(); ++} ++bool JumpTableAssembler::EmitJumpSlot(Address target) { ++ PatchAndJump(target); ++ return true; ++} ++void JumpTableAssembler::EmitFarJumpSlot(Address target) { ++ JumpToInstructionStream(target); ++} ++void JumpTableAssembler::PatchFarJumpSlot(Address slot, Address target) { ++ UNREACHABLE(); ++} ++void JumpTableAssembler::NopBytes(int bytes) { ++ DCHECK_LE(0, bytes); ++ DCHECK_EQ(0, bytes % kInstrSize); ++ for (; bytes > 0; bytes -= kInstrSize) { ++ nop(); ++ } ++} ++ + #elif V8_TARGET_ARCH_PPC64 + void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, + Address lazy_compile_target) { +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h +@@ -215,6 +215,12 @@ class V8_EXPORT_PRIVATE JumpTableAssembl + static constexpr int kJumpTableSlotSize = 8 * kInstrSize; + static constexpr int kFarJumpTableSlotSize = 6 * kInstrSize; + static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; ++#elif V8_TARGET_ARCH_LOONGARCH64 ++ // TODO ++ static constexpr int kJumpTableLineSize = 8 * kInstrSize; ++ static constexpr int kJumpTableSlotSize = 8 * kInstrSize; ++ static constexpr int kFarJumpTableSlotSize = 4 * kInstrSize; ++ static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; + #else + #error Unknown architecture. + #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h +@@ -75,6 +75,15 @@ constexpr Register kGpReturnRegisters[] + constexpr DoubleRegister kFpParamRegisters[] = {f2, f4, f6, f8, f10, f12, f14}; + constexpr DoubleRegister kFpReturnRegisters[] = {f2, f4}; + ++#elif V8_TARGET_ARCH_LOONGARCH64 ++// =========================================================================== ++// == LOONGARCH64 TODO ============================================================= ++// =========================================================================== ++constexpr Register kGpParamRegisters[] = {a0, a2, a3, a4, a5, a6, a7}; ++constexpr Register kGpReturnRegisters[] = {a0, a1}; ++constexpr DoubleRegister kFpParamRegisters[] = {f2, f4, f6, f8, f10, f12, f14}; ++constexpr DoubleRegister kFpReturnRegisters[] = {f2, f4}; ++ + #elif V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 + // =========================================================================== + // == ppc & ppc64 ============================================================ +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/gn/tools/gn/args.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/gn/tools/gn/args.cc +@@ -329,6 +329,7 @@ void Args::SetSystemVarsLocked(Scope* de + static const char kMips64[] = "mips64el"; + static const char kS390X[] = "s390x"; + static const char kPPC64[] = "ppc64"; ++ static const char kLoongarch64[] = "loongarch64"; + const char* arch = nullptr; + + // Set the host CPU architecture based on the underlying OS, not +@@ -353,6 +354,8 @@ void Args::SetSystemVarsLocked(Scope* de + // This allows us to use the same toolchain as ppc64 BE + // and specific flags are included using the host_byteorder logic. + arch = kPPC64; ++ else if (os_arch == "loongarch64") ++ arch = kLoongarch64; + else + CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; + +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/gn/util/build_config.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/gn/util/build_config.h +@@ -172,6 +172,15 @@ + #define ARCH_CPU_32_BITS 1 + #define ARCH_CPU_BIG_ENDIAN 1 + #endif ++#elif defined(__loongarch__) ++#if defined(__loongarch_lp64) ++#define ARCH_CPU_LOONGARCH_FAMILY 1 ++#define ARCH_CPU_LOONGARCH64 1 ++#define ARCH_CPU_64_BITS 1 ++#define ARCH_CPU_LITTLE_ENDIAN 1 ++#else ++#error Only lp64 been supported on loongarch architecture! ++#endif + #else + #error Please add support for your architecture in build_config.h + #endif +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/buildtools/config/support.pri ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/buildtools/config/support.pri +@@ -110,7 +110,7 @@ defineTest(qtwebengine_checkForPlatform) + defineTest(qtwebengine_checkForArch) { + module = $$1 + !qtConfig(webengine-arch-support) { +- qtwebengine_skipBuild("$${module} can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.") ++ qtwebengine_skipBuild("$${module} can only be built for x86, x86-64, ARM, Aarch64, Loongarch64, and MIPSel architectures.") + return(false) + } + return(true) diff --git a/debian/patches/add-riscv64-support.patch b/debian/patches/add-riscv64-support.patch new file mode 100644 index 0000000000..4aa355ae6d --- /dev/null +++ b/debian/patches/add-riscv64-support.patch @@ -0,0 +1,44231 @@ +Description: Add riscv64 support for qtwebengine-opensource-src + Partly taken from an earlier revision of openSUSE RISC-V's Chromium (https://build.opensuse.org/package/show/openSUSE:Factory:RISCV/chromium), + with patches for vendored ffmpeg and linking to libatomic. +Author: Eric Long +--- a/src/3rdparty/chromium/v8/BUILD.gn ++++ b/src/3rdparty/chromium/v8/BUILD.gn +@@ -714,7 +714,7 @@ + + # Mips64el/mipsel simulators. + if (target_is_simulator && +- (v8_current_cpu == "mipsel" || v8_current_cpu == "mips64el")) { ++ (v8_current_cpu == "mipsel" || v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64")) { + defines += [ "_MIPS_TARGET_SIMULATOR" ] + } + +@@ -817,6 +817,21 @@ + } + } + ++ # Under simulator build, compiler will not provide __riscv_xlen. Define here ++ if (v8_current_cpu == "riscv") { ++ defines += [ "V8_TARGET_ARCH_RISCV" ] ++ defines += [ "__riscv_xlen=32" ] ++ } ++ ++ if (v8_current_cpu == "riscv64") { ++ defines += [ "V8_TARGET_ARCH_RISCV64" ] ++ defines += [ "__riscv_xlen=64" ] ++ #FIXME: Temporarily use MIPS macro for the building. ++ defines += [ ++ "CAN_USE_FPU_INSTRUCTIONS", ++ ] ++ } ++ + if (v8_current_cpu == "x86") { + defines += [ "V8_TARGET_ARCH_IA32" ] + if (is_win) { +@@ -905,7 +920,7 @@ + } + + if (v8_current_cpu == "x64" || v8_current_cpu == "arm64" || +- v8_current_cpu == "mips64el") { ++ v8_current_cpu == "mips64el" || v8_current_cpu == "riscv64") { + cflags += [ "-Wshorten-64-to-32" ] + } + } +@@ -1888,6 +1903,16 @@ + ### gcmole(arch:s390) ### + "src/builtins/s390/builtins-s390.cc", + ] ++ } else if (v8_current_cpu == "riscv64") { ++ sources += [ ++ ### gcmole(arch:riscv64) ### ++ "src/builtins/riscv64/builtins-riscv64.cc", ++ ] ++ } else if (v8_current_cpu == "riscv") { ++ sources += [ ++ ### gcmole(arch:riscv) ### ++ "src/builtins/riscv/builtins-riscv.cc", ++ ] + } + + if (!v8_enable_i18n_support) { +@@ -3762,6 +3787,60 @@ + "src/regexp/s390/regexp-macro-assembler-s390.h", + "src/wasm/baseline/s390/liftoff-assembler-s390.h", + ] ++ } else if (v8_current_cpu == "riscv64") { ++ sources += [ ### gcmole(arch:riscv64) ### ++ "src/codegen/riscv64/assembler-riscv64-inl.h", ++ "src/codegen/riscv64/assembler-riscv64.cc", ++ "src/codegen/riscv64/assembler-riscv64.h", ++ "src/codegen/riscv64/constants-riscv64.cc", ++ "src/codegen/riscv64/constants-riscv64.h", ++ "src/codegen/riscv64/cpu-riscv64.cc", ++ "src/codegen/riscv64/interface-descriptors-riscv64.cc", ++ "src/codegen/riscv64/macro-assembler-riscv64.cc", ++ "src/codegen/riscv64/macro-assembler-riscv64.h", ++ "src/codegen/riscv64/register-riscv64.h", ++ "src/compiler/backend/riscv64/code-generator-riscv64.cc", ++ "src/compiler/backend/riscv64/instruction-codes-riscv64.h", ++ "src/compiler/backend/riscv64/instruction-scheduler-riscv64.cc", ++ "src/compiler/backend/riscv64/instruction-selector-riscv64.cc", ++ "src/debug/riscv64/debug-riscv64.cc", ++ "src/deoptimizer/riscv64/deoptimizer-riscv64.cc", ++ "src/diagnostics/riscv64/disasm-riscv64.cc", ++ "src/execution/riscv64/frame-constants-riscv64.cc", ++ "src/execution/riscv64/frame-constants-riscv64.h", ++ "src/execution/riscv64/simulator-riscv64.cc", ++ "src/execution/riscv64/simulator-riscv64.h", ++ "src/regexp/riscv64/regexp-macro-assembler-riscv64.cc", ++ "src/regexp/riscv64/regexp-macro-assembler-riscv64.h", ++ "src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h", ++ ] ++ } else if (v8_current_cpu == "riscv") { ++ sources += [ ### gcmole(arch:riscv) ### ++ "src/codegen/riscv/assembler-riscv-inl.h", ++ "src/codegen/riscv/assembler-riscv.cc", ++ "src/codegen/riscv/assembler-riscv.h", ++ "src/codegen/riscv/constants-riscv.cc", ++ "src/codegen/riscv/constants-riscv.h", ++ "src/codegen/riscv/cpu-riscv.cc", ++ "src/codegen/riscv/interface-descriptors-riscv.cc", ++ "src/codegen/riscv/macro-assembler-riscv.cc", ++ "src/codegen/riscv/macro-assembler-riscv.h", ++ "src/codegen/riscv/register-riscv.h", ++ "src/compiler/backend/riscv/code-generator-riscv.cc", ++ "src/compiler/backend/riscv/instruction-codes-riscv.h", ++ "src/compiler/backend/riscv/instruction-scheduler-riscv.cc", ++ "src/compiler/backend/riscv/instruction-selector-riscv.cc", ++ "src/debug/riscv/debug-riscv.cc", ++ "src/deoptimizer/riscv/deoptimizer-riscv.cc", ++ "src/diagnostics/riscv/disasm-riscv.cc", ++ "src/execution/riscv/frame-constants-riscv.cc", ++ "src/execution/riscv/frame-constants-riscv.h", ++ "src/execution/riscv/simulator-riscv.cc", ++ "src/execution/riscv/simulator-riscv.h", ++ "src/regexp/riscv/regexp-macro-assembler-riscv.cc", ++ "src/regexp/riscv/regexp-macro-assembler-riscv.h", ++ "src/wasm/baseline/riscv/liftoff-assembler-riscv.h", ++ ] + } + + configs = [ +@@ -3862,7 +3941,8 @@ + if (v8_current_cpu == "mips" || v8_current_cpu == "mipsel" || + v8_current_cpu == "mips64" || v8_current_cpu == "mips64el" || + v8_current_cpu == "ppc" || v8_current_cpu == "ppc64" || +- v8_current_cpu == "s390" || v8_current_cpu == "s390x") { ++ v8_current_cpu == "s390" || v8_current_cpu == "s390x" || ++ v8_current_cpu == "riscv64" || v8_current_cpu == "riscv") { + libs += [ "atomic" ] + } + +@@ -4197,7 +4277,7 @@ + } + + if (is_ubsan && (v8_current_cpu == "x86" || v8_current_cpu == "arm" || +- v8_current_cpu == "mips")) { ++ v8_current_cpu == "mips" || v8_current_cpu == "riscv")) { + # Special UBSan 32-bit requirement. + sources += [ "src/base/ubsan.cc" ] + } +@@ -4328,6 +4408,8 @@ + sources += [ "src/heap/base/asm/mips/push_registers_asm.cc" ] + } else if (current_cpu == "mips64el") { + sources += [ "src/heap/base/asm/mips64/push_registers_asm.cc" ] ++ } else if (current_cpu == "riscv64") { ++ sources += [ "src/heap/base/asm/riscv64/push_registers_asm.cc" ] + } + } else if (is_win) { + if (current_cpu == "x64") { +--- a/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni ++++ b/src/3rdparty/chromium/v8/gni/snapshot_toolchain.gni +@@ -79,7 +79,8 @@ + + if (v8_current_cpu == "x64" || v8_current_cpu == "x86") { + _cpus = v8_current_cpu +- } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el") { ++ } else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" ++ || v8_current_cpu == "riscv64") { + if (is_win && v8_current_cpu == "arm64") { + # set _cpus to blank for Windows ARM64 so host_toolchain could be + # selected as snapshot toolchain later. +--- a/src/3rdparty/chromium/v8/infra/mb/mb_config.pyl ++++ b/src/3rdparty/chromium/v8/infra/mb/mb_config.pyl +@@ -33,6 +33,12 @@ + 'ppc64.debug.sim': 'default_debug_ppc64_sim', + 'ppc64.optdebug.sim': 'default_optdebug_ppc64_sim', + 'ppc64.release.sim': 'default_release_ppc64_sim', ++ 'riscv64.debug': 'default_debug_riscv64', ++ 'riscv64.optdebug': 'default_optdebug_riscv64', ++ 'riscv64.release': 'default_release_riscv64', ++ 'riscv64.debug.sim': 'default_debug_riscv64_sim', ++ 'riscv64.optdebug.sim': 'default_optdebug_riscv64_sim', ++ 'riscv64.release.sim': 'default_release_riscv64_sim', + 's390x.debug': 'default_debug_s390x', + 's390x.optdebug': 'default_optdebug_s390x', + 's390x.release': 'default_release_s390x', +@@ -175,6 +181,8 @@ + # IBM. + 'V8 Linux - ppc64 - sim': 'release_simulate_ppc64', + 'V8 Linux - s390x - sim': 'release_simulate_s390x', ++ # RISC-V ++ 'V8 Linux - riscv64 - sim': 'release_simulate_riscv64', + }, + 'client.v8.branches': { + 'V8 Linux - previous branch': 'release_x86', +@@ -207,6 +215,9 @@ + 'V8 s390x - sim - previous branch': 'release_simulate_s390x', + 'V8 s390x - sim - beta branch': 'release_simulate_s390x', + 'V8 s390x - sim - stable branch': 'release_simulate_s390x', ++ 'V8 riscv64 - sim - previous branch': 'release_simulate_riscv64', ++ 'V8 riscv64 - sim - beta branch': 'release_simulate_riscv64', ++ 'V8 riscv64 - sim - stable branch': 'release_simulate_riscv64', + }, + 'tryserver.v8': { + 'v8_android_arm_compile_rel': 'release_android_arm', +@@ -323,6 +334,18 @@ + 'debug', 'simulate_mips64el', 'v8_enable_slow_dchecks'], + 'default_release_mips64el': [ + 'release', 'simulate_mips64el'], ++ 'default_debug_riscv64': [ ++ 'debug', 'riscv64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], ++ 'default_optdebug_riscv64': [ ++ 'debug', 'riscv64', 'gcc', 'v8_enable_slow_dchecks'], ++ 'default_release_riscv64': [ ++ 'release', 'riscv64', 'gcc'], ++ 'default_debug_riscv64_sim': [ ++ 'debug', 'simulate_riscv64', 'v8_enable_slow_dchecks', 'v8_full_debug'], ++ 'default_optdebug_riscv64_sim': [ ++ 'debug', 'simulate_riscv64', 'v8_enable_slow_dchecks'], ++ 'default_release_riscv64_sim': [ ++ 'release', 'simulate_riscv64'], + 'default_debug_ppc64': [ + 'debug', 'ppc64', 'gcc', 'v8_enable_slow_dchecks', 'v8_full_debug'], + 'default_optdebug_ppc64': [ +@@ -410,6 +433,8 @@ + 'release_bot', 'simulate_mips64el'], + 'release_simulate_ppc64': [ + 'release_bot', 'simulate_ppc64'], ++ 'release_simulate_riscv64': [ ++ 'release_bot', 'simulate_riscv64'], + 'release_simulate_s390x': [ + 'release_bot', 'simulate_s390x'], + +@@ -812,6 +837,10 @@ + 'gn_args': 'target_cpu="x64" v8_target_cpu="ppc64"', + }, + ++ 'simulate_riscv64': { ++ 'gn_args': 'target_cpu="x64" v8_target_cpu="riscv64"', ++ }, ++ + 'simulate_s390x': { + 'gn_args': 'target_cpu="x64" v8_target_cpu="s390x"', + }, +@@ -918,6 +947,10 @@ + 'gn_args': 'target_cpu="ppc64" use_custom_libcxx=false', + }, + ++ 'riscv64': { ++ 'gn_args': 'target_cpu="riscv64" use_custom_libcxx=false', ++ }, ++ + 'x64': { + 'gn_args': 'target_cpu="x64"', + }, +--- a/src/3rdparty/chromium/v8/src/base/build_config.h ++++ b/src/3rdparty/chromium/v8/src/base/build_config.h +@@ -46,6 +46,16 @@ + #else + #define V8_HOST_ARCH_32_BIT 1 + #endif ++#elif defined(__riscv) || defined(__riscv__) ++#if __riscv_xlen == 64 ++#define V8_HOST_ARCH_RISCV64 1 ++#define V8_HOST_ARCH_64_BIT 1 ++#elif __riscv_xlen == 32 ++#define V8_HOST_ARCH_RISCV 1 ++#define V8_HOST_ARCH_32_BIT 1 ++#else ++#error "Cannot detect Riscv's bitwidth" ++#endif + #else + #error "Host architecture was not detected as supported by v8" + #endif +@@ -77,7 +87,8 @@ + // environment as presented by the compiler. + #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && \ + !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 && \ +- !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 ++ !V8_TARGET_ARCH_PPC && !V8_TARGET_ARCH_PPC64 && !V8_TARGET_ARCH_S390 && \ ++ !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV + #if defined(_M_X64) || defined(__x86_64__) + #define V8_TARGET_ARCH_X64 1 + #elif defined(_M_IX86) || defined(__i386__) +@@ -94,6 +105,12 @@ + #define V8_TARGET_ARCH_PPC64 1 + #elif defined(_ARCH_PPC) + #define V8_TARGET_ARCH_PPC 1 ++#elif defined(__riscv) || defined(__riscv__) ++#if __riscv_xlen == 64 ++#define V8_TARGET_ARCH_RISCV64 1 ++#elif __riscv_xlen == 32 ++#define V8_TARGET_ARCH_RISCV 1 ++#endif + #else + #error Target architecture was not detected as supported by v8 + #endif +@@ -128,6 +145,10 @@ + #else + #define V8_TARGET_ARCH_32_BIT 1 + #endif ++#elif V8_TARGET_ARCH_RISCV64 ++#define V8_TARGET_ARCH_64_BIT 1 ++#elif V8_TARGET_ARCH_RISCV ++#define V8_TARGET_ARCH_32_BIT 1 + #else + #error Unknown target architecture pointer size + #endif +@@ -156,6 +177,13 @@ + #if (V8_TARGET_ARCH_MIPS64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_MIPS64)) + #error Target architecture mips64 is only supported on mips64 and x64 host + #endif ++#if (V8_TARGET_ARCH_RISCV64 && !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV64)) ++#error Target architecture riscv64 is only supported on riscv64 and x64 host ++#endif ++#if (V8_TARGET_ARCH_RISCV && \ ++ !(V8_HOST_ARCH_X64 || V8_HOST_ARCH_RISCV || V8_HOST_ARCH_RISCV64)) ++#error Target architecture riscv (32) is only supported on riscv(32), riscv64, and x64 host ++#endif + + // Determine architecture endianness. + #if V8_TARGET_ARCH_IA32 +@@ -190,6 +218,8 @@ + #else + #define V8_TARGET_BIG_ENDIAN 1 + #endif ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++#define V8_TARGET_LITTLE_ENDIAN 1 + #else + #error Unknown target architecture endianness + #endif +--- a/src/3rdparty/chromium/v8/src/base/compiler-specific.h ++++ b/src/3rdparty/chromium/v8/src/base/compiler-specific.h +@@ -96,9 +96,10 @@ + // do not support adding noexcept to default members. + // Disabled on MSVC because constructors of standard containers are not noexcept + // there. +-#if ((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \ +- !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ +- !defined(V8_TARGET_ARCH_PPC) && !defined(V8_TARGET_ARCH_PPC64)) || \ ++#if ((!defined(V8_CC_GNU) && !defined(V8_CC_MSVC) && \ ++ !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ ++ !defined(V8_TARGET_ARCH_PPC) && !defined(V8_TARGET_ARCH_PPC64) && \ ++ !defined(V8_TARGET_ARCH_RISCV64) && !defined(V8_TARGET_ARCH_RISCV)) || \ + (defined(__clang__) && __cplusplus > 201300L)) + #define V8_NOEXCEPT noexcept + #else +--- a/src/3rdparty/chromium/v8/src/base/macros.h ++++ b/src/3rdparty/chromium/v8/src/base/macros.h +@@ -12,6 +12,8 @@ + #include "src/base/compiler-specific.h" + #include "src/base/logging.h" + ++#define DEBUG_PRINTF(...) if (FLAG_debug_riscv) { printf(__VA_ARGS__); } ++ + // No-op macro which is used to work around MSVC's funky VA_ARGS support. + #define EXPAND(x) x + +--- a/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc ++++ b/src/3rdparty/chromium/v8/src/base/platform/platform-posix.cc +@@ -324,6 +324,12 @@ + // 42 bits of virtual addressing. Truncate to 40 bits to allow kernel chance + // to fulfill request. + raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_RISCV64 ++ // FIXME(RISCV): We need more information from the kernel to correctly mask ++ // this address for RISC-V. ++ raw_addr &= uint64_t{0xFFFFFF0000}; ++#elif V8_TARGET_ARCH_RISCV ++ #error RISCV archiecture not supported + #else + raw_addr &= 0x3FFFF000; + +@@ -512,6 +518,8 @@ + #elif V8_HOST_ARCH_S390 + // Software breakpoint instruction is 0x0001 + asm volatile(".word 0x0001"); ++#elif V8_HOST_ARCH_RISCV64 || V8_HOST_ARCH_RISCV ++ asm("ebreak"); + #else + #error Unsupported host architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/builtins/builtins-sharedarraybuffer-gen.cc ++++ b/src/3rdparty/chromium/v8/src/builtins/builtins-sharedarraybuffer-gen.cc +@@ -379,7 +379,9 @@ + // 2. Let i be ? ValidateAtomicAccess(typedArray, index). + TNode index_word = ValidateAtomicAccess(array, index, context); + +-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ ++ V8_TARGET_ARCH_RISCV ++ // FIXME(RISCV): Review this special case once atomics are added + USE(array_buffer); + TNode index_number = ChangeUintPtrToTagged(index_word); + Return(CallRuntime(Runtime::kAtomicsExchange, context, array, index_number, +@@ -481,7 +483,8 @@ + // This shouldn't happen, we've already validated the type. + BIND(&other); + Unreachable(); +-#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || ++ // V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + + BIND(&detached); + { +@@ -510,7 +513,9 @@ + TNode index_word = ValidateAtomicAccess(array, index, context); + + #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ +- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ ++ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ // FIXME(RISCV): Review this special case once atomics are added + USE(array_buffer); + TNode index_number = ChangeUintPtrToTagged(index_word); + Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array, +@@ -632,6 +637,7 @@ + Unreachable(); + #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 + // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + + BIND(&detached); + { +@@ -679,7 +685,9 @@ + TNode index_word = ValidateAtomicAccess(array, index, context); + + #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ +- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ ++ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ // FIXME(RISCV): Review this special case once atomics are added + USE(array_buffer); + TNode index_number = ChangeUintPtrToTagged(index_word); + Return(CallRuntime(runtime_function, context, array, index_number, value)); +@@ -783,6 +791,7 @@ + Unreachable(); + #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 + // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + + BIND(&detached); + ThrowTypeError(context, MessageTemplate::kDetachedOperation, method_name); +--- a/src/3rdparty/chromium/v8/src/builtins/builtins.cc ++++ b/src/3rdparty/chromium/v8/src/builtins/builtins.cc +@@ -490,14 +490,17 @@ + case Builtins::kCEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit: + return true; + default: +-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ ++ V8_TARGET_ARCH_RISCV ++ // FIXME(RISCV): Is this correct for RISC-V? + // TODO(Loongson): Move non-JS linkage builtins code objects into RO_SPACE + // caused MIPS platform to crash, and we need some time to handle it. Now + // disable this change temporarily on MIPS platform. + return true; + #else + return false; +-#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || ++ // V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + } + } + +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/builtins/riscv64/builtins-riscv64.cc +@@ -0,0 +1,3197 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/api/api-arguments.h" ++#include "src/codegen/code-factory.h" ++#include "src/debug/debug.h" ++#include "src/deoptimizer/deoptimizer.h" ++#include "src/execution/frame-constants.h" ++#include "src/execution/frames.h" ++#include "src/logging/counters.h" ++// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. ++#include "src/codegen/macro-assembler-inl.h" ++#include "src/codegen/register-configuration.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/heap/heap-inl.h" ++#include "src/objects/cell.h" ++#include "src/objects/foreign.h" ++#include "src/objects/heap-number.h" ++#include "src/objects/js-generator.h" ++#include "src/objects/objects-inl.h" ++#include "src/objects/smi.h" ++#include "src/runtime/runtime.h" ++#include "src/wasm/wasm-linkage.h" ++#include "src/wasm/wasm-objects.h" ++ ++namespace v8 { ++namespace internal { ++ ++#define __ ACCESS_MASM(masm) ++ ++void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { ++ __ li(kJavaScriptCallExtraArg1Register, ExternalReference::Create(address)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), AdaptorWithBuiltinExitFrame), ++ RelocInfo::CODE_TARGET); ++} ++ ++static void GenerateTailCallToReturnedCode(MacroAssembler* masm, ++ Runtime::FunctionId function_id) { ++ // ----------- S t a t e ------------- ++ // -- a1 : target function (preserved for callee) ++ // -- a3 : new target (preserved for callee) ++ // ----------------------------------- ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ // Push a copy of the function onto the stack. ++ // Push a copy of the target function and the new target. ++ __ Push(a1, a3, a1); ++ ++ __ CallRuntime(function_id, 1); ++ // Restore target function and new target. ++ __ Pop(a1, a3); ++ } ++ ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Add64(a2, a0, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++} ++ ++namespace { ++ ++enum StackLimitKind { kInterruptStackLimit, kRealStackLimit }; ++ ++void LoadStackLimit(MacroAssembler* masm, Register destination, ++ StackLimitKind kind) { ++ DCHECK(masm->root_array_available()); ++ Isolate* isolate = masm->isolate(); ++ ExternalReference limit = ++ kind == StackLimitKind::kRealStackLimit ++ ? ExternalReference::address_of_real_jslimit(isolate) ++ : ExternalReference::address_of_jslimit(isolate); ++ DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); ++ ++ intptr_t offset = ++ TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); ++ CHECK(is_int32(offset)); ++ __ Ld(destination, MemOperand(kRootRegister, static_cast(offset))); ++} ++ ++void Generate_JSBuiltinsConstructStubHelper(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : number of arguments ++ // -- a1 : constructor function ++ // -- a3 : new target ++ // -- cp : context ++ // -- ra : return address ++ // -- sp[...]: constructor arguments ++ // ----------------------------------- ++ ++ // Enter a construct frame. ++ { ++ FrameScope scope(masm, StackFrame::CONSTRUCT); ++ ++ // Preserve the incoming parameters on the stack. ++ __ SmiTag(a0); ++ __ Push(cp, a0); ++ __ SmiUntag(a0); ++ ++ // The receiver for the builtin/api call. ++ __ PushRoot(RootIndex::kTheHoleValue); ++ ++ // Set up pointer to last argument. ++ __ Add64(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); ++ ++ // Copy arguments and receiver to the expression stack. ++ Label loop, entry; ++ __ Move(t4, a0); ++ // ----------- S t a t e ------------- ++ // -- a0: number of arguments (untagged) ++ // -- a3: new target ++ // -- t2: pointer to last argument ++ // -- t4: counter ++ // -- sp[0*kPointerSize]: the hole (receiver) ++ // -- sp[1*kPointerSize]: number of arguments (tagged) ++ // -- sp[2*kPointerSize]: context ++ // ----------------------------------- ++ __ Branch(&entry); ++ __ bind(&loop); ++ __ CalcScaledAddress(t0, t2, t4, kPointerSizeLog2); ++ __ Ld(t1, MemOperand(t0)); ++ __ push(t1); ++ __ bind(&entry); ++ __ Add64(t4, t4, Operand(-1)); ++ __ Branch(&loop, greater_equal, t4, Operand(zero_reg)); ++ ++ // Call the function. ++ // a0: number of arguments (untagged) ++ // a1: constructor function ++ // a3: new target ++ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); ++ ++ // Restore context from the frame. ++ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ // Restore smi-tagged arguments count from the frame. ++ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ // Leave construct frame. ++ } ++ ++ // Remove caller arguments from the stack and return. ++ __ SmiScale(a4, a1, kPointerSizeLog2); ++ __ Add64(sp, sp, a4); ++ __ Add64(sp, sp, kPointerSize); ++ __ Ret(); ++} ++ ++static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args, ++ Register scratch1, Register scratch2, ++ Label* stack_overflow) { ++ // Check the stack for overflow. We are not trying to catch ++ // interruptions (e.g. debug break and preemption) here, so the "real stack ++ // limit" is checked. ++ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); ++ // Make scratch1 the space we have left. The stack might already be overflowed ++ // here which will cause scratch1 to become negative. ++ __ Sub64(scratch1, sp, scratch1); ++ // Check if the arguments will overflow the stack. ++ __ Sll64(scratch2, num_args, kPointerSizeLog2); ++ // Signed comparison. ++ __ Branch(stack_overflow, le, scratch1, Operand(scratch2)); ++} ++ ++} // namespace ++ ++// The construct stub for ES5 constructor functions and ES6 class constructors. ++void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0: number of arguments (untagged) ++ // -- a1: constructor function ++ // -- a3: new target ++ // -- cp: context ++ // -- ra: return address ++ // -- sp[...]: constructor arguments ++ // ----------------------------------- ++ ++ // Enter a construct frame. ++ { ++ FrameScope scope(masm, StackFrame::CONSTRUCT); ++ Label post_instantiation_deopt_entry, not_create_implicit_receiver; ++ ++ // Preserve the incoming parameters on the stack. ++ __ SmiTag(a0); ++ __ Push(cp, a0, a1); ++ __ PushRoot(RootIndex::kTheHoleValue); ++ __ Push(a3); ++ ++ // ----------- S t a t e ------------- ++ // -- sp[0*kPointerSize]: new target ++ // -- sp[1*kPointerSize]: padding ++ // -- a1 and sp[2*kPointerSize]: constructor function ++ // -- sp[3*kPointerSize]: number of arguments (tagged) ++ // -- sp[4*kPointerSize]: context ++ // ----------------------------------- ++ ++ __ Ld(t2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lwu(t2, FieldMemOperand(t2, SharedFunctionInfo::kFlagsOffset)); ++ __ DecodeField(t2); ++ __ JumpIfIsInRange(t2, kDefaultDerivedConstructor, kDerivedConstructor, ++ ¬_create_implicit_receiver); ++ ++ // If not derived class constructor: Allocate the new receiver object. ++ __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1, ++ t2, t4); ++ __ Call(BUILTIN_CODE(masm->isolate(), FastNewObject), ++ RelocInfo::CODE_TARGET); ++ __ Branch(&post_instantiation_deopt_entry); ++ ++ // Else: use TheHoleValue as receiver for constructor call ++ __ bind(¬_create_implicit_receiver); ++ __ LoadRoot(a0, RootIndex::kTheHoleValue); ++ ++ // ----------- S t a t e ------------- ++ // -- a0: receiver ++ // -- Slot 4 / sp[0*kPointerSize]: new target ++ // -- Slot 3 / sp[1*kPointerSize]: padding ++ // -- Slot 2 / sp[2*kPointerSize]: constructor function ++ // -- Slot 1 / sp[3*kPointerSize]: number of arguments (tagged) ++ // -- Slot 0 / sp[4*kPointerSize]: context ++ // ----------------------------------- ++ // Deoptimizer enters here. ++ masm->isolate()->heap()->SetConstructStubCreateDeoptPCOffset( ++ masm->pc_offset()); ++ __ bind(&post_instantiation_deopt_entry); ++ ++ // Restore new target. ++ __ Pop(a3); ++ // Push the allocated receiver to the stack. We need two copies ++ // because we may have to return the original one and the calling ++ // conventions dictate that the called function pops the receiver. ++ __ Push(a0, a0); ++ ++ // ----------- S t a t e ------------- ++ // -- r3: new target ++ // -- sp[0*kPointerSize]: implicit receiver ++ // -- sp[1*kPointerSize]: implicit receiver ++ // -- sp[2*kPointerSize]: padding ++ // -- sp[3*kPointerSize]: constructor function ++ // -- sp[4*kPointerSize]: number of arguments (tagged) ++ // -- sp[5*kPointerSize]: context ++ // ----------------------------------- ++ ++ // Restore constructor function and argument count. ++ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kConstructorOffset)); ++ __ Ld(a0, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ __ SmiUntag(a0); ++ ++ // Set up pointer to last argument. ++ __ Add64(t2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); ++ ++ Label enough_stack_space, stack_overflow; ++ Generate_StackOverflowCheck(masm, a0, t0, t1, &stack_overflow); ++ __ Branch(&enough_stack_space); ++ ++ __ bind(&stack_overflow); ++ // Restore the context from the frame. ++ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ ++ __ bind(&enough_stack_space); ++ ++ // Copy arguments and receiver to the expression stack. ++ Label loop, entry; ++ __ Move(t4, a0); ++ // ----------- S t a t e ------------- ++ // -- a0: number of arguments (untagged) ++ // -- a3: new target ++ // -- t2: pointer to last argument ++ // -- t4: counter ++ // -- sp[0*kPointerSize]: implicit receiver ++ // -- sp[1*kPointerSize]: implicit receiver ++ // -- sp[2*kPointerSize]: padding ++ // -- a1 and sp[3*kPointerSize]: constructor function ++ // -- sp[4*kPointerSize]: number of arguments (tagged) ++ // -- sp[5*kPointerSize]: context ++ // ----------------------------------- ++ __ Branch(&entry); ++ __ bind(&loop); ++ __ CalcScaledAddress(t0, t2, t4, kPointerSizeLog2); ++ __ Ld(t1, MemOperand(t0)); ++ __ push(t1); ++ __ bind(&entry); ++ __ Add64(t4, t4, Operand(-1)); ++ __ Branch(&loop, greater_equal, t4, Operand(zero_reg)); ++ ++ // Call the function. ++ __ InvokeFunctionWithNewTarget(a1, a3, a0, CALL_FUNCTION); ++ ++ // ----------- S t a t e ------------- ++ // -- a0: constructor result ++ // -- sp[0*kPointerSize]: implicit receiver ++ // -- sp[1*kPointerSize]: padding ++ // -- sp[2*kPointerSize]: constructor function ++ // -- sp[3*kPointerSize]: number of arguments ++ // -- sp[4*kPointerSize]: context ++ // ----------------------------------- ++ ++ // Store offset of return address for deoptimizer. ++ masm->isolate()->heap()->SetConstructStubInvokeDeoptPCOffset( ++ masm->pc_offset()); ++ ++ // Restore the context from the frame. ++ __ Ld(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); ++ ++ // If the result is an object (in the ECMA sense), we should get rid ++ // of the receiver and use the result; see ECMA-262 section 13.2.2-7 ++ // on page 74. ++ Label use_receiver, do_throw, leave_frame; ++ ++ // If the result is undefined, we jump out to using the implicit receiver. ++ __ JumpIfRoot(a0, RootIndex::kUndefinedValue, &use_receiver); ++ ++ // Otherwise we do a smi check and fall through to check if the return value ++ // is a valid receiver. ++ ++ // If the result is a smi, it is *not* an object in the ECMA sense. ++ __ JumpIfSmi(a0, &use_receiver); ++ ++ // If the type of the result (stored in its map) is less than ++ // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. ++ __ GetObjectType(a0, t2, t2); ++ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); ++ __ Branch(&leave_frame, greater_equal, t2, Operand(FIRST_JS_RECEIVER_TYPE)); ++ __ Branch(&use_receiver); ++ ++ __ bind(&do_throw); ++ __ CallRuntime(Runtime::kThrowConstructorReturnedNonObject); ++ ++ // Throw away the result of the constructor invocation and use the ++ // on-stack receiver as the result. ++ __ bind(&use_receiver); ++ __ Ld(a0, MemOperand(sp, 0 * kPointerSize)); ++ __ JumpIfRoot(a0, RootIndex::kTheHoleValue, &do_throw); ++ ++ __ bind(&leave_frame); ++ // Restore smi-tagged arguments count from the frame. ++ __ Ld(a1, MemOperand(fp, ConstructFrameConstants::kLengthOffset)); ++ // Leave construct frame. ++ } ++ // Remove caller arguments from the stack and return. ++ __ SmiScale(a4, a1, kPointerSizeLog2); ++ __ Add64(sp, sp, a4); ++ __ Add64(sp, sp, kPointerSize); ++ __ Ret(); ++} ++ ++void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { ++ Generate_JSBuiltinsConstructStubHelper(masm); ++} ++ ++static void GetSharedFunctionInfoBytecode(MacroAssembler* masm, ++ Register sfi_data, ++ Register scratch1) { ++ Label done; ++ ++ __ GetObjectType(sfi_data, scratch1, scratch1); ++ __ Branch(&done, ne, scratch1, Operand(INTERPRETER_DATA_TYPE)); ++ __ Ld(sfi_data, ++ FieldMemOperand(sfi_data, InterpreterData::kBytecodeArrayOffset)); ++ ++ __ bind(&done); ++} ++ ++// static ++void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the value to pass to the generator ++ // -- a1 : the JSGeneratorObject to resume ++ // -- ra : return address ++ // ----------------------------------- ++ __ AssertGeneratorObject(a1); ++ ++ // Store input value into generator object. ++ __ Sd(a0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); ++ __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, a0, a3, ++ kRAHasNotBeenSaved, kDontSaveFPRegs); ++ ++ // Load suspended function and context. ++ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Ld(cp, FieldMemOperand(a4, JSFunction::kContextOffset)); ++ ++ // Flood function if we are stepping. ++ Label prepare_step_in_if_stepping, prepare_step_in_suspended_generator; ++ Label stepping_prepared; ++ ExternalReference debug_hook = ++ ExternalReference::debug_hook_on_function_call_address(masm->isolate()); ++ __ li(a5, debug_hook); ++ __ Lb(a5, MemOperand(a5)); ++ __ Branch(&prepare_step_in_if_stepping, ne, a5, Operand(zero_reg)); ++ ++ // Flood function if we need to continue stepping in the suspended generator. ++ ExternalReference debug_suspended_generator = ++ ExternalReference::debug_suspended_generator_address(masm->isolate()); ++ __ li(a5, debug_suspended_generator); ++ __ Ld(a5, MemOperand(a5)); ++ __ Branch(&prepare_step_in_suspended_generator, eq, a1, Operand(a5)); ++ __ bind(&stepping_prepared); ++ ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ Label stack_overflow; ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&stack_overflow, Uless, sp, Operand(kScratchReg)); ++ ++ // Push receiver. ++ __ Ld(a5, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); ++ __ Push(a5); ++ ++ // ----------- S t a t e ------------- ++ // -- a1 : the JSGeneratorObject to resume ++ // -- a4 : generator function ++ // -- cp : generator context ++ // -- ra : return address ++ // -- sp[0] : generator receiver ++ // ----------------------------------- ++ ++ // Push holes for arguments to generator function. Since the parser forced ++ // context allocation for any variables in generators, the actual argument ++ // values have already been copied into the context and these dummy values ++ // will never be used. ++ __ Ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lhu(a3, ++ FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ Ld(t1, ++ FieldMemOperand(a1, JSGeneratorObject::kParametersAndRegistersOffset)); ++ { ++ Label done_loop, loop; ++ __ Move(t2, zero_reg); ++ __ bind(&loop); ++ __ Sub64(a3, a3, Operand(1)); ++ __ Branch(&done_loop, lt, a3, Operand(zero_reg)); ++ __ CalcScaledAddress(kScratchReg, t1, t2, kPointerSizeLog2); ++ __ Ld(kScratchReg, FieldMemOperand(kScratchReg, FixedArray::kHeaderSize)); ++ __ Push(kScratchReg); ++ __ Add64(t2, t2, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Underlying function needs to have bytecode available. ++ if (FLAG_debug_code) { ++ __ Ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); ++ GetSharedFunctionInfoBytecode(masm, a3, a0); ++ __ GetObjectType(a3, a3, a3); ++ __ Assert(eq, AbortReason::kMissingBytecodeArray, a3, ++ Operand(BYTECODE_ARRAY_TYPE)); ++ } ++ ++ // Resume (Ignition/TurboFan) generator object. ++ { ++ __ Ld(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lhu(a0, FieldMemOperand( ++ a0, SharedFunctionInfo::kFormalParameterCountOffset)); ++ // We abuse new.target both to indicate that this is a resume call and to ++ // pass in the generator object. In ordinary calls, new.target is always ++ // undefined because generator functions are non-constructable. ++ __ Move(a3, a1); ++ __ Move(a1, a4); ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ } ++ ++ __ bind(&prepare_step_in_if_stepping); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1, a4); ++ // Push hole as receiver since we do not use it for stepping. ++ __ PushRoot(RootIndex::kTheHoleValue); ++ __ CallRuntime(Runtime::kDebugOnFunctionCall); ++ __ Pop(a1); ++ } ++ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Branch(&stepping_prepared); ++ ++ __ bind(&prepare_step_in_suspended_generator); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kDebugPrepareStepInSuspendedGenerator); ++ __ Pop(a1); ++ } ++ __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); ++ __ Branch(&stepping_prepared); ++ ++ __ bind(&stack_overflow); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ __ break_(0xCC); // This should be unreachable. ++ } ++} ++ ++void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowConstructedNonConstructable); ++} ++ ++// Clobbers scratch1 and scratch2; preserves all other registers. ++static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, ++ Register scratch1, Register scratch2) { ++ // Check the stack for overflow. We are not trying to catch ++ // interruptions (e.g. debug break and preemption) here, so the "real stack ++ // limit" is checked. ++ Label okay; ++ LoadStackLimit(masm, scratch1, StackLimitKind::kRealStackLimit); ++ // Make a2 the space we have left. The stack might already be overflowed ++ // here which will cause r2 to become negative. ++ __ Sub64(scratch1, sp, scratch1); ++ // Check if the arguments will overflow the stack. ++ __ Sll64(scratch2, argc, kPointerSizeLog2); ++ __ Branch(&okay, gt, scratch1, Operand(scratch2)); // Signed comparison. ++ ++ // Out of stack space. ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ ++ __ bind(&okay); ++} ++ ++namespace { ++ ++// Called with the native C calling convention. The corresponding function ++// signature is either: ++// ++// using JSEntryFunction = GeneratedCode; ++// or ++// using JSEntryFunction = GeneratedCode; ++void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type, ++ Builtins::Name entry_trampoline) { ++ Label invoke, handler_entry, exit; ++ ++ { ++ NoRootArrayScope no_root_array(masm); ++ ++ // TODO(plind): unify the ABI description here. ++ // Registers: ++ // either ++ // a0: root register value ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a0: root register value ++ // a1: microtask_queue ++ ++ // Save callee saved registers on the stack. ++ __ MultiPush(kCalleeSaved | ra.bit()); ++ ++ // Save callee-saved FPU registers. ++ __ MultiPushFPU(kCalleeSavedFPU); ++ // Set up the reserved register for 0.0. ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0); ++ ++ // Initialize the root register. ++ // C calling convention. The first argument is passed in a0. ++ __ Move(kRootRegister, a0); ++ } ++ ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ ++ // We build an EntryFrame. ++ __ li(s1, Operand(-1)); // Push a bad frame pointer to fail if it is used. ++ __ li(s2, Operand(StackFrame::TypeToMarker(type))); ++ __ li(s3, Operand(StackFrame::TypeToMarker(type))); ++ ExternalReference c_entry_fp = ExternalReference::Create( ++ IsolateAddressId::kCEntryFPAddress, masm->isolate()); ++ __ li(s4, c_entry_fp); ++ __ Ld(s4, MemOperand(s4)); ++ __ Push(s1, s2, s3, s4); ++ // Set up frame pointer for the frame to be pushed. ++ __ Add64(fp, sp, -EntryFrameConstants::kCallerFPOffset); ++ // Registers: ++ // either ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a1: microtask_queue ++ // ++ // Stack: ++ // caller fp | ++ // function slot | entry frame ++ // context slot | ++ // bad fp (0xFF...F) | ++ // callee saved registers + ra ++ // [ O32: 4 args slots] ++ // args ++ ++ // If this is the outermost JS call, set js_entry_sp value. ++ Label non_outermost_js; ++ ExternalReference js_entry_sp = ExternalReference::Create( ++ IsolateAddressId::kJSEntrySPAddress, masm->isolate()); ++ __ li(s1, js_entry_sp); ++ __ Ld(s2, MemOperand(s1)); ++ __ Branch(&non_outermost_js, ne, s2, Operand(zero_reg)); ++ __ Sd(fp, MemOperand(s1)); ++ __ li(s3, Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); ++ Label cont; ++ __ Branch(&cont); ++ __ bind(&non_outermost_js); ++ __ li(s3, Operand(StackFrame::INNER_JSENTRY_FRAME)); ++ __ bind(&cont); ++ __ push(s3); ++ ++ // Jump to a faked try block that does the invoke, with a faked catch ++ // block that sets the pending exception. ++ __ Branch(&invoke); ++ __ bind(&handler_entry); ++ ++ // Store the current pc as the handler offset. It's used later to create the ++ // handler table. ++ masm->isolate()->builtins()->SetJSEntryHandlerOffset(handler_entry.pos()); ++ ++ // Caught exception: Store result (exception) in the pending exception ++ // field in the JSEnv and return a failure sentinel. Coming in here the ++ // fp will be invalid because the PushStackHandler below sets it to 0 to ++ // signal the existence of the JSEntry frame. ++ __ li(s1, ExternalReference::Create( ++ IsolateAddressId::kPendingExceptionAddress, masm->isolate())); ++ __ Sd(a0, MemOperand(s1)); // We come back from 'invoke'. result is in a0. ++ __ LoadRoot(a0, RootIndex::kException); ++ __ Branch(&exit); ++ ++ // Invoke: Link this frame into the handler chain. ++ __ bind(&invoke); ++ __ PushStackHandler(); ++ // If an exception not caught by another handler occurs, this handler ++ // returns control to the code after the bal(&invoke) above, which ++ // restores all kCalleeSaved registers (including cp and fp) to their ++ // saved values before returning a failure to C. ++ // ++ // Registers: ++ // either ++ // a0: root register value ++ // a1: entry address ++ // a2: function ++ // a3: receiver ++ // a4: argc ++ // a5: argv ++ // or ++ // a0: root register value ++ // a1: microtask_queue ++ // ++ // Stack: ++ // handler frame ++ // entry frame ++ // callee saved registers + ra ++ // [ O32: 4 args slots] ++ // args ++ // ++ // Invoke the function by calling through JS entry trampoline builtin and ++ // pop the faked function when we return. ++ ++ Handle trampoline_code = ++ masm->isolate()->builtins()->builtin_handle(entry_trampoline); ++ __ Call(trampoline_code, RelocInfo::CODE_TARGET); ++ ++ // Unlink this frame from the handler chain. ++ __ PopStackHandler(); ++ ++ __ bind(&exit); // a0 holds result ++ // Check if the current stack frame is marked as the outermost JS frame. ++ Label non_outermost_js_2; ++ __ pop(a5); ++ __ Branch(&non_outermost_js_2, ne, a5, ++ Operand(StackFrame::OUTERMOST_JSENTRY_FRAME)); ++ __ li(a5, js_entry_sp); ++ __ Sd(zero_reg, MemOperand(a5)); ++ __ bind(&non_outermost_js_2); ++ ++ // Restore the top frame descriptors from the stack. ++ __ pop(a5); ++ __ li(a4, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, ++ masm->isolate())); ++ __ Sd(a5, MemOperand(a4)); ++ ++ // Reset the stack to the callee saved registers. ++ __ Add64(sp, sp, -EntryFrameConstants::kCallerFPOffset); ++ ++ // Restore callee-saved fpu registers. ++ __ MultiPopFPU(kCalleeSavedFPU); ++ ++ // Restore callee saved registers from the stack. ++ __ MultiPop(kCalleeSaved | ra.bit()); ++ // Return. ++ __ Jump(ra); ++} ++ ++} // namespace ++ ++void Builtins::Generate_JSEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::ENTRY, ++ Builtins::kJSEntryTrampoline); ++} ++ ++void Builtins::Generate_JSConstructEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::CONSTRUCT_ENTRY, ++ Builtins::kJSConstructEntryTrampoline); ++} ++ ++void Builtins::Generate_JSRunMicrotasksEntry(MacroAssembler* masm) { ++ Generate_JSEntryVariant(masm, StackFrame::ENTRY, ++ Builtins::kRunMicrotasksTrampoline); ++} ++ ++static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ++ bool is_construct) { ++ // ----------- S t a t e ------------- ++ // -- a1: new.target ++ // -- a2: function ++ // -- a3: receiver_pointer ++ // -- a4: argc ++ // -- a5: argv ++ // ----------------------------------- ++ ++ // Enter an internal frame. ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ ++ // Setup the context (we need to use the caller context from the isolate). ++ ExternalReference context_address = ExternalReference::Create( ++ IsolateAddressId::kContextAddress, masm->isolate()); ++ __ li(cp, context_address); ++ __ Ld(cp, MemOperand(cp)); ++ ++ // Push the function and the receiver onto the stack. ++ __ Push(a2, a3); ++ ++ // Check if we have enough stack space to push all arguments. ++ // Clobbers a0 and a3. ++ Generate_CheckStackOverflow(masm, a4, a0, a3); ++ ++ // Setup new.target, function and argc. ++ __ Move(a3, a1); ++ __ Move(a1, a2); ++ __ Move(a0, a4); ++ ++ // a0: argc ++ // a1: function ++ // a3: new.target ++ // a5: argv ++ ++ // Copy arguments to the stack in a loop. ++ // a3: argc ++ // a5: argv, i.e. points to first arg ++ Label loop, entry; ++ __ CalcScaledAddress(s1, a5, a4, kPointerSizeLog2); ++ __ Branch(&entry); ++ // s1 points past last arg. ++ __ bind(&loop); ++ __ Ld(s2, MemOperand(a5)); // Read next parameter. ++ __ Add64(a5, a5, kPointerSize); ++ __ Ld(s2, MemOperand(s2)); // Dereference handle. ++ __ push(s2); // Push parameter. ++ __ bind(&entry); ++ __ Branch(&loop, ne, a5, Operand(s1)); ++ ++ // a0: argc ++ // a1: function ++ // a3: new.target ++ ++ // Initialize all JavaScript callee-saved registers, since they will be seen ++ // by the garbage collector as part of handlers. ++ __ LoadRoot(a4, RootIndex::kUndefinedValue); ++ __ Move(a5, a4); ++ __ Move(s1, a4); ++ __ Move(s2, a4); ++ __ Move(s3, a4); ++ __ Move(s4, a4); ++ __ Move(s5, a4); ++ // s6 holds the root address. Do not clobber. ++ // s7 is cp. Do not init. ++ ++ // Invoke the code. ++ Handle builtin = is_construct ++ ? BUILTIN_CODE(masm->isolate(), Construct) ++ : masm->isolate()->builtins()->Call(); ++ __ Call(builtin, RelocInfo::CODE_TARGET); ++ ++ // Leave internal frame. ++ } ++ __ Jump(ra); ++} ++ ++void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { ++ Generate_JSEntryTrampolineHelper(masm, false); ++} ++ ++void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { ++ Generate_JSEntryTrampolineHelper(masm, true); ++} ++ ++void Builtins::Generate_RunMicrotasksTrampoline(MacroAssembler* masm) { ++ // a1: microtask_queue ++ __ Move(RunMicrotasksDescriptor::MicrotaskQueueRegister(), a1); ++ __ Jump(BUILTIN_CODE(masm->isolate(), RunMicrotasks), RelocInfo::CODE_TARGET); ++} ++ ++static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm, ++ Register optimized_code, ++ Register closure, ++ Register scratch1, ++ Register scratch2) { ++ // Store code entry in the closure. ++ __ Sd(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset)); ++ __ Move(scratch1, optimized_code); // Write barrier clobbers scratch1 below. ++ __ RecordWriteField(closure, JSFunction::kCodeOffset, scratch1, scratch2, ++ kRAHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, ++ OMIT_SMI_CHECK); ++} ++ ++static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { ++ Register args_count = scratch; ++ ++ // Get the arguments + receiver count. ++ __ Ld(args_count, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Lw(t0, FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); ++ ++ // Leave the frame (also dropping the register file). ++ __ LeaveFrame(StackFrame::INTERPRETED); ++ ++ // Drop receiver + arguments. ++ __ Add64(sp, sp, args_count); ++} ++ ++// Tail-call |function_id| if |smi_entry| == |marker| ++static void TailCallRuntimeIfMarkerEquals(MacroAssembler* masm, ++ Register smi_entry, ++ OptimizationMarker marker, ++ Runtime::FunctionId function_id) { ++ Label no_match; ++ __ Branch(&no_match, ne, smi_entry, Operand(Smi::FromEnum(marker))); ++ GenerateTailCallToReturnedCode(masm, function_id); ++ __ bind(&no_match); ++} ++ ++static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ++ Register optimized_code_entry, ++ Register scratch1, Register scratch2) { ++ // ----------- S t a t e ------------- ++ // -- a3 : new target (preserved for callee if needed, and caller) ++ // -- a1 : target function (preserved for callee if needed, and caller) ++ // ----------------------------------- ++ DCHECK(!AreAliased(optimized_code_entry, a1, a3, scratch1, scratch2)); ++ ++ Register closure = a1; ++ ++ // Check if the optimized code is marked for deopt. If it is, call the ++ // runtime to clear it. ++ Label found_deoptimized_code; ++ __ Ld(a5, ++ FieldMemOperand(optimized_code_entry, Code::kCodeDataContainerOffset)); ++ __ Lw(a5, FieldMemOperand(a5, CodeDataContainer::kKindSpecificFlagsOffset)); ++ __ And(a5, a5, Operand(1 << Code::kMarkedForDeoptimizationBit)); ++ __ Branch(&found_deoptimized_code, ne, a5, Operand(zero_reg)); ++ ++ // Optimized code is good, get it into the closure and link the closure into ++ // the optimized functions list, then tail call the optimized code. ++ // The feedback vector is no longer used, so re-use it as a scratch ++ // register. ++ ReplaceClosureCodeWithOptimizedCode(masm, optimized_code_entry, closure, ++ scratch1, scratch2); ++ ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Add64(a2, optimized_code_entry, ++ Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ ++ // Optimized code slot contains deoptimized code, evict it and re-enter the ++ // closure's code. ++ __ bind(&found_deoptimized_code); ++ GenerateTailCallToReturnedCode(masm, Runtime::kEvictOptimizedCodeSlot); ++} ++ ++static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector, ++ Register optimization_marker) { ++ // ----------- S t a t e ------------- ++ // -- a3 : new target (preserved for callee if needed, and caller) ++ // -- a1 : target function (preserved for callee if needed, and caller) ++ // -- feedback vector (preserved for caller if needed) ++ // -- optimization_marker : a Smi containing a non-zero optimization marker. ++ // ----------------------------------- ++ DCHECK(!AreAliased(feedback_vector, a1, a3, optimization_marker)); ++ ++ // TODO(v8:8394): The logging of first execution will break if ++ // feedback vectors are not allocated. We need to find a different way of ++ // logging these events if required. ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kLogFirstExecution, ++ Runtime::kFunctionFirstExecution); ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kCompileOptimized, ++ Runtime::kCompileOptimized_NotConcurrent); ++ TailCallRuntimeIfMarkerEquals(masm, optimization_marker, ++ OptimizationMarker::kCompileOptimizedConcurrent, ++ Runtime::kCompileOptimized_Concurrent); ++ ++ // Otherwise, the marker is InOptimizationQueue, so fall through hoping ++ // that an interrupt will eventually update the slot with optimized code. ++ if (FLAG_debug_code) { ++ __ Assert(eq, AbortReason::kExpectedOptimizationSentinel, ++ optimization_marker, ++ Operand(Smi::FromEnum(OptimizationMarker::kInOptimizationQueue))); ++ } ++} ++ ++// Advance the current bytecode offset. This simulates what all bytecode ++// handlers do upon completion of the underlying operation. Will bail out to a ++// label if the bytecode (without prefix) is a return bytecode. Will not advance ++// the bytecode offset if the current bytecode is a JumpLoop, instead just ++// re-executing the JumpLoop to jump to the correct bytecode. ++static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ++ Register bytecode_array, ++ Register bytecode_offset, ++ Register bytecode, Register scratch1, ++ Register scratch2, Register scratch3, ++ Label* if_return) { ++ Register bytecode_size_table = scratch1; ++ ++ // The bytecode offset value will be increased by one in wide and extra wide ++ // cases. In the case of having a wide or extra wide JumpLoop bytecode, we ++ // will restore the original bytecode. In order to simplify the code, we have ++ // a backup of it. ++ Register original_bytecode_offset = scratch3; ++ DCHECK(!AreAliased(bytecode_array, bytecode_offset, bytecode, ++ bytecode_size_table, original_bytecode_offset)); ++ __ Move(original_bytecode_offset, bytecode_offset); ++ __ li(bytecode_size_table, ExternalReference::bytecode_size_table_address()); ++ ++ // Check if the bytecode is a Wide or ExtraWide prefix bytecode. ++ Label process_bytecode, extra_wide; ++ STATIC_ASSERT(0 == static_cast(interpreter::Bytecode::kWide)); ++ STATIC_ASSERT(1 == static_cast(interpreter::Bytecode::kExtraWide)); ++ STATIC_ASSERT(2 == static_cast(interpreter::Bytecode::kDebugBreakWide)); ++ STATIC_ASSERT(3 == ++ static_cast(interpreter::Bytecode::kDebugBreakExtraWide)); ++ __ Branch(&process_bytecode, Ugreater, bytecode, Operand(3)); ++ __ And(scratch2, bytecode, Operand(1)); ++ __ Branch(&extra_wide, ne, scratch2, Operand(zero_reg)); ++ ++ // Load the next bytecode and update table to the wide scaled table. ++ __ Add64(bytecode_offset, bytecode_offset, Operand(1)); ++ __ Add64(scratch2, bytecode_array, bytecode_offset); ++ __ Lbu(bytecode, MemOperand(scratch2)); ++ __ Add64(bytecode_size_table, bytecode_size_table, ++ Operand(kIntSize * interpreter::Bytecodes::kBytecodeCount)); ++ __ Branch(&process_bytecode); ++ ++ __ bind(&extra_wide); ++ // Load the next bytecode and update table to the extra wide scaled table. ++ __ Add64(bytecode_offset, bytecode_offset, Operand(1)); ++ __ Add64(scratch2, bytecode_array, bytecode_offset); ++ __ Lbu(bytecode, MemOperand(scratch2)); ++ __ Add64(bytecode_size_table, bytecode_size_table, ++ Operand(2 * kIntSize * interpreter::Bytecodes::kBytecodeCount)); ++ ++ __ bind(&process_bytecode); ++ ++// Bailout to the return label if this is a return bytecode. ++#define JUMP_IF_EQUAL(NAME) \ ++ __ Branch(if_return, eq, bytecode, \ ++ Operand(static_cast(interpreter::Bytecode::k##NAME))); ++ RETURN_BYTECODE_LIST(JUMP_IF_EQUAL) ++#undef JUMP_IF_EQUAL ++ ++ // If this is a JumpLoop, re-execute it to perform the jump to the beginning ++ // of the loop. ++ Label end, not_jump_loop; ++ __ Branch(¬_jump_loop, ne, bytecode, ++ Operand(static_cast(interpreter::Bytecode::kJumpLoop))); ++ // We need to restore the original bytecode_offset since we might have ++ // increased it to skip the wide / extra-wide prefix bytecode. ++ __ Move(bytecode_offset, original_bytecode_offset); ++ __ Branch(&end); ++ ++ __ bind(¬_jump_loop); ++ // Otherwise, load the size of the current bytecode and advance the offset. ++ __ CalcScaledAddress(scratch2, bytecode_size_table, bytecode, 2); ++ __ Lw(scratch2, MemOperand(scratch2)); ++ __ Add64(bytecode_offset, bytecode_offset, scratch2); ++ ++ __ bind(&end); ++} ++ ++// Generate code for entering a JS function with the interpreter. ++// On entry to the function the receiver and arguments have been pushed on the ++// stack left to right. The actual argument count matches the formal parameter ++// count expected by the function. ++// ++// The live registers are: ++// o a1: the JS function object being called. ++// o a3: the incoming new target or generator object ++// o cp: our context ++// o fp: the caller's frame pointer ++// o sp: stack pointer ++// o ra: return address ++// ++// The function builds an interpreter frame. See InterpreterFrameConstants in ++// frames.h for its layout. ++void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ++ Register closure = a1; ++ Register feedback_vector = a2; ++ ++ // Get the bytecode array from the function object and load it into ++ // kInterpreterBytecodeArrayRegister. ++ __ Ld(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld(kInterpreterBytecodeArrayRegister, ++ FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset)); ++ GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, a4); ++ ++ // The bytecode array could have been flushed from the shared function info, ++ // if so, call into CompileLazy. ++ Label compile_lazy; ++ __ GetObjectType(kInterpreterBytecodeArrayRegister, a0, a0); ++ __ Branch(&compile_lazy, ne, a0, Operand(BYTECODE_ARRAY_TYPE)); ++ ++ // Load the feedback vector from the closure. ++ __ Ld(feedback_vector, ++ FieldMemOperand(closure, JSFunction::kFeedbackCellOffset)); ++ __ Ld(feedback_vector, FieldMemOperand(feedback_vector, Cell::kValueOffset)); ++ ++ Label push_stack_frame; ++ // Check if feedback vector is valid. If valid, check for optimized code ++ // and update invocation count. Otherwise, setup the stack frame. ++ __ Ld(a4, FieldMemOperand(feedback_vector, HeapObject::kMapOffset)); ++ __ Lhu(a4, FieldMemOperand(a4, Map::kInstanceTypeOffset)); ++ __ Branch(&push_stack_frame, ne, a4, Operand(FEEDBACK_VECTOR_TYPE)); ++ ++ // Read off the optimized code slot in the feedback vector, and if there ++ // is optimized code or an optimization marker, call that instead. ++ Register optimized_code_entry = a4; ++ __ Ld(optimized_code_entry, ++ FieldMemOperand(feedback_vector, ++ FeedbackVector::kOptimizedCodeWeakOrSmiOffset)); ++ ++ // Check if the optimized code slot is not empty. ++ Label optimized_code_slot_not_empty; ++ ++ __ Branch(&optimized_code_slot_not_empty, ne, optimized_code_entry, ++ Operand(Smi::FromEnum(OptimizationMarker::kNone))); ++ ++ Label not_optimized; ++ __ bind(¬_optimized); ++ ++ // Increment invocation count for the function. ++ __ Lw(a4, FieldMemOperand(feedback_vector, ++ FeedbackVector::kInvocationCountOffset)); ++ __ Add32(a4, a4, Operand(1)); ++ __ Sw(a4, FieldMemOperand(feedback_vector, ++ FeedbackVector::kInvocationCountOffset)); ++ ++ // Open a frame scope to indicate that there is a frame on the stack. The ++ // MANUAL indicates that the scope shouldn't actually generate code to set up ++ // the frame (that is done below). ++ __ bind(&push_stack_frame); ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ PushStandardFrame(closure); ++ ++ // Reset code age and the OSR arming. The OSR field and BytecodeAgeOffset are ++ // 8-bit fields next to each other, so we could just optimize by writing a ++ // 16-bit. These static asserts guard our assumption is valid. ++ STATIC_ASSERT(BytecodeArray::kBytecodeAgeOffset == ++ BytecodeArray::kOsrNestingLevelOffset + kCharSize); ++ STATIC_ASSERT(BytecodeArray::kNoAgeBytecodeAge == 0); ++ __ Sh(zero_reg, FieldMemOperand(kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kOsrNestingLevelOffset)); ++ ++ // Load initial bytecode offset. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ ++ // Push bytecode array and Smi tagged bytecode array offset. ++ __ SmiTag(a4, kInterpreterBytecodeOffsetRegister); ++ __ Push(kInterpreterBytecodeArrayRegister, a4); ++ ++ // Allocate the local and temporary register file on the stack. ++ Label stack_overflow; ++ { ++ // Load frame size (word) from the BytecodeArray object. ++ __ Lw(a4, FieldMemOperand(kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kFrameSizeOffset)); ++ ++ // Do a stack check to ensure we don't go over the limit. ++ __ Sub64(a5, sp, Operand(a4)); ++ LoadStackLimit(masm, a2, StackLimitKind::kRealStackLimit); ++ __ Branch(&stack_overflow, Uless, a5, Operand(a2)); ++ ++ // If ok, push undefined as the initial value for all register file entries. ++ Label loop_header; ++ Label loop_check; ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ Branch(&loop_check); ++ __ bind(&loop_header); ++ // TODO(rmcilroy): Consider doing more than one push per loop iteration. ++ __ push(a5); ++ // Continue loop if not done. ++ __ bind(&loop_check); ++ __ Sub64(a4, a4, Operand(kPointerSize)); ++ __ Branch(&loop_header, ge, a4, Operand(zero_reg)); ++ } ++ ++ // If the bytecode array has a valid incoming new target or generator object ++ // register, initialize it with incoming value which was passed in r3. ++ Label no_incoming_new_target_or_generator_register; ++ __ Lw(a5, FieldMemOperand( ++ kInterpreterBytecodeArrayRegister, ++ BytecodeArray::kIncomingNewTargetOrGeneratorRegisterOffset)); ++ __ Branch(&no_incoming_new_target_or_generator_register, eq, a5, ++ Operand(zero_reg)); ++ __ CalcScaledAddress(a5, fp, a5, kPointerSizeLog2); ++ __ Sd(a3, MemOperand(a5)); ++ __ bind(&no_incoming_new_target_or_generator_register); ++ ++ // Perform interrupt stack check. ++ // TODO(solanes): Merge with the real stack limit check above. ++ Label stack_check_interrupt, after_stack_check_interrupt; ++ LoadStackLimit(masm, a5, StackLimitKind::kInterruptStackLimit); ++ __ Branch(&stack_check_interrupt, Uless, sp, Operand(a5)); ++ __ bind(&after_stack_check_interrupt); ++ ++ // Load accumulator as undefined. ++ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); ++ ++ // Load the dispatch table into a register and dispatch to the bytecode ++ // handler at the current bytecode offset. ++ Label do_dispatch; ++ __ bind(&do_dispatch); ++ __ li(kInterpreterDispatchTableRegister, ++ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); ++ __ Add64(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Lbu(a7, MemOperand(a1)); ++ __ CalcScaledAddress(kScratchReg, kInterpreterDispatchTableRegister, a7, ++ kPointerSizeLog2); ++ __ Ld(kJavaScriptCallCodeStartRegister, MemOperand(kScratchReg)); ++ __ Call(kJavaScriptCallCodeStartRegister); ++ masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); ++ ++ // Any returns to the entry trampoline are either due to the return bytecode ++ // or the interpreter tail calling a builtin and then a dispatch. ++ ++ // Get bytecode array and bytecode offset from the stack frame. ++ __ Ld(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Ld(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister); ++ ++ // Either return, or advance to the next bytecode and dispatch. ++ Label do_return; ++ __ Add64(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Lbu(a1, MemOperand(a1)); ++ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister, a1, a2, a3, ++ a4, &do_return); ++ __ Branch(&do_dispatch); ++ ++ __ bind(&do_return); ++ // The return value is in a0. ++ LeaveInterpreterFrame(masm, t0); ++ __ Jump(ra); ++ ++ __ bind(&stack_check_interrupt); ++ // Modify the bytecode offset in the stack to be kFunctionEntryBytecodeOffset ++ // for the call to the StackGuard. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(Smi::FromInt(BytecodeArray::kHeaderSize - kHeapObjectTag + ++ kFunctionEntryBytecodeOffset))); ++ __ Sd(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ CallRuntime(Runtime::kStackGuard); ++ ++ // After the call, restore the bytecode array, bytecode offset and accumulator ++ // registers again. Also, restore the bytecode offset in the stack to its ++ // previous value. ++ __ Ld(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue); ++ ++ __ SmiTag(a5, kInterpreterBytecodeOffsetRegister); ++ __ Sd(a5, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ __ Branch(&after_stack_check_interrupt); ++ ++ __ bind(&optimized_code_slot_not_empty); ++ Label maybe_has_optimized_code; ++ // Check if optimized code marker is actually a weak reference to the ++ // optimized code as opposed to an optimization marker. ++ __ JumpIfNotSmi(optimized_code_entry, &maybe_has_optimized_code); ++ MaybeOptimizeCode(masm, feedback_vector, optimized_code_entry); ++ // Fall through if there's no runnable optimized code. ++ __ Branch(¬_optimized); ++ ++ __ bind(&maybe_has_optimized_code); ++ // Load code entry from the weak reference, if it was cleared, resume ++ // execution of unoptimized code. ++ __ LoadWeakValue(optimized_code_entry, optimized_code_entry, ¬_optimized); ++ TailCallOptimizedCodeSlot(masm, optimized_code_entry, t4, a5); ++ ++ __ bind(&compile_lazy); ++ GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); ++ // Unreachable code. ++ __ break_(0xCC); ++ ++ __ bind(&stack_overflow); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++} ++ ++static void Generate_InterpreterPushArgs(MacroAssembler* masm, ++ Register num_args, Register index, ++ Register scratch, Register scratch2) { ++ // Find the address of the last argument. ++ __ Move(scratch2, num_args); ++ __ Sll64(scratch2, scratch2, kPointerSizeLog2); ++ __ Sub64(scratch2, index, Operand(scratch2)); ++ ++ // Push the arguments. ++ Label loop_header, loop_check; ++ __ Branch(&loop_check); ++ __ bind(&loop_header); ++ __ Ld(scratch, MemOperand(index)); ++ __ Add64(index, index, Operand(-kPointerSize)); ++ __ push(scratch); ++ __ bind(&loop_check); ++ __ Branch(&loop_header, Ugreater, index, Operand(scratch2)); ++} ++ ++// static ++void Builtins::Generate_InterpreterPushArgsThenCallImpl( ++ MacroAssembler* masm, ConvertReceiverMode receiver_mode, ++ InterpreterPushArgsMode mode) { ++ DCHECK(mode != InterpreterPushArgsMode::kArrayFunction); ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a2 : the address of the first argument to be pushed. Subsequent ++ // arguments should be consecutive above this, in the same order as ++ // they are to be pushed onto the stack. ++ // -- a1 : the target to call (can be any Object). ++ // ----------------------------------- ++ Label stack_overflow; ++ ++ __ Add64(a3, a0, Operand(1)); // Add one for receiver. ++ ++ // Push "undefined" as the receiver arg if we need to. ++ if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) { ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ Sub64(a3, a3, Operand(1)); // Subtract one for receiver. ++ } ++ ++ Generate_StackOverflowCheck(masm, a3, a4, t0, &stack_overflow); ++ ++ // This function modifies a2, t0 and a4. ++ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0); ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Pop(a2); // Pass the spread in a register ++ __ Sub64(a0, a0, Operand(1)); // Subtract one for spread ++ } ++ ++ // Call the target. ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithSpread), ++ RelocInfo::CODE_TARGET); ++ } else { ++ __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny), ++ RelocInfo::CODE_TARGET); ++ } ++ ++ __ bind(&stack_overflow); ++ { ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ } ++} ++ ++// static ++void Builtins::Generate_InterpreterPushArgsThenConstructImpl( ++ MacroAssembler* masm, InterpreterPushArgsMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argument count (not including receiver) ++ // -- a3 : new target ++ // -- a1 : constructor to call ++ // -- a2 : allocation site feedback if available, undefined otherwise. ++ // -- a4 : address of the first argument ++ // ----------------------------------- ++ Label stack_overflow; ++ ++ // Push a slot for the receiver. ++ __ push(zero_reg); ++ ++ Generate_StackOverflowCheck(masm, a0, a5, t0, &stack_overflow); ++ ++ // This function modifies t0, a4 and a5. ++ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0); ++ ++ if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ __ Pop(a2); // Pass the spread in a register ++ __ Sub64(a0, a0, Operand(1)); // Subtract one for spread ++ } else { ++ __ AssertUndefinedOrAllocationSite(a2, t0); ++ } ++ ++ if (mode == InterpreterPushArgsMode::kArrayFunction) { ++ __ AssertFunction(a1); ++ ++ // Tail call to the function-specific construct stub (still in the caller ++ // context at this point). ++ __ Jump(BUILTIN_CODE(masm->isolate(), ArrayConstructorImpl), ++ RelocInfo::CODE_TARGET); ++ } else if (mode == InterpreterPushArgsMode::kWithFinalSpread) { ++ // Call the constructor with a0, a1, and a3 unmodified. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithSpread), ++ RelocInfo::CODE_TARGET); ++ } else { ++ DCHECK_EQ(InterpreterPushArgsMode::kOther, mode); ++ // Call the constructor with a0, a1, and a3 unmodified. ++ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); ++ } ++ ++ __ bind(&stack_overflow); ++ { ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ // Unreachable code. ++ __ break_(0xCC); ++ } ++} ++ ++static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { ++ // Set the return address to the correct point in the interpreter entry ++ // trampoline. ++ Label builtin_trampoline, trampoline_loaded; ++ Smi interpreter_entry_return_pc_offset( ++ masm->isolate()->heap()->interpreter_entry_return_pc_offset()); ++ DCHECK_NE(interpreter_entry_return_pc_offset, Smi::zero()); ++ ++ // If the SFI function_data is an InterpreterData, the function will have a ++ // custom copy of the interpreter entry trampoline for profiling. If so, ++ // get the custom trampoline, otherwise grab the entry address of the global ++ // trampoline. ++ __ Ld(t0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ Ld(t0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); ++ __ Ld(t0, FieldMemOperand(t0, SharedFunctionInfo::kFunctionDataOffset)); ++ __ GetObjectType(t0, kInterpreterDispatchTableRegister, ++ kInterpreterDispatchTableRegister); ++ __ Branch(&builtin_trampoline, ne, kInterpreterDispatchTableRegister, ++ Operand(INTERPRETER_DATA_TYPE)); ++ ++ __ Ld(t0, FieldMemOperand(t0, InterpreterData::kInterpreterTrampolineOffset)); ++ __ Add64(t0, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Branch(&trampoline_loaded); ++ ++ __ bind(&builtin_trampoline); ++ __ li(t0, ExternalReference:: ++ address_of_interpreter_entry_trampoline_instruction_start( ++ masm->isolate())); ++ __ Ld(t0, MemOperand(t0)); ++ ++ __ bind(&trampoline_loaded); ++ __ Add64(ra, t0, Operand(interpreter_entry_return_pc_offset.value())); ++ ++ // Initialize the dispatch table register. ++ __ li(kInterpreterDispatchTableRegister, ++ ExternalReference::interpreter_dispatch_table_address(masm->isolate())); ++ ++ // Get the bytecode array pointer from the frame. ++ __ Ld(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ ++ if (FLAG_debug_code) { ++ // Check function data field is actually a BytecodeArray object. ++ __ SmiTst(kInterpreterBytecodeArrayRegister, kScratchReg); ++ __ Assert(ne, ++ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, ++ kScratchReg, Operand(zero_reg)); ++ __ GetObjectType(kInterpreterBytecodeArrayRegister, a1, a1); ++ __ Assert(eq, ++ AbortReason::kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, ++ a1, Operand(BYTECODE_ARRAY_TYPE)); ++ } ++ ++ // Get the target bytecode offset from the frame. ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ if (FLAG_debug_code) { ++ Label okay; ++ __ Branch(&okay, ge, kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ // Unreachable code. ++ __ break_(0xCC); ++ __ bind(&okay); ++ } ++ ++ // Dispatch to the target bytecode. ++ __ Add64(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Lbu(a7, MemOperand(a1)); ++ __ CalcScaledAddress(a1, kInterpreterDispatchTableRegister, a7, ++ kPointerSizeLog2); ++ __ Ld(kJavaScriptCallCodeStartRegister, MemOperand(a1)); ++ __ Jump(kJavaScriptCallCodeStartRegister); ++} ++ ++void Builtins::Generate_InterpreterEnterBytecodeAdvance(MacroAssembler* masm) { ++ // Advance the current bytecode offset stored within the given interpreter ++ // stack frame. This simulates what all bytecode handlers do upon completion ++ // of the underlying operation. ++ __ Ld(kInterpreterBytecodeArrayRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); ++ __ Ld(kInterpreterBytecodeOffsetRegister, ++ MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ __ SmiUntag(kInterpreterBytecodeOffsetRegister); ++ ++ Label enter_bytecode, function_entry_bytecode; ++ __ Branch(&function_entry_bytecode, eq, kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag + ++ kFunctionEntryBytecodeOffset)); ++ ++ // Load the current bytecode. ++ __ Add64(a1, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister); ++ __ Lbu(a1, MemOperand(a1)); ++ ++ // Advance to the next bytecode. ++ Label if_return; ++ AdvanceBytecodeOffsetOrReturn(masm, kInterpreterBytecodeArrayRegister, ++ kInterpreterBytecodeOffsetRegister, a1, a2, a3, ++ a4, &if_return); ++ ++ __ bind(&enter_bytecode); ++ // Convert new bytecode offset to a Smi and save in the stackframe. ++ __ SmiTag(a2, kInterpreterBytecodeOffsetRegister); ++ __ Sd(a2, MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); ++ ++ Generate_InterpreterEnterBytecode(masm); ++ ++ __ bind(&function_entry_bytecode); ++ // If the code deoptimizes during the implicit function entry stack interrupt ++ // check, it will have a bailout ID of kFunctionEntryBytecodeOffset, which is ++ // not a valid bytecode offset. Detect this case and advance to the first ++ // actual bytecode. ++ __ li(kInterpreterBytecodeOffsetRegister, ++ Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); ++ __ Branch(&enter_bytecode); ++ ++ // We should never take the if_return path. ++ __ bind(&if_return); ++ __ Abort(AbortReason::kInvalidBytecodeAdvance); ++} ++ ++void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { ++ Generate_InterpreterEnterBytecode(masm); ++} ++ ++namespace { ++void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, ++ bool java_script_builtin, ++ bool with_result) { ++ const RegisterConfiguration* config(RegisterConfiguration::Default()); ++ int allocatable_register_count = config->num_allocatable_general_registers(); ++ if (with_result) { ++ // Overwrite the hole inserted by the deoptimizer with the return value from ++ // the LAZY deopt point. ++ __ Sd(a0, ++ MemOperand( ++ sp, config->num_allocatable_general_registers() * kPointerSize + ++ BuiltinContinuationFrameConstants::kFixedFrameSize)); ++ } ++ for (int i = allocatable_register_count - 1; i >= 0; --i) { ++ int code = config->GetAllocatableGeneralCode(i); ++ __ Pop(Register::from_code(code)); ++ if (java_script_builtin && code == kJavaScriptCallArgCountRegister.code()) { ++ __ SmiUntag(Register::from_code(code)); ++ } ++ } ++ __ Ld(fp, MemOperand( ++ sp, BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); ++ // Load builtin index (stored as a Smi) and use it to get the builtin start ++ // address from the builtins table. ++ __ Pop(t0); ++ __ Add64(sp, sp, ++ Operand(BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); ++ __ Pop(ra); ++ __ LoadEntryFromBuiltinIndex(t0); ++ __ Jump(t0); ++} ++} // namespace ++ ++void Builtins::Generate_ContinueToCodeStubBuiltin(MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, false, false); ++} ++ ++void Builtins::Generate_ContinueToCodeStubBuiltinWithResult( ++ MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, false, true); ++} ++ ++void Builtins::Generate_ContinueToJavaScriptBuiltin(MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, true, false); ++} ++ ++void Builtins::Generate_ContinueToJavaScriptBuiltinWithResult( ++ MacroAssembler* masm) { ++ Generate_ContinueToBuiltinHelper(masm, true, true); ++} ++ ++void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kNotifyDeoptimized); ++ } ++ ++ DCHECK_EQ(kInterpreterAccumulatorRegister.code(), a0.code()); ++ __ Ld(a0, MemOperand(sp, 0 * kPointerSize)); ++ __ Add64(sp, sp, Operand(1 * kPointerSize)); // Remove state. ++ __ Ret(); ++} ++ ++void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kCompileForOnStackReplacement); ++ } ++ ++ // If the code object is null, just return to the caller. ++ __ Ret(eq, a0, Operand(Smi::zero())); ++ ++ // Drop the handler frame that is be sitting on top of the actual ++ // JavaScript frame. This is the case then OSR is triggered from bytecode. ++ __ LeaveFrame(StackFrame::STUB); ++ ++ // Load deoptimization data from the code object. ++ // = [#deoptimization_data_offset] ++ __ Ld(a1, MemOperand(a0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); ++ ++ // Load the OSR entrypoint offset from the deoptimization data. ++ // = [#header_size + #osr_pc_offset] ++ __ SmiUntag(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( ++ DeoptimizationData::kOsrPcOffsetIndex) - ++ kHeapObjectTag)); ++ ++ // Compute the target address = code_obj + header_size + osr_offset ++ // = + #header_size + ++ __ Add64(a0, a0, a1); ++ __ Add64(ra, a0, Code::kHeaderSize - kHeapObjectTag); ++ // And "return" to the OSR entry point of the function. ++ __ Ret(); ++} ++ ++// static ++void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : argArray ++ // -- sp[4] : thisArg ++ // -- sp[8] : receiver ++ // ----------------------------------- ++ ++ Register argc = a0; ++ Register arg_array = a2; ++ Register receiver = a1; ++ Register this_arg = a5; ++ Register undefined_value = a3; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load receiver into a1, argArray into a2 (if present), remove all ++ // arguments from the stack (including the receiver), and push thisArg (if ++ // present) instead. ++ { ++ // Claim (2 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ ++ __ Sub64(sp, sp, Operand(2 * kPointerSize)); ++ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); ++ __ Pop(this_arg, arg_array); // Overwrite argc ++ ++ Label done0, done1; ++ __ Branch(&done0, ne, argc, Operand(zero_reg)); ++ __ Move(arg_array, undefined_value); // if argc == 0 ++ __ Move(this_arg, undefined_value); // if argc == 0 ++ __ bind(&done0); // else (i.e., argc > 0) ++ ++ __ Branch(&done1, ne, argc, Operand(1)); ++ __ Move(arg_array, undefined_value); // if argc == 1 ++ __ bind(&done1); // else (i.e., argc > 1) ++ ++ __ Ld(receiver, MemOperand(sp)); ++ __ Sd(this_arg, MemOperand(sp)); ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argArray ++ // -- a1 : receiver ++ // -- a3 : undefined root value ++ // -- sp[0] : thisArg ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for callable receiver here, ++ // since that's the first thing the Call/CallWithArrayLike builtins ++ // will do. ++ ++ // 3. Tail call with no arguments if argArray is null or undefined. ++ Label no_arguments; ++ __ JumpIfRoot(arg_array, RootIndex::kNullValue, &no_arguments); ++ __ Branch(&no_arguments, eq, arg_array, Operand(undefined_value)); ++ ++ // 4a. Apply the receiver to the given argArray. ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), ++ RelocInfo::CODE_TARGET); ++ ++ // 4b. The argArray is either null or undefined, so we tail call without any ++ // arguments to the receiver. ++ __ bind(&no_arguments); ++ { ++ __ Move(a0, zero_reg); ++ DCHECK(receiver == a1); ++ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); ++ } ++} ++ ++// static ++void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { ++ // 1. Make sure we have at least one argument. ++ // a0: actual number of arguments ++ { ++ Label done; ++ __ Branch(&done, ne, a0, Operand(zero_reg)); ++ __ PushRoot(RootIndex::kUndefinedValue); ++ __ Add64(a0, a0, Operand(1)); ++ __ bind(&done); ++ } ++ ++ // 2. Get the function to call (passed as receiver) from the stack. ++ // a0: actual number of arguments ++ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); ++ __ Ld(a1, MemOperand(kScratchReg)); ++ ++ // 3. Shift arguments and return address one slot down on the stack ++ // (overwriting the original receiver). Adjust argument count to make ++ // the original first argument the new receiver. ++ // a0: actual number of arguments ++ // a1: function ++ { ++ Label loop; ++ // Calculate the copy start address (destination). Copy end address is sp. ++ __ CalcScaledAddress(a2, sp, a0, kPointerSizeLog2); ++ ++ __ bind(&loop); ++ __ Ld(kScratchReg, MemOperand(a2, -kPointerSize)); ++ __ Sd(kScratchReg, MemOperand(a2)); ++ __ Sub64(a2, a2, Operand(kPointerSize)); ++ __ Branch(&loop, ne, a2, Operand(sp)); ++ // Adjust the actual number of arguments and remove the top element ++ // (which is a copy of the last argument). ++ __ Sub64(a0, a0, Operand(1)); ++ __ Pop(); ++ } ++ ++ // 4. Call the callable. ++ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ReflectApply(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : argumentsList (if argc ==3) ++ // -- sp[4] : thisArgument (if argc >=2) ++ // -- sp[8] : target (if argc >=1) ++ // -- sp[12] : receiver ++ // ----------------------------------- ++ ++ Register argc = a0; ++ Register arguments_list = a2; ++ Register target = a1; ++ Register this_argument = a5; ++ Register undefined_value = a3; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load target into a1 (if present), argumentsList into a2 (if present), ++ // remove all arguments from the stack (including the receiver), and push ++ // thisArgument (if present) instead. ++ { ++ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ ++ __ Sub64(sp, sp, Operand(3 * kPointerSize)); ++ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); ++ __ Pop(target, this_argument, arguments_list); ++ ++ Label done0, done1, done2; ++ __ Branch(&done0, ne, argc, Operand(zero_reg)); ++ __ Move(arguments_list, undefined_value); // if argc == 0 ++ __ Move(this_argument, undefined_value); // if argc == 0 ++ __ Move(target, undefined_value); // if argc == 0 ++ __ bind(&done0); // argc != 0 ++ ++ __ Branch(&done1, ne, argc, Operand(1)); ++ __ Move(arguments_list, undefined_value); // if argc == 1 ++ __ Move(this_argument, undefined_value); // if argc == 1 ++ __ bind(&done1); // argc > 1 ++ ++ __ Branch(&done2, ne, argc, Operand(2)); ++ __ Move(arguments_list, undefined_value); // if argc == 2 ++ __ bind(&done2); // argc > 2 ++ ++ __ Sd(this_argument, MemOperand(sp, 0)); // Overwrite receiver ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argumentsList ++ // -- a1 : target ++ // -- a3 : undefined root value ++ // -- sp[0] : thisArgument ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for callable target here, ++ // since that's the first thing the Call/CallWithArrayLike builtins ++ // will do. ++ ++ // 3. Apply the target to the given argumentsList. ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallWithArrayLike), ++ RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : argc ++ // -- sp[0] : new.target (optional) (dummy value if argc <= 2) ++ // -- sp[4] : argumentsList (dummy value if argc <= 1) ++ // -- sp[8] : target (dummy value if argc == 0) ++ // -- sp[12] : receiver ++ // ----------------------------------- ++ Register argc = a0; ++ Register arguments_list = a2; ++ Register target = a1; ++ Register new_target = a3; ++ Register undefined_value = a4; ++ ++ __ LoadRoot(undefined_value, RootIndex::kUndefinedValue); ++ ++ // 1. Load target into a1 (if present), argumentsList into a2 (if present), ++ // new.target into a3 (if present, otherwise use target), remove all ++ // arguments from the stack (including the receiver), and push thisArgument ++ // (if present) instead. ++ { ++ // Claim (3 - argc) dummy arguments form the stack, to put the stack in a ++ // consistent state for a simple pop operation. ++ __ Sub64(sp, sp, Operand(3 * kPointerSize)); ++ __ CalcScaledAddress(sp, sp, argc, kPointerSizeLog2); ++ __ Pop(target, arguments_list, new_target); ++ ++ Label done0, done1, done2; ++ __ Branch(&done0, ne, argc, Operand(zero_reg)); ++ __ Move(arguments_list, undefined_value); // if argc == 0 ++ __ Move(new_target, undefined_value); // if argc == 0 ++ __ Move(target, undefined_value); // if argc == 0 ++ __ bind(&done0); ++ ++ __ Branch(&done1, ne, argc, Operand(1)); ++ __ Move(arguments_list, undefined_value); // if argc == 1 ++ __ Move(new_target, target); // if argc == 1 ++ __ bind(&done1); ++ ++ __ Branch(&done2, ne, argc, Operand(2)); ++ __ Move(new_target, target); // if argc == 2 ++ __ bind(&done2); ++ ++ __ Sd(undefined_value, MemOperand(sp, 0)); // Overwrite receiver ++ } ++ ++ // ----------- S t a t e ------------- ++ // -- a2 : argumentsList ++ // -- a1 : target ++ // -- a3 : new.target ++ // -- sp[0] : receiver (undefined) ++ // ----------------------------------- ++ ++ // 2. We don't need to check explicitly for constructor target here, ++ // since that's the first thing the Construct/ConstructWithArrayLike ++ // builtins will do. ++ ++ // 3. We don't need to check explicitly for constructor new.target here, ++ // since that's the second thing the Construct/ConstructWithArrayLike ++ // builtins will do. ++ ++ // 4. Construct the target with the given new.target and argumentsList. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructWithArrayLike), ++ RelocInfo::CODE_TARGET); ++} ++ ++static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { ++ __ SmiTag(a0); ++ __ li(a4, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); ++ __ Push(Smi::zero()); // Padding. ++ __ Add64(fp, sp, ++ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp)); ++} ++ ++static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : result being passed through ++ // ----------------------------------- ++ // Get the number of arguments passed (as a smi), tear down the frame and ++ // then tear down the parameters. ++ __ Ld(a1, MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ __ Move(sp, fp); ++ __ MultiPop(fp.bit() | ra.bit()); ++ __ SmiScale(a4, a1, kPointerSizeLog2); ++ __ Add64(sp, sp, a4); ++ // Adjust for the receiver. ++ __ Add64(sp, sp, Operand(kPointerSize)); ++} ++ ++// static ++void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm, ++ Handle code) { ++ // ----------- S t a t e ------------- ++ // -- a1 : target ++ // -- a0 : number of parameters on the stack (not including the receiver) ++ // -- a2 : arguments list (a FixedArray) ++ // -- a4 : len (number of elements to push from args) ++ // -- a3 : new.target (for [[Construct]]) ++ // ----------------------------------- ++ if (masm->emit_debug_code()) { ++ // Allow a2 to be a FixedArray, or a FixedDoubleArray if a4 == 0. ++ Label ok, fail; ++ __ AssertNotSmi(a2); ++ __ GetObjectType(a2, t5, t5); ++ __ Branch(&ok, eq, t5, Operand(FIXED_ARRAY_TYPE)); ++ __ Branch(&fail, ne, t5, Operand(FIXED_DOUBLE_ARRAY_TYPE)); ++ __ Branch(&ok, eq, a4, Operand(zero_reg)); ++ // Fall through. ++ __ bind(&fail); ++ __ Abort(AbortReason::kOperandIsNotAFixedArray); ++ ++ __ bind(&ok); ++ } ++ ++ Register args = a2; ++ Register len = a4; ++ ++ // Check for stack overflow. ++ Label stack_overflow; ++ Generate_StackOverflowCheck(masm, len, kScratchReg, a5, &stack_overflow); ++ ++ // Push arguments onto the stack (thisArgument is already on the stack). ++ { ++ Label done, push, loop; ++ Register src = a6; ++ Register scratch = len; ++ __ Add64(src, args, FixedArray::kHeaderSize - kHeapObjectTag); ++ __ Add64(a0, a0, len); // The 'len' argument for Call() or Construct(). ++ __ Branch(&done, eq, len, Operand(zero_reg)); ++ __ Sll64(scratch, len, kPointerSizeLog2); ++ __ Sub64(scratch, sp, Operand(scratch)); ++ __ LoadRoot(t1, RootIndex::kTheHoleValue); ++ __ bind(&loop); ++ __ Ld(a5, MemOperand(src)); ++ __ Branch(&push, ne, a5, Operand(t1)); ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ bind(&push); ++ __ Add64(src, src, kPointerSize); ++ __ Push(a5); ++ __ Branch(&loop, ne, scratch, Operand(sp)); ++ __ bind(&done); ++ } ++ ++ // Tail-call to the actual Call or Construct builtin. ++ __ Jump(code, RelocInfo::CODE_TARGET); ++ ++ __ bind(&stack_overflow); ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++} ++ ++// static ++void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm, ++ CallOrConstructMode mode, ++ Handle code) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a3 : the new.target (for [[Construct]] calls) ++ // -- a1 : the target to call (can be any Object) ++ // -- a2 : start index (to support rest parameters) ++ // ----------------------------------- ++ ++ // Check if new.target has a [[Construct]] internal method. ++ if (mode == CallOrConstructMode::kConstruct) { ++ Label new_target_constructor, new_target_not_constructor; ++ __ JumpIfSmi(a3, &new_target_not_constructor); ++ __ Ld(t1, FieldMemOperand(a3, HeapObject::kMapOffset)); ++ __ Lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t1, t1, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ __ Branch(&new_target_constructor, ne, t1, Operand(zero_reg)); ++ __ bind(&new_target_not_constructor); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ Push(a3); ++ __ CallRuntime(Runtime::kThrowNotConstructor); ++ } ++ __ bind(&new_target_constructor); ++ } ++ ++ // Check if we have an arguments adaptor frame below the function frame. ++ Label arguments_adaptor, arguments_done; ++ __ Ld(a6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ __ Ld(a7, MemOperand(a6, CommonFrameConstants::kContextOrFrameTypeOffset)); ++ __ Branch(&arguments_adaptor, eq, a7, ++ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ { ++ __ Ld(a7, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ Ld(a7, FieldMemOperand(a7, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lhu(a7, FieldMemOperand( ++ a7, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ Move(a6, fp); ++ } ++ __ Branch(&arguments_done); ++ __ bind(&arguments_adaptor); ++ { ++ // Just get the length from the ArgumentsAdaptorFrame. ++ __ SmiUntag(a7, ++ MemOperand(a6, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ } ++ __ bind(&arguments_done); ++ ++ Label stack_done, stack_overflow; ++ __ Sub32(a7, a7, a2); ++ __ Branch(&stack_done, le, a7, Operand(zero_reg)); ++ { ++ // Check for stack overflow. ++ Generate_StackOverflowCheck(masm, a7, a4, a5, &stack_overflow); ++ ++ // Forward the arguments from the caller frame. ++ { ++ Label loop; ++ __ Add64(a0, a0, a7); ++ __ bind(&loop); ++ { ++ __ CalcScaledAddress(kScratchReg, a6, a7, kPointerSizeLog2); ++ __ Ld(kScratchReg, MemOperand(kScratchReg, 1 * kPointerSize)); ++ __ push(kScratchReg); ++ __ Sub32(a7, a7, Operand(1)); ++ __ Branch(&loop, ne, a7, Operand(zero_reg)); ++ } ++ } ++ } ++ __ Branch(&stack_done); ++ __ bind(&stack_overflow); ++ __ TailCallRuntime(Runtime::kThrowStackOverflow); ++ __ bind(&stack_done); ++ ++ // Tail-call to the {code} handler. ++ __ Jump(code, RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_CallFunction(MacroAssembler* masm, ++ ConvertReceiverMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // ----------------------------------- ++ __ AssertFunction(a1); ++ ++ // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) ++ // Check that function is not a "classConstructor". ++ Label class_constructor; ++ __ Ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lwu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); ++ __ And(kScratchReg, a3, ++ Operand(SharedFunctionInfo::IsClassConstructorBit::kMask)); ++ __ Branch(&class_constructor, ne, kScratchReg, Operand(zero_reg)); ++ ++ // Enter the context of the function; ToObject has to run in the function ++ // context, and we also need to take the global proxy from the function ++ // context in case of conversion. ++ __ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ // We need to convert the receiver for non-native sloppy mode functions. ++ Label done_convert; ++ __ Lwu(a3, FieldMemOperand(a2, SharedFunctionInfo::kFlagsOffset)); ++ __ And(kScratchReg, a3, ++ Operand(SharedFunctionInfo::IsNativeBit::kMask | ++ SharedFunctionInfo::IsStrictBit::kMask)); ++ __ Branch(&done_convert, ne, kScratchReg, Operand(zero_reg)); ++ { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // -- a2 : the shared function info. ++ // -- cp : the function context. ++ // ----------------------------------- ++ ++ if (mode == ConvertReceiverMode::kNullOrUndefined) { ++ // Patch receiver to global proxy. ++ __ LoadGlobalProxy(a3); ++ } else { ++ Label convert_to_object, convert_receiver; ++ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); ++ __ Ld(a3, MemOperand(kScratchReg)); ++ __ JumpIfSmi(a3, &convert_to_object); ++ STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); ++ __ GetObjectType(a3, a4, a4); ++ __ Branch(&done_convert, Ugreater_equal, a4, ++ Operand(FIRST_JS_RECEIVER_TYPE)); ++ if (mode != ConvertReceiverMode::kNotNullOrUndefined) { ++ Label convert_global_proxy; ++ __ JumpIfRoot(a3, RootIndex::kUndefinedValue, &convert_global_proxy); ++ __ JumpIfNotRoot(a3, RootIndex::kNullValue, &convert_to_object); ++ __ bind(&convert_global_proxy); ++ { ++ // Patch receiver to global proxy. ++ __ LoadGlobalProxy(a3); ++ } ++ __ Branch(&convert_receiver); ++ } ++ __ bind(&convert_to_object); ++ { ++ // Convert receiver using ToObject. ++ // TODO(bmeurer): Inline the allocation here to avoid building the frame ++ // in the fast case? (fall back to AllocateInNewSpace?) ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ SmiTag(a0); ++ __ Push(a0, a1); ++ __ Move(a0, a3); ++ __ Push(cp); ++ __ Call(BUILTIN_CODE(masm->isolate(), ToObject), ++ RelocInfo::CODE_TARGET); ++ __ Pop(cp); ++ __ Move(a3, a0); ++ __ Pop(a0, a1); ++ __ SmiUntag(a0); ++ } ++ __ Ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ bind(&convert_receiver); ++ } ++ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); ++ __ Sd(a3, MemOperand(kScratchReg)); ++ } ++ __ bind(&done_convert); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSFunction) ++ // -- a2 : the shared function info. ++ // -- cp : the function context. ++ // ----------------------------------- ++ ++ __ Lhu(a2, ++ FieldMemOperand(a2, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ InvokeFunctionCode(a1, no_reg, a2, a0, JUMP_FUNCTION); ++ ++ // The function is a "classConstructor", need to raise an exception. ++ __ bind(&class_constructor); ++ { ++ FrameScope frame(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowConstructorNonCallableError); ++ } ++} ++ ++// static ++void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // ----------------------------------- ++ __ AssertBoundFunction(a1); ++ ++ // Patch the receiver to [[BoundThis]]. ++ { ++ __ Ld(kScratchReg, FieldMemOperand(a1, JSBoundFunction::kBoundThisOffset)); ++ __ CalcScaledAddress(a4, sp, a0, kPointerSizeLog2); ++ __ Sd(kScratchReg, MemOperand(a4)); ++ } ++ ++ // Load [[BoundArguments]] into a2 and length of that into a4. ++ __ Ld(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) ++ // -- a4 : the number of [[BoundArguments]] ++ // ----------------------------------- ++ ++ // Reserve stack space for the [[BoundArguments]]. ++ { ++ Label done; ++ __ Sll64(a5, a4, kPointerSizeLog2); ++ __ Sub64(sp, sp, Operand(a5)); ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&done, Ugreater_equal, sp, Operand(kScratchReg)); ++ // Restore the stack pointer. ++ __ Add64(sp, sp, Operand(a5)); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ } ++ __ bind(&done); ++ } ++ ++ // Relocate arguments down the stack. ++ { ++ Label loop, done_loop; ++ __ Move(a5, zero_reg); ++ __ bind(&loop); ++ __ Branch(&done_loop, gt, a5, Operand(a0)); ++ __ CalcScaledAddress(a6, sp, a4, kPointerSizeLog2); ++ __ Ld(kScratchReg, MemOperand(a6)); ++ __ CalcScaledAddress(a6, sp, a5, kPointerSizeLog2); ++ __ Sd(kScratchReg, MemOperand(a6)); ++ __ Add64(a4, a4, Operand(1)); ++ __ Add64(a5, a5, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Copy [[BoundArguments]] to the stack (below the arguments). ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add64(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub64(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ CalcScaledAddress(a5, a2, a4, kPointerSizeLog2); ++ __ Ld(kScratchReg, MemOperand(a5)); ++ __ CalcScaledAddress(a5, sp, a0, kPointerSizeLog2); ++ __ Sd(kScratchReg, MemOperand(a5)); ++ __ Add64(a0, a0, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Call the [[BoundTargetFunction]] via the Call builtin. ++ __ Ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), Call_ReceiverIsAny), ++ RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the target to call (can be any Object). ++ // ----------------------------------- ++ ++ Label non_callable, non_smi; ++ __ JumpIfSmi(a1, &non_callable); ++ __ bind(&non_smi); ++ __ GetObjectType(a1, t1, t2); ++ __ Jump(masm->isolate()->builtins()->CallFunction(mode), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); ++ ++ // Check if target has a [[Call]] internal method. ++ __ Lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t1, t1, Operand(Map::Bits1::IsCallableBit::kMask)); ++ __ Branch(&non_callable, eq, t1, Operand(zero_reg)); ++ ++ __ Jump(BUILTIN_CODE(masm->isolate(), CallProxy), RelocInfo::CODE_TARGET, eq, ++ t2, Operand(JS_PROXY_TYPE)); ++ ++ // 2. Call to something else, which might have a [[Call]] internal method (if ++ // not we raise an exception). ++ // Overwrite the original receiver with the (original) target. ++ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); ++ __ Sd(a1, MemOperand(kScratchReg)); ++ // Let the "call_as_function_delegate" take care of the rest. ++ __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, a1); ++ __ Jump(masm->isolate()->builtins()->CallFunction( ++ ConvertReceiverMode::kNotNullOrUndefined), ++ RelocInfo::CODE_TARGET); ++ ++ // 3. Call to something that is not callable. ++ __ bind(&non_callable); ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ Push(a1); ++ __ CallRuntime(Runtime::kThrowCalledNonCallable); ++ } ++} ++ ++void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the constructor to call (checked to be a JSFunction) ++ // -- a3 : the new target (checked to be a constructor) ++ // ----------------------------------- ++ __ AssertConstructor(a1); ++ __ AssertFunction(a1); ++ ++ // Calling convention for function specific ConstructStubs require ++ // a2 to contain either an AllocationSite or undefined. ++ __ LoadRoot(a2, RootIndex::kUndefinedValue); ++ ++ Label call_generic_stub; ++ ++ // Jump to JSBuiltinsConstructStub or JSConstructStubGeneric. ++ __ Ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lwu(a4, FieldMemOperand(a4, SharedFunctionInfo::kFlagsOffset)); ++ __ And(a4, a4, Operand(SharedFunctionInfo::ConstructAsBuiltinBit::kMask)); ++ __ Branch(&call_generic_stub, eq, a4, Operand(zero_reg)); ++ ++ __ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub), ++ RelocInfo::CODE_TARGET); ++ ++ __ bind(&call_generic_stub); ++ __ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric), ++ RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a3 : the new target (checked to be a constructor) ++ // ----------------------------------- ++ __ AssertConstructor(a1); ++ __ AssertBoundFunction(a1); ++ ++ // Load [[BoundArguments]] into a2 and length of that into a4. ++ __ Ld(a2, FieldMemOperand(a1, JSBoundFunction::kBoundArgumentsOffset)); ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the function to call (checked to be a JSBoundFunction) ++ // -- a2 : the [[BoundArguments]] (implemented as FixedArray) ++ // -- a3 : the new target (checked to be a constructor) ++ // -- a4 : the number of [[BoundArguments]] ++ // ----------------------------------- ++ ++ // Reserve stack space for the [[BoundArguments]]. ++ { ++ Label done; ++ __ Sll64(a5, a4, kPointerSizeLog2); ++ __ Sub64(sp, sp, Operand(a5)); ++ // Check the stack for overflow. We are not trying to catch interruptions ++ // (i.e. debug break and preemption) here, so check the "real stack limit". ++ LoadStackLimit(masm, kScratchReg, StackLimitKind::kRealStackLimit); ++ __ Branch(&done, Ugreater_equal, sp, Operand(kScratchReg)); ++ // Restore the stack pointer. ++ __ Add64(sp, sp, Operand(a5)); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterFrame(StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ } ++ __ bind(&done); ++ } ++ ++ // Relocate arguments down the stack. ++ { ++ Label loop, done_loop; ++ __ Move(a5, zero_reg); ++ __ bind(&loop); ++ __ Branch(&done_loop, ge, a5, Operand(a0)); ++ __ CalcScaledAddress(a6, sp, a4, kPointerSizeLog2); ++ __ Ld(kScratchReg, MemOperand(a6)); ++ __ CalcScaledAddress(a6, sp, a5, kPointerSizeLog2); ++ __ Sd(kScratchReg, MemOperand(a6)); ++ __ Add64(a4, a4, Operand(1)); ++ __ Add64(a5, a5, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Copy [[BoundArguments]] to the stack (below the arguments). ++ { ++ Label loop, done_loop; ++ __ SmiUntag(a4, FieldMemOperand(a2, FixedArray::kLengthOffset)); ++ __ Add64(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); ++ __ bind(&loop); ++ __ Sub64(a4, a4, Operand(1)); ++ __ Branch(&done_loop, lt, a4, Operand(zero_reg)); ++ __ CalcScaledAddress(a5, a2, a4, kPointerSizeLog2); ++ __ Ld(kScratchReg, MemOperand(a5)); ++ __ CalcScaledAddress(a5, sp, a0, kPointerSizeLog2); ++ __ Sd(kScratchReg, MemOperand(a5)); ++ __ Add64(a0, a0, Operand(1)); ++ __ Branch(&loop); ++ __ bind(&done_loop); ++ } ++ ++ // Patch new.target to [[BoundTargetFunction]] if new.target equals target. ++ { ++ Label skip_load; ++ __ Branch(&skip_load, ne, a1, Operand(a3)); ++ __ Ld(a3, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ bind(&skip_load); ++ } ++ ++ // Construct the [[BoundTargetFunction]] via the Construct builtin. ++ __ Ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), Construct), RelocInfo::CODE_TARGET); ++} ++ ++// static ++void Builtins::Generate_Construct(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- a0 : the number of arguments (not including the receiver) ++ // -- a1 : the constructor to call (can be any Object) ++ // -- a3 : the new target (either the same as the constructor or ++ // the JSFunction on which new was invoked initially) ++ // ----------------------------------- ++ ++ // Check if target is a Smi. ++ Label non_constructor, non_proxy; ++ __ JumpIfSmi(a1, &non_constructor); ++ ++ // Check if target has a [[Construct]] internal method. ++ __ Ld(t1, FieldMemOperand(a1, HeapObject::kMapOffset)); ++ __ Lbu(t4, FieldMemOperand(t1, Map::kBitFieldOffset)); ++ __ And(t4, t4, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ __ Branch(&non_constructor, eq, t4, Operand(zero_reg)); ++ ++ // Dispatch based on instance type. ++ __ Lhu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); ++ ++ // Only dispatch to bound functions after checking whether they are ++ // constructors. ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructBoundFunction), ++ RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); ++ ++ // Only dispatch to proxies after checking whether they are constructors. ++ __ Branch(&non_proxy, ne, t2, Operand(JS_PROXY_TYPE)); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructProxy), ++ RelocInfo::CODE_TARGET); ++ ++ // Called Construct on an exotic Object with a [[Construct]] internal method. ++ __ bind(&non_proxy); ++ { ++ // Overwrite the original receiver with the (original) target. ++ __ CalcScaledAddress(kScratchReg, sp, a0, kPointerSizeLog2); ++ __ Sd(a1, MemOperand(kScratchReg)); ++ // Let the "call_as_constructor_delegate" take care of the rest. ++ __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); ++ __ Jump(masm->isolate()->builtins()->CallFunction(), ++ RelocInfo::CODE_TARGET); ++ } ++ ++ // Called Construct on an Object that doesn't have a [[Construct]] internal ++ // method. ++ __ bind(&non_constructor); ++ __ Jump(BUILTIN_CODE(masm->isolate(), ConstructedNonConstructable), ++ RelocInfo::CODE_TARGET); ++} ++ ++void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ++ // State setup as expected by MacroAssembler::InvokePrologue. ++ // ----------- S t a t e ------------- ++ // -- a0: actual arguments count ++ // -- a1: function (passed through to callee) ++ // -- a2: expected arguments count ++ // -- a3: new target (passed through to callee) ++ // ----------------------------------- ++ ++ Label invoke, dont_adapt_arguments, stack_overflow; ++ ++ Label enough, too_few; ++ __ Branch(&dont_adapt_arguments, eq, a2, ++ Operand(kDontAdaptArgumentsSentinel)); ++ // We use Uless as the number of argument should always be greater than 0. ++ __ Branch(&too_few, Uless, a0, Operand(a2)); ++ ++ { // Enough parameters: actual >= expected. ++ // a0: actual number of arguments as a smi ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ bind(&enough); ++ EnterArgumentsAdaptorFrame(masm); ++ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); ++ ++ // Calculate copy start address into a0 and copy end address into a4. ++ __ SmiScale(a0, a0, kPointerSizeLog2); ++ __ Add64(a0, fp, a0); ++ // Adjust for return address and receiver. ++ __ Add64(a0, a0, Operand(2 * kPointerSize)); ++ // Compute copy end address. ++ __ Sll64(a4, a2, kPointerSizeLog2); ++ __ Sub64(a4, a0, a4); ++ ++ // Copy the arguments (including the receiver) to the new stack frame. ++ // a0: copy start address ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ // a4: copy end address ++ ++ Label copy; ++ __ bind(©); ++ __ Ld(a5, MemOperand(a0)); ++ __ push(a5); ++ __ Add64(a0, a0, -kPointerSize); ++ __ Branch(©, ge, a0, Operand(a4)); ++ ++ __ Branch(&invoke); ++ } ++ ++ { // Too few parameters: Actual < expected. ++ __ bind(&too_few); ++ EnterArgumentsAdaptorFrame(masm); ++ Generate_StackOverflowCheck(masm, a2, a5, kScratchReg, &stack_overflow); ++ ++ // Calculate copy start address into a0 and copy end address into a7. ++ // a0: actual number of arguments as a smi ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ SmiScale(a0, a0, kPointerSizeLog2); ++ __ Add64(a0, fp, a0); ++ // Adjust for return address and receiver. ++ __ Add64(a0, a0, Operand(2 * kPointerSize)); ++ // Compute copy end address. Also adjust for return address. ++ __ Add64(a7, fp, kPointerSize); ++ ++ // Copy the arguments (including the receiver) to the new stack frame. ++ // a0: copy start address ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ // a7: copy end address ++ Label copy; ++ __ bind(©); ++ __ Ld(a4, MemOperand(a0)); // Adjusted above for return addr and receiver. ++ __ Sub64(sp, sp, kPointerSize); ++ __ Sub64(a0, a0, kPointerSize); ++ __ Sd(a4, MemOperand(sp)); ++ __ Branch(©, ne, a0, Operand(a7)); ++ ++ // Fill the remaining expected arguments with undefined. ++ // a1: function ++ // a2: expected number of arguments ++ // a3: new target (passed through to callee) ++ __ LoadRoot(a5, RootIndex::kUndefinedValue); ++ __ Sll64(a6, a2, kPointerSizeLog2); ++ __ Sub64(a4, fp, Operand(a6)); ++ // Adjust for frame. ++ __ Sub64(a4, a4, ++ Operand(ArgumentsAdaptorFrameConstants::kFixedFrameSizeFromFp + ++ kPointerSize)); ++ ++ Label fill; ++ __ bind(&fill); ++ __ Sub64(sp, sp, kPointerSize); ++ __ Sd(a5, MemOperand(sp)); ++ __ Branch(&fill, ne, sp, Operand(a4)); ++ } ++ ++ // Call the entry point. ++ __ bind(&invoke); ++ __ Move(a0, a2); ++ // a0 : expected number of arguments ++ // a1 : function (passed through to callee) ++ // a3: new target (passed through to callee) ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Call(a2); ++ ++ // Store offset of return address for deoptimizer. ++ masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); ++ ++ // Exit frame and return. ++ LeaveArgumentsAdaptorFrame(masm); ++ __ Ret(); ++ ++ // ------------------------------------------- ++ // Don't adapt arguments. ++ // ------------------------------------------- ++ __ bind(&dont_adapt_arguments); ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld(a2, FieldMemOperand(a1, JSFunction::kCodeOffset)); ++ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Jump(a2); ++ ++ __ bind(&stack_overflow); ++ { ++ FrameScope frame(masm, StackFrame::MANUAL); ++ __ CallRuntime(Runtime::kThrowStackOverflow); ++ __ break_(0xCC); ++ } ++} ++ ++void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { ++ // The function index was put in t0 by the jump table trampoline. ++ // Convert to Smi for the runtime call ++ __ SmiTag(kWasmCompileLazyFuncIndexRegister); ++ { ++ HardAbortScope hard_abort(masm); // Avoid calls to Abort. ++ FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY); ++ ++ // Save all parameter registers (see kGpParamRegisters in wasm-linkage.cc). ++ // They might be overwritten in the runtime call below. We don't have any ++ // callee-saved registers in wasm, so no need to store anything else. ++ constexpr RegList gp_regs = Register::ListOf(a0, a2, a3, a4, a5, a6, a7); ++ constexpr RegList fp_regs = ++ DoubleRegister::ListOf(fa0, fa1, fa2, fa3, fa4, fa5, fa6); ++ static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs == ++ arraysize(wasm::kGpParamRegisters), ++ "frame size mismatch"); ++ static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs == ++ arraysize(wasm::kFpParamRegisters), ++ "frame size mismatch"); ++ __ MultiPush(gp_regs); ++ __ MultiPushFPU(fp_regs); ++ ++ // Pass instance and function index as an explicit arguments to the runtime ++ // function. ++ __ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister); ++ // Initialize the JavaScript context with 0. CEntry will use it to ++ // set the current context on the isolate. ++ __ Move(kContextRegister, Smi::zero()); ++ __ CallRuntime(Runtime::kWasmCompileLazy, 2); ++ ++ __ Move(s1, a0); // move return value to s1 since a0 will be restored to ++ // the value before the call ++ ++ // Restore registers. ++ __ MultiPopFPU(fp_regs); ++ __ MultiPop(gp_regs); ++ } ++ // Finally, jump to the entrypoint. ++ __ Jump(s1); ++} ++ ++void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) { ++ HardAbortScope hard_abort(masm); // Avoid calls to Abort. ++ { ++ FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK); ++ ++ // Save all parameter registers. They might hold live values, we restore ++ // them after the runtime call. ++ __ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs); ++ __ MultiPushFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); ++ ++ // Initialize the JavaScript context with 0. CEntry will use it to ++ // set the current context on the isolate. ++ __ Move(cp, Smi::zero()); ++ __ CallRuntime(Runtime::kWasmDebugBreak, 0); ++ ++ // Restore registers. ++ __ MultiPopFPU(WasmDebugBreakFrameConstants::kPushedFpRegs); ++ __ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs); ++ } ++ __ Ret(); ++} ++ ++void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size, ++ SaveFPRegsMode save_doubles, ArgvMode argv_mode, ++ bool builtin_exit_frame) { ++ // Called from JavaScript; parameters are on stack as if calling JS function ++ // a0: number of arguments including receiver ++ // a1: pointer to builtin function ++ // fp: frame pointer (restored after C call) ++ // sp: stack pointer (restored as callee's sp after C call) ++ // cp: current context (C callee-saved) ++ // ++ // If argv_mode == kArgvInRegister: ++ // a2: pointer to the first argument ++ ++ if (argv_mode == kArgvInRegister) { ++ // Move argv into the correct register. ++ __ Move(s1, a2); ++ } else { ++ // Compute the argv pointer in a callee-saved register. ++ __ CalcScaledAddress(s1, sp, a0, kPointerSizeLog2); ++ __ Sub64(s1, s1, kPointerSize); ++ } ++ ++ // Enter the exit frame that transitions from JavaScript to C++. ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame( ++ save_doubles == kSaveFPRegs, 0, ++ builtin_exit_frame ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT); ++ ++ // s3: number of arguments including receiver (C callee-saved) ++ // s1: pointer to first argument (C callee-saved) ++ // s2: pointer to builtin function (C callee-saved) ++ ++ // Prepare arguments for C routine. ++ // a0 = argc ++ __ Move(s3, a0); ++ __ Move(s2, a1); ++ ++ // We are calling compiled C/C++ code. a0 and a1 hold our two arguments. We ++ // also need to reserve the 4 argument slots on the stack. ++ ++ __ AssertStackIsAligned(); ++ ++ // a0 = argc, a1 = argv, a2 = isolate ++ __ li(a2, ExternalReference::isolate_address(masm->isolate())); ++ __ Move(a1, s1); ++ ++ __ StoreReturnAddressAndCall(s2); ++ ++ // Result returned in a0 or a1:a0 - do not destroy these registers! ++ ++ // Check result for exception sentinel. ++ Label exception_returned; ++ __ LoadRoot(a4, RootIndex::kException); ++ __ Branch(&exception_returned, eq, a4, Operand(a0)); ++ ++ // Check that there is no pending exception, otherwise we ++ // should have returned the exception sentinel. ++ if (FLAG_debug_code) { ++ Label okay; ++ ExternalReference pending_exception_address = ExternalReference::Create( ++ IsolateAddressId::kPendingExceptionAddress, masm->isolate()); ++ __ li(a2, pending_exception_address); ++ __ Ld(a2, MemOperand(a2)); ++ __ LoadRoot(a4, RootIndex::kTheHoleValue); ++ // Cannot use check here as it attempts to generate call into runtime. ++ __ Branch(&okay, eq, a4, Operand(a2)); ++ __ stop(); ++ __ bind(&okay); ++ } ++ ++ // Exit C frame and return. ++ // a0:a1: result ++ // sp: stack pointer ++ // fp: frame pointer ++ Register argc = argv_mode == kArgvInRegister ++ // We don't want to pop arguments so set argc to no_reg. ++ ? no_reg ++ // s3: still holds argc (callee-saved). ++ : s3; ++ __ LeaveExitFrame(save_doubles == kSaveFPRegs, argc, EMIT_RETURN); ++ ++ // Handling of exception. ++ __ bind(&exception_returned); ++ ++ ExternalReference pending_handler_context_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerContextAddress, masm->isolate()); ++ ExternalReference pending_handler_entrypoint_address = ++ ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerEntrypointAddress, masm->isolate()); ++ ExternalReference pending_handler_fp_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerFPAddress, masm->isolate()); ++ ExternalReference pending_handler_sp_address = ExternalReference::Create( ++ IsolateAddressId::kPendingHandlerSPAddress, masm->isolate()); ++ ++ // Ask the runtime for help to determine the handler. This will set a0 to ++ // contain the current pending exception, don't clobber it. ++ ExternalReference find_handler = ++ ExternalReference::Create(Runtime::kUnwindAndFindExceptionHandler); ++ { ++ FrameScope scope(masm, StackFrame::MANUAL); ++ __ PrepareCallCFunction(3, 0, a0); ++ __ Move(a0, zero_reg); ++ __ Move(a1, zero_reg); ++ __ li(a2, ExternalReference::isolate_address(masm->isolate())); ++ __ CallCFunction(find_handler, 3); ++ } ++ ++ // Retrieve the handler context, SP and FP. ++ __ li(cp, pending_handler_context_address); ++ __ Ld(cp, MemOperand(cp)); ++ __ li(sp, pending_handler_sp_address); ++ __ Ld(sp, MemOperand(sp)); ++ __ li(fp, pending_handler_fp_address); ++ __ Ld(fp, MemOperand(fp)); ++ ++ // If the handler is a JS frame, restore the context to the frame. Note that ++ // the context will be set to (cp == 0) for non-JS frames. ++ Label zero; ++ __ Branch(&zero, eq, cp, Operand(zero_reg)); ++ __ Sd(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); ++ __ bind(&zero); ++ ++ // Reset the masking register. This is done independent of the underlying ++ // feature flag {FLAG_untrusted_code_mitigations} to make the snapshot work ++ // with both configurations. It is safe to always do this, because the ++ // underlying register is caller-saved and can be arbitrarily clobbered. ++ __ ResetSpeculationPoisonRegister(); ++ ++ // Compute the handler entry address and jump to it. ++ __ li(t6, pending_handler_entrypoint_address); ++ __ Ld(t6, MemOperand(t6)); ++ __ Jump(t6); ++} ++ ++void Builtins::Generate_DoubleToI(MacroAssembler* masm) { ++ Label done; ++ Register result_reg = t0; ++ ++ Register scratch = GetRegisterThatIsNotOneOf(result_reg); ++ Register scratch2 = GetRegisterThatIsNotOneOf(result_reg, scratch); ++ Register scratch3 = GetRegisterThatIsNotOneOf(result_reg, scratch, scratch2); ++ DoubleRegister double_scratch = kScratchDoubleReg; ++ ++ // Account for saved regs. ++ const int kArgumentOffset = 4 * kPointerSize; ++ ++ __ Push(result_reg); ++ __ Push(scratch, scratch2, scratch3); ++ ++ // Load double input. ++ __ LoadDouble(double_scratch, MemOperand(sp, kArgumentOffset)); ++ ++ // Try a conversion to a signed integer, if exception occurs, scratch is ++ // set to 0 ++ __ Trunc_w_d(scratch3, double_scratch, scratch); ++ ++ // If we had no exceptions then set result_reg and we are done. ++ Label error; ++ __ Branch(&error, eq, scratch, Operand(zero_reg)); ++ __ Move(result_reg, scratch3); ++ __ Branch(&done); ++ __ bind(&error); ++ ++ // Load the double value and perform a manual truncation. ++ Register input_high = scratch2; ++ Register input_low = scratch3; ++ ++ __ Lw(input_low, MemOperand(sp, kArgumentOffset + Register::kMantissaOffset)); ++ __ Lw(input_high, ++ MemOperand(sp, kArgumentOffset + Register::kExponentOffset)); ++ ++ Label normal_exponent; ++ // Extract the biased exponent in result. ++ __ ExtractBits(result_reg, input_high, HeapNumber::kExponentShift, ++ HeapNumber::kExponentBits); ++ ++ // Check for Infinity and NaNs, which should return 0. ++ __ Sub32(scratch, result_reg, HeapNumber::kExponentMask); ++ __ LoadZeroIfConditionZero( ++ result_reg, ++ scratch); // result_reg = scratch == 0 ? 0 : result_reg ++ __ Branch(&done, eq, scratch, Operand(zero_reg)); ++ ++ // Express exponent as delta to (number of mantissa bits + 31). ++ __ Sub32(result_reg, result_reg, ++ Operand(HeapNumber::kExponentBias + HeapNumber::kMantissaBits + 31)); ++ ++ // If the delta is strictly positive, all bits would be shifted away, ++ // which means that we can return 0. ++ __ Branch(&normal_exponent, le, result_reg, Operand(zero_reg)); ++ __ Move(result_reg, zero_reg); ++ __ Branch(&done); ++ ++ __ bind(&normal_exponent); ++ const int kShiftBase = HeapNumber::kNonMantissaBitsInTopWord - 1; ++ // Calculate shift. ++ __ Add32(scratch, result_reg, ++ Operand(kShiftBase + HeapNumber::kMantissaBits)); ++ ++ // Save the sign. ++ Register sign = result_reg; ++ result_reg = no_reg; ++ __ And(sign, input_high, Operand(HeapNumber::kSignMask)); ++ ++ // We must specially handle shifts greater than 31. ++ Label high_shift_needed, high_shift_done; ++ __ Branch(&high_shift_needed, lt, scratch, Operand(32)); ++ __ Move(input_high, zero_reg); ++ __ Branch(&high_shift_done); ++ __ bind(&high_shift_needed); ++ ++ // Set the implicit 1 before the mantissa part in input_high. ++ __ Or(input_high, input_high, ++ Operand(1 << HeapNumber::kMantissaBitsInTopWord)); ++ // Shift the mantissa bits to the correct position. ++ // We don't need to clear non-mantissa bits as they will be shifted away. ++ // If they weren't, it would mean that the answer is in the 32bit range. ++ __ Sll32(input_high, input_high, scratch); ++ ++ __ bind(&high_shift_done); ++ ++ // Replace the shifted bits with bits from the lower mantissa word. ++ Label pos_shift, shift_done, sign_negative; ++ __ li(kScratchReg, 32); ++ __ subw(scratch, kScratchReg, scratch); ++ __ Branch(&pos_shift, ge, scratch, Operand(zero_reg)); ++ ++ // Negate scratch. ++ __ Sub32(scratch, zero_reg, scratch); ++ __ Sll32(input_low, input_low, scratch); ++ __ Branch(&shift_done); ++ ++ __ bind(&pos_shift); ++ __ srlw(input_low, input_low, scratch); ++ ++ __ bind(&shift_done); ++ __ Or(input_high, input_high, Operand(input_low)); ++ // Restore sign if necessary. ++ __ Move(scratch, sign); ++ result_reg = sign; ++ sign = no_reg; ++ __ Sub32(result_reg, zero_reg, input_high); ++ __ Branch(&sign_negative, ne, scratch, Operand(zero_reg)); ++ __ Move(result_reg, input_high); ++ __ bind(&sign_negative); ++ ++ __ bind(&done); ++ ++ __ Sd(result_reg, MemOperand(sp, kArgumentOffset)); ++ __ Pop(scratch, scratch2, scratch3); ++ __ Pop(result_reg); ++ __ Ret(); ++} ++ ++void Builtins::Generate_GenericJSToWasmWrapper(MacroAssembler* masm) { ++ // TODO(v8:10701): Implement for this platform. ++ __ Trap(); ++} ++ ++namespace { ++ ++int AddressOffset(ExternalReference ref0, ExternalReference ref1) { ++ int64_t offset = (ref0.address() - ref1.address()); ++ DCHECK(static_cast(offset) == offset); ++ return static_cast(offset); ++} ++ ++// Calls an API function. Allocates HandleScope, extracts returned value ++// from handle and propagates exceptions. Restores context. stack_space ++// - space to be unwound on exit (includes the call JS arguments space and ++// the additional space allocated for the fast call). ++void CallApiFunctionAndReturn(MacroAssembler* masm, Register function_address, ++ ExternalReference thunk_ref, int stack_space, ++ MemOperand* stack_space_operand, ++ MemOperand return_value_operand) { ++ Isolate* isolate = masm->isolate(); ++ ExternalReference next_address = ++ ExternalReference::handle_scope_next_address(isolate); ++ const int kNextOffset = 0; ++ const int kLimitOffset = AddressOffset( ++ ExternalReference::handle_scope_limit_address(isolate), next_address); ++ const int kLevelOffset = AddressOffset( ++ ExternalReference::handle_scope_level_address(isolate), next_address); ++ ++ DCHECK(function_address == a1 || function_address == a2); ++ ++ Label profiler_enabled, end_profiler_check; ++ __ li(t6, ExternalReference::is_profiling_address(isolate)); ++ __ Lb(t6, MemOperand(t6, 0)); ++ __ Branch(&profiler_enabled, ne, t6, Operand(zero_reg)); ++ __ li(t6, ExternalReference::address_of_runtime_stats_flag()); ++ __ Lw(t6, MemOperand(t6, 0)); ++ __ Branch(&profiler_enabled, ne, t6, Operand(zero_reg)); ++ { ++ // Call the api function directly. ++ __ Move(t6, function_address); ++ __ Branch(&end_profiler_check); ++ } ++ ++ __ bind(&profiler_enabled); ++ { ++ // Additional parameter is the address of the actual callback. ++ __ li(t6, thunk_ref); ++ } ++ __ bind(&end_profiler_check); ++ ++ // Allocate HandleScope in callee-save registers. ++ __ li(s5, next_address); ++ __ Ld(s3, MemOperand(s5, kNextOffset)); ++ __ Ld(s1, MemOperand(s5, kLimitOffset)); ++ __ Lw(s2, MemOperand(s5, kLevelOffset)); ++ __ Add32(s2, s2, Operand(1)); ++ __ Sw(s2, MemOperand(s5, kLevelOffset)); ++ ++ __ StoreReturnAddressAndCall(t6); ++ ++ Label promote_scheduled_exception; ++ Label delete_allocated_handles; ++ Label leave_exit_frame; ++ Label return_value_loaded; ++ ++ // Load value from ReturnValue. ++ __ Ld(a0, return_value_operand); ++ __ bind(&return_value_loaded); ++ ++ // No more valid handles (the result handle was the last one). Restore ++ // previous handle scope. ++ __ Sd(s3, MemOperand(s5, kNextOffset)); ++ if (__ emit_debug_code()) { ++ __ Lw(a1, MemOperand(s5, kLevelOffset)); ++ __ Check(eq, AbortReason::kUnexpectedLevelAfterReturnFromApiCall, a1, ++ Operand(s2)); ++ } ++ __ Sub32(s2, s2, Operand(1)); ++ __ Sw(s2, MemOperand(s5, kLevelOffset)); ++ __ Ld(kScratchReg, MemOperand(s5, kLimitOffset)); ++ __ Branch(&delete_allocated_handles, ne, s1, Operand(kScratchReg)); ++ ++ // Leave the API exit frame. ++ __ bind(&leave_exit_frame); ++ ++ if (stack_space_operand == nullptr) { ++ DCHECK_NE(stack_space, 0); ++ __ li(s3, Operand(stack_space)); ++ } else { ++ DCHECK_EQ(stack_space, 0); ++ STATIC_ASSERT(kCArgSlotCount == 0); ++ __ Ld(s3, *stack_space_operand); ++ } ++ ++ static constexpr bool kDontSaveDoubles = false; ++ static constexpr bool kRegisterContainsSlotCount = false; ++ __ LeaveExitFrame(kDontSaveDoubles, s3, NO_EMIT_RETURN, ++ kRegisterContainsSlotCount); ++ ++ // Check if the function scheduled an exception. ++ __ LoadRoot(a4, RootIndex::kTheHoleValue); ++ __ li(kScratchReg, ExternalReference::scheduled_exception_address(isolate)); ++ __ Ld(a5, MemOperand(kScratchReg)); ++ __ Branch(&promote_scheduled_exception, ne, a4, Operand(a5)); ++ ++ __ Ret(); ++ ++ // Re-throw by promoting a scheduled exception. ++ __ bind(&promote_scheduled_exception); ++ __ TailCallRuntime(Runtime::kPromoteScheduledException); ++ ++ // HandleScope limit has changed. Delete allocated extensions. ++ __ bind(&delete_allocated_handles); ++ __ Sd(s1, MemOperand(s5, kLimitOffset)); ++ __ Move(s3, a0); ++ __ PrepareCallCFunction(1, s1); ++ __ li(a0, ExternalReference::isolate_address(isolate)); ++ __ CallCFunction(ExternalReference::delete_handle_scope_extensions(), 1); ++ __ Move(a0, s3); ++ __ Branch(&leave_exit_frame); ++} ++ ++} // namespace ++ ++void Builtins::Generate_CallApiCallback(MacroAssembler* masm) { ++ // ----------- S t a t e ------------- ++ // -- cp : context ++ // -- a1 : api function address ++ // -- a2 : arguments count (not including the receiver) ++ // -- a3 : call data ++ // -- a0 : holder ++ // -- ++ // -- sp[0] : last argument ++ // -- ... ++ // -- sp[(argc - 1) * 8] : first argument ++ // -- sp[(argc + 0) * 8] : receiver ++ // ----------------------------------- ++ ++ Register api_function_address = a1; ++ Register argc = a2; ++ Register call_data = a3; ++ Register holder = a0; ++ Register scratch = t0; ++ Register base = t1; // For addressing MemOperands on the stack. ++ ++ DCHECK(!AreAliased(api_function_address, argc, call_data, holder, scratch, ++ base)); ++ ++ using FCA = FunctionCallbackArguments; ++ ++ STATIC_ASSERT(FCA::kArgsLength == 6); ++ STATIC_ASSERT(FCA::kNewTargetIndex == 5); ++ STATIC_ASSERT(FCA::kDataIndex == 4); ++ STATIC_ASSERT(FCA::kReturnValueOffset == 3); ++ STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); ++ STATIC_ASSERT(FCA::kIsolateIndex == 1); ++ STATIC_ASSERT(FCA::kHolderIndex == 0); ++ ++ // Set up FunctionCallbackInfo's implicit_args on the stack as follows: ++ // ++ // Target state: ++ // sp[0 * kPointerSize]: kHolder ++ // sp[1 * kPointerSize]: kIsolate ++ // sp[2 * kPointerSize]: undefined (kReturnValueDefaultValue) ++ // sp[3 * kPointerSize]: undefined (kReturnValue) ++ // sp[4 * kPointerSize]: kData ++ // sp[5 * kPointerSize]: undefined (kNewTarget) ++ ++ // Set up the base register for addressing through MemOperands. It will point ++ // at the receiver (located at sp + argc * kPointerSize). ++ __ CalcScaledAddress(base, sp, argc, kPointerSizeLog2); ++ ++ // Reserve space on the stack. ++ __ Sub64(sp, sp, Operand(FCA::kArgsLength * kPointerSize)); ++ ++ // kHolder. ++ __ Sd(holder, MemOperand(sp, 0 * kPointerSize)); ++ ++ // kIsolate. ++ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); ++ __ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); ++ ++ // kReturnValueDefaultValue and kReturnValue. ++ __ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ __ Sd(scratch, MemOperand(sp, 2 * kPointerSize)); ++ __ Sd(scratch, MemOperand(sp, 3 * kPointerSize)); ++ ++ // kData. ++ __ Sd(call_data, MemOperand(sp, 4 * kPointerSize)); ++ ++ // kNewTarget. ++ __ Sd(scratch, MemOperand(sp, 5 * kPointerSize)); ++ ++ // Keep a pointer to kHolder (= implicit_args) in a scratch register. ++ // We use it below to set up the FunctionCallbackInfo object. ++ __ Move(scratch, sp); ++ ++ // Allocate the v8::Arguments structure in the arguments' space since ++ // it's not controlled by GC. ++ static constexpr int kApiStackSpace = 4; ++ static constexpr bool kDontSaveDoubles = false; ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame(kDontSaveDoubles, kApiStackSpace); ++ ++ // EnterExitFrame may align the sp. ++ ++ // FunctionCallbackInfo::implicit_args_ (points at kHolder as set up above). ++ // Arguments are after the return address (pushed by EnterExitFrame()). ++ __ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); ++ ++ // FunctionCallbackInfo::values_ (points at the first varargs argument passed ++ // on the stack). ++ __ Sub64(scratch, base, Operand(1 * kPointerSize)); ++ __ Sd(scratch, MemOperand(sp, 2 * kPointerSize)); ++ ++ // FunctionCallbackInfo::length_. ++ // Stored as int field, 32-bit integers within struct on stack always left ++ // justified by n64 ABI. ++ __ Sw(argc, MemOperand(sp, 3 * kPointerSize)); ++ ++ // We also store the number of bytes to drop from the stack after returning ++ // from the API function here. ++ // Note: Unlike on other architectures, this stores the number of slots to ++ // drop, not the number of bytes. ++ __ Add64(scratch, argc, Operand(FCA::kArgsLength + 1 /* receiver */)); ++ __ Sd(scratch, MemOperand(sp, 4 * kPointerSize)); ++ ++ // v8::InvocationCallback's argument. ++ DCHECK(!AreAliased(api_function_address, scratch, a0)); ++ __ Add64(a0, sp, Operand(1 * kPointerSize)); ++ ++ ExternalReference thunk_ref = ExternalReference::invoke_function_callback(); ++ ++ // There are two stack slots above the arguments we constructed on the stack. ++ // TODO(jgruber): Document what these arguments are. ++ static constexpr int kStackSlotsAboveFCA = 2; ++ MemOperand return_value_operand( ++ fp, (kStackSlotsAboveFCA + FCA::kReturnValueOffset) * kPointerSize); ++ ++ static constexpr int kUseStackSpaceOperand = 0; ++ MemOperand stack_space_operand(sp, 4 * kPointerSize); ++ ++ AllowExternalCallThatCantCauseGC scope(masm); ++ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, ++ kUseStackSpaceOperand, &stack_space_operand, ++ return_value_operand); ++} ++ ++void Builtins::Generate_CallApiGetter(MacroAssembler* masm) { ++ // Build v8::PropertyCallbackInfo::args_ array on the stack and push property ++ // name below the exit frame to make GC aware of them. ++ STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); ++ STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); ++ STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); ++ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); ++ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); ++ STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); ++ STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); ++ STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); ++ ++ Register receiver = ApiGetterDescriptor::ReceiverRegister(); ++ Register holder = ApiGetterDescriptor::HolderRegister(); ++ Register callback = ApiGetterDescriptor::CallbackRegister(); ++ Register scratch = a4; ++ DCHECK(!AreAliased(receiver, holder, callback, scratch)); ++ ++ Register api_function_address = a2; ++ ++ // Here and below +1 is for name() pushed after the args_ array. ++ using PCA = PropertyCallbackArguments; ++ __ Sub64(sp, sp, (PCA::kArgsLength + 1) * kPointerSize); ++ __ Sd(receiver, MemOperand(sp, (PCA::kThisIndex + 1) * kPointerSize)); ++ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kDataOffset)); ++ __ Sd(scratch, MemOperand(sp, (PCA::kDataIndex + 1) * kPointerSize)); ++ __ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ __ Sd(scratch, MemOperand(sp, (PCA::kReturnValueOffset + 1) * kPointerSize)); ++ __ Sd(scratch, MemOperand(sp, (PCA::kReturnValueDefaultValueIndex + 1) * ++ kPointerSize)); ++ __ li(scratch, ExternalReference::isolate_address(masm->isolate())); ++ __ Sd(scratch, MemOperand(sp, (PCA::kIsolateIndex + 1) * kPointerSize)); ++ __ Sd(holder, MemOperand(sp, (PCA::kHolderIndex + 1) * kPointerSize)); ++ // should_throw_on_error -> false ++ DCHECK_EQ(0, Smi::zero().ptr()); ++ __ Sd(zero_reg, ++ MemOperand(sp, (PCA::kShouldThrowOnErrorIndex + 1) * kPointerSize)); ++ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kNameOffset)); ++ __ Sd(scratch, MemOperand(sp, 0 * kPointerSize)); ++ ++ // v8::PropertyCallbackInfo::args_ array and name handle. ++ const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; ++ ++ // Load address of v8::PropertyAccessorInfo::args_ array and name handle. ++ __ Move(a0, sp); // a0 = Handle ++ __ Add64(a1, a0, Operand(1 * kPointerSize)); // a1 = v8::PCI::args_ ++ ++ const int kApiStackSpace = 1; ++ FrameScope frame_scope(masm, StackFrame::MANUAL); ++ __ EnterExitFrame(false, kApiStackSpace); ++ ++ // Create v8::PropertyCallbackInfo object on the stack and initialize ++ // it's args_ field. ++ __ Sd(a1, MemOperand(sp, 1 * kPointerSize)); ++ __ Add64(a1, sp, Operand(1 * kPointerSize)); ++ // a1 = v8::PropertyCallbackInfo& ++ ++ ExternalReference thunk_ref = ++ ExternalReference::invoke_accessor_getter_callback(); ++ ++ __ Ld(scratch, FieldMemOperand(callback, AccessorInfo::kJsGetterOffset)); ++ __ Ld(api_function_address, ++ FieldMemOperand(scratch, Foreign::kForeignAddressOffset)); ++ ++ // +3 is to skip prolog, return address and name handle. ++ MemOperand return_value_operand( ++ fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); ++ MemOperand* const kUseStackSpaceConstant = nullptr; ++ CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, ++ kStackUnwindSpace, kUseStackSpaceConstant, ++ return_value_operand); ++} ++ ++void Builtins::Generate_DirectCEntry(MacroAssembler* masm) { ++ // The sole purpose of DirectCEntry is for movable callers (e.g. any general ++ // purpose Code object) to be able to call into C functions that may trigger ++ // GC and thus move the caller. ++ // ++ // DirectCEntry places the return address on the stack (updated by the GC), ++ // making the call GC safe. The irregexp backend relies on this. ++ ++ // Make place for arguments to fit C calling convention. Callers use ++ // EnterExitFrame/LeaveExitFrame so they handle stack restoring and we don't ++ // have to do that here. Any caller must drop kCArgsSlotsSize stack space ++ // after the call. ++ __ Add64(sp, sp, -kCArgsSlotsSize); ++ ++ __ Sd(ra, MemOperand(sp, kCArgsSlotsSize)); // Store the return address. ++ __ Call(t6); // Call the C++ function. ++ __ Ld(t6, MemOperand(sp, kCArgsSlotsSize)); // Return to calling code. ++ ++ if (FLAG_debug_code && FLAG_enable_slow_asserts) { ++ // In case of an error the return address may point to a memory area ++ // filled with kZapValue by the GC. Dereference the address and check for ++ // this. ++ __ Uld(a4, MemOperand(t6)); ++ __ Assert(ne, AbortReason::kReceivedInvalidReturnAddress, a4, ++ Operand(reinterpret_cast(kZapValue))); ++ } ++ ++ __ Jump(t6); ++} ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- a/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h ++++ b/src/3rdparty/chromium/v8/src/codegen/assembler-arch.h +@@ -23,6 +23,10 @@ + #include "src/codegen/mips64/assembler-mips64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/assembler-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/codegen/riscv64/assembler-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/codegen/riscv/assembler-riscv.h" + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h ++++ b/src/3rdparty/chromium/v8/src/codegen/assembler-inl.h +@@ -23,6 +23,10 @@ + #include "src/codegen/mips64/assembler-mips64-inl.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/assembler-s390-inl.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/codegen/riscv64/assembler-riscv64-inl.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/codegen/riscv/assembler-riscv-inl.h" + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/constants-arch.h ++++ b/src/3rdparty/chromium/v8/src/codegen/constants-arch.h +@@ -21,6 +21,10 @@ + #include "src/codegen/s390/constants-s390.h" // NOLINT + #elif V8_TARGET_ARCH_X64 + #include "src/codegen/x64/constants-x64.h" // NOLINT ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/codegen/riscv64/constants-riscv64.h" // NOLINT ++#elif V8_TARGET_ARCH_RISCV ++#include "src/codegen/riscv64/constants-riscv.h" // NOLINT + #else + #error Unsupported target architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/cpu-features.h ++++ b/src/3rdparty/chromium/v8/src/codegen/cpu-features.h +@@ -67,6 +67,12 @@ + VECTOR_ENHANCE_FACILITY_1, + VECTOR_ENHANCE_FACILITY_2, + MISC_INSTR_EXT2, ++ ++// FIXME (RISCV): add features for RISCV ++#elif V8_TARGET_ARCH_RISCV64 ++ FPU, ++ FP64FPU, ++ RISCV_SIMD, + #endif + + NUMBER_OF_CPU_FEATURES +--- a/src/3rdparty/chromium/v8/src/codegen/external-reference.cc ++++ b/src/3rdparty/chromium/v8/src/codegen/external-reference.cc +@@ -502,6 +502,8 @@ + #define re_stack_check_func RegExpMacroAssemblerMIPS::CheckStackGuardState + #elif V8_TARGET_ARCH_S390 + #define re_stack_check_func RegExpMacroAssemblerS390::CheckStackGuardState ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++#define re_stack_check_func RegExpMacroAssemblerRISCV::CheckStackGuardState + #else + UNREACHABLE(); + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc ++++ b/src/3rdparty/chromium/v8/src/codegen/interface-descriptors.cc +@@ -397,7 +397,9 @@ + } + #endif // !V8_TARGET_ARCH_IA32 + +-#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) ++// FIXME(RISCV): Review this once atomics are added ++#if !defined(V8_TARGET_ARCH_MIPS) && !defined(V8_TARGET_ARCH_MIPS64) && \ ++ !defined(V8_TARGET_ARCH_RISCV64) && !defined(V8_TARGET_ARCH_RISCV) + void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( + CallInterfaceDescriptorData* data) { + DefaultInitializePlatformSpecific(data, kParameterCount); +--- a/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h ++++ b/src/3rdparty/chromium/v8/src/codegen/macro-assembler.h +@@ -52,6 +52,12 @@ + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/constants-s390.h" + #include "src/codegen/s390/macro-assembler-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/codegen/riscv64/macro-assembler-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/codegen/riscv/constants-riscv.h" ++#include "src/codegen/riscv/macro-assembler-riscv.h" + #else + #error Unsupported target architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/register-arch.h ++++ b/src/3rdparty/chromium/v8/src/codegen/register-arch.h +@@ -24,6 +24,10 @@ + #include "src/codegen/mips64/register-mips64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/codegen/s390/register-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/codegen/riscv64/register-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/codegen/riscv/register-riscv.h" + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc ++++ b/src/3rdparty/chromium/v8/src/codegen/register-configuration.cc +@@ -64,6 +64,8 @@ + kMaxAllocatableDoubleRegisterCount; + #elif V8_TARGET_ARCH_S390 + kMaxAllocatableDoubleRegisterCount; ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ kMaxAllocatableDoubleRegisterCount; + #else + #error Unsupported target architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc ++++ b/src/3rdparty/chromium/v8/src/codegen/reloc-info.cc +@@ -330,7 +330,8 @@ + return false; + #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_MIPS) || \ + defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_PPC) || \ +- defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) ++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_S390) || \ ++ defined(V8_TARGET_ARCH_RISCV64) || defined(V8_TARGET_ARCH_RISCV) + return true; + #endif + } +--- a/src/3rdparty/chromium/v8/src/codegen/reloc-info.h ++++ b/src/3rdparty/chromium/v8/src/codegen/reloc-info.h +@@ -69,7 +69,7 @@ + EXTERNAL_REFERENCE, // The address of an external C++ function. + INTERNAL_REFERENCE, // An address inside the same function. + +- // Encoded internal reference, used only on MIPS, MIPS64 and PPC. ++ // Encoded internal reference, used only on RISCV64, MIPS, MIPS64 and PPC. + INTERNAL_REFERENCE_ENCODED, + + // An off-heap instruction stream target. See http://goo.gl/Z2HUiM. +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64-inl.h +@@ -0,0 +1,247 @@ ++ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#ifndef V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ ++#define V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/riscv64/assembler-riscv64.h" ++#include "src/debug/debug.h" ++#include "src/objects/objects-inl.h" ++ ++namespace v8 { ++namespace internal { ++ ++bool CpuFeatures::SupportsOptimizer() { return IsSupported(FPU); } ++ ++bool CpuFeatures::SupportsWasmSimd128() { return IsSupported(RISCV_SIMD); } ++ ++// ----------------------------------------------------------------------------- ++// Operand and MemOperand. ++ ++bool Operand::is_reg() const { return rm_.is_valid(); } ++ ++int64_t Operand::immediate() const { ++ DCHECK(!is_reg()); ++ DCHECK(!IsHeapObjectRequest()); ++ return value_.immediate; ++} ++ ++// ----------------------------------------------------------------------------- ++// RelocInfo. ++ ++void RelocInfo::apply(intptr_t delta) { ++ if (IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_)) { ++ // Absolute code pointer inside code object moves with the code object. ++ Assembler::RelocateInternalReference(rmode_, pc_, delta); ++ } ++} ++ ++Address RelocInfo::target_address() { ++ DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++Address RelocInfo::target_address_address() { ++ DCHECK(HasTargetAddressAddress()); ++ // Read the address of the word containing the target_address in an ++ // instruction stream. ++ // The only architecture-independent user of this function is the serializer. ++ // The serializer uses it to find out how many raw bytes of instruction to ++ // output before the next target. ++ // For an instruction like LUI/ORI where the target bits are mixed into the ++ // instruction bits, the size of the target will be zero, indicating that the ++ // serializer should not step forward in memory after a target is resolved ++ // and written. In this case the target_address_address function should ++ // return the end of the instructions to be patched, allowing the ++ // deserializer to deserialize the instructions as raw bytes and put them in ++ // place, ready to be patched with the target. After jump optimization, ++ // that is the address of the instruction that follows J/JAL/JR/JALR ++ // instruction. ++ return pc_ + Assembler::kInstructionsFor64BitConstant * kInstrSize; ++} ++ ++Address RelocInfo::constant_pool_entry_address() { UNREACHABLE(); } ++ ++int RelocInfo::target_address_size() { return Assembler::kSpecialTargetSize; } ++ ++void Assembler::deserialization_set_special_target_at( ++ Address instruction_payload, Code code, Address target) { ++ set_target_address_at(instruction_payload, ++ !code.is_null() ? code.constant_pool() : kNullAddress, ++ target); ++} ++ ++int Assembler::deserialization_special_target_size( ++ Address instruction_payload) { ++ return kSpecialTargetSize; ++} ++ ++void Assembler::set_target_internal_reference_encoded_at(Address pc, ++ Address target) { ++ set_target_value_at(pc, static_cast(target)); ++} ++ ++void Assembler::deserialization_set_target_internal_reference_at( ++ Address pc, Address target, RelocInfo::Mode mode) { ++ if (RelocInfo::IsInternalReferenceEncoded(mode)) { ++ DCHECK(IsLui(instr_at(pc))); ++ set_target_internal_reference_encoded_at(pc, target); ++ } else { ++ DCHECK(RelocInfo::IsInternalReference(mode)); ++ Memory
(pc) = target; ++ } ++} ++ ++HeapObject RelocInfo::target_object() { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ return HeapObject::cast( ++ Object(Assembler::target_address_at(pc_, constant_pool_))); ++} ++ ++HeapObject RelocInfo::target_object_no_host(Isolate* isolate) { ++ return target_object(); ++} ++ ++Handle RelocInfo::target_object_handle(Assembler* origin) { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ return Handle(reinterpret_cast( ++ Assembler::target_address_at(pc_, constant_pool_))); ++} ++ ++void RelocInfo::set_target_object(Heap* heap, HeapObject target, ++ WriteBarrierMode write_barrier_mode, ++ ICacheFlushMode icache_flush_mode) { ++ DCHECK(IsCodeTarget(rmode_) || IsFullEmbeddedObject(rmode_)); ++ Assembler::set_target_address_at(pc_, constant_pool_, target.ptr(), ++ icache_flush_mode); ++ if (write_barrier_mode == UPDATE_WRITE_BARRIER && !host().is_null() && ++ !FLAG_disable_write_barriers) { ++ WriteBarrierForCode(host(), this, target); ++ } ++} ++ ++Address RelocInfo::target_external_reference() { ++ DCHECK(rmode_ == EXTERNAL_REFERENCE); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++void RelocInfo::set_target_external_reference( ++ Address target, ICacheFlushMode icache_flush_mode) { ++ DCHECK(rmode_ == RelocInfo::EXTERNAL_REFERENCE); ++ Assembler::set_target_address_at(pc_, constant_pool_, target, ++ icache_flush_mode); ++} ++ ++Address RelocInfo::target_internal_reference() { ++ if (rmode_ == INTERNAL_REFERENCE) { ++ return Memory
(pc_); ++ } else { ++ // Encoded internal references are j/jal instructions. ++ DCHECK(rmode_ == INTERNAL_REFERENCE_ENCODED); ++ DCHECK(Assembler::IsLui(Assembler::instr_at(pc_ + 0 * kInstrSize))); ++ Address address = Assembler::target_address_at(pc_); ++ return address; ++ } ++} ++ ++Address RelocInfo::target_internal_reference_address() { ++ DCHECK(rmode_ == INTERNAL_REFERENCE || rmode_ == INTERNAL_REFERENCE_ENCODED); ++ return pc_; ++} ++ ++Address RelocInfo::target_runtime_entry(Assembler* origin) { ++ DCHECK(IsRuntimeEntry(rmode_)); ++ return target_address(); ++} ++ ++void RelocInfo::set_target_runtime_entry(Address target, ++ WriteBarrierMode write_barrier_mode, ++ ICacheFlushMode icache_flush_mode) { ++ DCHECK(IsRuntimeEntry(rmode_)); ++ if (target_address() != target) ++ set_target_address(target, write_barrier_mode, icache_flush_mode); ++} ++ ++Address RelocInfo::target_off_heap_target() { ++ DCHECK(IsOffHeapTarget(rmode_)); ++ return Assembler::target_address_at(pc_, constant_pool_); ++} ++ ++void RelocInfo::WipeOut() { ++ DCHECK(IsFullEmbeddedObject(rmode_) || IsCodeTarget(rmode_) || ++ IsRuntimeEntry(rmode_) || IsExternalReference(rmode_) || ++ IsInternalReference(rmode_) || IsInternalReferenceEncoded(rmode_) || ++ IsOffHeapTarget(rmode_)); ++ if (IsInternalReference(rmode_)) { ++ Memory
(pc_) = kNullAddress; ++ } else if (IsInternalReferenceEncoded(rmode_)) { ++ Assembler::set_target_internal_reference_encoded_at(pc_, kNullAddress); ++ } else { ++ Assembler::set_target_address_at(pc_, constant_pool_, kNullAddress); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Assembler. ++ ++void Assembler::CheckBuffer() { ++ if (buffer_space() <= kGap) { ++ GrowBuffer(); ++ } ++} ++ ++template ++void Assembler::EmitHelper(T x) { ++ DEBUG_PRINTF("%p: ", pc_); ++ disassembleInstr((int)x); ++ *reinterpret_cast(pc_) = x; ++ pc_ += sizeof(x); ++ CheckTrampolinePoolQuick(); ++} ++ ++void Assembler::emit(Instr x) { ++ if (!is_buffer_growth_blocked()) { ++ CheckBuffer(); ++ } ++ EmitHelper(x); ++} ++ ++EnsureSpace::EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_RISCV_ASSEMBLER_RISCV_INL_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64.cc +@@ -0,0 +1,2342 @@ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/riscv64/assembler-riscv64.h" ++ ++#include "src/base/cpu.h" ++#include "src/codegen/riscv64/assembler-riscv64-inl.h" ++#include "src/codegen/safepoint-table.h" ++#include "src/codegen/string-constants.h" ++#include "src/deoptimizer/deoptimizer.h" ++#include "src/diagnostics/disasm.h" ++#include "src/diagnostics/disassembler.h" ++#include "src/objects/heap-number-inl.h" ++ ++namespace v8 { ++namespace internal { ++// Get the CPU features enabled by the build. For cross compilation the ++// preprocessor symbols CAN_USE_FPU_INSTRUCTIONS ++// can be defined to enable FPU instructions when building the ++// snapshot. ++static unsigned CpuFeaturesImpliedByCompiler() { ++ unsigned answer = 0; ++#ifdef CAN_USE_FPU_INSTRUCTIONS ++ answer |= 1u << FPU; ++#endif // def CAN_USE_FPU_INSTRUCTIONS ++ ++ return answer; ++} ++ ++void CpuFeatures::ProbeImpl(bool cross_compile) { ++ supported_ |= CpuFeaturesImpliedByCompiler(); ++ ++ // Only use statically determined features for cross compile (snapshot). ++ if (cross_compile) return; ++ ++ // Probe for additional features at runtime. ++ base::CPU cpu; ++ if (cpu.has_fpu()) supported_ |= 1u << FPU; ++} ++ ++void CpuFeatures::PrintTarget() {} ++void CpuFeatures::PrintFeatures() {} ++ ++int ToNumber(Register reg) { ++ DCHECK(reg.is_valid()); ++ const int kNumbers[] = { ++ 0, // zero_reg ++ 1, // ra ++ 2, // sp ++ 3, // gp ++ 4, // tp ++ 5, // t0 ++ 6, // t1 ++ 7, // t2 ++ 8, // s0/fp ++ 9, // s1 ++ 10, // a0 ++ 11, // a1 ++ 12, // a2 ++ 13, // a3 ++ 14, // a4 ++ 15, // a5 ++ 16, // a6 ++ 17, // a7 ++ 18, // s2 ++ 19, // s3 ++ 20, // s4 ++ 21, // s5 ++ 22, // s6 ++ 23, // s7 ++ 24, // s8 ++ 25, // s9 ++ 26, // s10 ++ 27, // s11 ++ 28, // t3 ++ 29, // t4 ++ 30, // t5 ++ 31, // t6 ++ }; ++ return kNumbers[reg.code()]; ++} ++ ++Register ToRegister(int num) { ++ DCHECK(num >= 0 && num < kNumRegisters); ++ const Register kRegisters[] = { ++ zero_reg, ra, sp, gp, tp, t0, t1, t2, fp, s1, a0, a1, a2, a3, a4, a5, ++ a6, a7, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, t3, t4, t5, t6}; ++ return kRegisters[num]; ++} ++ ++// ----------------------------------------------------------------------------- ++// Implementation of RelocInfo. ++ ++const int RelocInfo::kApplyMask = ++ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | ++ RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); ++ ++bool RelocInfo::IsCodedSpecially() { ++ // The deserializer needs to know whether a pointer is specially coded. Being ++ // specially coded on RISC-V means that it is a lui/addi instruction, and that ++ // is always the case inside code objects. ++ return true; ++} ++ ++bool RelocInfo::IsInConstantPool() { return false; } ++ ++uint32_t RelocInfo::wasm_call_tag() const { ++ DCHECK(rmode_ == WASM_CALL || rmode_ == WASM_STUB_CALL); ++ return static_cast( ++ Assembler::target_address_at(pc_, constant_pool_)); ++} ++ ++// ----------------------------------------------------------------------------- ++// Implementation of Operand and MemOperand. ++// See assembler-riscv64-inl.h for inlined constructors. ++ ++Operand::Operand(Handle handle) ++ : rm_(no_reg), rmode_(RelocInfo::FULL_EMBEDDED_OBJECT) { ++ value_.immediate = static_cast(handle.address()); ++} ++ ++Operand Operand::EmbeddedNumber(double value) { ++ int32_t smi; ++ if (DoubleToSmiInteger(value, &smi)) return Operand(Smi::FromInt(smi)); ++ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); ++ result.is_heap_object_request_ = true; ++ result.value_.heap_object_request = HeapObjectRequest(value); ++ return result; ++} ++ ++Operand Operand::EmbeddedStringConstant(const StringConstantBase* str) { ++ Operand result(0, RelocInfo::FULL_EMBEDDED_OBJECT); ++ result.is_heap_object_request_ = true; ++ result.value_.heap_object_request = HeapObjectRequest(str); ++ return result; ++} ++ ++MemOperand::MemOperand(Register rm, int32_t offset) : Operand(rm) { ++ offset_ = offset; ++} ++ ++MemOperand::MemOperand(Register rm, int32_t unit, int32_t multiplier, ++ OffsetAddend offset_addend) ++ : Operand(rm) { ++ offset_ = unit * multiplier + offset_addend; ++} ++ ++void Assembler::AllocateAndInstallRequestedHeapObjects(Isolate* isolate) { ++ DCHECK_IMPLIES(isolate == nullptr, heap_object_requests_.empty()); ++ for (auto& request : heap_object_requests_) { ++ Handle object; ++ switch (request.kind()) { ++ case HeapObjectRequest::kHeapNumber: ++ object = isolate->factory()->NewHeapNumber( ++ request.heap_number()); ++ break; ++ case HeapObjectRequest::kStringConstant: ++ const StringConstantBase* str = request.string(); ++ CHECK_NOT_NULL(str); ++ object = str->AllocateStringConstant(isolate); ++ break; ++ } ++ Address pc = reinterpret_cast
(buffer_start_) + request.offset(); ++ set_target_value_at(pc, reinterpret_cast(object.location())); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Specific instructions, constants, and masks. ++ ++Assembler::Assembler(const AssemblerOptions& options, ++ std::unique_ptr buffer) ++ : AssemblerBase(options, std::move(buffer)), ++ scratch_register_list_(t3.bit()) { ++ reloc_info_writer.Reposition(buffer_start_ + buffer_->size(), pc_); ++ ++ last_trampoline_pool_end_ = 0; ++ no_trampoline_pool_before_ = 0; ++ trampoline_pool_blocked_nesting_ = 0; ++ // We leave space (16 * kTrampolineSlotsSize) ++ // for BlockTrampolinePoolScope buffer. ++ next_buffer_check_ = FLAG_force_long_branches ++ ? kMaxInt ++ : kMaxBranchOffset - kTrampolineSlotsSize * 16; ++ internal_trampoline_exception_ = false; ++ last_bound_pos_ = 0; ++ ++ trampoline_emitted_ = FLAG_force_long_branches; ++ unbound_labels_count_ = 0; ++ block_buffer_growth_ = false; ++} ++ ++void Assembler::GetCode(Isolate* isolate, CodeDesc* desc, ++ SafepointTableBuilder* safepoint_table_builder, ++ int handler_table_offset) { ++ int code_comments_size = WriteCodeComments(); ++ ++ DCHECK(pc_ <= reloc_info_writer.pos()); // No overlap. ++ ++ AllocateAndInstallRequestedHeapObjects(isolate); ++ ++ // Set up code descriptor. ++ // TODO(jgruber): Reconsider how these offsets and sizes are maintained up to ++ // this point to make CodeDesc initialization less fiddly. ++ ++ static constexpr int kConstantPoolSize = 0; ++ const int instruction_size = pc_offset(); ++ const int code_comments_offset = instruction_size - code_comments_size; ++ const int constant_pool_offset = code_comments_offset - kConstantPoolSize; ++ const int handler_table_offset2 = (handler_table_offset == kNoHandlerTable) ++ ? constant_pool_offset ++ : handler_table_offset; ++ const int safepoint_table_offset = ++ (safepoint_table_builder == kNoSafepointTable) ++ ? handler_table_offset2 ++ : safepoint_table_builder->GetCodeOffset(); ++ const int reloc_info_offset = ++ static_cast(reloc_info_writer.pos() - buffer_->start()); ++ CodeDesc::Initialize(desc, this, safepoint_table_offset, ++ handler_table_offset2, constant_pool_offset, ++ code_comments_offset, reloc_info_offset); ++} ++ ++void Assembler::Align(int m) { ++ DCHECK(m >= 4 && base::bits::IsPowerOfTwo(m)); ++ while ((pc_offset() & (m - 1)) != 0) { ++ nop(); ++ } ++} ++ ++void Assembler::CodeTargetAlign() { ++ // No advantage to aligning branch/call targets to more than ++ // single instruction, that I am aware of. ++ Align(4); ++} ++ ++// Labels refer to positions in the (to be) generated code. ++// There are bound, linked, and unused labels. ++// ++// Bound labels refer to known positions in the already ++// generated code. pos() is the position the label refers to. ++// ++// Linked labels refer to unknown positions in the code ++// to be generated; pos() is the position of the last ++// instruction using the label. ++ ++// The link chain is terminated by a value in the instruction of 0, ++// which is an otherwise illegal value (branch 0 is inf loop). ++ ++const int kEndOfChain = 0; ++ ++// Determines the end of the Jump chain (a subset of the label link chain). ++const int kEndOfJumpChain = 0; ++ ++bool Assembler::IsBranch(Instr instr) { ++ return (instr & kBaseOpcodeMask) == BRANCH; ++} ++ ++bool Assembler::IsJump(Instr instr) { ++ int Op = instr & kBaseOpcodeMask; ++ return Op == JAL || Op == JALR; ++} ++ ++bool Assembler::IsJal(Instr instr) { return (instr & kBaseOpcodeMask) == JAL; } ++ ++bool Assembler::IsJalr(Instr instr) { ++ return (instr & kBaseOpcodeMask) == JALR; ++} ++ ++bool Assembler::IsLui(Instr instr) { return (instr & kBaseOpcodeMask) == LUI; } ++bool Assembler::IsAuipc(Instr instr) { return (instr & kBaseOpcodeMask) == AUIPC; } ++bool Assembler::IsAddiw(Instr instr) { ++ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_ADDIW; ++} ++bool Assembler::IsAddi(Instr instr) { ++ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_ADDI; ++} ++bool Assembler::IsSlli(Instr instr) { ++ return (instr & (kBaseOpcodeMask | kFunct3Mask)) == RO_SLLI; ++} ++int Assembler::target_at(int pos, bool is_internal) { ++ if (is_internal) { ++ int64_t* p = reinterpret_cast(buffer_start_ + pos); ++ int64_t address = *p; ++ if (address == kEndOfJumpChain) { ++ return kEndOfChain; ++ } else { ++ int64_t instr_address = reinterpret_cast(p); ++ DCHECK(instr_address - address < INT_MAX); ++ int delta = static_cast(instr_address - address); ++ DCHECK(pos > delta); ++ return pos - delta; ++ } ++ } ++ Instr instr = instr_at(pos); ++ DEBUG_PRINTF("target_at: %p (%d)\n\t", ++ reinterpret_cast(buffer_start_ + pos), pos); ++ disassembleInstr(instr); ++ if (IsBranch(instr)) { ++ int32_t imm13 = BranchOffset(instr); ++ if (imm13 == kEndOfJumpChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or pos. ++ return kEndOfChain; ++ } else { ++ return pos + imm13; ++ } ++ } else if (IsJal(instr)) { ++ int32_t imm21 = JumpOffset(instr); ++ if (imm21 == kEndOfJumpChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or pos. ++ return kEndOfChain; ++ } else { ++ return pos + imm21; ++ } ++ } else if (IsJalr(instr)) { ++ int32_t imm12 = instr >> 20; ++ if (imm12 == kEndOfJumpChain) { ++ // EndOfChain sentinel is returned directly, not relative to pc or pos. ++ return kEndOfChain; ++ } else { ++ return pos + imm12; ++ } ++ } else if (IsLui(instr)) { ++ Address pc = reinterpret_cast
(buffer_start_ + pos); ++ pc = target_address_at(pc); ++ uint64_t instr_address = reinterpret_cast(buffer_start_ + pos); ++ uint64_t imm = reinterpret_cast(pc); ++ if(imm == kEndOfJumpChain) { ++ return kEndOfChain; ++ } else { ++ DCHECK(instr_address - imm < INT_MAX); ++ int32_t delta = static_cast(instr_address - imm); ++ DCHECK(pos > delta); ++ return pos - delta; ++ } ++ } else if (IsAuipc(instr)) { ++ Instr instr_auipc = instr; ++ Instr instr_jalr = instr_at(pos + 4); ++ DCHECK(IsJalr(instr_jalr)); ++ int32_t offset = BrachlongOffset(instr_auipc, instr_jalr); ++ if(offset == kEndOfJumpChain) ++ return kEndOfChain; ++ return offset + pos; ++ } else { ++ // Emitted label constant, not part of a branch. ++ if (instr == 0) { ++ return kEndOfChain; ++ } else { ++ int32_t imm18 = ((instr & static_cast(kImm16Mask)) << 16) >> 14; ++ return (imm18 + pos); ++ } ++ } ++} ++ ++static inline Instr SetBranchOffset(int32_t pos, int32_t target_pos, ++ Instr instr) { ++ int32_t imm = target_pos - pos; ++ DCHECK_EQ(imm & 1, 0); ++ DCHECK(is_intn(imm, Assembler::kBranchOffsetBits)); ++ ++ instr &= ~kBImm12Mask; ++ int32_t imm12 = ((imm & 0x800) >> 4) | // bit 11 ++ ((imm & 0x1e) << 7) | // bits 4-1 ++ ((imm & 0x7e0) << 20) | // bits 10-5 ++ ((imm & 0x1000) << 19); // bit 12 ++ ++ return instr | (imm12 & kBImm12Mask); ++} ++ ++static inline Instr SetJalOffset(int32_t pos, int32_t target_pos, Instr instr) { ++ int32_t imm = target_pos - pos; ++ DCHECK_EQ(imm & 1, 0); ++ DCHECK(is_intn(imm, Assembler::kJumpOffsetBits)); ++ ++ instr &= ~kImm20Mask; ++ int32_t imm20 = (imm & 0xff000) | // bits 19-12 ++ ((imm & 0x800) << 9) | // bit 11 ++ ((imm & 0x7fe) << 20) | // bits 10-1 ++ ((imm & 0x100000) << 11); // bit 20 ++ ++ return instr | (imm20 & kImm20Mask); ++} ++ ++void Assembler::target_at_put(int pos, int target_pos, bool is_internal) { ++ if (is_internal) { ++ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; ++ *reinterpret_cast(buffer_start_ + pos) = imm; ++ return; ++ } ++ DEBUG_PRINTF("target_at_put: %p (%d) to %p (%d)\n", ++ reinterpret_cast(buffer_start_ + pos), pos, ++ reinterpret_cast(buffer_start_ + target_pos), ++ target_pos); ++ Instr instr = instr_at(pos); ++ ++ if (IsBranch(instr)) { ++ instr = SetBranchOffset(pos, target_pos, instr); ++ instr_at_put(pos, instr); ++ } else if (IsJal(instr)) { ++ instr = SetJalOffset(pos, target_pos, instr); ++ instr_at_put(pos, instr); ++ } else if (IsLui(instr)) { ++ Address pc = reinterpret_cast
(buffer_start_ + pos); ++ set_target_value_at(pc, reinterpret_cast(buffer_start_ + target_pos)); ++ } else if (IsAuipc(instr)) { ++ Instr instr_auipc = instr; ++ Instr instr_jalr = instr_at(pos + 4); ++ DCHECK(IsJalr(instr_jalr)); ++ ++ int64_t offset = target_pos - pos; ++ DCHECK(is_int32(offset)); ++ ++ int32_t Hi20 = (((int32_t)offset + 0x800) >> 12); ++ int32_t Lo12 = (int32_t)offset << 20 >> 20; ++ ++ const int kImm31_12Mask = ((1 << 20) - 1) << 12; ++ const int kImm19_0Mask = ((1 << 20) - 1); ++ instr_auipc = (instr_auipc & ~kImm31_12Mask) | ++ ((Hi20 & kImm19_0Mask) << 12); ++ instr_at_put(pos, instr_auipc); ++ ++ const int kImm31_20Mask = ((1 << 12) - 1) << 20; ++ const int kImm11_0Mask = ((1 << 12) - 1); ++ instr_jalr = (instr_jalr & ~kImm31_20Mask) | ++ ((Lo12 & kImm11_0Mask) << 20); ++ instr_at_put(pos + 4, instr_jalr); ++ } else { ++ // Emitted label constant, not part of a branch. ++ // Make label relative to Code pointer of generated Code object. ++ instr_at_put(pos, target_pos + (Code::kHeaderSize - kHeapObjectTag)); ++ } ++ disassembleInstr(instr); ++} ++ ++void Assembler::print(const Label* L) { ++ if (L->is_unused()) { ++ PrintF("unused label\n"); ++ } else if (L->is_bound()) { ++ PrintF("bound label to %d\n", L->pos()); ++ } else if (L->is_linked()) { ++ Label l; ++ l.link_to(L->pos()); ++ PrintF("unbound label"); ++ while (l.is_linked()) { ++ PrintF("@ %d ", l.pos()); ++ Instr instr = instr_at(l.pos()); ++ if ((instr & ~kImm16Mask) == 0) { ++ PrintF("value\n"); ++ } else { ++ PrintF("%d\n", instr); ++ } ++ next(&l, is_internal_reference(&l)); ++ } ++ } else { ++ PrintF("label in inconsistent state (pos = %d)\n", L->pos_); ++ } ++} ++ ++void Assembler::bind_to(Label* L, int pos) { ++ DCHECK(0 <= pos && pos <= pc_offset()); // Must have valid binding position. ++ DEBUG_PRINTF("binding %d to label %p\n", pos, L); ++ int trampoline_pos = kInvalidSlotPos; ++ bool is_internal = false; ++ if (L->is_linked() && !trampoline_emitted_) { ++ unbound_labels_count_--; ++ if (!is_internal_reference(L)) { ++ next_buffer_check_ += kTrampolineSlotsSize; ++ } ++ } ++ ++ while (L->is_linked()) { ++ int fixup_pos = L->pos(); ++ int dist = pos - fixup_pos; ++ is_internal = is_internal_reference(L); ++ next(L, is_internal); // Call next before overwriting link with target ++ // at fixup_pos. ++ Instr instr = instr_at(fixup_pos); ++ DEBUG_PRINTF("\tfixup: %d to %d\n", fixup_pos, dist); ++ if (is_internal) { ++ target_at_put(fixup_pos, pos, is_internal); ++ } else { ++ if (IsBranch(instr)) { ++ if (dist > kMaxBranchOffset) { ++ if (trampoline_pos == kInvalidSlotPos) { ++ trampoline_pos = get_trampoline_entry(fixup_pos); ++ CHECK_NE(trampoline_pos, kInvalidSlotPos); ++ } ++ CHECK((trampoline_pos - fixup_pos) <= kMaxBranchOffset); ++ DEBUG_PRINTF("\t\ttrampolining: %d\n", trampoline_pos); ++ target_at_put(fixup_pos, trampoline_pos, false); ++ fixup_pos = trampoline_pos; ++ } ++ target_at_put(fixup_pos, pos, false); ++ } else if (IsJal(instr)) { ++ if (dist > kMaxJumpOffset) { ++ if (trampoline_pos == kInvalidSlotPos) { ++ trampoline_pos = get_trampoline_entry(fixup_pos); ++ CHECK_NE(trampoline_pos, kInvalidSlotPos); ++ } ++ CHECK((trampoline_pos - fixup_pos) <= kMaxJumpOffset); ++ DEBUG_PRINTF("\t\ttrampolining: %d\n", trampoline_pos); ++ target_at_put(fixup_pos, trampoline_pos, false); ++ fixup_pos = trampoline_pos; ++ } ++ target_at_put(fixup_pos, pos, false); ++ } else { ++ target_at_put(fixup_pos, pos, false); ++ } ++ } ++ } ++ L->bind_to(pos); ++ ++ // Keep track of the last bound label so we don't eliminate any instructions ++ // before a bound label. ++ if (pos > last_bound_pos_) last_bound_pos_ = pos; ++} ++ ++void Assembler::bind(Label* L) { ++ DCHECK(!L->is_bound()); // Label can only be bound once. ++ bind_to(L, pc_offset()); ++} ++ ++void Assembler::next(Label* L, bool is_internal) { ++ DCHECK(L->is_linked()); ++ int link = target_at(L->pos(), is_internal); ++ if (link == kEndOfChain) { ++ L->Unuse(); ++ } else { ++ DCHECK_GT(link, 0); ++ DEBUG_PRINTF("next: %p to %p (%d)\n", L, ++ reinterpret_cast(buffer_start_ + link), link); ++ L->link_to(link); ++ } ++} ++ ++bool Assembler::is_near(Label* L) { ++ DCHECK(L->is_bound()); ++ return is_intn((pc_offset() - L->pos()), kJumpOffsetBits); ++} ++ ++bool Assembler::is_near(Label* L, OffsetSize bits) { ++ if (L == nullptr || !L->is_bound()) return true; ++ return is_intn((pc_offset() - L->pos()), bits); ++} ++ ++bool Assembler::is_near_branch(Label* L) { ++ DCHECK(L->is_bound()); ++ return is_intn((pc_offset() - L->pos()), kBranchOffsetBits); ++} ++ ++int Assembler::BranchOffset(Instr instr) { ++ // | imm[12] | imm[10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode | ++ // 31 25 11 7 ++ int32_t imm13 = ((instr & 0xf00) >> 7) | ((instr & 0x7e000000) >> 20) | ++ ((instr & 0x80) << 4) | ((instr & 0x80000000) >> 19); ++ imm13 = imm13 << 19 >> 19; ++ return imm13; ++} ++ ++int Assembler::JumpOffset(Instr instr) { ++ int32_t imm21 = ((instr & 0x7fe00000) >> 20) | ((instr & 0x100000) >> 9) | ++ (instr & 0xff000) | ((instr & 0x80000000) >> 11); ++ imm21 = imm21 << 11 >> 11; ++ return imm21; ++} ++ ++int Assembler::BrachlongOffset(Instr auipc, Instr jalr) { ++ const int kImm19_0Mask = ((1 << 20) - 1); ++ int32_t imm_auipc = auipc & (kImm19_0Mask << 12); ++ int32_t imm_jalr = jalr >> 20; ++ int32_t offset = imm_jalr + imm_auipc; ++ return offset; ++} ++ ++// We have to use a temporary register for things that can be relocated even ++// if they can be encoded in RISC-V's 12 bits of immediate-offset instruction ++// space. There is no guarantee that the relocated location can be similarly ++// encoded. ++bool Assembler::MustUseReg(RelocInfo::Mode rmode) { ++ return !RelocInfo::IsNone(rmode); ++} ++ ++void Assembler::disassembleInstr(Instr instr) { ++ if (!FLAG_debug_riscv) return; ++ disasm::NameConverter converter; ++ disasm::Disassembler disasm(converter); ++ EmbeddedVector disasm_buffer; ++ ++ disasm.InstructionDecode(disasm_buffer, reinterpret_cast(&instr)); ++ DEBUG_PRINTF("%s\n", disasm_buffer.begin()); ++} ++ ++// ----- Top-level instruction formats match those in the ISA manual ++// (R, I, S, B, U, J). These match the formats defined in the compiler ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ Register rd, Register rs1, Register rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ Register rd, FPURegister rs1, Register rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ FPURegister rd, Register rs1, Register rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ FPURegister rd, FPURegister rs1, Register rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, ++ Register rd, FPURegister rs1, FPURegister rs2) { ++ DCHECK(is_uint7(funct7) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR4(uint8_t funct2, Opcode opcode, Register rd, ++ Register rs1, Register rs2, Register rs3, ++ RoundingMode frm) { ++ DCHECK(is_uint2(funct2) && rd.is_valid() && rs1.is_valid() && ++ rs2.is_valid() && rs3.is_valid() && is_uint3(frm)); ++ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct2 << kFunct2Shift) | (rs3.code() << kRs3Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrR4(uint8_t funct2, Opcode opcode, FPURegister rd, ++ FPURegister rs1, FPURegister rs2, FPURegister rs3, ++ RoundingMode frm) { ++ DCHECK(is_uint2(funct2) && rd.is_valid() && rs1.is_valid() && ++ rs2.is_valid() && rs3.is_valid() && is_uint3(frm)); ++ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct2 << kFunct2Shift) | (rs3.code() << kRs3Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrRAtomic(uint8_t funct5, bool aq, bool rl, ++ uint8_t funct3, Register rd, Register rs1, ++ Register rs2) { ++ DCHECK(is_uint5(funct5) && is_uint3(funct3) && rd.is_valid() && ++ rs1.is_valid() && rs2.is_valid()); ++ Instr instr = AMO | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (rl << kRlShift) | (aq << kAqShift) | (funct5 << kFunct5Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrRFrm(uint8_t funct7, Opcode opcode, Register rd, ++ Register rs1, Register rs2, RoundingMode frm) { ++ DCHECK(rd.is_valid() && rs1.is_valid() && rs2.is_valid() && is_uint3(frm)); ++ Instr instr = opcode | (rd.code() << kRdShift) | (frm << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (rs2.code() << kRs2Shift) | ++ (funct7 << kFunct7Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrI(uint8_t funct3, Opcode opcode, Register rd, ++ Register rs1, int16_t imm12) { ++ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && ++ (is_uint12(imm12) || is_int12(imm12))); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (imm12 << kImm12Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrI(uint8_t funct3, Opcode opcode, FPURegister rd, ++ Register rs1, int16_t imm12) { ++ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && ++ (is_uint12(imm12) || is_int12(imm12))); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (imm12 << kImm12Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrIShift(bool arithshift, uint8_t funct3, Opcode opcode, ++ Register rd, Register rs1, uint8_t shamt) { ++ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && ++ is_uint6(shamt)); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (shamt << kShamtShift) | ++ (arithshift << kArithShiftShift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrIShiftW(bool arithshift, uint8_t funct3, Opcode opcode, ++ Register rd, Register rs1, uint8_t shamt) { ++ DCHECK(is_uint3(funct3) && rd.is_valid() && rs1.is_valid() && ++ is_uint5(shamt)); ++ Instr instr = opcode | (rd.code() << kRdShift) | (funct3 << kFunct3Shift) | ++ (rs1.code() << kRs1Shift) | (shamt << kShamtWShift) | ++ (arithshift << kArithShiftShift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, ++ Register rs2, int16_t imm12) { ++ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && ++ is_int12(imm12)); ++ Instr instr = opcode | ((imm12 & 0x1f) << 7) | // bits 4-0 ++ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | ++ (rs2.code() << kRs2Shift) | ++ ((imm12 & 0xfe0) << 20); // bits 11-5 ++ emit(instr); ++} ++ ++void Assembler::GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, ++ FPURegister rs2, int16_t imm12) { ++ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && ++ is_int12(imm12)); ++ Instr instr = opcode | ((imm12 & 0x1f) << 7) | // bits 4-0 ++ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | ++ (rs2.code() << kRs2Shift) | ++ ((imm12 & 0xfe0) << 20); // bits 11-5 ++ emit(instr); ++} ++ ++void Assembler::GenInstrB(uint8_t funct3, Opcode opcode, Register rs1, ++ Register rs2, int16_t imm13) { ++ DCHECK(is_uint3(funct3) && rs1.is_valid() && rs2.is_valid() && ++ is_int13(imm13) && ((imm13 & 1) == 0)); ++ Instr instr = opcode | ((imm13 & 0x800) >> 4) | // bit 11 ++ ((imm13 & 0x1e) << 7) | // bits 4-1 ++ (funct3 << kFunct3Shift) | (rs1.code() << kRs1Shift) | ++ (rs2.code() << kRs2Shift) | ++ ((imm13 & 0x7e0) << 20) | // bits 10-5 ++ ((imm13 & 0x1000) << 19); // bit 12 ++ emit(instr); ++} ++ ++void Assembler::GenInstrU(Opcode opcode, Register rd, int32_t imm20) { ++ DCHECK(rd.is_valid() && (is_int20(imm20) || is_uint20(imm20))); ++ Instr instr = opcode | (rd.code() << kRdShift) | (imm20 << kImm20Shift); ++ emit(instr); ++} ++ ++void Assembler::GenInstrJ(Opcode opcode, Register rd, int32_t imm21) { ++ DCHECK(rd.is_valid() && is_int21(imm21) && ((imm21 & 1) == 0)); ++ Instr instr = opcode | (rd.code() << kRdShift) | ++ (imm21 & 0xff000) | // bits 19-12 ++ ((imm21 & 0x800) << 9) | // bit 11 ++ ((imm21 & 0x7fe) << 20) | // bits 10-1 ++ ((imm21 & 0x100000) << 11); // bit 20 ++ emit(instr); ++} ++ ++// ----- Instruction class templates match those in the compiler ++ ++void Assembler::GenInstrBranchCC_rri(uint8_t funct3, Register rs1, Register rs2, ++ int16_t imm13) { ++ GenInstrB(funct3, BRANCH, rs1, rs2, imm13); ++} ++ ++void Assembler::GenInstrLoad_ri(uint8_t funct3, Register rd, Register rs1, ++ int16_t imm12) { ++ GenInstrI(funct3, LOAD, rd, rs1, imm12); ++} ++ ++void Assembler::GenInstrStore_rri(uint8_t funct3, Register rs1, Register rs2, ++ int16_t imm12) { ++ GenInstrS(funct3, STORE, rs1, rs2, imm12); ++} ++ ++void Assembler::GenInstrALU_ri(uint8_t funct3, Register rd, Register rs1, ++ int16_t imm12) { ++ GenInstrI(funct3, OP_IMM, rd, rs1, imm12); ++} ++ ++void Assembler::GenInstrShift_ri(bool arithshift, uint8_t funct3, Register rd, ++ Register rs1, uint8_t shamt) { ++ DCHECK(is_uint6(shamt)); ++ GenInstrI(funct3, OP_IMM, rd, rs1, (arithshift << 10) | shamt); ++} ++ ++void Assembler::GenInstrALU_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ Register rs1, Register rs2) { ++ GenInstrR(funct7, funct3, OP, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrCSR_ir(uint8_t funct3, Register rd, ++ ControlStatusReg csr, Register rs1) { ++ GenInstrI(funct3, SYSTEM, rd, rs1, csr); ++} ++ ++void Assembler::GenInstrCSR_ii(uint8_t funct3, Register rd, ++ ControlStatusReg csr, uint8_t imm5) { ++ GenInstrI(funct3, SYSTEM, rd, ToRegister(imm5), csr); ++} ++ ++void Assembler::GenInstrShiftW_ri(bool arithshift, uint8_t funct3, Register rd, ++ Register rs1, uint8_t shamt) { ++ GenInstrIShiftW(arithshift, funct3, OP_IMM_32, rd, rs1, shamt); ++} ++ ++void Assembler::GenInstrALUW_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ Register rs1, Register rs2) { ++ GenInstrR(funct7, funct3, OP_32, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrPriv(uint8_t funct7, Register rs1, Register rs2) { ++ GenInstrR(funct7, 0b000, SYSTEM, ToRegister(0), rs1, rs2); ++} ++ ++void Assembler::GenInstrLoadFP_ri(uint8_t funct3, FPURegister rd, Register rs1, ++ int16_t imm12) { ++ GenInstrI(funct3, LOAD_FP, rd, rs1, imm12); ++} ++ ++void Assembler::GenInstrStoreFP_rri(uint8_t funct3, Register rs1, ++ FPURegister rs2, int16_t imm12) { ++ GenInstrS(funct3, STORE_FP, rs1, rs2, imm12); ++} ++ ++void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ FPURegister rs1, FPURegister rs2) { ++ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ Register rs1, Register rs2) { ++ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ FPURegister rs1, Register rs2) { ++ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ FPURegister rs1, Register rs2) { ++ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); ++} ++ ++void Assembler::GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ FPURegister rs1, FPURegister rs2) { ++ GenInstrR(funct7, funct3, OP_FP, rd, rs1, rs2); ++} ++ ++// Returns the next free trampoline entry. ++int32_t Assembler::get_trampoline_entry(int32_t pos) { ++ int32_t trampoline_entry = kInvalidSlotPos; ++ if (!internal_trampoline_exception_) { ++ if (trampoline_.start() > pos) { ++ trampoline_entry = trampoline_.take_slot(); ++ } ++ ++ if (kInvalidSlotPos == trampoline_entry) { ++ internal_trampoline_exception_ = true; ++ } ++ } ++ return trampoline_entry; ++} ++ ++uint64_t Assembler::jump_address(Label* L) { ++ int64_t target_pos; ++ DEBUG_PRINTF("jump_address: %p to %p (%d)\n", L, ++ reinterpret_cast(buffer_start_ + pc_offset()), ++ pc_offset()); ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ L->link_to(pc_offset()); ++ } else { ++ L->link_to(pc_offset()); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ DEBUG_PRINTF("\tstarted link\n"); ++ return kEndOfJumpChain; ++ } ++ } ++ uint64_t imm = reinterpret_cast(buffer_start_) + target_pos; ++ DCHECK_EQ(imm & 3, 0); ++ ++ return imm; ++} ++ ++uint64_t Assembler::branch_long_offset(Label* L) { ++ int64_t target_pos; ++ ++ DEBUG_PRINTF("branch_long_offset: %p to %p (%d)\n", L, ++ reinterpret_cast(buffer_start_ + pc_offset()), ++ pc_offset()); ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ L->link_to(pc_offset()); ++ } else { ++ L->link_to(pc_offset()); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ DEBUG_PRINTF("\tstarted link\n"); ++ return kEndOfJumpChain; ++ } ++ } ++ int64_t offset = target_pos - pc_offset(); ++ DCHECK_EQ(offset & 3, 0); ++ ++ return static_cast(offset); ++} ++ ++int32_t Assembler::branch_offset_helper(Label* L, OffsetSize bits) { ++ int32_t target_pos; ++ ++ DEBUG_PRINTF("branch_offset_helper: %p to %p (%d)\n", L, ++ reinterpret_cast(buffer_start_ + pc_offset()), ++ pc_offset()); ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ DEBUG_PRINTF("\tbound: %d", target_pos); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); ++ L->link_to(pc_offset()); ++ DEBUG_PRINTF("\tadded to link: %d\n", target_pos); ++ } else { ++ L->link_to(pc_offset()); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ DEBUG_PRINTF("\tstarted link\n"); ++ return kEndOfChain; ++ } ++ } ++ ++ int32_t offset = target_pos - pc_offset(); ++ DCHECK(is_intn(offset, bits)); ++ DCHECK_EQ(offset & 1, 0); ++ DEBUG_PRINTF("\toffset = %d\n", offset); ++ return offset; ++} ++ ++void Assembler::label_at_put(Label* L, int at_offset) { ++ int target_pos; ++ DEBUG_PRINTF("label_at_put: %p @ %p (%d)\n", L, ++ reinterpret_cast(buffer_start_ + at_offset), at_offset); ++ if (L->is_bound()) { ++ target_pos = L->pos(); ++ instr_at_put(at_offset, target_pos + (Code::kHeaderSize - kHeapObjectTag)); ++ } else { ++ if (L->is_linked()) { ++ target_pos = L->pos(); // L's link. ++ int32_t imm18 = target_pos - at_offset; ++ DCHECK_EQ(imm18 & 3, 0); ++ int32_t imm16 = imm18 >> 2; ++ DCHECK(is_int16(imm16)); ++ instr_at_put(at_offset, (imm16 & kImm16Mask)); ++ } else { ++ target_pos = kEndOfChain; ++ instr_at_put(at_offset, 0); ++ if (!trampoline_emitted_) { ++ unbound_labels_count_++; ++ next_buffer_check_ -= kTrampolineSlotsSize; ++ } ++ } ++ L->link_to(at_offset); ++ } ++} ++ ++//===----------------------------------------------------------------------===// ++// Instructions ++//===----------------------------------------------------------------------===// ++ ++void Assembler::lui(Register rd, int32_t imm20) { GenInstrU(LUI, rd, imm20); } ++ ++void Assembler::auipc(Register rd, int32_t imm20) { ++ GenInstrU(AUIPC, rd, imm20); ++} ++ ++// Jumps ++ ++void Assembler::jal(Register rd, int32_t imm21) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ GenInstrJ(JAL, rd, imm21); ++ BlockTrampolinePoolFor(1); ++} ++ ++void Assembler::jalr(Register rd, Register rs1, int16_t imm12) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ GenInstrI(0b000, JALR, rd, rs1, imm12); ++ BlockTrampolinePoolFor(1); ++} ++ ++// Branches ++ ++void Assembler::beq(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b000, rs1, rs2, imm13); ++} ++ ++void Assembler::bne(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b001, rs1, rs2, imm13); ++} ++ ++void Assembler::blt(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b100, rs1, rs2, imm13); ++} ++ ++void Assembler::bge(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b101, rs1, rs2, imm13); ++} ++ ++void Assembler::bltu(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b110, rs1, rs2, imm13); ++} ++ ++void Assembler::bgeu(Register rs1, Register rs2, int16_t imm13) { ++ GenInstrBranchCC_rri(0b111, rs1, rs2, imm13); ++} ++ ++// Loads ++ ++void Assembler::lb(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b000, rd, rs1, imm12); ++} ++ ++void Assembler::lh(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b001, rd, rs1, imm12); ++} ++ ++void Assembler::lw(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b010, rd, rs1, imm12); ++} ++ ++void Assembler::lbu(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b100, rd, rs1, imm12); ++} ++ ++void Assembler::lhu(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b101, rd, rs1, imm12); ++} ++ ++// Stores ++ ++void Assembler::sb(Register source, Register base, int16_t imm12) { ++ GenInstrStore_rri(0b000, base, source, imm12); ++} ++ ++void Assembler::sh(Register source, Register base, int16_t imm12) { ++ GenInstrStore_rri(0b001, base, source, imm12); ++} ++ ++void Assembler::sw(Register source, Register base, int16_t imm12) { ++ GenInstrStore_rri(0b010, base, source, imm12); ++} ++ ++// Arithmetic with immediate ++ ++void Assembler::addi(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b000, rd, rs1, imm12); ++} ++ ++void Assembler::slti(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b010, rd, rs1, imm12); ++} ++ ++void Assembler::sltiu(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b011, rd, rs1, imm12); ++} ++ ++void Assembler::xori(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b100, rd, rs1, imm12); ++} ++ ++void Assembler::ori(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b110, rd, rs1, imm12); ++} ++ ++void Assembler::andi(Register rd, Register rs1, int16_t imm12) { ++ GenInstrALU_ri(0b111, rd, rs1, imm12); ++} ++ ++void Assembler::slli(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShift_ri(0, 0b001, rd, rs1, shamt & 0x3f); ++} ++ ++void Assembler::srli(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShift_ri(0, 0b101, rd, rs1, shamt & 0x3f); ++} ++ ++void Assembler::srai(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShift_ri(1, 0b101, rd, rs1, shamt & 0x3f); ++} ++ ++// Arithmetic ++ ++void Assembler::add(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::sub(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0100000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::sll(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::slt(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::sltu(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::xor_(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b100, rd, rs1, rs2); ++} ++ ++void Assembler::srl(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b101, rd, rs1, rs2); ++} ++ ++void Assembler::sra(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0100000, 0b101, rd, rs1, rs2); ++} ++ ++void Assembler::or_(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b110, rd, rs1, rs2); ++} ++ ++void Assembler::and_(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000000, 0b111, rd, rs1, rs2); ++} ++ ++// Memory fences ++ ++void Assembler::fence(uint8_t pred, uint8_t succ) { ++ DCHECK(is_uint4(pred) && is_uint4(succ)); ++ uint16_t imm12 = succ | (pred << 4) | (0b0000 << 8); ++ GenInstrI(0b000, MISC_MEM, ToRegister(0), ToRegister(0), imm12); ++} ++ ++void Assembler::fence_tso() { ++ uint16_t imm12 = (0b0011) | (0b0011 << 4) | (0b1000 << 8); ++ GenInstrI(0b000, MISC_MEM, ToRegister(0), ToRegister(0), imm12); ++} ++ ++// Environment call / break ++ ++void Assembler::ecall() { ++ GenInstrI(0b000, SYSTEM, ToRegister(0), ToRegister(0), 0); ++} ++ ++void Assembler::ebreak() { ++ GenInstrI(0b000, SYSTEM, ToRegister(0), ToRegister(0), 1); ++} ++ ++// This is a de facto standard (as set by GNU binutils) 32-bit unimplemented ++// instruction (i.e., it should always trap, if your implementation has invalid ++// instruction traps). ++void Assembler::unimp() { ++ GenInstrI(0b001, SYSTEM, ToRegister(0), ToRegister(0), 0b110000000000); ++} ++ ++// CSR ++ ++void Assembler::csrrw(Register rd, ControlStatusReg csr, Register rs1) { ++ GenInstrCSR_ir(0b001, rd, csr, rs1); ++} ++ ++void Assembler::csrrs(Register rd, ControlStatusReg csr, Register rs1) { ++ GenInstrCSR_ir(0b010, rd, csr, rs1); ++} ++ ++void Assembler::csrrc(Register rd, ControlStatusReg csr, Register rs1) { ++ GenInstrCSR_ir(0b011, rd, csr, rs1); ++} ++ ++void Assembler::csrrwi(Register rd, ControlStatusReg csr, uint8_t imm5) { ++ GenInstrCSR_ii(0b101, rd, csr, imm5); ++} ++ ++void Assembler::csrrsi(Register rd, ControlStatusReg csr, uint8_t imm5) { ++ GenInstrCSR_ii(0b110, rd, csr, imm5); ++} ++ ++void Assembler::csrrci(Register rd, ControlStatusReg csr, uint8_t imm5) { ++ GenInstrCSR_ii(0b111, rd, csr, imm5); ++} ++ ++// RV64I ++ ++void Assembler::lwu(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b110, rd, rs1, imm12); ++} ++ ++void Assembler::ld(Register rd, Register rs1, int16_t imm12) { ++ GenInstrLoad_ri(0b011, rd, rs1, imm12); ++} ++ ++void Assembler::sd(Register source, Register base, int16_t imm12) { ++ GenInstrStore_rri(0b011, base, source, imm12); ++} ++ ++void Assembler::addiw(Register rd, Register rs1, int16_t imm12) { ++ GenInstrI(0b000, OP_IMM_32, rd, rs1, imm12); ++} ++ ++void Assembler::slliw(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShiftW_ri(0, 0b001, rd, rs1, shamt & 0x1f); ++} ++ ++void Assembler::srliw(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShiftW_ri(0, 0b101, rd, rs1, shamt & 0x1f); ++} ++ ++void Assembler::sraiw(Register rd, Register rs1, uint8_t shamt) { ++ GenInstrShiftW_ri(1, 0b101, rd, rs1, shamt & 0x1f); ++} ++ ++void Assembler::addw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::subw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0100000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::sllw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000000, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::srlw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000000, 0b101, rd, rs1, rs2); ++} ++ ++void Assembler::sraw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0100000, 0b101, rd, rs1, rs2); ++} ++ ++// RV32M Standard Extension ++ ++void Assembler::mul(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::mulh(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::mulhsu(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::mulhu(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::div(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b100, rd, rs1, rs2); ++} ++ ++void Assembler::divu(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b101, rd, rs1, rs2); ++} ++ ++void Assembler::rem(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b110, rd, rs1, rs2); ++} ++ ++void Assembler::remu(Register rd, Register rs1, Register rs2) { ++ GenInstrALU_rr(0b0000001, 0b111, rd, rs1, rs2); ++} ++ ++// RV64M Standard Extension (in addition to RV32M) ++ ++void Assembler::mulw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000001, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::divw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000001, 0b100, rd, rs1, rs2); ++} ++ ++void Assembler::divuw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000001, 0b101, rd, rs1, rs2); ++} ++ ++void Assembler::remw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000001, 0b110, rd, rs1, rs2); ++} ++ ++void Assembler::remuw(Register rd, Register rs1, Register rs2) { ++ GenInstrALUW_rr(0b0000001, 0b111, rd, rs1, rs2); ++} ++ ++// RV32A Standard Extension ++ ++void Assembler::lr_w(bool aq, bool rl, Register rd, Register rs1) { ++ GenInstrRAtomic(0b00010, aq, rl, 0b010, rd, rs1, zero_reg); ++} ++ ++void Assembler::sc_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00011, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amoswap_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00001, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amoadd_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00000, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amoxor_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00100, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amoand_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b01100, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amoor_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b01000, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amomin_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b10000, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amomax_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b10100, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amominu_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b11000, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::amomaxu_w(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b11100, aq, rl, 0b010, rd, rs1, rs2); ++} ++ ++// RV64A Standard Extension (in addition to RV32A) ++ ++void Assembler::lr_d(bool aq, bool rl, Register rd, Register rs1) { ++ GenInstrRAtomic(0b00010, aq, rl, 0b011, rd, rs1, zero_reg); ++} ++ ++void Assembler::sc_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00011, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amoswap_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00001, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amoadd_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00000, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amoxor_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b00100, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amoand_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b01100, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amoor_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b01000, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amomin_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b10000, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amomax_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b10100, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amominu_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b11000, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++void Assembler::amomaxu_d(bool aq, bool rl, Register rd, Register rs1, ++ Register rs2) { ++ GenInstrRAtomic(0b11100, aq, rl, 0b011, rd, rs1, rs2); ++} ++ ++// RV32F Standard Extension ++ ++void Assembler::flw(FPURegister rd, Register rs1, int16_t imm12) { ++ GenInstrLoadFP_ri(0b010, rd, rs1, imm12); ++} ++ ++void Assembler::fsw(FPURegister source, Register base, int16_t imm12) { ++ GenInstrStoreFP_rri(0b010, base, source, imm12); ++} ++ ++void Assembler::fmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b00, MADD, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b00, MSUB, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fnmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b00, NMSUB, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fnmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b00, NMADD, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0000000, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0000100, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fmul_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0001000, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fdiv_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0001100, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fsqrt_s(FPURegister rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b0101100, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fsgnj_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fsgnjn_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010000, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fsgnjx_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010000, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::fmin_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010100, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fmax_s(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010100, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fcvt_w_s(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_wu_s(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(1)); ++} ++ ++void Assembler::fmv_x_w(Register rd, FPURegister rs1) { ++ GenInstrALUFP_rr(0b1110000, 0b000, rd, rs1, zero_reg); ++} ++ ++void Assembler::feq_s(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010000, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::flt_s(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010000, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fle_s(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010000, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fclass_s(Register rd, FPURegister rs1) { ++ GenInstrALUFP_rr(0b1110000, 0b001, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_s_w(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_s_wu(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(1)); ++} ++ ++void Assembler::fmv_w_x(FPURegister rd, Register rs1) { ++ GenInstrALUFP_rr(0b1111000, 0b000, rd, rs1, zero_reg); ++} ++ ++// RV64F Standard Extension (in addition to RV32F) ++ ++void Assembler::fcvt_l_s(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(2)); ++} ++ ++void Assembler::fcvt_lu_s(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100000, frm, rd, rs1, ToRegister(3)); ++} ++ ++void Assembler::fcvt_s_l(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(2)); ++} ++ ++void Assembler::fcvt_s_lu(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101000, frm, rd, rs1, ToRegister(3)); ++} ++ ++// RV32D Standard Extension ++ ++void Assembler::fld(FPURegister rd, Register rs1, int16_t imm12) { ++ GenInstrLoadFP_ri(0b011, rd, rs1, imm12); ++} ++ ++void Assembler::fsd(FPURegister source, Register base, int16_t imm12) { ++ GenInstrStoreFP_rri(0b011, base, source, imm12); ++} ++ ++void Assembler::fmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b01, MADD, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b01, MSUB, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fnmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b01, NMSUB, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fnmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm) { ++ GenInstrR4(0b01, NMADD, rd, rs1, rs2, rs3, frm); ++} ++ ++void Assembler::fadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0000001, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0000101, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fmul_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0001001, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fdiv_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm) { ++ GenInstrALUFP_rr(0b0001101, frm, rd, rs1, rs2); ++} ++ ++void Assembler::fsqrt_d(FPURegister rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b0101101, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fsgnj_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010001, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fsgnjn_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010001, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fsgnjx_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010001, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::fmin_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010101, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fmax_d(FPURegister rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b0010101, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fcvt_s_d(FPURegister rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b0100000, frm, rd, rs1, ToRegister(1)); ++} ++ ++void Assembler::fcvt_d_s(FPURegister rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b0100001, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::feq_d(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010001, 0b010, rd, rs1, rs2); ++} ++ ++void Assembler::flt_d(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010001, 0b001, rd, rs1, rs2); ++} ++ ++void Assembler::fle_d(Register rd, FPURegister rs1, FPURegister rs2) { ++ GenInstrALUFP_rr(0b1010001, 0b000, rd, rs1, rs2); ++} ++ ++void Assembler::fclass_d(Register rd, FPURegister rs1) { ++ GenInstrALUFP_rr(0b1110001, 0b001, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_w_d(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_wu_d(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(1)); ++} ++ ++void Assembler::fcvt_d_w(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_d_wu(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(1)); ++} ++ ++// RV64D Standard Extension (in addition to RV32D) ++ ++void Assembler::fcvt_l_d(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(2)); ++} ++ ++void Assembler::fcvt_lu_d(Register rd, FPURegister rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1100001, frm, rd, rs1, ToRegister(3)); ++} ++ ++void Assembler::fmv_x_d(Register rd, FPURegister rs1) { ++ GenInstrALUFP_rr(0b1110001, 0b000, rd, rs1, zero_reg); ++} ++ ++void Assembler::fcvt_d_l(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(2)); ++} ++ ++void Assembler::fcvt_d_lu(FPURegister rd, Register rs1, RoundingMode frm) { ++ GenInstrALUFP_rr(0b1101001, frm, rd, rs1, ToRegister(3)); ++} ++ ++void Assembler::fmv_d_x(FPURegister rd, Register rs1) { ++ GenInstrALUFP_rr(0b1111001, 0b000, rd, rs1, zero_reg); ++} ++ ++// Privileged ++ ++void Assembler::uret() { ++ GenInstrPriv(0b0000000, ToRegister(0), ToRegister(0b00010)); ++} ++ ++void Assembler::sret() { ++ GenInstrPriv(0b0001000, ToRegister(0), ToRegister(0b00010)); ++} ++ ++void Assembler::mret() { ++ GenInstrPriv(0b0011000, ToRegister(0), ToRegister(0b00010)); ++} ++ ++void Assembler::wfi() { ++ GenInstrPriv(0b0001000, ToRegister(0), ToRegister(0b00101)); ++} ++ ++void Assembler::sfence_vma(Register rs1, Register rs2) { ++ GenInstrR(0b0001001, 0b000, SYSTEM, ToRegister(0), rs1, rs2); ++} ++ ++// Assembler Pseudo Instructions (Tables 25.2 and 25.3, RISC-V Unprivileged ISA) ++ ++void Assembler::nop() { addi(ToRegister(0), ToRegister(0), 0); } ++ ++void Assembler::RV_li(Register rd, int64_t imm) { ++ // 64-bit imm is put in the register rd. ++ // In most cases the imm is 32 bit and 2 instructions are generated. If a ++ // temporary register is available, in the worst case, 6 instructions are ++ // generated for a full 64-bit immediate. If temporay register is not ++ // available the maximum will be 8 instructions. If imm is more than 32 bits ++ // and a temp register is available, imm is divided into two 32-bit parts, ++ // low_32 and up_32. Each part is built in a separate register. low_32 is ++ // built before up_32. If low_32 is negative (upper 32 bits are 1), 0xffffffff ++ // is subtracted from up_32 before up_32 is built. This compensates for 32 ++ // bits of 1's in the lower when the two registers are added. If no temp is ++ // available, the upper 32 bit is built in rd, and the lower 32 bits are ++ // devided to 3 parts (11, 11, and 10 bits). The parts are shifted and added ++ // to the upper part built in rd. ++ if (is_int32(imm + 0x800)) { ++ // 32-bit case. Maximum of 2 instructions generated ++ int64_t high_20 = ((imm + 0x800) >> 12); ++ int64_t low_12 = imm << 52 >> 52; ++ if (high_20) { ++ lui(rd, (int32_t)high_20); ++ if (low_12) { ++ addi(rd, rd, low_12); ++ } ++ } else { ++ addi(rd, zero_reg, low_12); ++ } ++ return; ++ } else { ++ // 64-bit case: divide imm into two 32-bit parts, upper and lower ++ int64_t up_32 = imm >> 32; ++ int64_t low_32 = imm & 0xffffffffull; ++ Register temp_reg = rd; ++ // Check if a temporary register is available ++ if (up_32 == 0 || low_32 == 0) { ++ // No temp register is needed ++ } else { ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ temp_reg = temps.hasAvailable() ? temps.Acquire() : no_reg; ++ } ++ if (temp_reg != no_reg) { ++ // keep track of hardware behavior for lower part in sim_low ++ int64_t sim_low = 0; ++ // Build lower part ++ if (low_32 != 0) { ++ int64_t high_20 = ((low_32 + 0x800) >> 12); ++ int64_t low_12 = low_32 & 0xfff; ++ if (high_20) { ++ // Adjust to 20 bits for the case of overflow ++ high_20 &= 0xfffff; ++ sim_low = ((high_20 << 12) << 32) >> 32; ++ lui(rd, (int32_t)high_20); ++ if (low_12) { ++ sim_low += (low_12 << 52 >> 52) | low_12; ++ addi(rd, rd, low_12); ++ } ++ } else { ++ sim_low = low_12; ++ ori(rd, zero_reg, low_12); ++ } ++ } ++ if (sim_low & 0x100000000) { ++ // Bit 31 is 1. Either an overflow or a negative 64 bit ++ if (up_32 == 0) { ++ // Positive number, but overflow because of the add 0x800 ++ slli(rd, rd, 32); ++ srli(rd, rd, 32); ++ return; ++ } ++ // low_32 is a negative 64 bit after the build ++ up_32 = (up_32 - 0xffffffff) & 0xffffffff; ++ } ++ if (up_32 == 0) { ++ return; ++ } ++ // Build upper part in a temporary register ++ if (low_32 == 0) { ++ // Build upper part in rd ++ temp_reg = rd; ++ } ++ int64_t high_20 = (up_32 + 0x800) >> 12; ++ int64_t low_12 = up_32 & 0xfff; ++ if (high_20) { ++ // Adjust to 20 bits for the case of overflow ++ high_20 &= 0xfffff; ++ lui(temp_reg, (int32_t)high_20); ++ if (low_12) { ++ addi(temp_reg, temp_reg, low_12); ++ } ++ } else { ++ ori(temp_reg, zero_reg, low_12); ++ } ++ // Put it at the bgining of register ++ slli(temp_reg, temp_reg, 32); ++ if (low_32 != 0) { ++ add(rd, rd, temp_reg); ++ } ++ return; ++ } ++ // No temp register. Build imm in rd. ++ // Build upper 32 bits first in rd. Divide lower 32 bits parts and add ++ // parts to the upper part by doing shift and add. ++ // First build upper part in rd. ++ int64_t high_20 = (up_32 + 0x800) >> 12; ++ int64_t low_12 = up_32 & 0xfff; ++ if (high_20) { ++ // Adjust to 20 bits for the case of overflow ++ high_20 &= 0xfffff; ++ lui(rd, (int32_t)high_20); ++ if (low_12) { ++ addi(rd, rd, low_12); ++ } ++ } else { ++ ori(rd, zero_reg, low_12); ++ } ++ // upper part already in rd. Each part to be added to rd, has maximum of 11 ++ // bits, and always starts with a 1. rd is shifted by the size of the part ++ // plus the number of zeros between the parts. Each part is added after the ++ // left shift. ++ uint32_t mask = 0x80000000; ++ int32_t shift_val = 0; ++ int32_t i; ++ for (i = 0; i < 32; i++) { ++ if ((low_32 & mask) == 0) { ++ mask >>= 1; ++ shift_val++; ++ if (i == 31) { ++ // rest is zero ++ slli(rd, rd, shift_val); ++ } ++ continue; ++ } ++ // The first 1 seen ++ int32_t part; ++ if ((i + 11) < 32) { ++ // Pick 11 bits ++ part = ((uint32_t)(low_32 << i) >> i) >> (32 - (i + 11)); ++ slli(rd, rd, shift_val + 11); ++ ori(rd, rd, part); ++ i += 10; ++ mask >>= 11; ++ } else { ++ part = (uint32_t)(low_32 << i) >> i; ++ slli(rd, rd, shift_val + (32 - i)); ++ ori(rd, rd, part); ++ break; ++ } ++ shift_val = 0; ++ } ++ } ++} ++ ++int Assembler::li_count(int64_t imm) { ++ int count = 0; ++ if (is_int32(imm + 0x800)) { ++ int64_t Hi20 = ((imm + 0x800) >> 12); ++ int64_t Lo12 = imm << 52 >> 52; ++ ++ if (Hi20) count++; ++ ++ if (Lo12 || Hi20 == 0) count++; ++ return count; ++ } ++ ++ int64_t Lo12 = imm << 52 >> 52; ++ int64_t Hi52 = ((uint64_t)imm + 0x800ull) >> 12; ++ int FirstBit = 0; ++ uint64_t Val = Hi52; ++ while ((Val & 1) == 0) { ++ Val = Val >> 1; ++ FirstBit++; ++ } ++ int ShiftAmount = 12 + FirstBit; ++ Hi52 = (Hi52 >> (ShiftAmount - 12)) << ShiftAmount >> ShiftAmount; ++ ++ count += li_count(Hi52); ++ ++ count++; ++ if (Lo12) count++; ++ ++ return count; ++} ++ ++void Assembler::li_constant(Register rd, int64_t imm) { ++ DEBUG_PRINTF("li_constant(%d, %lx <%ld>)\n", ToNumber(rd), imm, imm); ++ lui(rd, (imm + (1LL << 47) + (1LL << 35) + (1LL << 23) + (1LL << 11)) >> ++ 48); // Bits 63:48 ++ addiw(rd, rd, ++ (imm + (1LL << 35) + (1LL << 23) + (1LL << 11)) << 16 >> ++ 52); // Bits 47:36 ++ slli(rd, rd, 12); ++ addi(rd, rd, (imm + (1LL << 23) + (1LL << 11)) << 28 >> 52); // Bits 35:24 ++ slli(rd, rd, 12); ++ addi(rd, rd, (imm + (1LL << 11)) << 40 >> 52); // Bits 23:12 ++ slli(rd, rd, 12); ++ addi(rd, rd, imm << 52 >> 52); // Bits 11:0 ++} ++ ++// Break / Trap instructions. ++void Assembler::break_(uint32_t code, bool break_as_stop) { ++ // We need to invalidate breaks that could be stops as well because the ++ // simulator expects a char pointer after the stop instruction. ++ // See constants-mips.h for explanation. ++ DCHECK( ++ (break_as_stop && code <= kMaxStopCode && code > kMaxWatchpointCode) || ++ (!break_as_stop && (code > kMaxStopCode || code <= kMaxWatchpointCode))); ++ ++ // since ebreak does not allow additional immediate field, we use the ++ // immediate field of lui instruction immediately following the ebreak to ++ // encode the "code" info ++ ebreak(); ++ DCHECK(is_uint20(code)); ++ lui(zero_reg, code); ++} ++ ++void Assembler::stop(uint32_t code) { ++ DCHECK_GT(code, kMaxWatchpointCode); ++ DCHECK_LE(code, kMaxStopCode); ++#if defined(V8_HOST_ARCH_RISCV64) ++ // FIXME: does RISCV expect a special value? ++ break_(0x54321); ++#else // V8_HOST_ARCH_RISCV64 ++ break_(code, true); ++#endif ++} ++ ++// Original MIPS Instructions ++ ++// ------------Memory-instructions------------- ++ ++bool Assembler::NeedAdjustBaseAndOffset(const MemOperand& src, ++ OffsetAccessType access_type, ++ int second_access_add_to_offset) { ++ bool two_accesses = static_cast(access_type); ++ DCHECK_LE(second_access_add_to_offset, 7); // Must be <= 7. ++ ++ // is_int12 must be passed a signed value, hence the static cast below. ++ if (is_int12(src.offset()) && ++ (!two_accesses || is_int12(static_cast( ++ src.offset() + second_access_add_to_offset)))) { ++ // Nothing to do: 'offset' (and, if needed, 'offset + 4', or other specified ++ // value) fits into int12. ++ return false; ++ } ++ return true; ++} ++ ++void Assembler::AdjustBaseAndOffset(MemOperand* src, Register scratch, ++ OffsetAccessType access_type, ++ int second_Access_add_to_offset) { ++ // This method is used to adjust the base register and offset pair ++ // for a load/store when the offset doesn't fit into int12. ++ ++ // Must not overwrite the register 'base' while loading 'offset'. ++ DCHECK(src->rm() != scratch); ++ ++ // FIXME(RISC-V): There may be a more optimal way to do this ++ RV_li(scratch, src->offset()); ++ add(scratch, scratch, src->rm()); ++ src->offset_ = 0; ++ src->rm_ = scratch; ++} ++ ++// FIXME (RISCV): not yet ported (or not used?) ++int Assembler::RelocateInternalReference(RelocInfo::Mode rmode, Address pc, ++ intptr_t pc_delta) { ++ if (RelocInfo::IsInternalReference(rmode)) { ++ int64_t* p = reinterpret_cast(pc); ++ if (*p == kEndOfJumpChain) { ++ return 0; // Number of instructions patched. ++ } ++ *p += pc_delta; ++ return 2; // Number of instructions patched. ++ } ++ Instr instr = instr_at(pc); ++ DCHECK(RelocInfo::IsInternalReferenceEncoded(rmode)); ++ if (IsLui(instr)) { ++ uint64_t target_address = target_address_at(pc) + pc_delta; ++ DEBUG_PRINTF("target_address 0x%lx\n", target_address); ++ set_target_value_at(pc, target_address); ++ return 8; // Number of instructions patched. ++ } else { ++ UNIMPLEMENTED(); ++ return 1; ++ } ++} ++ ++void Assembler::GrowBuffer() { ++ DEBUG_PRINTF("GrowBuffer: %p -> ", buffer_start_); ++ // Compute new buffer size. ++ int old_size = buffer_->size(); ++ int new_size = std::min(2 * old_size, old_size + 1 * MB); ++ ++ // Some internal data structures overflow for very large buffers, ++ // they must ensure that kMaximalBufferSize is not too large. ++ if (new_size > kMaximalBufferSize) { ++ V8::FatalProcessOutOfMemory(nullptr, "Assembler::GrowBuffer"); ++ } ++ ++ // Set up new buffer. ++ std::unique_ptr new_buffer = buffer_->Grow(new_size); ++ DCHECK_EQ(new_size, new_buffer->size()); ++ byte* new_start = new_buffer->start(); ++ ++ // Copy the data. ++ intptr_t pc_delta = new_start - buffer_start_; ++ intptr_t rc_delta = (new_start + new_size) - (buffer_start_ + old_size); ++ size_t reloc_size = (buffer_start_ + old_size) - reloc_info_writer.pos(); ++ MemMove(new_start, buffer_start_, pc_offset()); ++ MemMove(reloc_info_writer.pos() + rc_delta, reloc_info_writer.pos(), ++ reloc_size); ++ ++ // Switch buffers. ++ buffer_ = std::move(new_buffer); ++ buffer_start_ = new_start; ++ DEBUG_PRINTF("%p\n", buffer_start_); ++ pc_ += pc_delta; ++ reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, ++ reloc_info_writer.last_pc() + pc_delta); ++ ++ // Relocate runtime entries. ++ Vector instructions{buffer_start_, (size_t)pc_offset()}; ++ Vector reloc_info{reloc_info_writer.pos(), reloc_size}; ++ for (RelocIterator it(instructions, reloc_info, 0); !it.done(); it.next()) { ++ RelocInfo::Mode rmode = it.rinfo()->rmode(); ++ if (rmode == RelocInfo::INTERNAL_REFERENCE) { ++ RelocateInternalReference(rmode, it.rinfo()->pc(), pc_delta); ++ } ++ } ++ DCHECK(!overflow()); ++} ++ ++void Assembler::db(uint8_t data) { ++ if (!is_buffer_growth_blocked()) CheckBuffer(); ++ EmitHelper(data); ++} ++ ++void Assembler::dd(uint32_t data) { ++ if (!is_buffer_growth_blocked()) CheckBuffer(); ++ EmitHelper(data); ++} ++ ++void Assembler::dq(uint64_t data) { ++ if (!is_buffer_growth_blocked()) CheckBuffer(); ++ EmitHelper(data); ++} ++ ++void Assembler::dd(Label* label) { ++ uint64_t data; ++ if (!is_buffer_growth_blocked()) CheckBuffer(); ++ if (label->is_bound()) { ++ data = reinterpret_cast(buffer_start_ + label->pos()); ++ } else { ++ data = jump_address(label); ++ internal_reference_positions_.insert(label->pos()); ++ } ++ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE); ++ EmitHelper(data); ++} ++ ++void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { ++ if (!ShouldRecordRelocInfo(rmode)) return; ++ // We do not try to reuse pool constants. ++ RelocInfo rinfo(reinterpret_cast
(pc_), rmode, data, Code()); ++ DCHECK_GE(buffer_space(), kMaxRelocSize); // Too late to grow buffer here. ++ reloc_info_writer.Write(&rinfo); ++} ++ ++void Assembler::BlockTrampolinePoolFor(int instructions) { ++ CheckTrampolinePoolQuick(instructions); ++ BlockTrampolinePoolBefore(pc_offset() + instructions * kInstrSize); ++} ++ ++void Assembler::CheckTrampolinePool() { ++ // Some small sequences of instructions must not be broken up by the ++ // insertion of a trampoline pool; such sequences are protected by setting ++ // either trampoline_pool_blocked_nesting_ or no_trampoline_pool_before_, ++ // which are both checked here. Also, recursive calls to CheckTrampolinePool ++ // are blocked by trampoline_pool_blocked_nesting_. ++ if ((trampoline_pool_blocked_nesting_ > 0) || ++ (pc_offset() < no_trampoline_pool_before_)) { ++ // Emission is currently blocked; make sure we try again as soon as ++ // possible. ++ if (trampoline_pool_blocked_nesting_ > 0) { ++ next_buffer_check_ = pc_offset() + kInstrSize; ++ } else { ++ next_buffer_check_ = no_trampoline_pool_before_; ++ } ++ return; ++ } ++ ++ DCHECK(!trampoline_emitted_); ++ DCHECK_GE(unbound_labels_count_, 0); ++ if (unbound_labels_count_ > 0) { ++ // First we emit jump, then we emit trampoline pool. ++ { ++ DEBUG_PRINTF("inserting trampoline pool at %p (%d)\n", ++ reinterpret_cast(buffer_start_ + pc_offset()), ++ pc_offset()); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Label after_pool; ++ j(&after_pool); ++ ++ int pool_start = pc_offset(); ++ for (int i = 0; i < unbound_labels_count_; i++) { ++ int64_t imm64; ++ imm64 = branch_long_offset(&after_pool); ++ DCHECK(is_int32(imm64)); ++ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); ++ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; ++ auipc(t5, Hi20); // Read PC + Hi20 into t5. ++ jr(t5, Lo12); // jump PC + Hi20 + Lo12 ++ } ++ // If unbound_labels_count_ is big enough, label after_pool will ++ // need a trampoline too, so we must create the trampoline before ++ // the bind operation to make sure function 'bind' can get this ++ // information. ++ trampoline_ = Trampoline(pool_start, unbound_labels_count_); ++ bind(&after_pool); ++ ++ trampoline_emitted_ = true; ++ // As we are only going to emit trampoline once, we need to prevent any ++ // further emission. ++ next_buffer_check_ = kMaxInt; ++ } ++ } else { ++ // Number of branches to unbound label at this point is zero, so we can ++ // move next buffer check to maximum. ++ next_buffer_check_ = ++ pc_offset() + kMaxBranchOffset - kTrampolineSlotsSize * 16; ++ } ++ return; ++} ++ ++Address Assembler::target_address_at(Address pc) { ++ DEBUG_PRINTF("target_address_at: pc: %lx\t", pc); ++ Instruction* instr0 = Instruction::At((unsigned char*)pc); ++ Instruction* instr1 = Instruction::At((unsigned char*)(pc + 1 * kInstrSize)); ++ Instruction* instr3 = Instruction::At((unsigned char*)(pc + 3 * kInstrSize)); ++ Instruction* instr5 = Instruction::At((unsigned char*)(pc + 5 * kInstrSize)); ++ Instruction* instr7 = Instruction::At((unsigned char*)(pc + 7 * kInstrSize)); ++ ++ // Interpret 5 instructions for address generated by li: See listing in ++ // Assembler::set_target_address_at() just below. ++ if (IsLui(*reinterpret_cast(instr0)) && ++ IsAddiw(*reinterpret_cast(instr1)) && ++ IsAddi(*reinterpret_cast(instr3)) && ++ IsAddi(*reinterpret_cast(instr5)) && ++ IsAddi(*reinterpret_cast(instr7))) { ++ // Assemble the 64 bit value. ++ int64_t addr = (int64_t)(instr0->Imm20UValue() << kImm20Shift) + ++ (int64_t)instr1->Imm12Value(); ++ addr <<= 12; ++ addr += (int64_t)instr3->Imm12Value(); ++ addr <<= 12; ++ addr += (int64_t)instr5->Imm12Value(); ++ addr <<= 12; ++ addr += (int64_t)instr7->Imm12Value(); ++ ++ DEBUG_PRINTF("addr: %lx\n", addr); ++ return static_cast
(addr); ++ } ++ // We should never get here, force a bad address if we do. ++ UNREACHABLE(); ++} ++ ++// On RISC-V, a 64-bit target address is stored in an 8-instruction sequence: ++// 0: lui(rd, (j.imm64_ + (1LL << 47) + (1LL << 35) + ++// (1LL << 23) + (1LL << 11)) >> 48); ++// 1: addiw(rd, rd, (j.imm64_ + (1LL << 35) + (1LL << 23) + (1LL << 11)) ++// << 16 >> 52); ++// 2: slli(rd, rd, 12); ++// 3: addi(rd, rd, (j.imm64_ + (1LL << 23) + (1LL << 11)) << 28 >> 52); ++// 4: slli(rd, rd, 12); ++// 5: addi(rd, rd, (j.imm64_ + (1 << 11)) << 40 >> 52); ++// 6: slli(rd, rd, 12); ++// 7: addi(rd, rd, j.imm64_ << 52 >> 52); ++// ++// Patching the address must replace all the lui & addi instructions, ++// and flush the i-cache. ++void Assembler::set_target_value_at(Address pc, uint64_t target, ++ ICacheFlushMode icache_flush_mode) { ++ // FIXME(RISC-V): Does the below statement apply to RISC-V? If so, we do not ++ // need all 8 instructions. ++ // There is an optimization where only 4 instructions are used to load address ++ // in code on MIP64 because only 48-bits of address is effectively used. ++ // It relies on fact the upper [63:48] bits are not used for virtual address ++ // translation and they have to be set according to value of bit 47 in order ++ // get canonical address. ++ Instruction* instr0 = Instruction::At((unsigned char*)pc); ++ DEBUG_PRINTF("set_target_value_at: pc: %lx\ttarget: %lx\n", pc, target); ++ int rd_code = instr0->RdValue(); ++ uint32_t* p = reinterpret_cast(pc); ++ ++#ifdef DEBUG ++ // Check we have the result from a li macro-instruction. ++ Instruction* instr1 = Instruction::At((unsigned char*)(pc + 1 * kInstrSize)); ++ Instruction* instr3 = Instruction::At((unsigned char*)(pc + 3 * kInstrSize)); ++ Instruction* instr5 = Instruction::At((unsigned char*)(pc + 5 * kInstrSize)); ++ Instruction* instr7 = Instruction::At((unsigned char*)(pc + 7 * kInstrSize)); ++ DCHECK(IsLui(*reinterpret_cast(instr0)) && ++ IsAddiw(*reinterpret_cast(instr1)) && ++ IsAddi(*reinterpret_cast(instr3)) && ++ IsAddi(*reinterpret_cast(instr5)) && ++ IsAddi(*reinterpret_cast(instr7))); ++#endif ++ ++ // Must use 8 instructions to insure patchable code (see above comment). ++ *p = LUI | (rd_code << kRdShift) | ++ ((uint32_t)( ++ (target + (1LL << 47) + (1LL << 35) + (1LL << 23) + (1LL << 11)) >> ++ 48) ++ << kImm20Shift); ++ *(p + 1) = ++ OP_IMM_32 | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | ++ ((uint32_t)((target + (1LL << 35) + (1LL << 23) + (1LL << 11)) << 16 >> ++ 52) ++ << kImm12Shift); ++ *(p + 2) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | (12 << kImm12Shift); ++ *(p + 3) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | ++ ((uint32_t)((target + (1LL << 23) + (1LL << 11)) << 28 >> 52) ++ << kImm12Shift); ++ *(p + 4) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | (12 << kImm12Shift); ++ *(p + 5) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | ++ ((uint32_t)((target + (1LL << 11)) << 40 >> 52) << kImm12Shift); ++ *(p + 6) = OP_IMM | (rd_code << kRdShift) | (0b001 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | (12 << kImm12Shift); ++ *(p + 7) = OP_IMM | (rd_code << kRdShift) | (0b000 << kFunct3Shift) | ++ (rd_code << kRs1Shift) | ++ ((uint32_t)(target << 52 >> 52) << kImm12Shift); ++ ++ if (icache_flush_mode != SKIP_ICACHE_FLUSH) { ++ FlushInstructionCache(pc, 8 * kInstrSize); ++ } ++ DCHECK_EQ(target_address_at(pc), target); ++} ++ ++UseScratchRegisterScope::UseScratchRegisterScope(Assembler* assembler) ++ : available_(assembler->GetScratchRegisterList()), ++ old_available_(*available_) {} ++ ++UseScratchRegisterScope::~UseScratchRegisterScope() { ++ *available_ = old_available_; ++} ++ ++Register UseScratchRegisterScope::Acquire() { ++ DCHECK_NOT_NULL(available_); ++ DCHECK_NE(*available_, 0); ++ int index = static_cast(base::bits::CountTrailingZeros32(*available_)); ++ *available_ &= ~(1UL << index); ++ ++ return Register::from_code(index); ++} ++ ++bool UseScratchRegisterScope::hasAvailable() const { return *available_ != 0; } ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/assembler-riscv64.h +@@ -0,0 +1,1110 @@ ++// Copyright (c) 1994-2006 Sun Microsystems Inc. ++// All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, with or without ++// modification, are permitted provided that the following conditions are ++// met: ++// ++// - Redistributions of source code must retain the above copyright notice, ++// this list of conditions and the following disclaimer. ++// ++// - Redistribution in binary form must reproduce the above copyright ++// notice, this list of conditions and the following disclaimer in the ++// documentation and/or other materials provided with the distribution. ++// ++// - Neither the name of Sun Microsystems or the names of contributors may ++// be used to endorse or promote products derived from this software without ++// specific prior written permission. ++// ++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ++// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ++// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++// The original source code covered by the above license above has been ++// modified significantly by Google Inc. ++// Copyright 2012 the V8 project authors. All rights reserved. ++ ++#ifndef V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ ++#define V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ ++ ++#include ++ ++#include ++#include ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/external-reference.h" ++#include "src/codegen/label.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/codegen/riscv64/register-riscv64.h" ++#include "src/objects/contexts.h" ++#include "src/objects/smi.h" ++ ++namespace v8 { ++namespace internal { ++ ++class SafepointTableBuilder; ++ ++// ----------------------------------------------------------------------------- ++// Machine instruction Operands. ++constexpr int kSmiShift = kSmiTagSize + kSmiShiftSize; ++constexpr uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; ++// Class Operand represents a shifter operand in data processing instructions. ++class Operand { ++ public: ++ // Immediate. ++ V8_INLINE explicit Operand(int64_t immediate, ++ RelocInfo::Mode rmode = RelocInfo::NONE) ++ : rm_(no_reg), rmode_(rmode) { ++ value_.immediate = immediate; ++ } ++ V8_INLINE explicit Operand(const ExternalReference& f) ++ : rm_(no_reg), rmode_(RelocInfo::EXTERNAL_REFERENCE) { ++ value_.immediate = static_cast(f.address()); ++ } ++ V8_INLINE explicit Operand(const char* s); ++ explicit Operand(Handle handle); ++ V8_INLINE explicit Operand(Smi value) : rm_(no_reg), rmode_(RelocInfo::NONE) { ++ value_.immediate = static_cast(value.ptr()); ++ } ++ ++ static Operand EmbeddedNumber(double number); // Smi or HeapNumber. ++ static Operand EmbeddedStringConstant(const StringConstantBase* str); ++ ++ // Register. ++ V8_INLINE explicit Operand(Register rm) : rm_(rm) {} ++ ++ // Return true if this is a register operand. ++ V8_INLINE bool is_reg() const; ++ ++ inline int64_t immediate() const; ++ ++ bool IsImmediate() const { return !rm_.is_valid(); } ++ ++ HeapObjectRequest heap_object_request() const { ++ DCHECK(IsHeapObjectRequest()); ++ return value_.heap_object_request; ++ } ++ ++ bool IsHeapObjectRequest() const { ++ DCHECK_IMPLIES(is_heap_object_request_, IsImmediate()); ++ DCHECK_IMPLIES(is_heap_object_request_, ++ rmode_ == RelocInfo::FULL_EMBEDDED_OBJECT || ++ rmode_ == RelocInfo::CODE_TARGET); ++ return is_heap_object_request_; ++ } ++ ++ Register rm() const { return rm_; } ++ ++ RelocInfo::Mode rmode() const { return rmode_; } ++ ++ private: ++ Register rm_; ++ union Value { ++ Value() {} ++ HeapObjectRequest heap_object_request; // if is_heap_object_request_ ++ int64_t immediate; // otherwise ++ } value_; // valid if rm_ == no_reg ++ bool is_heap_object_request_ = false; ++ RelocInfo::Mode rmode_; ++ ++ friend class Assembler; ++ friend class MacroAssembler; ++}; ++ ++// On RISC-V we have only one addressing mode with base_reg + offset. ++// Class MemOperand represents a memory operand in load and store instructions. ++class V8_EXPORT_PRIVATE MemOperand : public Operand { ++ public: ++ // Immediate value attached to offset. ++ enum OffsetAddend { offset_minus_one = -1, offset_zero = 0 }; ++ ++ explicit MemOperand(Register rn, int32_t offset = 0); ++ explicit MemOperand(Register rn, int32_t unit, int32_t multiplier, ++ OffsetAddend offset_addend = offset_zero); ++ int32_t offset() const { return offset_; } ++ ++ bool OffsetIsInt12Encodable() const { return is_int12(offset_); } ++ ++ private: ++ int32_t offset_; ++ ++ friend class Assembler; ++}; ++ ++class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ++ public: ++ // Create an assembler. Instructions and relocation information are emitted ++ // into a buffer, with the instructions starting from the beginning and the ++ // relocation information starting from the end of the buffer. See CodeDesc ++ // for a detailed comment on the layout (globals.h). ++ // ++ // If the provided buffer is nullptr, the assembler allocates and grows its ++ // own buffer. Otherwise it takes ownership of the provided buffer. ++ explicit Assembler(const AssemblerOptions&, ++ std::unique_ptr = {}); ++ ++ virtual ~Assembler() {} ++ ++ // GetCode emits any pending (non-emitted) code and fills the descriptor desc. ++ static constexpr int kNoHandlerTable = 0; ++ static constexpr SafepointTableBuilder* kNoSafepointTable = nullptr; ++ void GetCode(Isolate* isolate, CodeDesc* desc, ++ SafepointTableBuilder* safepoint_table_builder, ++ int handler_table_offset); ++ ++ // Convenience wrapper for code without safepoint or handler tables. ++ void GetCode(Isolate* isolate, CodeDesc* desc) { ++ GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable); ++ } ++ ++ // Unused on this architecture. ++ void MaybeEmitOutOfLineConstantPool() {} ++ ++ // Label operations & relative jumps (PPUM Appendix D). ++ // ++ // Takes a branch opcode (cc) and a label (L) and generates ++ // either a backward branch or a forward branch and links it ++ // to the label fixup chain. Usage: ++ // ++ // Label L; // unbound label ++ // j(cc, &L); // forward branch to unbound label ++ // bind(&L); // bind label to the current pc ++ // j(cc, &L); // backward branch to bound label ++ // bind(&L); // illegal: a label may be bound only once ++ // ++ // Note: The same Label can be used for forward and backward branches ++ // but it may be bound only once. ++ void bind(Label* L); // Binds an unbound label L to current code position. ++ ++ enum OffsetSize : int { ++ kOffset21 = 21, // RISCV jal ++ kOffset12 = 12, // RISCV imm12 ++ kOffset20 = 20, // RISCV imm20 ++ kOffset13 = 13 // RISCV branch ++ }; ++ ++ // Determines if Label is bound and near enough so that branch instruction ++ // can be used to reach it, instead of jump instruction. ++ bool is_near(Label* L); ++ bool is_near(Label* L, OffsetSize bits); ++ bool is_near_branch(Label* L); ++ ++ //Get offset from instr. ++ int BranchOffset(Instr instr); ++ int BrachlongOffset(Instr auipc, Instr jalr); ++ int JumpOffset(Instr instr); ++ ++ // Returns the branch offset to the given label from the current code ++ // position. Links the label to the current position if it is still unbound. ++ // Manages the jump elimination optimization if the second parameter is true. ++ int32_t branch_offset_helper(Label* L, OffsetSize bits); ++ inline int32_t branch_offset(Label* L) { ++ return branch_offset_helper(L, OffsetSize::kOffset13); ++ } ++ inline int32_t jump_offset(Label* L) { ++ return branch_offset_helper(L, OffsetSize::kOffset21); ++ } ++ ++ uint64_t jump_address(Label* L); ++ uint64_t branch_long_offset(Label* L); ++ ++ // Puts a labels target address at the given position. ++ // The high 8 bits are set to zero. ++ void label_at_put(Label* L, int at_offset); ++ ++ // Read/Modify the code target address in the branch/call instruction at pc. ++ // The isolate argument is unused (and may be nullptr) when skipping flushing. ++ static Address target_address_at(Address pc); ++ V8_INLINE static void set_target_address_at( ++ Address pc, Address target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { ++ set_target_value_at(pc, target, icache_flush_mode); ++ } ++ // On RISC-V there is no Constant Pool so we skip that parameter. ++ V8_INLINE static Address target_address_at(Address pc, ++ Address constant_pool) { ++ return target_address_at(pc); ++ } ++ V8_INLINE static void set_target_address_at( ++ Address pc, Address constant_pool, Address target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED) { ++ set_target_address_at(pc, target, icache_flush_mode); ++ } ++ ++ static void set_target_value_at( ++ Address pc, uint64_t target, ++ ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); ++ ++ static void JumpLabelToJumpRegister(Address pc); ++ ++ // This sets the branch destination (which gets loaded at the call address). ++ // This is for calls and branches within generated code. The serializer ++ // has already deserialized the lui/ori instructions etc. ++ inline static void deserialization_set_special_target_at( ++ Address instruction_payload, Code code, Address target); ++ ++ // Get the size of the special target encoded at 'instruction_payload'. ++ inline static int deserialization_special_target_size( ++ Address instruction_payload); ++ ++ // This sets the internal reference at the pc. ++ inline static void deserialization_set_target_internal_reference_at( ++ Address pc, Address target, ++ RelocInfo::Mode mode = RelocInfo::INTERNAL_REFERENCE); ++ ++ // Difference between address of current opcode and target address offset. ++ static constexpr int kBranchPCOffset = kInstrSize; ++ ++ // Difference between address of current opcode and target address offset, ++ // when we are generatinga sequence of instructions for long relative PC ++ // branches ++ static constexpr int kLongBranchPCOffset = 3 * kInstrSize; ++ ++ // Adjust ra register in branch delay slot of bal instruction so to skip ++ // instructions not needed after optimization of PIC in ++ // TurboAssembler::BranchAndLink method. ++ ++ static constexpr int kOptimizedBranchAndLinkLongReturnOffset = 4 * kInstrSize; ++ ++ // Here we are patching the address in the LUI/ADDI instruction pair. ++ // These values are used in the serialization process and must be zero for ++ // RISC-V platform, as Code, Embedded Object or External-reference pointers ++ // are split across two consecutive instructions and don't exist separately ++ // in the code, so the serializer should not step forwards in memory after ++ // a target is resolved and written. ++ static constexpr int kSpecialTargetSize = 0; ++ ++ // Number of consecutive instructions used to store 32bit/64bit constant. ++ // This constant was used in RelocInfo::target_address_address() function ++ // to tell serializer address of the instruction that follows ++ // LUI/ADDI instruction pair. ++ static constexpr int kInstructionsFor32BitConstant = 2; ++ static constexpr int kInstructionsFor64BitConstant = 8; ++ ++ // Difference between address of current opcode and value read from pc ++ // register. ++ static constexpr int kPcLoadDelta = 4; ++ ++ // Bits available for offset field in branches ++ static constexpr int kBranchOffsetBits = 13; ++ ++ // Bits available for offset field in jump ++ static constexpr int kJumpOffsetBits = 21; ++ ++ // Max offset for b instructions with 12-bit offset field (multiple of 2) ++ static constexpr int kMaxBranchOffset = (1 << (13 - 1)) - 1; ++ ++ // Max offset for jal instruction with 20-bit offset field (multiple of 2) ++ static constexpr int kMaxJumpOffset = (1 << (21 - 1)) - 1; ++ ++ static constexpr int kTrampolineSlotsSize = 2 * kInstrSize; ++ ++ RegList* GetScratchRegisterList() { return &scratch_register_list_; } ++ ++ // --------------------------------------------------------------------------- ++ // Code generation. ++ ++ // Insert the smallest number of nop instructions ++ // possible to align the pc offset to a multiple ++ // of m. m must be a power of 2 (>= 4). ++ void Align(int m); ++ // Insert the smallest number of zero bytes possible to align the pc offset ++ // to a mulitple of m. m must be a power of 2 (>= 2). ++ void DataAlign(int m); ++ // Aligns code to something that's optimal for a jump target for the platform. ++ void CodeTargetAlign(); ++ ++ // Different nop operations are used by the code generator to detect certain ++ // states of the generated code. ++ enum NopMarkerTypes { ++ NON_MARKING_NOP = 0, ++ DEBUG_BREAK_NOP, ++ // IC markers. ++ PROPERTY_ACCESS_INLINED, ++ PROPERTY_ACCESS_INLINED_CONTEXT, ++ PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE, ++ // Helper values. ++ LAST_CODE_MARKER, ++ FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED, ++ }; ++ ++ // RISC-V Instructions Emited to a buffer ++ ++ void lui(Register rd, int32_t imm20); ++ void auipc(Register rd, int32_t imm20); ++ ++ // Jumps ++ void jal(Register rd, int32_t imm20); ++ void jalr(Register rd, Register rs1, int16_t imm12); ++ ++ // Branches ++ void beq(Register rs1, Register rs2, int16_t imm12); ++ inline void beq(Register rs1, Register rs2, Label* L) { ++ beq(rs1, rs2, branch_offset(L)); ++ } ++ void bne(Register rs1, Register rs2, int16_t imm12); ++ inline void bne(Register rs1, Register rs2, Label* L) { ++ bne(rs1, rs2, branch_offset(L)); ++ } ++ void blt(Register rs1, Register rs2, int16_t imm12); ++ inline void blt(Register rs1, Register rs2, Label* L) { ++ blt(rs1, rs2, branch_offset(L)); ++ } ++ void bge(Register rs1, Register rs2, int16_t imm12); ++ inline void bge(Register rs1, Register rs2, Label* L) { ++ bge(rs1, rs2, branch_offset(L)); ++ } ++ void bltu(Register rs1, Register rs2, int16_t imm12); ++ inline void bltu(Register rs1, Register rs2, Label* L) { ++ bltu(rs1, rs2, branch_offset(L)); ++ } ++ void bgeu(Register rs1, Register rs2, int16_t imm12); ++ inline void bgeu(Register rs1, Register rs2, Label* L) { ++ bgeu(rs1, rs2, branch_offset(L)); ++ } ++ ++ // Loads ++ void lb(Register rd, Register rs1, int16_t imm12); ++ void lh(Register rd, Register rs1, int16_t imm12); ++ void lw(Register rd, Register rs1, int16_t imm12); ++ void lbu(Register rd, Register rs1, int16_t imm12); ++ void lhu(Register rd, Register rs1, int16_t imm12); ++ ++ // Stores ++ void sb(Register source, Register base, int16_t imm12); ++ void sh(Register source, Register base, int16_t imm12); ++ void sw(Register source, Register base, int16_t imm12); ++ ++ // Arithmetic with immediate ++ void addi(Register rd, Register rs1, int16_t imm12); ++ void slti(Register rd, Register rs1, int16_t imm12); ++ void sltiu(Register rd, Register rs1, int16_t imm12); ++ void xori(Register rd, Register rs1, int16_t imm12); ++ void ori(Register rd, Register rs1, int16_t imm12); ++ void andi(Register rd, Register rs1, int16_t imm12); ++ void slli(Register rd, Register rs1, uint8_t shamt); ++ void srli(Register rd, Register rs1, uint8_t shamt); ++ void srai(Register rd, Register rs1, uint8_t shamt); ++ ++ // Arithmetic ++ void add(Register rd, Register rs1, Register rs2); ++ void sub(Register rd, Register rs1, Register rs2); ++ void sll(Register rd, Register rs1, Register rs2); ++ void slt(Register rd, Register rs1, Register rs2); ++ void sltu(Register rd, Register rs1, Register rs2); ++ void xor_(Register rd, Register rs1, Register rs2); ++ void srl(Register rd, Register rs1, Register rs2); ++ void sra(Register rd, Register rs1, Register rs2); ++ void or_(Register rd, Register rs1, Register rs2); ++ void and_(Register rd, Register rs1, Register rs2); ++ ++ // Memory fences ++ void fence(uint8_t pred, uint8_t succ); ++ void fence_tso(); ++ ++ // Environment call / break ++ void ecall(); ++ void ebreak(); ++ ++ // This is a de facto standard (as set by GNU binutils) 32-bit unimplemented ++ // instruction (i.e., it should always trap, if your implementation has ++ // invalid instruction traps). ++ void unimp(); ++ ++ // CSR ++ void csrrw(Register rd, ControlStatusReg csr, Register rs1); ++ void csrrs(Register rd, ControlStatusReg csr, Register rs1); ++ void csrrc(Register rd, ControlStatusReg csr, Register rs1); ++ void csrrwi(Register rd, ControlStatusReg csr, uint8_t imm5); ++ void csrrsi(Register rd, ControlStatusReg csr, uint8_t imm5); ++ void csrrci(Register rd, ControlStatusReg csr, uint8_t imm5); ++ ++ // RV64I ++ void lwu(Register rd, Register rs1, int16_t imm12); ++ void ld(Register rd, Register rs1, int16_t imm12); ++ void sd(Register source, Register base, int16_t imm12); ++ void addiw(Register rd, Register rs1, int16_t imm12); ++ void slliw(Register rd, Register rs1, uint8_t shamt); ++ void srliw(Register rd, Register rs1, uint8_t shamt); ++ void sraiw(Register rd, Register rs1, uint8_t shamt); ++ void addw(Register rd, Register rs1, Register rs2); ++ void subw(Register rd, Register rs1, Register rs2); ++ void sllw(Register rd, Register rs1, Register rs2); ++ void srlw(Register rd, Register rs1, Register rs2); ++ void sraw(Register rd, Register rs1, Register rs2); ++ ++ // RV32M Standard Extension ++ void mul(Register rd, Register rs1, Register rs2); ++ void mulh(Register rd, Register rs1, Register rs2); ++ void mulhsu(Register rd, Register rs1, Register rs2); ++ void mulhu(Register rd, Register rs1, Register rs2); ++ void div(Register rd, Register rs1, Register rs2); ++ void divu(Register rd, Register rs1, Register rs2); ++ void rem(Register rd, Register rs1, Register rs2); ++ void remu(Register rd, Register rs1, Register rs2); ++ ++ // RV64M Standard Extension (in addition to RV32M) ++ void mulw(Register rd, Register rs1, Register rs2); ++ void divw(Register rd, Register rs1, Register rs2); ++ void divuw(Register rd, Register rs1, Register rs2); ++ void remw(Register rd, Register rs1, Register rs2); ++ void remuw(Register rd, Register rs1, Register rs2); ++ ++ // RV32A Standard Extension ++ void lr_w(bool aq, bool rl, Register rd, Register rs1); ++ void sc_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoswap_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoadd_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoxor_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoand_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoor_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomin_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomax_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amominu_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomaxu_w(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ ++ // RV64A Standard Extension (in addition to RV32A) ++ void lr_d(bool aq, bool rl, Register rd, Register rs1); ++ void sc_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoswap_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoadd_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoxor_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoand_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amoor_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomin_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomax_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amominu_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ void amomaxu_d(bool aq, bool rl, Register rd, Register rs1, Register rs2); ++ ++ // RV32F Standard Extension ++ void flw(FPURegister rd, Register rs1, int16_t imm12); ++ void fsw(FPURegister source, Register base, int16_t imm12); ++ void fmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fnmsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fnmadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fadd_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fsub_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fmul_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fdiv_s(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fsqrt_s(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fsgnj_s(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fsgnjn_s(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fsgnjx_s(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fmin_s(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fmax_s(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fcvt_w_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_wu_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fmv_x_w(Register rd, FPURegister rs1); ++ void feq_s(Register rd, FPURegister rs1, FPURegister rs2); ++ void flt_s(Register rd, FPURegister rs1, FPURegister rs2); ++ void fle_s(Register rd, FPURegister rs1, FPURegister rs2); ++ void fclass_s(Register rd, FPURegister rs1); ++ void fcvt_s_w(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fcvt_s_wu(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fmv_w_x(FPURegister rd, Register rs1); ++ ++ // RV64F Standard Extension (in addition to RV32F) ++ void fcvt_l_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_lu_s(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_s_l(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fcvt_s_lu(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ ++ // RV32D Standard Extension ++ void fld(FPURegister rd, Register rs1, int16_t imm12); ++ void fsd(FPURegister source, Register base, int16_t imm12); ++ void fmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fnmsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fnmadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ FPURegister rs3, RoundingMode frm = RNE); ++ void fadd_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fsub_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fmul_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fdiv_d(FPURegister rd, FPURegister rs1, FPURegister rs2, ++ RoundingMode frm = RNE); ++ void fsqrt_d(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fsgnj_d(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fsgnjn_d(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fsgnjx_d(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fmin_d(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fmax_d(FPURegister rd, FPURegister rs1, FPURegister rs2); ++ void fcvt_s_d(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_d_s(FPURegister rd, FPURegister rs1, RoundingMode frm = RNE); ++ void feq_d(Register rd, FPURegister rs1, FPURegister rs2); ++ void flt_d(Register rd, FPURegister rs1, FPURegister rs2); ++ void fle_d(Register rd, FPURegister rs1, FPURegister rs2); ++ void fclass_d(Register rd, FPURegister rs1); ++ void fcvt_w_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_wu_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_d_w(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fcvt_d_wu(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ ++ // RV64D Standard Extension (in addition to RV32D) ++ void fcvt_l_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fcvt_lu_d(Register rd, FPURegister rs1, RoundingMode frm = RNE); ++ void fmv_x_d(Register rd, FPURegister rs1); ++ void fcvt_d_l(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fcvt_d_lu(FPURegister rd, Register rs1, RoundingMode frm = RNE); ++ void fmv_d_x(FPURegister rd, Register rs1); ++ ++ // Privileged ++ void uret(); ++ void sret(); ++ void mret(); ++ void wfi(); ++ void sfence_vma(Register rs1, Register rs2); ++ ++ // Assembler Pseudo Instructions (Tables 25.2, 25.3, RISC-V Unprivileged ISA) ++ void nop(); ++ void RV_li(Register rd, int64_t imm); ++ // Returns the number of instructions required to load the immediate ++ static int li_count(int64_t imm); ++ // Loads an immediate, always using 8 instructions, regardless of the value, ++ // so that it can be modified later. ++ void li_constant(Register rd, int64_t imm); ++ ++ void mv(Register rd, Register rs) { addi(rd, rs, 0); } ++ void not_(Register rd, Register rs) { xori(rd, rs, -1); } ++ void neg(Register rd, Register rs) { sub(rd, zero_reg, rs); } ++ void negw(Register rd, Register rs) { subw(rd, zero_reg, rs); } ++ void sext_w(Register rd, Register rs) { addiw(rd, rs, 0); } ++ void seqz(Register rd, Register rs) { sltiu(rd, rs, 1); } ++ void snez(Register rd, Register rs) { sltu(rd, zero_reg, rs); } ++ void sltz(Register rd, Register rs) { slt(rd, rs, zero_reg); } ++ void sgtz(Register rd, Register rs) { slt(rd, zero_reg, rs); } ++ ++ void fmv_s(FPURegister rd, FPURegister rs) { fsgnj_s(rd, rs, rs); } ++ void fabs_s(FPURegister rd, FPURegister rs) { fsgnjx_s(rd, rs, rs); } ++ void fneg_s(FPURegister rd, FPURegister rs) { fsgnjn_s(rd, rs, rs); } ++ void fmv_d(FPURegister rd, FPURegister rs) { fsgnj_d(rd, rs, rs); } ++ void fabs_d(FPURegister rd, FPURegister rs) { fsgnjx_d(rd, rs, rs); } ++ void fneg_d(FPURegister rd, FPURegister rs) { fsgnjn_d(rd, rs, rs); } ++ ++ void beqz(Register rs, int16_t imm13) { beq(rs, zero_reg, imm13); } ++ inline void beqz(Register rs1, Label* L) { beqz(rs1, branch_offset(L)); } ++ void bnez(Register rs, int16_t imm13) { bne(rs, zero_reg, imm13); } ++ inline void bnez(Register rs1, Label* L) { bnez(rs1, branch_offset(L)); } ++ void blez(Register rs, int16_t imm13) { bge(zero_reg, rs, imm13); } ++ inline void blez(Register rs1, Label* L) { blez(rs1, branch_offset(L)); } ++ void bgez(Register rs, int16_t imm13) { bge(rs, zero_reg, imm13); } ++ inline void bgez(Register rs1, Label* L) { bgez(rs1, branch_offset(L)); } ++ void bltz(Register rs, int16_t imm13) { blt(rs, zero_reg, imm13); } ++ inline void bltz(Register rs1, Label* L) { bltz(rs1, branch_offset(L)); } ++ void bgtz(Register rs, int16_t imm13) { blt(zero_reg, rs, imm13); } ++ ++ inline void bgtz(Register rs1, Label* L) { bgtz(rs1, branch_offset(L)); } ++ void bgt(Register rs1, Register rs2, int16_t imm13) { blt(rs2, rs1, imm13); } ++ inline void bgt(Register rs1, Register rs2, Label* L) { ++ bgt(rs1, rs2, branch_offset(L)); ++ } ++ void ble(Register rs1, Register rs2, int16_t imm13) { bge(rs2, rs1, imm13); } ++ inline void ble(Register rs1, Register rs2, Label* L) { ++ ble(rs1, rs2, branch_offset(L)); ++ } ++ void bgtu(Register rs1, Register rs2, int16_t imm13) { ++ bltu(rs2, rs1, imm13); ++ } ++ inline void bgtu(Register rs1, Register rs2, Label* L) { ++ bgtu(rs1, rs2, branch_offset(L)); ++ } ++ void bleu(Register rs1, Register rs2, int16_t imm13) { ++ bgeu(rs2, rs1, imm13); ++ } ++ inline void bleu(Register rs1, Register rs2, Label* L) { ++ bleu(rs1, rs2, branch_offset(L)); ++ } ++ ++ // TODO: Replace uses of ToRegister with names once they are properly defined ++ void j(int32_t imm21) { jal(zero_reg, imm21); } ++ inline void j(Label* L) { j(jump_offset(L)); } ++ void jal(int32_t imm21) { jal(ToRegister(1), imm21); } ++ inline void jal(Label* L) { jal(jump_offset(L)); } ++ void jr(Register rs) { jalr(zero_reg, rs, 0); } ++ void jr(Register rs, int32_t imm12) { jalr(zero_reg, rs, imm12); } ++ void jalr(Register rs, int32_t imm12) { jalr(ToRegister(1), rs, imm12); } ++ void jalr(Register rs) { jalr(ToRegister(1), rs, 0); } ++ void ret() { jalr(zero_reg, ToRegister(1), 0); } ++ void call(int32_t offset) { ++ auipc(ToRegister(1), (offset >> 12) + ((offset & 0x800) >> 11)); ++ jalr(ToRegister(1), ToRegister(1), offset << 20 >> 20); ++ } ++ ++ // Read instructions-retired counter ++ void rdinstret(Register rd) { csrrs(rd, csr_instret, zero_reg); } ++ void rdinstreth(Register rd) { csrrs(rd, csr_instreth, zero_reg); } ++ void rdcycle(Register rd) { csrrs(rd, csr_cycle, zero_reg); } ++ void rdcycleh(Register rd) { csrrs(rd, csr_cycleh, zero_reg); } ++ void rdtime(Register rd) { csrrs(rd, csr_time, zero_reg); } ++ void rdtimeh(Register rd) { csrrs(rd, csr_timeh, zero_reg); } ++ ++ void csrr(Register rd, ControlStatusReg csr) { csrrs(rd, csr, zero_reg); } ++ void csrw(ControlStatusReg csr, Register rs) { csrrw(zero_reg, csr, rs); } ++ void csrs(ControlStatusReg csr, Register rs) { csrrs(zero_reg, csr, rs); } ++ void csrc(ControlStatusReg csr, Register rs) { csrrc(zero_reg, csr, rs); } ++ ++ void csrwi(ControlStatusReg csr, uint8_t imm) { csrrwi(zero_reg, csr, imm); } ++ void csrsi(ControlStatusReg csr, uint8_t imm) { csrrsi(zero_reg, csr, imm); } ++ void csrci(ControlStatusReg csr, uint8_t imm) { csrrci(zero_reg, csr, imm); } ++ ++ void frcsr(Register rd) { csrrs(rd, csr_fcsr, zero_reg); } ++ void fscsr(Register rd, Register rs) { csrrw(rd, csr_fcsr, rs); } ++ void fscsr(Register rs) { csrrw(zero_reg, csr_fcsr, rs); } ++ ++ void frrm(Register rd) { csrrs(rd, csr_frm, zero_reg); } ++ void fsrm(Register rd, Register rs) { csrrw(rd, csr_frm, rs); } ++ void fsrm(Register rs) { csrrw(zero_reg, csr_frm, rs); } ++ ++ void frflags(Register rd) { csrrs(rd, csr_fflags, zero_reg); } ++ void fsflags(Register rd, Register rs) { csrrw(rd, csr_fflags, rs); } ++ void fsflags(Register rs) { csrrw(zero_reg, csr_fflags, rs); } ++ ++ // Other pseudo instructions that are not part of RISCV pseudo assemly ++ void nor(Register rd, Register rs, Register rt) { ++ or_(rd, rs, rt); ++ not_(rd, rd); ++ } ++ ++ void sync() { fence(0b1111, 0b1111); } ++ void break_(uint32_t code, bool break_as_stop = false); ++ void stop(uint32_t code = kMaxStopCode); ++ ++ // Check the code size generated from label to here. ++ int SizeOfCodeGeneratedSince(Label* label) { ++ return pc_offset() - label->pos(); ++ } ++ ++ // Check the number of instructions generated from label to here. ++ int InstructionsGeneratedSince(Label* label) { ++ return SizeOfCodeGeneratedSince(label) / kInstrSize; ++ } ++ ++ // Class for scoping postponing the trampoline pool generation. ++ class BlockTrampolinePoolScope { ++ public: ++ explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) { ++ assem_->StartBlockTrampolinePool(); ++ } ++ ~BlockTrampolinePoolScope() { assem_->EndBlockTrampolinePool(); } ++ ++ private: ++ Assembler* assem_; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope); ++ }; ++ ++ // Class for postponing the assembly buffer growth. Typically used for ++ // sequences of instructions that must be emitted as a unit, before ++ // buffer growth (and relocation) can occur. ++ // This blocking scope is not nestable. ++ class BlockGrowBufferScope { ++ public: ++ explicit BlockGrowBufferScope(Assembler* assem) : assem_(assem) { ++ assem_->StartBlockGrowBuffer(); ++ } ++ ~BlockGrowBufferScope() { assem_->EndBlockGrowBuffer(); } ++ ++ private: ++ Assembler* assem_; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockGrowBufferScope); ++ }; ++ ++ // Record a deoptimization reason that can be used by a log or cpu profiler. ++ // Use --trace-deopt to enable. ++ void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position, ++ int id); ++ ++ static int RelocateInternalReference(RelocInfo::Mode rmode, Address pc, ++ intptr_t pc_delta); ++ ++ // Writes a single byte or word of data in the code stream. Used for ++ // inline tables, e.g., jump-tables. ++ void db(uint8_t data); ++ void dd(uint32_t data); ++ void dq(uint64_t data); ++ void dp(uintptr_t data) { dq(data); } ++ void dd(Label* label); ++ ++ // Postpone the generation of the trampoline pool for the specified number of ++ // instructions. ++ void BlockTrampolinePoolFor(int instructions); ++ ++ // Check if there is less than kGap bytes available in the buffer. ++ // If this is the case, we need to grow the buffer before emitting ++ // an instruction or relocation information. ++ inline bool overflow() const { return pc_ >= reloc_info_writer.pos() - kGap; } ++ ++ // Get the number of bytes available in the buffer. ++ inline intptr_t available_space() const { ++ return reloc_info_writer.pos() - pc_; ++ } ++ ++ // Read/patch instructions. ++ static Instr instr_at(Address pc) { return *reinterpret_cast(pc); } ++ static void instr_at_put(Address pc, Instr instr) { ++ *reinterpret_cast(pc) = instr; ++ } ++ Instr instr_at(int pos) { ++ return *reinterpret_cast(buffer_start_ + pos); ++ } ++ void instr_at_put(int pos, Instr instr) { ++ *reinterpret_cast(buffer_start_ + pos) = instr; ++ } ++ ++ // Check if an instruction is a branch of some kind. ++ static bool IsBranch(Instr instr); ++ static bool IsJump(Instr instr); ++ static bool IsJal(Instr instr); ++ static bool IsJalr(Instr instr); ++ static bool IsLui(Instr instr); ++ static bool IsAuipc(Instr instr); ++ static bool IsAddiw(Instr instr); ++ static bool IsAddi(Instr instr); ++ static bool IsSlli(Instr instr); ++ ++ void CheckTrampolinePool(); ++ ++ inline int UnboundLabelsCount() { return unbound_labels_count_; } ++ ++ protected: ++ // Readable constants for base and offset adjustment helper, these indicate if ++ // aside from offset, another value like offset + 4 should fit into int16. ++ enum class OffsetAccessType : bool { ++ SINGLE_ACCESS = false, ++ TWO_ACCESSES = true ++ }; ++ ++ // Determine whether need to adjust base and offset of memroy load/store ++ bool NeedAdjustBaseAndOffset( ++ const MemOperand& src, OffsetAccessType = OffsetAccessType::SINGLE_ACCESS, ++ int second_Access_add_to_offset = 4); ++ ++ // Helper function for memory load/store using base register and offset. ++ void AdjustBaseAndOffset( ++ MemOperand* src, Register scratch, ++ OffsetAccessType access_type = OffsetAccessType::SINGLE_ACCESS, ++ int second_access_add_to_offset = 4); ++ ++ inline static void set_target_internal_reference_encoded_at(Address pc, ++ Address target); ++ ++ int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } ++ ++ // Decode branch instruction at pos and return branch target pos. ++ int target_at(int pos, bool is_internal); ++ ++ // Patch branch instruction at pos to branch to given branch target pos. ++ void target_at_put(int pos, int target_pos, bool is_internal); ++ ++ // Say if we need to relocate with this mode. ++ bool MustUseReg(RelocInfo::Mode rmode); ++ ++ // Record reloc info for current pc_. ++ void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); ++ ++ // Block the emission of the trampoline pool before pc_offset. ++ void BlockTrampolinePoolBefore(int pc_offset) { ++ if (no_trampoline_pool_before_ < pc_offset) ++ no_trampoline_pool_before_ = pc_offset; ++ } ++ ++ void StartBlockTrampolinePool() { trampoline_pool_blocked_nesting_++; } ++ ++ void EndBlockTrampolinePool() { ++ trampoline_pool_blocked_nesting_--; ++ if (trampoline_pool_blocked_nesting_ == 0) { ++ CheckTrampolinePoolQuick(1); ++ } ++ } ++ ++ bool is_trampoline_pool_blocked() const { ++ return trampoline_pool_blocked_nesting_ > 0; ++ } ++ ++ bool has_exception() const { return internal_trampoline_exception_; } ++ ++ bool is_trampoline_emitted() const { return trampoline_emitted_; } ++ ++ // Temporarily block automatic assembly buffer growth. ++ void StartBlockGrowBuffer() { ++ DCHECK(!block_buffer_growth_); ++ block_buffer_growth_ = true; ++ } ++ ++ void EndBlockGrowBuffer() { ++ DCHECK(block_buffer_growth_); ++ block_buffer_growth_ = false; ++ } ++ ++ bool is_buffer_growth_blocked() const { return block_buffer_growth_; } ++ ++ void CheckTrampolinePoolQuick(int extra_instructions = 0) { ++ if (pc_offset() >= next_buffer_check_ - extra_instructions * kInstrSize) { ++ CheckTrampolinePool(); ++ } ++ } ++ ++ private: ++ // Avoid overflows for displacements etc. ++ static const int kMaximalBufferSize = 512 * MB; ++ ++ // Buffer size and constant pool distance are checked together at regular ++ // intervals of kBufferCheckInterval emitted bytes. ++ static constexpr int kBufferCheckInterval = 1 * KB / 2; ++ ++ // Code generation. ++ // The relocation writer's position is at least kGap bytes below the end of ++ // the generated instructions. This is so that multi-instruction sequences do ++ // not have to check for overflow. The same is true for writes of large ++ // relocation info entries. ++ static constexpr int kGap = 64; ++ STATIC_ASSERT(AssemblerBase::kMinimalBufferSize >= 2 * kGap); ++ ++ // Repeated checking whether the trampoline pool should be emitted is rather ++ // expensive. By default we only check again once a number of instructions ++ // has been generated. ++ static constexpr int kCheckConstIntervalInst = 32; ++ static constexpr int kCheckConstInterval = ++ kCheckConstIntervalInst * kInstrSize; ++ ++ int next_buffer_check_; // pc offset of next buffer check. ++ ++ // Emission of the trampoline pool may be blocked in some code sequences. ++ int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. ++ int no_trampoline_pool_before_; // Block emission before this pc offset. ++ ++ // Keep track of the last emitted pool to guarantee a maximal distance. ++ int last_trampoline_pool_end_; // pc offset of the end of the last pool. ++ ++ // Automatic growth of the assembly buffer may be blocked for some sequences. ++ bool block_buffer_growth_; // Block growth when true. ++ ++ // Relocation information generation. ++ // Each relocation is encoded as a variable size value. ++ static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; ++ RelocInfoWriter reloc_info_writer; ++ ++ // The bound position, before this we cannot do instruction elimination. ++ int last_bound_pos_; ++ ++ // Code emission. ++ inline void CheckBuffer(); ++ void GrowBuffer(); ++ inline void emit(Instr x); ++ inline void emit(uint64_t x); ++ template ++ inline void EmitHelper(T x); ++ ++ static void disassembleInstr(Instr instr); ++ ++ // Instruction generation. ++ ++ // ----- Top-level instruction formats match those in the ISA manual ++ // (R, I, S, B, U, J). These match the formats defined in LLVM's ++ // RISCVInstrFormats.td. ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, ++ Register rs1, Register rs2); ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, ++ FPURegister rs1, FPURegister rs2); ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, ++ FPURegister rs1, Register rs2); ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, ++ Register rs1, Register rs2); ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, FPURegister rd, ++ FPURegister rs1, Register rs2); ++ void GenInstrR(uint8_t funct7, uint8_t funct3, Opcode opcode, Register rd, ++ FPURegister rs1, FPURegister rs2); ++ void GenInstrR4(uint8_t funct2, Opcode opcode, Register rd, Register rs1, ++ Register rs2, Register rs3, RoundingMode frm); ++ void GenInstrR4(uint8_t funct2, Opcode opcode, FPURegister rd, ++ FPURegister rs1, FPURegister rs2, FPURegister rs3, ++ RoundingMode frm); ++ void GenInstrRAtomic(uint8_t funct5, bool aq, bool rl, uint8_t funct3, ++ Register rd, Register rs1, Register rs2); ++ void GenInstrRFrm(uint8_t funct7, Opcode opcode, Register rd, Register rs1, ++ Register rs2, RoundingMode frm); ++ void GenInstrI(uint8_t funct3, Opcode opcode, Register rd, Register rs1, ++ int16_t imm12); ++ void GenInstrI(uint8_t funct3, Opcode opcode, FPURegister rd, Register rs1, ++ int16_t imm12); ++ void GenInstrIShift(bool arithshift, uint8_t funct3, Opcode opcode, ++ Register rd, Register rs1, uint8_t shamt); ++ void GenInstrIShiftW(bool arithshift, uint8_t funct3, Opcode opcode, ++ Register rd, Register rs1, uint8_t shamt); ++ void GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, Register rs2, ++ int16_t imm12); ++ void GenInstrS(uint8_t funct3, Opcode opcode, Register rs1, FPURegister rs2, ++ int16_t imm12); ++ void GenInstrB(uint8_t funct3, Opcode opcode, Register rs1, Register rs2, ++ int16_t imm12); ++ void GenInstrU(Opcode opcode, Register rd, int32_t imm20); ++ void GenInstrJ(Opcode opcode, Register rd, int32_t imm20); ++ ++ // ----- Instruction class templates match those in LLVM's RISCVInstrInfo.td ++ void GenInstrBranchCC_rri(uint8_t funct3, Register rs1, Register rs2, ++ int16_t imm12); ++ void GenInstrLoad_ri(uint8_t funct3, Register rd, Register rs1, ++ int16_t imm12); ++ void GenInstrStore_rri(uint8_t funct3, Register rs1, Register rs2, ++ int16_t imm12); ++ void GenInstrALU_ri(uint8_t funct3, Register rd, Register rs1, int16_t imm12); ++ void GenInstrShift_ri(bool arithshift, uint8_t funct3, Register rd, ++ Register rs1, uint8_t shamt); ++ void GenInstrALU_rr(uint8_t funct7, uint8_t funct3, Register rd, Register rs1, ++ Register rs2); ++ void GenInstrCSR_ir(uint8_t funct3, Register rd, ControlStatusReg csr, ++ Register rs1); ++ void GenInstrCSR_ii(uint8_t funct3, Register rd, ControlStatusReg csr, ++ uint8_t rs1); ++ void GenInstrShiftW_ri(bool arithshift, uint8_t funct3, Register rd, ++ Register rs1, uint8_t shamt); ++ void GenInstrALUW_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ Register rs1, Register rs2); ++ void GenInstrPriv(uint8_t funct7, Register rs1, Register rs2); ++ void GenInstrLoadFP_ri(uint8_t funct3, FPURegister rd, Register rs1, ++ int16_t imm12); ++ void GenInstrStoreFP_rri(uint8_t funct3, Register rs1, FPURegister rs2, ++ int16_t imm12); ++ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ FPURegister rs1, FPURegister rs2); ++ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ Register rs1, Register rs2); ++ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, FPURegister rd, ++ FPURegister rs1, Register rs2); ++ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ FPURegister rs1, Register rs2); ++ void GenInstrALUFP_rr(uint8_t funct7, uint8_t funct3, Register rd, ++ FPURegister rs1, FPURegister rs2); ++ ++ // Labels. ++ void print(const Label* L); ++ void bind_to(Label* L, int pos); ++ void next(Label* L, bool is_internal); ++ ++ // One trampoline consists of: ++ // - space for trampoline slots, ++ // - space for labels. ++ // ++ // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. ++ // Space for trampoline slots precedes space for labels. Each label is of one ++ // instruction size, so total amount for labels is equal to ++ // label_count * kInstrSize. ++ class Trampoline { ++ public: ++ Trampoline() { ++ start_ = 0; ++ next_slot_ = 0; ++ free_slot_count_ = 0; ++ end_ = 0; ++ } ++ Trampoline(int start, int slot_count) { ++ start_ = start; ++ next_slot_ = start; ++ free_slot_count_ = slot_count; ++ end_ = start + slot_count * kTrampolineSlotsSize; ++ } ++ int start() { return start_; } ++ int end() { return end_; } ++ int take_slot() { ++ int trampoline_slot = kInvalidSlotPos; ++ if (free_slot_count_ <= 0) { ++ // We have run out of space on trampolines. ++ // Make sure we fail in debug mode, so we become aware of each case ++ // when this happens. ++ DCHECK(0); ++ // Internal exception will be caught. ++ } else { ++ trampoline_slot = next_slot_; ++ free_slot_count_--; ++ next_slot_ += kTrampolineSlotsSize; ++ } ++ return trampoline_slot; ++ } ++ ++ private: ++ int start_; ++ int end_; ++ int next_slot_; ++ int free_slot_count_; ++ }; ++ ++ int32_t get_trampoline_entry(int32_t pos); ++ int unbound_labels_count_; ++ // After trampoline is emitted, long branches are used in generated code for ++ // the forward branches whose target offsets could be beyond reach of branch ++ // instruction. We use this information to trigger different mode of ++ // branch instruction generation, where we use jump instructions rather ++ // than regular branch instructions. ++ bool trampoline_emitted_ = false; ++ static constexpr int kInvalidSlotPos = -1; ++ ++ // Internal reference positions, required for unbounded internal reference ++ // labels. ++ std::set internal_reference_positions_; ++ bool is_internal_reference(Label* L) { ++ return internal_reference_positions_.find(L->pos()) != ++ internal_reference_positions_.end(); ++ } ++ ++ Trampoline trampoline_; ++ bool internal_trampoline_exception_; ++ ++ RegList scratch_register_list_; ++ ++ private: ++ void AllocateAndInstallRequestedHeapObjects(Isolate* isolate); ++ ++ int WriteCodeComments(); ++ ++ friend class RegExpMacroAssemblerRISCV; ++ friend class RelocInfo; ++ friend class BlockTrampolinePoolScope; ++ friend class EnsureSpace; ++}; ++ ++class EnsureSpace { ++ public: ++ explicit inline EnsureSpace(Assembler* assembler); ++}; ++ ++class V8_EXPORT_PRIVATE UseScratchRegisterScope { ++ public: ++ explicit UseScratchRegisterScope(Assembler* assembler); ++ ~UseScratchRegisterScope(); ++ ++ Register Acquire(); ++ bool hasAvailable() const; ++ ++ private: ++ RegList* available_; ++ RegList old_available_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_RISCV_ASSEMBLER_RISCV_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/constants-riscv64.cc +@@ -0,0 +1,111 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/riscv64/constants-riscv64.h" ++ ++namespace v8 { ++namespace internal { ++ ++// ----------------------------------------------------------------------------- ++// Registers. ++ ++// These register names are defined in a way to match the native disassembler ++// formatting. See for example the command "objdump -d ". ++const char* Registers::names_[kNumSimuRegisters] = { ++ "zero_reg", "ra", "sp", "gp", "tp", "t0", "t1", "t2", "fp", "s1", "a0", ++ "a1", "a2", "a3", "a4", "a5", "a6", "a7", "s2", "s3", "s4", "s5", ++ "s6", "s7", "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6", "pc"}; ++ ++// List of alias names which can be used when referring to RISC-V registers. ++const Registers::RegisterAlias Registers::aliases_[] = { ++ {0, "zero"}, ++ {33, "pc"}, ++ {8, "s0"}, ++ {8, "s0_fp"}, ++ {kInvalidRegister, nullptr}}; ++ ++const char* Registers::Name(int reg) { ++ const char* result; ++ if ((0 <= reg) && (reg < kNumSimuRegisters)) { ++ result = names_[reg]; ++ } else { ++ result = "noreg"; ++ } ++ return result; ++} ++ ++int Registers::Number(const char* name) { ++ // Look through the canonical names. ++ for (int i = 0; i < kNumSimuRegisters; i++) { ++ if (strcmp(names_[i], name) == 0) { ++ return i; ++ } ++ } ++ ++ // Look through the alias names. ++ int i = 0; ++ while (aliases_[i].reg != kInvalidRegister) { ++ if (strcmp(aliases_[i].name, name) == 0) { ++ return aliases_[i].reg; ++ } ++ i++; ++ } ++ ++ // No register with the reguested name found. ++ return kInvalidRegister; ++} ++ ++/* ++const char* FPURegisters::names_[kNumFPURegisters] = { ++ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", ++ "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", ++ "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"}; ++*/ ++const char* FPURegisters::names_[kNumFPURegisters] = { ++ "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", ++ "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", ++ "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", ++ "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11"}; ++ ++// List of alias names which can be used when referring to RISC-V FP registers. ++const FPURegisters::RegisterAlias FPURegisters::aliases_[] = { ++ {kInvalidRegister, nullptr}}; ++ ++const char* FPURegisters::Name(int creg) { ++ const char* result; ++ if ((0 <= creg) && (creg < kNumFPURegisters)) { ++ result = names_[creg]; ++ } else { ++ result = "nocreg"; ++ } ++ return result; ++} ++ ++int FPURegisters::Number(const char* name) { ++ // Look through the canonical names. ++ for (int i = 0; i < kNumFPURegisters; i++) { ++ if (strcmp(names_[i], name) == 0) { ++ return i; ++ } ++ } ++ ++ // Look through the alias names. ++ int i = 0; ++ while (aliases_[i].creg != kInvalidRegister) { ++ if (strcmp(aliases_[i].name, name) == 0) { ++ return aliases_[i].creg; ++ } ++ i++; ++ } ++ ++ // No Cregister with the reguested name found. ++ return kInvalidFPURegister; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/constants-riscv64.h +@@ -0,0 +1,947 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ ++#define V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ ++ ++#include "src/base/logging.h" ++#include "src/base/macros.h" ++#include "src/common/globals.h" ++ ++// UNIMPLEMENTED_ macro for RISCV. ++#ifdef DEBUG ++#define UNIMPLEMENTED_RISCV() \ ++ v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ ++ __FILE__, __LINE__, __func__) ++#else ++#define UNIMPLEMENTED_RISCV() ++#endif ++ ++#define UNSUPPORTED_RISCV() v8::internal::PrintF("Unsupported instruction.\n") ++ ++enum Endianness { kLittle, kBig }; ++ ++#if defined(V8_TARGET_LITTLE_ENDIAN) ++static const Endianness kArchEndian = kLittle; ++#elif defined(V8_TARGET_BIG_ENDIAN) ++static const Endianness kArchEndian = kBig; ++#else ++#error Unknown endianness ++#endif ++ ++#if defined(V8_TARGET_LITTLE_ENDIAN) ++const uint32_t kLeastSignificantByteInInt32Offset = 0; ++const uint32_t kLessSignificantWordInDoublewordOffset = 0; ++#elif defined(V8_TARGET_BIG_ENDIAN) ++const uint32_t kLeastSignificantByteInInt32Offset = 3; ++const uint32_t kLessSignificantWordInDoublewordOffset = 4; ++#else ++#error Unknown endianness ++#endif ++ ++#ifndef __STDC_FORMAT_MACROS ++#define __STDC_FORMAT_MACROS ++#endif ++#include ++ ++// Defines constants and accessor classes to assemble, disassemble and ++// simulate RISC-V instructions. ++// ++// See: The RISC-V Instruction Set Manual ++// Volume I: User-Level ISA ++// Try https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf. ++ ++namespace v8 { ++namespace internal { ++ ++// TODO(sigurds): Change this value once we use relative jumps. ++constexpr size_t kMaxPCRelativeCodeRangeInMB = 0; ++ ++// ----------------------------------------------------------------------------- ++// Registers and FPURegisters. ++ ++// Number of general purpose registers. ++const int kNumRegisters = 32; ++const int kInvalidRegister = -1; ++ ++// Number of registers with pc. ++const int kNumSimuRegisters = 33; ++ ++// In the simulator, the PC register is simulated as the 34th register. ++const int kPCRegister = 34; ++ ++// Number coprocessor registers. ++const int kNumFPURegisters = 32; ++const int kInvalidFPURegister = -1; ++ ++// 'pref' instruction hints ++const int32_t kPrefHintLoad = 0; ++const int32_t kPrefHintStore = 1; ++const int32_t kPrefHintLoadStreamed = 4; ++const int32_t kPrefHintStoreStreamed = 5; ++const int32_t kPrefHintLoadRetained = 6; ++const int32_t kPrefHintStoreRetained = 7; ++const int32_t kPrefHintWritebackInvalidate = 25; ++const int32_t kPrefHintPrepareForStore = 30; ++ ++// Actual value of root register is offset from the root array's start ++// to take advantage of negative displacement values. ++// TODO(sigurds): Choose best value. ++constexpr int kRootRegisterBias = 256; ++ ++// Helper functions for converting between register numbers and names. ++class Registers { ++ public: ++ // Return the name of the register. ++ static const char* Name(int reg); ++ ++ // Lookup the register number for the name provided. ++ static int Number(const char* name); ++ ++ struct RegisterAlias { ++ int reg; ++ const char* name; ++ }; ++ ++ static const int64_t kMaxValue = 0x7fffffffffffffffl; ++ static const int64_t kMinValue = 0x8000000000000000l; ++ ++ private: ++ static const char* names_[kNumSimuRegisters]; ++ static const RegisterAlias aliases_[]; ++}; ++ ++// Helper functions for converting between register numbers and names. ++class FPURegisters { ++ public: ++ // Return the name of the register. ++ static const char* Name(int reg); ++ ++ // Lookup the register number for the name provided. ++ static int Number(const char* name); ++ ++ struct RegisterAlias { ++ int creg; ++ const char* name; ++ }; ++ ++ private: ++ static const char* names_[kNumFPURegisters]; ++ static const RegisterAlias aliases_[]; ++}; ++ ++// ----------------------------------------------------------------------------- ++// Instructions encoding constants. ++ ++// On RISCV all instructions are 32 bits. ++using Instr = int32_t; ++ ++// Special Software Interrupt codes when used in the presence of the RISC-V ++// simulator. ++enum SoftwareInterruptCodes { ++ // Transition to C code. ++ call_rt_redirected = 0xfffff ++}; ++ ++// On RISC-V Simulator breakpoints can have different codes: ++// - Breaks between 0 and kMaxWatchpointCode are treated as simple watchpoints, ++// the simulator will run through them and print the registers. ++// - Breaks between kMaxWatchpointCode and kMaxStopCode are treated as stop() ++// instructions (see Assembler::stop()). ++// - Breaks larger than kMaxStopCode are simple breaks, dropping you into the ++// debugger. ++const uint32_t kMaxWatchpointCode = 31; ++const uint32_t kMaxStopCode = 127; ++STATIC_ASSERT(kMaxWatchpointCode < kMaxStopCode); ++ ++// ----- Fields offset and length. ++// RISCV constants ++const int kBaseOpcodeShift = 0; ++const int kBaseOpcodeBits = 7; ++const int kFunct7Shift = 25; ++const int kFunct7Bits = 7; ++const int kFunct5Shift = 27; ++const int kFunct5Bits = 5; ++const int kFunct3Shift = 12; ++const int kFunct3Bits = 3; ++const int kFunct2Shift = 25; ++const int kFunct2Bits = 2; ++const int kRs1Shift = 15; ++const int kRs1Bits = 5; ++const int kRs2Shift = 20; ++const int kRs2Bits = 5; ++const int kRs3Shift = 27; ++const int kRs3Bits = 5; ++const int kRdShift = 7; ++const int kRdBits = 5; ++const int kRlShift = 25; ++const int kAqShift = 26; ++const int kImm12Shift = 20; ++const int kImm12Bits = 12; ++const int kShamtShift = 20; ++const int kShamtBits = 5; ++const int kShamtWShift = 20; ++const int kShamtWBits = 6; ++const int kArithShiftShift = 30; ++const int kImm20Shift = 12; ++const int kImm20Bits = 20; ++const int kCsrShift = 20; ++const int kCsrBits = 12; ++const int kMemOrderBits = 4; ++const int kPredOrderShift = 24; ++const int kSuccOrderShift = 20; ++ ++// RISCV Instruction bit masks ++const uint32_t kBaseOpcodeMask = ((1 << kBaseOpcodeBits) - 1) << kBaseOpcodeShift; ++const uint32_t kFunct3Mask = ((1 << kFunct3Bits) - 1) << kFunct3Shift; ++const uint32_t kFunct5Mask = ((1 << kFunct5Bits) - 1) << kFunct5Shift; ++const uint32_t kFunct7Mask = ((1 << kFunct7Bits) - 1) << kFunct7Shift; ++const uint32_t kFunct2Mask = 0b11 << kFunct7Shift; ++const uint32_t kRTypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct7Mask; ++const uint32_t kRATypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct5Mask; ++const uint32_t kRFPTypeMask = kBaseOpcodeMask | kFunct7Mask; ++const uint32_t kR4TypeMask = kBaseOpcodeMask | kFunct3Mask | kFunct2Mask; ++const uint32_t kITypeMask = kBaseOpcodeMask | kFunct3Mask; ++const uint32_t kSTypeMask = kBaseOpcodeMask | kFunct3Mask; ++const uint32_t kBTypeMask = kBaseOpcodeMask | kFunct3Mask; ++const uint32_t kUTypeMask = kBaseOpcodeMask; ++const uint32_t kJTypeMask = kBaseOpcodeMask; ++const uint32_t kRs1FieldMask = ((1 << kRs1Bits) - 1) << kRs1Shift; ++const uint32_t kRs2FieldMask = ((1 << kRs2Bits) - 1) << kRs2Shift; ++const uint32_t kRs3FieldMask = ((1 << kRs3Bits) - 1) << kRs3Shift; ++const uint32_t kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; ++const uint32_t kBImm12Mask = kFunct7Mask | kRdFieldMask; ++const uint32_t kImm20Mask = ((1 << kImm20Bits) - 1) << kImm20Shift; ++const uint32_t kImm12Mask = ((1 << kImm12Bits) - 1) << kImm12Shift; ++ ++// RISCV CSR related bit mask and shift ++const uint32_t kFcsrFlagsBits = 5; ++const uint32_t kFcsrFlagsMask = (1 << kFcsrFlagsBits) - 1; ++const uint32_t kFcsrFrmBits = 3; ++const uint32_t kFcsrFrmShift = kFcsrFlagsBits; ++const uint32_t kFcsrFrmMask = ((1 << kFcsrFrmBits) - 1) << kFcsrFrmShift; ++const uint32_t kFcsrBits = kFcsrFlagsBits + kFcsrFrmBits; ++const uint32_t kFcsrMask = kFcsrFlagsMask | kFcsrFrmMask; ++ ++// Original MIPS constants ++// FIXME (RISCV): to be cleaned up ++const uint32_t kImm16Shift = 0; ++const uint32_t kImm16Bits = 16; ++const uint32_t kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; ++// end of FIXME (RISCV): to be cleaned up ++ ++// ----- RISCV Base Opcodes ++ ++enum BaseOpcode : uint32_t { ++ ++}; ++ ++// ----- RISC-V Opcodes and Function Fields. ++enum Opcode : uint32_t { ++ LOAD = 0b0000011, // I form: LB LH LW LBU LHU ++ LOAD_FP = 0b0000111, // I form: FLW FLD FLQ ++ MISC_MEM = 0b0001111, // I special form: FENCE FENCE.I ++ OP_IMM = 0b0010011, // I form: ADDI SLTI SLTIU XORI ORI ANDI SLLI SRLI SARI ++ // Note: SLLI/SRLI/SRAI I form first, then func3 001/101 => R type ++ AUIPC = 0b0010111, // U form: AUIPC ++ OP_IMM_32 = 0b0011011, // I form: ADDIW SLLIW SRLIW SRAIW ++ // Note: SRLIW SRAIW I form first, then func3 101 special shift encoding ++ STORE = 0b0100011, // S form: SB SH SW SD ++ STORE_FP = 0b0100111, // S form: FSW FSD FSQ ++ AMO = 0b0101111, // R form: All A instructions ++ OP = 0b0110011, // R: ADD SUB SLL SLT SLTU XOR SRL SRA OR AND and 32M set ++ LUI = 0b0110111, // U form: LUI ++ OP_32 = 0b0111011, // R: ADDW SUBW SLLW SRLW SRAW MULW DIVW DIVUW REMW REMUW ++ MADD = 0b1000011, // R4 type: FMADD.S FMADD.D FMADD.Q ++ MSUB = 0b1000111, // R4 type: FMSUB.S FMSUB.D FMSUB.Q ++ NMSUB = 0b1001011, // R4 type: FNMSUB.S FNMSUB.D FNMSUB.Q ++ NMADD = 0b1001111, // R4 type: FNMADD.S FNMADD.D FNMADD.Q ++ OP_FP = 0b1010011, // R type: Q ext ++ BRANCH = 0b1100011, // B form: BEQ BNE, BLT, BGE, BLTU BGEU ++ JALR = 0b1100111, // I form: JALR ++ JAL = 0b1101111, // J form: JAL ++ SYSTEM = 0b1110011, // I form: ECALL EBREAK Zicsr ext ++ ++ // Note use RO (RiscV Opcode) prefix ++ // RV32I Base Instruction Set ++ RO_LUI = LUI, ++ RO_AUIPC = AUIPC, ++ RO_JAL = JAL, ++ RO_JALR = JALR | (0b000 << kFunct3Shift), ++ RO_BEQ = BRANCH | (0b000 << kFunct3Shift), ++ RO_BNE = BRANCH | (0b001 << kFunct3Shift), ++ RO_BLT = BRANCH | (0b100 << kFunct3Shift), ++ RO_BGE = BRANCH | (0b101 << kFunct3Shift), ++ RO_BLTU = BRANCH | (0b110 << kFunct3Shift), ++ RO_BGEU = BRANCH | (0b111 << kFunct3Shift), ++ RO_LB = LOAD | (0b000 << kFunct3Shift), ++ RO_LH = LOAD | (0b001 << kFunct3Shift), ++ RO_LW = LOAD | (0b010 << kFunct3Shift), ++ RO_LBU = LOAD | (0b100 << kFunct3Shift), ++ RO_LHU = LOAD | (0b101 << kFunct3Shift), ++ RO_SB = STORE | (0b000 << kFunct3Shift), ++ RO_SH = STORE | (0b001 << kFunct3Shift), ++ RO_SW = STORE | (0b010 << kFunct3Shift), ++ RO_ADDI = OP_IMM | (0b000 << kFunct3Shift), ++ RO_SLTI = OP_IMM | (0b010 << kFunct3Shift), ++ RO_SLTIU = OP_IMM | (0b011 << kFunct3Shift), ++ RO_XORI = OP_IMM | (0b100 << kFunct3Shift), ++ RO_ORI = OP_IMM | (0b110 << kFunct3Shift), ++ RO_ANDI = OP_IMM | (0b111 << kFunct3Shift), ++ RO_SLLI = OP_IMM | (0b001 << kFunct3Shift), ++ RO_SRLI = OP_IMM | (0b101 << kFunct3Shift), ++ // RO_SRAI = OP_IMM | (0b101 << kFunct3Shift), // Same as SRLI, use func7 ++ RO_ADD = OP | (0b000 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SUB = OP | (0b000 << kFunct3Shift) | (0b0100000 << kFunct7Shift), ++ RO_SLL = OP | (0b001 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SLT = OP | (0b010 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SLTU = OP | (0b011 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_XOR = OP | (0b100 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SRL = OP | (0b101 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SRA = OP | (0b101 << kFunct3Shift) | (0b0100000 << kFunct7Shift), ++ RO_OR = OP | (0b110 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_AND = OP | (0b111 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_FENCE = MISC_MEM | (0b000 << kFunct3Shift), ++ RO_ECALL = SYSTEM | (0b000 << kFunct3Shift), ++ // RO_EBREAK = SYSTEM | (0b000 << kFunct3Shift), // Same as ECALL, use imm12 ++ ++ // RV64I Base Instruction Set (in addition to RV32I) ++ RO_LWU = LOAD | (0b110 << kFunct3Shift), ++ RO_LD = LOAD | (0b011 << kFunct3Shift), ++ RO_SD = STORE | (0b011 << kFunct3Shift), ++ RO_ADDIW = OP_IMM_32 | (0b000 << kFunct3Shift), ++ RO_SLLIW = OP_IMM_32 | (0b001 << kFunct3Shift), ++ RO_SRLIW = OP_IMM_32 | (0b101 << kFunct3Shift), ++ // RO_SRAIW = OP_IMM_32 | (0b101 << kFunct3Shift), // Same as SRLIW, use func7 ++ RO_ADDW = OP_32 | (0b000 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SUBW = OP_32 | (0b000 << kFunct3Shift) | (0b0100000 << kFunct7Shift), ++ RO_SLLW = OP_32 | (0b001 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SRLW = OP_32 | (0b101 << kFunct3Shift) | (0b0000000 << kFunct7Shift), ++ RO_SRAW = OP_32 | (0b101 << kFunct3Shift) | (0b0100000 << kFunct7Shift), ++ ++ // RV32/RV64 Zifencei Standard Extension ++ RO_FENCE_I = MISC_MEM | (0b001 << kFunct3Shift), ++ ++ // RV32/RV64 Zicsr Standard Extension ++ RO_CSRRW = SYSTEM | (0b001 << kFunct3Shift), ++ RO_CSRRS = SYSTEM | (0b010 << kFunct3Shift), ++ RO_CSRRC = SYSTEM | (0b011 << kFunct3Shift), ++ RO_CSRRWI = SYSTEM | (0b101 << kFunct3Shift), ++ RO_CSRRSI = SYSTEM | (0b110 << kFunct3Shift), ++ RO_CSRRCI = SYSTEM | (0b111 << kFunct3Shift), ++ ++ // RV32M Standard Extension ++ RO_MUL = OP | (0b000 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_MULH = OP | (0b001 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_MULHSU = OP | (0b010 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_MULHU = OP | (0b011 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_DIV = OP | (0b100 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_DIVU = OP | (0b101 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_REM = OP | (0b110 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_REMU = OP | (0b111 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ ++ // RV64M Standard Extension (in addition to RV32M) ++ RO_MULW = OP_32 | (0b000 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_DIVW = OP_32 | (0b100 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_DIVUW = OP_32 | (0b101 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_REMW = OP_32 | (0b110 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ RO_REMUW = OP_32 | (0b111 << kFunct3Shift) | (0b0000001 << kFunct7Shift), ++ ++ // RV32A Standard Extension ++ RO_LR_W = AMO | (0b010 << kFunct3Shift) | (0b00010 << kFunct5Shift), ++ RO_SC_W = AMO | (0b010 << kFunct3Shift) | (0b00011 << kFunct5Shift), ++ RO_AMOSWAP_W = AMO | (0b010 << kFunct3Shift) | (0b00001 << kFunct5Shift), ++ RO_AMOADD_W = AMO | (0b010 << kFunct3Shift) | (0b00000 << kFunct5Shift), ++ RO_AMOXOR_W = AMO | (0b010 << kFunct3Shift) | (0b00100 << kFunct5Shift), ++ RO_AMOAND_W = AMO | (0b010 << kFunct3Shift) | (0b01100 << kFunct5Shift), ++ RO_AMOOR_W = AMO | (0b010 << kFunct3Shift) | (0b01000 << kFunct5Shift), ++ RO_AMOMIN_W = AMO | (0b010 << kFunct3Shift) | (0b10000 << kFunct5Shift), ++ RO_AMOMAX_W = AMO | (0b010 << kFunct3Shift) | (0b10100 << kFunct5Shift), ++ RO_AMOMINU_W = AMO | (0b010 << kFunct3Shift) | (0b11000 << kFunct5Shift), ++ RO_AMOMAXU_W = AMO | (0b010 << kFunct3Shift) | (0b11100 << kFunct5Shift), ++ ++ // RV64A Standard Extension (in addition to RV32A) ++ RO_LR_D = AMO | (0b011 << kFunct3Shift) | (0b00010 << kFunct5Shift), ++ RO_SC_D = AMO | (0b011 << kFunct3Shift) | (0b00011 << kFunct5Shift), ++ RO_AMOSWAP_D = AMO | (0b011 << kFunct3Shift) | (0b00001 << kFunct5Shift), ++ RO_AMOADD_D = AMO | (0b011 << kFunct3Shift) | (0b00000 << kFunct5Shift), ++ RO_AMOXOR_D = AMO | (0b011 << kFunct3Shift) | (0b00100 << kFunct5Shift), ++ RO_AMOAND_D = AMO | (0b011 << kFunct3Shift) | (0b01100 << kFunct5Shift), ++ RO_AMOOR_D = AMO | (0b011 << kFunct3Shift) | (0b01000 << kFunct5Shift), ++ RO_AMOMIN_D = AMO | (0b011 << kFunct3Shift) | (0b10000 << kFunct5Shift), ++ RO_AMOMAX_D = AMO | (0b011 << kFunct3Shift) | (0b10100 << kFunct5Shift), ++ RO_AMOMINU_D = AMO | (0b011 << kFunct3Shift) | (0b11000 << kFunct5Shift), ++ RO_AMOMAXU_D = AMO | (0b011 << kFunct3Shift) | (0b11100 << kFunct5Shift), ++ ++ // RV32F Standard Extension ++ RO_FLW = LOAD_FP | (0b010 << kFunct3Shift), ++ RO_FSW = STORE_FP | (0b010 << kFunct3Shift), ++ RO_FMADD_S = MADD | (0b00 << kFunct2Shift), ++ RO_FMSUB_S = MSUB | (0b00 << kFunct2Shift), ++ RO_FNMSUB_S = NMSUB | (0b00 << kFunct2Shift), ++ RO_FNMADD_S = NMADD | (0b00 << kFunct2Shift), ++ RO_FADD_S = OP_FP | (0b0000000 << kFunct7Shift), ++ RO_FSUB_S = OP_FP | (0b0000100 << kFunct7Shift), ++ RO_FMUL_S = OP_FP | (0b0001000 << kFunct7Shift), ++ RO_FDIV_S = OP_FP | (0b0001100 << kFunct7Shift), ++ RO_FSQRT_S = OP_FP | (0b0101100 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FSGNJ_S = OP_FP | (0b000 << kFunct3Shift) | (0b0010000 << kFunct7Shift), ++ RO_FSGNJN_S = OP_FP | (0b001 << kFunct3Shift) | (0b0010000 << kFunct7Shift), ++ RO_FSQNJX_S = OP_FP | (0b010 << kFunct3Shift) | (0b0010000 << kFunct7Shift), ++ RO_FMIN_S = OP_FP | (0b000 << kFunct3Shift) | (0b0010100 << kFunct7Shift), ++ RO_FMAX_S = OP_FP | (0b001 << kFunct3Shift) | (0b0010100 << kFunct7Shift), ++ RO_FCVT_W_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FCVT_WU_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00001 << kRs2Shift), ++ RO_FMV = OP_FP | (0b1110000 << kFunct7Shift) | (0b000 << kFunct3Shift) | ++ (0b00000 << kRs2Shift), ++ RO_FEQ_S = OP_FP | (0b010 << kFunct3Shift) | (0b1010000 << kFunct7Shift), ++ RO_FLT_S = OP_FP | (0b001 << kFunct3Shift) | (0b1010000 << kFunct7Shift), ++ RO_FLE_S = OP_FP | (0b000 << kFunct3Shift) | (0b1010000 << kFunct7Shift), ++ RO_FCLASS_S = OP_FP | (0b001 << kFunct3Shift) | (0b1110000 << kFunct7Shift), ++ RO_FCVT_S_W = OP_FP | (0b1101000 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FCVT_S_WU = OP_FP | (0b1101000 << kFunct7Shift) | (0b00001 << kRs2Shift), ++ RO_FMV_W_X = OP_FP | (0b000 << kFunct3Shift) | (0b1111000 << kFunct7Shift), ++ ++ // RV64F Standard Extension (in addition to RV32F) ++ RO_FCVT_L_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00010 << kRs2Shift), ++ RO_FCVT_LU_S = OP_FP | (0b1100000 << kFunct7Shift) | (0b00011 << kRs2Shift), ++ RO_FCVT_S_L = OP_FP | (0b1101000 << kFunct7Shift) | (0b00010 << kRs2Shift), ++ RO_FCVT_S_LU = OP_FP | (0b1101000 << kFunct7Shift) | (0b00011 << kRs2Shift), ++ ++ // RV32D Standard Extension ++ RO_FLD = LOAD_FP | (0b011 << kFunct3Shift), ++ RO_FSD = STORE_FP | (0b011 << kFunct3Shift), ++ RO_FMADD_D = MADD | (0b01 << kFunct2Shift), ++ RO_FMSUB_D = MSUB | (0b01 << kFunct2Shift), ++ RO_FNMSUB_D = NMSUB | (0b01 << kFunct2Shift), ++ RO_FNMADD_D = NMADD | (0b01 << kFunct2Shift), ++ RO_FADD_D = OP_FP | (0b0000001 << kFunct7Shift), ++ RO_FSUB_D = OP_FP | (0b0000101 << kFunct7Shift), ++ RO_FMUL_D = OP_FP | (0b0001001 << kFunct7Shift), ++ RO_FDIV_D = OP_FP | (0b0001101 << kFunct7Shift), ++ RO_FSQRT_D = OP_FP | (0b0101101 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FSGNJ_D = OP_FP | (0b000 << kFunct3Shift) | (0b0010001 << kFunct7Shift), ++ RO_FSGNJN_D = OP_FP | (0b001 << kFunct3Shift) | (0b0010001 << kFunct7Shift), ++ RO_FSQNJX_D = OP_FP | (0b010 << kFunct3Shift) | (0b0010001 << kFunct7Shift), ++ RO_FMIN_D = OP_FP | (0b000 << kFunct3Shift) | (0b0010101 << kFunct7Shift), ++ RO_FMAX_D = OP_FP | (0b001 << kFunct3Shift) | (0b0010101 << kFunct7Shift), ++ RO_FCVT_S_D = OP_FP | (0b0100000 << kFunct7Shift) | (0b00001 << kRs2Shift), ++ RO_FCVT_D_S = OP_FP | (0b0100001 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FEQ_D = OP_FP | (0b010 << kFunct3Shift) | (0b1010001 << kFunct7Shift), ++ RO_FLT_D = OP_FP | (0b001 << kFunct3Shift) | (0b1010001 << kFunct7Shift), ++ RO_FLE_D = OP_FP | (0b000 << kFunct3Shift) | (0b1010001 << kFunct7Shift), ++ RO_FCLASS_D = OP_FP | (0b001 << kFunct3Shift) | (0b1110001 << kFunct7Shift) | ++ (0b00000 << kRs2Shift), ++ RO_FCVT_W_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FCVT_WU_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00001 << kRs2Shift), ++ RO_FCVT_D_W = OP_FP | (0b1101001 << kFunct7Shift) | (0b00000 << kRs2Shift), ++ RO_FCVT_D_WU = OP_FP | (0b1101001 << kFunct7Shift) | (0b00001 << kRs2Shift), ++ ++ // RV64D Standard Extension (in addition to RV32D) ++ RO_FCVT_L_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00010 << kRs2Shift), ++ RO_FCVT_LU_D = OP_FP | (0b1100001 << kFunct7Shift) | (0b00011 << kRs2Shift), ++ RO_FMV_X_D = OP_FP | (0b000 << kFunct3Shift) | (0b1110001 << kFunct7Shift) | ++ (0b00000 << kRs2Shift), ++ RO_FCVT_D_L = OP_FP | (0b1101001 << kFunct7Shift) | (0b00010 << kRs2Shift), ++ RO_FCVT_D_LU = OP_FP | (0b1101001 << kFunct7Shift) | (0b00011 << kRs2Shift), ++ RO_FMV_D_X = OP_FP | (0b000 << kFunct3Shift) | (0b1111001 << kFunct7Shift) | ++ (0b00000 << kRs2Shift), ++}; ++ ++// ----- Emulated conditions. ++// On RISC-V we use this enum to abstract from conditional branch instructions. ++// The 'U' prefix is used to specify unsigned comparisons. ++// Opposite conditions must be paired as odd/even numbers ++// because 'NegateCondition' function flips LSB to negate condition. ++enum Condition { // Any value < 0 is considered no_condition. ++ kNoCondition = -1, ++ overflow = 0, ++ no_overflow = 1, ++ Uless = 2, ++ Ugreater_equal = 3, ++ Uless_equal = 4, ++ Ugreater = 5, ++ equal = 6, ++ not_equal = 7, // Unordered or Not Equal. ++ less = 8, ++ greater_equal = 9, ++ less_equal = 10, ++ greater = 11, ++ cc_always = 12, ++ ++ // Aliases. ++ eq = equal, ++ ne = not_equal, ++ ge = greater_equal, ++ lt = less, ++ gt = greater, ++ le = less_equal, ++ al = cc_always, ++ ult = Uless, ++ uge = Ugreater_equal, ++ ule = Uless_equal, ++ ugt = Ugreater, ++}; ++ ++// Returns the equivalent of !cc. ++// Negation of the default kNoCondition (-1) results in a non-default ++// no_condition value (-2). As long as tests for no_condition check ++// for condition < 0, this will work as expected. ++inline Condition NegateCondition(Condition cc) { ++ DCHECK(cc != cc_always); ++ return static_cast(cc ^ 1); ++} ++ ++inline Condition NegateFpuCondition(Condition cc) { ++ DCHECK(cc != cc_always); ++ switch (cc) { ++ case ult: ++ return ge; ++ case ugt: ++ return le; ++ case uge: ++ return lt; ++ case ule: ++ return gt; ++ case lt: ++ return uge; ++ case gt: ++ return ule; ++ case ge: ++ return ult; ++ case le: ++ return ugt; ++ case eq: ++ return ne; ++ case ne: ++ return eq; ++ default: ++ return cc; ++ } ++} ++ ++// ----- Coprocessor conditions. ++enum FPUCondition { ++ kNoFPUCondition = -1, ++ EQ = 0x02, // Ordered and Equal ++ NE = 0x03, // Unordered or Not Equal ++ LT = 0x04, // Ordered and Less Than ++ GE = 0x05, // Ordered and Greater Than or Equal ++ LE = 0x06, // Ordered and Less Than or Equal ++ GT = 0x07, // Ordered and Greater Than ++}; ++ ++enum CheckForInexactConversion { ++ kCheckForInexactConversion, ++ kDontCheckForInexactConversion ++}; ++ ++enum class MaxMinKind : int { kMin = 0, kMax = 1 }; ++ ++// ---------------------------------------------------------------------------- ++// RISCV flags ++ ++enum ControlStatusReg { ++ csr_fflags = 0x001, // Floating-Point Accrued Exceptions (RW) ++ csr_frm = 0x002, // Floating-Point Dynamic Rounding Mode (RW) ++ csr_fcsr = 0x003, // Floating-Point Control and Status Register (RW) ++ csr_cycle = 0xc00, // Cycle counter for RDCYCLE instruction (RO) ++ csr_time = 0xc01, // Timer for RDTIME instruction (RO) ++ csr_instret = 0xc02, // Insns-retired counter for RDINSTRET instruction (RO) ++ csr_cycleh = 0xc80, // Upper 32 bits of cycle, RV32I only (RO) ++ csr_timeh = 0xc81, // Upper 32 bits of time, RV32I only (RO) ++ csr_instreth = 0xc82 // Upper 32 bits of instret, RV32I only (RO) ++}; ++ ++enum FFlagsMask { ++ kInvalidOperation = 0b10000, // NV: Invalid ++ kDivideByZero = 0b1000, // DZ: Divide by Zero ++ kOverflow = 0b100, // OF: Overflow ++ kUnderflow = 0b10, // UF: Underflow ++ kInexact = 0b1 // NX: Inexact ++}; ++ ++enum RoundingMode { ++ RNE = 0b000, // Round to Nearest, ties to Even ++ RTZ = 0b001, // Round towards Zero ++ RDN = 0b010, // Round Down (towards -infinity) ++ RUP = 0b011, // Round Up (towards +infinity) ++ RMM = 0b100, // Round to Nearest, tiest to Max Magnitude ++ DYN = 0b111 // In instruction's rm field, selects dynamic rounding mode; ++ // In Rounding Mode register, Invalid ++}; ++ ++enum MemoryOdering { ++ PSI = 0b1000, // PI or SI ++ PSO = 0b0100, // PO or SO ++ PSR = 0b0010, // PR or SR ++ PSW = 0b0001, // PW or SW ++ PSIORW = PSI | PSO | PSR | PSW ++}; ++ ++enum FClassFlag { ++ kNegativeInfinity = 1, ++ kNegativeNormalNumber = 1 << 1, ++ kNegativeSubnormalNumber = 1 << 2, ++ kNegativeZero = 1 << 3, ++ kPositiveZero = 1 << 4, ++ kPositiveSubnormalNumber = 1 << 5, ++ kPositiveNormalNumber = 1 << 6, ++ kPositiveInfinity = 1 << 7, ++ kSignalingNaN = 1 << 8, ++ kQuietNaN = 1 << 9 ++}; ++ ++// ----------------------------------------------------------------------------- ++// Hints. ++ ++// Branch hints are not used on RISC-V. They are defined so that they can ++// appear in shared function signatures, but will be ignored in RISC-V ++// implementations. ++enum Hint { no_hint = 0 }; ++ ++inline Hint NegateHint(Hint hint) { return no_hint; } ++ ++// ----------------------------------------------------------------------------- ++// Specific instructions, constants, and masks. ++// These constants are declared in assembler-riscv64.cc, as they use named ++// registers and other constants. ++ ++// An ECALL instruction, used for redirected real time call ++const Instr rtCallRedirInstr = SYSTEM; // All other bits are 0s (i.e., ecall) ++// An EBreak instruction, used for debugging and semi-hosting ++const Instr kBreakInstr = SYSTEM | 1 << kImm12Shift; // ebreak ++ ++constexpr uint8_t kInstrSize = 4; ++constexpr uint8_t kInstrSizeLog2 = 2; ++ ++class InstructionBase { ++ public: ++ enum { ++ // On RISC-V, PC cannot actually be directly accessed. We behave as if PC ++ // was always the value of the current instruction being executed. ++ kPCReadOffset = 0 ++ }; ++ ++ // Instruction type. ++ enum Type { ++ kRType, ++ kR4Type, // Special R4 for Q extension ++ kIType, ++ kSType, ++ kBType, ++ kUType, ++ kJType, ++ kUnsupported = -1 ++ }; ++ ++ // Get the raw instruction bits. ++ inline Instr InstructionBits() const { ++ return *reinterpret_cast(this); ++ } ++ ++ // Set the raw instruction bits to value. ++ inline void SetInstructionBits(Instr value) { ++ *reinterpret_cast(this) = value; ++ } ++ ++ // Read one particular bit out of the instruction bits. ++ inline int Bit(int nr) const { return (InstructionBits() >> nr) & 1; } ++ ++ // Read a bit field out of the instruction bits. ++ inline int Bits(int hi, int lo) const { ++ return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1); ++ } ++ ++ // Accessors for the different named fields used in the RISC-V encoding. ++ inline Opcode BaseOpcodeValue() const { ++ return static_cast( ++ Bits(kBaseOpcodeShift + kBaseOpcodeBits - 1, kBaseOpcodeShift)); ++ } ++ ++ // Return the fields at their original place in the instruction encoding. ++ inline Opcode BaseOpcodeFieldRaw() const { ++ return static_cast(InstructionBits() & kBaseOpcodeMask); ++ } ++ ++ // Safe to call within R-type instructions ++ inline int Funct7FieldRaw() const { return InstructionBits() & kFunct7Mask; } ++ ++ // Safe to call within R-, I-, S-, or B-type instructions ++ inline int Funct3FieldRaw() const { return InstructionBits() & kFunct3Mask; } ++ ++ // Safe to call within R-, I-, S-, or B-type instructions ++ inline int Rs1FieldRawNoAssert() const { ++ return InstructionBits() & kRs1FieldMask; ++ } ++ ++ // Safe to call within R-, S-, or B-type instructions ++ inline int Rs2FieldRawNoAssert() const { ++ return InstructionBits() & kRs2FieldMask; ++ } ++ ++ // Safe to call within R4-type instructions ++ inline int Rs3FieldRawNoAssert() const { ++ return InstructionBits() & kRs3FieldMask; ++ } ++ ++ inline int32_t ITypeBits() const { return InstructionBits() & kITypeMask; } ++ ++ // Get the encoding type of the instruction. ++ inline Type InstructionType() const; ++ ++ protected: ++ InstructionBase() {} ++}; ++ ++template ++class InstructionGetters : public T { ++ public: ++ inline int BaseOpcode() const { ++ return this->InstructionBits() & kBaseOpcodeMask; ++ } ++ ++ inline int Rs1Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType || ++ this->InstructionType() == InstructionBase::kR4Type || ++ this->InstructionType() == InstructionBase::kIType || ++ this->InstructionType() == InstructionBase::kSType || ++ this->InstructionType() == InstructionBase::kBType); ++ return this->Bits(kRs1Shift + kRs1Bits - 1, kRs1Shift); ++ } ++ ++ inline int Rs2Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType || ++ this->InstructionType() == InstructionBase::kR4Type || ++ this->InstructionType() == InstructionBase::kSType || ++ this->InstructionType() == InstructionBase::kBType); ++ return this->Bits(kRs2Shift + kRs2Bits - 1, kRs2Shift); ++ } ++ ++ inline int Rs3Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kR4Type); ++ return this->Bits(kRs3Shift + kRs3Bits - 1, kRs3Shift); ++ } ++ ++ inline int RdValue() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType || ++ this->InstructionType() == InstructionBase::kR4Type || ++ this->InstructionType() == InstructionBase::kIType || ++ this->InstructionType() == InstructionBase::kUType || ++ this->InstructionType() == InstructionBase::kJType); ++ return this->Bits(kRdShift + kRdBits - 1, kRdShift); ++ } ++ ++ inline int Funct7Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType); ++ return this->Bits(kFunct7Shift + kFunct7Bits - 1, kFunct7Shift); ++ } ++ ++ inline int Funct3Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType || ++ this->InstructionType() == InstructionBase::kIType || ++ this->InstructionType() == InstructionBase::kSType || ++ this->InstructionType() == InstructionBase::kBType); ++ return this->Bits(kFunct3Shift + kFunct3Bits - 1, kFunct3Shift); ++ } ++ ++ inline int Funct5Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kRType && ++ this->BaseOpcode() == OP_FP); ++ return this->Bits(kFunct5Shift + kFunct5Bits - 1, kFunct5Shift); ++ } ++ ++ inline int CsrValue() const { ++ DCHECK(this->InstructionType() == InstructionBase::kIType && ++ this->BaseOpcode() == SYSTEM); ++ return (this->Bits(kCsrShift + kCsrBits - 1, kCsrShift)); ++ } ++ ++ inline int RoundMode() const { ++ DCHECK((this->InstructionType() == InstructionBase::kRType || ++ this->InstructionType() == InstructionBase::kR4Type) && ++ this->BaseOpcode() == OP_FP); ++ return this->Bits(kFunct3Shift + kFunct3Bits - 1, kFunct3Shift); ++ } ++ ++ inline int MemoryOrder(bool is_pred) const { ++ DCHECK((this->InstructionType() == InstructionBase::kIType && ++ this->BaseOpcode() == MISC_MEM)); ++ if (is_pred) { ++ return this->Bits(kPredOrderShift + kMemOrderBits - 1, kPredOrderShift); ++ } else { ++ return this->Bits(kSuccOrderShift + kMemOrderBits - 1, kSuccOrderShift); ++ } ++ } ++ ++ inline int Imm12Value() const { ++ DCHECK(this->InstructionType() == InstructionBase::kIType); ++ int Value = this->Bits(kImm12Shift + kImm12Bits - 1, kImm12Shift); ++ return Value << 20 >> 20; ++ } ++ ++ inline int32_t Imm12SExtValue() const { ++ int32_t Value = this->Imm12Value() << 20 >> 20; ++ return Value; ++ } ++ ++ inline int BranchOffset() const { ++ DCHECK(this->InstructionType() == InstructionBase::kBType); ++ // | imm[12|10:5] | rs2 | rs1 | funct3 | imm[4:1|11] | opcode | ++ // 31 25 11 7 ++ uint32_t Bits = this->InstructionBits(); ++ int16_t imm13 = ((Bits & 0xf00) >> 7) | ((Bits & 0x7e000000) >> 20) | ++ ((Bits & 0x80) << 4) | ((Bits & 0x80000000) >> 19); ++ return imm13 << 19 >> 19; ++ } ++ ++ inline int StoreOffset() const { ++ DCHECK(this->InstructionType() == InstructionBase::kSType); ++ // | imm[11:5] | rs2 | rs1 | funct3 | imm[4:0] | opcode | ++ // 31 25 11 7 ++ uint32_t Bits = this->InstructionBits(); ++ int16_t imm12 = ((Bits & 0xf80) >> 7) | ((Bits & 0xfe000000) >> 20); ++ return imm12 << 20 >> 20; ++ } ++ ++ inline int Imm20UValue() const { ++ DCHECK(this->InstructionType() == InstructionBase::kUType); ++ // | imm[31:12] | rd | opcode | ++ // 31 12 ++ int32_t Bits = this->InstructionBits(); ++ return Bits >> 12; ++ } ++ ++ inline int Imm20JValue() const { ++ DCHECK(this->InstructionType() == InstructionBase::kJType); ++ // | imm[20|10:1|11|19:12] | rd | opcode | ++ // 31 12 ++ uint32_t Bits = this->InstructionBits(); ++ int32_t imm20 = ((Bits & 0x7fe00000) >> 20) | ((Bits & 0x100000) >> 9) | ++ (Bits & 0xff000) | ((Bits & 0x80000000) >> 11); ++ return imm20 << 11 >> 11; ++ } ++ ++ inline bool IsArithShift() const { ++ // Valid only for right shift operations ++ DCHECK((this->BaseOpcode() == OP || this->BaseOpcode() == OP_32 || ++ this->BaseOpcode() == OP_IMM || this->BaseOpcode() == OP_IMM_32) && ++ this->Funct3Value() == 0b101); ++ return this->InstructionBits() & 0x40000000; ++ } ++ ++ inline int Shamt() const { ++ // Valid only for shift instructions (SLLI, SRLI, SRAI) ++ DCHECK((this->InstructionBits() & kBaseOpcodeMask) == OP_IMM && ++ (this->Funct3Value() == 0b001 || this->Funct3Value() == 0b101)); ++ // | 0A0000 | shamt | rs1 | funct3 | rd | opcode | ++ // 31 25 20 ++ return this->Bits(kImm12Shift + 5, kImm12Shift); ++ } ++ ++ inline int Shamt32() const { ++ // Valid only for shift instructions (SLLIW, SRLIW, SRAIW) ++ DCHECK((this->InstructionBits() & kBaseOpcodeMask) == OP_IMM_32 && ++ (this->Funct3Value() == 0b001 || this->Funct3Value() == 0b101)); ++ // | 0A00000 | shamt | rs1 | funct3 | rd | opcode | ++ // 31 24 20 ++ return this->Bits(kImm12Shift + 4, kImm12Shift); ++ } ++ ++ inline bool AqValue() const { return this->Bits(kAqShift, kAqShift); } ++ ++ inline bool RlValue() const { return this->Bits(kRlShift, kRlShift); } ++ ++ // Say if the instruction is a break or a trap. ++ bool IsTrap() const; ++}; ++ ++class Instruction : public InstructionGetters { ++ public: ++ // Instructions are read of out a code stream. The only way to get a ++ // reference to an instruction is to convert a pointer. There is no way ++ // to allocate or create instances of class Instruction. ++ // Use the At(pc) function to create references to Instruction. ++ static Instruction* At(byte* pc) { ++ return reinterpret_cast(pc); ++ } ++ ++ private: ++ // We need to prevent the creation of instances of class Instruction. ++ DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); ++}; ++ ++// ----------------------------------------------------------------------------- ++// RISC-V assembly various constants. ++ ++// C/C++ argument slots size. ++const int kCArgSlotCount = 0; ++ ++// TODO(plind): below should be based on kPointerSize ++// TODO(plind): find all usages and remove the needless instructions for n64. ++const int kCArgsSlotsSize = kCArgSlotCount * kInstrSize * 2; ++ ++const int kInvalidStackOffset = -1; ++const int kBranchReturnOffset = 2 * kInstrSize; ++ ++static const int kNegOffset = 0x00008000; ++ ++InstructionBase::Type InstructionBase::InstructionType() const { ++ // RISCV routine ++ switch (InstructionBits() & kBaseOpcodeMask) { ++ case LOAD: ++ return kIType; ++ case LOAD_FP: ++ return kIType; ++ case MISC_MEM: ++ return kIType; ++ case OP_IMM: ++ return kIType; ++ case AUIPC: ++ return kUType; ++ case OP_IMM_32: ++ return kIType; ++ case STORE: ++ return kSType; ++ case STORE_FP: ++ return kSType; ++ case AMO: ++ return kRType; ++ case OP: ++ return kRType; ++ case LUI: ++ return kUType; ++ case OP_32: ++ return kRType; ++ case MADD: ++ case MSUB: ++ case NMSUB: ++ case NMADD: ++ return kR4Type; ++ case OP_FP: ++ return kRType; ++ case BRANCH: ++ return kBType; ++ case JALR: ++ return kIType; ++ case JAL: ++ return kJType; ++ case SYSTEM: ++ return kIType; ++ } ++ return kUnsupported; ++} ++ ++// ----------------------------------------------------------------------------- ++// Instructions. ++ ++template ++bool InstructionGetters

::IsTrap() const { ++ return (this->InstructionBits() == kBreakInstr); ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_RISCV_CONSTANTS_RISCV_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/cpu-riscv64.cc +@@ -0,0 +1,28 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// CPU specific code for arm independent of OS goes here. ++ ++#include ++#include ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/cpu-features.h" ++ ++namespace v8 { ++namespace internal { ++ ++void CpuFeatures::FlushICache(void* start, size_t size) { ++#if !defined(USE_SIMULATOR) ++ // FIXME(RISCV): builtin_clear_cache doesn't work yet, so use `fence.i` for now ++ // __builtin___clear_cache(start, (char *)start + size); ++ asm volatile("fence.i" ::: "memory"); ++#endif // !USE_SIMULATOR. ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/interface-descriptors-riscv64.cc +@@ -0,0 +1,348 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/interface-descriptors.h" ++#include "src/execution/frames.h" ++ ++namespace v8 { ++namespace internal { ++ ++const Register CallInterfaceDescriptor::ContextRegister() { return cp; } ++ ++void CallInterfaceDescriptor::DefaultInitializePlatformSpecific( ++ CallInterfaceDescriptorData* data, int register_parameter_count) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ CHECK_LE(static_cast(register_parameter_count), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(register_parameter_count, ++ default_stub_registers); ++} ++ ++void WasmI32AtomicWait32Descriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3}; ++ CHECK_EQ(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++void WasmI64AtomicWait32Descriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, a4}; ++ CHECK_EQ(static_cast(kParameterCount - kStackArgumentsCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount - kStackArgumentsCount, ++ default_stub_registers); ++} ++ ++void RecordWriteDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0}; ++ ++ data->RestrictAllocatableRegisters(default_stub_registers, ++ arraysize(default_stub_registers)); ++ ++ CHECK_LE(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++void EphemeronKeyBarrierDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ const Register default_stub_registers[] = {a0, a1, a2, a3, kReturnRegister0}; ++ ++ data->RestrictAllocatableRegisters(default_stub_registers, ++ arraysize(default_stub_registers)); ++ ++ CHECK_LE(static_cast(kParameterCount), ++ arraysize(default_stub_registers)); ++ data->InitializePlatformSpecific(kParameterCount, default_stub_registers); ++} ++ ++const Register LoadDescriptor::ReceiverRegister() { return a1; } ++const Register LoadDescriptor::NameRegister() { return a2; } ++const Register LoadDescriptor::SlotRegister() { return a0; } ++ ++const Register LoadWithVectorDescriptor::VectorRegister() { return a3; } ++ ++const Register ++LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() { ++ return a4; ++} ++ ++const Register StoreDescriptor::ReceiverRegister() { return a1; } ++const Register StoreDescriptor::NameRegister() { return a2; } ++const Register StoreDescriptor::ValueRegister() { return a0; } ++const Register StoreDescriptor::SlotRegister() { return a4; } ++ ++const Register StoreWithVectorDescriptor::VectorRegister() { return a3; } ++ ++const Register StoreTransitionDescriptor::SlotRegister() { return a4; } ++const Register StoreTransitionDescriptor::VectorRegister() { return a3; } ++const Register StoreTransitionDescriptor::MapRegister() { return a5; } ++ ++const Register ApiGetterDescriptor::HolderRegister() { return a0; } ++const Register ApiGetterDescriptor::CallbackRegister() { return a3; } ++ ++const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } ++const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } ++ ++// static ++const Register TypeConversionDescriptor::ArgumentRegister() { return a0; } ++ ++void TypeofDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a3}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallTrampolineDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: target ++ // a0: number of arguments ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a4 : arguments list length (untagged) ++ // a2 : arguments list (FixedArray) ++ Register registers[] = {a1, a0, a4, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallForwardVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: the target to call ++ // a0: number of arguments ++ // a2: start index (to support rest parameters) ++ Register registers[] = {a1, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallFunctionTemplateDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : function template info ++ // a0 : number of arguments (on the stack, not including receiver) ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallWithSpreadDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a2 : the object to spread ++ Register registers[] = {a1, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CallWithArrayLikeDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : the target to call ++ // a2 : the arguments list ++ Register registers[] = {a1, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a3 : the new target ++ // a4 : arguments list length (untagged) ++ // a2 : arguments list (FixedArray) ++ Register registers[] = {a1, a3, a0, a4, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructForwardVarargsDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: the target to call ++ // a3: new target ++ // a0: number of arguments ++ // a2: start index (to support rest parameters) ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructWithSpreadDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a0 : number of arguments (on the stack, not including receiver) ++ // a1 : the target to call ++ // a3 : the new target ++ // a2 : the object to spread ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructWithArrayLikeDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1 : the target to call ++ // a3 : the new target ++ // a2 : the arguments list ++ Register registers[] = {a1, a3, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ConstructStubDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // a1: target ++ // a3: new target ++ // a0: number of arguments ++ // a2: allocation site or undefined ++ Register registers[] = {a1, a3, a0, a2}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void AbortDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void CompareDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void BinaryOpDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a1, a0}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ArgumentsAdaptorDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // JSFunction ++ a3, // the new target ++ a0, // actual number of arguments ++ a2, // expected number of arguments ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ApiCallbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // kApiFunctionAddress ++ a2, // kArgc ++ a3, // kCallData ++ a0, // kHolder ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterDispatchDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister, ++ kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterPushArgsThenCallDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // argument count (not including receiver) ++ a2, // address of first argument ++ a1 // the target callable to be call ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void InterpreterPushArgsThenConstructDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // argument count (not including receiver) ++ a4, // address of the first argument ++ a1, // constructor to call ++ a3, // new target ++ a2, // allocation site feedback if available, undefined otherwise ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void ResumeGeneratorDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a0, // the value to pass to the generator ++ a1 // the JSGeneratorObject to resume ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void FrameDropperTrampolineDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = { ++ a1, // loaded new FP ++ }; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void RunMicrotasksEntryDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ Register registers[] = {a0, a1}; ++ data->InitializePlatformSpecific(arraysize(registers), registers); ++} ++ ++void BinaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallTrampoline_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void CallWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void ConstructWithArrayLike_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void ConstructWithSpread_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void Compare_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 4); ++} ++ ++void UnaryOp_WithFeedbackDescriptor::InitializePlatformSpecific( ++ CallInterfaceDescriptorData* data) { ++ // TODO(v8:8888): Implement on this platform. ++ DefaultInitializePlatformSpecific(data, 3); ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/macro-assembler-riscv64.cc +@@ -0,0 +1,4336 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include // For LONG_MIN, LONG_MAX. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/base/bits.h" ++#include "src/base/division-by-constant.h" ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/callable.h" ++#include "src/codegen/code-factory.h" ++#include "src/codegen/external-reference-table.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/register-configuration.h" ++#include "src/debug/debug.h" ++#include "src/execution/frames-inl.h" ++#include "src/heap/memory-chunk.h" ++#include "src/init/bootstrapper.h" ++#include "src/logging/counters.h" ++#include "src/objects/heap-number.h" ++#include "src/runtime/runtime.h" ++#include "src/snapshot/embedded/embedded-data.h" ++#include "src/snapshot/snapshot.h" ++#include "src/wasm/wasm-code-manager.h" ++ ++// Satisfy cpplint check, but don't include platform-specific header. It is ++// included recursively via macro-assembler.h. ++#if 0 ++#include "src/codegen/riscv64/macro-assembler-riscv64.h" ++#endif ++ ++namespace v8 { ++namespace internal { ++ ++static inline bool IsZero(const Operand& rt) { ++ if (rt.is_reg()) { ++ return rt.rm() == zero_reg; ++ } else { ++ return rt.immediate() == 0; ++ } ++} ++ ++int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, ++ Register exclusion1, ++ Register exclusion2, ++ Register exclusion3) const { ++ int bytes = 0; ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ bytes += NumRegs(list) * kPointerSize; ++ ++ if (fp_mode == kSaveFPRegs) { ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ return bytes; ++} ++ ++int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ++ Register exclusion2, Register exclusion3) { ++ int bytes = 0; ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ MultiPush(list); ++ bytes += NumRegs(list) * kPointerSize; ++ ++ if (fp_mode == kSaveFPRegs) { ++ MultiPushFPU(kCallerSavedFPU); ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ return bytes; ++} ++ ++int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1, ++ Register exclusion2, Register exclusion3) { ++ int bytes = 0; ++ if (fp_mode == kSaveFPRegs) { ++ MultiPopFPU(kCallerSavedFPU); ++ bytes += NumRegs(kCallerSavedFPU) * kDoubleSize; ++ } ++ ++ RegList exclusions = 0; ++ if (exclusion1 != no_reg) { ++ exclusions |= exclusion1.bit(); ++ if (exclusion2 != no_reg) { ++ exclusions |= exclusion2.bit(); ++ if (exclusion3 != no_reg) { ++ exclusions |= exclusion3.bit(); ++ } ++ } ++ } ++ ++ RegList list = kJSCallerSaved & ~exclusions; ++ MultiPop(list); ++ bytes += NumRegs(list) * kPointerSize; ++ ++ return bytes; ++} ++ ++void TurboAssembler::LoadRoot(Register destination, RootIndex index) { ++ Ld(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); ++} ++ ++void TurboAssembler::LoadRoot(Register destination, RootIndex index, ++ Condition cond, Register src1, ++ const Operand& src2) { ++ Label skip; ++ Branch(&skip, NegateCondition(cond), src1, src2); ++ Ld(destination, MemOperand(s6, RootRegisterOffsetForRootIndex(index))); ++ bind(&skip); ++} ++ ++void TurboAssembler::PushCommonFrame(Register marker_reg) { ++ if (marker_reg.is_valid()) { ++ Push(ra, fp, marker_reg); ++ Add64(fp, sp, Operand(kPointerSize)); ++ } else { ++ Push(ra, fp); ++ mv(fp, sp); ++ } ++} ++ ++void TurboAssembler::PushStandardFrame(Register function_reg) { ++ int offset = -StandardFrameConstants::kContextOffset; ++ if (function_reg.is_valid()) { ++ Push(ra, fp, cp, function_reg); ++ offset += kPointerSize; ++ } else { ++ Push(ra, fp, cp); ++ } ++ Add64(fp, sp, Operand(offset)); ++} ++ ++int MacroAssembler::SafepointRegisterStackIndex(int reg_code) { ++ // The registers are pushed starting with the highest encoding, ++ // which means that lowest encodings are closest to the stack pointer. ++ return kSafepointRegisterStackIndexMap[reg_code]; ++} ++ ++// Clobbers object, dst, value, and ra, if (ra_status == kRAHasBeenSaved) ++// The register 'object' contains a heap object pointer. The heap object ++// tag is shifted away. ++void MacroAssembler::RecordWriteField(Register object, int offset, ++ Register value, Register dst, ++ RAStatus ra_status, ++ SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action, ++ SmiCheck smi_check) { ++ DCHECK(!AreAliased(value, dst, t5, object)); ++ // First, check if a write barrier is even needed. The tests below ++ // catch stores of Smis. ++ Label done; ++ ++ // Skip barrier if writing a smi. ++ if (smi_check == INLINE_SMI_CHECK) { ++ JumpIfSmi(value, &done); ++ } ++ ++ // Although the object register is tagged, the offset is relative to the start ++ // of the object, so so offset must be a multiple of kPointerSize. ++ DCHECK(IsAligned(offset, kPointerSize)); ++ ++ Add64(dst, object, Operand(offset - kHeapObjectTag)); ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Label ok; ++ And(t5, dst, Operand(kPointerSize - 1)); ++ Branch(&ok, eq, t5, Operand(zero_reg)); ++ ebreak(); ++ bind(&ok); ++ } ++ ++ RecordWrite(object, dst, value, ra_status, save_fp, remembered_set_action, ++ OMIT_SMI_CHECK); ++ ++ bind(&done); ++ ++ // Clobber clobbered input registers when running with the debug-code flag ++ // turned on to provoke errors. ++ if (emit_debug_code()) { ++ li(value, Operand(bit_cast(kZapValue + 4))); ++ li(dst, Operand(bit_cast(kZapValue + 8))); ++ } ++} ++ ++void TurboAssembler::SaveRegisters(RegList registers) { ++ DCHECK_GT(NumRegs(registers), 0); ++ RegList regs = 0; ++ for (int i = 0; i < Register::kNumRegisters; ++i) { ++ if ((registers >> i) & 1u) { ++ regs |= Register::from_code(i).bit(); ++ } ++ } ++ MultiPush(regs); ++} ++ ++void TurboAssembler::RestoreRegisters(RegList registers) { ++ DCHECK_GT(NumRegs(registers), 0); ++ RegList regs = 0; ++ for (int i = 0; i < Register::kNumRegisters; ++i) { ++ if ((registers >> i) & 1u) { ++ regs |= Register::from_code(i).bit(); ++ } ++ } ++ MultiPop(regs); ++} ++ ++void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address, ++ SaveFPRegsMode fp_mode) { ++ EphemeronKeyBarrierDescriptor descriptor; ++ RegList registers = descriptor.allocatable_registers(); ++ ++ SaveRegisters(registers); ++ ++ Register object_parameter( ++ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kObject)); ++ Register slot_parameter(descriptor.GetRegisterParameter( ++ EphemeronKeyBarrierDescriptor::kSlotAddress)); ++ Register fp_mode_parameter( ++ descriptor.GetRegisterParameter(EphemeronKeyBarrierDescriptor::kFPMode)); ++ ++ Push(object); ++ Push(address); ++ ++ Pop(slot_parameter); ++ Pop(object_parameter); ++ ++ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); ++ Call(isolate()->builtins()->builtin_handle(Builtins::kEphemeronKeyBarrier), ++ RelocInfo::CODE_TARGET); ++ RestoreRegisters(registers); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) { ++ CallRecordWriteStub( ++ object, address, remembered_set_action, fp_mode, ++ isolate()->builtins()->builtin_handle(Builtins::kRecordWrite), ++ kNullAddress); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, ++ Address wasm_target) { ++ CallRecordWriteStub(object, address, remembered_set_action, fp_mode, ++ Handle::null(), wasm_target); ++} ++ ++void TurboAssembler::CallRecordWriteStub( ++ Register object, Register address, ++ RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, ++ Handle code_target, Address wasm_target) { ++ DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress); ++ // TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode, ++ // i.e. always emit remember set and save FP registers in RecordWriteStub. If ++ // large performance regression is observed, we should use these values to ++ // avoid unnecessary work. ++ ++ RecordWriteDescriptor descriptor; ++ RegList registers = descriptor.allocatable_registers(); ++ ++ SaveRegisters(registers); ++ Register object_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kObject)); ++ Register slot_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kSlot)); ++ Register remembered_set_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kRememberedSet)); ++ Register fp_mode_parameter( ++ descriptor.GetRegisterParameter(RecordWriteDescriptor::kFPMode)); ++ ++ Push(object); ++ Push(address); ++ ++ Pop(slot_parameter); ++ Pop(object_parameter); ++ ++ Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action)); ++ Move(fp_mode_parameter, Smi::FromEnum(fp_mode)); ++ if (code_target.is_null()) { ++ Call(wasm_target, RelocInfo::WASM_STUB_CALL); ++ } else { ++ Call(code_target, RelocInfo::CODE_TARGET); ++ } ++ ++ RestoreRegisters(registers); ++} ++ ++// Clobbers object, address, value, and ra, if (ra_status == kRAHasBeenSaved) ++// The register 'object' contains a heap object pointer. The heap object ++// tag is shifted away. ++void MacroAssembler::RecordWrite(Register object, Register address, ++ Register value, RAStatus ra_status, ++ SaveFPRegsMode fp_mode, ++ RememberedSetAction remembered_set_action, ++ SmiCheck smi_check) { ++ DCHECK(!AreAliased(object, address, value, t5)); ++ DCHECK(!AreAliased(object, address, value, t6)); ++ ++ if (emit_debug_code()) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Ld(scratch, MemOperand(address)); ++ Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, ++ Operand(value)); ++ } ++ ++ if ((remembered_set_action == OMIT_REMEMBERED_SET && ++ !FLAG_incremental_marking) || ++ FLAG_disable_write_barriers) { ++ return; ++ } ++ ++ // First, check if a write barrier is even needed. The tests below ++ // catch stores of smis and stores into the young generation. ++ Label done; ++ ++ if (smi_check == INLINE_SMI_CHECK) { ++ DCHECK_EQ(0, kSmiTag); ++ JumpIfSmi(value, &done); ++ } ++ ++ CheckPageFlag(value, ++ value, // Used as scratch. ++ MemoryChunk::kPointersToHereAreInterestingMask, eq, &done); ++ CheckPageFlag(object, ++ value, // Used as scratch. ++ MemoryChunk::kPointersFromHereAreInterestingMask, eq, &done); ++ ++ // Record the actual write. ++ if (ra_status == kRAHasNotBeenSaved) { ++ push(ra); ++ } ++ CallRecordWriteStub(object, address, remembered_set_action, fp_mode); ++ if (ra_status == kRAHasNotBeenSaved) { ++ pop(ra); ++ } ++ ++ bind(&done); ++ ++ // Clobber clobbered registers when running with the debug-code flag ++ // turned on to provoke errors. ++ if (emit_debug_code()) { ++ li(address, Operand(bit_cast(kZapValue + 12))); ++ li(value, Operand(bit_cast(kZapValue + 16))); ++ } ++} ++ ++// --------------------------------------------------------------------------- ++// Instruction macros. ++ ++void TurboAssembler::Add32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ addw(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ addiw(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ addw(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Add64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ add(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ addi(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ // Register scratch = temps.Acquire(); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ add(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sub32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ subw(rd, rs, rt.rm()); ++ } else { ++ DCHECK(is_int32(rt.immediate())); ++ if (is_int12(-rt.immediate()) && !MustUseReg(rt.rmode())) { ++ addiw(rd, rs, ++ static_cast( ++ -rt.immediate())); // No subiw instr, use addiw(x, y, -imm). ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ if (-rt.immediate() >> 12 == 0 && !MustUseReg(rt.rmode())) { ++ // Use load -imm and addu when loading -imm generates one instruction. ++ RV_li(scratch, -rt.immediate()); ++ addw(rd, rs, scratch); ++ } else { ++ // li handles the relocation. ++ RV_li(scratch, rt.immediate()); ++ subw(rd, rs, scratch); ++ } ++ } ++ } ++} ++ ++void TurboAssembler::Sub64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ sub(rd, rs, rt.rm()); ++ } else if (is_int12(-rt.immediate()) && !MustUseReg(rt.rmode())) { ++ addi(rd, rs, ++ static_cast( ++ -rt.immediate())); // No subi instr, use addi(x, y, -imm). ++ } else { ++ DCHECK(rs != t3); ++ int li_count = InstrCountForLi64Bit(rt.immediate()); ++ int li_neg_count = InstrCountForLi64Bit(-rt.immediate()); ++ if (li_neg_count < li_count && !MustUseReg(rt.rmode())) { ++ // Use load -imm and add when loading -imm generates one instruction. ++ DCHECK(rt.immediate() != std::numeric_limits::min()); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ RV_li(scratch, -rt.immediate()); ++ add(rd, rs, scratch); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ RV_li(scratch, rt.immediate()); ++ sub(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Mul32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ mulw(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ mulw(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Mulh32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ mul(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ mul(rd, rs, scratch); ++ } ++ srai(rd, rd, 32); ++} ++ ++void TurboAssembler::Mulhu32(Register rd, Register rs, const Operand& rt, ++ Register rsz, Register rtz) { ++ slli(rsz, rs, 32); ++ if (rt.is_reg()) ++ slli(rtz, rt.rm(), 32); ++ else ++ RV_li(rtz, rt.immediate() << 32); ++ mulhu(rd, rsz, rtz); ++ srai(rd, rd, 32); ++} ++ ++void TurboAssembler::Mul64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ mul(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ mul(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Mulh64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ mulh(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ mulh(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Div32(Register res, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ divw(res, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ divw(res, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Mod32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ remw(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ remw(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Modu32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ remuw(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ remuw(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Div64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ div(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ div(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Divu32(Register res, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ divuw(res, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ divuw(res, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Divu64(Register res, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ divu(res, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ divu(res, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Mod64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ rem(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ rem(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::Modu64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ remu(rd, rs, rt.rm()); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ remu(rd, rs, scratch); ++ } ++} ++ ++void TurboAssembler::And(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ and_(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ andi(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ and_(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Or(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ or_(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ ori(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ or_(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Xor(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ xor_(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ xori(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ xor_(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Nor(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ or_(rd, rs, rt.rm()); ++ not_(rd, rd); ++ } else { ++ Or(rd, rs, rt); ++ not_(rd, rd); ++ } ++} ++ ++void TurboAssembler::Neg(Register rs, const Operand& rt) { ++ DCHECK(rt.is_reg()); ++ neg(rs, rt.rm()); ++} ++ ++void TurboAssembler::Seqz(Register rd, const Operand& rt) { ++ if (rt.is_reg()) { ++ seqz(rd, rt.rm()); ++ } else { ++ li(rd, rt.immediate() == 0); ++ } ++} ++ ++void TurboAssembler::Snez(Register rd, const Operand& rt) { ++ if (rt.is_reg()) { ++ snez(rd, rt.rm()); ++ } else { ++ li(rd, rt.immediate() != 0); ++ } ++} ++ ++void TurboAssembler::Seq(Register rd, Register rs, const Operand& rt) { ++ if (rs == zero_reg) { ++ Seqz(rd, rt); ++ } else if (IsZero(rt)) { ++ seqz(rd, rs); ++ } else { ++ Sub64(rd, rs, rt); ++ seqz(rd, rd); ++ } ++} ++ ++void TurboAssembler::Sne(Register rd, Register rs, const Operand& rt) { ++ if (rs == zero_reg) { ++ Snez(rd, rt); ++ } else if (IsZero(rt)) { ++ snez(rd, rs); ++ } else { ++ Sub64(rd, rs, rt); ++ snez(rd, rd); ++ } ++} ++ ++void TurboAssembler::Slt(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ slt(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ slti(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ slt(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sltu(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ sltu(rd, rs, rt.rm()); ++ } else { ++ if (is_int12(rt.immediate()) && !MustUseReg(rt.rmode())) { ++ sltiu(rd, rs, static_cast(rt.immediate())); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ sltu(rd, rs, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::Sle(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ slt(rd, rt.rm(), rs); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ slt(rd, scratch, rs); ++ } ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sleu(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ sltu(rd, rt.rm(), rs); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ sltu(rd, scratch, rs); ++ } ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sge(Register rd, Register rs, const Operand& rt) { ++ Slt(rd, rs, rt); ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sgeu(Register rd, Register rs, const Operand& rt) { ++ Sltu(rd, rs, rt); ++ xori(rd, rd, 1); ++} ++ ++void TurboAssembler::Sgt(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ slt(rd, rt.rm(), rs); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ slt(rd, scratch, rs); ++ } ++} ++ ++void TurboAssembler::Sgtu(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) { ++ sltu(rd, rt.rm(), rs); ++ } else { ++ // li handles the relocation. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ DCHECK(rs != scratch); ++ RV_li(scratch, rt.immediate()); ++ sltu(rd, scratch, rs); ++ } ++} ++ ++void TurboAssembler::Sll32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ sllw(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ slliw(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Sra32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ sraw(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ sraiw(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Srl32(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ srlw(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ srliw(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Sra64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ sra(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ srai(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Srl64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ srl(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ srli(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Sll64(Register rd, Register rs, const Operand& rt) { ++ if (rt.is_reg()) ++ sll(rd, rs, rt.rm()); ++ else { ++ uint8_t shamt = static_cast(rt.immediate()); ++ slli(rd, rs, shamt); ++ } ++} ++ ++void TurboAssembler::Ror(Register rd, Register rs, const Operand& rt) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ if (rt.is_reg()) { ++ negw(scratch, rt.rm()); ++ sllw(scratch, rs, scratch); ++ srlw(rd, rs, rt.rm()); ++ or_(rd, scratch, rd); ++ sext_w(rd, rd); ++ } else { ++ int64_t ror_value = rt.immediate() % 32; ++ if (ror_value == 0) { ++ mv(rd, rs); ++ return; ++ } else if (ror_value < 0) { ++ ror_value += 32; ++ } ++ srliw(scratch, rs, ror_value); ++ slliw(rd, rs, 32 - ror_value); ++ or_(rd, scratch, rd); ++ sext_w(rd, rd); ++ } ++} ++ ++void TurboAssembler::Dror(Register rd, Register rs, const Operand& rt) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ DCHECK(rs != scratch); ++ if (rt.is_reg()) { ++ negw(scratch, rt.rm()); ++ sll(scratch, rs, scratch); ++ srl(rd, rs, rt.rm()); ++ or_(rd, scratch, rd); ++ } else { ++ int64_t dror_value = rt.immediate() % 64; ++ if (dror_value == 0) { ++ mv(rd, rs); ++ return; ++ } else if (dror_value < 0) { ++ dror_value += 64; ++ } ++ srli(scratch, rs, dror_value); ++ slli(rd, rs, 64 - dror_value); ++ or_(rd, scratch, rd); ++ } ++} ++ ++void TurboAssembler::CalcScaledAddress(Register rd, Register rt, Register rs, ++ uint8_t sa, Register scratch) { ++ DCHECK(sa >= 1 && sa <= 31); ++ Register tmp = rd == rt ? scratch : rd; ++ DCHECK(tmp != rt); ++ slli(tmp, rs, sa); ++ Add64(rd, rt, tmp); ++} ++ ++// ------------Pseudo-instructions------------- ++// Change endianness ++void TurboAssembler::ByteSwap(Register rd, Register rs, int operand_size) { ++ DCHECK(operand_size == 4 || operand_size == 8); ++ DCHECK(rd != t5 && rd != t6); ++ if (operand_size == 4) { ++ // Uint32_t t5 = 0x00FF00FF; ++ // x = (x << 16 | x >> 16); ++ // x = (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)); ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register x = temps.Acquire(); ++ li(t5, 0x00FF00FF); ++ slliw(x, rs, 16); ++ srliw(rd, rs, 16); ++ or_(x, rd, x); // x <- x << 16 | x >> 16 ++ and_(t6, x, t5); // t <- x & 0x00FF00FF ++ slliw(t6, t6, 8); // t <- (x & t5) << 8 ++ slliw(t5, t5, 8); // t5 <- 0xFF00FF00 ++ and_(rd, x, t5); // x & 0xFF00FF00 ++ srliw(rd, rd, 8); ++ or_(rd, rd, t6); // (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)) ++ } else { ++ // uint64_t t5 = 0x0000FFFF0000FFFFl; ++ // uint64_t t5 = 0x00FF00FF00FF00FFl; ++ // x = (x << 32 | x >> 32); ++ // x = (x & t5) << 16 | (x & (t5 << 16)) >> 16; ++ // x = (x & t5) << 8 | (x & (t5 << 8)) >> 8; ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register x = temps.Acquire(); ++ li(t5, 0x0000FFFF0000FFFFl); ++ slli(x, rs, 32); ++ srli(rd, rs, 32); ++ or_(x, rd, x); // x <- x << 32 | x >> 32 ++ and_(t6, x, t5); // t <- x & 0x0000FFFF0000FFFF ++ slli(t6, t6, 16); // t <- (x & 0x0000FFFF0000FFFF) << 16 ++ slli(t5, t5, 16); // t5 <- 0xFFFF0000FFFF0000 ++ and_(rd, x, t5); // rd <- x & 0xFFFF0000FFFF0000 ++ srli(rd, rd, 16); // rd <- x & (t5 << 16)) >> 16 ++ or_(x, rd, t6); // (x & t5) << 16 | (x & (t5 << 16)) >> 16; ++ li(t5, 0x00FF00FF00FF00FFl); ++ and_(t6, x, t5); // t <- x & 0x00FF00FF00FF00FF ++ slli(t6, t6, 8); // t <- (x & t5) << 8 ++ slli(t5, t5, 8); // t5 <- 0xFF00FF00FF00FF00 ++ and_(rd, x, t5); ++ srli(rd, rd, 8); // rd <- (x & (t5 << 8)) >> 8 ++ or_(rd, rd, t6); // (((x & t5) << 8) | ((x & (t5 << 8)) >> 8)) ++ } ++} ++ ++template ++void TurboAssembler::LoadNBytes(Register rd, const MemOperand& rs, ++ Register scratch) { ++ DCHECK(rd != rs.rm() && rd != scratch); ++ DCHECK(NBYTES <= 8); ++ ++ // load the most significant byte ++ if (LOAD_SIGNED) { ++ lb(rd, rs.rm(), rs.offset() + (NBYTES - 1)); ++ } else { ++ lbu(rd, rs.rm(), rs.offset() + (NBYTES - 1)); ++ } ++ ++ // load remaining (nbytes-1) bytes from higher to lower ++ slli(rd, rd, 8 * (NBYTES - 1)); ++ for (int i = (NBYTES - 2); i >= 0; i--) { ++ lbu(scratch, rs.rm(), rs.offset() + i); ++ if (i) slli(scratch, scratch, i * 8); ++ or_(rd, rd, scratch); ++ } ++} ++ ++template ++void TurboAssembler::LoadNBytesOverwritingBaseReg(const MemOperand& rs, ++ Register scratch0, ++ Register scratch1) { ++ // This function loads nbytes from memory specified by rs and into rs.rm() ++ DCHECK(rs.rm() != scratch0 && rs.rm() != scratch1 && scratch0 != scratch1); ++ DCHECK(NBYTES <= 8); ++ ++ // load the most significant byte ++ if (LOAD_SIGNED) { ++ lb(scratch0, rs.rm(), rs.offset() + (NBYTES - 1)); ++ } else { ++ lbu(scratch0, rs.rm(), rs.offset() + (NBYTES - 1)); ++ } ++ ++ // load remaining (nbytes-1) bytes from higher to lower ++ slli(scratch0, scratch0, 8 * (NBYTES - 1)); ++ for (int i = (NBYTES - 2); i >= 0; i--) { ++ lbu(scratch1, rs.rm(), rs.offset() + i); ++ if (i) { ++ slli(scratch1, scratch1, i * 8); ++ or_(scratch0, scratch0, scratch1); ++ } else { ++ // write to rs.rm() when processing the last byte ++ or_(rs.rm(), scratch0, scratch1); ++ } ++ } ++} ++ ++template ++void TurboAssembler::UnalignedLoadHelper(Register rd, const MemOperand& rs) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ UseScratchRegisterScope temps(this); ++ ++ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { ++ // Adjust offset for two accesses and check if offset + 3 fits into int12. ++ MemOperand source = rs; ++ Register scratch_base = temps.Acquire(); ++ DCHECK(scratch_base != rs.rm()); ++ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, ++ NBYTES - 1); ++ ++ // Since source.rm() is scratch_base, assume rd != source.rm() ++ DCHECK(rd != source.rm()); ++ Register scratch_other = t5; ++ LoadNBytes(rd, source, scratch_other); ++ } else { ++ // no need to adjust base-and-offset ++ if (rd != rs.rm()) { ++ Register scratch = temps.Acquire(); ++ LoadNBytes(rd, rs, scratch); ++ } else { // rd == rs.rm() ++ Register scratch0 = temps.Acquire(); ++ Register scratch1 = t5; ++ LoadNBytesOverwritingBaseReg(rs, scratch0, scratch1); ++ } ++ } ++} ++ ++template ++void TurboAssembler::UnalignedFLoadHelper(FPURegister frd, const MemOperand& rs, ++ Register scratch) { ++ DCHECK(scratch != rs.rm()); ++ DCHECK(NBYTES == 4 || NBYTES == 8); ++ ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ UseScratchRegisterScope temps(this); ++ MemOperand source = rs; ++ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { ++ // Adjust offset for two accesses and check if offset + 3 fits into int12. ++ Register scratch_base = temps.Acquire(); ++ DCHECK(scratch_base != scratch && scratch_base != rs.rm()); ++ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, ++ NBYTES - 1); ++ } ++ ++ Register scratch_other = temps.hasAvailable() ? temps.Acquire() : t5; ++ DCHECK(scratch_other != scratch && scratch_other != rs.rm()); ++ LoadNBytes(scratch, source, scratch_other); ++ if (NBYTES == 4) ++ fmv_w_x(frd, scratch); ++ else ++ fmv_d_x(frd, scratch); ++} ++ ++template ++void TurboAssembler::UnalignedStoreHelper(Register rd, const MemOperand& rs, ++ Register scratch_other) { ++ DCHECK(scratch_other != rs.rm()); ++ DCHECK(NBYTES <= 8); ++ ++ UseScratchRegisterScope temps(this); ++ MemOperand source = rs; ++ // Adjust offset for two accesses and check if offset + 3 fits into int12. ++ if (NeedAdjustBaseAndOffset(rs, OffsetAccessType::TWO_ACCESSES, NBYTES - 1)) { ++ Register scratch_base = temps.Acquire(); ++ DCHECK(scratch_base != rd && scratch_base != rs.rm()); ++ AdjustBaseAndOffset(&source, scratch_base, OffsetAccessType::TWO_ACCESSES, ++ NBYTES - 1); ++ } ++ ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (scratch_other == no_reg) ++ scratch_other = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ DCHECK(scratch_other != rd && scratch_other != rs.rm() && ++ scratch_other != source.rm()); ++ ++ sb(rd, source.rm(), source.offset()); ++ for (size_t i = 1; i <= (NBYTES - 1); i++) { ++ srli(scratch_other, rd, i * 8); ++ sb(scratch_other, source.rm(), source.offset() + i); ++ } ++} ++ ++template ++void TurboAssembler::UnalignedFStoreHelper(FPURegister frd, ++ const MemOperand& rs, ++ Register scratch) { ++ DCHECK(scratch != rs.rm()); ++ DCHECK(NBYTES == 8 || NBYTES == 4); ++ ++ if (NBYTES == 4) { ++ fmv_x_w(scratch, frd); ++ } else { ++ fmv_x_d(scratch, frd); ++ } ++ UnalignedStoreHelper(scratch, rs); ++} ++ ++template ++void TurboAssembler::AlignedLoadHelper(Reg_T target, const MemOperand& rs, ++ Func generator) { ++ MemOperand source = rs; ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (NeedAdjustBaseAndOffset(source)) { ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ DCHECK(scratch != rs.rm()); ++ AdjustBaseAndOffset(&source, scratch); ++ } ++ generator(target, source); ++} ++ ++template ++void TurboAssembler::AlignedStoreHelper(Reg_T value, const MemOperand& rs, ++ Func generator) { ++ MemOperand source = rs; ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (NeedAdjustBaseAndOffset(source)) { ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ // make sure scratch does not overwrite value ++ if (std::is_same::value) ++ DCHECK(scratch.code() != value.code()); ++ DCHECK(scratch != rs.rm()); ++ AdjustBaseAndOffset(&source, scratch); ++ } ++ generator(value, source); ++} ++ ++void TurboAssembler::Ulw(Register rd, const MemOperand& rs) { ++ UnalignedLoadHelper<4, true>(rd, rs); ++} ++ ++void TurboAssembler::Ulwu(Register rd, const MemOperand& rs) { ++ UnalignedLoadHelper<4, false>(rd, rs); ++} ++ ++void TurboAssembler::Usw(Register rd, const MemOperand& rs) { ++ UnalignedStoreHelper<4>(rd, rs); ++} ++ ++void TurboAssembler::Ulh(Register rd, const MemOperand& rs) { ++ UnalignedLoadHelper<2, true>(rd, rs); ++} ++ ++void TurboAssembler::Ulhu(Register rd, const MemOperand& rs) { ++ UnalignedLoadHelper<2, false>(rd, rs); ++} ++ ++void TurboAssembler::Ush(Register rd, const MemOperand& rs) { ++ UnalignedStoreHelper<2>(rd, rs); ++} ++ ++void TurboAssembler::Uld(Register rd, const MemOperand& rs) { ++ UnalignedLoadHelper<8, true>(rd, rs); ++} ++ ++// Load consequent 32-bit word pair in 64-bit reg. and put first word in low ++// bits, ++// second word in high bits. ++void MacroAssembler::LoadWordPair(Register rd, const MemOperand& rs, ++ Register scratch) { ++ Lwu(rd, rs); ++ Lw(scratch, MemOperand(rs.rm(), rs.offset() + kPointerSize / 2)); ++ slli(scratch, scratch, 32); ++ Add64(rd, rd, scratch); ++} ++ ++void TurboAssembler::Usd(Register rd, const MemOperand& rs) { ++ UnalignedStoreHelper<8>(rd, rs); ++} ++ ++// Do 64-bit store as two consequent 32-bit stores to unaligned address. ++void MacroAssembler::StoreWordPair(Register rd, const MemOperand& rs, ++ Register scratch) { ++ Sw(rd, rs); ++ srai(scratch, rd, 32); ++ Sw(scratch, MemOperand(rs.rm(), rs.offset() + kPointerSize / 2)); ++} ++ ++void TurboAssembler::ULoadFloat(FPURegister fd, const MemOperand& rs, ++ Register scratch) { ++ UnalignedFLoadHelper<4>(fd, rs, scratch); ++} ++ ++void TurboAssembler::UStoreFloat(FPURegister fd, const MemOperand& rs, ++ Register scratch) { ++ UnalignedFStoreHelper<4>(fd, rs, scratch); ++} ++ ++void TurboAssembler::ULoadDouble(FPURegister fd, const MemOperand& rs, ++ Register scratch) { ++ UnalignedFLoadHelper<8>(fd, rs, scratch); ++} ++ ++void TurboAssembler::UStoreDouble(FPURegister fd, const MemOperand& rs, ++ Register scratch) { ++ UnalignedFStoreHelper<8>(fd, rs, scratch); ++} ++ ++void TurboAssembler::Lb(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lb(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Lbu(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lbu(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Sb(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register value, const MemOperand& source) { ++ this->sb(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Lh(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lh(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Lhu(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lhu(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Sh(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register value, const MemOperand& source) { ++ this->sh(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Lw(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lw(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Lwu(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->lwu(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Sw(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register value, const MemOperand& source) { ++ this->sw(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Ld(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register target, const MemOperand& source) { ++ this->ld(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::Sd(Register rd, const MemOperand& rs) { ++ auto fn = [this](Register value, const MemOperand& source) { ++ this->sd(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(rd, rs, fn); ++} ++ ++void TurboAssembler::LoadFloat(FPURegister fd, const MemOperand& src) { ++ auto fn = [this](FPURegister target, const MemOperand& source) { ++ this->flw(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(fd, src, fn); ++} ++ ++void TurboAssembler::StoreFloat(FPURegister fs, const MemOperand& src) { ++ auto fn = [this](FPURegister value, const MemOperand& source) { ++ this->fsw(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(fs, src, fn); ++} ++ ++void TurboAssembler::LoadDouble(FPURegister fd, const MemOperand& src) { ++ auto fn = [this](FPURegister target, const MemOperand& source) { ++ this->fld(target, source.rm(), source.offset()); ++ }; ++ AlignedLoadHelper(fd, src, fn); ++} ++ ++void TurboAssembler::StoreDouble(FPURegister fs, const MemOperand& src) { ++ auto fn = [this](FPURegister value, const MemOperand& source) { ++ this->fsd(value, source.rm(), source.offset()); ++ }; ++ AlignedStoreHelper(fs, src, fn); ++} ++ ++void TurboAssembler::Ll(Register rd, const MemOperand& rs) { ++ bool is_one_instruction = rs.offset() == 0; ++ if (is_one_instruction) { ++ lr_w(false, false, rd, rs.rm()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Add64(scratch, rs.rm(), rs.offset()); ++ lr_w(false, false, rd, scratch); ++ } ++} ++ ++void TurboAssembler::Lld(Register rd, const MemOperand& rs) { ++ bool is_one_instruction = rs.offset() == 0; ++ if (is_one_instruction) { ++ lr_d(false, false, rd, rs.rm()); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Add64(scratch, rs.rm(), rs.offset()); ++ lr_d(false, false, rd, scratch); ++ } ++} ++ ++void TurboAssembler::Sc(Register rd, const MemOperand& rs) { ++ bool is_one_instruction = rs.offset() == 0; ++ if (is_one_instruction) { ++ sc_w(false, false, rd, rs.rm(), rd); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Add64(scratch, rs.rm(), rs.offset()); ++ sc_w(false, false, rd, scratch, rd); ++ } ++} ++ ++void TurboAssembler::Scd(Register rd, const MemOperand& rs) { ++ bool is_one_instruction = rs.offset() == 0; ++ if (is_one_instruction) { ++ sc_d(false, false, rd, rs.rm(), rd); ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Add64(scratch, rs.rm(), rs.offset()); ++ sc_d(false, false, rd, scratch, rd); ++ } ++} ++ ++void TurboAssembler::li(Register dst, Handle value, LiFlags mode) { ++ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating ++ // non-isolate-independent code. In many cases it might be cheaper than ++ // embedding the relocatable value. ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(dst, value); ++ return; ++ } ++ li(dst, Operand(value), mode); ++} ++ ++void TurboAssembler::li(Register dst, ExternalReference value, LiFlags mode) { ++ // TODO(jgruber,v8:8887): Also consider a root-relative load when generating ++ // non-isolate-independent code. In many cases it might be cheaper than ++ // embedding the relocatable value. ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadExternalReference(dst, value); ++ return; ++ } ++ li(dst, Operand(value), mode); ++} ++ ++void TurboAssembler::li(Register dst, const StringConstantBase* string, ++ LiFlags mode) { ++ li(dst, Operand::EmbeddedStringConstant(string), mode); ++} ++ ++static inline int InstrCountForLiLower32Bit(int64_t value) { ++ int64_t Hi20 = ((value + 0x800) >> 12); ++ int64_t Lo12 = value << 52 >> 52; ++ if (Hi20 == 0 || Lo12 == 0) { ++ return 1; ++ } ++ return 2; ++} ++ ++int TurboAssembler::InstrCountForLi64Bit(int64_t value) { ++ if (is_int32(value)) { ++ return InstrCountForLiLower32Bit(value); ++ } else { ++ return li_count(value); ++ } ++ UNREACHABLE(); ++ return INT_MAX; ++} ++ ++void TurboAssembler::li_optimized(Register rd, Operand j, LiFlags mode) { ++ DCHECK(!j.is_reg()); ++ DCHECK(!MustUseReg(j.rmode())); ++ DCHECK(mode == OPTIMIZE_SIZE); ++ RV_li(rd, j.immediate()); ++} ++ ++void TurboAssembler::li(Register rd, Operand j, LiFlags mode) { ++ DCHECK(!j.is_reg()); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (!MustUseReg(j.rmode()) && mode == OPTIMIZE_SIZE) { ++ RV_li(rd, j.immediate()); ++ } else if (MustUseReg(j.rmode())) { ++ int64_t immediate; ++ if (j.IsHeapObjectRequest()) { ++ RequestHeapObject(j.heap_object_request()); ++ immediate = 0; ++ } else { ++ immediate = j.immediate(); ++ } ++ ++ RecordRelocInfo(j.rmode(), immediate); ++ // FIXME(RISC_V): Does this case need to be constant size? ++ li_constant(rd, immediate); ++ } else if (mode == ADDRESS_LOAD) { ++ // We always need the same number of instructions as we may need to patch ++ // this code to load another value which may need all 8 instructions. ++ RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); ++ li_constant(rd, j.immediate()); ++ } else { // mode == CONSTANT_SIZE - always emit the same instruction ++ // sequence. ++ li_constant(rd, j.immediate()); ++ } ++} ++ ++static RegList t_regs = Register::ListOf(t0, t1, t2, t3, t4, t5, t6); ++static RegList a_regs = Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7); ++static RegList s_regs = ++ Register::ListOf(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11); ++ ++void TurboAssembler::MultiPush(RegList regs) { ++ int16_t num_to_push = base::bits::CountPopulation(regs); ++ int16_t stack_offset = num_to_push * kPointerSize; ++ ++#define TEST_AND_PUSH_REG(reg) \ ++ if ((regs & reg.bit()) != 0) { \ ++ stack_offset -= kPointerSize; \ ++ Sd(reg, MemOperand(sp, stack_offset)); \ ++ regs &= ~reg.bit(); \ ++ } ++ ++#define T_REGS(V) V(t6) V(t5) V(t4) V(t3) V(t2) V(t1) V(t0) ++#define A_REGS(V) V(a7) V(a6) V(a5) V(a4) V(a3) V(a2) V(a1) V(a0) ++#define S_REGS(V) \ ++ V(s11) V(s10) V(s9) V(s8) V(s7) V(s6) V(s5) V(s4) V(s3) V(s2) V(s1) ++ ++ Sub64(sp, sp, Operand(stack_offset)); ++ ++ // Certain usage of MultiPush requires that registers are pushed onto the ++ // stack in a particular: ra, fp, sp, gp, .... (basically in the decreasing ++ // order of register numbers according to MIPS register numbers) ++ TEST_AND_PUSH_REG(ra); ++ TEST_AND_PUSH_REG(fp); ++ TEST_AND_PUSH_REG(sp); ++ TEST_AND_PUSH_REG(gp); ++ TEST_AND_PUSH_REG(tp); ++ if ((regs & s_regs) != 0) { ++ S_REGS(TEST_AND_PUSH_REG) ++ } ++ if ((regs & a_regs) != 0) { ++ A_REGS(TEST_AND_PUSH_REG) ++ } ++ if ((regs & t_regs) != 0) { ++ T_REGS(TEST_AND_PUSH_REG) ++ } ++ ++ DCHECK(regs == 0); ++ ++#undef TEST_AND_PUSH_REG ++#undef T_REGS ++#undef A_REGS ++#undef S_REGS ++} ++ ++void TurboAssembler::MultiPop(RegList regs) { ++ int16_t stack_offset = 0; ++ ++#define TEST_AND_POP_REG(reg) \ ++ if ((regs & reg.bit()) != 0) { \ ++ Ld(reg, MemOperand(sp, stack_offset)); \ ++ stack_offset += kPointerSize; \ ++ regs &= ~reg.bit(); \ ++ } ++ ++#define T_REGS(V) V(t0) V(t1) V(t2) V(t3) V(t4) V(t5) V(t6) ++#define A_REGS(V) V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) V(a6) V(a7) ++#define S_REGS(V) \ ++ V(s1) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) V(s9) V(s10) V(s11) ++ ++ // MultiPop pops from the stack in reverse order as MultiPush ++ if ((regs & t_regs) != 0) { ++ T_REGS(TEST_AND_POP_REG) ++ } ++ if ((regs & a_regs) != 0) { ++ A_REGS(TEST_AND_POP_REG) ++ } ++ if ((regs & s_regs) != 0) { ++ S_REGS(TEST_AND_POP_REG) ++ } ++ TEST_AND_POP_REG(tp); ++ TEST_AND_POP_REG(gp); ++ TEST_AND_POP_REG(sp); ++ TEST_AND_POP_REG(fp); ++ TEST_AND_POP_REG(ra); ++ ++ DCHECK(regs == 0); ++ ++ addi(sp, sp, stack_offset); ++ ++#undef TEST_AND_POP_REG ++#undef T_REGS ++#undef S_REGS ++#undef A_REGS ++} ++ ++void TurboAssembler::MultiPushFPU(RegList regs) { ++ int16_t num_to_push = base::bits::CountPopulation(regs); ++ int16_t stack_offset = num_to_push * kDoubleSize; ++ ++ Sub64(sp, sp, Operand(stack_offset)); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ if ((regs & (1 << i)) != 0) { ++ stack_offset -= kDoubleSize; ++ StoreDouble(FPURegister::from_code(i), MemOperand(sp, stack_offset)); ++ } ++ } ++} ++ ++void TurboAssembler::MultiPopFPU(RegList regs) { ++ int16_t stack_offset = 0; ++ ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ if ((regs & (1 << i)) != 0) { ++ LoadDouble(FPURegister::from_code(i), MemOperand(sp, stack_offset)); ++ stack_offset += kDoubleSize; ++ } ++ } ++ addi(sp, sp, stack_offset); ++} ++ ++void TurboAssembler::ExtractBits(Register rt, Register rs, uint16_t pos, ++ uint16_t size, bool sign_extend) { ++ DCHECK(pos < 64 && 0 < size && size <= 64 && 0 < pos + size && ++ pos + size <= 64); ++ slli(rt, rs, 64 - (pos + size)); ++ if (sign_extend) { ++ srai(rt, rt, 64 - size); ++ } else { ++ srli(rt, rt, 64 - size); ++ } ++} ++ ++void TurboAssembler::InsertBits(Register dest, Register source, Register pos, ++ int size) { ++ DCHECK(size < 64); ++ UseScratchRegisterScope temps(this); ++ Register mask = temps.Acquire(); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register source_ = temps.hasAvailable() ? temps.Acquire() : t5; ++ // Create a mask of the length=size. ++ li(mask, 1); ++ slli(mask, mask, size); ++ addi(mask, mask, -1); ++ and_(source_, mask, source); ++ sll(source_, source_, pos); ++ // Make a mask containing 0's. 0's start at "pos" with length=size. ++ sll(mask, mask, pos); ++ not_(mask, mask); ++ // cut area for insertion of source. ++ and_(dest, mask, dest); ++ // insert source ++ or_(dest, dest, source_); ++} ++ ++void TurboAssembler::Neg_s(FPURegister fd, FPURegister fs) { fneg_s(fd, fs); } ++ ++void TurboAssembler::Neg_d(FPURegister fd, FPURegister fs) { fneg_d(fd, fs); } ++ ++void TurboAssembler::Cvt_d_uw(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_d_wu(fd, rs); ++} ++ ++void TurboAssembler::Cvt_d_w(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_d_w(fd, rs); ++} ++ ++void TurboAssembler::Cvt_d_ul(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_d_lu(fd, rs); ++} ++ ++void TurboAssembler::Cvt_s_uw(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_s_wu(fd, rs); ++} ++ ++void TurboAssembler::Cvt_s_w(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_s_w(fd, rs); ++} ++ ++void TurboAssembler::Cvt_s_ul(FPURegister fd, Register rs) { ++ // Convert rs to a FP value in fd. ++ fcvt_s_lu(fd, rs); ++} ++ ++template ++void TurboAssembler::RoundFloatingPointToInteger(Register rd, FPURegister fs, ++ Register result, ++ CvtFunc fcvt_generator) { ++ // Save csr_fflags to scratch & clear exception flags ++ if (result.is_valid()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ int exception_flags = kInvalidOperation; ++ csrrci(scratch, csr_fflags, exception_flags); ++ ++ // actual conversion instruction ++ fcvt_generator(this, rd, fs); ++ ++ // check kInvalidOperation flag (out-of-range, NaN) ++ // set result to 1 if normal, otherwise set result to 0 for abnormal ++ frflags(result); ++ andi(result, result, exception_flags); ++ seqz(result, result); // result <-- 1 (normal), result <-- 0 (abnormal) ++ ++ // restore csr_fflags ++ csrw(csr_fflags, scratch); ++ } else { ++ // actual conversion instruction ++ fcvt_generator(this, rd, fs); ++ } ++} ++ ++void TurboAssembler::Trunc_uw_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_wu_d(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_w_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_d(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_uw_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_wu_s(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_w_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_s(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_ul_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_lu_d(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_l_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_l_d(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_ul_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_lu_s(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Trunc_l_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_l_s(dst, src, RTZ); ++ }); ++} ++ ++void TurboAssembler::Round_w_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_s(dst, src, RNE); ++ }); ++} ++ ++void TurboAssembler::Round_w_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_d(dst, src, RNE); ++ }); ++} ++ ++void TurboAssembler::Ceil_w_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_s(dst, src, RUP); ++ }); ++} ++ ++void TurboAssembler::Ceil_w_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_d(dst, src, RUP); ++ }); ++} ++ ++void TurboAssembler::Floor_w_s(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_s(dst, src, RDN); ++ }); ++} ++ ++void TurboAssembler::Floor_w_d(Register rd, FPURegister fs, Register result) { ++ RoundFloatingPointToInteger( ++ rd, fs, result, [](TurboAssembler* tasm, Register dst, FPURegister src) { ++ tasm->fcvt_w_d(dst, src, RDN); ++ }); ++} ++ ++// According to JS ECMA specification, for floating-point round operations, if ++// the input is NaN, +/-infinity, or +/-0, the same input is returned as the ++// rounded result; this differs from behavior of RISCV fcvt instructions (which ++// round out-of-range values to the nearest max or min value), therefore special ++// handling is needed by NaN, +/-Infinity, +/-0 ++template ++void TurboAssembler::RoundHelper(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch, RoundingMode frm) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ DCHECK((std::is_same::value) || (std::is_same::value)); ++ // Need at least two FPRs, so check against dst == src == fpu_scratch ++ DCHECK(!(dst == src && dst == fpu_scratch)); ++ ++ const int kFloat32ExponentBias = 127; ++ const int kFloat32MantissaBits = 23; ++ const int kFloat32ExponentBits = 8; ++ const int kFloat64ExponentBias = 1023; ++ const int kFloat64MantissaBits = 52; ++ const int kFloat64ExponentBits = 11; ++ const int kFloatMantissaBits = ++ sizeof(F) == 4 ? kFloat32MantissaBits : kFloat64MantissaBits; ++ const int kFloatExponentBits = ++ sizeof(F) == 4 ? kFloat32ExponentBits : kFloat64ExponentBits; ++ const int kFloatExponentBias = ++ sizeof(F) == 4 ? kFloat32ExponentBias : kFloat64ExponentBias; ++ ++ Label done; ++ ++ // extract exponent value of the source floating-point to t6 ++ if (std::is_same::value) { ++ fmv_x_d(scratch, src); ++ } else { ++ fmv_x_w(scratch, src); ++ } ++ ExtractBits(t6, scratch, kFloatMantissaBits, kFloatExponentBits); ++ ++ // if src is NaN/+-Infinity/+-Zero or if the exponent is larger than # of bits ++ // in mantissa, the result is the same as src, so move src to dest (to avoid ++ // generating another branch) ++ if (dst != src) { ++ if (std::is_same::value) { ++ fmv_d(dst, src); ++ } else { ++ fmv_s(dst, src); ++ } ++ } ++ ++ // If real exponent (i.e., t6 - kFloatExponentBias) is greater than ++ // kFloat32MantissaBits, it means the floating-point value has no fractional ++ // part, thus the input is already rounded, jump to done. Note that, NaN and ++ // Infinity in floating-point representation sets maximal exponent value, so ++ // they also satisfy (t6-kFloatExponentBias >= kFloatMantissaBits), and JS ++ // round semantics specify that rounding of NaN (Infinity) returns NaN ++ // (Infinity), so NaN and Infinity are considered rounded value too. ++ Branch(&done, greater_equal, t6, ++ Operand(kFloatExponentBias + kFloatMantissaBits)); ++ ++ // Actual rounding is needed along this path ++ ++ // old_src holds the original input, needed for the case of src == dst ++ FPURegister old_src = src; ++ if (src == dst) { ++ DCHECK(fpu_scratch != dst); ++ Move(fpu_scratch, src); ++ old_src = fpu_scratch; ++ } ++ ++ // Since only input whose real exponent value is less than kMantissaBits ++ // (i.e., 23 or 52-bits) falls into this path, the value range of the input ++ // falls into that of 23- or 53-bit integers. So we round the input to integer ++ // values, then convert them back to floating-point. ++ if (std::is_same::value) { ++ fcvt_l_d(scratch, src, frm); ++ fcvt_d_l(dst, scratch, frm); ++ } else { ++ fcvt_w_s(scratch, src, frm); ++ fcvt_s_w(dst, scratch, frm); ++ } ++ ++ // A special handling is needed if the input is a very small positive/negative ++ // number that rounds to zero. JS semantics requires that the rounded result ++ // retains the sign of the input, so a very small positive (negative) ++ // floating-point number should be rounded to positive (negative) 0. ++ // Therefore, we use sign-bit injection to produce +/-0 correctly. Instead of ++ // testing for zero w/ a branch, we just insert sign-bit for everyone on this ++ // path (this is where old_src is needed) ++ if (std::is_same::value) { ++ fsgnj_d(dst, dst, old_src); ++ } else { ++ fsgnj_s(dst, dst, old_src); ++ } ++ ++ bind(&done); ++} ++ ++void TurboAssembler::Floor_d_d(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RDN); ++} ++ ++void TurboAssembler::Ceil_d_d(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RUP); ++} ++ ++void TurboAssembler::Trunc_d_d(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RTZ); ++} ++ ++void TurboAssembler::Round_d_d(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RNE); ++} ++ ++void TurboAssembler::Floor_s_s(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RDN); ++} ++ ++void TurboAssembler::Ceil_s_s(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RUP); ++} ++ ++void TurboAssembler::Trunc_s_s(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RTZ); ++} ++ ++void TurboAssembler::Round_s_s(FPURegister dst, FPURegister src, ++ FPURegister fpu_scratch) { ++ RoundHelper(dst, src, fpu_scratch, RNE); ++} ++ ++void MacroAssembler::Madd_s(FPURegister fd, FPURegister fr, FPURegister fs, ++ FPURegister ft) { ++ fmadd_s(fd, fs, ft, fr); ++} ++ ++void MacroAssembler::Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, ++ FPURegister ft) { ++ fmadd_d(fd, fs, ft, fr); ++} ++ ++void MacroAssembler::Msub_s(FPURegister fd, FPURegister fr, FPURegister fs, ++ FPURegister ft) { ++ fmsub_s(fd, fs, ft, fr); ++} ++ ++void MacroAssembler::Msub_d(FPURegister fd, FPURegister fr, FPURegister fs, ++ FPURegister ft) { ++ fmsub_d(fd, fs, ft, fr); ++} ++ ++void TurboAssembler::CompareF32(Register rd, FPUCondition cc, FPURegister cmp1, ++ FPURegister cmp2) { ++ switch (cc) { ++ case EQ: ++ feq_s(rd, cmp1, cmp2); ++ break; ++ case NE: ++ feq_s(rd, cmp1, cmp2); ++ NegateBool(rd, rd); ++ break; ++ case LT: ++ flt_s(rd, cmp1, cmp2); ++ break; ++ case GE: ++ fle_s(rd, cmp2, cmp1); ++ break; ++ case LE: ++ fle_s(rd, cmp1, cmp2); ++ break; ++ case GT: ++ flt_s(rd, cmp2, cmp1); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void TurboAssembler::CompareF64(Register rd, FPUCondition cc, FPURegister cmp1, ++ FPURegister cmp2) { ++ switch (cc) { ++ case EQ: ++ feq_d(rd, cmp1, cmp2); ++ break; ++ case NE: ++ feq_d(rd, cmp1, cmp2); ++ NegateBool(rd, rd); ++ break; ++ case LT: ++ flt_d(rd, cmp1, cmp2); ++ break; ++ case GE: ++ fle_d(rd, cmp2, cmp1); ++ break; ++ case LE: ++ fle_d(rd, cmp1, cmp2); ++ break; ++ case GT: ++ flt_d(rd, cmp2, cmp1); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void TurboAssembler::CompareIsNanF32(Register rd, FPURegister cmp1, ++ FPURegister cmp2) { ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ feq_s(rd, cmp1, cmp1); // rd <- !isNan(cmp1) ++ feq_s(scratch, cmp2, cmp2); // scratch <- !isNaN(cmp2) ++ And(rd, rd, scratch); // rd <- !isNan(cmp1) && !isNan(cmp2) ++ Xor(rd, rd, 1); // rd <- isNan(cmp1) || isNan(cmp2) ++} ++ ++void TurboAssembler::CompareIsNanF64(Register rd, FPURegister cmp1, ++ FPURegister cmp2) { ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ feq_d(rd, cmp1, cmp1); // rd <- !isNan(cmp1) ++ feq_d(scratch, cmp2, cmp2); // scratch <- !isNaN(cmp2) ++ And(rd, rd, scratch); // rd <- !isNan(cmp1) && !isNan(cmp2) ++ Xor(rd, rd, 1); // rd <- isNan(cmp1) || isNan(cmp2) ++} ++ ++void TurboAssembler::BranchTrueShortF(Register rs, Label* target) { ++ Branch(target, not_equal, rs, Operand(zero_reg)); ++} ++ ++void TurboAssembler::BranchFalseShortF(Register rs, Label* target) { ++ Branch(target, equal, rs, Operand(zero_reg)); ++} ++ ++void TurboAssembler::BranchTrueF(Register rs, Label* target) { ++ bool long_branch = ++ target->is_bound() ? !is_near(target) : is_trampoline_emitted(); ++ if (long_branch) { ++ Label skip; ++ BranchFalseShortF(rs, &skip); ++ BranchLong(target); ++ bind(&skip); ++ } else { ++ BranchTrueShortF(rs, target); ++ } ++} ++ ++void TurboAssembler::BranchFalseF(Register rs, Label* target) { ++ bool long_branch = ++ target->is_bound() ? !is_near(target) : is_trampoline_emitted(); ++ if (long_branch) { ++ Label skip; ++ BranchTrueShortF(rs, &skip); ++ BranchLong(target); ++ bind(&skip); ++ } else { ++ BranchFalseShortF(rs, target); ++ } ++} ++ ++void TurboAssembler::InsertHighWordF64(FPURegister dst, Register src_high) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ ++ DCHECK(src_high != t5 && src_high != scratch); ++ ++ fmv_x_d(scratch, dst); ++ slli(t5, src_high, 32); ++ slli(scratch, scratch, 32); ++ srli(scratch, scratch, 32); ++ or_(scratch, scratch, t5); ++ fmv_d_x(dst, scratch); ++} ++ ++void TurboAssembler::InsertLowWordF64(FPURegister dst, Register src_low) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ UseScratchRegisterScope block_trampoline_pool(this); ++ ++ DCHECK(src_low != scratch && src_low != t5); ++ fmv_x_d(scratch, dst); ++ slli(t5, src_low, 32); ++ srli(t5, t5, 32); ++ srli(scratch, scratch, 32); ++ slli(scratch, scratch, 32); ++ or_(scratch, scratch, t5); ++ fmv_d_x(dst, scratch); ++} ++ ++void TurboAssembler::LoadFPRImmediate(FPURegister dst, uint32_t src) { ++ // Handle special values first. ++ if (src == bit_cast(0.0f) && has_single_zero_reg_set_) { ++ if (dst != kDoubleRegZero) fmv_s(dst, kDoubleRegZero); ++ } else if (src == bit_cast(-0.0f) && has_single_zero_reg_set_) { ++ Neg_s(dst, kDoubleRegZero); ++ } else { ++ if (dst == kDoubleRegZero) { ++ DCHECK(src == bit_cast(0.0f)); ++ fmv_w_x(dst, zero_reg); ++ has_single_zero_reg_set_ = true; ++ has_double_zero_reg_set_ = false; ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(static_cast(src))); ++ fmv_w_x(dst, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::LoadFPRImmediate(FPURegister dst, uint64_t src) { ++ // Handle special values first. ++ if (src == bit_cast(0.0) && has_double_zero_reg_set_) { ++ if (dst != kDoubleRegZero) fmv_d(dst, kDoubleRegZero); ++ } else if (src == bit_cast(-0.0) && has_double_zero_reg_set_) { ++ Neg_d(dst, kDoubleRegZero); ++ } else { ++ if (dst == kDoubleRegZero) { ++ DCHECK(src == bit_cast(0.0)); ++ fmv_d_x(dst, zero_reg); ++ has_double_zero_reg_set_ = true; ++ has_single_zero_reg_set_ = false; ++ } else { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(src)); ++ fmv_d_x(dst, scratch); ++ } ++ } ++} ++ ++void TurboAssembler::CompareI(Register rd, Register rs, const Operand& rt, ++ Condition cond) { ++ switch (cond) { ++ case eq: ++ Seq(rd, rs, rt); ++ break; ++ case ne: ++ Sne(rd, rs, rt); ++ break; ++ ++ // Signed comparison. ++ case greater: ++ Sgt(rd, rs, rt); ++ break; ++ case greater_equal: ++ Sge(rd, rs, rt); // rs >= rt ++ break; ++ case less: ++ Slt(rd, rs, rt); // rs < rt ++ break; ++ case less_equal: ++ Sle(rd, rs, rt); // rs <= rt ++ break; ++ ++ // Unsigned comparison. ++ case Ugreater: ++ Sgtu(rd, rs, rt); // rs > rt ++ break; ++ case Ugreater_equal: ++ Sgeu(rd, rs, rt); // rs >= rt ++ break; ++ case Uless: ++ Sltu(rd, rs, rt); // rs < rt ++ break; ++ case Uless_equal: ++ Sleu(rd, rs, rt); // rs <= rt ++ break; ++ case cc_always: ++ UNREACHABLE(); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++// dest <- (condition != 0 ? zero : dest) ++void TurboAssembler::LoadZeroIfConditionNotZero(Register dest, ++ Register condition) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ seqz(scratch, condition); ++ // neg + and may be more efficient than mul(dest, dest, scratch) ++ neg(scratch, scratch); // 0 is still 0, 1 becomes all 1s ++ and_(dest, dest, scratch); ++} ++ ++// dest <- (condition == 0 ? 0 : dest) ++void TurboAssembler::LoadZeroIfConditionZero(Register dest, ++ Register condition) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ snez(scratch, condition); ++ // neg + and may be more efficient than mul(dest, dest, scratch); ++ neg(scratch, scratch); // 0 is still 0, 1 becomes all 1s ++ and_(dest, dest, scratch); ++} ++ ++void TurboAssembler::Clz32(Register rd, Register xx) { ++ // 32 bit unsigned in lower word: count number of leading zeros. ++ // int n = 32; ++ // unsigned y; ++ ++ // y = x >>16; if (y != 0) { n = n -16; x = y; } ++ // y = x >> 8; if (y != 0) { n = n - 8; x = y; } ++ // y = x >> 4; if (y != 0) { n = n - 4; x = y; } ++ // y = x >> 2; if (y != 0) { n = n - 2; x = y; } ++ // y = x >> 1; if (y != 0) {rd = n - 2; return;} ++ // rd = n - x; ++ ++ Label L0, L1, L2, L3, L4; ++ DCHECK(xx != t5 && xx != t6); ++ UseScratchRegisterScope temps(this); ++ UseScratchRegisterScope block_trampoline_pool(this); ++ Register x = rd; ++ Register y = t5; ++ Register n = t6; ++ Move(x, xx); ++ li(n, Operand(32)); ++ srliw(y, x, 16); ++ Branch(&L0, eq, y, Operand(zero_reg)); ++ Move(x, y); ++ addiw(n, n, -16); ++ bind(&L0); ++ srliw(y, x, 8); ++ Branch(&L1, eq, y, Operand(zero_reg)); ++ addiw(n, n, -8); ++ Move(x, y); ++ bind(&L1); ++ srliw(y, x, 4); ++ Branch(&L2, eq, y, Operand(zero_reg)); ++ addiw(n, n, -4); ++ Move(x, y); ++ bind(&L2); ++ srliw(y, x, 2); ++ Branch(&L3, eq, y, Operand(zero_reg)); ++ addiw(n, n, -2); ++ Move(x, y); ++ bind(&L3); ++ srliw(y, x, 1); ++ subw(rd, n, x); ++ Branch(&L4, eq, y, Operand(zero_reg)); ++ addiw(rd, n, -2); ++ bind(&L4); ++} ++ ++void TurboAssembler::Clz64(Register rd, Register xx) { ++ // 64 bit: count number of leading zeros. ++ // int n = 64; ++ // unsigned y; ++ ++ // y = x >>32; if (y != 0) { n = n - 32; x = y; } ++ // y = x >>16; if (y != 0) { n = n - 16; x = y; } ++ // y = x >> 8; if (y != 0) { n = n - 8; x = y; } ++ // y = x >> 4; if (y != 0) { n = n - 4; x = y; } ++ // y = x >> 2; if (y != 0) { n = n - 2; x = y; } ++ // y = x >> 1; if (y != 0) {rd = n - 2; return;} ++ // rd = n - x; ++ ++ DCHECK(xx != t5 && xx != t6); ++ Label L0, L1, L2, L3, L4, L5; ++ UseScratchRegisterScope temps(this); ++ UseScratchRegisterScope block_trampoline_pool(this); ++ Register x = rd; ++ Register y = t5; ++ Register n = t6; ++ Move(x, xx); ++ li(n, Operand(64)); ++ srli(y, x, 32); ++ Branch(&L0, eq, y, Operand(zero_reg)); ++ addiw(n, n, -32); ++ Move(x, y); ++ bind(&L0); ++ srli(y, x, 16); ++ Branch(&L1, eq, y, Operand(zero_reg)); ++ addiw(n, n, -16); ++ Move(x, y); ++ bind(&L1); ++ srli(y, x, 8); ++ Branch(&L2, eq, y, Operand(zero_reg)); ++ addiw(n, n, -8); ++ Move(x, y); ++ bind(&L2); ++ srli(y, x, 4); ++ Branch(&L3, eq, y, Operand(zero_reg)); ++ addiw(n, n, -4); ++ Move(x, y); ++ bind(&L3); ++ srli(y, x, 2); ++ Branch(&L4, eq, y, Operand(zero_reg)); ++ addiw(n, n, -2); ++ Move(x, y); ++ bind(&L4); ++ srli(y, x, 1); ++ subw(rd, n, x); ++ Branch(&L5, eq, y, Operand(zero_reg)); ++ addiw(rd, n, -2); ++ bind(&L5); ++} ++ ++void TurboAssembler::Ctz32(Register rd, Register rs) { ++ // Convert trailing zeroes to trailing ones, and bits to their left ++ // to zeroes. ++ UseScratchRegisterScope temps(this); ++ UseScratchRegisterScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ Add64(scratch, rs, -1); ++ Xor(rd, scratch, rs); ++ And(rd, rd, scratch); ++ // Count number of leading zeroes. ++ Clz32(rd, rd); ++ // Subtract number of leading zeroes from 32 to get number of trailing ++ // ones. Remember that the trailing ones were formerly trailing zeroes. ++ li(scratch, 32); ++ Sub32(rd, scratch, rd); ++} ++ ++void TurboAssembler::Ctz64(Register rd, Register rs) { ++ // Convert trailing zeroes to trailing ones, and bits to their left ++ // to zeroes. ++ UseScratchRegisterScope temps(this); ++ UseScratchRegisterScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ Add64(scratch, rs, -1); ++ Xor(rd, scratch, rs); ++ And(rd, rd, scratch); ++ // Count number of leading zeroes. ++ Clz64(rd, rd); ++ // Subtract number of leading zeroes from 64 to get number of trailing ++ // ones. Remember that the trailing ones were formerly trailing zeroes. ++ li(scratch, 64); ++ Sub64(rd, scratch, rd); ++} ++ ++void TurboAssembler::Popcnt32(Register rd, Register rs) { ++ // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel ++ // ++ // A generalization of the best bit counting method to integers of ++ // bit-widths up to 128 (parameterized by type T) is this: ++ // ++ // v = v - ((v >> 1) & (T)~(T)0/3); // temp ++ // v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); // temp ++ // v = (v + (v >> 4)) & (T)~(T)0/255*15; // temp ++ // c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * BITS_PER_BYTE; //count ++ // ++ // There are algorithms which are faster in the cases where very few ++ // bits are set but the algorithm here attempts to minimize the total ++ // number of instructions executed even when a large number of bits ++ // are set. ++ // The number of instruction is 20. ++ // uint32_t B0 = 0x55555555; // (T)~(T)0/3 ++ // uint32_t B1 = 0x33333333; // (T)~(T)0/15*3 ++ // uint32_t B2 = 0x0F0F0F0F; // (T)~(T)0/255*15 ++ // uint32_t value = 0x01010101; // (T)~(T)0/255 ++ ++ DCHECK(rd != t5 && rd != t6 && rs != t5 && rs != t6); ++ uint32_t shift = 24; ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.Acquire(); ++ Register scratch2 = t5; ++ Register value = t6; ++ li(value, 0x01010101); // value = 0x01010101; ++ li(scratch2, 0x55555555); // B0 = 0x55555555; ++ Srl32(scratch, rs, 1); ++ And(scratch, scratch, scratch2); ++ Sub32(scratch, rs, scratch); ++ li(scratch2, 0x33333333); // B1 = 0x33333333; ++ slli(rd, scratch2, 4); ++ or_(scratch2, scratch2, rd); ++ And(rd, scratch, scratch2); ++ Srl32(scratch, scratch, 2); ++ And(scratch, scratch, scratch2); ++ Add32(scratch, rd, scratch); ++ srliw(rd, scratch, 4); ++ Add32(rd, rd, scratch); ++ li(scratch2, 0xF); ++ Mul32(scratch2, value, scratch2); // B2 = 0x0F0F0F0F; ++ And(rd, rd, scratch2); ++ Mul32(rd, rd, value); ++ Srl32(rd, rd, shift); ++} ++ ++void TurboAssembler::Popcnt64(Register rd, Register rs) { ++ // uint64_t B0 = 0x5555555555555555l; // (T)~(T)0/3 ++ // uint64_t B1 = 0x3333333333333333l; // (T)~(T)0/15*3 ++ // uint64_t B2 = 0x0F0F0F0F0F0F0F0Fl; // (T)~(T)0/255*15 ++ // uint64_t value = 0x0101010101010101l; // (T)~(T)0/255 ++ // uint64_t shift = 24; // (sizeof(T) - 1) * BITS_PER_BYTE ++ ++ DCHECK(rd != t5 && rd != t6 && rs != t5 && rs != t6); ++ uint64_t shift = 24; ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.Acquire(); ++ Register scratch2 = t5; ++ Register value = t6; ++ li(value, 0x1111111111111111l); // value = 0x1111111111111111l; ++ li(scratch2, 5); ++ Mul64(scratch2, value, scratch2); // B0 = 0x5555555555555555l; ++ Srl64(scratch, rs, 1); ++ And(scratch, scratch, scratch2); ++ Sub64(scratch, rs, scratch); ++ li(scratch2, 3); ++ Mul64(scratch2, value, scratch2); // B1 = 0x3333333333333333l; ++ And(rd, scratch, scratch2); ++ Srl64(scratch, scratch, 2); ++ And(scratch, scratch, scratch2); ++ Add64(scratch, rd, scratch); ++ Srl64(rd, scratch, 4); ++ Add64(rd, rd, scratch); ++ li(scratch2, 0xF); ++ li(value, 0x0101010101010101l); // value = 0x0101010101010101l; ++ Mul64(scratch2, value, scratch2); // B2 = 0x0F0F0F0F0F0F0F0Fl; ++ And(rd, rd, scratch2); ++ Mul64(rd, rd, value); ++ srli(rd, rd, 32 + shift); ++} ++ ++void TurboAssembler::TryInlineTruncateDoubleToI(Register result, ++ DoubleRegister double_input, ++ Label* done) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ // if scratch == 1, exception happens during truncation ++ Trunc_w_d(result, double_input, scratch); ++ // If we had no exceptions (i.e., scratch==1) we are done. ++ Branch(done, eq, scratch, Operand(1)); ++} ++ ++void TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone, ++ Register result, ++ DoubleRegister double_input, ++ StubCallMode stub_mode) { ++ Label done; ++ ++ TryInlineTruncateDoubleToI(result, double_input, &done); ++ ++ // If we fell through then inline version didn't succeed - call stub ++ // instead. ++ push(ra); ++ Sub64(sp, sp, Operand(kDoubleSize)); // Put input on stack. ++ fsd(double_input, sp, 0); ++ ++ if (stub_mode == StubCallMode::kCallWasmRuntimeStub) { ++ Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL); ++ } else { ++ Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET); ++ } ++ ld(result, sp, 0); ++ ++ Add64(sp, sp, Operand(kDoubleSize)); ++ pop(ra); ++ ++ bind(&done); ++} ++ ++// BRANCH_ARGS_CHECK checks that conditional jump arguments are correct. ++#define BRANCH_ARGS_CHECK(cond, rs, rt) \ ++ DCHECK((cond == cc_always && rs == zero_reg && rt.rm() == zero_reg) || \ ++ (cond != cc_always && (rs != zero_reg || rt.rm() != zero_reg))) ++ ++void TurboAssembler::Branch(int32_t offset) { ++ DCHECK(is_int21(offset)); ++ BranchShort(offset); ++} ++ ++void TurboAssembler::Branch(int32_t offset, Condition cond, Register rs, ++ const Operand& rt) { ++ bool is_near = BranchShortCheck(offset, nullptr, cond, rs, rt); ++ DCHECK(is_near); ++ USE(is_near); ++} ++ ++void TurboAssembler::Branch(Label* L) { ++ if (L->is_bound()) { ++ if (is_near(L)) { ++ BranchShort(L); ++ } else { ++ BranchLong(L); ++ } ++ } else { ++ if (is_trampoline_emitted()) { ++ BranchLong(L); ++ } else { ++ BranchShort(L); ++ } ++ } ++} ++ ++void TurboAssembler::Branch(Label* L, Condition cond, Register rs, ++ const Operand& rt) { ++ if (L->is_bound()) { ++ if (!BranchShortCheck(0, L, cond, rs, rt)) { ++ if (cond != cc_always) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rs, rt); ++ BranchLong(L); ++ bind(&skip); ++ } else { ++ BranchLong(L); ++ } ++ } ++ } else { ++ if (is_trampoline_emitted()) { ++ if (cond != cc_always) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rs, rt); ++ BranchLong(L); ++ bind(&skip); ++ } else { ++ BranchLong(L); ++ } ++ } else { ++ BranchShort(L, cond, rs, rt); ++ } ++ } ++} ++ ++void TurboAssembler::Branch(Label* L, Condition cond, Register rs, ++ RootIndex index) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(L, cond, rs, Operand(scratch)); ++} ++ ++void TurboAssembler::BranchShortHelper(int32_t offset, Label* L) { ++ DCHECK(L == nullptr || offset == 0); ++ offset = GetOffset(offset, L, OffsetSize::kOffset21); ++ j(offset); ++} ++ ++void TurboAssembler::BranchShort(int32_t offset) { ++ DCHECK(is_int21(offset)); ++ BranchShortHelper(offset, nullptr); ++} ++ ++void TurboAssembler::BranchShort(Label* L) { BranchShortHelper(0, L); } ++ ++int32_t TurboAssembler::GetOffset(int32_t offset, Label* L, OffsetSize bits) { ++ if (L) { ++ offset = branch_offset_helper(L, bits); ++ } else { ++ DCHECK(is_intn(offset, bits)); ++ } ++ return offset; ++} ++ ++Register TurboAssembler::GetRtAsRegisterHelper(const Operand& rt, ++ Register scratch) { ++ Register r2 = no_reg; ++ if (rt.is_reg()) { ++ r2 = rt.rm(); ++ } else { ++ r2 = scratch; ++ li(r2, rt); ++ } ++ ++ return r2; ++} ++ ++bool TurboAssembler::CalculateOffset(Label* L, int32_t* offset, ++ OffsetSize bits) { ++ if (!is_near(L, bits)) return false; ++ *offset = GetOffset(*offset, L, bits); ++ return true; ++} ++ ++bool TurboAssembler::CalculateOffset(Label* L, int32_t* offset, OffsetSize bits, ++ Register* scratch, const Operand& rt) { ++ if (!is_near(L, bits)) return false; ++ *scratch = GetRtAsRegisterHelper(rt, *scratch); ++ *offset = GetOffset(*offset, L, bits); ++ return true; ++} ++ ++bool TurboAssembler::BranchShortHelper(int32_t offset, Label* L, Condition cond, ++ Register rs, const Operand& rt) { ++ DCHECK(L == nullptr || offset == 0); ++ UseScratchRegisterScope temps(this); ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register scratch = temps.hasAvailable() ? temps.Acquire() : t5; ++ ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ switch (cond) { ++ case cc_always: ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ break; ++ case eq: ++ // rs == rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ beq(rs, scratch, offset); ++ } ++ break; ++ case ne: ++ // rs != rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ break; // No code needs to be emitted ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bne(rs, scratch, offset); ++ } ++ break; ++ ++ // Signed comparison. ++ case greater: ++ // rs > rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ break; // No code needs to be emitted. ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bgt(rs, scratch, offset); ++ } ++ break; ++ case greater_equal: ++ // rs >= rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bge(rs, scratch, offset); ++ } ++ break; ++ case less: ++ // rs < rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ break; // No code needs to be emitted. ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ blt(rs, scratch, offset); ++ } ++ break; ++ case less_equal: ++ // rs <= rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ ble(rs, scratch, offset); ++ } ++ break; ++ ++ // Unsigned comparison. ++ case Ugreater: ++ // rs > rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ break; // No code needs to be emitted. ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bgtu(rs, scratch, offset); ++ } ++ break; ++ case Ugreater_equal: ++ // rs >= rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bgeu(rs, scratch, offset); ++ } ++ break; ++ case Uless: ++ // rs < rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ break; // No code needs to be emitted. ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bltu(rs, scratch, offset); ++ } ++ break; ++ case Uless_equal: ++ // rs <= rt ++ if (rt.is_reg() && rs == rt.rm()) { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset21)) return false; ++ j(offset); ++ } else { ++ if (!CalculateOffset(L, &offset, OffsetSize::kOffset13, &scratch, rt)) ++ return false; ++ DCHECK(rs != scratch); ++ bleu(rs, scratch, offset); ++ } ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ ++ CheckTrampolinePoolQuick(1); ++ return true; ++} ++ ++bool TurboAssembler::BranchShortCheck(int32_t offset, Label* L, Condition cond, ++ Register rs, const Operand& rt) { ++ BRANCH_ARGS_CHECK(cond, rs, rt); ++ ++ if (!L) { ++ DCHECK(is_int13(offset)); ++ return BranchShortHelper(offset, nullptr, cond, rs, rt); ++ } else { ++ DCHECK_EQ(offset, 0); ++ return BranchShortHelper(0, L, cond, rs, rt); ++ } ++ return false; ++} ++ ++void TurboAssembler::BranchShort(int32_t offset, Condition cond, Register rs, ++ const Operand& rt) { ++ BranchShortCheck(offset, nullptr, cond, rs, rt); ++} ++ ++void TurboAssembler::BranchShort(Label* L, Condition cond, Register rs, ++ const Operand& rt) { ++ BranchShortCheck(0, L, cond, rs, rt); ++} ++ ++void TurboAssembler::BranchAndLink(int32_t offset) { ++ BranchAndLinkShort(offset); ++} ++ ++void TurboAssembler::BranchAndLink(int32_t offset, Condition cond, Register rs, ++ const Operand& rt) { ++ bool is_near = BranchAndLinkShortCheck(offset, nullptr, cond, rs, rt); ++ DCHECK(is_near); ++ USE(is_near); ++} ++ ++void TurboAssembler::BranchAndLink(Label* L) { ++ if (L->is_bound()) { ++ if (is_near(L)) { ++ BranchAndLinkShort(L); ++ } else { ++ BranchAndLinkLong(L); ++ } ++ } else { ++ if (is_trampoline_emitted()) { ++ BranchAndLinkLong(L); ++ } else { ++ BranchAndLinkShort(L); ++ } ++ } ++} ++ ++void TurboAssembler::BranchAndLink(Label* L, Condition cond, Register rs, ++ const Operand& rt) { ++ if (L->is_bound()) { ++ if (!BranchAndLinkShortCheck(0, L, cond, rs, rt)) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rs, rt); ++ BranchAndLinkLong(L); ++ bind(&skip); ++ } ++ } else { ++ if (is_trampoline_emitted()) { ++ Label skip; ++ Condition neg_cond = NegateCondition(cond); ++ BranchShort(&skip, neg_cond, rs, rt); ++ BranchAndLinkLong(L); ++ bind(&skip); ++ } else { ++ BranchAndLinkShortCheck(0, L, cond, rs, rt); ++ } ++ } ++} ++ ++void TurboAssembler::BranchAndLinkShortHelper(int32_t offset, Label* L) { ++ DCHECK(L == nullptr || offset == 0); ++ offset = GetOffset(offset, L, OffsetSize::kOffset21); ++ jal(offset); ++} ++ ++void TurboAssembler::BranchAndLinkShort(int32_t offset) { ++ DCHECK(is_int21(offset)); ++ BranchAndLinkShortHelper(offset, nullptr); ++} ++ ++void TurboAssembler::BranchAndLinkShort(Label* L) { ++ BranchAndLinkShortHelper(0, L); ++} ++ ++// Pre r6 we need to use a bgezal or bltzal, but they can't be used directly ++// with the slt instructions. We could use sub or add instead but we would miss ++// overflow cases, so we keep slt and add an intermediate third instruction. ++bool TurboAssembler::BranchAndLinkShortHelper(int32_t offset, Label* L, ++ Condition cond, Register rs, ++ const Operand& rt) { ++ DCHECK(L == nullptr || offset == 0); ++ if (!is_near(L, OffsetSize::kOffset21)) return false; ++ ++ Register scratch = t5; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ ++ if (cond == cc_always) { ++ offset = GetOffset(offset, L, OffsetSize::kOffset21); ++ jal(offset); ++ } else { ++ Branch(kInstrSize * 2, NegateCondition(cond), rs, ++ Operand(GetRtAsRegisterHelper(rt, scratch))); ++ offset = GetOffset(offset, L, OffsetSize::kOffset21); ++ jal(offset); ++ } ++ ++ return true; ++} ++ ++bool TurboAssembler::BranchAndLinkShortCheck(int32_t offset, Label* L, ++ Condition cond, Register rs, ++ const Operand& rt) { ++ BRANCH_ARGS_CHECK(cond, rs, rt); ++ ++ if (!L) { ++ DCHECK(is_int21(offset)); ++ return BranchAndLinkShortHelper(offset, nullptr, cond, rs, rt); ++ } else { ++ DCHECK_EQ(offset, 0); ++ return BranchAndLinkShortHelper(0, L, cond, rs, rt); ++ } ++ return false; ++} ++ ++void TurboAssembler::LoadFromConstantsTable(Register destination, ++ int constant_index) { ++ DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kBuiltinsConstantsTable)); ++ LoadRoot(destination, RootIndex::kBuiltinsConstantsTable); ++ Ld(destination, ++ FieldMemOperand(destination, ++ FixedArray::kHeaderSize + constant_index * kPointerSize)); ++} ++ ++void TurboAssembler::LoadRootRelative(Register destination, int32_t offset) { ++ Ld(destination, MemOperand(kRootRegister, offset)); ++} ++ ++void TurboAssembler::LoadRootRegisterOffset(Register destination, ++ intptr_t offset) { ++ if (offset == 0) { ++ Move(destination, kRootRegister); ++ } else { ++ Add64(destination, kRootRegister, Operand(offset)); ++ } ++} ++ ++void TurboAssembler::Jump(Register target, Condition cond, Register rs, ++ const Operand& rt) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (cond == cc_always) { ++ jr(target); ++ } else { ++ BRANCH_ARGS_CHECK(cond, rs, rt); ++ Branch(kInstrSize * 2, NegateCondition(cond), rs, rt); ++ jr(target); ++ } ++} ++ ++void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode, ++ Condition cond, Register rs, const Operand& rt) { ++ Label skip; ++ if (cond != cc_always) { ++ Branch(&skip, NegateCondition(cond), rs, rt); ++ } ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t6, Operand(target, rmode)); ++ Jump(t6, al, zero_reg, Operand(zero_reg)); ++ bind(&skip); ++ } ++} ++ ++void TurboAssembler::Jump(Address target, RelocInfo::Mode rmode, Condition cond, ++ Register rs, const Operand& rt) { ++ DCHECK(!RelocInfo::IsCodeTarget(rmode)); ++ Jump(static_cast(target), rmode, cond, rs, rt); ++} ++ ++void TurboAssembler::Jump(Handle code, RelocInfo::Mode rmode, ++ Condition cond, Register rs, const Operand& rt) { ++ DCHECK(RelocInfo::IsCodeTarget(rmode)); ++ ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(t6, code); ++ Add64(t6, t6, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Jump(t6, cond, rs, rt); ++ return; ++ } else if (options().inline_offheap_trampolines) { ++ int builtin_index = Builtins::kNoBuiltinId; ++ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && ++ Builtins::IsIsolateIndependent(builtin_index)) { ++ // Inline the trampoline. ++ RecordCommentForOffHeapTrampoline(builtin_index); ++ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ Address entry = d.InstructionStartOfBuiltin(builtin_index); ++ li(t6, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Jump(t6, cond, rs, rt); ++ return; ++ } ++ } ++ ++ Jump(static_cast(code.address()), rmode, cond, rs, rt); ++} ++ ++void TurboAssembler::Jump(const ExternalReference& reference) { ++ li(t6, reference); ++ Jump(t6); ++} ++ ++// FIXME (RISCV): the comment does not make sense, where is t6 used? ++// Note: To call gcc-compiled C code on riscv64, you must call through t6. ++void TurboAssembler::Call(Register target, Condition cond, Register rs, ++ const Operand& rt) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (cond == cc_always) { ++ jalr(ra, target, 0); ++ } else { ++ BRANCH_ARGS_CHECK(cond, rs, rt); ++ Branch(kInstrSize * 2, NegateCondition(cond), rs, rt); ++ jalr(ra, target, 0); ++ } ++} ++ ++void MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit, ++ unsigned higher_limit, ++ Label* on_in_range) { ++ if (lower_limit != 0) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Sub64(scratch, value, Operand(lower_limit)); ++ Branch(on_in_range, Uless_equal, scratch, ++ Operand(higher_limit - lower_limit)); ++ } else { ++ Branch(on_in_range, Uless_equal, value, ++ Operand(higher_limit - lower_limit)); ++ } ++} ++ ++void TurboAssembler::Call(Address target, RelocInfo::Mode rmode, Condition cond, ++ Register rs, const Operand& rt) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t6, Operand(static_cast(target), rmode), ADDRESS_LOAD); ++ Call(t6, cond, rs, rt); ++} ++ ++void TurboAssembler::Call(Handle code, RelocInfo::Mode rmode, ++ Condition cond, Register rs, const Operand& rt) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ ++ if (root_array_available_ && options().isolate_independent_code) { ++ IndirectLoadConstant(t6, code); ++ Add64(t6, t6, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Call(t6, cond, rs, rt); ++ return; ++ } else if (options().inline_offheap_trampolines) { ++ int builtin_index = Builtins::kNoBuiltinId; ++ if (isolate()->builtins()->IsBuiltinHandle(code, &builtin_index) && ++ Builtins::IsIsolateIndependent(builtin_index)) { ++ // Inline the trampoline. ++ RecordCommentForOffHeapTrampoline(builtin_index); ++ CHECK_NE(builtin_index, Builtins::kNoBuiltinId); ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ Address entry = d.InstructionStartOfBuiltin(builtin_index); ++ li(t6, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Call(t6, cond, rs, rt); ++ return; ++ } ++ } ++ ++ DCHECK(RelocInfo::IsCodeTarget(rmode)); ++ DCHECK(code->IsExecutable()); ++ Call(code.address(), rmode, cond, rs, rt); ++} ++ ++void TurboAssembler::LoadEntryFromBuiltinIndex(Register builtin_index) { ++ STATIC_ASSERT(kSystemPointerSize == 8); ++ STATIC_ASSERT(kSmiTagSize == 1); ++ STATIC_ASSERT(kSmiTag == 0); ++ ++ // The builtin_index register contains the builtin index as a Smi. ++ SmiUntag(builtin_index, builtin_index); ++ CalcScaledAddress(builtin_index, kRootRegister, builtin_index, ++ kSystemPointerSizeLog2); ++ Ld(builtin_index, ++ MemOperand(builtin_index, IsolateData::builtin_entry_table_offset())); ++} ++ ++void TurboAssembler::CallBuiltinByIndex(Register builtin_index) { ++ LoadEntryFromBuiltinIndex(builtin_index); ++ Call(builtin_index); ++} ++ ++void TurboAssembler::PatchAndJump(Address target) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ auipc(scratch, 0); // Load PC into scratch ++ Ld(t6, MemOperand(scratch, kInstrSize * 4)); ++ jr(t6); ++ nop(); // For alignment ++ DCHECK_EQ(reinterpret_cast(pc_) % 8, 0); ++ *reinterpret_cast(pc_) = target; // pc_ should be align. ++ pc_ += sizeof(uint64_t); ++} ++ ++void TurboAssembler::StoreReturnAddressAndCall(Register target) { ++ // This generates the final instruction sequence for calls to C functions ++ // once an exit frame has been constructed. ++ // ++ // Note that this assumes the caller code (i.e. the Code object currently ++ // being generated) is immovable or that the callee function cannot trigger ++ // GC, since the callee function will return to it. ++ ++ // Compute the return address in lr to return to after the jump below. The ++ // pc is already at '+ 8' from the current instruction; but return is after ++ // three instructions, so add another 4 to pc to get the return address. ++ ++ Assembler::BlockTrampolinePoolScope block_trampoline_pool(this); ++ static constexpr int kNumInstructionsToJump = 5; ++ Label find_ra; ++ // Adjust the value in ra to point to the correct return location, one ++ // instruction past the real call into C code (the jalr(t6)), and push it. ++ // This is the return address of the exit frame. ++ auipc(ra, 0); // Set ra the current PC ++ bind(&find_ra); ++ addi(ra, ra, ++ (kNumInstructionsToJump + 1) * ++ kInstrSize); // Set ra to insn after the call ++ ++ // This spot was reserved in EnterExitFrame. ++ Sd(ra, MemOperand(sp)); ++ addi(sp, sp, -kCArgsSlotsSize); ++ // Stack is still aligned. ++ ++ // Call the C routine. ++ mv(t6, target); // Function pointer to t6 to conform to ABI for PIC. ++ jalr(t6); ++ // Make sure the stored 'ra' points to this position. ++ DCHECK_EQ(kNumInstructionsToJump, InstructionsGeneratedSince(&find_ra)); ++} ++ ++void TurboAssembler::Ret(Condition cond, Register rs, const Operand& rt) { ++ Jump(ra, cond, rs, rt); ++} ++ ++void TurboAssembler::BranchLong(Label* L) { ++ // Generate position independent long branch. ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ int64_t imm64; ++ imm64 = branch_long_offset(L); ++ DCHECK(is_int32(imm64)); ++ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); ++ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; ++ auipc(t5, Hi20); // Read PC + Hi20 into t5. ++ jr(t5, Lo12); // jump PC + Hi20 + Lo12 ++} ++ ++void TurboAssembler::BranchAndLinkLong(Label* L) { ++ // Generate position independent long branch and link. ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ int64_t imm64; ++ imm64 = branch_long_offset(L); ++ DCHECK(is_int32(imm64)); ++ int32_t Hi20 = (((int32_t)imm64 + 0x800) >> 12); ++ int32_t Lo12 = (int32_t)imm64 << 20 >> 20; ++ auipc(t5, Hi20); // Read PC + Hi20 into t5. ++ jalr(t5, Lo12); // jump PC + Hi20 + Lo12 and read PC + 4 to ra ++} ++ ++void TurboAssembler::DropAndRet(int drop) { ++ Add64(sp, sp, drop * kPointerSize); ++ Ret(); ++} ++ ++void TurboAssembler::DropAndRet(int drop, Condition cond, Register r1, ++ const Operand& r2) { ++ // Both Drop and Ret need to be conditional. ++ Label skip; ++ if (cond != cc_always) { ++ Branch(&skip, NegateCondition(cond), r1, r2); ++ } ++ ++ Drop(drop); ++ Ret(); ++ ++ if (cond != cc_always) { ++ bind(&skip); ++ } ++} ++ ++void TurboAssembler::Drop(int count, Condition cond, Register reg, ++ const Operand& op) { ++ if (count <= 0) { ++ return; ++ } ++ ++ Label skip; ++ ++ if (cond != al) { ++ Branch(&skip, NegateCondition(cond), reg, op); ++ } ++ ++ Add64(sp, sp, Operand(count * kPointerSize)); ++ ++ if (cond != al) { ++ bind(&skip); ++ } ++} ++ ++void MacroAssembler::Swap(Register reg1, Register reg2, Register scratch) { ++ if (scratch == no_reg) { ++ Xor(reg1, reg1, Operand(reg2)); ++ Xor(reg2, reg2, Operand(reg1)); ++ Xor(reg1, reg1, Operand(reg2)); ++ } else { ++ mv(scratch, reg1); ++ mv(reg1, reg2); ++ mv(reg2, scratch); ++ } ++} ++ ++void TurboAssembler::Call(Label* target) { BranchAndLink(target); } ++ ++void TurboAssembler::LoadAddress(Register dst, Label* target) { ++ uint64_t address = jump_address(target); ++ li(dst, address, ADDRESS_LOAD); ++} ++ ++void TurboAssembler::Push(Smi smi) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(smi)); ++ push(scratch); ++} ++ ++void TurboAssembler::Push(Handle handle) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(handle)); ++ push(scratch); ++} ++ ++void MacroAssembler::MaybeDropFrames() { ++ // Check whether we need to drop frames to restart a function on the stack. ++ li(a1, ExternalReference::debug_restart_fp_address(isolate())); ++ Ld(a1, MemOperand(a1)); ++ Jump(BUILTIN_CODE(isolate(), FrameDropperTrampoline), RelocInfo::CODE_TARGET, ++ ne, a1, Operand(zero_reg)); ++} ++ ++// --------------------------------------------------------------------------- ++// Exception handling. ++ ++void MacroAssembler::PushStackHandler() { ++ // Adjust this code if not the case. ++ STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize); ++ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); ++ ++ Push(Smi::zero()); // Padding. ++ ++ // Link the current handler as the next handler. ++ li(t2, ++ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); ++ Ld(t1, MemOperand(t2)); ++ push(t1); ++ ++ // Set this new handler as the current one. ++ Sd(sp, MemOperand(t2)); ++} ++ ++void MacroAssembler::PopStackHandler() { ++ STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); ++ pop(a1); ++ Add64(sp, sp, ++ Operand( ++ static_cast(StackHandlerConstants::kSize - kPointerSize))); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, ++ ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); ++ Sd(a1, MemOperand(scratch)); ++} ++ ++void TurboAssembler::FPUCanonicalizeNaN(const DoubleRegister dst, ++ const DoubleRegister src) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ Label NotNaN; ++ ++ fmv_d(dst, src); ++ feq_d(scratch, src, src); ++ bne(scratch, zero_reg, &NotNaN); ++ RV_li(scratch, 0x7ff8000000000000ULL); // This is the canonical NaN ++ fmv_d_x(dst, scratch); ++ bind(&NotNaN); ++} ++ ++void TurboAssembler::MovFromFloatResult(const DoubleRegister dst) { ++ Move(dst, fa0); // Reg fa0 is FP return value. ++} ++ ++void TurboAssembler::MovFromFloatParameter(const DoubleRegister dst) { ++ Move(dst, fa0); // Reg fa0 is FP first argument value. ++} ++ ++void TurboAssembler::MovToFloatParameter(DoubleRegister src) { Move(fa0, src); } ++ ++void TurboAssembler::MovToFloatResult(DoubleRegister src) { Move(fa0, src); } ++ ++void TurboAssembler::MovToFloatParameters(DoubleRegister src1, ++ DoubleRegister src2) { ++ const DoubleRegister fparg2 = fa1; ++ if (src2 == fa0) { ++ DCHECK(src1 != fparg2); ++ Move(fparg2, src2); ++ Move(fa0, src1); ++ } else { ++ Move(fa0, src1); ++ Move(fparg2, src2); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// JavaScript invokes. ++ ++void TurboAssembler::PrepareForTailCall(Register callee_args_count, ++ Register caller_args_count, ++ Register scratch0, Register scratch1) { ++ // Calculate the end of destination area where we will put the arguments ++ // after we drop current frame. We add kPointerSize to count the receiver ++ // argument which is not included into formal parameters count. ++ Register dst_reg = scratch0; ++ CalcScaledAddress(dst_reg, fp, caller_args_count, kPointerSizeLog2); ++ Add64(dst_reg, dst_reg, ++ Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); ++ ++ Register src_reg = caller_args_count; ++ // Calculate the end of source area. +kPointerSize is for the receiver. ++ CalcScaledAddress(src_reg, sp, callee_args_count, kPointerSizeLog2); ++ Add64(src_reg, src_reg, Operand(kPointerSize)); ++ ++ if (FLAG_debug_code) { ++ Check(Uless, AbortReason::kStackAccessBelowStackPointer, src_reg, ++ Operand(dst_reg)); ++ } ++ ++ // Restore caller's frame pointer and return address now as they will be ++ // overwritten by the copying loop. ++ Ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); ++ Ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ ++ // Now copy callee arguments to the caller frame going backwards to avoid ++ // callee arguments corruption (source and destination areas could overlap). ++ ++ // Both src_reg and dst_reg are pointing to the word after the one to copy, ++ // so they must be pre-decremented in the loop. ++ Register tmp_reg = scratch1; ++ Label loop, entry; ++ Branch(&entry); ++ bind(&loop); ++ Sub64(src_reg, src_reg, Operand(kPointerSize)); ++ Sub64(dst_reg, dst_reg, Operand(kPointerSize)); ++ Ld(tmp_reg, MemOperand(src_reg)); ++ Sd(tmp_reg, MemOperand(dst_reg)); ++ bind(&entry); ++ Branch(&loop, ne, sp, Operand(src_reg)); ++ ++ // Leave current frame. ++ mv(sp, dst_reg); ++} ++ ++void MacroAssembler::InvokePrologue(Register expected_parameter_count, ++ Register actual_parameter_count, ++ Label* done, InvokeFlag flag) { ++ Label regular_invoke; ++ ++ // Check whether the expected and actual arguments count match. The ++ // registers are set up according to contract with ++ // ArgumentsAdaptorTrampoline: ++ // a0: actual arguments count ++ // a1: function (passed through to callee) ++ // a2: expected arguments count ++ ++ // The code below is made a lot easier because the calling code already sets ++ // up actual and expected registers according to the contract. ++ ++ DCHECK_EQ(actual_parameter_count, a0); ++ DCHECK_EQ(expected_parameter_count, a2); ++ ++ Branch(®ular_invoke, eq, expected_parameter_count, ++ Operand(actual_parameter_count)); ++ ++ Handle adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline); ++ if (flag == CALL_FUNCTION) { ++ Call(adaptor); ++ Branch(done); ++ } else { ++ Jump(adaptor, RelocInfo::CODE_TARGET); ++ } ++ ++ bind(®ular_invoke); ++} ++ ++void MacroAssembler::CheckDebugHook(Register fun, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count) { ++ Label skip_hook; ++ ++ li(t0, ExternalReference::debug_hook_on_function_call_address(isolate())); ++ Lb(t0, MemOperand(t0)); ++ Branch(&skip_hook, eq, t0, Operand(zero_reg)); ++ ++ { ++ // Load receiver to pass it later to DebugOnFunctionCall hook. ++ CalcScaledAddress(t0, sp, actual_parameter_count, kPointerSizeLog2); ++ Ld(t0, MemOperand(t0)); ++ FrameScope frame(this, ++ has_frame() ? StackFrame::NONE : StackFrame::INTERNAL); ++ SmiTag(expected_parameter_count); ++ Push(expected_parameter_count); ++ ++ SmiTag(actual_parameter_count); ++ Push(actual_parameter_count); ++ ++ if (new_target.is_valid()) { ++ Push(new_target); ++ } ++ Push(fun); ++ Push(fun); ++ Push(t0); ++ CallRuntime(Runtime::kDebugOnFunctionCall); ++ Pop(fun); ++ if (new_target.is_valid()) { ++ Pop(new_target); ++ } ++ ++ Pop(actual_parameter_count); ++ SmiUntag(actual_parameter_count); ++ ++ Pop(expected_parameter_count); ++ SmiUntag(expected_parameter_count); ++ } ++ bind(&skip_hook); ++} ++ ++void MacroAssembler::InvokeFunctionCode(Register function, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ DCHECK_EQ(function, a1); ++ DCHECK_IMPLIES(new_target.is_valid(), new_target == a3); ++ ++ // On function call, call into the debugger if necessary. ++ CheckDebugHook(function, new_target, expected_parameter_count, ++ actual_parameter_count); ++ ++ // Clear the new.target register if not given. ++ if (!new_target.is_valid()) { ++ LoadRoot(a3, RootIndex::kUndefinedValue); ++ } ++ ++ Label done; ++ InvokePrologue(expected_parameter_count, actual_parameter_count, &done, flag); ++ // We call indirectly through the code field in the function to ++ // allow recompilation to take effect without changing any of the ++ // call sites. ++ Register code = kJavaScriptCallCodeStartRegister; ++ Ld(code, FieldMemOperand(function, JSFunction::kCodeOffset)); ++ if (flag == CALL_FUNCTION) { ++ Add64(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Call(code); ++ } else { ++ DCHECK(flag == JUMP_FUNCTION); ++ Add64(code, code, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ Jump(code); ++ } ++ ++ // Continue here if InvokePrologue does handle the invocation due to ++ // mismatched parameter counts. ++ bind(&done); ++} ++ ++void MacroAssembler::InvokeFunctionWithNewTarget( ++ Register function, Register new_target, Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ ++ // Contract with called JS functions requires that function is passed in a1. ++ DCHECK_EQ(function, a1); ++ Register expected_parameter_count = a2; ++ Register temp_reg = t0; ++ Ld(temp_reg, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ // The argument count is stored as uint16_t ++ Lhu(expected_parameter_count, ++ FieldMemOperand(temp_reg, ++ SharedFunctionInfo::kFormalParameterCountOffset)); ++ ++ InvokeFunctionCode(a1, new_target, expected_parameter_count, ++ actual_parameter_count, flag); ++} ++ ++void MacroAssembler::InvokeFunction(Register function, ++ Register expected_parameter_count, ++ Register actual_parameter_count, ++ InvokeFlag flag) { ++ // You can't call a function without a valid frame. ++ DCHECK_IMPLIES(flag == CALL_FUNCTION, has_frame()); ++ ++ // Contract with called JS functions requires that function is passed in a1. ++ DCHECK_EQ(function, a1); ++ ++ // Get the function and setup the context. ++ Ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); ++ ++ InvokeFunctionCode(a1, no_reg, expected_parameter_count, ++ actual_parameter_count, flag); ++} ++ ++// --------------------------------------------------------------------------- ++// Support functions. ++ ++void MacroAssembler::GetObjectType(Register object, Register map, ++ Register type_reg) { ++ LoadMap(map, object); ++ Lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); ++} ++ ++// ----------------------------------------------------------------------------- ++// Runtime calls. ++ ++void TurboAssembler::AddOverflow64(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t5; ++ if (!right.is_reg()) { ++ li(t3, Operand(right)); ++ right_reg = t3; ++ } else { ++ right_reg = right.rm(); ++ } ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ if (dst == left || dst == right_reg) { ++ add(scratch, left, right_reg); ++ xor_(overflow, scratch, left); ++ xor_(t3, scratch, right_reg); ++ and_(overflow, overflow, t3); ++ mv(dst, scratch); ++ } else { ++ add(dst, left, right_reg); ++ xor_(overflow, dst, left); ++ xor_(t3, dst, right_reg); ++ and_(overflow, overflow, t3); ++ } ++} ++ ++void TurboAssembler::SubOverflow64(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t5; ++ if (!right.is_reg()) { ++ li(t3, Operand(right)); ++ right_reg = t3; ++ } else { ++ right_reg = right.rm(); ++ } ++ ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ ++ if (dst == left || dst == right_reg) { ++ sub(scratch, left, right_reg); ++ xor_(overflow, left, scratch); ++ xor_(t3, left, right_reg); ++ and_(overflow, overflow, t3); ++ mv(dst, scratch); ++ } else { ++ sub(dst, left, right_reg); ++ xor_(overflow, left, dst); ++ xor_(t3, left, right_reg); ++ and_(overflow, overflow, t3); ++ } ++} ++ ++void TurboAssembler::MulOverflow32(Register dst, Register left, ++ const Operand& right, Register overflow) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ Register right_reg = no_reg; ++ Register scratch = t5; ++ if (!right.is_reg()) { ++ li(t3, Operand(right)); ++ right_reg = t3; ++ } else { ++ right_reg = right.rm(); ++ } ++ ++ DCHECK(left != scratch && right_reg != scratch && dst != scratch && ++ overflow != scratch); ++ DCHECK(overflow != left && overflow != right_reg); ++ sext_w(overflow, left); ++ sext_w(scratch, right_reg); ++ ++ mul(overflow, overflow, scratch); ++ sext_w(dst, overflow); ++ xor_(overflow, overflow, dst); ++} ++ ++void MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, ++ SaveFPRegsMode save_doubles) { ++ // All parameters are on the stack. a0 has the return value after call. ++ ++ // If the expected number of arguments of the runtime function is ++ // constant, we check that the actual number of arguments match the ++ // expectation. ++ CHECK(f->nargs < 0 || f->nargs == num_arguments); ++ ++ // TODO(1236192): Most runtime routines don't need the number of ++ // arguments passed in because it is constant. At some point we ++ // should remove this need and make the runtime routine entry code ++ // smarter. ++ PrepareCEntryArgs(num_arguments); ++ PrepareCEntryFunction(ExternalReference::Create(f)); ++ Handle code = ++ CodeFactory::CEntry(isolate(), f->result_size, save_doubles); ++ Call(code, RelocInfo::CODE_TARGET); ++} ++ ++void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { ++ const Runtime::Function* function = Runtime::FunctionForId(fid); ++ DCHECK_EQ(1, function->result_size); ++ if (function->nargs >= 0) { ++ PrepareCEntryArgs(function->nargs); ++ } ++ JumpToExternalReference(ExternalReference::Create(fid)); ++} ++ ++void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, ++ bool builtin_exit_frame) { ++ PrepareCEntryFunction(builtin); ++ Handle code = CodeFactory::CEntry(isolate(), 1, kDontSaveFPRegs, ++ kArgvOnStack, builtin_exit_frame); ++ Jump(code, RelocInfo::CODE_TARGET, al, zero_reg, Operand(zero_reg)); ++} ++ ++void MacroAssembler::JumpToInstructionStream(Address entry) { ++ li(kOffHeapTrampolineRegister, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ Jump(kOffHeapTrampolineRegister); ++} ++ ++void MacroAssembler::LoadWeakValue(Register out, Register in, ++ Label* target_if_cleared) { ++ Branch(target_if_cleared, eq, in, Operand(kClearedWeakHeapObjectLower32)); ++ ++ And(out, in, Operand(~kWeakHeapObjectMask)); ++} ++ ++void MacroAssembler::IncrementCounter(StatsCounter* counter, int value, ++ Register scratch1, Register scratch2) { ++ DCHECK_GT(value, 0); ++ if (FLAG_native_code_counters && counter->Enabled()) { ++ // This operation has to be exactly 32-bit wide in case the external ++ // reference table redirects the counter to a uint32_t ++ // dummy_stats_counter_ field. ++ li(scratch2, ExternalReference::Create(counter)); ++ Lw(scratch1, MemOperand(scratch2)); ++ Add32(scratch1, scratch1, Operand(value)); ++ Sw(scratch1, MemOperand(scratch2)); ++ } ++} ++ ++void MacroAssembler::DecrementCounter(StatsCounter* counter, int value, ++ Register scratch1, Register scratch2) { ++ DCHECK_GT(value, 0); ++ if (FLAG_native_code_counters && counter->Enabled()) { ++ // This operation has to be exactly 32-bit wide in case the external ++ // reference table redirects the counter to a uint32_t ++ // dummy_stats_counter_ field. ++ li(scratch2, ExternalReference::Create(counter)); ++ Lw(scratch1, MemOperand(scratch2)); ++ Sub32(scratch1, scratch1, Operand(value)); ++ Sw(scratch1, MemOperand(scratch2)); ++ } ++} ++ ++// ----------------------------------------------------------------------------- ++// Debugging. ++ ++void TurboAssembler::Trap() { stop(); } ++void TurboAssembler::DebugBreak() { stop(); } ++ ++void TurboAssembler::Assert(Condition cc, AbortReason reason, Register rs, ++ Operand rt) { ++ if (emit_debug_code()) Check(cc, reason, rs, rt); ++} ++ ++void TurboAssembler::Check(Condition cc, AbortReason reason, Register rs, ++ Operand rt) { ++ Label L; ++ Branch(&L, cc, rs, rt); ++ Abort(reason); ++ // Will not return here. ++ bind(&L); ++} ++ ++void TurboAssembler::Abort(AbortReason reason) { ++ Label abort_start; ++ bind(&abort_start); ++#ifdef DEBUG ++ const char* msg = GetAbortReason(reason); ++ RecordComment("Abort message: "); ++ RecordComment(msg); ++#endif ++ ++ // Avoid emitting call to builtin if requested. ++ if (trap_on_abort()) { ++ ebreak(); ++ return; ++ } ++ ++ if (should_abort_hard()) { ++ // We don't care if we constructed a frame. Just pretend we did. ++ FrameScope assume_frame(this, StackFrame::NONE); ++ PrepareCallCFunction(0, a0); ++ li(a0, Operand(static_cast(reason))); ++ CallCFunction(ExternalReference::abort_with_reason(), 1); ++ return; ++ } ++ ++ Move(a0, Smi::FromInt(static_cast(reason))); ++ ++ // Disable stub call restrictions to always allow calls to abort. ++ if (!has_frame()) { ++ // We don't actually want to generate a pile of code for this, so just ++ // claim there is a stack frame, without generating one. ++ FrameScope scope(this, StackFrame::NONE); ++ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); ++ } else { ++ Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); ++ } ++ // Will not return here. ++ if (is_trampoline_pool_blocked()) { ++ // If the calling code cares about the exact number of ++ // instructions generated, we insert padding here to keep the size ++ // of the Abort macro constant. ++ // Currently in debug mode with debug_code enabled the number of ++ // generated instructions is 10, so we use this as a maximum value. ++ static const int kExpectedAbortInstructions = 10; ++ int abort_instructions = InstructionsGeneratedSince(&abort_start); ++ DCHECK_LE(abort_instructions, kExpectedAbortInstructions); ++ while (abort_instructions++ < kExpectedAbortInstructions) { ++ nop(); ++ } ++ } ++} ++ ++void MacroAssembler::LoadMap(Register destination, Register object) { ++ Ld(destination, FieldMemOperand(object, HeapObject::kMapOffset)); ++} ++ ++void MacroAssembler::LoadNativeContextSlot(int index, Register dst) { ++ LoadMap(dst, cp); ++ Ld(dst, ++ FieldMemOperand(dst, Map::kConstructorOrBackPointerOrNativeContextOffset)); ++ Ld(dst, MemOperand(dst, Context::SlotOffset(index))); ++} ++ ++void TurboAssembler::StubPrologue(StackFrame::Type type) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(StackFrame::TypeToMarker(type))); ++ PushCommonFrame(scratch); ++} ++ ++void TurboAssembler::Prologue() { PushStandardFrame(a1); } ++ ++void TurboAssembler::EnterFrame(StackFrame::Type type) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ int stack_offset = -3 * kPointerSize; ++ const int fp_offset = 1 * kPointerSize; ++ addi(sp, sp, stack_offset); ++ stack_offset = -stack_offset - kPointerSize; ++ Sd(ra, MemOperand(sp, stack_offset)); ++ stack_offset -= kPointerSize; ++ Sd(fp, MemOperand(sp, stack_offset)); ++ stack_offset -= kPointerSize; ++ li(t6, Operand(StackFrame::TypeToMarker(type))); ++ Sd(t6, MemOperand(sp, stack_offset)); ++ // Adjust FP to point to saved FP. ++ DCHECK_EQ(stack_offset, 0); ++ Add64(fp, sp, Operand(fp_offset)); ++} ++ ++void TurboAssembler::LeaveFrame(StackFrame::Type type) { ++ addi(sp, fp, 2 * kPointerSize); ++ Ld(ra, MemOperand(fp, 1 * kPointerSize)); ++ Ld(fp, MemOperand(fp, 0 * kPointerSize)); ++} ++ ++void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, ++ StackFrame::Type frame_type) { ++ DCHECK(frame_type == StackFrame::EXIT || ++ frame_type == StackFrame::BUILTIN_EXIT); ++ ++ // Set up the frame structure on the stack. ++ STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); ++ STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); ++ STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); ++ ++ // This is how the stack will look: ++ // fp + 2 (==kCallerSPDisplacement) - old stack's end ++ // [fp + 1 (==kCallerPCOffset)] - saved old ra ++ // [fp + 0 (==kCallerFPOffset)] - saved old fp ++ // [fp - 1 StackFrame::EXIT Smi ++ // [fp - 2 (==kSPOffset)] - sp of the called function ++ // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the ++ // new stack (will contain saved ra) ++ ++ // Save registers and reserve room for saved entry sp. ++ addi(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp); ++ Sd(ra, MemOperand(sp, 3 * kPointerSize)); ++ Sd(fp, MemOperand(sp, 2 * kPointerSize)); ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ li(scratch, Operand(StackFrame::TypeToMarker(frame_type))); ++ Sd(scratch, MemOperand(sp, 1 * kPointerSize)); ++ } ++ // Set up new frame pointer. ++ addi(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp); ++ ++ if (emit_debug_code()) { ++ Sd(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); ++ } ++ ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Save the frame pointer and the context in top. ++ li(t5, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, ++ isolate())); ++ Sd(fp, MemOperand(t5)); ++ li(t5, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ Sd(cp, MemOperand(t5)); ++ } ++ ++ const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); ++ if (save_doubles) { ++ // The stack is already aligned to 0 modulo 8 for stores with sdc1. ++ int kNumOfSavedRegisters = FPURegister::kNumRegisters; ++ int space = kNumOfSavedRegisters * kDoubleSize; ++ Sub64(sp, sp, Operand(space)); ++ for (int i = 0; i < kNumOfSavedRegisters; i++) { ++ FPURegister reg = FPURegister::from_code(i); ++ StoreDouble(reg, MemOperand(sp, i * kDoubleSize)); ++ } ++ } ++ ++ // Reserve place for the return address, stack space and an optional slot ++ // (used by DirectCEntry to hold the return value if a struct is ++ // returned) and align the frame preparing for calling the runtime function. ++ DCHECK_GE(stack_space, 0); ++ Sub64(sp, sp, Operand((stack_space + 2) * kPointerSize)); ++ if (frame_alignment > 0) { ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ And(sp, sp, Operand(-frame_alignment)); // Align stack. ++ } ++ ++ // Set the exit frame sp value to point just before the return address ++ // location. ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ addi(scratch, sp, kPointerSize); ++ Sd(scratch, MemOperand(fp, ExitFrameConstants::kSPOffset)); ++} ++ ++void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count, ++ bool do_return, ++ bool argument_count_is_length) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ // Optionally restore all double registers. ++ if (save_doubles) { ++ // Remember: we only need to restore every 2nd double FPU value. ++ int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2; ++ Sub64(t5, fp, ++ Operand(ExitFrameConstants::kFixedFrameSizeFromFp + ++ kNumOfSavedRegisters * kDoubleSize)); ++ for (int i = 0; i < kNumOfSavedRegisters; i++) { ++ FPURegister reg = FPURegister::from_code(2 * i); ++ LoadDouble(reg, MemOperand(t5, i * kDoubleSize)); ++ } ++ } ++ ++ // Clear top frame. ++ li(t5, ++ ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, isolate())); ++ Sd(zero_reg, MemOperand(t5)); ++ ++ // Restore current context from top and clear it in debug mode. ++ li(t5, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ Ld(cp, MemOperand(t5)); ++ ++#ifdef DEBUG ++ li(t5, ++ ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); ++ Sd(a3, MemOperand(t5)); ++#endif ++ ++ // Pop the arguments, restore registers, and return. ++ mv(sp, fp); // Respect ABI stack constraint. ++ Ld(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); ++ Ld(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); ++ ++ if (argument_count.is_valid()) { ++ if (argument_count_is_length) { ++ add(sp, sp, argument_count); ++ } else { ++ CalcScaledAddress(sp, sp, argument_count, kPointerSizeLog2, t5); ++ } ++ } ++ ++ addi(sp, sp, 2 * kPointerSize); ++ ++ if (do_return) { ++ Ret(); ++ } ++} ++ ++int TurboAssembler::ActivationFrameAlignment() { ++#if V8_HOST_ARCH_RISCV64 ++ // Running on the real platform. Use the alignment as mandated by the local ++ // environment. ++ // Note: This will break if we ever start generating snapshots on one RISC-V ++ // platform for another RISC-V platform with a different alignment. ++ return base::OS::ActivationFrameAlignment(); ++#else // V8_HOST_ARCH_RISCV64 ++ // If we are using the simulator then we should always align to the expected ++ // alignment. As the simulator is used to generate snapshots we do not know ++ // if the target platform will need alignment, so this is controlled from a ++ // flag. ++ return FLAG_sim_stack_alignment; ++#endif // V8_HOST_ARCH_RISCV64 ++} ++ ++void MacroAssembler::AssertStackIsAligned() { ++ if (emit_debug_code()) { ++ const int frame_alignment = ActivationFrameAlignment(); ++ const int frame_alignment_mask = frame_alignment - 1; ++ ++ if (frame_alignment > kPointerSize) { ++ Label alignment_as_expected; ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, sp, frame_alignment_mask); ++ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); ++ } ++ // Don't use Check here, as it will call Runtime_Abort re-entering here. ++ ebreak(); ++ bind(&alignment_as_expected); ++ } ++ } ++} ++ ++void TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { ++ if (SmiValuesAre32Bits()) { ++ Lw(dst, MemOperand(src.rm(), SmiWordOffset(src.offset()))); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ Lw(dst, src); ++ SmiUntag(dst); ++ } ++} ++ ++void TurboAssembler::JumpIfSmi(Register value, Label* smi_label, ++ Register scratch) { ++ DCHECK_EQ(0, kSmiTag); ++ andi(scratch, value, kSmiTagMask); ++ Branch(smi_label, eq, scratch, Operand(zero_reg)); ++} ++ ++void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label, ++ Register scratch) { ++ DCHECK_EQ(0, kSmiTag); ++ andi(scratch, value, kSmiTagMask); ++ Branch(not_smi_label, ne, scratch, Operand(zero_reg)); ++} ++ ++void MacroAssembler::AssertNotSmi(Register object) { ++ if (emit_debug_code()) { ++ STATIC_ASSERT(kSmiTag == 0); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, object, kSmiTagMask); ++ Check(ne, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertSmi(Register object) { ++ if (emit_debug_code()) { ++ STATIC_ASSERT(kSmiTag == 0); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ andi(scratch, object, kSmiTagMask); ++ Check(eq, AbortReason::kOperandIsASmi, scratch, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertConstructor(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t5); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor, t5, ++ Operand(zero_reg)); ++ ++ LoadMap(t5, object); ++ Lbu(t5, FieldMemOperand(t5, Map::kBitFieldOffset)); ++ And(t5, t5, Operand(Map::Bits1::IsConstructorBit::kMask)); ++ Check(ne, AbortReason::kOperandIsNotAConstructor, t5, Operand(zero_reg)); ++ } ++} ++ ++void MacroAssembler::AssertFunction(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t5); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t5, ++ Operand(zero_reg)); ++ GetObjectType(object, t5, t5); ++ Check(eq, AbortReason::kOperandIsNotAFunction, t5, ++ Operand(JS_FUNCTION_TYPE)); ++ } ++} ++ ++void MacroAssembler::AssertBoundFunction(Register object) { ++ if (emit_debug_code()) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t5); ++ Check(ne, AbortReason::kOperandIsASmiAndNotABoundFunction, t5, ++ Operand(zero_reg)); ++ GetObjectType(object, t5, t5); ++ Check(eq, AbortReason::kOperandIsNotABoundFunction, t5, ++ Operand(JS_BOUND_FUNCTION_TYPE)); ++ } ++} ++ ++void MacroAssembler::AssertGeneratorObject(Register object) { ++ if (!emit_debug_code()) return; ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ STATIC_ASSERT(kSmiTag == 0); ++ SmiTst(object, t5); ++ Check(ne, AbortReason::kOperandIsASmiAndNotAGeneratorObject, t5, ++ Operand(zero_reg)); ++ ++ GetObjectType(object, t5, t5); ++ ++ Label done; ++ ++ // Check if JSGeneratorObject ++ Branch(&done, eq, t5, Operand(JS_GENERATOR_OBJECT_TYPE)); ++ ++ // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) ++ Branch(&done, eq, t5, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); ++ ++ // Check if JSAsyncGeneratorObject ++ Branch(&done, eq, t5, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); ++ ++ Abort(AbortReason::kOperandIsNotAGeneratorObject); ++ ++ bind(&done); ++} ++ ++void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, ++ Register scratch) { ++ if (emit_debug_code()) { ++ Label done_checking; ++ AssertNotSmi(object); ++ LoadRoot(scratch, RootIndex::kUndefinedValue); ++ Branch(&done_checking, eq, object, Operand(scratch)); ++ GetObjectType(object, scratch, scratch); ++ Assert(eq, AbortReason::kExpectedUndefinedOrCell, scratch, ++ Operand(ALLOCATION_SITE_TYPE)); ++ bind(&done_checking); ++ } ++} ++ ++template ++void TurboAssembler::FloatMinMaxHelper(FPURegister dst, FPURegister src1, ++ FPURegister src2, MaxMinKind kind) { ++ DCHECK((std::is_same::value) || ++ (std::is_same::value)); ++ ++ if (src1 == src2 && dst != src1) { ++ if (std::is_same::value) { ++ fmv_s(dst, src1); ++ } else { ++ fmv_d(dst, src1); ++ } ++ return; ++ } ++ ++ Label done, nan; ++ ++ // For RISCV, fmin_s returns the other non-NaN operand as result if only one ++ // operand is NaN; but for JS, if any operand is NaN, result is Nan. The ++ // following handles the discrepency between handling of NaN between ISA and ++ // JS semantics ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ if (std::is_same::value) { ++ CompareIsNanF32(scratch, src1, src2); ++ } else { ++ CompareIsNanF64(scratch, src1, src2); ++ } ++ BranchTrueF(scratch, &nan); ++ ++ if (kind == MaxMinKind::kMax) { ++ if (std::is_same::value) { ++ fmax_s(dst, src1, src2); ++ } else { ++ fmax_d(dst, src1, src2); ++ } ++ } else { ++ if (std::is_same::value) { ++ fmin_s(dst, src1, src2); ++ } else { ++ fmin_d(dst, src1, src2); ++ } ++ } ++ j(&done); ++ ++ bind(&nan); ++ // if any operand is NaN, return NaN (fadd returns NaN if any operand is NaN) ++ if (std::is_same::value) { ++ fadd_s(dst, src1, src2); ++ } else { ++ fadd_d(dst, src1, src2); ++ } ++ ++ bind(&done); ++} ++ ++void TurboAssembler::Float32Max(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMax); ++} ++ ++void TurboAssembler::Float32Min(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMin); ++} ++ ++void TurboAssembler::Float64Max(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMax); ++} ++ ++void TurboAssembler::Float64Min(FPURegister dst, FPURegister src1, ++ FPURegister src2) { ++ FloatMinMaxHelper(dst, src1, src2, MaxMinKind::kMin); ++} ++ ++static const int kRegisterPassedArguments = 8; ++ ++int TurboAssembler::CalculateStackPassedDWords(int num_gp_arguments, ++ int num_fp_arguments) { ++ int stack_passed_dwords = 0; ++ ++ // Up to eight integer arguments are passed in registers a0..a7 and ++ // up to eight floating point arguments are passed in registers fa0..fa7 ++ if (num_gp_arguments > kRegisterPassedArguments) { ++ stack_passed_dwords += num_gp_arguments - kRegisterPassedArguments; ++ } ++ if (num_fp_arguments > kRegisterPassedArguments) { ++ stack_passed_dwords += num_fp_arguments - kRegisterPassedArguments; ++ } ++ stack_passed_dwords += kCArgSlotCount; ++ return stack_passed_dwords; ++} ++ ++void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, ++ int num_double_arguments, ++ Register scratch) { ++ int frame_alignment = ActivationFrameAlignment(); ++ ++ // Up to eight simple arguments in a0..a7, fa0..fa7. ++ // Remaining arguments are pushed on the stack (arg slot calculation handled ++ // by CalculateStackPassedDWords()). ++ int stack_passed_arguments = ++ CalculateStackPassedDWords(num_reg_arguments, num_double_arguments); ++ if (frame_alignment > kPointerSize) { ++ // Make stack end at alignment and make room for stack arguments and the ++ // original value of sp. ++ mv(scratch, sp); ++ Sub64(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ And(sp, sp, Operand(-frame_alignment)); ++ Sd(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); ++ } else { ++ Sub64(sp, sp, Operand(stack_passed_arguments * kPointerSize)); ++ } ++} ++ ++void TurboAssembler::PrepareCallCFunction(int num_reg_arguments, ++ Register scratch) { ++ PrepareCallCFunction(num_reg_arguments, 0, scratch); ++} ++ ++void TurboAssembler::CallCFunction(ExternalReference function, ++ int num_reg_arguments, ++ int num_double_arguments) { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ li(t6, function); ++ CallCFunctionHelper(t6, num_reg_arguments, num_double_arguments); ++} ++ ++void TurboAssembler::CallCFunction(Register function, int num_reg_arguments, ++ int num_double_arguments) { ++ CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); ++} ++ ++void TurboAssembler::CallCFunction(ExternalReference function, ++ int num_arguments) { ++ CallCFunction(function, num_arguments, 0); ++} ++ ++void TurboAssembler::CallCFunction(Register function, int num_arguments) { ++ CallCFunction(function, num_arguments, 0); ++} ++ ++void TurboAssembler::CallCFunctionHelper(Register function, ++ int num_reg_arguments, ++ int num_double_arguments) { ++ DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); ++ DCHECK(has_frame()); ++ // Make sure that the stack is aligned before calling a C function unless ++ // running in the simulator. The simulator has its own alignment check which ++ // provides more information. ++ // The argument stots are presumed to have been set up by ++ // PrepareCallCFunction. ++ ++#if V8_HOST_ARCH_RISCV64 ++ if (emit_debug_code()) { ++ int frame_alignment = base::OS::ActivationFrameAlignment(); ++ int frame_alignment_mask = frame_alignment - 1; ++ if (frame_alignment > kPointerSize) { ++ DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); ++ Label alignment_as_expected; ++ { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ And(scratch, sp, Operand(frame_alignment_mask)); ++ Branch(&alignment_as_expected, eq, scratch, Operand(zero_reg)); ++ } ++ // Don't use Check here, as it will call Runtime_Abort possibly ++ // re-entering here. ++ ebreak(); ++ bind(&alignment_as_expected); ++ } ++ } ++#endif // V8_HOST_ARCH_RISCV64 ++ ++ // Just call directly. The function called cannot cause a GC, or ++ // allow preemption, so the return address in the link register ++ // stays correct. ++ { ++ BlockTrampolinePoolScope block_trampoline_pool(this); ++ if (function != t6) { ++ mv(t6, function); ++ function = t6; ++ } ++ ++ // Save the frame pointer and PC so that the stack layout remains ++ // iterable, even without an ExitFrame which normally exists between JS ++ // and C frames. ++ // 't' registers are caller-saved so this is safe as a scratch register. ++ Register pc_scratch = t1; ++ Register scratch = t2; ++ DCHECK(!AreAliased(pc_scratch, scratch, function)); ++ ++ auipc(pc_scratch, 0); ++ // FIXME(RISCV): Does this need an offset? It seems like this should be the ++ // PC of the call, but MIPS does not seem to do that. ++ ++ // See x64 code for reasoning about how to address the isolate data fields. ++ if (root_array_available()) { ++ Sd(pc_scratch, MemOperand(kRootRegister, ++ IsolateData::fast_c_call_caller_pc_offset())); ++ Sd(fp, MemOperand(kRootRegister, ++ IsolateData::fast_c_call_caller_fp_offset())); ++ } else { ++ DCHECK_NOT_NULL(isolate()); ++ li(scratch, ExternalReference::fast_c_call_caller_pc_address(isolate())); ++ Sd(pc_scratch, MemOperand(scratch)); ++ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); ++ Sd(fp, MemOperand(scratch)); ++ } ++ ++ Call(function); ++ ++ if (isolate() != nullptr) { ++ // We don't unset the PC; the FP is the source of truth. ++ Register scratch = t1; ++ li(scratch, ExternalReference::fast_c_call_caller_fp_address(isolate())); ++ Sd(zero_reg, MemOperand(scratch)); ++ } ++ } ++ ++ int stack_passed_arguments = ++ CalculateStackPassedDWords(num_reg_arguments, num_double_arguments); ++ ++ if (base::OS::ActivationFrameAlignment() > kPointerSize) { ++ Ld(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); ++ } else { ++ Add64(sp, sp, Operand(stack_passed_arguments * kPointerSize)); ++ } ++} ++ ++#undef BRANCH_ARGS_CHECK ++ ++void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask, ++ Condition cc, Label* condition_met) { ++ And(scratch, object, Operand(~kPageAlignmentMask)); ++ Ld(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); ++ And(scratch, scratch, Operand(mask)); ++ Branch(condition_met, cc, scratch, Operand(zero_reg)); ++} ++ ++Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, ++ Register reg4, Register reg5, ++ Register reg6) { ++ RegList regs = 0; ++ if (reg1.is_valid()) regs |= reg1.bit(); ++ if (reg2.is_valid()) regs |= reg2.bit(); ++ if (reg3.is_valid()) regs |= reg3.bit(); ++ if (reg4.is_valid()) regs |= reg4.bit(); ++ if (reg5.is_valid()) regs |= reg5.bit(); ++ if (reg6.is_valid()) regs |= reg6.bit(); ++ ++ const RegisterConfiguration* config = RegisterConfiguration::Default(); ++ for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { ++ int code = config->GetAllocatableGeneralCode(i); ++ Register candidate = Register::from_code(code); ++ if (regs & candidate.bit()) continue; ++ return candidate; ++ } ++ UNREACHABLE(); ++} ++ ++void TurboAssembler::ComputeCodeStartAddress(Register dst) { ++ // This push on ra and the pop below together ensure that we restore the ++ // register ra, which is needed while computing the code start address. ++ push(ra); ++ ++ auipc(ra, 0); ++ addi(ra, ra, kInstrSize * 2); // ra = address of li ++ int pc = pc_offset(); ++ li(dst, Operand(pc)); ++ Sub64(dst, ra, dst); ++ ++ pop(ra); // Restore ra ++} ++ ++void TurboAssembler::ResetSpeculationPoisonRegister() { ++ li(kSpeculationPoisonRegister, -1); ++} ++ ++void TurboAssembler::CallForDeoptimization(Address target, int deopt_id, ++ Label* exit, DeoptimizeKind kind) { ++ USE(exit, kind); ++ NoRootArrayScope no_root_array(this); ++ ++ // Save the deopt id in kRootRegister (we don't need the roots array from ++ // now on). ++ DCHECK_LE(deopt_id, 0xFFFF); ++ li(kRootRegister, deopt_id); ++ Call(target, RelocInfo::RUNTIME_ENTRY); ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/macro-assembler-riscv64.h +@@ -0,0 +1,1181 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef INCLUDED_FROM_MACRO_ASSEMBLER_H ++#error This header must be included via macro-assembler.h ++#endif ++ ++#ifndef V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ ++#define V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ ++ ++#include "src/codegen/assembler.h" ++#include "src/codegen/riscv64/assembler-riscv64.h" ++#include "src/common/globals.h" ++ ++namespace v8 { ++namespace internal { ++ ++// Forward declarations. ++enum class AbortReason : uint8_t; ++ ++// Reserved Register Usage Summary. ++// ++// Registers t5, t6, and t3 are reserved for use by the MacroAssembler. ++// ++// The programmer should know that the MacroAssembler may clobber these three, ++// but won't touch other registers except in special cases. ++// ++// FIXME(RISCV): Cannot find info about this ABI. We chose t6 for now. ++// Per the RISC-V ABI, register t6 must be used for indirect function call ++// via 'jalr t6' or 'jr t6' instructions. This is relied upon by gcc when ++// trying to update gp register for position-independent-code. Whenever ++// RISC-V generated code calls C code, it must be via t6 register. ++ ++// Flags used for LeaveExitFrame function. ++enum LeaveExitFrameMode { EMIT_RETURN = true, NO_EMIT_RETURN = false }; ++ ++// Flags used for the li macro-assembler function. ++enum LiFlags { ++ // If the constant value can be represented in just 16 bits, then ++ // optimize the li to use a single instruction, rather than lui/ori/slli ++ // sequence. A number of other optimizations that emits less than ++ // maximum number of instructions exists. ++ OPTIMIZE_SIZE = 0, ++ // Always use 8 instructions (lui/addi/slliw sequence), even if the ++ // constant ++ // could be loaded with just one, so that this value is patchable later. ++ CONSTANT_SIZE = 1, ++ // For address loads 8 instruction are required. Used to mark ++ // constant load that will be used as address without relocation ++ // information. It ensures predictable code size, so specific sites ++ // in code are patchable. ++ ADDRESS_LOAD = 2 ++}; ++ ++enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET }; ++enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK }; ++enum RAStatus { kRAHasNotBeenSaved, kRAHasBeenSaved }; ++ ++Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2 = no_reg, ++ Register reg3 = no_reg, ++ Register reg4 = no_reg, ++ Register reg5 = no_reg, ++ Register reg6 = no_reg); ++ ++// ----------------------------------------------------------------------------- ++// Static helper functions. ++ ++#if defined(V8_TARGET_LITTLE_ENDIAN) ++#define SmiWordOffset(offset) (offset + kPointerSize / 2) ++#else ++#define SmiWordOffset(offset) offset ++#endif ++ ++// Generate a MemOperand for loading a field from an object. ++inline MemOperand FieldMemOperand(Register object, int offset) { ++ return MemOperand(object, offset - kHeapObjectTag); ++} ++ ++// Generate a MemOperand for storing arguments 5..N on the stack ++// when calling CallCFunction(). ++// TODO(plind): Currently ONLY used for O32. Should be fixed for ++// n64, and used in RegExp code, and other places ++// with more than 8 arguments. ++inline MemOperand CFunctionArgumentOperand(int index) { ++ DCHECK_GT(index, kCArgSlotCount); ++ // Argument 5 takes the slot just past the four Arg-slots. ++ int offset = (index - 5) * kPointerSize + kCArgsSlotsSize; ++ return MemOperand(sp, offset); ++} ++ ++class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ++ public: ++ using TurboAssemblerBase::TurboAssemblerBase; ++ ++ // Activation support. ++ void EnterFrame(StackFrame::Type type); ++ void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg) { ++ // Out-of-line constant pool not implemented on RISC-V. ++ UNREACHABLE(); ++ } ++ void LeaveFrame(StackFrame::Type type); ++ ++ // Generates function and stub prologue code. ++ void StubPrologue(StackFrame::Type type); ++ void Prologue(); ++ ++ void InitializeRootRegister() { ++ ExternalReference isolate_root = ExternalReference::isolate_root(isolate()); ++ li(kRootRegister, Operand(isolate_root)); ++ } ++ ++ // Jump unconditionally to given label. ++ void jmp(Label* L) { Branch(L); } ++ ++ // ------------------------------------------------------------------------- ++ // Debugging. ++ ++ void Trap() override; ++ void DebugBreak() override; ++ ++ // Calls Abort(msg) if the condition cc is not satisfied. ++ // Use --debug_code to enable. ++ void Assert(Condition cc, AbortReason reason, Register rs, Operand rt); ++ ++ // Like Assert(), but always enabled. ++ void Check(Condition cc, AbortReason reason, Register rs, Operand rt); ++ ++ // Print a message to stdout and abort execution. ++ void Abort(AbortReason msg); ++ ++ // Arguments macros. ++#define COND_TYPED_ARGS Condition cond, Register r1, const Operand &r2 ++#define COND_ARGS cond, r1, r2 ++ ++ // Cases when relocation is not needed. ++#define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \ ++ void Name(target_type target); \ ++ void Name(target_type target, COND_TYPED_ARGS); ++ ++#define DECLARE_BRANCH_PROTOTYPES(Name) \ ++ DECLARE_NORELOC_PROTOTYPE(Name, Label*) \ ++ DECLARE_NORELOC_PROTOTYPE(Name, int32_t) ++ ++ DECLARE_BRANCH_PROTOTYPES(Branch) ++ DECLARE_BRANCH_PROTOTYPES(BranchAndLink) ++ DECLARE_BRANCH_PROTOTYPES(BranchShort) ++ ++#undef DECLARE_BRANCH_PROTOTYPES ++#undef COND_TYPED_ARGS ++#undef COND_ARGS ++ ++ inline void NegateBool(Register rd, Register rs) { Xor(rd, rs, 1); } ++ ++ // Compare float, if any operand is NaN, result is false except for NE ++ void CompareF32(Register rd, FPUCondition cc, FPURegister cmp1, ++ FPURegister cmp2); ++ // Compare double, if any operand is NaN, result is false except for NE ++ void CompareF64(Register rd, FPUCondition cc, FPURegister cmp1, ++ FPURegister cmp2); ++ void CompareIsNanF32(Register rd, FPURegister cmp1, FPURegister cmp2); ++ void CompareIsNanF64(Register rd, FPURegister cmp1, FPURegister cmp2); ++ ++ // Floating point branches ++ void BranchTrueShortF(Register rs, Label* target); ++ void BranchFalseShortF(Register rs, Label* target); ++ ++ void BranchTrueF(Register rs, Label* target); ++ void BranchFalseF(Register rs, Label* target); ++ ++ void Branch(Label* L, Condition cond, Register rs, RootIndex index); ++ ++ static int InstrCountForLi64Bit(int64_t value); ++ inline void LiLower32BitHelper(Register rd, Operand j); ++ void li_optimized(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); ++ // Load int32 in the rd register. ++ void li(Register rd, Operand j, LiFlags mode = OPTIMIZE_SIZE); ++ inline void li(Register rd, int64_t j, LiFlags mode = OPTIMIZE_SIZE) { ++ li(rd, Operand(j), mode); ++ } ++ ++ void li(Register dst, Handle value, LiFlags mode = OPTIMIZE_SIZE); ++ void li(Register dst, ExternalReference value, LiFlags mode = OPTIMIZE_SIZE); ++ void li(Register dst, const StringConstantBase* string, ++ LiFlags mode = OPTIMIZE_SIZE); ++ ++ void LoadFromConstantsTable(Register destination, ++ int constant_index) override; ++ void LoadRootRegisterOffset(Register destination, intptr_t offset) override; ++ void LoadRootRelative(Register destination, int32_t offset) override; ++ ++// Jump, Call, and Ret pseudo instructions implementing inter-working. ++#define COND_ARGS \ ++ Condition cond = al, Register rs = zero_reg, \ ++ const Operand &rt = Operand(zero_reg) ++ ++ void Jump(Register target, COND_ARGS); ++ void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS); ++ void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS); ++ // Deffer from li, this method save target to the memory, and then load ++ // it to register use ld, it can be used in wasm jump table for concurrent ++ // patching. ++ void PatchAndJump(Address target); ++ void Jump(Handle code, RelocInfo::Mode rmode, COND_ARGS); ++ void Jump(const ExternalReference& reference) override; ++ void Call(Register target, COND_ARGS); ++ void Call(Address target, RelocInfo::Mode rmode, COND_ARGS); ++ void Call(Handle code, RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, ++ COND_ARGS); ++ void Call(Label* target); ++ void LoadAddress(Register dst, Label* target); ++ ++ // Load the builtin given by the Smi in |builtin_index| into the same ++ // register. ++ void LoadEntryFromBuiltinIndex(Register builtin_index); ++ void CallBuiltinByIndex(Register builtin_index) override; ++ ++ void LoadCodeObjectEntry(Register destination, ++ Register code_object) override { ++ // TODO(RISCV): Implement. ++ UNIMPLEMENTED(); ++ } ++ void CallCodeObject(Register code_object) override { ++ // TODO(RISCV): Implement. ++ UNIMPLEMENTED(); ++ } ++ void JumpCodeObject(Register code_object) override { ++ // TODO(RISCV): Implement. ++ UNIMPLEMENTED(); ++ } ++ ++ // Generates an instruction sequence s.t. the return address points to the ++ // instruction following the call. ++ // The return address on the stack is used by frame iteration. ++ void StoreReturnAddressAndCall(Register target); ++ ++ void CallForDeoptimization(Address target, int deopt_id, Label* exit, ++ DeoptimizeKind kind); ++ ++ void Ret(COND_ARGS); ++ ++ // Emit code to discard a non-negative number of pointer-sized elements ++ // from the stack, clobbering only the sp register. ++ void Drop(int count, Condition cond = cc_always, Register reg = no_reg, ++ const Operand& op = Operand(no_reg)); ++ ++ // Trivial case of DropAndRet that only emits 2 instructions. ++ void DropAndRet(int drop); ++ ++ void DropAndRet(int drop, Condition cond, Register reg, const Operand& op); ++ ++ void Ld(Register rd, const MemOperand& rs); ++ void Sd(Register rd, const MemOperand& rs); ++ ++ void push(Register src) { ++ Add64(sp, sp, Operand(-kPointerSize)); ++ Sd(src, MemOperand(sp, 0)); ++ } ++ void Push(Register src) { push(src); } ++ void Push(Handle handle); ++ void Push(Smi smi); ++ ++ // Push two registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2) { ++ Sub64(sp, sp, Operand(2 * kPointerSize)); ++ Sd(src1, MemOperand(sp, 1 * kPointerSize)); ++ Sd(src2, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push three registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3) { ++ Sub64(sp, sp, Operand(3 * kPointerSize)); ++ Sd(src1, MemOperand(sp, 2 * kPointerSize)); ++ Sd(src2, MemOperand(sp, 1 * kPointerSize)); ++ Sd(src3, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push four registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3, Register src4) { ++ Sub64(sp, sp, Operand(4 * kPointerSize)); ++ Sd(src1, MemOperand(sp, 3 * kPointerSize)); ++ Sd(src2, MemOperand(sp, 2 * kPointerSize)); ++ Sd(src3, MemOperand(sp, 1 * kPointerSize)); ++ Sd(src4, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ // Push five registers. Pushes leftmost register first (to highest address). ++ void Push(Register src1, Register src2, Register src3, Register src4, ++ Register src5) { ++ Sub64(sp, sp, Operand(5 * kPointerSize)); ++ Sd(src1, MemOperand(sp, 4 * kPointerSize)); ++ Sd(src2, MemOperand(sp, 3 * kPointerSize)); ++ Sd(src3, MemOperand(sp, 2 * kPointerSize)); ++ Sd(src4, MemOperand(sp, 1 * kPointerSize)); ++ Sd(src5, MemOperand(sp, 0 * kPointerSize)); ++ } ++ ++ void Push(Register src, Condition cond, Register tst1, Register tst2) { ++ // Since we don't have conditional execution we use a Branch. ++ Branch(3, cond, tst1, Operand(tst2)); ++ Sub64(sp, sp, Operand(kPointerSize)); ++ Sd(src, MemOperand(sp, 0)); ++ } ++ ++ void SaveRegisters(RegList registers); ++ void RestoreRegisters(RegList registers); ++ ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode); ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode, Address wasm_target); ++ void CallEphemeronKeyBarrier(Register object, Register address, ++ SaveFPRegsMode fp_mode); ++ ++ // Push multiple registers on the stack. ++ // Registers are saved in numerical order, with higher numbered registers ++ // saved in higher memory addresses. ++ void MultiPush(RegList regs); ++ void MultiPushFPU(RegList regs); ++ ++ // Calculate how much stack space (in bytes) are required to store caller ++ // registers excluding those specified in the arguments. ++ int RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, ++ Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg) const; ++ ++ // Push caller saved registers on the stack, and return the number of bytes ++ // stack pointer is adjusted. ++ int PushCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg); ++ // Restore caller saved registers from the stack, and return the number of ++ // bytes stack pointer is adjusted. ++ int PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion1 = no_reg, ++ Register exclusion2 = no_reg, ++ Register exclusion3 = no_reg); ++ ++ void pop(Register dst) { ++ Ld(dst, MemOperand(sp, 0)); ++ Add64(sp, sp, Operand(kPointerSize)); ++ } ++ void Pop(Register dst) { pop(dst); } ++ ++ // Pop two registers. Pops rightmost register first (from lower address). ++ void Pop(Register src1, Register src2) { ++ DCHECK(src1 != src2); ++ Ld(src2, MemOperand(sp, 0 * kPointerSize)); ++ Ld(src1, MemOperand(sp, 1 * kPointerSize)); ++ Add64(sp, sp, 2 * kPointerSize); ++ } ++ ++ // Pop three registers. Pops rightmost register first (from lower address). ++ void Pop(Register src1, Register src2, Register src3) { ++ Ld(src3, MemOperand(sp, 0 * kPointerSize)); ++ Ld(src2, MemOperand(sp, 1 * kPointerSize)); ++ Ld(src1, MemOperand(sp, 2 * kPointerSize)); ++ Add64(sp, sp, 3 * kPointerSize); ++ } ++ ++ void Pop(uint32_t count = 1) { Add64(sp, sp, Operand(count * kPointerSize)); } ++ ++ // Pops multiple values from the stack and load them in the ++ // registers specified in regs. Pop order is the opposite as in MultiPush. ++ void MultiPop(RegList regs); ++ void MultiPopFPU(RegList regs); ++ ++#define DEFINE_INSTRUCTION(instr) \ ++ void instr(Register rd, Register rs, const Operand& rt); \ ++ void instr(Register rd, Register rs, Register rt) { \ ++ instr(rd, rs, Operand(rt)); \ ++ } \ ++ void instr(Register rs, Register rt, int32_t j) { instr(rs, rt, Operand(j)); } ++ ++#define DEFINE_INSTRUCTION2(instr) \ ++ void instr(Register rs, const Operand& rt); \ ++ void instr(Register rs, Register rt) { instr(rs, Operand(rt)); } \ ++ void instr(Register rs, int32_t j) { instr(rs, Operand(j)); } ++ ++ DEFINE_INSTRUCTION(Add32) ++ DEFINE_INSTRUCTION(Add64) ++ DEFINE_INSTRUCTION(Div32) ++ DEFINE_INSTRUCTION(Divu32) ++ DEFINE_INSTRUCTION(Divu64) ++ DEFINE_INSTRUCTION(Mod32) ++ DEFINE_INSTRUCTION(Modu32) ++ DEFINE_INSTRUCTION(Div64) ++ DEFINE_INSTRUCTION(Sub32) ++ DEFINE_INSTRUCTION(Sub64) ++ DEFINE_INSTRUCTION(Mod64) ++ DEFINE_INSTRUCTION(Modu64) ++ DEFINE_INSTRUCTION(Mul32) ++ DEFINE_INSTRUCTION(Mulh32) ++ DEFINE_INSTRUCTION(Mul64) ++ DEFINE_INSTRUCTION(Mulh64) ++ DEFINE_INSTRUCTION2(Div32) ++ DEFINE_INSTRUCTION2(Div64) ++ DEFINE_INSTRUCTION2(Divu32) ++ DEFINE_INSTRUCTION2(Divu64) ++ ++ DEFINE_INSTRUCTION(And) ++ DEFINE_INSTRUCTION(Or) ++ DEFINE_INSTRUCTION(Xor) ++ DEFINE_INSTRUCTION(Nor) ++ DEFINE_INSTRUCTION2(Neg) ++ ++ DEFINE_INSTRUCTION(Slt) ++ DEFINE_INSTRUCTION(Sltu) ++ DEFINE_INSTRUCTION(Sle) ++ DEFINE_INSTRUCTION(Sleu) ++ DEFINE_INSTRUCTION(Sgt) ++ DEFINE_INSTRUCTION(Sgtu) ++ DEFINE_INSTRUCTION(Sge) ++ DEFINE_INSTRUCTION(Sgeu) ++ DEFINE_INSTRUCTION(Seq) ++ DEFINE_INSTRUCTION(Sne) ++ ++ DEFINE_INSTRUCTION(Sll64) ++ DEFINE_INSTRUCTION(Sra64) ++ DEFINE_INSTRUCTION(Srl64) ++ DEFINE_INSTRUCTION(Sll32) ++ DEFINE_INSTRUCTION(Sra32) ++ DEFINE_INSTRUCTION(Srl32) ++ ++ DEFINE_INSTRUCTION2(Seqz) ++ DEFINE_INSTRUCTION2(Snez) ++ ++ DEFINE_INSTRUCTION(Ror) ++ DEFINE_INSTRUCTION(Dror) ++#undef DEFINE_INSTRUCTION ++#undef DEFINE_INSTRUCTION2 ++#undef DEFINE_INSTRUCTION3 ++ ++ void SmiUntag(Register dst, const MemOperand& src); ++ void SmiUntag(Register dst, Register src) { ++ if (SmiValuesAre32Bits()) { ++ srai(dst, src, kSmiShift); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ sraiw(dst, src, kSmiShift); ++ } ++ } ++ ++ void SmiUntag(Register reg) { SmiUntag(reg, reg); } ++ ++ // Removes current frame and its arguments from the stack preserving ++ // the arguments and a return address pushed to the stack for the next call. ++ // Both |callee_args_count| and |caller_args_count| do not include ++ // receiver. |callee_args_count| is not modified. |caller_args_count| ++ // is trashed. ++ void PrepareForTailCall(Register callee_args_count, ++ Register caller_args_count, Register scratch0, ++ Register scratch1); ++ ++ int CalculateStackPassedDWords(int num_gp_arguments, int num_fp_arguments); ++ ++ // Before calling a C-function from generated code, align arguments on stack. ++ // After aligning the frame, non-register arguments must be stored on the ++ // stack, using helper: CFunctionArgumentOperand(). ++ // The argument count assumes all arguments are word sized. ++ // Some compilers/platforms require the stack to be aligned when calling ++ // C++ code. ++ // Needs a scratch register to do some arithmetic. This register will be ++ // trashed. ++ void PrepareCallCFunction(int num_reg_arguments, int num_double_registers, ++ Register scratch); ++ void PrepareCallCFunction(int num_reg_arguments, Register scratch); ++ ++ // Arguments 1-8 are placed in registers a0 through a7 respectively. ++ // Arguments 9..n are stored to stack ++ ++ // Calls a C function and cleans up the space for arguments allocated ++ // by PrepareCallCFunction. The called function is not allowed to trigger a ++ // garbage collection, since that might move the code and invalidate the ++ // return address (unless this is somehow accounted for by the called ++ // function). ++ void CallCFunction(ExternalReference function, int num_arguments); ++ void CallCFunction(Register function, int num_arguments); ++ void CallCFunction(ExternalReference function, int num_reg_arguments, ++ int num_double_arguments); ++ void CallCFunction(Register function, int num_reg_arguments, ++ int num_double_arguments); ++ void MovFromFloatResult(DoubleRegister dst); ++ void MovFromFloatParameter(DoubleRegister dst); ++ ++ // These functions abstract parameter passing for the three different ways ++ // we call C functions from generated code. ++ void MovToFloatParameter(DoubleRegister src); ++ void MovToFloatParameters(DoubleRegister src1, DoubleRegister src2); ++ void MovToFloatResult(DoubleRegister src); ++ ++ // See comments at the beginning of Builtins::Generate_CEntry. ++ inline void PrepareCEntryArgs(int num_args) { li(a0, num_args); } ++ inline void PrepareCEntryFunction(const ExternalReference& ref) { ++ li(a1, ref); ++ } ++ ++ void CheckPageFlag(Register object, Register scratch, int mask, Condition cc, ++ Label* condition_met); ++#undef COND_ARGS ++ ++ // Performs a truncating conversion of a floating point number as used by ++ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. ++ // Exits with 'result' holding the answer. ++ void TruncateDoubleToI(Isolate* isolate, Zone* zone, Register result, ++ DoubleRegister double_input, StubCallMode stub_mode); ++ ++ void CompareI(Register rd, Register rs, const Operand& rt, Condition cond); ++ ++ void LoadZeroIfConditionNotZero(Register dest, Register condition); ++ void LoadZeroIfConditionZero(Register dest, Register condition); ++ ++ void SignExtendByte(Register rd, Register rs) { ++ slli(rd, rs, 64 - 8); ++ srai(rd, rd, 64 - 8); ++ } ++ ++ void SignExtendShort(Register rd, Register rs) { ++ slli(rd, rs, 64 - 16); ++ srai(rd, rd, 64 - 16); ++ } ++ ++ void SignExtendWord(Register rd, Register rs) { sext_w(rd, rs); } ++ void ZeroExtendWord(Register rd, Register rs) { ++ slli(rd, rs, 32); ++ srli(rd, rd, 32); ++ } ++ ++ void Clz32(Register rd, Register rs); ++ void Clz64(Register rd, Register rs); ++ void Ctz32(Register rd, Register rs); ++ void Ctz64(Register rd, Register rs); ++ void Popcnt32(Register rd, Register rs); ++ void Popcnt64(Register rd, Register rs); ++ ++ // Bit field starts at bit pos and extending for size bits is extracted from ++ // rs and stored zero/sign-extended and right-justified in rt ++ void ExtractBits(Register rt, Register rs, uint16_t pos, uint16_t size, ++ bool sign_extend = false); ++ void ExtractBits(Register dest, Register source, Register pos, int size, ++ bool sign_extend = false) { ++ sra(dest, source, pos); ++ ExtractBits(dest, dest, 0, size, sign_extend); ++ } ++ ++ // Insert bits [0, size) of source to bits [pos, pos+size) of dest ++ void InsertBits(Register dest, Register source, Register pos, int size); ++ ++ void Neg_s(FPURegister fd, FPURegister fs); ++ void Neg_d(FPURegister fd, FPURegister fs); ++ ++ // Change endianness ++ void ByteSwap(Register dest, Register src, int operand_size); ++ ++ // Convert single to unsigned word. ++ void Trunc_uw_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // helper functions for unaligned load/store ++ template ++ void UnalignedLoadHelper(Register rd, const MemOperand& rs); ++ template ++ void UnalignedStoreHelper(Register rd, const MemOperand& rs, ++ Register scratch_other = no_reg); ++ ++ template ++ void UnalignedFLoadHelper(FPURegister frd, const MemOperand& rs, ++ Register scratch); ++ template ++ void UnalignedFStoreHelper(FPURegister frd, const MemOperand& rs, ++ Register scratch); ++ ++ template ++ void AlignedLoadHelper(Reg_T target, const MemOperand& rs, Func generator); ++ template ++ void AlignedStoreHelper(Reg_T value, const MemOperand& rs, Func generator); ++ ++ template ++ void LoadNBytes(Register rd, const MemOperand& rs, Register scratch); ++ template ++ void LoadNBytesOverwritingBaseReg(const MemOperand& rs, Register scratch0, ++ Register scratch1); ++ // load/store macros ++ void Ulh(Register rd, const MemOperand& rs); ++ void Ulhu(Register rd, const MemOperand& rs); ++ void Ush(Register rd, const MemOperand& rs); ++ ++ void Ulw(Register rd, const MemOperand& rs); ++ void Ulwu(Register rd, const MemOperand& rs); ++ void Usw(Register rd, const MemOperand& rs); ++ ++ void Uld(Register rd, const MemOperand& rs); ++ void Usd(Register rd, const MemOperand& rs); ++ ++ void ULoadFloat(FPURegister fd, const MemOperand& rs, Register scratch); ++ void UStoreFloat(FPURegister fd, const MemOperand& rs, Register scratch); ++ ++ void ULoadDouble(FPURegister fd, const MemOperand& rs, Register scratch); ++ void UStoreDouble(FPURegister fd, const MemOperand& rs, Register scratch); ++ ++ void Lb(Register rd, const MemOperand& rs); ++ void Lbu(Register rd, const MemOperand& rs); ++ void Sb(Register rd, const MemOperand& rs); ++ ++ void Lh(Register rd, const MemOperand& rs); ++ void Lhu(Register rd, const MemOperand& rs); ++ void Sh(Register rd, const MemOperand& rs); ++ ++ void Lw(Register rd, const MemOperand& rs); ++ void Lwu(Register rd, const MemOperand& rs); ++ void Sw(Register rd, const MemOperand& rs); ++ ++ void LoadFloat(FPURegister fd, const MemOperand& src); ++ void StoreFloat(FPURegister fs, const MemOperand& dst); ++ ++ void LoadDouble(FPURegister fd, const MemOperand& src); ++ void StoreDouble(FPURegister fs, const MemOperand& dst); ++ ++ void Ll(Register rd, const MemOperand& rs); ++ void Sc(Register rd, const MemOperand& rs); ++ ++ void Lld(Register rd, const MemOperand& rs); ++ void Scd(Register rd, const MemOperand& rs); ++ ++ void Float32Max(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float32Min(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float64Max(FPURegister dst, FPURegister src1, FPURegister src2); ++ void Float64Min(FPURegister dst, FPURegister src1, FPURegister src2); ++ template ++ void FloatMinMaxHelper(FPURegister dst, FPURegister src1, FPURegister src2, ++ MaxMinKind kind); ++ ++ bool IsDoubleZeroRegSet() { return has_double_zero_reg_set_; } ++ bool IsSingleZeroRegSet() { return has_single_zero_reg_set_; } ++ ++ inline void Move(Register dst, Smi smi) { li(dst, Operand(smi)); } ++ ++ inline void Move(Register dst, Register src) { ++ if (dst != src) { ++ mv(dst, src); ++ } ++ } ++ ++ inline void Move(FPURegister dst, FPURegister src) { ++ if (dst != src) fmv_d(dst, src); ++ } ++ ++ inline void Move(Register dst_low, Register dst_high, FPURegister src) { ++ fmv_x_d(dst_high, src); ++ fmv_x_w(dst_low, src); ++ srli(dst_high, dst_high, 32); ++ } ++ ++ inline void Move(Register dst, FPURegister src) { fmv_x_d(dst, src); } ++ ++ inline void Move(FPURegister dst, Register src) { fmv_d_x(dst, src); } ++ ++ // Extract sign-extended word from high-half of FPR to GPR ++ inline void ExtractHighWordFromF64(Register dst_high, FPURegister src) { ++ fmv_x_d(dst_high, src); ++ srai(dst_high, dst_high, 32); ++ } ++ ++ // Insert low-word from GPR (src_high) to the high-half of FPR (dst) ++ void InsertHighWordF64(FPURegister dst, Register src_high); ++ ++ // Extract sign-extended word from low-half of FPR to GPR ++ inline void ExtractLowWordFromF64(Register dst_low, FPURegister src) { ++ fmv_x_w(dst_low, src); ++ } ++ ++ // Insert low-word from GPR (src_high) to the low-half of FPR (dst) ++ void InsertLowWordF64(FPURegister dst, Register src_low); ++ ++ void LoadFPRImmediate(FPURegister dst, float imm) { ++ LoadFPRImmediate(dst, bit_cast(imm)); ++ } ++ void LoadFPRImmediate(FPURegister dst, double imm) { ++ LoadFPRImmediate(dst, bit_cast(imm)); ++ } ++ void LoadFPRImmediate(FPURegister dst, uint32_t src); ++ void LoadFPRImmediate(FPURegister dst, uint64_t src); ++ ++ // AddOverflow64 sets overflow register to a negative value if ++ // overflow occured, otherwise it is zero or positive ++ void AddOverflow64(Register dst, Register left, const Operand& right, ++ Register overflow); ++ // SubOverflow64 sets overflow register to a negative value if ++ // overflow occured, otherwise it is zero or positive ++ void SubOverflow64(Register dst, Register left, const Operand& right, ++ Register overflow); ++ // MulOverflow32 sets overflow register to zero if no overflow occured ++ void MulOverflow32(Register dst, Register left, const Operand& right, ++ Register overflow); ++ ++ // MIPS-style 32-bit unsigned mulh ++ void Mulhu32(Register dst, Register left, const Operand& right, ++ Register left_zero, Register right_zero); ++ ++ // Number of instructions needed for calculation of switch table entry address ++ static const int kSwitchTablePrologueSize = 6; ++ ++ // GetLabelFunction must be lambda '[](size_t index) -> Label*' or a ++ // functor/function with 'Label *func(size_t index)' declaration. ++ template ++ void GenerateSwitchTable(Register index, size_t case_count, ++ Func GetLabelFunction); ++ ++ // Load an object from the root table. ++ void LoadRoot(Register destination, RootIndex index) override; ++ void LoadRoot(Register destination, RootIndex index, Condition cond, ++ Register src1, const Operand& src2); ++ ++ // If the value is a NaN, canonicalize the value else, do nothing. ++ void FPUCanonicalizeNaN(const DoubleRegister dst, const DoubleRegister src); ++ ++ // --------------------------------------------------------------------------- ++ // FPU macros. These do not handle special cases like NaN or +- inf. ++ ++ // Convert unsigned word to double. ++ void Cvt_d_uw(FPURegister fd, Register rs); ++ ++ // convert signed word to double. ++ void Cvt_d_w(FPURegister fd, Register rs); ++ ++ // Convert unsigned long to double. ++ void Cvt_d_ul(FPURegister fd, Register rs); ++ ++ // Convert unsigned word to float. ++ void Cvt_s_uw(FPURegister fd, Register rs); ++ ++ // convert signed word to float. ++ void Cvt_s_w(FPURegister fd, Register rs); ++ ++ // Convert unsigned long to float. ++ void Cvt_s_ul(FPURegister fd, Register rs); ++ ++ // Convert double to unsigned word. ++ void Trunc_uw_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert double to signed word. ++ void Trunc_w_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert single to signed word. ++ void Trunc_w_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert double to unsigned long. ++ void Trunc_ul_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert singled to signed long. ++ void Trunc_l_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert single to unsigned long. ++ void Trunc_ul_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Convert singled to signed long. ++ void Trunc_l_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Round single to signed word. ++ void Round_w_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Round double to signed word. ++ void Round_w_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Ceil single to signed word. ++ void Ceil_w_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Ceil double to signed word. ++ void Ceil_w_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Floor single to signed word. ++ void Floor_w_s(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Floor double to signed word. ++ void Floor_w_d(Register rd, FPURegister fs, Register result = no_reg); ++ ++ // Round double functions ++ void Trunc_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Round_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Floor_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Ceil_d_d(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ ++ // Round float functions ++ void Trunc_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Round_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Floor_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ void Ceil_s_s(FPURegister fd, FPURegister fs, FPURegister fpu_scratch); ++ ++ // Jump the register contains a smi. ++ void JumpIfSmi(Register value, Label* smi_label, Register scratch = t3); ++ ++ void JumpIfEqual(Register a, int32_t b, Label* dest) { ++ Branch(dest, eq, a, Operand(b)); ++ } ++ ++ void JumpIfLessThan(Register a, int32_t b, Label* dest) { ++ Branch(dest, lt, a, Operand(b)); ++ } ++ ++ // Push a standard frame, consisting of ra, fp, context and JS function. ++ void PushStandardFrame(Register function_reg); ++ ++ // Get the actual activation frame alignment for target environment. ++ static int ActivationFrameAlignment(); ++ ++ // Calculated scaled address (rd) as rt + rs << sa ++ void CalcScaledAddress(Register rd, Register rs, Register rt, uint8_t sa, ++ Register scratch = t3); ++ ++ // Compute the start of the generated instruction stream from the current PC. ++ // This is an alternative to embedding the {CodeObject} handle as a reference. ++ void ComputeCodeStartAddress(Register dst); ++ ++ void ResetSpeculationPoisonRegister(); ++ ++ // Control-flow integrity: ++ ++ // Define a function entrypoint. This doesn't emit any code for this ++ // architecture, as control-flow integrity is not supported for it. ++ void CodeEntry() {} ++ // Define an exception handler. ++ void ExceptionHandler() {} ++ // Define an exception handler and bind a label. ++ void BindExceptionHandler(Label* label) { bind(label); } ++ ++ protected: ++ inline Register GetRtAsRegisterHelper(const Operand& rt, Register scratch); ++ inline int32_t GetOffset(int32_t offset, Label* L, OffsetSize bits); ++ ++ private: ++ bool has_double_zero_reg_set_ = false; ++ bool has_single_zero_reg_set_ = false; ++ ++ // Performs a truncating conversion of a floating point number as used by ++ // the JS bitwise operations. See ECMA-262 9.5: ToInt32. Goes to 'done' if it ++ // succeeds, otherwise falls through if result is saturated. On return ++ // 'result' either holds answer, or is clobbered on fall through. ++ void TryInlineTruncateDoubleToI(Register result, DoubleRegister input, ++ Label* done); ++ ++ void CallCFunctionHelper(Register function, int num_reg_arguments, ++ int num_double_arguments); ++ ++ // TODO(RISCV) Reorder parameters so out parameters come last. ++ bool CalculateOffset(Label* L, int32_t* offset, OffsetSize bits); ++ bool CalculateOffset(Label* L, int32_t* offset, OffsetSize bits, ++ Register* scratch, const Operand& rt); ++ ++ void BranchShortHelper(int32_t offset, Label* L); ++ bool BranchShortHelper(int32_t offset, Label* L, Condition cond, Register rs, ++ const Operand& rt); ++ bool BranchShortCheck(int32_t offset, Label* L, Condition cond, Register rs, ++ const Operand& rt); ++ ++ void BranchAndLinkShortHelper(int32_t offset, Label* L); ++ void BranchAndLinkShort(int32_t offset); ++ void BranchAndLinkShort(Label* L); ++ bool BranchAndLinkShortHelper(int32_t offset, Label* L, Condition cond, ++ Register rs, const Operand& rt); ++ bool BranchAndLinkShortCheck(int32_t offset, Label* L, Condition cond, ++ Register rs, const Operand& rt); ++ void BranchLong(Label* L); ++ void BranchAndLinkLong(Label* L); ++ ++ template ++ void RoundHelper(FPURegister dst, FPURegister src, FPURegister fpu_scratch, ++ RoundingMode mode); ++ ++ template ++ void RoundFloatingPointToInteger(Register rd, FPURegister fs, Register result, ++ TruncFunc trunc); ++ ++ // Push a fixed frame, consisting of ra, fp. ++ void PushCommonFrame(Register marker_reg = no_reg); ++ ++ void CallRecordWriteStub(Register object, Register address, ++ RememberedSetAction remembered_set_action, ++ SaveFPRegsMode fp_mode, Handle code_target, ++ Address wasm_target); ++}; ++ ++// MacroAssembler implements a collection of frequently used macros. ++class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { ++ public: ++ using TurboAssembler::TurboAssembler; ++ ++ bool IsNear(Label* L, Condition cond, int rs_reg); ++ ++ // Swap two registers. If the scratch register is omitted then a slightly ++ // less efficient form using xor instead of mov is emitted. ++ void Swap(Register reg1, Register reg2, Register scratch = no_reg); ++ ++ void PushRoot(RootIndex index) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Push(scratch); ++ } ++ ++ // Compare the object in a register to a value and jump if they are equal. ++ void JumpIfRoot(Register with, RootIndex index, Label* if_equal) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(if_equal, eq, with, Operand(scratch)); ++ } ++ ++ // Compare the object in a register to a value and jump if they are not equal. ++ void JumpIfNotRoot(Register with, RootIndex index, Label* if_not_equal) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ LoadRoot(scratch, index); ++ Branch(if_not_equal, ne, with, Operand(scratch)); ++ } ++ ++ // Checks if value is in range [lower_limit, higher_limit] using a single ++ // comparison. ++ void JumpIfIsInRange(Register value, unsigned lower_limit, ++ unsigned higher_limit, Label* on_in_range); ++ ++ // --------------------------------------------------------------------------- ++ // GC Support ++ ++ // Notify the garbage collector that we wrote a pointer into an object. ++ // |object| is the object being stored into, |value| is the object being ++ // stored. value and scratch registers are clobbered by the operation. ++ // The offset is the offset from the start of the object, not the offset from ++ // the tagged HeapObject pointer. For use with FieldOperand(reg, off). ++ void RecordWriteField( ++ Register object, int offset, Register value, Register scratch, ++ RAStatus ra_status, SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, ++ SmiCheck smi_check = INLINE_SMI_CHECK); ++ ++ // For a given |object| notify the garbage collector that the slot |address| ++ // has been written. |value| is the object being stored. The value and ++ // address registers are clobbered by the operation. ++ void RecordWrite( ++ Register object, Register address, Register value, RAStatus ra_status, ++ SaveFPRegsMode save_fp, ++ RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET, ++ SmiCheck smi_check = INLINE_SMI_CHECK); ++ ++ // void Pref(int32_t hint, const MemOperand& rs); ++ ++ // --------------------------------------------------------------------------- ++ // Pseudo-instructions. ++ ++ void LoadWordPair(Register rd, const MemOperand& rs, Register scratch = t3); ++ void StoreWordPair(Register rd, const MemOperand& rs, Register scratch = t3); ++ ++ void Madd_s(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); ++ void Madd_d(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); ++ void Msub_s(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); ++ void Msub_d(FPURegister fd, FPURegister fr, FPURegister fs, FPURegister ft); ++ ++ // Enter exit frame. ++ // argc - argument count to be dropped by LeaveExitFrame. ++ // save_doubles - saves FPU registers on stack, currently disabled. ++ // stack_space - extra stack space. ++ void EnterExitFrame(bool save_doubles, int stack_space = 0, ++ StackFrame::Type frame_type = StackFrame::EXIT); ++ ++ // Leave the current exit frame. ++ void LeaveExitFrame(bool save_doubles, Register arg_count, ++ bool do_return = NO_EMIT_RETURN, ++ bool argument_count_is_length = false); ++ ++ void LoadMap(Register destination, Register object); ++ ++ // Make sure the stack is aligned. Only emits code in debug mode. ++ void AssertStackIsAligned(); ++ ++ // Load the global proxy from the current context. ++ void LoadGlobalProxy(Register dst) { ++ LoadNativeContextSlot(Context::GLOBAL_PROXY_INDEX, dst); ++ } ++ ++ void LoadNativeContextSlot(int index, Register dst); ++ ++ // Load the initial map from the global function. The registers ++ // function and map can be the same, function is then overwritten. ++ void LoadGlobalFunctionInitialMap(Register function, Register map, ++ Register scratch); ++ ++ // ------------------------------------------------------------------------- ++ // JavaScript invokes. ++ ++ // Invoke the JavaScript function code by either calling or jumping. ++ void InvokeFunctionCode(Register function, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count, InvokeFlag flag); ++ ++ // On function call, call into the debugger if necessary. ++ void CheckDebugHook(Register fun, Register new_target, ++ Register expected_parameter_count, ++ Register actual_parameter_count); ++ ++ // Invoke the JavaScript function in the given register. Changes the ++ // current context to the context in the function before invoking. ++ void InvokeFunctionWithNewTarget(Register function, Register new_target, ++ Register actual_parameter_count, ++ InvokeFlag flag); ++ void InvokeFunction(Register function, Register expected_parameter_count, ++ Register actual_parameter_count, InvokeFlag flag); ++ ++ // Frame restart support. ++ void MaybeDropFrames(); ++ ++ // Exception handling. ++ ++ // Push a new stack handler and link into stack handler chain. ++ void PushStackHandler(); ++ ++ // Unlink the stack handler on top of the stack from the stack handler chain. ++ // Must preserve the result register. ++ void PopStackHandler(); ++ ++ // ------------------------------------------------------------------------- ++ // Support functions. ++ ++ void GetObjectType(Register function, Register map, Register type_reg); ++ ++ // ------------------------------------------------------------------------- ++ // Runtime calls. ++ ++ // Call a runtime routine. ++ void CallRuntime(const Runtime::Function* f, int num_arguments, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs); ++ ++ // Convenience function: Same as above, but takes the fid instead. ++ void CallRuntime(Runtime::FunctionId fid, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { ++ const Runtime::Function* function = Runtime::FunctionForId(fid); ++ CallRuntime(function, function->nargs, save_doubles); ++ } ++ ++ // Convenience function: Same as above, but takes the fid instead. ++ void CallRuntime(Runtime::FunctionId fid, int num_arguments, ++ SaveFPRegsMode save_doubles = kDontSaveFPRegs) { ++ CallRuntime(Runtime::FunctionForId(fid), num_arguments, save_doubles); ++ } ++ ++ // Convenience function: tail call a runtime routine (jump). ++ void TailCallRuntime(Runtime::FunctionId fid); ++ ++ // Jump to the builtin routine. ++ void JumpToExternalReference(const ExternalReference& builtin, ++ bool builtin_exit_frame = false); ++ ++ // Generates a trampoline to jump to the off-heap instruction stream. ++ void JumpToInstructionStream(Address entry); ++ ++ // --------------------------------------------------------------------------- ++ // In-place weak references. ++ void LoadWeakValue(Register out, Register in, Label* target_if_cleared); ++ ++ // ------------------------------------------------------------------------- ++ // StatsCounter support. ++ ++ void IncrementCounter(StatsCounter* counter, int value, Register scratch1, ++ Register scratch2); ++ void DecrementCounter(StatsCounter* counter, int value, Register scratch1, ++ Register scratch2); ++ ++ // ------------------------------------------------------------------------- ++ // Smi utilities. ++ ++ void SmiTag(Register dst, Register src) { ++ STATIC_ASSERT(kSmiTag == 0); ++ if (SmiValuesAre32Bits()) { ++ // FIXME(RISCV): do not understand the logic here ++ slli(dst, src, 32); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ Add32(dst, src, src); ++ } ++ } ++ ++ void SmiTag(Register reg) { SmiTag(reg, reg); } ++ ++ // Left-shifted from int32 equivalent of Smi. ++ void SmiScale(Register dst, Register src, int scale) { ++ if (SmiValuesAre32Bits()) { ++ // The int portion is upper 32-bits of 64-bit word. ++ srai(dst, src, (kSmiShift - scale) & 0x3F); ++ } else { ++ DCHECK(SmiValuesAre31Bits()); ++ DCHECK_GE(scale, kSmiTagSize); ++ slliw(dst, src, scale - kSmiTagSize); ++ } ++ } ++ ++ // Test if the register contains a smi. ++ inline void SmiTst(Register value, Register scratch) { ++ And(scratch, value, Operand(kSmiTagMask)); ++ } ++ ++ // Jump if the register contains a non-smi. ++ void JumpIfNotSmi(Register value, Label* not_smi_label, ++ Register scratch = t3); ++ ++ // Abort execution if argument is a smi, enabled via --debug-code. ++ void AssertNotSmi(Register object); ++ void AssertSmi(Register object); ++ ++ // Abort execution if argument is not a Constructor, enabled via --debug-code. ++ void AssertConstructor(Register object); ++ ++ // Abort execution if argument is not a JSFunction, enabled via --debug-code. ++ void AssertFunction(Register object); ++ ++ // Abort execution if argument is not a JSBoundFunction, ++ // enabled via --debug-code. ++ void AssertBoundFunction(Register object); ++ ++ // Abort execution if argument is not a JSGeneratorObject (or subclass), ++ // enabled via --debug-code. ++ void AssertGeneratorObject(Register object); ++ ++ // Abort execution if argument is not undefined or an AllocationSite, enabled ++ // via --debug-code. ++ void AssertUndefinedOrAllocationSite(Register object, Register scratch); ++ ++ template ++ void DecodeField(Register dst, Register src) { ++ ExtractBits(dst, src, Field::kShift, Field::kSize); ++ } ++ ++ template ++ void DecodeField(Register reg) { ++ DecodeField(reg, reg); ++ } ++ ++ private: ++ // Helper functions for generating invokes. ++ void InvokePrologue(Register expected_parameter_count, ++ Register actual_parameter_count, Label* done, ++ InvokeFlag flag); ++ ++ // Compute memory operands for safepoint stack slots. ++ static int SafepointRegisterStackIndex(int reg_code); ++ ++ // Needs access to SafepointRegisterStackIndex for compiled frame ++ // traversal. ++ friend class StandardFrame; ++ ++ DISALLOW_IMPLICIT_CONSTRUCTORS(MacroAssembler); ++}; ++ ++template ++void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count, ++ Func GetLabelFunction) { ++ // Ensure that dd-ed labels following this instruction use 8 bytes aligned ++ // addresses. ++ BlockTrampolinePoolFor(static_cast(case_count) * 2 + ++ kSwitchTablePrologueSize); ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ ++ Align(8); ++ // Load the address from the jump table at index and jump to it ++ auipc(scratch, 0); // Load the current PC into scratch ++ slli(t5, index, kPointerSizeLog2); // t5 = offset of indexth entry ++ add(t5, t5, scratch); // t5 = (saved PC) + (offset of indexth entry) ++ ld(t5, t5, 6 * kInstrSize); // Add the size of these 6 instructions to the ++ // offset, then load ++ jr(t5); // Jump to the address loaded from the table ++ nop(); // For 16-byte alignment ++ for (size_t index = 0; index < case_count; ++index) { ++ dd(GetLabelFunction(index)); ++ } ++} ++ ++#define ACCESS_MASM(masm) masm-> ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_RISCV_MACRO_ASSEMBLER_RISCV_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/codegen/riscv64/register-riscv64.h +@@ -0,0 +1,345 @@ ++// Copyright 2018 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_CODEGEN_RISCV_REGISTER_RISCV_H_ ++#define V8_CODEGEN_RISCV_REGISTER_RISCV_H_ ++ ++#include "src/codegen/register.h" ++#include "src/codegen/reglist.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++ ++namespace v8 { ++namespace internal { ++ ++// clang-format off ++#define GENERAL_REGISTERS(V) \ ++ V(zero_reg) V(ra) V(sp) V(gp) V(tp) V(t0) V(t1) V(t2) \ ++ V(fp) V(s1) V(a0) V(a1) V(a2) V(a3) V(a4) V(a5) \ ++ V(a6) V(a7) V(s2) V(s3) V(s4) V(s5) V(s6) V(s7) V(s8) V(s9) \ ++ V(s10) V(s11) V(t3) V(t4) V(t5) V(t6) ++ ++#define ALLOCATABLE_GENERAL_REGISTERS(V) \ ++ V(a0) V(a1) V(a2) V(a3) \ ++ V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(s7) V(t4) ++ ++#define DOUBLE_REGISTERS(V) \ ++ V(ft0) V(ft1) V(ft2) V(ft3) V(ft4) V(ft5) V(ft6) V(ft7) \ ++ V(fs0) V(fs1) V(fa0) V(fa1) V(fa2) V(fa3) V(fa4) V(fa5) \ ++ V(fa6) V(fa7) V(fs2) V(fs3) V(fs4) V(fs5) V(fs6) V(fs7) \ ++ V(fs8) V(fs9) V(fs10) V(fs11) V(ft8) V(ft9) V(ft10) V(ft11) ++ ++#define FLOAT_REGISTERS DOUBLE_REGISTERS ++#define SIMD128_REGISTERS(V) \ ++ V(w0) V(w1) V(w2) V(w3) V(w4) V(w5) V(w6) V(w7) \ ++ V(w8) V(w9) V(w10) V(w11) V(w12) V(w13) V(w14) V(w15) \ ++ V(w16) V(w17) V(w18) V(w19) V(w20) V(w21) V(w22) V(w23) \ ++ V(w24) V(w25) V(w26) V(w27) V(w28) V(w29) V(w30) V(w31) ++ ++#define ALLOCATABLE_DOUBLE_REGISTERS(V) \ ++ V(ft0) V(ft1) V(ft2) V(ft3) \ ++ V(ft4) V(ft5) V(ft6) V(ft7) V(fa0) V(fa1) V(fa2) V(fa3) V(fa4) V(fa5) \ ++ V(fa6) V(fa7) ++ ++// clang-format on ++ ++// Note that the bit values must match those used in actual instruction ++// encoding. ++const int kNumRegs = 32; ++ ++const RegList kJSCallerSaved = 1 << 5 | // t0 ++ 1 << 6 | // t1 ++ 1 << 7 | // t2 ++ 1 << 10 | // a0 ++ 1 << 11 | // a1 ++ 1 << 12 | // a2 ++ 1 << 13 | // a3 ++ 1 << 14 | // a4 ++ 1 << 15 | // a5 ++ 1 << 16 | // a6 ++ 1 << 17 | // a7 ++ 1 << 29; // t4 ++ ++const int kNumJSCallerSaved = 12; ++ ++// Callee-saved registers preserved when switching from C to JavaScript. ++const RegList kCalleeSaved = 1 << 8 | // fp/s0 ++ 1 << 9 | // s1 ++ 1 << 18 | // s2 ++ 1 << 19 | // s3 ++ 1 << 20 | // s4 ++ 1 << 21 | // s5 ++ 1 << 22 | // s6 (roots in Javascript code) ++ 1 << 23 | // s7 (cp in Javascript code) ++ 1 << 24 | // s8 ++ 1 << 25 | // s9 ++ 1 << 26 | // s10 ++ 1 << 27; // s11 ++ ++const int kNumCalleeSaved = 12; ++ ++const RegList kCalleeSavedFPU = 1 << 8 | // fs0 ++ 1 << 9 | // fs1 ++ 1 << 18 | // fs2 ++ 1 << 19 | // fs3 ++ 1 << 20 | // fs4 ++ 1 << 21 | // fs5 ++ 1 << 22 | // fs6 ++ 1 << 23 | // fs7 ++ 1 << 24 | // fs8 ++ 1 << 25 | // fs9 ++ 1 << 26 | // fs10 ++ 1 << 27; // fs11 ++ ++const int kNumCalleeSavedFPU = 12; ++ ++const RegList kCallerSavedFPU = 1 << 0 | // ft0 ++ 1 << 1 | // ft1 ++ 1 << 2 | // ft2 ++ 1 << 3 | // ft3 ++ 1 << 4 | // ft4 ++ 1 << 5 | // ft5 ++ 1 << 6 | // ft6 ++ 1 << 7 | // ft7 ++ 1 << 10 | // fa0 ++ 1 << 11 | // fa1 ++ 1 << 12 | // fa2 ++ 1 << 13 | // fa3 ++ 1 << 14 | // fa4 ++ 1 << 15 | // fa5 ++ 1 << 16 | // fa6 ++ 1 << 17 | // fa7 ++ 1 << 28 | // ft8 ++ 1 << 29 | // ft9 ++ 1 << 30 | // ft10 ++ 1 << 31; // ft11 ++ ++// Number of registers for which space is reserved in safepoints. Must be a ++// multiple of 8. ++const int kNumSafepointRegisters = 32; ++ ++// Define the list of registers actually saved at safepoints. ++// Note that the number of saved registers may be smaller than the reserved ++// space, i.e. kNumSafepointSavedRegisters <= kNumSafepointRegisters. ++const RegList kSafepointSavedRegisters = kJSCallerSaved | kCalleeSaved; ++const int kNumSafepointSavedRegisters = kNumJSCallerSaved + kNumCalleeSaved; ++ ++const int kUndefIndex = -1; ++// Map with indexes on stack that corresponds to codes of saved registers. ++const int kSafepointRegisterStackIndexMap[kNumRegs] = {kUndefIndex, // zero_reg ++ kUndefIndex, // ra ++ kUndefIndex, // sp ++ kUndefIndex, // gp ++ kUndefIndex, // tp ++ 0, // t0 ++ 1, // t1 ++ 2, // t2 ++ 3, // s0/fp ++ 4, // s1 ++ 5, // a0 ++ 6, // a1 ++ 7, // a2 ++ 8, // a3 ++ 9, // a4 ++ 10, // a5 ++ 11, // a6 ++ 12, // a7 ++ 13, // s2 ++ 14, // s3 ++ 15, // s4 ++ 16, // s5 ++ 17, // s6 ++ 18, // s7 ++ 19, // s8 ++ 10, // s9 ++ 21, // s10 ++ 22, // s11 ++ kUndefIndex, // t3 ++ 23, // t4 ++ kUndefIndex, // t5 ++ kUndefIndex}; // t6 ++// CPU Registers. ++// ++// 1) We would prefer to use an enum, but enum values are assignment- ++// compatible with int, which has caused code-generation bugs. ++// ++// 2) We would prefer to use a class instead of a struct but we don't like ++// the register initialization to depend on the particular initialization ++// order (which appears to be different on OS X, Linux, and Windows for the ++// installed versions of C++ we tried). Using a struct permits C-style ++// "initialization". Also, the Register objects cannot be const as this ++// forces initialization stubs in MSVC, making us dependent on initialization ++// order. ++// ++// 3) By not using an enum, we are possibly preventing the compiler from ++// doing certain constant folds, which may significantly reduce the ++// code generated for some assembly instructions (because they boil down ++// to a few constants). If this is a problem, we could change the code ++// such that we use an enum in optimized mode, and the struct in debug ++// mode. This way we get the compile-time error checking in debug mode ++// and best performance in optimized code. ++ ++// ----------------------------------------------------------------------------- ++// Implementation of Register and FPURegister. ++ ++enum RegisterCode { ++#define REGISTER_CODE(R) kRegCode_##R, ++ GENERAL_REGISTERS(REGISTER_CODE) ++#undef REGISTER_CODE ++ kRegAfterLast ++}; ++ ++class Register : public RegisterBase { ++ public: ++#if defined(V8_TARGET_LITTLE_ENDIAN) ++ static constexpr int kMantissaOffset = 0; ++ static constexpr int kExponentOffset = 4; ++#elif defined(V8_TARGET_BIG_ENDIAN) ++ static constexpr int kMantissaOffset = 4; ++ static constexpr int kExponentOffset = 0; ++#else ++#error Unknown endianness ++#endif ++ ++ private: ++ friend class RegisterBase; ++ explicit constexpr Register(int code) : RegisterBase(code) {} ++}; ++ ++// s7: context register ++// s3: scratch register ++// s4: scratch register 2 ++#define DECLARE_REGISTER(R) \ ++ constexpr Register R = Register::from_code(kRegCode_##R); ++GENERAL_REGISTERS(DECLARE_REGISTER) ++#undef DECLARE_REGISTER ++ ++constexpr Register no_reg = Register::no_reg(); ++ ++int ToNumber(Register reg); ++ ++Register ToRegister(int num); ++ ++constexpr bool kPadArguments = false; ++constexpr bool kSimpleFPAliasing = true; ++constexpr bool kSimdMaskRegisters = false; ++ ++enum DoubleRegisterCode { ++#define REGISTER_CODE(R) kDoubleCode_##R, ++ DOUBLE_REGISTERS(REGISTER_CODE) ++#undef REGISTER_CODE ++ kDoubleAfterLast ++}; ++ ++// Coprocessor register. ++class FPURegister : public RegisterBase { ++ public: ++ // TODO(plind): Warning, inconsistent numbering here. kNumFPURegisters refers ++ // to number of 32-bit FPU regs, but kNumAllocatableRegisters refers to ++ // number of Double regs (64-bit regs, or FPU-reg-pairs). ++ ++ FPURegister low() const { ++ // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. ++ // Find low reg of a Double-reg pair, which is the reg itself. ++ return FPURegister::from_code(code()); ++ } ++ FPURegister high() const { ++ // TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1. ++ // Find high reg of a Doubel-reg pair, which is reg + 1. ++ return FPURegister::from_code(code() + 1); ++ } ++ ++ private: ++ friend class RegisterBase; ++ explicit constexpr FPURegister(int code) : RegisterBase(code) {} ++}; ++ ++enum MSARegisterCode { ++#define REGISTER_CODE(R) kMsaCode_##R, ++ SIMD128_REGISTERS(REGISTER_CODE) ++#undef REGISTER_CODE ++ kMsaAfterLast ++}; ++ ++// MIPS SIMD (MSA) register ++// FIXME (RISCV) ++class MSARegister : public RegisterBase { ++ friend class RegisterBase; ++ explicit constexpr MSARegister(int code) : RegisterBase(code) {} ++}; ++ ++// A few double registers are reserved: one as a scratch register and one to ++// hold 0.0. ++// fs9: 0.0 ++// fs11: scratch register. ++ ++// For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. ++using FloatRegister = FPURegister; ++ ++using DoubleRegister = FPURegister; ++ ++#define DECLARE_DOUBLE_REGISTER(R) \ ++ constexpr DoubleRegister R = DoubleRegister::from_code(kDoubleCode_##R); ++DOUBLE_REGISTERS(DECLARE_DOUBLE_REGISTER) ++#undef DECLARE_DOUBLE_REGISTER ++ ++constexpr DoubleRegister no_dreg = DoubleRegister::no_reg(); ++ ++// SIMD registers. ++using Simd128Register = MSARegister; ++ ++#define DECLARE_SIMD128_REGISTER(R) \ ++ constexpr Simd128Register R = Simd128Register::from_code(kMsaCode_##R); ++SIMD128_REGISTERS(DECLARE_SIMD128_REGISTER) ++#undef DECLARE_SIMD128_REGISTER ++ ++const Simd128Register no_msareg = Simd128Register::no_reg(); ++ ++// Register aliases. ++// cp is assumed to be a callee saved register. ++constexpr Register kRootRegister = s6; ++constexpr Register cp = s7; ++constexpr Register kScratchReg = s3; ++constexpr Register kScratchReg2 = s4; ++ ++constexpr DoubleRegister kScratchDoubleReg = fs11; ++ ++constexpr DoubleRegister kDoubleRegZero = fs9; ++ ++// Define {RegisterName} methods for the register types. ++DEFINE_REGISTER_NAMES(Register, GENERAL_REGISTERS) ++DEFINE_REGISTER_NAMES(FPURegister, DOUBLE_REGISTERS) ++DEFINE_REGISTER_NAMES(MSARegister, SIMD128_REGISTERS) ++ ++// Give alias names to registers for calling conventions. ++constexpr Register kReturnRegister0 = a0; ++constexpr Register kReturnRegister1 = a1; ++constexpr Register kReturnRegister2 = a2; ++constexpr Register kJSFunctionRegister = a1; ++constexpr Register kContextRegister = s7; ++constexpr Register kAllocateSizeRegister = a1; ++constexpr Register kSpeculationPoisonRegister = a7; ++constexpr Register kInterpreterAccumulatorRegister = a0; ++constexpr Register kInterpreterBytecodeOffsetRegister = t0; ++constexpr Register kInterpreterBytecodeArrayRegister = t1; ++constexpr Register kInterpreterDispatchTableRegister = t2; ++ ++constexpr Register kJavaScriptCallArgCountRegister = a0; ++constexpr Register kJavaScriptCallCodeStartRegister = a2; ++constexpr Register kJavaScriptCallTargetRegister = kJSFunctionRegister; ++constexpr Register kJavaScriptCallNewTargetRegister = a3; ++constexpr Register kJavaScriptCallExtraArg1Register = a2; ++ ++constexpr Register kOffHeapTrampolineRegister = t3; ++constexpr Register kRuntimeCallFunctionRegister = a1; ++constexpr Register kRuntimeCallArgCountRegister = a0; ++constexpr Register kRuntimeCallArgvRegister = a2; ++constexpr Register kWasmInstanceRegister = a0; ++constexpr Register kWasmCompileLazyFuncIndexRegister = t0; ++ ++constexpr DoubleRegister kFPReturnRegister0 = fa0; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_CODEGEN_RISCV_REGISTER_RISCV_H_ +--- a/src/3rdparty/chromium/v8/src/common/globals.h ++++ b/src/3rdparty/chromium/v8/src/common/globals.h +@@ -58,6 +58,12 @@ + #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) + #define USE_SIMULATOR 1 + #endif ++#if (V8_TARGET_ARCH_RISCV64 && !V8_HOST_ARCH_RISCV64) ++#define USE_SIMULATOR 1 ++#endif ++#if (V8_TARGET_ARCH_RISCV && !V8_HOST_ARCH_RISCV && !V8_HOST_ARCH_RISCV64) ++#define USE_SIMULATOR 1 ++#endif + #endif + + // Determine whether the architecture uses an embedded constant pool +--- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-codes.h +@@ -23,6 +23,10 @@ + #include "src/compiler/backend/ppc/instruction-codes-ppc.h" + #elif V8_TARGET_ARCH_S390 + #include "src/compiler/backend/s390/instruction-codes-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/compiler/backend/riscv64/instruction-codes-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/compiler/backend/riscv/instruction-codes-riscv.h" + #else + #define TARGET_ARCH_OPCODE_LIST(V) + #define TARGET_ADDRESSING_MODE_LIST(V) +--- a/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/instruction-selector.cc +@@ -2624,7 +2624,8 @@ + #endif // !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_MIPS + + #if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_MIPS64 && \ +- !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 ++ !V8_TARGET_ARCH_S390 && !V8_TARGET_ARCH_PPC64 && \ ++ !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV + void InstructionSelector::VisitWord64AtomicLoad(Node* node) { UNIMPLEMENTED(); } + + void InstructionSelector::VisitWord64AtomicStore(Node* node) { +@@ -2649,7 +2650,8 @@ + UNIMPLEMENTED(); + } + #endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_PPC64 +- // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 ++ // !V8_TARGET_ARCH_MIPS64 && !V8_TARGET_ARCH_S390 && ++ // !V8_TARGET_ARCH_RISCV64 && !V8_TARGET_ARCH_RISCV + + #if !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM + // This is only needed on 32-bit to split the 64-bit value into two operands. +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/code-generator-riscv64.cc +@@ -0,0 +1,2759 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/callable.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/optimized-compilation-info.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/compiler/backend/code-generator-impl.h" ++#include "src/compiler/backend/code-generator.h" ++#include "src/compiler/backend/gap-resolver.h" ++#include "src/compiler/node-matchers.h" ++#include "src/compiler/osr.h" ++#include "src/heap/memory-chunk.h" ++#include "src/wasm/wasm-code-manager.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++#define __ tasm()-> ++ ++// TODO(plind): consider renaming these macros. ++#define TRACE_MSG(msg) \ ++ PrintF("code_gen: \'%s\' in function %s at line %d\n", msg, __FUNCTION__, \ ++ __LINE__) ++ ++#define TRACE_UNIMPL() \ ++ PrintF("UNIMPLEMENTED code_generator_riscv64: %s at line %d\n", \ ++ __FUNCTION__, __LINE__) ++ ++// Adds RISC-V-specific methods to convert InstructionOperands. ++class RiscvOperandConverter final : public InstructionOperandConverter { ++ public: ++ RiscvOperandConverter(CodeGenerator* gen, Instruction* instr) ++ : InstructionOperandConverter(gen, instr) {} ++ ++ FloatRegister OutputSingleRegister(size_t index = 0) { ++ return ToSingleRegister(instr_->OutputAt(index)); ++ } ++ ++ FloatRegister InputSingleRegister(size_t index) { ++ return ToSingleRegister(instr_->InputAt(index)); ++ } ++ ++ FloatRegister ToSingleRegister(InstructionOperand* op) { ++ // Single (Float) and Double register namespace is same on RISC-V, ++ // both are typedefs of FPURegister. ++ return ToDoubleRegister(op); ++ } ++ ++ Register InputOrZeroRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) { ++ DCHECK_EQ(0, InputInt32(index)); ++ return zero_reg; ++ } ++ return InputRegister(index); ++ } ++ ++ DoubleRegister InputOrZeroDoubleRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; ++ ++ return InputDoubleRegister(index); ++ } ++ ++ DoubleRegister InputOrZeroSingleRegister(size_t index) { ++ if (instr_->InputAt(index)->IsImmediate()) return kDoubleRegZero; ++ ++ return InputSingleRegister(index); ++ } ++ ++ Operand InputImmediate(size_t index) { ++ Constant constant = ToConstant(instr_->InputAt(index)); ++ switch (constant.type()) { ++ case Constant::kInt32: ++ return Operand(constant.ToInt32()); ++ case Constant::kInt64: ++ return Operand(constant.ToInt64()); ++ case Constant::kFloat32: ++ return Operand::EmbeddedNumber(constant.ToFloat32()); ++ case Constant::kFloat64: ++ return Operand::EmbeddedNumber(constant.ToFloat64().value()); ++ case Constant::kExternalReference: ++ case Constant::kCompressedHeapObject: ++ case Constant::kHeapObject: ++ // TODO(plind): Maybe we should handle ExtRef & HeapObj here? ++ // maybe not done on arm due to const pool ?? ++ break; ++ case Constant::kDelayedStringConstant: ++ return Operand::EmbeddedStringConstant( ++ constant.ToDelayedStringConstant()); ++ case Constant::kRpoNumber: ++ UNREACHABLE(); // TODO(titzer): RPO immediates ++ break; ++ } ++ UNREACHABLE(); ++ } ++ ++ Operand InputOperand(size_t index) { ++ InstructionOperand* op = instr_->InputAt(index); ++ if (op->IsRegister()) { ++ return Operand(ToRegister(op)); ++ } ++ return InputImmediate(index); ++ } ++ ++ MemOperand MemoryOperand(size_t* first_index) { ++ const size_t index = *first_index; ++ switch (AddressingModeField::decode(instr_->opcode())) { ++ case kMode_None: ++ break; ++ case kMode_MRI: ++ *first_index += 2; ++ return MemOperand(InputRegister(index + 0), InputInt32(index + 1)); ++ case kMode_MRR: ++ // TODO(plind): r6 address mode, to be implemented ... ++ UNREACHABLE(); ++ } ++ UNREACHABLE(); ++ } ++ ++ MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } ++ ++ MemOperand ToMemOperand(InstructionOperand* op) const { ++ DCHECK_NOT_NULL(op); ++ DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); ++ return SlotToMemOperand(AllocatedOperand::cast(op)->index()); ++ } ++ ++ MemOperand SlotToMemOperand(int slot) const { ++ FrameOffset offset = frame_access_state()->GetFrameOffset(slot); ++ return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); ++ } ++}; ++ ++static inline bool HasRegisterInput(Instruction* instr, size_t index) { ++ return instr->InputAt(index)->IsRegister(); ++} ++ ++namespace { ++ ++class OutOfLineRecordWrite final : public OutOfLineCode { ++ public: ++ OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, ++ Register value, Register scratch0, Register scratch1, ++ RecordWriteMode mode, StubCallMode stub_mode) ++ : OutOfLineCode(gen), ++ object_(object), ++ index_(index), ++ value_(value), ++ scratch0_(scratch0), ++ scratch1_(scratch1), ++ mode_(mode), ++ stub_mode_(stub_mode), ++ must_save_lr_(!gen->frame_access_state()->has_frame()), ++ zone_(gen->zone()) {} ++ ++ void Generate() final { ++ if (mode_ > RecordWriteMode::kValueIsPointer) { ++ __ JumpIfSmi(value_, exit()); ++ } ++ __ CheckPageFlag(value_, scratch0_, ++ MemoryChunk::kPointersToHereAreInterestingMask, eq, ++ exit()); ++ __ Add64(scratch1_, object_, index_); ++ RememberedSetAction const remembered_set_action = ++ mode_ > RecordWriteMode::kValueIsMap ? EMIT_REMEMBERED_SET ++ : OMIT_REMEMBERED_SET; ++ SaveFPRegsMode const save_fp_mode = ++ frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; ++ if (must_save_lr_) { ++ // We need to save and restore ra if the frame was elided. ++ __ Push(ra); ++ } ++ if (mode_ == RecordWriteMode::kValueIsEphemeronKey) { ++ __ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode); ++ } else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) { ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched when the code ++ // is added to the native module and copied into wasm code space. ++ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, ++ save_fp_mode, wasm::WasmCode::kRecordWrite); ++ } else { ++ __ CallRecordWriteStub(object_, scratch1_, remembered_set_action, ++ save_fp_mode); ++ } ++ if (must_save_lr_) { ++ __ Pop(ra); ++ } ++ } ++ ++ private: ++ Register const object_; ++ Register const index_; ++ Register const value_; ++ Register const scratch0_; ++ Register const scratch1_; ++ RecordWriteMode const mode_; ++ StubCallMode const stub_mode_; ++ bool must_save_lr_; ++ Zone* zone_; ++}; ++ ++Condition FlagsConditionToConditionCmp(FlagsCondition condition) { ++ switch (condition) { ++ case kEqual: ++ return eq; ++ case kNotEqual: ++ return ne; ++ case kSignedLessThan: ++ return lt; ++ case kSignedGreaterThanOrEqual: ++ return ge; ++ case kSignedLessThanOrEqual: ++ return le; ++ case kSignedGreaterThan: ++ return gt; ++ case kUnsignedLessThan: ++ return Uless; ++ case kUnsignedGreaterThanOrEqual: ++ return Ugreater_equal; ++ case kUnsignedLessThanOrEqual: ++ return Uless_equal; ++ case kUnsignedGreaterThan: ++ return Ugreater; ++ case kUnorderedEqual: ++ case kUnorderedNotEqual: ++ break; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++Condition FlagsConditionToConditionTst(FlagsCondition condition) { ++ switch (condition) { ++ case kNotEqual: ++ return ne; ++ case kEqual: ++ return eq; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++Condition FlagsConditionToConditionOvf(FlagsCondition condition) { ++ switch (condition) { ++ case kOverflow: ++ return ne; ++ case kNotOverflow: ++ return eq; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++FPUCondition FlagsConditionToConditionCmpFPU(bool* predicate, ++ FlagsCondition condition) { ++ switch (condition) { ++ case kEqual: ++ *predicate = true; ++ return EQ; ++ case kNotEqual: ++ *predicate = false; ++ return EQ; ++ case kUnsignedLessThan: ++ *predicate = true; ++ return LT; ++ case kUnsignedGreaterThanOrEqual: ++ *predicate = false; ++ return LT; ++ case kUnsignedLessThanOrEqual: ++ *predicate = true; ++ return LE; ++ case kUnsignedGreaterThan: ++ *predicate = false; ++ return LE; ++ case kUnorderedEqual: ++ case kUnorderedNotEqual: ++ *predicate = true; ++ break; ++ default: ++ *predicate = true; ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, ++ InstructionCode opcode, Instruction* instr, ++ RiscvOperandConverter const& i) { ++ const MemoryAccessMode access_mode = ++ static_cast(MiscField::decode(opcode)); ++ if (access_mode == kMemoryAccessPoisoned) { ++ Register value = i.OutputRegister(); ++ codegen->tasm()->And(value, value, kSpeculationPoisonRegister); ++ } ++} ++ ++} // namespace ++ ++#define ASSEMBLE_ATOMIC_LOAD_INTEGER(asm_instr) \ ++ do { \ ++ __ asm_instr(i.OutputRegister(), i.MemoryOperand()); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_STORE_INTEGER(asm_instr) \ ++ do { \ ++ __ sync(); \ ++ __ asm_instr(i.InputOrZeroRegister(2), i.MemoryOperand()); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_BINOP(load_linked, store_conditional, bin_instr) \ ++ do { \ ++ Label binop; \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ __ sync(); \ ++ __ bind(&binop); \ ++ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ ++ __ bin_instr(i.TempRegister(1), i.OutputRegister(0), \ ++ Operand(i.InputRegister(2))); \ ++ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&binop, ne, i.TempRegister(1), Operand(zero_reg)); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_BINOP_EXT(load_linked, store_conditional, sign_extend, \ ++ size, bin_instr, representation) \ ++ do { \ ++ Label binop; \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ And(i.TempRegister(3), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ And(i.TempRegister(3), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(3))); \ ++ __ Sll32(i.TempRegister(3), i.TempRegister(3), 3); \ ++ __ sync(); \ ++ __ bind(&binop); \ ++ __ load_linked(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(1), i.TempRegister(3), \ ++ size, sign_extend); \ ++ __ bin_instr(i.TempRegister(2), i.OutputRegister(0), \ ++ Operand(i.InputRegister(2))); \ ++ __ InsertBits(i.TempRegister(1), i.TempRegister(2), i.TempRegister(3), \ ++ size); \ ++ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&binop, ne, i.TempRegister(1), Operand(zero_reg)); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(load_linked, store_conditional) \ ++ do { \ ++ Label exchange; \ ++ __ sync(); \ ++ __ bind(&exchange); \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ ++ __ Move(i.TempRegister(1), i.InputRegister(2)); \ ++ __ store_conditional(i.TempRegister(1), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&exchange, ne, i.TempRegister(1), Operand(zero_reg)); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT( \ ++ load_linked, store_conditional, sign_extend, size, representation) \ ++ do { \ ++ Label exchange; \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ And(i.TempRegister(1), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ And(i.TempRegister(1), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(1))); \ ++ __ Sll32(i.TempRegister(1), i.TempRegister(1), 3); \ ++ __ sync(); \ ++ __ bind(&exchange); \ ++ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ InsertBits(i.TempRegister(2), i.InputRegister(2), i.TempRegister(1), \ ++ size); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&exchange, ne, i.TempRegister(2), Operand(zero_reg)); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(load_linked, \ ++ store_conditional) \ ++ do { \ ++ Label compareExchange; \ ++ Label exit; \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ __ sync(); \ ++ __ bind(&compareExchange); \ ++ __ load_linked(i.OutputRegister(0), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&exit, ne, i.InputRegister(2), \ ++ Operand(i.OutputRegister(0))); \ ++ __ Move(i.TempRegister(2), i.InputRegister(3)); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&compareExchange, ne, i.TempRegister(2), \ ++ Operand(zero_reg)); \ ++ __ bind(&exit); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT( \ ++ load_linked, store_conditional, sign_extend, size, representation) \ ++ do { \ ++ Label compareExchange; \ ++ Label exit; \ ++ __ Add64(i.TempRegister(0), i.InputRegister(0), i.InputRegister(1)); \ ++ if (representation == 32) { \ ++ __ And(i.TempRegister(1), i.TempRegister(0), 0x3); \ ++ } else { \ ++ DCHECK_EQ(representation, 64); \ ++ __ And(i.TempRegister(1), i.TempRegister(0), 0x7); \ ++ } \ ++ __ Sub64(i.TempRegister(0), i.TempRegister(0), \ ++ Operand(i.TempRegister(1))); \ ++ __ Sll32(i.TempRegister(1), i.TempRegister(1), 3); \ ++ __ sync(); \ ++ __ bind(&compareExchange); \ ++ __ load_linked(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ ExtractBits(i.OutputRegister(0), i.TempRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ ExtractBits(i.InputRegister(2), i.InputRegister(2), i.TempRegister(1), \ ++ size, sign_extend); \ ++ __ BranchShort(&exit, ne, i.InputRegister(2), \ ++ Operand(i.OutputRegister(0))); \ ++ __ InsertBits(i.TempRegister(2), i.InputRegister(3), i.TempRegister(1), \ ++ size); \ ++ __ store_conditional(i.TempRegister(2), MemOperand(i.TempRegister(0), 0)); \ ++ __ BranchShort(&compareExchange, ne, i.TempRegister(2), \ ++ Operand(zero_reg)); \ ++ __ bind(&exit); \ ++ __ sync(); \ ++ } while (0) ++ ++#define ASSEMBLE_IEEE754_BINOP(name) \ ++ do { \ ++ FrameScope scope(tasm(), StackFrame::MANUAL); \ ++ __ PrepareCallCFunction(0, 2, kScratchReg); \ ++ __ MovToFloatParameters(i.InputDoubleRegister(0), \ ++ i.InputDoubleRegister(1)); \ ++ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 2); \ ++ /* Move the result in the double result register. */ \ ++ __ MovFromFloatResult(i.OutputDoubleRegister()); \ ++ } while (0) ++ ++#define ASSEMBLE_IEEE754_UNOP(name) \ ++ do { \ ++ FrameScope scope(tasm(), StackFrame::MANUAL); \ ++ __ PrepareCallCFunction(0, 1, kScratchReg); \ ++ __ MovToFloatParameter(i.InputDoubleRegister(0)); \ ++ __ CallCFunction(ExternalReference::ieee754_##name##_function(), 0, 1); \ ++ /* Move the result in the double result register. */ \ ++ __ MovFromFloatResult(i.OutputDoubleRegister()); \ ++ } while (0) ++ ++#define ASSEMBLE_F64X2_ARITHMETIC_BINOP(op) \ ++ do { \ ++ __ op(i.OutputSimd128Register(), i.InputSimd128Register(0), \ ++ i.InputSimd128Register(1)); \ ++ } while (0) ++ ++void CodeGenerator::AssembleDeconstructFrame() { ++ __ Move(sp, fp); ++ __ Pop(ra, fp); ++} ++ ++void CodeGenerator::AssemblePrepareTailCall() { ++ if (frame_access_state()->has_frame()) { ++ __ Ld(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); ++ __ Ld(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); ++ } ++ frame_access_state()->SetFrameAccessToSP(); ++} ++ ++void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, ++ Register scratch1, ++ Register scratch2, ++ Register scratch3) { ++ DCHECK(!AreAliased(args_reg, scratch1, scratch2, scratch3)); ++ Label done; ++ ++ // Check if current frame is an arguments adaptor frame. ++ __ Ld(scratch3, MemOperand(fp, StandardFrameConstants::kContextOffset)); ++ __ Branch(&done, ne, scratch3, ++ Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); ++ ++ // Load arguments count from current arguments adaptor frame (note, it ++ // does not include receiver). ++ Register caller_args_count_reg = scratch1; ++ __ Ld(caller_args_count_reg, ++ MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); ++ __ SmiUntag(caller_args_count_reg); ++ ++ __ PrepareForTailCall(args_reg, caller_args_count_reg, scratch2, scratch3); ++ __ bind(&done); ++} ++ ++namespace { ++ ++void AdjustStackPointerForTailCall(TurboAssembler* tasm, ++ FrameAccessState* state, ++ int new_slot_above_sp, ++ bool allow_shrinkage = true) { ++ int current_sp_offset = state->GetSPToFPSlotCount() + ++ StandardFrameConstants::kFixedSlotCountAboveFp; ++ int stack_slot_delta = new_slot_above_sp - current_sp_offset; ++ if (stack_slot_delta > 0) { ++ tasm->Sub64(sp, sp, stack_slot_delta * kSystemPointerSize); ++ state->IncreaseSPDelta(stack_slot_delta); ++ } else if (allow_shrinkage && stack_slot_delta < 0) { ++ tasm->Add64(sp, sp, -stack_slot_delta * kSystemPointerSize); ++ state->IncreaseSPDelta(stack_slot_delta); ++ } ++} ++ ++} // namespace ++ ++void CodeGenerator::AssembleTailCallBeforeGap(Instruction* instr, ++ int first_unused_stack_slot) { ++ AdjustStackPointerForTailCall(tasm(), frame_access_state(), ++ first_unused_stack_slot, false); ++} ++ ++void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr, ++ int first_unused_stack_slot) { ++ AdjustStackPointerForTailCall(tasm(), frame_access_state(), ++ first_unused_stack_slot); ++} ++ ++// Check that {kJavaScriptCallCodeStartRegister} is correct. ++void CodeGenerator::AssembleCodeStartRegisterCheck() { ++ __ ComputeCodeStartAddress(kScratchReg); ++ __ Assert(eq, AbortReason::kWrongFunctionCodeStart, ++ kJavaScriptCallCodeStartRegister, Operand(kScratchReg)); ++} ++ ++// Check if the code object is marked for deoptimization. If it is, then it ++// jumps to the CompileLazyDeoptimizedCode builtin. In order to do this we need ++// to: ++// 1. read from memory the word that contains that bit, which can be found in ++// the flags in the referenced {CodeDataContainer} object; ++// 2. test kMarkedForDeoptimizationBit in those flags; and ++// 3. if it is not zero then it jumps to the builtin. ++void CodeGenerator::BailoutIfDeoptimized() { ++ int offset = Code::kCodeDataContainerOffset - Code::kHeaderSize; ++ __ Ld(kScratchReg, MemOperand(kJavaScriptCallCodeStartRegister, offset)); ++ __ Lw(kScratchReg, ++ FieldMemOperand(kScratchReg, ++ CodeDataContainer::kKindSpecificFlagsOffset)); ++ __ And(kScratchReg, kScratchReg, ++ Operand(1 << Code::kMarkedForDeoptimizationBit)); ++ __ Jump(BUILTIN_CODE(isolate(), CompileLazyDeoptimizedCode), ++ RelocInfo::CODE_TARGET, ne, kScratchReg, Operand(zero_reg)); ++} ++ ++void CodeGenerator::GenerateSpeculationPoisonFromCodeStartRegister() { ++ // Calculate a mask which has all bits set in the normal case, but has all ++ // bits cleared if we are speculatively executing the wrong PC. ++ // difference = (current - expected) | (expected - current) ++ // poison = ~(difference >> (kBitsPerSystemPointer - 1)) ++ __ ComputeCodeStartAddress(kScratchReg); ++ __ Move(kSpeculationPoisonRegister, kScratchReg); ++ __ Sub32(kSpeculationPoisonRegister, kSpeculationPoisonRegister, ++ kJavaScriptCallCodeStartRegister); ++ __ Sub32(kJavaScriptCallCodeStartRegister, kJavaScriptCallCodeStartRegister, ++ kScratchReg); ++ __ or_(kSpeculationPoisonRegister, kSpeculationPoisonRegister, ++ kJavaScriptCallCodeStartRegister); ++ __ Sra64(kSpeculationPoisonRegister, kSpeculationPoisonRegister, ++ kBitsPerSystemPointer - 1); ++ __ Nor(kSpeculationPoisonRegister, kSpeculationPoisonRegister, ++ kSpeculationPoisonRegister); ++} ++ ++void CodeGenerator::AssembleRegisterArgumentPoisoning() { ++ __ And(kJSFunctionRegister, kJSFunctionRegister, kSpeculationPoisonRegister); ++ __ And(kContextRegister, kContextRegister, kSpeculationPoisonRegister); ++ __ And(sp, sp, kSpeculationPoisonRegister); ++} ++ ++// Assembles an instruction after register allocation, producing machine code. ++CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ++ Instruction* instr) { ++ RiscvOperandConverter i(this, instr); ++ InstructionCode opcode = instr->opcode(); ++ ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode); ++ switch (arch_opcode) { ++ case kArchCallCodeObject: { ++ if (instr->InputAt(0)->IsImmediate()) { ++ __ Call(i.InputCode(0), RelocInfo::CODE_TARGET); ++ } else { ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ Add64(reg, reg, Code::kHeaderSize - kHeapObjectTag); ++ __ Call(reg); ++ } ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchCallBuiltinPointer: { ++ DCHECK(!instr->InputAt(0)->IsImmediate()); ++ Register builtin_index = i.InputRegister(0); ++ __ CallBuiltinByIndex(builtin_index); ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchCallWasmFunction: { ++ // FIXME (RISCV): isnt this test deadcode? ++ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { ++ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, ++ i.TempRegister(0), i.TempRegister(1), ++ i.TempRegister(2)); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ Constant constant = i.ToConstant(instr->InputAt(0)); ++ Address wasm_code = static_cast

(constant.ToInt64()); ++ __ Call(wasm_code, constant.rmode()); ++ } else { ++ __ Add64(kScratchReg, i.InputRegister(0), 0); ++ __ Call(kScratchReg); ++ } ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchTailCallCodeObjectFromJSFunction: ++ case kArchTailCallCodeObject: { ++ if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) { ++ AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister, ++ i.TempRegister(0), i.TempRegister(1), ++ i.TempRegister(2)); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ __ Jump(i.InputCode(0), RelocInfo::CODE_TARGET); ++ } else { ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ Add64(reg, reg, Code::kHeaderSize - kHeapObjectTag); ++ __ Jump(reg); ++ } ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchTailCallWasm: { ++ if (instr->InputAt(0)->IsImmediate()) { ++ Constant constant = i.ToConstant(instr->InputAt(0)); ++ Address wasm_code = static_cast
(constant.ToInt64()); ++ __ Jump(wasm_code, constant.rmode()); ++ } else { ++ __ Add64(kScratchReg, i.InputRegister(0), 0); ++ __ Jump(kScratchReg); ++ } ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchTailCallAddress: { ++ CHECK(!instr->InputAt(0)->IsImmediate()); ++ Register reg = i.InputRegister(0); ++ DCHECK_IMPLIES( ++ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister), ++ reg == kJavaScriptCallCodeStartRegister); ++ __ Jump(reg); ++ frame_access_state()->ClearSPDelta(); ++ frame_access_state()->SetFrameAccessToDefault(); ++ break; ++ } ++ case kArchCallJSFunction: { ++ Register func = i.InputRegister(0); ++ if (FLAG_debug_code) { ++ // Check the function's context matches the context argument. ++ __ Ld(kScratchReg, FieldMemOperand(func, JSFunction::kContextOffset)); ++ __ Assert(eq, AbortReason::kWrongFunctionContext, cp, ++ Operand(kScratchReg)); ++ } ++ static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch"); ++ __ Ld(a2, FieldMemOperand(func, JSFunction::kCodeOffset)); ++ __ Add64(a2, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); ++ __ Call(a2); ++ RecordCallPosition(instr); ++ frame_access_state()->ClearSPDelta(); ++ break; ++ } ++ case kArchPrepareCallCFunction: { ++ int const num_parameters = MiscField::decode(instr->opcode()); ++ __ PrepareCallCFunction(num_parameters, kScratchReg); ++ // Frame alignment requires using FP-relative frame addressing. ++ frame_access_state()->SetFrameAccessToFP(); ++ break; ++ } ++ case kArchSaveCallerRegisters: { ++ fp_mode_ = ++ static_cast(MiscField::decode(instr->opcode())); ++ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); ++ // kReturnRegister0 should have been saved before entering the stub. ++ int bytes = __ PushCallerSaved(fp_mode_, kReturnRegister0); ++ DCHECK(IsAligned(bytes, kSystemPointerSize)); ++ DCHECK_EQ(0, frame_access_state()->sp_delta()); ++ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); ++ DCHECK(!caller_registers_saved_); ++ caller_registers_saved_ = true; ++ break; ++ } ++ case kArchRestoreCallerRegisters: { ++ DCHECK(fp_mode_ == ++ static_cast(MiscField::decode(instr->opcode()))); ++ DCHECK(fp_mode_ == kDontSaveFPRegs || fp_mode_ == kSaveFPRegs); ++ // Don't overwrite the returned value. ++ int bytes = __ PopCallerSaved(fp_mode_, kReturnRegister0); ++ frame_access_state()->IncreaseSPDelta(-(bytes / kSystemPointerSize)); ++ DCHECK_EQ(0, frame_access_state()->sp_delta()); ++ DCHECK(caller_registers_saved_); ++ caller_registers_saved_ = false; ++ break; ++ } ++ case kArchPrepareTailCall: ++ AssemblePrepareTailCall(); ++ break; ++ case kArchCallCFunction: { ++ int const num_parameters = MiscField::decode(instr->opcode()); ++ Label start_call; ++ bool isWasmCapiFunction = ++ linkage()->GetIncomingDescriptor()->IsWasmCapiFunction(); ++ // from start_call to return address. ++ // FIXME (RISC_V): is the same number of instructions generated from ++ // &start_call to after __CallCFunction()? This code seems quite brittle. ++ // Better to use label and PC-relative addressing to generate the return ++ // address ++ int offset = __ root_array_available() ? 64 : 72; ++#if V8_HOST_ARCH_RISCV64 ++ if (__ emit_debug_code()) { ++ offset += 16; ++ } ++#endif ++ if (isWasmCapiFunction) { ++ // Put the return address in a stack slot. ++ __ bind(&start_call); ++ __ auipc(kScratchReg, 0); ++ __ Add64(kScratchReg, kScratchReg, offset); ++ __ Sd(kScratchReg, ++ MemOperand(fp, WasmExitFrameConstants::kCallingPCOffset)); ++ } ++ if (instr->InputAt(0)->IsImmediate()) { ++ ExternalReference ref = i.InputExternalReference(0); ++ __ CallCFunction(ref, num_parameters); ++ } else { ++ Register func = i.InputRegister(0); ++ __ CallCFunction(func, num_parameters); ++ } ++ if (isWasmCapiFunction) { ++ CHECK_EQ(offset, __ SizeOfCodeGeneratedSince(&start_call)); ++ RecordSafepoint(instr->reference_map(), Safepoint::kNoLazyDeopt); ++ } ++ ++ frame_access_state()->SetFrameAccessToDefault(); ++ // Ideally, we should decrement SP delta to match the change of stack ++ // pointer in CallCFunction. However, for certain architectures (e.g. ++ // ARM), there may be more strict alignment requirement, causing old SP ++ // to be saved on the stack. In those cases, we can not calculate the SP ++ // delta statically. ++ frame_access_state()->ClearSPDelta(); ++ if (caller_registers_saved_) { ++ // Need to re-sync SP delta introduced in kArchSaveCallerRegisters. ++ // Here, we assume the sequence to be: ++ // kArchSaveCallerRegisters; ++ // kArchCallCFunction; ++ // kArchRestoreCallerRegisters; ++ int bytes = ++ __ RequiredStackSizeForCallerSaved(fp_mode_, kReturnRegister0); ++ frame_access_state()->IncreaseSPDelta(bytes / kSystemPointerSize); ++ } ++ break; ++ } ++ case kArchJmp: ++ AssembleArchJump(i.InputRpo(0)); ++ break; ++ case kArchBinarySearchSwitch: ++ AssembleArchBinarySearchSwitch(instr); ++ break; ++ case kArchTableSwitch: ++ AssembleArchTableSwitch(instr); ++ break; ++ case kArchAbortCSAAssert: ++ DCHECK(i.InputRegister(0) == a0); ++ { ++ // We don't actually want to generate a pile of code for this, so just ++ // claim there is a stack frame, without generating one. ++ FrameScope scope(tasm(), StackFrame::NONE); ++ __ Call( ++ isolate()->builtins()->builtin_handle(Builtins::kAbortCSAAssert), ++ RelocInfo::CODE_TARGET); ++ } ++ __ stop(); ++ break; ++ case kArchDebugBreak: ++ __ DebugBreak(); ++ break; ++ case kArchComment: ++ __ RecordComment(reinterpret_cast(i.InputInt64(0))); ++ break; ++ case kArchNop: ++ case kArchThrowTerminator: ++ // don't emit code for nops. ++ break; ++ case kArchDeoptimize: { ++ DeoptimizationExit* exit = ++ BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); ++ CodeGenResult result = AssembleDeoptimizerCall(exit); ++ if (result != kSuccess) return result; ++ break; ++ } ++ case kArchRet: ++ AssembleReturn(instr->InputAt(0)); ++ break; ++ case kArchStackPointerGreaterThan: ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kArchStackCheckOffset: ++ __ Move(i.OutputRegister(), Smi::FromInt(GetStackCheckOffset())); ++ break; ++ case kArchFramePointer: ++ __ Move(i.OutputRegister(), fp); ++ break; ++ case kArchParentFramePointer: ++ if (frame_access_state()->has_frame()) { ++ __ Ld(i.OutputRegister(), MemOperand(fp, 0)); ++ } else { ++ __ Move(i.OutputRegister(), fp); ++ } ++ break; ++ case kArchTruncateDoubleToI: ++ __ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(), ++ i.InputDoubleRegister(0), DetermineStubCallMode()); ++ break; ++ case kArchStoreWithWriteBarrier: { ++ RecordWriteMode mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ Register object = i.InputRegister(0); ++ Register index = i.InputRegister(1); ++ Register value = i.InputRegister(2); ++ Register scratch0 = i.TempRegister(0); ++ Register scratch1 = i.TempRegister(1); ++ auto ool = zone()->New(this, object, index, value, ++ scratch0, scratch1, mode, ++ DetermineStubCallMode()); ++ __ Add64(kScratchReg, object, index); ++ __ Sd(value, MemOperand(kScratchReg)); ++ __ CheckPageFlag(object, scratch0, ++ MemoryChunk::kPointersFromHereAreInterestingMask, ne, ++ ool->entry()); ++ __ bind(ool->exit()); ++ break; ++ } ++ case kArchStackSlot: { ++ FrameOffset offset = ++ frame_access_state()->GetFrameOffset(i.InputInt32(0)); ++ Register base_reg = offset.from_stack_pointer() ? sp : fp; ++ __ Add64(i.OutputRegister(), base_reg, Operand(offset.offset())); ++ int alignment = i.InputInt32(1); ++ DCHECK(alignment == 0 || alignment == 4 || alignment == 8 || ++ alignment == 16); ++ if (FLAG_debug_code && alignment > 0) { ++ // Verify that the output_register is properly aligned ++ __ And(kScratchReg, i.OutputRegister(), ++ Operand(kSystemPointerSize - 1)); ++ __ Assert(eq, AbortReason::kAllocationIsNotDoubleAligned, kScratchReg, ++ Operand(zero_reg)); ++ } ++ if (alignment == 2 * kSystemPointerSize) { ++ Label done; ++ __ Add64(kScratchReg, base_reg, Operand(offset.offset())); ++ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); ++ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); ++ __ Add64(i.OutputRegister(), i.OutputRegister(), kSystemPointerSize); ++ __ bind(&done); ++ } else if (alignment > 2 * kSystemPointerSize) { ++ Label done; ++ __ Add64(kScratchReg, base_reg, Operand(offset.offset())); ++ __ And(kScratchReg, kScratchReg, Operand(alignment - 1)); ++ __ BranchShort(&done, eq, kScratchReg, Operand(zero_reg)); ++ __ li(kScratchReg2, alignment); ++ __ Sub64(kScratchReg2, kScratchReg2, Operand(kScratchReg)); ++ __ Add64(i.OutputRegister(), i.OutputRegister(), kScratchReg2); ++ __ bind(&done); ++ } ++ ++ break; ++ } ++ case kArchWordPoisonOnSpeculation: ++ __ And(i.OutputRegister(), i.InputRegister(0), ++ kSpeculationPoisonRegister); ++ break; ++ case kIeee754Float64Acos: ++ ASSEMBLE_IEEE754_UNOP(acos); ++ break; ++ case kIeee754Float64Acosh: ++ ASSEMBLE_IEEE754_UNOP(acosh); ++ break; ++ case kIeee754Float64Asin: ++ ASSEMBLE_IEEE754_UNOP(asin); ++ break; ++ case kIeee754Float64Asinh: ++ ASSEMBLE_IEEE754_UNOP(asinh); ++ break; ++ case kIeee754Float64Atan: ++ ASSEMBLE_IEEE754_UNOP(atan); ++ break; ++ case kIeee754Float64Atanh: ++ ASSEMBLE_IEEE754_UNOP(atanh); ++ break; ++ case kIeee754Float64Atan2: ++ ASSEMBLE_IEEE754_BINOP(atan2); ++ break; ++ case kIeee754Float64Cos: ++ ASSEMBLE_IEEE754_UNOP(cos); ++ break; ++ case kIeee754Float64Cosh: ++ ASSEMBLE_IEEE754_UNOP(cosh); ++ break; ++ case kIeee754Float64Cbrt: ++ ASSEMBLE_IEEE754_UNOP(cbrt); ++ break; ++ case kIeee754Float64Exp: ++ ASSEMBLE_IEEE754_UNOP(exp); ++ break; ++ case kIeee754Float64Expm1: ++ ASSEMBLE_IEEE754_UNOP(expm1); ++ break; ++ case kIeee754Float64Log: ++ ASSEMBLE_IEEE754_UNOP(log); ++ break; ++ case kIeee754Float64Log1p: ++ ASSEMBLE_IEEE754_UNOP(log1p); ++ break; ++ case kIeee754Float64Log2: ++ ASSEMBLE_IEEE754_UNOP(log2); ++ break; ++ case kIeee754Float64Log10: ++ ASSEMBLE_IEEE754_UNOP(log10); ++ break; ++ case kIeee754Float64Pow: ++ ASSEMBLE_IEEE754_BINOP(pow); ++ break; ++ case kIeee754Float64Sin: ++ ASSEMBLE_IEEE754_UNOP(sin); ++ break; ++ case kIeee754Float64Sinh: ++ ASSEMBLE_IEEE754_UNOP(sinh); ++ break; ++ case kIeee754Float64Tan: ++ ASSEMBLE_IEEE754_UNOP(tan); ++ break; ++ case kIeee754Float64Tanh: ++ ASSEMBLE_IEEE754_UNOP(tanh); ++ break; ++ case kRiscvAdd32: ++ __ Add32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvAdd64: ++ __ Add64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvAddOvf64: ++ __ AddOverflow64(i.OutputRegister(), i.InputRegister(0), ++ i.InputOperand(1), kScratchReg); ++ break; ++ case kRiscvSub32: ++ __ Sub32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvSub64: ++ __ Sub64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvSubOvf64: ++ __ SubOverflow64(i.OutputRegister(), i.InputRegister(0), ++ i.InputOperand(1), kScratchReg); ++ break; ++ case kRiscvMul32: ++ __ Mul32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvMulOvf32: ++ __ MulOverflow32(i.OutputRegister(), i.InputRegister(0), ++ i.InputOperand(1), kScratchReg); ++ break; ++ case kRiscvMulHigh32: ++ __ Mulh32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvMulHighU32: ++ __ Mulhu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1), ++ kScratchReg, kScratchReg2); ++ break; ++ case kRiscvMulHigh64: ++ __ Mulh64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvDiv32: { ++ __ Div32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ // Set ouput to zero if divisor == 0 ++ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); ++ break; ++ } ++ case kRiscvDivU32: { ++ __ Divu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ // Set ouput to zero if divisor == 0 ++ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); ++ break; ++ } ++ case kRiscvMod32: ++ __ Mod32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvModU32: ++ __ Modu32(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvMul64: ++ __ Mul64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvDiv64: { ++ __ Div64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ // Set ouput to zero if divisor == 0 ++ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); ++ break; ++ } ++ case kRiscvDivU64: { ++ __ Divu64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ // Set ouput to zero if divisor == 0 ++ __ LoadZeroIfConditionZero(i.OutputRegister(), i.InputRegister(1)); ++ break; ++ } ++ case kRiscvMod64: ++ __ Mod64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvModU64: ++ __ Modu64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvAnd: ++ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvAnd32: ++ __ And(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kRiscvOr: ++ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvOr32: ++ __ Or(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kRiscvNor: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ } else { ++ DCHECK_EQ(0, i.InputOperand(1).immediate()); ++ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); ++ } ++ break; ++ case kRiscvNor32: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Nor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); ++ } else { ++ DCHECK_EQ(0, i.InputOperand(1).immediate()); ++ __ Nor(i.OutputRegister(), i.InputRegister(0), zero_reg); ++ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); ++ } ++ break; ++ case kRiscvXor: ++ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvXor32: ++ __ Xor(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ __ Sll32(i.OutputRegister(), i.OutputRegister(), 0x0); ++ break; ++ case kRiscvClz32: ++ __ Clz32(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvClz64: ++ __ Clz64(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvCtz32: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Ctz32(dst, src); ++ } break; ++ case kRiscvCtz64: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Ctz64(dst, src); ++ } break; ++ case kRiscvPopcnt32: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Popcnt32(dst, src); ++ } break; ++ case kRiscvPopcnt64: { ++ Register src = i.InputRegister(0); ++ Register dst = i.OutputRegister(); ++ __ Popcnt64(dst, src); ++ } break; ++ case kRiscvShl32: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Sll32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ Sll32(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kRiscvShr32: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Srl32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ Srl32(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kRiscvSar32: ++ if (instr->InputAt(1)->IsRegister()) { ++ __ Sra32(i.OutputRegister(), i.InputRegister(0), i.InputRegister(1)); ++ } else { ++ int64_t imm = i.InputOperand(1).immediate(); ++ __ Sra32(i.OutputRegister(), i.InputRegister(0), ++ static_cast(imm)); ++ } ++ break; ++ case kRiscvZeroExtendWord: { ++ __ ZeroExtendWord(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvSignExtendWord: { ++ __ SignExtendWord(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvShl64: ++ __ Sll64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvShr64: ++ __ Srl64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvSar64: ++ __ Sra64(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvRor32: ++ __ Ror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvRor64: ++ __ Dror(i.OutputRegister(), i.InputRegister(0), i.InputOperand(1)); ++ break; ++ case kRiscvTst: ++ __ And(kScratchReg, i.InputRegister(0), i.InputOperand(1)); ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kRiscvCmp: ++ // Pseudo-instruction used for cmp/branch. No opcode emitted here. ++ break; ++ case kRiscvMov: ++ // TODO(plind): Should we combine mov/li like this, or use separate instr? ++ // - Also see x64 ASSEMBLE_BINOP & RegisterOrOperandType ++ if (HasRegisterInput(instr, 0)) { ++ __ Move(i.OutputRegister(), i.InputRegister(0)); ++ } else { ++ __ li(i.OutputRegister(), i.InputOperand(0)); ++ } ++ break; ++ ++ case kRiscvCmpS: { ++ FPURegister left = i.InputOrZeroSingleRegister(0); ++ FPURegister right = i.InputOrZeroSingleRegister(1); ++ bool predicate; ++ FPUCondition cc = ++ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); ++ ++ if ((left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsSingleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); ++ } ++ // compare result set to kScratchReg ++ __ CompareF32(kScratchReg, cc, left, right); ++ } break; ++ case kRiscvAddS: ++ // TODO(plind): add special case: combine mult & add. ++ __ fadd_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvSubS: ++ __ fsub_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvMulS: ++ // TODO(plind): add special case: right op is -1.0, see arm port. ++ __ fmul_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvDivS: ++ __ fdiv_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvModS: { ++ // TODO(bmeurer): We should really get rid of this special instruction, ++ // and generate a CallAddress instruction instead. ++ FrameScope scope(tasm(), StackFrame::MANUAL); ++ __ PrepareCallCFunction(0, 2, kScratchReg); ++ __ MovToFloatParameters(i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ // TODO(balazs.kilvady): implement mod_two_floats_operation(isolate()) ++ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); ++ // Move the result in the double result register. ++ __ MovFromFloatResult(i.OutputSingleRegister()); ++ break; ++ } ++ case kRiscvAbsS: ++ __ fabs_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kRiscvNegS: ++ __ Neg_s(i.OutputSingleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kRiscvSqrtS: { ++ __ fsqrt_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kRiscvMaxS: ++ __ fmax_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvMinS: ++ __ fmin_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvCmpD: { ++ FPURegister left = i.InputOrZeroDoubleRegister(0); ++ FPURegister right = i.InputOrZeroDoubleRegister(1); ++ bool predicate; ++ FPUCondition cc = ++ FlagsConditionToConditionCmpFPU(&predicate, instr->flags_condition()); ++ if ((left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsDoubleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0); ++ } ++ // compare result set to kScratchReg ++ __ CompareF64(kScratchReg, cc, left, right); ++ } break; ++ case kRiscvAddD: ++ // TODO(plind): add special case: combine mult & add. ++ __ fadd_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvSubD: ++ __ fsub_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvMulD: ++ // TODO(plind): add special case: right op is -1.0, see arm port. ++ __ fmul_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvDivD: ++ __ fdiv_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvModD: { ++ // TODO(bmeurer): We should really get rid of this special instruction, ++ // and generate a CallAddress instruction instead. ++ FrameScope scope(tasm(), StackFrame::MANUAL); ++ __ PrepareCallCFunction(0, 2, kScratchReg); ++ __ MovToFloatParameters(i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ __ CallCFunction(ExternalReference::mod_two_doubles_operation(), 0, 2); ++ // Move the result in the double result register. ++ __ MovFromFloatResult(i.OutputDoubleRegister()); ++ break; ++ } ++ case kRiscvAbsD: ++ __ fabs_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvNegD: ++ __ Neg_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvSqrtD: { ++ __ fsqrt_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ } ++ case kRiscvMaxD: ++ __ fmax_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvMinD: ++ __ fmin_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ i.InputDoubleRegister(1)); ++ break; ++ case kRiscvFloat64RoundDown: { ++ __ Floor_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat32RoundDown: { ++ __ Floor_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat64RoundTruncate: { ++ __ Trunc_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat32RoundTruncate: { ++ __ Trunc_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat64RoundUp: { ++ __ Ceil_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat32RoundUp: { ++ __ Ceil_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat64RoundTiesEven: { ++ __ Round_d_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat32RoundTiesEven: { ++ __ Round_s_s(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ kScratchDoubleReg); ++ break; ++ } ++ case kRiscvFloat32Max: { ++ __ Float32Max(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ i.InputSingleRegister(1)); ++ break; ++ } ++ case kRiscvFloat64Max: { ++ __ Float64Max(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ i.InputSingleRegister(1)); ++ break; ++ } ++ case kRiscvFloat32Min: { ++ __ Float32Min(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ i.InputSingleRegister(1)); ++ break; ++ } ++ case kRiscvFloat64Min: { ++ __ Float64Min(i.OutputSingleRegister(), i.InputSingleRegister(0), ++ i.InputSingleRegister(1)); ++ break; ++ } ++ case kRiscvFloat64SilenceNaN: ++ __ FPUCanonicalizeNaN(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvCvtSD: ++ __ fcvt_s_d(i.OutputSingleRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvCvtDS: ++ __ fcvt_d_s(i.OutputDoubleRegister(), i.InputSingleRegister(0)); ++ break; ++ case kRiscvCvtDW: { ++ __ fcvt_d_w(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtSW: { ++ __ fcvt_s_w(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtSUw: { ++ __ Cvt_s_uw(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtSL: { ++ __ fcvt_s_l(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtDL: { ++ __ fcvt_d_l(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtDUw: { ++ __ Cvt_d_uw(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtDUl: { ++ __ Cvt_d_ul(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvCvtSUl: { ++ __ Cvt_s_ul(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ } ++ case kRiscvFloorWD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Floor_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvCeilWD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Ceil_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvRoundWD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Round_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncWD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_w_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvFloorWS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Floor_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvCeilWS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Ceil_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvRoundWS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Round_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncWS: { ++ Label done; ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_w_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ ++ // On RISCV, if the input value exceeds INT32_MAX, the result of fcvt ++ // is INT32_MAX. Note that, since INT32_MAX means the lower 31-bits are ++ // all 1s, INT32_MAX cannot be represented precisely as a float, so an ++ // fcvt result of INT32_MAX always indicate overflow. ++ // ++ // In wasm_compiler, to detect overflow in converting a FP value, fval, to ++ // integer, V8 checks whether I2F(F2I(fval)) equals fval. However, if fval ++ // == INT32_MAX+1, the value of I2F(F2I(fval)) happens to be fval. So, ++ // INT32_MAX is not a good value to indicate overflow. Instead, we will ++ // use INT32_MIN as the converted result of an out-of-range FP value, ++ // exploiting the fact that INT32_MAX+1 is INT32_MIN. ++ // ++ // If the result of conversion overflow, the result will be set to ++ // INT32_MIN. Here we detect overflow by testing whether output + 1 < ++ // output (i.e., kScratchReg < output) ++ __ Add32(kScratchReg, i.OutputRegister(), 1); ++ __ Branch(&done, lt, i.OutputRegister(), Operand(kScratchReg)); ++ __ Move(i.OutputRegister(), kScratchReg); ++ __ bind(&done); ++ break; ++ } ++ case kRiscvTruncLS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_l_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncLD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_l_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncUwD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_uw_d(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncUwS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_uw_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ ++ // On RISCV, if the input value exceeds UINT32_MAX, the result of fcvt ++ // is UINT32_MAX. Note that, since UINT32_MAX means all 32-bits are 1s, ++ // UINT32_MAX cannot be represented precisely as float, so an fcvt result ++ // of UINT32_MAX always indicates overflow. ++ // ++ // In wasm_compiler.cc, to detect overflow in converting a FP value, fval, ++ // to integer, V8 checks whether I2F(F2I(fval)) equals fval. However, if ++ // fval == UINT32_MAX+1, the value of I2F(F2I(fval)) happens to be fval. ++ // So, UINT32_MAX is not a good value to indicate overflow. Instead, we ++ // will use 0 as the converted result of an out-of-range FP value, ++ // exploiting the fact that UINT32_MAX+1 is 0. ++ __ Add32(kScratchReg, i.OutputRegister(), 1); ++ // Set ouput to zero if result overflows (i.e., UINT32_MAX) ++ __ LoadZeroIfConditionZero(i.OutputRegister(), kScratchReg); ++ break; ++ } ++ case kRiscvTruncUlS: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_ul_s(i.OutputRegister(), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvTruncUlD: { ++ Register result = instr->OutputCount() > 1 ? i.OutputRegister(1) : no_reg; ++ __ Trunc_ul_d(i.OutputRegister(0), i.InputDoubleRegister(0), result); ++ break; ++ } ++ case kRiscvBitcastDL: ++ __ fmv_x_d(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvBitcastLD: ++ __ fmv_d_x(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvBitcastInt32ToFloat32: ++ __ fmv_w_x(i.OutputDoubleRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvBitcastFloat32ToInt32: ++ __ fmv_x_w(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvFloat64ExtractLowWord32: ++ __ ExtractLowWordFromF64(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvFloat64ExtractHighWord32: ++ __ ExtractHighWordFromF64(i.OutputRegister(), i.InputDoubleRegister(0)); ++ break; ++ case kRiscvFloat64InsertLowWord32: ++ __ InsertLowWordF64(i.OutputDoubleRegister(), i.InputRegister(1)); ++ break; ++ case kRiscvFloat64InsertHighWord32: ++ __ InsertHighWordF64(i.OutputDoubleRegister(), i.InputRegister(1)); ++ break; ++ // ... more basic instructions ... ++ ++ case kRiscvSignExtendByte: ++ __ SignExtendByte(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvSignExtendShort: ++ __ SignExtendShort(i.OutputRegister(), i.InputRegister(0)); ++ break; ++ case kRiscvLbu: ++ __ Lbu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvLb: ++ __ Lb(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvSb: ++ __ Sb(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvLhu: ++ __ Lhu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvUlhu: ++ __ Ulhu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvLh: ++ __ Lh(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvUlh: ++ __ Ulh(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvSh: ++ __ Sh(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvUsh: ++ __ Ush(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvLw: ++ __ Lw(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvUlw: ++ __ Ulw(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvLwu: ++ __ Lwu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvUlwu: ++ __ Ulwu(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvLd: ++ __ Ld(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvUld: ++ __ Uld(i.OutputRegister(), i.MemoryOperand()); ++ EmitWordLoadPoisoningIfNeeded(this, opcode, instr, i); ++ break; ++ case kRiscvSw: ++ __ Sw(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvUsw: ++ __ Usw(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvSd: ++ __ Sd(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvUsd: ++ __ Usd(i.InputOrZeroRegister(2), i.MemoryOperand()); ++ break; ++ case kRiscvLoadFloat: { ++ __ LoadFloat(i.OutputSingleRegister(), i.MemoryOperand()); ++ break; ++ } ++ case kRiscvULoadFloat: { ++ __ ULoadFloat(i.OutputSingleRegister(), i.MemoryOperand(), kScratchReg); ++ break; ++ } ++ case kRiscvStoreFloat: { ++ size_t index = 0; ++ MemOperand operand = i.MemoryOperand(&index); ++ FPURegister ft = i.InputOrZeroSingleRegister(index); ++ if (ft == kDoubleRegZero && !__ IsSingleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); ++ } ++ __ StoreFloat(ft, operand); ++ break; ++ } ++ case kRiscvUStoreFloat: { ++ size_t index = 0; ++ MemOperand operand = i.MemoryOperand(&index); ++ FPURegister ft = i.InputOrZeroSingleRegister(index); ++ if (ft == kDoubleRegZero && !__ IsSingleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); ++ } ++ __ UStoreFloat(ft, operand, kScratchReg); ++ break; ++ } ++ case kRiscvLoadDouble: ++ __ LoadDouble(i.OutputDoubleRegister(), i.MemoryOperand()); ++ break; ++ case kRiscvULoadDouble: ++ __ ULoadDouble(i.OutputDoubleRegister(), i.MemoryOperand(), kScratchReg); ++ break; ++ case kRiscvStoreDouble: { ++ FPURegister ft = i.InputOrZeroDoubleRegister(2); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0); ++ } ++ __ StoreDouble(ft, i.MemoryOperand()); ++ break; ++ } ++ case kRiscvUStoreDouble: { ++ FPURegister ft = i.InputOrZeroDoubleRegister(2); ++ if (ft == kDoubleRegZero && !__ IsDoubleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0); ++ } ++ __ UStoreDouble(ft, i.MemoryOperand(), kScratchReg); ++ break; ++ } ++ case kRiscvSync: { ++ __ sync(); ++ break; ++ } ++ case kRiscvPush: ++ if (instr->InputAt(0)->IsFPRegister()) { ++ __ StoreDouble(i.InputDoubleRegister(0), MemOperand(sp, -kDoubleSize)); ++ __ Sub32(sp, sp, Operand(kDoubleSize)); ++ frame_access_state()->IncreaseSPDelta(kDoubleSize / kSystemPointerSize); ++ } else { ++ __ Push(i.InputRegister(0)); ++ frame_access_state()->IncreaseSPDelta(1); ++ } ++ break; ++ case kRiscvPeek: { ++ // The incoming value is 0-based, but we need a 1-based value. ++ int reverse_slot = i.InputInt32(0) + 1; ++ int offset = ++ FrameSlotToFPOffset(frame()->GetTotalFrameSlotCount() - reverse_slot); ++ if (instr->OutputAt(0)->IsFPRegister()) { ++ LocationOperand* op = LocationOperand::cast(instr->OutputAt(0)); ++ if (op->representation() == MachineRepresentation::kFloat64) { ++ __ LoadDouble(i.OutputDoubleRegister(), MemOperand(fp, offset)); ++ } else { ++ DCHECK_EQ(op->representation(), MachineRepresentation::kFloat32); ++ __ LoadFloat( ++ i.OutputSingleRegister(0), ++ MemOperand(fp, offset + kLessSignificantWordInDoublewordOffset)); ++ } ++ } else { ++ __ Ld(i.OutputRegister(0), MemOperand(fp, offset)); ++ } ++ break; ++ } ++ case kRiscvStackClaim: { ++ __ Sub64(sp, sp, Operand(i.InputInt32(0))); ++ frame_access_state()->IncreaseSPDelta(i.InputInt32(0) / ++ kSystemPointerSize); ++ break; ++ } ++ case kRiscvStoreToStackSlot: { ++ if (instr->InputAt(0)->IsFPRegister()) { ++ if (instr->InputAt(0)->IsSimd128Register()) { ++ UNREACHABLE(); ++ } else { ++ __ StoreDouble(i.InputDoubleRegister(0), ++ MemOperand(sp, i.InputInt32(1))); ++ } ++ } else { ++ __ Sd(i.InputRegister(0), MemOperand(sp, i.InputInt32(1))); ++ } ++ break; ++ } ++ case kRiscvByteSwap64: { ++ __ ByteSwap(i.OutputRegister(0), i.InputRegister(0), 8); ++ break; ++ } ++ case kRiscvByteSwap32: { ++ __ ByteSwap(i.OutputRegister(0), i.InputRegister(0), 4); ++ break; ++ } ++ case kWord32AtomicLoadInt8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lb); ++ break; ++ case kWord32AtomicLoadUint8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lbu); ++ break; ++ case kWord32AtomicLoadInt16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lh); ++ break; ++ case kWord32AtomicLoadUint16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lhu); ++ break; ++ case kWord32AtomicLoadWord32: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lw); ++ break; ++ case kRiscvWord64AtomicLoadUint8: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lbu); ++ break; ++ case kRiscvWord64AtomicLoadUint16: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lhu); ++ break; ++ case kRiscvWord64AtomicLoadUint32: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Lwu); ++ break; ++ case kRiscvWord64AtomicLoadUint64: ++ ASSEMBLE_ATOMIC_LOAD_INTEGER(Ld); ++ break; ++ case kWord32AtomicStoreWord8: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sb); ++ break; ++ case kWord32AtomicStoreWord16: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sh); ++ break; ++ case kWord32AtomicStoreWord32: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sw); ++ break; ++ case kRiscvWord64AtomicStoreWord8: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sb); ++ break; ++ case kRiscvWord64AtomicStoreWord16: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sh); ++ break; ++ case kRiscvWord64AtomicStoreWord32: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sw); ++ break; ++ case kRiscvWord64AtomicStoreWord64: ++ ASSEMBLE_ATOMIC_STORE_INTEGER(Sd); ++ break; ++ case kWord32AtomicExchangeInt8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 8, 32); ++ break; ++ case kWord32AtomicExchangeUint8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 8, 32); ++ break; ++ case kWord32AtomicExchangeInt16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 16, 32); ++ break; ++ case kWord32AtomicExchangeUint16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 16, 32); ++ break; ++ case kWord32AtomicExchangeWord32: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(Ll, Sc); ++ break; ++ case kRiscvWord64AtomicExchangeUint8: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 8, 64); ++ break; ++ case kRiscvWord64AtomicExchangeUint16: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 16, 64); ++ break; ++ case kRiscvWord64AtomicExchangeUint32: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 32, 64); ++ break; ++ case kRiscvWord64AtomicExchangeUint64: ++ ASSEMBLE_ATOMIC_EXCHANGE_INTEGER(Lld, Scd); ++ break; ++ case kWord32AtomicCompareExchangeInt8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 8, 32); ++ break; ++ case kWord32AtomicCompareExchangeUint8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 8, 32); ++ break; ++ case kWord32AtomicCompareExchangeInt16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, true, 16, 32); ++ break; ++ case kWord32AtomicCompareExchangeUint16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Ll, Sc, false, 16, 32); ++ break; ++ case kWord32AtomicCompareExchangeWord32: ++ __ Sll32(i.InputRegister(2), i.InputRegister(2), 0); ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Ll, Sc); ++ break; ++ case kRiscvWord64AtomicCompareExchangeUint8: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 8, 64); ++ break; ++ case kRiscvWord64AtomicCompareExchangeUint16: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 16, 64); ++ break; ++ case kRiscvWord64AtomicCompareExchangeUint32: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT(Lld, Scd, false, 32, 64); ++ break; ++ case kRiscvWord64AtomicCompareExchangeUint64: ++ ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER(Lld, Scd); ++ break; ++#define ATOMIC_BINOP_CASE(op, inst) \ ++ case kWord32Atomic##op##Int8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, true, 8, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Uint8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, false, 8, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Int16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, true, 16, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Uint16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Ll, Sc, false, 16, inst, 32); \ ++ break; \ ++ case kWord32Atomic##op##Word32: \ ++ ASSEMBLE_ATOMIC_BINOP(Ll, Sc, inst); \ ++ break; ++ ATOMIC_BINOP_CASE(Add, Add32) ++ ATOMIC_BINOP_CASE(Sub, Sub32) ++ ATOMIC_BINOP_CASE(And, And) ++ ATOMIC_BINOP_CASE(Or, Or) ++ ATOMIC_BINOP_CASE(Xor, Xor) ++#undef ATOMIC_BINOP_CASE ++#define ATOMIC_BINOP_CASE(op, inst) \ ++ case kRiscvWord64Atomic##op##Uint8: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 8, inst, 64); \ ++ break; \ ++ case kRiscvWord64Atomic##op##Uint16: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 16, inst, 64); \ ++ break; \ ++ case kRiscvWord64Atomic##op##Uint32: \ ++ ASSEMBLE_ATOMIC_BINOP_EXT(Lld, Scd, false, 32, inst, 64); \ ++ break; \ ++ case kRiscvWord64Atomic##op##Uint64: \ ++ ASSEMBLE_ATOMIC_BINOP(Lld, Scd, inst); \ ++ break; ++ ATOMIC_BINOP_CASE(Add, Add64) ++ ATOMIC_BINOP_CASE(Sub, Sub64) ++ ATOMIC_BINOP_CASE(And, And) ++ ATOMIC_BINOP_CASE(Or, Or) ++ ATOMIC_BINOP_CASE(Xor, Xor) ++#undef ATOMIC_BINOP_CASE ++ case kRiscvAssertEqual: ++ __ Assert(eq, static_cast(i.InputOperand(2).immediate()), ++ i.InputRegister(0), Operand(i.InputRegister(1))); ++ break; ++ ++ default: ++ UNIMPLEMENTED(); ++ } ++ return kSuccess; ++} // NOLINT(readability/fn_size) ++ ++#define UNSUPPORTED_COND(opcode, condition) \ ++ StdoutStream{} << "Unsupported " << #opcode << " condition: \"" << condition \ ++ << "\""; \ ++ UNIMPLEMENTED(); ++ ++void AssembleBranchToLabels(CodeGenerator* gen, TurboAssembler* tasm, ++ Instruction* instr, FlagsCondition condition, ++ Label* tlabel, Label* flabel, bool fallthru) { ++#undef __ ++#define __ tasm-> ++ RiscvOperandConverter i(gen, instr); ++ ++ Condition cc = kNoCondition; ++ // RISC-V does not have condition code flags, so compare and branch are ++ // implemented differently than on the other arch's. The compare operations ++ // emit riscv64 pseudo-instructions, which are handled here by branch ++ // instructions that do the actual comparison. Essential that the input ++ // registers to compare pseudo-op are not modified before this branch op, as ++ // they are tested here. ++ ++ if (instr->arch_opcode() == kRiscvTst) { ++ cc = FlagsConditionToConditionTst(condition); ++ __ Branch(tlabel, cc, kScratchReg, Operand(zero_reg)); ++ } else if (instr->arch_opcode() == kRiscvAdd64 || ++ instr->arch_opcode() == kRiscvSub64) { ++ cc = FlagsConditionToConditionOvf(condition); ++ __ Sra64(kScratchReg, i.OutputRegister(), 32); ++ __ Sra64(kScratchReg2, i.OutputRegister(), 31); ++ __ Branch(tlabel, cc, kScratchReg2, Operand(kScratchReg)); ++ } else if (instr->arch_opcode() == kRiscvAddOvf64 || ++ instr->arch_opcode() == kRiscvSubOvf64) { ++ switch (condition) { ++ // Overflow occurs if overflow register is negative ++ case kOverflow: ++ __ Branch(tlabel, lt, kScratchReg, Operand(zero_reg)); ++ break; ++ case kNotOverflow: ++ __ Branch(tlabel, ge, kScratchReg, Operand(zero_reg)); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ break; ++ } ++ } else if (instr->arch_opcode() == kRiscvMulOvf32) { ++ // Overflow occurs if overflow register is not zero ++ switch (condition) { ++ case kOverflow: ++ __ Branch(tlabel, ne, kScratchReg, Operand(zero_reg)); ++ break; ++ case kNotOverflow: ++ __ Branch(tlabel, eq, kScratchReg, Operand(zero_reg)); ++ break; ++ default: ++ UNSUPPORTED_COND(kRiscvMulOvf32, condition); ++ break; ++ } ++ } else if (instr->arch_opcode() == kRiscvCmp) { ++ cc = FlagsConditionToConditionCmp(condition); ++ __ Branch(tlabel, cc, i.InputRegister(0), i.InputOperand(1)); ++ } else if (instr->arch_opcode() == kArchStackPointerGreaterThan) { ++ cc = FlagsConditionToConditionCmp(condition); ++ Register lhs_register = sp; ++ uint32_t offset; ++ if (gen->ShouldApplyOffsetToStackCheck(instr, &offset)) { ++ lhs_register = i.TempRegister(0); ++ __ Sub64(lhs_register, sp, offset); ++ } ++ __ Branch(tlabel, cc, lhs_register, Operand(i.InputRegister(0))); ++ } else if (instr->arch_opcode() == kRiscvCmpS || ++ instr->arch_opcode() == kRiscvCmpD) { ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ // floating-point compare result is set in kScratchReg ++ if (predicate) { ++ __ BranchTrueF(kScratchReg, tlabel); ++ } else { ++ __ BranchFalseF(kScratchReg, tlabel); ++ } ++ } else { ++ PrintF("AssembleArchBranch Unimplemented arch_opcode: %d\n", ++ instr->arch_opcode()); ++ UNIMPLEMENTED(); ++ } ++ if (!fallthru) __ Branch(flabel); // no fallthru to flabel. ++#undef __ ++#define __ tasm()-> ++} ++ ++// Assembles branches after an instruction. ++void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { ++ Label* tlabel = branch->true_label; ++ Label* flabel = branch->false_label; ++ ++ AssembleBranchToLabels(this, tasm(), instr, branch->condition, tlabel, flabel, ++ branch->fallthru); ++} ++ ++void CodeGenerator::AssembleBranchPoisoning(FlagsCondition condition, ++ Instruction* instr) { ++ // TODO(jarin) Handle float comparisons (kUnordered[Not]Equal). ++ if (condition == kUnorderedEqual || condition == kUnorderedNotEqual) { ++ return; ++ } ++ ++ RiscvOperandConverter i(this, instr); ++ condition = NegateFlagsCondition(condition); ++ ++ switch (instr->arch_opcode()) { ++ case kRiscvCmp: { ++ __ CompareI(kScratchReg, i.InputRegister(0), i.InputOperand(1), ++ FlagsConditionToConditionCmp(condition)); ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, kScratchReg); ++ } ++ return; ++ case kRiscvTst: { ++ switch (condition) { ++ case kEqual: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); ++ break; ++ case kNotEqual: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ return; ++ case kRiscvAdd64: ++ case kRiscvSub64: { ++ // Check for overflow creates 1 or 0 for result. ++ __ Srl64(kScratchReg, i.OutputRegister(), 63); ++ __ Srl32(kScratchReg2, i.OutputRegister(), 31); ++ __ Xor(kScratchReg2, kScratchReg, kScratchReg2); ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg2); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kRiscvAddOvf64: ++ case kRiscvSubOvf64: { ++ // Overflow occurs if overflow register is negative ++ __ Slt(kScratchReg2, kScratchReg, zero_reg); ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg2); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg2); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kRiscvMulOvf32: { ++ // Overflow occurs if overflow register is not zero ++ switch (condition) { ++ case kOverflow: ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, ++ kScratchReg); ++ break; ++ case kNotOverflow: ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); ++ break; ++ default: ++ UNSUPPORTED_COND(instr->arch_opcode(), condition); ++ } ++ } ++ return; ++ case kRiscvCmpS: ++ case kRiscvCmpD: { ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ if (predicate) { ++ __ LoadZeroIfConditionNotZero(kSpeculationPoisonRegister, kScratchReg); ++ } else { ++ __ LoadZeroIfConditionZero(kSpeculationPoisonRegister, kScratchReg); ++ } ++ } ++ return; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++#undef UNSUPPORTED_COND ++ ++void CodeGenerator::AssembleArchDeoptBranch(Instruction* instr, ++ BranchInfo* branch) { ++ AssembleArchBranch(instr, branch); ++} ++ ++void CodeGenerator::AssembleArchJump(RpoNumber target) { ++ if (!IsNextInAssemblyOrder(target)) __ Branch(GetLabel(target)); ++} ++ ++void CodeGenerator::AssembleArchTrap(Instruction* instr, ++ FlagsCondition condition) { ++ class OutOfLineTrap final : public OutOfLineCode { ++ public: ++ OutOfLineTrap(CodeGenerator* gen, Instruction* instr) ++ : OutOfLineCode(gen), instr_(instr), gen_(gen) {} ++ void Generate() final { ++ RiscvOperandConverter i(gen_, instr_); ++ TrapId trap_id = ++ static_cast(i.InputInt32(instr_->InputCount() - 1)); ++ GenerateCallToTrap(trap_id); ++ } ++ ++ private: ++ void GenerateCallToTrap(TrapId trap_id) { ++ if (trap_id == TrapId::kInvalid) { ++ // We cannot test calls to the runtime in cctest/test-run-wasm. ++ // Therefore we emit a call to C here instead of a call to the runtime. ++ // We use the context register as the scratch register, because we do ++ // not have a context here. ++ __ PrepareCallCFunction(0, 0, cp); ++ __ CallCFunction( ++ ExternalReference::wasm_call_trap_callback_for_testing(), 0); ++ __ LeaveFrame(StackFrame::WASM); ++ auto call_descriptor = gen_->linkage()->GetIncomingDescriptor(); ++ int pop_count = ++ static_cast(call_descriptor->StackParameterCount()); ++ pop_count += (pop_count & 1); // align ++ __ Drop(pop_count); ++ __ Ret(); ++ } else { ++ gen_->AssembleSourcePosition(instr_); ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched when the code ++ // is added to the native module and copied into wasm code space. ++ __ Call(static_cast
(trap_id), RelocInfo::WASM_STUB_CALL); ++ ReferenceMap* reference_map = ++ gen_->zone()->New(gen_->zone()); ++ gen_->RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); ++ if (FLAG_debug_code) { ++ __ stop(); ++ } ++ } ++ } ++ Instruction* instr_; ++ CodeGenerator* gen_; ++ }; ++ auto ool = zone()->New(this, instr); ++ Label* tlabel = ool->entry(); ++ AssembleBranchToLabels(this, tasm(), instr, condition, tlabel, nullptr, true); ++} ++ ++// Assembles boolean materializations after an instruction. ++void CodeGenerator::AssembleArchBoolean(Instruction* instr, ++ FlagsCondition condition) { ++ RiscvOperandConverter i(this, instr); ++ ++ // Materialize a full 32-bit 1 or 0 value. The result register is always the ++ // last output of the instruction. ++ DCHECK_NE(0u, instr->OutputCount()); ++ Register result = i.OutputRegister(instr->OutputCount() - 1); ++ Condition cc = kNoCondition; ++ // RISC-V does not have condition code flags, so compare and branch are ++ // implemented differently than on the other arch's. The compare operations ++ // emit riscv64 pseudo-instructions, which are checked and handled here. ++ ++ if (instr->arch_opcode() == kRiscvTst) { ++ cc = FlagsConditionToConditionTst(condition); ++ if (cc == eq) { ++ __ Sltu(result, kScratchReg, 1); ++ } else { ++ __ Sltu(result, zero_reg, kScratchReg); ++ } ++ return; ++ } else if (instr->arch_opcode() == kRiscvAdd64 || ++ instr->arch_opcode() == kRiscvSub64) { ++ cc = FlagsConditionToConditionOvf(condition); ++ // Check for overflow creates 1 or 0 for result. ++ __ Srl64(kScratchReg, i.OutputRegister(), 63); ++ __ Srl32(kScratchReg2, i.OutputRegister(), 31); ++ __ Xor(result, kScratchReg, kScratchReg2); ++ if (cc == eq) // Toggle result for not overflow. ++ __ Xor(result, result, 1); ++ return; ++ } else if (instr->arch_opcode() == kRiscvAddOvf64 || ++ instr->arch_opcode() == kRiscvSubOvf64) { ++ // Overflow occurs if overflow register is negative ++ __ Slt(result, kScratchReg, zero_reg); ++ } else if (instr->arch_opcode() == kRiscvMulOvf32) { ++ // Overflow occurs if overflow register is not zero ++ __ Sgtu(result, kScratchReg, zero_reg); ++ } else if (instr->arch_opcode() == kRiscvCmp) { ++ cc = FlagsConditionToConditionCmp(condition); ++ switch (cc) { ++ case eq: ++ case ne: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ if (instr->InputAt(1)->IsImmediate()) { ++ if (is_int12(-right.immediate())) { ++ if (right.immediate() == 0) { ++ if (cc == eq) { ++ __ Sltu(result, left, 1); ++ } else { ++ __ Sltu(result, zero_reg, left); ++ } ++ } else { ++ __ Add64(result, left, Operand(-right.immediate())); ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } else { ++ if (is_uint12(right.immediate())) { ++ __ Xor(result, left, right); ++ } else { ++ __ li(kScratchReg, right); ++ __ Xor(result, left, kScratchReg); ++ } ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } else { ++ __ Xor(result, left, right); ++ if (cc == eq) { ++ __ Sltu(result, result, 1); ++ } else { ++ __ Sltu(result, zero_reg, result); ++ } ++ } ++ } break; ++ case lt: ++ case ge: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ __ Slt(result, left, right); ++ if (cc == ge) { ++ __ Xor(result, result, 1); ++ } ++ } break; ++ case gt: ++ case le: { ++ Register left = i.InputRegister(1); ++ Operand right = i.InputOperand(0); ++ __ Slt(result, left, right); ++ if (cc == le) { ++ __ Xor(result, result, 1); ++ } ++ } break; ++ case Uless: ++ case Ugreater_equal: { ++ Register left = i.InputRegister(0); ++ Operand right = i.InputOperand(1); ++ __ Sltu(result, left, right); ++ if (cc == Ugreater_equal) { ++ __ Xor(result, result, 1); ++ } ++ } break; ++ case Ugreater: ++ case Uless_equal: { ++ Register left = i.InputRegister(1); ++ Operand right = i.InputOperand(0); ++ __ Sltu(result, left, right); ++ if (cc == Uless_equal) { ++ __ Xor(result, result, 1); ++ } ++ } break; ++ default: ++ UNREACHABLE(); ++ } ++ return; ++ } else if (instr->arch_opcode() == kRiscvCmpD || ++ instr->arch_opcode() == kRiscvCmpS) { ++ FPURegister left = i.InputOrZeroDoubleRegister(0); ++ FPURegister right = i.InputOrZeroDoubleRegister(1); ++ if ((instr->arch_opcode() == kRiscvCmpD) && ++ (left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsDoubleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0); ++ } else if ((instr->arch_opcode() == kRiscvCmpS) && ++ (left == kDoubleRegZero || right == kDoubleRegZero) && ++ !__ IsSingleZeroRegSet()) { ++ __ LoadFPRImmediate(kDoubleRegZero, 0.0f); ++ } ++ bool predicate; ++ FlagsConditionToConditionCmpFPU(&predicate, condition); ++ // RISCV compare returns 0 or 1, do nothing when predicate; otherwise ++ // toggle kScratchReg (i.e., 0 -> 1, 1 -> 0) ++ if (predicate) { ++ __ Move(result, kScratchReg); ++ } else { ++ __ Xor(result, kScratchReg, 1); ++ } ++ return; ++ } else { ++ PrintF("AssembleArchBranch Unimplemented arch_opcode is : %d\n", ++ instr->arch_opcode()); ++ TRACE_UNIMPL(); ++ UNIMPLEMENTED(); ++ } ++} ++ ++void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) { ++ RiscvOperandConverter i(this, instr); ++ Register input = i.InputRegister(0); ++ std::vector> cases; ++ for (size_t index = 2; index < instr->InputCount(); index += 2) { ++ cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))}); ++ } ++ AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(), ++ cases.data() + cases.size()); ++} ++ ++void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { ++ RiscvOperandConverter i(this, instr); ++ Register input = i.InputRegister(0); ++ size_t const case_count = instr->InputCount() - 2; ++ ++ __ Branch(GetLabel(i.InputRpo(1)), Ugreater_equal, input, ++ Operand(case_count)); ++ __ GenerateSwitchTable(input, case_count, [&i, this](size_t index) { ++ return GetLabel(i.InputRpo(index + 2)); ++ }); ++} ++ ++void CodeGenerator::FinishFrame(Frame* frame) { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ if (saves_fpu != 0) { ++ int count = base::bits::CountPopulation(saves_fpu); ++ DCHECK_EQ(kNumCalleeSavedFPU, count); ++ frame->AllocateSavedCalleeRegisterSlots(count * ++ (kDoubleSize / kSystemPointerSize)); ++ } ++ ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ if (saves != 0) { ++ int count = base::bits::CountPopulation(saves); ++ DCHECK_EQ(kNumCalleeSaved, count + 1); ++ frame->AllocateSavedCalleeRegisterSlots(count); ++ } ++} ++ ++void CodeGenerator::AssembleConstructFrame() { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ if (frame_access_state()->has_frame()) { ++ if (call_descriptor->IsCFunctionCall()) { ++ if (info()->GetOutputStackFrameType() == StackFrame::C_WASM_ENTRY) { ++ __ StubPrologue(StackFrame::C_WASM_ENTRY); ++ // Reserve stack space for saving the c_entry_fp later. ++ __ Sub64(sp, sp, Operand(kSystemPointerSize)); ++ } else { ++ __ Push(ra, fp); ++ __ Move(fp, sp); ++ } ++ } else if (call_descriptor->IsJSFunctionCall()) { ++ __ Prologue(); ++ } else { ++ __ StubPrologue(info()->GetOutputStackFrameType()); ++ if (call_descriptor->IsWasmFunctionCall()) { ++ __ Push(kWasmInstanceRegister); ++ } else if (call_descriptor->IsWasmImportWrapper() || ++ call_descriptor->IsWasmCapiFunction()) { ++ // Wasm import wrappers are passed a tuple in the place of the instance. ++ // Unpack the tuple into the instance and the target callable. ++ // This must be done here in the codegen because it cannot be expressed ++ // properly in the graph. ++ __ Ld(kJSFunctionRegister, ++ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset)); ++ __ Ld(kWasmInstanceRegister, ++ FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); ++ __ Push(kWasmInstanceRegister); ++ if (call_descriptor->IsWasmCapiFunction()) { ++ // Reserve space for saving the PC later. ++ __ Sub64(sp, sp, Operand(kSystemPointerSize)); ++ } ++ } ++ } ++ } ++ ++ int required_slots = ++ frame()->GetTotalFrameSlotCount() - frame()->GetFixedSlotCount(); ++ ++ if (info()->is_osr()) { ++ // TurboFan OSR-compiled functions cannot be entered directly. ++ __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); ++ ++ // Unoptimized code jumps directly to this entrypoint while the unoptimized ++ // frame is still on the stack. Optimized code uses OSR values directly from ++ // the unoptimized frame. Thus, all that needs to be done is to allocate the ++ // remaining stack slots. ++ if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); ++ osr_pc_offset_ = __ pc_offset(); ++ required_slots -= osr_helper()->UnoptimizedFrameSlots(); ++ ResetSpeculationPoison(); ++ } ++ ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ ++ if (required_slots > 0) { ++ DCHECK(frame_access_state()->has_frame()); ++ if (info()->IsWasm() && required_slots > 128) { ++ // For WebAssembly functions with big frames we have to do the stack ++ // overflow check before we construct the frame. Otherwise we may not ++ // have enough space on the stack to call the runtime for the stack ++ // overflow. ++ Label done; ++ ++ // If the frame is bigger than the stack, we throw the stack overflow ++ // exception unconditionally. Thereby we can avoid the integer overflow ++ // check in the condition code. ++ if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { ++ __ Ld( ++ kScratchReg, ++ FieldMemOperand(kWasmInstanceRegister, ++ WasmInstanceObject::kRealStackLimitAddressOffset)); ++ __ Ld(kScratchReg, MemOperand(kScratchReg)); ++ __ Add64(kScratchReg, kScratchReg, ++ Operand(required_slots * kSystemPointerSize)); ++ __ Branch(&done, uge, sp, Operand(kScratchReg)); ++ } ++ ++ __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); ++ // We come from WebAssembly, there are no references for the GC. ++ ReferenceMap* reference_map = zone()->New(zone()); ++ RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); ++ if (FLAG_debug_code) { ++ __ stop(); ++ } ++ ++ __ bind(&done); ++ } ++ } ++ ++ const int returns = frame()->GetReturnSlotCount(); ++ ++ // Skip callee-saved and return slots, which are pushed below. ++ required_slots -= base::bits::CountPopulation(saves); ++ required_slots -= base::bits::CountPopulation(saves_fpu); ++ required_slots -= returns; ++ if (required_slots > 0) { ++ __ Sub64(sp, sp, Operand(required_slots * kSystemPointerSize)); ++ } ++ ++ if (saves_fpu != 0) { ++ // Save callee-saved FPU registers. ++ __ MultiPushFPU(saves_fpu); ++ DCHECK_EQ(kNumCalleeSavedFPU, base::bits::CountPopulation(saves_fpu)); ++ } ++ ++ if (saves != 0) { ++ // Save callee-saved registers. ++ __ MultiPush(saves); ++ DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1); ++ } ++ ++ if (returns != 0) { ++ // Create space for returns. ++ __ Sub64(sp, sp, Operand(returns * kSystemPointerSize)); ++ } ++} ++ ++void CodeGenerator::AssembleReturn(InstructionOperand* pop) { ++ auto call_descriptor = linkage()->GetIncomingDescriptor(); ++ ++ const int returns = frame()->GetReturnSlotCount(); ++ if (returns != 0) { ++ __ Add64(sp, sp, Operand(returns * kSystemPointerSize)); ++ } ++ ++ // Restore GP registers. ++ const RegList saves = call_descriptor->CalleeSavedRegisters(); ++ if (saves != 0) { ++ __ MultiPop(saves); ++ } ++ ++ // Restore FPU registers. ++ const RegList saves_fpu = call_descriptor->CalleeSavedFPRegisters(); ++ if (saves_fpu != 0) { ++ __ MultiPopFPU(saves_fpu); ++ } ++ ++ RiscvOperandConverter g(this, nullptr); ++ if (call_descriptor->IsCFunctionCall()) { ++ AssembleDeconstructFrame(); ++ } else if (frame_access_state()->has_frame()) { ++ // Canonicalize JSFunction return sites for now unless they have an variable ++ // number of stack slot pops. ++ if (pop->IsImmediate() && g.ToConstant(pop).ToInt32() == 0) { ++ if (return_label_.is_bound()) { ++ __ Branch(&return_label_); ++ return; ++ } else { ++ __ bind(&return_label_); ++ AssembleDeconstructFrame(); ++ } ++ } else { ++ AssembleDeconstructFrame(); ++ } ++ } ++ int pop_count = static_cast(call_descriptor->StackParameterCount()); ++ if (pop->IsImmediate()) { ++ pop_count += g.ToConstant(pop).ToInt32(); ++ } else { ++ Register pop_reg = g.ToRegister(pop); ++ __ Sll64(pop_reg, pop_reg, kSystemPointerSizeLog2); ++ __ Add64(sp, sp, pop_reg); ++ } ++ if (pop_count != 0) { ++ __ DropAndRet(pop_count); ++ } else { ++ __ Ret(); ++ } ++} ++ ++void CodeGenerator::FinishCode() {} ++ ++void CodeGenerator::PrepareForDeoptimizationExits(int deopt_count) {} ++ ++void CodeGenerator::AssembleMove(InstructionOperand* source, ++ InstructionOperand* destination) { ++ RiscvOperandConverter g(this, nullptr); ++ // Dispatch on the source and destination operand kinds. Not all ++ // combinations are possible. ++ if (source->IsRegister()) { ++ DCHECK(destination->IsRegister() || destination->IsStackSlot()); ++ Register src = g.ToRegister(source); ++ if (destination->IsRegister()) { ++ __ Move(g.ToRegister(destination), src); ++ } else { ++ __ Sd(src, g.ToMemOperand(destination)); ++ } ++ } else if (source->IsStackSlot()) { ++ DCHECK(destination->IsRegister() || destination->IsStackSlot()); ++ MemOperand src = g.ToMemOperand(source); ++ if (destination->IsRegister()) { ++ __ Ld(g.ToRegister(destination), src); ++ } else { ++ Register temp = kScratchReg; ++ __ Ld(temp, src); ++ __ Sd(temp, g.ToMemOperand(destination)); ++ } ++ } else if (source->IsConstant()) { ++ Constant src = g.ToConstant(source); ++ if (destination->IsRegister() || destination->IsStackSlot()) { ++ Register dst = ++ destination->IsRegister() ? g.ToRegister(destination) : kScratchReg; ++ switch (src.type()) { ++ case Constant::kInt32: ++ __ li(dst, Operand(src.ToInt32())); ++ break; ++ case Constant::kFloat32: ++ __ li(dst, Operand::EmbeddedNumber(src.ToFloat32())); ++ break; ++ case Constant::kInt64: ++ if (RelocInfo::IsWasmReference(src.rmode())) { ++ __ li(dst, Operand(src.ToInt64(), src.rmode())); ++ } else { ++ __ li(dst, Operand(src.ToInt64())); ++ } ++ break; ++ case Constant::kFloat64: ++ __ li(dst, Operand::EmbeddedNumber(src.ToFloat64().value())); ++ break; ++ case Constant::kExternalReference: ++ __ li(dst, src.ToExternalReference()); ++ break; ++ case Constant::kDelayedStringConstant: ++ __ li(dst, src.ToDelayedStringConstant()); ++ break; ++ case Constant::kHeapObject: { ++ Handle src_object = src.ToHeapObject(); ++ RootIndex index; ++ if (IsMaterializableFromRoot(src_object, &index)) { ++ __ LoadRoot(dst, index); ++ } else { ++ __ li(dst, src_object); ++ } ++ break; ++ } ++ case Constant::kCompressedHeapObject: ++ UNREACHABLE(); ++ case Constant::kRpoNumber: ++ UNREACHABLE(); // TODO(titzer): loading RPO numbers ++ break; ++ } ++ if (destination->IsStackSlot()) __ Sd(dst, g.ToMemOperand(destination)); ++ } else if (src.type() == Constant::kFloat32) { ++ if (destination->IsFPStackSlot()) { ++ MemOperand dst = g.ToMemOperand(destination); ++ if (bit_cast(src.ToFloat32()) == 0) { ++ __ Sw(zero_reg, dst); ++ } else { ++ __ li(kScratchReg, Operand(bit_cast(src.ToFloat32()))); ++ __ Sw(kScratchReg, dst); ++ } ++ } else { ++ DCHECK(destination->IsFPRegister()); ++ FloatRegister dst = g.ToSingleRegister(destination); ++ __ LoadFPRImmediate(dst, src.ToFloat32()); ++ } ++ } else { ++ DCHECK_EQ(Constant::kFloat64, src.type()); ++ DoubleRegister dst = destination->IsFPRegister() ++ ? g.ToDoubleRegister(destination) ++ : kScratchDoubleReg; ++ __ LoadFPRImmediate(dst, src.ToFloat64().value()); ++ if (destination->IsFPStackSlot()) { ++ __ StoreDouble(dst, g.ToMemOperand(destination)); ++ } ++ } ++ } else if (source->IsFPRegister()) { ++ MachineRepresentation rep = LocationOperand::cast(source)->representation(); ++ if (rep == MachineRepresentation::kSimd128) { ++ UNIMPLEMENTED(); ++ } else { ++ FPURegister src = g.ToDoubleRegister(source); ++ if (destination->IsFPRegister()) { ++ FPURegister dst = g.ToDoubleRegister(destination); ++ __ Move(dst, src); ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ if (rep == MachineRepresentation::kFloat32) { ++ __ StoreFloat(src, g.ToMemOperand(destination)); ++ } else { ++ DCHECK_EQ(rep, MachineRepresentation::kFloat64); ++ __ StoreDouble(src, g.ToMemOperand(destination)); ++ } ++ } ++ } ++ } else if (source->IsFPStackSlot()) { ++ DCHECK(destination->IsFPRegister() || destination->IsFPStackSlot()); ++ MemOperand src = g.ToMemOperand(source); ++ MachineRepresentation rep = LocationOperand::cast(source)->representation(); ++ if (rep == MachineRepresentation::kSimd128) { ++ UNIMPLEMENTED(); ++ } else { ++ if (destination->IsFPRegister()) { ++ if (rep == MachineRepresentation::kFloat32) { ++ __ LoadFloat(g.ToDoubleRegister(destination), src); ++ } else { ++ DCHECK_EQ(rep, MachineRepresentation::kFloat64); ++ __ LoadDouble(g.ToDoubleRegister(destination), src); ++ } ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ FPURegister temp = kScratchDoubleReg; ++ if (rep == MachineRepresentation::kFloat32) { ++ __ LoadFloat(temp, src); ++ __ StoreFloat(temp, g.ToMemOperand(destination)); ++ } else { ++ DCHECK_EQ(rep, MachineRepresentation::kFloat64); ++ __ LoadDouble(temp, src); ++ __ StoreDouble(temp, g.ToMemOperand(destination)); ++ } ++ } ++ } ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++void CodeGenerator::AssembleSwap(InstructionOperand* source, ++ InstructionOperand* destination) { ++ RiscvOperandConverter g(this, nullptr); ++ // Dispatch on the source and destination operand kinds. Not all ++ // combinations are possible. ++ if (source->IsRegister()) { ++ // Register-register. ++ Register temp = kScratchReg; ++ Register src = g.ToRegister(source); ++ if (destination->IsRegister()) { ++ Register dst = g.ToRegister(destination); ++ __ Move(temp, src); ++ __ Move(src, dst); ++ __ Move(dst, temp); ++ } else { ++ DCHECK(destination->IsStackSlot()); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ Move(temp, src); ++ __ Ld(src, dst); ++ __ Sd(temp, dst); ++ } ++ } else if (source->IsStackSlot()) { ++ DCHECK(destination->IsStackSlot()); ++ Register temp_0 = kScratchReg; ++ Register temp_1 = kScratchReg2; ++ MemOperand src = g.ToMemOperand(source); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ Ld(temp_0, src); ++ __ Ld(temp_1, dst); ++ __ Sd(temp_0, dst); ++ __ Sd(temp_1, src); ++ } else if (source->IsFPRegister()) { ++ MachineRepresentation rep = LocationOperand::cast(source)->representation(); ++ if (rep == MachineRepresentation::kSimd128) { ++ UNIMPLEMENTED(); ++ } else { ++ FPURegister temp = kScratchDoubleReg; ++ FPURegister src = g.ToDoubleRegister(source); ++ if (destination->IsFPRegister()) { ++ FPURegister dst = g.ToDoubleRegister(destination); ++ __ Move(temp, src); ++ __ Move(src, dst); ++ __ Move(dst, temp); ++ } else { ++ DCHECK(destination->IsFPStackSlot()); ++ MemOperand dst = g.ToMemOperand(destination); ++ __ Move(temp, src); ++ __ LoadDouble(src, dst); ++ __ StoreDouble(temp, dst); ++ } ++ } ++ } else if (source->IsFPStackSlot()) { ++ DCHECK(destination->IsFPStackSlot()); ++ Register temp_0 = kScratchReg; ++ MemOperand src0 = g.ToMemOperand(source); ++ MemOperand src1(src0.rm(), src0.offset() + kIntSize); ++ MemOperand dst0 = g.ToMemOperand(destination); ++ MemOperand dst1(dst0.rm(), dst0.offset() + kIntSize); ++ MachineRepresentation rep = LocationOperand::cast(source)->representation(); ++ if (rep == MachineRepresentation::kSimd128) { ++ UNIMPLEMENTED(); ++ } else { ++ FPURegister temp_1 = kScratchDoubleReg; ++ __ LoadDouble(temp_1, dst0); // Save destination in temp_1. ++ __ Lw(temp_0, src0); // Then use temp_0 to copy source to destination. ++ __ Sw(temp_0, dst0); ++ __ Lw(temp_0, src1); ++ __ Sw(temp_0, dst1); ++ __ StoreDouble(temp_1, src0); ++ } ++ } else { ++ // No other combinations are possible. ++ UNREACHABLE(); ++ } ++} ++ ++void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { ++ // On 64-bit RISC-V we emit the jump tables inline. ++ UNREACHABLE(); ++} ++ ++#undef ASSEMBLE_ATOMIC_LOAD_INTEGER ++#undef ASSEMBLE_ATOMIC_STORE_INTEGER ++#undef ASSEMBLE_ATOMIC_BINOP ++#undef ASSEMBLE_ATOMIC_BINOP_EXT ++#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER ++#undef ASSEMBLE_ATOMIC_EXCHANGE_INTEGER_EXT ++#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER ++#undef ASSEMBLE_ATOMIC_COMPARE_EXCHANGE_INTEGER_EXT ++#undef ASSEMBLE_IEEE754_BINOP ++#undef ASSEMBLE_IEEE754_UNOP ++ ++#undef TRACE_MSG ++#undef TRACE_UNIMPL ++#undef __ ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-codes-riscv64.h +@@ -0,0 +1,432 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ ++#define V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++// RISC-V-specific opcodes that specify which assembly sequence to emit. ++// Most opcodes specify a single instruction. ++#define TARGET_ARCH_OPCODE_LIST(V) \ ++ V(RiscvAdd32) \ ++ V(RiscvAdd64) \ ++ V(RiscvAddOvf64) \ ++ V(RiscvSub32) \ ++ V(RiscvSub64) \ ++ V(RiscvSubOvf64) \ ++ V(RiscvMul32) \ ++ V(RiscvMulOvf32) \ ++ V(RiscvMulHigh32) \ ++ V(RiscvMulHigh64) \ ++ V(RiscvMulHighU32) \ ++ V(RiscvMul64) \ ++ V(RiscvDiv32) \ ++ V(RiscvDiv64) \ ++ V(RiscvDivU32) \ ++ V(RiscvDivU64) \ ++ V(RiscvMod32) \ ++ V(RiscvMod64) \ ++ V(RiscvModU32) \ ++ V(RiscvModU64) \ ++ V(RiscvAnd) \ ++ V(RiscvAnd32) \ ++ V(RiscvOr) \ ++ V(RiscvOr32) \ ++ V(RiscvNor) \ ++ V(RiscvNor32) \ ++ V(RiscvXor) \ ++ V(RiscvXor32) \ ++ V(RiscvClz32) \ ++ V(RiscvShl32) \ ++ V(RiscvShr32) \ ++ V(RiscvSar32) \ ++ V(RiscvZeroExtendWord) \ ++ V(RiscvSignExtendWord) \ ++ V(RiscvClz64) \ ++ V(RiscvCtz32) \ ++ V(RiscvCtz64) \ ++ V(RiscvPopcnt32) \ ++ V(RiscvPopcnt64) \ ++ V(RiscvShl64) \ ++ V(RiscvShr64) \ ++ V(RiscvSar64) \ ++ V(RiscvRor32) \ ++ V(RiscvRor64) \ ++ V(RiscvMov) \ ++ V(RiscvTst) \ ++ V(RiscvCmp) \ ++ V(RiscvCmpS) \ ++ V(RiscvAddS) \ ++ V(RiscvSubS) \ ++ V(RiscvMulS) \ ++ V(RiscvDivS) \ ++ V(RiscvModS) \ ++ V(RiscvAbsS) \ ++ V(RiscvNegS) \ ++ V(RiscvSqrtS) \ ++ V(RiscvMaxS) \ ++ V(RiscvMinS) \ ++ V(RiscvCmpD) \ ++ V(RiscvAddD) \ ++ V(RiscvSubD) \ ++ V(RiscvMulD) \ ++ V(RiscvDivD) \ ++ V(RiscvModD) \ ++ V(RiscvAbsD) \ ++ V(RiscvNegD) \ ++ V(RiscvSqrtD) \ ++ V(RiscvMaxD) \ ++ V(RiscvMinD) \ ++ V(RiscvFloat64RoundDown) \ ++ V(RiscvFloat64RoundTruncate) \ ++ V(RiscvFloat64RoundUp) \ ++ V(RiscvFloat64RoundTiesEven) \ ++ V(RiscvFloat32RoundDown) \ ++ V(RiscvFloat32RoundTruncate) \ ++ V(RiscvFloat32RoundUp) \ ++ V(RiscvFloat32RoundTiesEven) \ ++ V(RiscvCvtSD) \ ++ V(RiscvCvtDS) \ ++ V(RiscvTruncWD) \ ++ V(RiscvRoundWD) \ ++ V(RiscvFloorWD) \ ++ V(RiscvCeilWD) \ ++ V(RiscvTruncWS) \ ++ V(RiscvRoundWS) \ ++ V(RiscvFloorWS) \ ++ V(RiscvCeilWS) \ ++ V(RiscvTruncLS) \ ++ V(RiscvTruncLD) \ ++ V(RiscvTruncUwD) \ ++ V(RiscvTruncUwS) \ ++ V(RiscvTruncUlS) \ ++ V(RiscvTruncUlD) \ ++ V(RiscvCvtDW) \ ++ V(RiscvCvtSL) \ ++ V(RiscvCvtSW) \ ++ V(RiscvCvtSUw) \ ++ V(RiscvCvtSUl) \ ++ V(RiscvCvtDL) \ ++ V(RiscvCvtDUw) \ ++ V(RiscvCvtDUl) \ ++ V(RiscvLb) \ ++ V(RiscvLbu) \ ++ V(RiscvSb) \ ++ V(RiscvLh) \ ++ V(RiscvUlh) \ ++ V(RiscvLhu) \ ++ V(RiscvUlhu) \ ++ V(RiscvSh) \ ++ V(RiscvUsh) \ ++ V(RiscvLd) \ ++ V(RiscvUld) \ ++ V(RiscvLw) \ ++ V(RiscvUlw) \ ++ V(RiscvLwu) \ ++ V(RiscvUlwu) \ ++ V(RiscvSw) \ ++ V(RiscvUsw) \ ++ V(RiscvSd) \ ++ V(RiscvUsd) \ ++ V(RiscvLoadFloat) \ ++ V(RiscvULoadFloat) \ ++ V(RiscvStoreFloat) \ ++ V(RiscvUStoreFloat) \ ++ V(RiscvLoadDouble) \ ++ V(RiscvULoadDouble) \ ++ V(RiscvStoreDouble) \ ++ V(RiscvUStoreDouble) \ ++ V(RiscvBitcastDL) \ ++ V(RiscvBitcastLD) \ ++ V(RiscvBitcastInt32ToFloat32) \ ++ V(RiscvBitcastFloat32ToInt32) \ ++ V(RiscvFloat64ExtractLowWord32) \ ++ V(RiscvFloat64ExtractHighWord32) \ ++ V(RiscvFloat64InsertLowWord32) \ ++ V(RiscvFloat64InsertHighWord32) \ ++ V(RiscvFloat32Max) \ ++ V(RiscvFloat64Max) \ ++ V(RiscvFloat32Min) \ ++ V(RiscvFloat64Min) \ ++ V(RiscvFloat64SilenceNaN) \ ++ V(RiscvPush) \ ++ V(RiscvPeek) \ ++ V(RiscvByteSwap64) \ ++ V(RiscvByteSwap32) \ ++ V(RiscvStoreToStackSlot) \ ++ V(RiscvStackClaim) \ ++ V(RiscvSignExtendByte) \ ++ V(RiscvSignExtendShort) \ ++ V(RiscvSync) \ ++ V(RiscvAssertEqual) \ ++ V(RiscvS128Const) \ ++ V(RiscvS128Zero) \ ++ V(RiscvS128AllOnes) \ ++ V(RiscvI32x4Splat) \ ++ V(RiscvI32x4ExtractLane) \ ++ V(RiscvI32x4ReplaceLane) \ ++ V(RiscvI32x4Add) \ ++ V(RiscvI32x4AddHoriz) \ ++ V(RiscvI32x4Sub) \ ++ V(RiscvF64x2Abs) \ ++ V(RiscvF64x2Neg) \ ++ V(RiscvF32x4Splat) \ ++ V(RiscvF32x4ExtractLane) \ ++ V(RiscvF32x4ReplaceLane) \ ++ V(RiscvF32x4SConvertI32x4) \ ++ V(RiscvF32x4UConvertI32x4) \ ++ V(RiscvI32x4Mul) \ ++ V(RiscvI32x4MaxS) \ ++ V(RiscvI32x4MinS) \ ++ V(RiscvI32x4Eq) \ ++ V(RiscvI32x4Ne) \ ++ V(RiscvI32x4Shl) \ ++ V(RiscvI32x4ShrS) \ ++ V(RiscvI32x4ShrU) \ ++ V(RiscvI32x4MaxU) \ ++ V(RiscvI32x4MinU) \ ++ V(RiscvF64x2Sqrt) \ ++ V(RiscvF64x2Add) \ ++ V(RiscvF64x2Sub) \ ++ V(RiscvF64x2Mul) \ ++ V(RiscvF64x2Div) \ ++ V(RiscvF64x2Min) \ ++ V(RiscvF64x2Max) \ ++ V(RiscvF64x2Eq) \ ++ V(RiscvF64x2Ne) \ ++ V(RiscvF64x2Lt) \ ++ V(RiscvF64x2Le) \ ++ V(RiscvF64x2Splat) \ ++ V(RiscvF64x2ExtractLane) \ ++ V(RiscvF64x2ReplaceLane) \ ++ V(RiscvF64x2Pmin) \ ++ V(RiscvF64x2Pmax) \ ++ V(RiscvF64x2Ceil) \ ++ V(RiscvF64x2Floor) \ ++ V(RiscvF64x2Trunc) \ ++ V(RiscvF64x2NearestInt) \ ++ V(RiscvI64x2Splat) \ ++ V(RiscvI64x2ExtractLane) \ ++ V(RiscvI64x2ReplaceLane) \ ++ V(RiscvI64x2Add) \ ++ V(RiscvI64x2Sub) \ ++ V(RiscvI64x2Mul) \ ++ V(RiscvI64x2Neg) \ ++ V(RiscvI64x2Shl) \ ++ V(RiscvI64x2ShrS) \ ++ V(RiscvI64x2ShrU) \ ++ V(RiscvF32x4Abs) \ ++ V(RiscvF32x4Neg) \ ++ V(RiscvF32x4Sqrt) \ ++ V(RiscvF32x4RecipApprox) \ ++ V(RiscvF32x4RecipSqrtApprox) \ ++ V(RiscvF32x4Add) \ ++ V(RiscvF32x4AddHoriz) \ ++ V(RiscvF32x4Sub) \ ++ V(RiscvF32x4Mul) \ ++ V(RiscvF32x4Div) \ ++ V(RiscvF32x4Max) \ ++ V(RiscvF32x4Min) \ ++ V(RiscvF32x4Eq) \ ++ V(RiscvF32x4Ne) \ ++ V(RiscvF32x4Lt) \ ++ V(RiscvF32x4Le) \ ++ V(RiscvF32x4Pmin) \ ++ V(RiscvF32x4Pmax) \ ++ V(RiscvF32x4Ceil) \ ++ V(RiscvF32x4Floor) \ ++ V(RiscvF32x4Trunc) \ ++ V(RiscvF32x4NearestInt) \ ++ V(RiscvI32x4SConvertF32x4) \ ++ V(RiscvI32x4UConvertF32x4) \ ++ V(RiscvI32x4Neg) \ ++ V(RiscvI32x4GtS) \ ++ V(RiscvI32x4GeS) \ ++ V(RiscvI32x4GtU) \ ++ V(RiscvI32x4GeU) \ ++ V(RiscvI32x4Abs) \ ++ V(RiscvI32x4BitMask) \ ++ V(RiscvI16x8Splat) \ ++ V(RiscvI16x8ExtractLaneU) \ ++ V(RiscvI16x8ExtractLaneS) \ ++ V(RiscvI16x8ReplaceLane) \ ++ V(RiscvI16x8Neg) \ ++ V(RiscvI16x8Shl) \ ++ V(RiscvI16x8ShrS) \ ++ V(RiscvI16x8ShrU) \ ++ V(RiscvI16x8Add) \ ++ V(RiscvI16x8AddSaturateS) \ ++ V(RiscvI16x8AddHoriz) \ ++ V(RiscvI16x8Sub) \ ++ V(RiscvI16x8SubSaturateS) \ ++ V(RiscvI16x8Mul) \ ++ V(RiscvI16x8MaxS) \ ++ V(RiscvI16x8MinS) \ ++ V(RiscvI16x8Eq) \ ++ V(RiscvI16x8Ne) \ ++ V(RiscvI16x8GtS) \ ++ V(RiscvI16x8GeS) \ ++ V(RiscvI16x8AddSaturateU) \ ++ V(RiscvI16x8SubSaturateU) \ ++ V(RiscvI16x8MaxU) \ ++ V(RiscvI16x8MinU) \ ++ V(RiscvI16x8GtU) \ ++ V(RiscvI16x8GeU) \ ++ V(RiscvI16x8RoundingAverageU) \ ++ V(RiscvI16x8Abs) \ ++ V(RiscvI16x8BitMask) \ ++ V(RiscvI8x16Splat) \ ++ V(RiscvI8x16ExtractLaneU) \ ++ V(RiscvI8x16ExtractLaneS) \ ++ V(RiscvI8x16ReplaceLane) \ ++ V(RiscvI8x16Neg) \ ++ V(RiscvI8x16Shl) \ ++ V(RiscvI8x16ShrS) \ ++ V(RiscvI8x16Add) \ ++ V(RiscvI8x16AddSaturateS) \ ++ V(RiscvI8x16Sub) \ ++ V(RiscvI8x16SubSaturateS) \ ++ V(RiscvI8x16Mul) \ ++ V(RiscvI8x16MaxS) \ ++ V(RiscvI8x16MinS) \ ++ V(RiscvI8x16Eq) \ ++ V(RiscvI8x16Ne) \ ++ V(RiscvI8x16GtS) \ ++ V(RiscvI8x16GeS) \ ++ V(RiscvI8x16ShrU) \ ++ V(RiscvI8x16AddSaturateU) \ ++ V(RiscvI8x16SubSaturateU) \ ++ V(RiscvI8x16MaxU) \ ++ V(RiscvI8x16MinU) \ ++ V(RiscvI8x16GtU) \ ++ V(RiscvI8x16GeU) \ ++ V(RiscvI8x16RoundingAverageU) \ ++ V(RiscvI8x16Abs) \ ++ V(RiscvI8x16BitMask) \ ++ V(RiscvS128And) \ ++ V(RiscvS128Or) \ ++ V(RiscvS128Xor) \ ++ V(RiscvS128Not) \ ++ V(RiscvS128Select) \ ++ V(RiscvS128AndNot) \ ++ V(RiscvV32x4AnyTrue) \ ++ V(RiscvV32x4AllTrue) \ ++ V(RiscvV16x8AnyTrue) \ ++ V(RiscvV16x8AllTrue) \ ++ V(RiscvV8x16AnyTrue) \ ++ V(RiscvV8x16AllTrue) \ ++ V(RiscvS32x4InterleaveRight) \ ++ V(RiscvS32x4InterleaveLeft) \ ++ V(RiscvS32x4PackEven) \ ++ V(RiscvS32x4PackOdd) \ ++ V(RiscvS32x4InterleaveEven) \ ++ V(RiscvS32x4InterleaveOdd) \ ++ V(RiscvS32x4Shuffle) \ ++ V(RiscvS16x8InterleaveRight) \ ++ V(RiscvS16x8InterleaveLeft) \ ++ V(RiscvS16x8PackEven) \ ++ V(RiscvS16x8PackOdd) \ ++ V(RiscvS16x8InterleaveEven) \ ++ V(RiscvS16x8InterleaveOdd) \ ++ V(RiscvS16x4Reverse) \ ++ V(RiscvS16x2Reverse) \ ++ V(RiscvS8x16InterleaveRight) \ ++ V(RiscvS8x16InterleaveLeft) \ ++ V(RiscvS8x16PackEven) \ ++ V(RiscvS8x16PackOdd) \ ++ V(RiscvS8x16InterleaveEven) \ ++ V(RiscvS8x16InterleaveOdd) \ ++ V(RiscvI8x16Shuffle) \ ++ V(RiscvI8x16Swizzle) \ ++ V(RiscvS8x16Concat) \ ++ V(RiscvS8x8Reverse) \ ++ V(RiscvS8x4Reverse) \ ++ V(RiscvS8x2Reverse) \ ++ V(RiscvS8x16LoadSplat) \ ++ V(RiscvS16x8LoadSplat) \ ++ V(RiscvS32x4LoadSplat) \ ++ V(RiscvS64x2LoadSplat) \ ++ V(RiscvI16x8Load8x8S) \ ++ V(RiscvI16x8Load8x8U) \ ++ V(RiscvI32x4Load16x4S) \ ++ V(RiscvI32x4Load16x4U) \ ++ V(RiscvI64x2Load32x2S) \ ++ V(RiscvI64x2Load32x2U) \ ++ V(RiscvMsaLd) \ ++ V(RiscvMsaSt) \ ++ V(RiscvI32x4SConvertI16x8Low) \ ++ V(RiscvI32x4SConvertI16x8High) \ ++ V(RiscvI32x4UConvertI16x8Low) \ ++ V(RiscvI32x4UConvertI16x8High) \ ++ V(RiscvI16x8SConvertI8x16Low) \ ++ V(RiscvI16x8SConvertI8x16High) \ ++ V(RiscvI16x8SConvertI32x4) \ ++ V(RiscvI16x8UConvertI32x4) \ ++ V(RiscvI16x8UConvertI8x16Low) \ ++ V(RiscvI16x8UConvertI8x16High) \ ++ V(RiscvI8x16SConvertI16x8) \ ++ V(RiscvI8x16UConvertI16x8) \ ++ V(RiscvWord64AtomicLoadUint8) \ ++ V(RiscvWord64AtomicLoadUint16) \ ++ V(RiscvWord64AtomicLoadUint32) \ ++ V(RiscvWord64AtomicLoadUint64) \ ++ V(RiscvWord64AtomicStoreWord8) \ ++ V(RiscvWord64AtomicStoreWord16) \ ++ V(RiscvWord64AtomicStoreWord32) \ ++ V(RiscvWord64AtomicStoreWord64) \ ++ V(RiscvWord64AtomicAddUint8) \ ++ V(RiscvWord64AtomicAddUint16) \ ++ V(RiscvWord64AtomicAddUint32) \ ++ V(RiscvWord64AtomicAddUint64) \ ++ V(RiscvWord64AtomicSubUint8) \ ++ V(RiscvWord64AtomicSubUint16) \ ++ V(RiscvWord64AtomicSubUint32) \ ++ V(RiscvWord64AtomicSubUint64) \ ++ V(RiscvWord64AtomicAndUint8) \ ++ V(RiscvWord64AtomicAndUint16) \ ++ V(RiscvWord64AtomicAndUint32) \ ++ V(RiscvWord64AtomicAndUint64) \ ++ V(RiscvWord64AtomicOrUint8) \ ++ V(RiscvWord64AtomicOrUint16) \ ++ V(RiscvWord64AtomicOrUint32) \ ++ V(RiscvWord64AtomicOrUint64) \ ++ V(RiscvWord64AtomicXorUint8) \ ++ V(RiscvWord64AtomicXorUint16) \ ++ V(RiscvWord64AtomicXorUint32) \ ++ V(RiscvWord64AtomicXorUint64) \ ++ V(RiscvWord64AtomicExchangeUint8) \ ++ V(RiscvWord64AtomicExchangeUint16) \ ++ V(RiscvWord64AtomicExchangeUint32) \ ++ V(RiscvWord64AtomicExchangeUint64) \ ++ V(RiscvWord64AtomicCompareExchangeUint8) \ ++ V(RiscvWord64AtomicCompareExchangeUint16) \ ++ V(RiscvWord64AtomicCompareExchangeUint32) \ ++ V(RiscvWord64AtomicCompareExchangeUint64) ++ ++// Addressing modes represent the "shape" of inputs to an instruction. ++// Many instructions support multiple addressing modes. Addressing modes ++// are encoded into the InstructionCode of the instruction and tell the ++// code generator after register allocation which assembler method to call. ++// ++// We use the following local notation for addressing modes: ++// ++// R = register ++// O = register or stack slot ++// D = double register ++// I = immediate (handle, external, int32) ++// MRI = [register + immediate] ++// MRR = [register + register] ++// TODO(plind): Add the new r6 address modes. ++#define TARGET_ADDRESSING_MODE_LIST(V) \ ++ V(MRI) /* [%r0 + K] */ \ ++ V(MRR) /* [%r0 + %r1] */ ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_COMPILER_BACKEND_RISCV_INSTRUCTION_CODES_RISCV_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-scheduler-riscv64.cc +@@ -0,0 +1,1571 @@ ++// Copyright 2015 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/compiler/backend/instruction-scheduler.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++bool InstructionScheduler::SchedulerSupported() { return true; } ++ ++int InstructionScheduler::GetTargetInstructionFlags( ++ const Instruction* instr) const { ++ switch (instr->arch_opcode()) { ++ case kRiscvAbsD: ++ case kRiscvAbsS: ++ case kRiscvAdd32: ++ case kRiscvAddD: ++ case kRiscvAddS: ++ case kRiscvAnd: ++ case kRiscvAnd32: ++ case kRiscvAssertEqual: ++ case kRiscvBitcastDL: ++ case kRiscvBitcastLD: ++ case kRiscvBitcastInt32ToFloat32: ++ case kRiscvBitcastFloat32ToInt32: ++ case kRiscvByteSwap32: ++ case kRiscvByteSwap64: ++ case kRiscvCeilWD: ++ case kRiscvCeilWS: ++ case kRiscvClz32: ++ case kRiscvCmp: ++ case kRiscvCmpD: ++ case kRiscvCmpS: ++ case kRiscvCtz32: ++ case kRiscvCvtDL: ++ case kRiscvCvtDS: ++ case kRiscvCvtDUl: ++ case kRiscvCvtDUw: ++ case kRiscvCvtDW: ++ case kRiscvCvtSD: ++ case kRiscvCvtSL: ++ case kRiscvCvtSUl: ++ case kRiscvCvtSUw: ++ case kRiscvCvtSW: ++ case kRiscvMulHigh64: ++ case kRiscvMulHighU32: ++ case kRiscvAdd64: ++ case kRiscvAddOvf64: ++ case kRiscvClz64: ++ case kRiscvCtz64: ++ case kRiscvDiv64: ++ case kRiscvDivU64: ++ case kRiscvZeroExtendWord: ++ case kRiscvSignExtendWord: ++ case kRiscvDiv32: ++ case kRiscvDivD: ++ case kRiscvDivS: ++ case kRiscvDivU32: ++ case kRiscvMod64: ++ case kRiscvModU64: ++ case kRiscvMul64: ++ case kRiscvPopcnt64: ++ case kRiscvRor64: ++ case kRiscvSar64: ++ case kRiscvShl64: ++ case kRiscvShr64: ++ case kRiscvSub64: ++ case kRiscvSubOvf64: ++ case kRiscvF64x2Abs: ++ case kRiscvF64x2Neg: ++ case kRiscvF64x2Sqrt: ++ case kRiscvF64x2Add: ++ case kRiscvF64x2Sub: ++ case kRiscvF64x2Mul: ++ case kRiscvF64x2Div: ++ case kRiscvF64x2Min: ++ case kRiscvF64x2Max: ++ case kRiscvF64x2Eq: ++ case kRiscvF64x2Ne: ++ case kRiscvF64x2Lt: ++ case kRiscvF64x2Le: ++ case kRiscvF64x2Pmin: ++ case kRiscvF64x2Pmax: ++ case kRiscvF64x2Ceil: ++ case kRiscvF64x2Floor: ++ case kRiscvF64x2Trunc: ++ case kRiscvF64x2NearestInt: ++ case kRiscvI64x2Splat: ++ case kRiscvI64x2ExtractLane: ++ case kRiscvI64x2ReplaceLane: ++ case kRiscvI64x2Add: ++ case kRiscvI64x2Sub: ++ case kRiscvI64x2Mul: ++ case kRiscvI64x2Neg: ++ case kRiscvI64x2Shl: ++ case kRiscvI64x2ShrS: ++ case kRiscvI64x2ShrU: ++ case kRiscvF32x4Abs: ++ case kRiscvF32x4Add: ++ case kRiscvF32x4AddHoriz: ++ case kRiscvF32x4Eq: ++ case kRiscvF32x4ExtractLane: ++ case kRiscvF32x4Lt: ++ case kRiscvF32x4Le: ++ case kRiscvF32x4Max: ++ case kRiscvF32x4Min: ++ case kRiscvF32x4Mul: ++ case kRiscvF32x4Div: ++ case kRiscvF32x4Ne: ++ case kRiscvF32x4Neg: ++ case kRiscvF32x4Sqrt: ++ case kRiscvF32x4RecipApprox: ++ case kRiscvF32x4RecipSqrtApprox: ++ case kRiscvF32x4ReplaceLane: ++ case kRiscvF32x4SConvertI32x4: ++ case kRiscvF32x4Splat: ++ case kRiscvF32x4Sub: ++ case kRiscvF32x4UConvertI32x4: ++ case kRiscvF32x4Pmin: ++ case kRiscvF32x4Pmax: ++ case kRiscvF32x4Ceil: ++ case kRiscvF32x4Floor: ++ case kRiscvF32x4Trunc: ++ case kRiscvF32x4NearestInt: ++ case kRiscvF64x2Splat: ++ case kRiscvF64x2ExtractLane: ++ case kRiscvF64x2ReplaceLane: ++ case kRiscvFloat32Max: ++ case kRiscvFloat32Min: ++ case kRiscvFloat32RoundDown: ++ case kRiscvFloat32RoundTiesEven: ++ case kRiscvFloat32RoundTruncate: ++ case kRiscvFloat32RoundUp: ++ case kRiscvFloat64ExtractLowWord32: ++ case kRiscvFloat64ExtractHighWord32: ++ case kRiscvFloat64InsertLowWord32: ++ case kRiscvFloat64InsertHighWord32: ++ case kRiscvFloat64Max: ++ case kRiscvFloat64Min: ++ case kRiscvFloat64RoundDown: ++ case kRiscvFloat64RoundTiesEven: ++ case kRiscvFloat64RoundTruncate: ++ case kRiscvFloat64RoundUp: ++ case kRiscvFloat64SilenceNaN: ++ case kRiscvFloorWD: ++ case kRiscvFloorWS: ++ case kRiscvI16x8Add: ++ case kRiscvI16x8AddHoriz: ++ case kRiscvI16x8AddSaturateS: ++ case kRiscvI16x8AddSaturateU: ++ case kRiscvI16x8Eq: ++ case kRiscvI16x8ExtractLaneU: ++ case kRiscvI16x8ExtractLaneS: ++ case kRiscvI16x8GeS: ++ case kRiscvI16x8GeU: ++ case kRiscvI16x8GtS: ++ case kRiscvI16x8GtU: ++ case kRiscvI16x8MaxS: ++ case kRiscvI16x8MaxU: ++ case kRiscvI16x8MinS: ++ case kRiscvI16x8MinU: ++ case kRiscvI16x8Mul: ++ case kRiscvI16x8Ne: ++ case kRiscvI16x8Neg: ++ case kRiscvI16x8ReplaceLane: ++ case kRiscvI8x16SConvertI16x8: ++ case kRiscvI16x8SConvertI32x4: ++ case kRiscvI16x8SConvertI8x16High: ++ case kRiscvI16x8SConvertI8x16Low: ++ case kRiscvI16x8Shl: ++ case kRiscvI16x8ShrS: ++ case kRiscvI16x8ShrU: ++ case kRiscvI16x8Splat: ++ case kRiscvI16x8Sub: ++ case kRiscvI16x8SubSaturateS: ++ case kRiscvI16x8SubSaturateU: ++ case kRiscvI8x16UConvertI16x8: ++ case kRiscvI16x8UConvertI32x4: ++ case kRiscvI16x8UConvertI8x16High: ++ case kRiscvI16x8UConvertI8x16Low: ++ case kRiscvI16x8RoundingAverageU: ++ case kRiscvI16x8Abs: ++ case kRiscvI16x8BitMask: ++ case kRiscvI32x4Add: ++ case kRiscvI32x4AddHoriz: ++ case kRiscvI32x4Eq: ++ case kRiscvI32x4ExtractLane: ++ case kRiscvI32x4GeS: ++ case kRiscvI32x4GeU: ++ case kRiscvI32x4GtS: ++ case kRiscvI32x4GtU: ++ case kRiscvI32x4MaxS: ++ case kRiscvI32x4MaxU: ++ case kRiscvI32x4MinS: ++ case kRiscvI32x4MinU: ++ case kRiscvI32x4Mul: ++ case kRiscvI32x4Ne: ++ case kRiscvI32x4Neg: ++ case kRiscvI32x4ReplaceLane: ++ case kRiscvI32x4SConvertF32x4: ++ case kRiscvI32x4SConvertI16x8High: ++ case kRiscvI32x4SConvertI16x8Low: ++ case kRiscvI32x4Shl: ++ case kRiscvI32x4ShrS: ++ case kRiscvI32x4ShrU: ++ case kRiscvI32x4Splat: ++ case kRiscvI32x4Sub: ++ case kRiscvI32x4UConvertF32x4: ++ case kRiscvI32x4UConvertI16x8High: ++ case kRiscvI32x4UConvertI16x8Low: ++ case kRiscvI32x4Abs: ++ case kRiscvI32x4BitMask: ++ case kRiscvI8x16Add: ++ case kRiscvI8x16AddSaturateS: ++ case kRiscvI8x16AddSaturateU: ++ case kRiscvI8x16Eq: ++ case kRiscvI8x16ExtractLaneU: ++ case kRiscvI8x16ExtractLaneS: ++ case kRiscvI8x16GeS: ++ case kRiscvI8x16GeU: ++ case kRiscvI8x16GtS: ++ case kRiscvI8x16GtU: ++ case kRiscvI8x16MaxS: ++ case kRiscvI8x16MaxU: ++ case kRiscvI8x16MinS: ++ case kRiscvI8x16MinU: ++ case kRiscvI8x16Mul: ++ case kRiscvI8x16Ne: ++ case kRiscvI8x16Neg: ++ case kRiscvI8x16ReplaceLane: ++ case kRiscvI8x16Shl: ++ case kRiscvI8x16ShrS: ++ case kRiscvI8x16ShrU: ++ case kRiscvI8x16Splat: ++ case kRiscvI8x16Sub: ++ case kRiscvI8x16SubSaturateS: ++ case kRiscvI8x16SubSaturateU: ++ case kRiscvI8x16RoundingAverageU: ++ case kRiscvI8x16Abs: ++ case kRiscvI8x16BitMask: ++ case kRiscvMaxD: ++ case kRiscvMaxS: ++ case kRiscvMinD: ++ case kRiscvMinS: ++ case kRiscvMod32: ++ case kRiscvModU32: ++ case kRiscvMov: ++ case kRiscvMul32: ++ case kRiscvMulD: ++ case kRiscvMulHigh32: ++ case kRiscvMulOvf32: ++ case kRiscvMulS: ++ case kRiscvNegD: ++ case kRiscvNegS: ++ case kRiscvNor: ++ case kRiscvNor32: ++ case kRiscvOr: ++ case kRiscvOr32: ++ case kRiscvPopcnt32: ++ case kRiscvRor32: ++ case kRiscvRoundWD: ++ case kRiscvRoundWS: ++ case kRiscvS128And: ++ case kRiscvS128Or: ++ case kRiscvS128Not: ++ case kRiscvS128Select: ++ case kRiscvS128AndNot: ++ case kRiscvS128Xor: ++ case kRiscvS128Const: ++ case kRiscvS128Zero: ++ case kRiscvS128AllOnes: ++ case kRiscvS16x8InterleaveEven: ++ case kRiscvS16x8InterleaveOdd: ++ case kRiscvS16x8InterleaveLeft: ++ case kRiscvS16x8InterleaveRight: ++ case kRiscvS16x8PackEven: ++ case kRiscvS16x8PackOdd: ++ case kRiscvS16x2Reverse: ++ case kRiscvS16x4Reverse: ++ case kRiscvV8x16AllTrue: ++ case kRiscvV8x16AnyTrue: ++ case kRiscvV32x4AllTrue: ++ case kRiscvV32x4AnyTrue: ++ case kRiscvV16x8AllTrue: ++ case kRiscvV16x8AnyTrue: ++ case kRiscvS32x4InterleaveEven: ++ case kRiscvS32x4InterleaveOdd: ++ case kRiscvS32x4InterleaveLeft: ++ case kRiscvS32x4InterleaveRight: ++ case kRiscvS32x4PackEven: ++ case kRiscvS32x4PackOdd: ++ case kRiscvS32x4Shuffle: ++ case kRiscvS8x16Concat: ++ case kRiscvS8x16InterleaveEven: ++ case kRiscvS8x16InterleaveOdd: ++ case kRiscvS8x16InterleaveLeft: ++ case kRiscvS8x16InterleaveRight: ++ case kRiscvS8x16PackEven: ++ case kRiscvS8x16PackOdd: ++ case kRiscvS8x2Reverse: ++ case kRiscvS8x4Reverse: ++ case kRiscvS8x8Reverse: ++ case kRiscvI8x16Shuffle: ++ case kRiscvI8x16Swizzle: ++ case kRiscvSar32: ++ case kRiscvSignExtendByte: ++ case kRiscvSignExtendShort: ++ case kRiscvShl32: ++ case kRiscvShr32: ++ case kRiscvSqrtD: ++ case kRiscvSqrtS: ++ case kRiscvSub32: ++ case kRiscvSubD: ++ case kRiscvSubS: ++ case kRiscvTruncLD: ++ case kRiscvTruncLS: ++ case kRiscvTruncUlD: ++ case kRiscvTruncUlS: ++ case kRiscvTruncUwD: ++ case kRiscvTruncUwS: ++ case kRiscvTruncWD: ++ case kRiscvTruncWS: ++ case kRiscvTst: ++ case kRiscvXor: ++ case kRiscvXor32: ++ return kNoOpcodeFlags; ++ ++ case kRiscvLb: ++ case kRiscvLbu: ++ case kRiscvLd: ++ case kRiscvLoadDouble: ++ case kRiscvLh: ++ case kRiscvLhu: ++ case kRiscvLw: ++ case kRiscvLoadFloat: ++ case kRiscvLwu: ++ case kRiscvMsaLd: ++ case kRiscvPeek: ++ case kRiscvUld: ++ case kRiscvULoadDouble: ++ case kRiscvUlh: ++ case kRiscvUlhu: ++ case kRiscvUlw: ++ case kRiscvUlwu: ++ case kRiscvULoadFloat: ++ case kRiscvS8x16LoadSplat: ++ case kRiscvS16x8LoadSplat: ++ case kRiscvS32x4LoadSplat: ++ case kRiscvS64x2LoadSplat: ++ case kRiscvI16x8Load8x8S: ++ case kRiscvI16x8Load8x8U: ++ case kRiscvI32x4Load16x4S: ++ case kRiscvI32x4Load16x4U: ++ case kRiscvI64x2Load32x2S: ++ case kRiscvI64x2Load32x2U: ++ case kRiscvWord64AtomicLoadUint8: ++ case kRiscvWord64AtomicLoadUint16: ++ case kRiscvWord64AtomicLoadUint32: ++ case kRiscvWord64AtomicLoadUint64: ++ ++ return kIsLoadOperation; ++ ++ case kRiscvModD: ++ case kRiscvModS: ++ case kRiscvMsaSt: ++ case kRiscvPush: ++ case kRiscvSb: ++ case kRiscvSd: ++ case kRiscvStoreDouble: ++ case kRiscvSh: ++ case kRiscvStackClaim: ++ case kRiscvStoreToStackSlot: ++ case kRiscvSw: ++ case kRiscvStoreFloat: ++ case kRiscvUsd: ++ case kRiscvUStoreDouble: ++ case kRiscvUsh: ++ case kRiscvUsw: ++ case kRiscvUStoreFloat: ++ case kRiscvSync: ++ case kRiscvWord64AtomicStoreWord8: ++ case kRiscvWord64AtomicStoreWord16: ++ case kRiscvWord64AtomicStoreWord32: ++ case kRiscvWord64AtomicStoreWord64: ++ case kRiscvWord64AtomicAddUint8: ++ case kRiscvWord64AtomicAddUint16: ++ case kRiscvWord64AtomicAddUint32: ++ case kRiscvWord64AtomicAddUint64: ++ case kRiscvWord64AtomicSubUint8: ++ case kRiscvWord64AtomicSubUint16: ++ case kRiscvWord64AtomicSubUint32: ++ case kRiscvWord64AtomicSubUint64: ++ case kRiscvWord64AtomicAndUint8: ++ case kRiscvWord64AtomicAndUint16: ++ case kRiscvWord64AtomicAndUint32: ++ case kRiscvWord64AtomicAndUint64: ++ case kRiscvWord64AtomicOrUint8: ++ case kRiscvWord64AtomicOrUint16: ++ case kRiscvWord64AtomicOrUint32: ++ case kRiscvWord64AtomicOrUint64: ++ case kRiscvWord64AtomicXorUint8: ++ case kRiscvWord64AtomicXorUint16: ++ case kRiscvWord64AtomicXorUint32: ++ case kRiscvWord64AtomicXorUint64: ++ case kRiscvWord64AtomicExchangeUint8: ++ case kRiscvWord64AtomicExchangeUint16: ++ case kRiscvWord64AtomicExchangeUint32: ++ case kRiscvWord64AtomicExchangeUint64: ++ case kRiscvWord64AtomicCompareExchangeUint8: ++ case kRiscvWord64AtomicCompareExchangeUint16: ++ case kRiscvWord64AtomicCompareExchangeUint32: ++ case kRiscvWord64AtomicCompareExchangeUint64: ++ return kHasSideEffect; ++ ++#define CASE(Name) case k##Name: ++ COMMON_ARCH_OPCODE_LIST(CASE) ++#undef CASE ++ // Already covered in architecture independent code. ++ UNREACHABLE(); ++ } ++ ++ UNREACHABLE(); ++} ++ ++enum Latency { ++ BRANCH = 4, // Estimated max. ++ RINT_S = 4, // Estimated. ++ RINT_D = 4, // Estimated. ++ ++ // FIXME (RISCV): remove MULT instructions (MIPS legacy) ++ MULT = 4, ++ MULTU = 4, ++ DMULT = 4, ++ ++ MUL32 = 7, ++ ++ DIV32 = 50, // Min:11 Max:50 ++ DIV64 = 50, ++ DIVU32 = 50, ++ DIVU64 = 50, ++ ++ ABS_S = 4, ++ ABS_D = 4, ++ NEG_S = 4, ++ NEG_D = 4, ++ ADD_S = 4, ++ ADD_D = 4, ++ SUB_S = 4, ++ SUB_D = 4, ++ MAX_S = 4, // Estimated. ++ MIN_S = 4, ++ MAX_D = 4, // Estimated. ++ MIN_D = 4, ++ C_cond_S = 4, ++ C_cond_D = 4, ++ MUL_S = 4, ++ ++ MADD_S = 4, ++ MSUB_S = 4, ++ NMADD_S = 4, ++ NMSUB_S = 4, ++ ++ CABS_cond_S = 4, ++ CABS_cond_D = 4, ++ ++ CVT_D_S = 4, ++ CVT_PS_PW = 4, ++ ++ CVT_S_W = 4, ++ CVT_S_L = 4, ++ CVT_D_W = 4, ++ CVT_D_L = 4, ++ ++ CVT_S_D = 4, ++ ++ CVT_W_S = 4, ++ CVT_W_D = 4, ++ CVT_L_S = 4, ++ CVT_L_D = 4, ++ ++ CEIL_W_S = 4, ++ CEIL_W_D = 4, ++ CEIL_L_S = 4, ++ CEIL_L_D = 4, ++ ++ FLOOR_W_S = 4, ++ FLOOR_W_D = 4, ++ FLOOR_L_S = 4, ++ FLOOR_L_D = 4, ++ ++ ROUND_W_S = 4, ++ ROUND_W_D = 4, ++ ROUND_L_S = 4, ++ ROUND_L_D = 4, ++ ++ TRUNC_W_S = 4, ++ TRUNC_W_D = 4, ++ TRUNC_L_S = 4, ++ TRUNC_L_D = 4, ++ ++ MOV_S = 4, ++ MOV_D = 4, ++ ++ MOVF_S = 4, ++ MOVF_D = 4, ++ ++ MOVN_S = 4, ++ MOVN_D = 4, ++ ++ MOVT_S = 4, ++ MOVT_D = 4, ++ ++ MOVZ_S = 4, ++ MOVZ_D = 4, ++ ++ MUL_D = 5, ++ MADD_D = 5, ++ MSUB_D = 5, ++ NMADD_D = 5, ++ NMSUB_D = 5, ++ ++ RECIP_S = 13, ++ RECIP_D = 26, ++ ++ RSQRT_S = 17, ++ RSQRT_D = 36, ++ ++ DIV_S = 17, ++ SQRT_S = 17, ++ ++ DIV_D = 32, ++ SQRT_D = 32, ++ ++ MOVT_FREG = 4, ++ MOVT_HIGH_FREG = 4, ++ MOVT_DREG = 4, ++ LOAD_FLOAT = 4, ++ LOAD_DOUBLE = 4, ++ ++ MOVF_FREG = 1, ++ MOVF_HIGH_FREG = 1, ++ MOVF_HIGH_DREG = 1, ++ MOVF_HIGH = 1, ++ MOVF_LOW = 1, ++ STORE_FLOAT = 1, ++ STORE_DOUBLE = 1, ++}; ++ ++int Add64Latency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int Sub64Latency(bool is_operand_register = true) { ++ return Add64Latency(is_operand_register); ++} ++ ++int AndLatency(bool is_operand_register = true) { ++ return Add64Latency(is_operand_register); ++} ++ ++int OrLatency(bool is_operand_register = true) { ++ return Add64Latency(is_operand_register); ++} ++ ++int NorLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int XorLatency(bool is_operand_register = true) { ++ return Add64Latency(is_operand_register); ++} ++ ++int Mul32Latency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::MUL32; ++ } else { ++ return Latency::MUL32 + 1; ++ } ++} ++ ++int Mul64Latency(bool is_operand_register = true) { ++ int latency = Latency::DMULT + Latency::MOVF_LOW; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Mulh32Latency(bool is_operand_register = true) { ++ int latency = Latency::MULT + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Mulhu32Latency(bool is_operand_register = true) { ++ int latency = Latency::MULTU + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Mulh64Latency(bool is_operand_register = true) { ++ int latency = Latency::DMULT + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Div32Latency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::DIV32; ++ } else { ++ return Latency::DIV32 + 1; ++ } ++} ++ ++int Divu32Latency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return Latency::DIVU32; ++ } else { ++ return Latency::DIVU32 + 1; ++ } ++} ++ ++int Div64Latency(bool is_operand_register = true) { ++ int latency = Latency::DIV64 + Latency::MOVF_LOW; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Divu64Latency(bool is_operand_register = true) { ++ int latency = Latency::DIVU64 + Latency::MOVF_LOW; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Mod32Latency(bool is_operand_register = true) { ++ int latency = Latency::DIV32 + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Modu32Latency(bool is_operand_register = true) { ++ int latency = Latency::DIVU32 + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Mod64Latency(bool is_operand_register = true) { ++ int latency = Latency::DIV64 + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int Modu64Latency(bool is_operand_register = true) { ++ int latency = Latency::DIV64 + Latency::MOVF_HIGH; ++ if (!is_operand_register) { ++ latency += 1; ++ } ++ return latency; ++} ++ ++int MovzLatency() { return 1; } ++ ++int MovnLatency() { return 1; } ++ ++int CallLatency() { ++ // Estimated. ++ return Add64Latency(false) + Latency::BRANCH + 5; ++} ++ ++int JumpLatency() { ++ // Estimated max. ++ return 1 + Add64Latency() + Latency::BRANCH + 2; ++} ++ ++int SmiUntagLatency() { return 1; } ++ ++int PrepareForTailCallLatency() { ++ // Estimated max. ++ return 2 * (Add64Latency() + 1 + Add64Latency(false)) + 2 + Latency::BRANCH + ++ Latency::BRANCH + 2 * Sub64Latency(false) + 2 + Latency::BRANCH + 1; ++} ++ ++int AssemblePopArgumentsAdoptFrameLatency() { ++ return 1 + Latency::BRANCH + 1 + SmiUntagLatency() + ++ PrepareForTailCallLatency(); ++} ++ ++int AssertLatency() { return 1; } ++ ++int PrepareCallCFunctionLatency() { ++ int frame_alignment = TurboAssembler::ActivationFrameAlignment(); ++ if (frame_alignment > kSystemPointerSize) { ++ return 1 + Sub64Latency(false) + AndLatency(false) + 1; ++ } else { ++ return Sub64Latency(false); ++ } ++} ++ ++int AdjustBaseAndOffsetLatency() { ++ return 3; // Estimated max. ++} ++ ++int AlignedMemoryLatency() { return AdjustBaseAndOffsetLatency() + 1; } ++ ++int UlhuLatency() { ++ return AdjustBaseAndOffsetLatency() + 2 * AlignedMemoryLatency() + 2; ++} ++ ++int UlwLatency() { ++ // Estimated max. ++ return AdjustBaseAndOffsetLatency() + 3; ++} ++ ++int UlwuLatency() { return UlwLatency() + 1; } ++ ++int UldLatency() { ++ // Estimated max. ++ return AdjustBaseAndOffsetLatency() + 3; ++} ++ ++int ULoadFloatLatency() { return UlwLatency() + Latency::MOVT_FREG; } ++ ++int ULoadDoubleLatency() { return UldLatency() + Latency::MOVT_DREG; } ++ ++int UshLatency() { ++ // Estimated max. ++ return AdjustBaseAndOffsetLatency() + 2 + 2 * AlignedMemoryLatency(); ++} ++ ++int UswLatency() { return AdjustBaseAndOffsetLatency() + 2; } ++ ++int UsdLatency() { return AdjustBaseAndOffsetLatency() + 2; } ++ ++int UStoreFloatLatency() { return Latency::MOVF_FREG + UswLatency(); } ++ ++int UStoreDoubleLatency() { return Latency::MOVF_HIGH_DREG + UsdLatency(); } ++ ++int LoadFloatLatency() { ++ return AdjustBaseAndOffsetLatency() + Latency::LOAD_FLOAT; ++} ++ ++int StoreFloatLatency() { ++ return AdjustBaseAndOffsetLatency() + Latency::STORE_FLOAT; ++} ++ ++int StoreDoubleLatency() { ++ return AdjustBaseAndOffsetLatency() + Latency::STORE_DOUBLE; ++} ++ ++int LoadDoubleLatency() { ++ return AdjustBaseAndOffsetLatency() + Latency::LOAD_DOUBLE; ++} ++ ++int MultiPushLatency() { ++ int latency = Sub64Latency(false); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ latency++; ++ } ++ return latency; ++} ++ ++int MultiPushFPULatency() { ++ int latency = Sub64Latency(false); ++ for (int16_t i = kNumRegisters - 1; i >= 0; i--) { ++ latency += StoreDoubleLatency(); ++ } ++ return latency; ++} ++ ++int PushCallerSavedLatency(SaveFPRegsMode fp_mode) { ++ int latency = MultiPushLatency(); ++ if (fp_mode == kSaveFPRegs) { ++ latency += MultiPushFPULatency(); ++ } ++ return latency; ++} ++ ++int MultiPopLatency() { ++ int latency = Add64Latency(false); ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ latency++; ++ } ++ return latency; ++} ++ ++int MultiPopFPULatency() { ++ int latency = Add64Latency(false); ++ for (int16_t i = 0; i < kNumRegisters; i++) { ++ latency += LoadDoubleLatency(); ++ } ++ return latency; ++} ++ ++int PopCallerSavedLatency(SaveFPRegsMode fp_mode) { ++ int latency = MultiPopLatency(); ++ if (fp_mode == kSaveFPRegs) { ++ latency += MultiPopFPULatency(); ++ } ++ return latency; ++} ++ ++int CallCFunctionHelperLatency() { ++ // Estimated. ++ int latency = AndLatency(false) + Latency::BRANCH + 2 + CallLatency(); ++ if (base::OS::ActivationFrameAlignment() > kSystemPointerSize) { ++ latency++; ++ } else { ++ latency += Add64Latency(false); ++ } ++ return latency; ++} ++ ++int CallCFunctionLatency() { return 1 + CallCFunctionHelperLatency(); } ++ ++int AssembleArchJumpLatency() { ++ // Estimated max. ++ return Latency::BRANCH; ++} ++ ++int GenerateSwitchTableLatency() { ++ int latency = 6; ++ latency += 2; ++ return latency; ++} ++ ++int AssembleArchTableSwitchLatency() { ++ return Latency::BRANCH + GenerateSwitchTableLatency(); ++} ++ ++int DropAndRetLatency() { ++ // Estimated max. ++ return Add64Latency(false) + JumpLatency(); ++} ++ ++int AssemblerReturnLatency() { ++ // Estimated max. ++ return Add64Latency(false) + MultiPopLatency() + MultiPopFPULatency() + ++ Latency::BRANCH + Add64Latency() + 1 + DropAndRetLatency(); ++} ++ ++int TryInlineTruncateDoubleToILatency() { ++ return 2 + Latency::TRUNC_W_D + Latency::MOVF_FREG + 2 + AndLatency(false) + ++ Latency::BRANCH; ++} ++ ++int CallStubDelayedLatency() { return 1 + CallLatency(); } ++ ++int TruncateDoubleToIDelayedLatency() { ++ // TODO(riscv): This no longer reflects how TruncateDoubleToI is called. ++ return TryInlineTruncateDoubleToILatency() + 1 + Sub64Latency(false) + ++ StoreDoubleLatency() + CallStubDelayedLatency() + Add64Latency(false) + ++ 1; ++} ++ ++int CheckPageFlagLatency() { ++ return AndLatency(false) + AlignedMemoryLatency() + AndLatency(false) + ++ Latency::BRANCH; ++} ++ ++int SltuLatency(bool is_operand_register = true) { ++ if (is_operand_register) { ++ return 1; ++ } else { ++ return 2; // Estimated max. ++ } ++} ++ ++int BranchShortHelperLatency() { ++ return SltuLatency() + 2; // Estimated max. ++} ++ ++int BranchShortLatency() { return BranchShortHelperLatency(); } ++ ++int MoveLatency() { return 1; } ++ ++int MovToFloatParametersLatency() { return 2 * MoveLatency(); } ++ ++int MovFromFloatResultLatency() { return MoveLatency(); } ++ ++int AddOverflow64Latency() { ++ // Estimated max. ++ return 6; ++} ++ ++int SubOverflow64Latency() { ++ // Estimated max. ++ return 6; ++} ++ ++int MulOverflow32Latency() { ++ // Estimated max. ++ return Mul32Latency() + Mulh32Latency() + 2; ++} ++ ++// FIXME (RISCV): need update ++int Clz64Latency() { return 1; } ++ ++int Ctz32Latency() { ++ return Add64Latency(false) + XorLatency() + AndLatency() + Clz64Latency() + ++ 1 + Sub64Latency(); ++} ++ ++int Ctz64Latency() { ++ return Add64Latency(false) + XorLatency() + AndLatency() + 1 + Sub64Latency(); ++} ++ ++int Popcnt32Latency() { ++ return 2 + AndLatency() + Sub64Latency() + 1 + AndLatency() + 1 + ++ AndLatency() + Add64Latency() + 1 + Add64Latency() + 1 + AndLatency() + ++ 1 + Mul32Latency() + 1; ++} ++ ++int Popcnt64Latency() { ++ return 2 + AndLatency() + Sub64Latency() + 1 + AndLatency() + 1 + ++ AndLatency() + Add64Latency() + 1 + Add64Latency() + 1 + AndLatency() + ++ 1 + Mul64Latency() + 1; ++} ++ ++int CompareFLatency() { return Latency::C_cond_S; } ++ ++int CompareF32Latency() { return CompareFLatency(); } ++ ++int CompareF64Latency() { return CompareFLatency(); } ++ ++int CompareIsNanFLatency() { return CompareFLatency(); } ++ ++int CompareIsNanF32Latency() { return CompareIsNanFLatency(); } ++ ++int CompareIsNanF64Latency() { return CompareIsNanFLatency(); } ++ ++int NegsLatency() { ++ // Estimated. ++ return CompareIsNanF32Latency() + 2 * Latency::BRANCH + Latency::NEG_S + ++ Latency::MOVF_FREG + 1 + XorLatency() + Latency::MOVT_FREG; ++} ++ ++int NegdLatency() { ++ // Estimated. ++ return CompareIsNanF64Latency() + 2 * Latency::BRANCH + Latency::NEG_D + ++ Latency::MOVF_HIGH_DREG + 1 + XorLatency() + Latency::MOVT_DREG; ++} ++ ++int Float64RoundLatency() { ++ // For ceil_l_d, floor_l_d, round_l_d, trunc_l_d latency is 4. ++ return Latency::MOVF_HIGH_DREG + 1 + Latency::BRANCH + Latency::MOV_D + 4 + ++ Latency::MOVF_HIGH_DREG + Latency::BRANCH + Latency::CVT_D_L + 2 + ++ Latency::MOVT_HIGH_FREG; ++} ++ ++int Float32RoundLatency() { ++ // For ceil_w_s, floor_w_s, round_w_s, trunc_w_s latency is 4. ++ return Latency::MOVF_FREG + 1 + Latency::BRANCH + Latency::MOV_S + 4 + ++ Latency::MOVF_FREG + Latency::BRANCH + Latency::CVT_S_W + 2 + ++ Latency::MOVT_FREG; ++} ++ ++int Float32MaxLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF32Latency() + Latency::BRANCH; ++ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + ++ Latency::MOVF_FREG + 1 + Latency::MOV_S; ++} ++ ++int Float64MaxLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF64Latency() + Latency::BRANCH; ++ return latency + 5 * Latency::BRANCH + 2 * CompareF64Latency() + ++ Latency::MOVF_HIGH_DREG + Latency::MOV_D; ++} ++ ++int Float32MinLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF32Latency() + Latency::BRANCH; ++ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + ++ Latency::MOVF_FREG + 1 + Latency::MOV_S; ++} ++ ++int Float64MinLatency() { ++ // Estimated max. ++ int latency = CompareIsNanF64Latency() + Latency::BRANCH; ++ return latency + 5 * Latency::BRANCH + 2 * CompareF32Latency() + ++ Latency::MOVF_HIGH_DREG + Latency::MOV_D; ++} ++ ++int TruncLSLatency(bool load_status) { ++ int latency = Latency::TRUNC_L_S + Latency::MOVF_HIGH_DREG; ++ if (load_status) { ++ latency += SltuLatency() + 7; ++ } ++ return latency; ++} ++ ++int TruncLDLatency(bool load_status) { ++ int latency = Latency::TRUNC_L_D + Latency::MOVF_HIGH_DREG; ++ if (load_status) { ++ latency += SltuLatency() + 7; ++ } ++ return latency; ++} ++ ++int TruncUlSLatency() { ++ // Estimated max. ++ return 2 * CompareF32Latency() + CompareIsNanF32Latency() + ++ 4 * Latency::BRANCH + Latency::SUB_S + 2 * Latency::TRUNC_L_S + ++ 3 * Latency::MOVF_HIGH_DREG + OrLatency() + Latency::MOVT_FREG + ++ Latency::MOV_S + SltuLatency() + 4; ++} ++ ++int TruncUlDLatency() { ++ // Estimated max. ++ return 2 * CompareF64Latency() + CompareIsNanF64Latency() + ++ 4 * Latency::BRANCH + Latency::SUB_D + 2 * Latency::TRUNC_L_D + ++ 3 * Latency::MOVF_HIGH_DREG + OrLatency() + Latency::MOVT_DREG + ++ Latency::MOV_D + SltuLatency() + 4; ++} ++ ++int PushLatency() { return Add64Latency() + AlignedMemoryLatency(); } ++ ++int ByteSwapSignedLatency() { return 2; } ++ ++int LlLatency(int offset) { ++ bool is_one_instruction = is_int12(offset); ++ if (is_one_instruction) { ++ return 1; ++ } else { ++ return 3; ++ } ++} ++ ++int ExtractBitsLatency(bool sign_extend, int size) { ++ int latency = 2; ++ if (sign_extend) { ++ switch (size) { ++ case 8: ++ case 16: ++ case 32: ++ latency += 1; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++ return latency; ++} ++ ++int InsertBitsLatency() { return 2 + Sub64Latency(false) + 2; } ++ ++int ScLatency(int offset) { return 3; } ++ ++int Word32AtomicExchangeLatency(bool sign_extend, int size) { ++ return Add64Latency(false) + 1 + Sub64Latency() + 2 + LlLatency(0) + ++ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + ++ ScLatency(0) + BranchShortLatency() + 1; ++} ++ ++int Word32AtomicCompareExchangeLatency(bool sign_extend, int size) { ++ return 2 + Sub64Latency() + 2 + LlLatency(0) + ++ ExtractBitsLatency(sign_extend, size) + InsertBitsLatency() + ++ ScLatency(0) + BranchShortLatency() + 1; ++} ++ ++int InstructionScheduler::GetInstructionLatency(const Instruction* instr) { ++ // FIXME(RISCV): Verify these latencies for RISC-V (currently using MIPS ++ // numbers) ++ switch (instr->arch_opcode()) { ++ case kArchCallCodeObject: ++ case kArchCallWasmFunction: ++ return CallLatency(); ++ case kArchTailCallCodeObjectFromJSFunction: ++ case kArchTailCallCodeObject: { ++ int latency = 0; ++ if (instr->arch_opcode() == kArchTailCallCodeObjectFromJSFunction) { ++ latency = AssemblePopArgumentsAdoptFrameLatency(); ++ } ++ return latency + JumpLatency(); ++ } ++ case kArchTailCallWasm: ++ case kArchTailCallAddress: ++ return JumpLatency(); ++ case kArchCallJSFunction: { ++ int latency = 0; ++ if (FLAG_debug_code) { ++ latency = 1 + AssertLatency(); ++ } ++ return latency + 1 + Add64Latency(false) + CallLatency(); ++ } ++ case kArchPrepareCallCFunction: ++ return PrepareCallCFunctionLatency(); ++ case kArchSaveCallerRegisters: { ++ auto fp_mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ return PushCallerSavedLatency(fp_mode); ++ } ++ case kArchRestoreCallerRegisters: { ++ auto fp_mode = ++ static_cast(MiscField::decode(instr->opcode())); ++ return PopCallerSavedLatency(fp_mode); ++ } ++ case kArchPrepareTailCall: ++ return 2; ++ case kArchCallCFunction: ++ return CallCFunctionLatency(); ++ case kArchJmp: ++ return AssembleArchJumpLatency(); ++ case kArchTableSwitch: ++ return AssembleArchTableSwitchLatency(); ++ case kArchAbortCSAAssert: ++ return CallLatency() + 1; ++ case kArchDebugBreak: ++ return 1; ++ case kArchComment: ++ case kArchNop: ++ case kArchThrowTerminator: ++ case kArchDeoptimize: ++ return 0; ++ case kArchRet: ++ return AssemblerReturnLatency(); ++ case kArchFramePointer: ++ return 1; ++ case kArchParentFramePointer: ++ // Estimated max. ++ return AlignedMemoryLatency(); ++ case kArchTruncateDoubleToI: ++ return TruncateDoubleToIDelayedLatency(); ++ case kArchStoreWithWriteBarrier: ++ return Add64Latency() + 1 + CheckPageFlagLatency(); ++ case kArchStackSlot: ++ // Estimated max. ++ return Add64Latency(false) + AndLatency(false) + AssertLatency() + ++ Add64Latency(false) + AndLatency(false) + BranchShortLatency() + ++ 1 + Sub64Latency() + Add64Latency(); ++ case kArchWordPoisonOnSpeculation: ++ return AndLatency(); ++ case kIeee754Float64Acos: ++ case kIeee754Float64Acosh: ++ case kIeee754Float64Asin: ++ case kIeee754Float64Asinh: ++ case kIeee754Float64Atan: ++ case kIeee754Float64Atanh: ++ case kIeee754Float64Atan2: ++ case kIeee754Float64Cos: ++ case kIeee754Float64Cosh: ++ case kIeee754Float64Cbrt: ++ case kIeee754Float64Exp: ++ case kIeee754Float64Expm1: ++ case kIeee754Float64Log: ++ case kIeee754Float64Log1p: ++ case kIeee754Float64Log10: ++ case kIeee754Float64Log2: ++ case kIeee754Float64Pow: ++ case kIeee754Float64Sin: ++ case kIeee754Float64Sinh: ++ case kIeee754Float64Tan: ++ case kIeee754Float64Tanh: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kRiscvAdd32: ++ case kRiscvAdd64: ++ return Add64Latency(instr->InputAt(1)->IsRegister()); ++ case kRiscvAddOvf64: ++ return AddOverflow64Latency(); ++ case kRiscvSub32: ++ case kRiscvSub64: ++ return Sub64Latency(instr->InputAt(1)->IsRegister()); ++ case kRiscvSubOvf64: ++ return SubOverflow64Latency(); ++ case kRiscvMul32: ++ return Mul32Latency(); ++ case kRiscvMulOvf32: ++ return MulOverflow32Latency(); ++ case kRiscvMulHigh32: ++ return Mulh32Latency(); ++ case kRiscvMulHighU32: ++ return Mulhu32Latency(); ++ case kRiscvMulHigh64: ++ return Mulh64Latency(); ++ case kRiscvDiv32: { ++ int latency = Div32Latency(instr->InputAt(1)->IsRegister()); ++ return latency + MovzLatency(); ++ } ++ case kRiscvDivU32: { ++ int latency = Divu32Latency(instr->InputAt(1)->IsRegister()); ++ return latency + MovzLatency(); ++ } ++ case kRiscvMod32: ++ return Mod32Latency(); ++ case kRiscvModU32: ++ return Modu32Latency(); ++ case kRiscvMul64: ++ return Mul64Latency(); ++ case kRiscvDiv64: { ++ int latency = Div64Latency(); ++ return latency + MovzLatency(); ++ } ++ case kRiscvDivU64: { ++ int latency = Divu64Latency(); ++ return latency + MovzLatency(); ++ } ++ case kRiscvMod64: ++ return Mod64Latency(); ++ case kRiscvModU64: ++ return Modu64Latency(); ++ case kRiscvAnd: ++ return AndLatency(instr->InputAt(1)->IsRegister()); ++ case kRiscvAnd32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = AndLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kRiscvOr: ++ return OrLatency(instr->InputAt(1)->IsRegister()); ++ case kRiscvOr32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = OrLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kRiscvNor: ++ return NorLatency(instr->InputAt(1)->IsRegister()); ++ case kRiscvNor32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = NorLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kRiscvXor: ++ return XorLatency(instr->InputAt(1)->IsRegister()); ++ case kRiscvXor32: { ++ bool is_operand_register = instr->InputAt(1)->IsRegister(); ++ int latency = XorLatency(is_operand_register); ++ if (is_operand_register) { ++ return latency + 2; ++ } else { ++ return latency + 1; ++ } ++ } ++ case kRiscvClz32: ++ case kRiscvClz64: ++ return Clz64Latency(); ++ case kRiscvCtz32: ++ return Ctz32Latency(); ++ case kRiscvCtz64: ++ return Ctz64Latency(); ++ case kRiscvPopcnt32: ++ return Popcnt32Latency(); ++ case kRiscvPopcnt64: ++ return Popcnt64Latency(); ++ case kRiscvShl32: ++ return 1; ++ case kRiscvShr32: ++ case kRiscvSar32: ++ case kRiscvZeroExtendWord: ++ return 2; ++ case kRiscvSignExtendWord: ++ case kRiscvShl64: ++ case kRiscvShr64: ++ case kRiscvSar64: ++ case kRiscvRor32: ++ case kRiscvRor64: ++ return 1; ++ case kRiscvTst: ++ return AndLatency(instr->InputAt(1)->IsRegister()); ++ case kRiscvMov: ++ return 1; ++ case kRiscvCmpS: ++ return MoveLatency() + CompareF32Latency(); ++ case kRiscvAddS: ++ return Latency::ADD_S; ++ case kRiscvSubS: ++ return Latency::SUB_S; ++ case kRiscvMulS: ++ return Latency::MUL_S; ++ case kRiscvDivS: ++ return Latency::DIV_S; ++ case kRiscvModS: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kRiscvAbsS: ++ return Latency::ABS_S; ++ case kRiscvNegS: ++ return NegdLatency(); ++ case kRiscvSqrtS: ++ return Latency::SQRT_S; ++ case kRiscvMaxS: ++ return Latency::MAX_S; ++ case kRiscvMinS: ++ return Latency::MIN_S; ++ case kRiscvCmpD: ++ return MoveLatency() + CompareF64Latency(); ++ case kRiscvAddD: ++ return Latency::ADD_D; ++ case kRiscvSubD: ++ return Latency::SUB_D; ++ case kRiscvMulD: ++ return Latency::MUL_D; ++ case kRiscvDivD: ++ return Latency::DIV_D; ++ case kRiscvModD: ++ return PrepareCallCFunctionLatency() + MovToFloatParametersLatency() + ++ CallCFunctionLatency() + MovFromFloatResultLatency(); ++ case kRiscvAbsD: ++ return Latency::ABS_D; ++ case kRiscvNegD: ++ return NegdLatency(); ++ case kRiscvSqrtD: ++ return Latency::SQRT_D; ++ case kRiscvMaxD: ++ return Latency::MAX_D; ++ case kRiscvMinD: ++ return Latency::MIN_D; ++ case kRiscvFloat64RoundDown: ++ case kRiscvFloat64RoundTruncate: ++ case kRiscvFloat64RoundUp: ++ case kRiscvFloat64RoundTiesEven: ++ return Float64RoundLatency(); ++ case kRiscvFloat32RoundDown: ++ case kRiscvFloat32RoundTruncate: ++ case kRiscvFloat32RoundUp: ++ case kRiscvFloat32RoundTiesEven: ++ return Float32RoundLatency(); ++ case kRiscvFloat32Max: ++ return Float32MaxLatency(); ++ case kRiscvFloat64Max: ++ return Float64MaxLatency(); ++ case kRiscvFloat32Min: ++ return Float32MinLatency(); ++ case kRiscvFloat64Min: ++ return Float64MinLatency(); ++ case kRiscvFloat64SilenceNaN: ++ return Latency::SUB_D; ++ case kRiscvCvtSD: ++ return Latency::CVT_S_D; ++ case kRiscvCvtDS: ++ return Latency::CVT_D_S; ++ case kRiscvCvtDW: ++ return Latency::MOVT_FREG + Latency::CVT_D_W; ++ case kRiscvCvtSW: ++ return Latency::MOVT_FREG + Latency::CVT_S_W; ++ case kRiscvCvtSUw: ++ return 1 + Latency::MOVT_DREG + Latency::CVT_S_L; ++ case kRiscvCvtSL: ++ return Latency::MOVT_DREG + Latency::CVT_S_L; ++ case kRiscvCvtDL: ++ return Latency::MOVT_DREG + Latency::CVT_D_L; ++ case kRiscvCvtDUw: ++ return 1 + Latency::MOVT_DREG + Latency::CVT_D_L; ++ case kRiscvCvtDUl: ++ return 2 * Latency::BRANCH + 3 + 2 * Latency::MOVT_DREG + ++ 2 * Latency::CVT_D_L + Latency::ADD_D; ++ case kRiscvCvtSUl: ++ return 2 * Latency::BRANCH + 3 + 2 * Latency::MOVT_DREG + ++ 2 * Latency::CVT_S_L + Latency::ADD_S; ++ case kRiscvFloorWD: ++ return Latency::FLOOR_W_D + Latency::MOVF_FREG; ++ case kRiscvCeilWD: ++ return Latency::CEIL_W_D + Latency::MOVF_FREG; ++ case kRiscvRoundWD: ++ return Latency::ROUND_W_D + Latency::MOVF_FREG; ++ case kRiscvTruncWD: ++ return Latency::TRUNC_W_D + Latency::MOVF_FREG; ++ case kRiscvFloorWS: ++ return Latency::FLOOR_W_S + Latency::MOVF_FREG; ++ case kRiscvCeilWS: ++ return Latency::CEIL_W_S + Latency::MOVF_FREG; ++ case kRiscvRoundWS: ++ return Latency::ROUND_W_S + Latency::MOVF_FREG; ++ case kRiscvTruncWS: ++ return Latency::TRUNC_W_S + Latency::MOVF_FREG + 2 + MovnLatency(); ++ case kRiscvTruncLS: ++ return TruncLSLatency(instr->OutputCount() > 1); ++ case kRiscvTruncLD: ++ return TruncLDLatency(instr->OutputCount() > 1); ++ case kRiscvTruncUwD: ++ // Estimated max. ++ return CompareF64Latency() + 2 * Latency::BRANCH + ++ 2 * Latency::TRUNC_W_D + Latency::SUB_D + OrLatency() + ++ Latency::MOVT_FREG + Latency::MOVF_FREG + Latency::MOVT_HIGH_FREG + ++ 1; ++ case kRiscvTruncUwS: ++ // Estimated max. ++ return CompareF32Latency() + 2 * Latency::BRANCH + ++ 2 * Latency::TRUNC_W_S + Latency::SUB_S + OrLatency() + ++ Latency::MOVT_FREG + 2 * Latency::MOVF_FREG + 2 + MovzLatency(); ++ case kRiscvTruncUlS: ++ return TruncUlSLatency(); ++ case kRiscvTruncUlD: ++ return TruncUlDLatency(); ++ case kRiscvBitcastDL: ++ return Latency::MOVF_HIGH_DREG; ++ case kRiscvBitcastLD: ++ return Latency::MOVT_DREG; ++ case kRiscvFloat64ExtractLowWord32: ++ return Latency::MOVF_FREG; ++ case kRiscvFloat64InsertLowWord32: ++ return Latency::MOVF_HIGH_FREG + Latency::MOVT_FREG + ++ Latency::MOVT_HIGH_FREG; ++ case kRiscvFloat64ExtractHighWord32: ++ return Latency::MOVF_HIGH_FREG; ++ case kRiscvFloat64InsertHighWord32: ++ return Latency::MOVT_HIGH_FREG; ++ case kRiscvSignExtendByte: ++ case kRiscvSignExtendShort: ++ return 1; ++ case kRiscvLbu: ++ case kRiscvLb: ++ case kRiscvLhu: ++ case kRiscvLh: ++ case kRiscvLwu: ++ case kRiscvLw: ++ case kRiscvLd: ++ case kRiscvSb: ++ case kRiscvSh: ++ case kRiscvSw: ++ case kRiscvSd: ++ return AlignedMemoryLatency(); ++ case kRiscvLoadFloat: ++ return ULoadFloatLatency(); ++ case kRiscvLoadDouble: ++ return LoadDoubleLatency(); ++ case kRiscvStoreFloat: ++ return StoreFloatLatency(); ++ case kRiscvStoreDouble: ++ return StoreDoubleLatency(); ++ case kRiscvUlhu: ++ case kRiscvUlh: ++ return UlhuLatency(); ++ case kRiscvUlwu: ++ return UlwuLatency(); ++ case kRiscvUlw: ++ return UlwLatency(); ++ case kRiscvUld: ++ return UldLatency(); ++ case kRiscvULoadFloat: ++ return ULoadFloatLatency(); ++ case kRiscvULoadDouble: ++ return ULoadDoubleLatency(); ++ case kRiscvUsh: ++ return UshLatency(); ++ case kRiscvUsw: ++ return UswLatency(); ++ case kRiscvUsd: ++ return UsdLatency(); ++ case kRiscvUStoreFloat: ++ return UStoreFloatLatency(); ++ case kRiscvUStoreDouble: ++ return UStoreDoubleLatency(); ++ case kRiscvPush: { ++ int latency = 0; ++ if (instr->InputAt(0)->IsFPRegister()) { ++ latency = StoreDoubleLatency() + Sub64Latency(false); ++ } else { ++ latency = PushLatency(); ++ } ++ return latency; ++ } ++ case kRiscvPeek: { ++ int latency = 0; ++ if (instr->OutputAt(0)->IsFPRegister()) { ++ auto op = LocationOperand::cast(instr->OutputAt(0)); ++ switch (op->representation()) { ++ case MachineRepresentation::kFloat64: ++ latency = LoadDoubleLatency(); ++ break; ++ case MachineRepresentation::kFloat32: ++ latency = Latency::LOAD_FLOAT; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } else { ++ latency = AlignedMemoryLatency(); ++ } ++ return latency; ++ } ++ case kRiscvStackClaim: ++ return Sub64Latency(false); ++ case kRiscvStoreToStackSlot: { ++ int latency = 0; ++ if (instr->InputAt(0)->IsFPRegister()) { ++ if (instr->InputAt(0)->IsSimd128Register()) { ++ latency = 1; // Estimated value. ++ } else { ++ latency = StoreDoubleLatency(); ++ } ++ } else { ++ latency = AlignedMemoryLatency(); ++ } ++ return latency; ++ } ++ case kRiscvByteSwap64: ++ return ByteSwapSignedLatency(); ++ case kRiscvByteSwap32: ++ return ByteSwapSignedLatency(); ++ case kWord32AtomicLoadInt8: ++ case kWord32AtomicLoadUint8: ++ case kWord32AtomicLoadInt16: ++ case kWord32AtomicLoadUint16: ++ case kWord32AtomicLoadWord32: ++ return 2; ++ case kWord32AtomicStoreWord8: ++ case kWord32AtomicStoreWord16: ++ case kWord32AtomicStoreWord32: ++ return 3; ++ case kWord32AtomicExchangeInt8: ++ return Word32AtomicExchangeLatency(true, 8); ++ case kWord32AtomicExchangeUint8: ++ return Word32AtomicExchangeLatency(false, 8); ++ case kWord32AtomicExchangeInt16: ++ return Word32AtomicExchangeLatency(true, 16); ++ case kWord32AtomicExchangeUint16: ++ return Word32AtomicExchangeLatency(false, 16); ++ case kWord32AtomicExchangeWord32: ++ return 2 + LlLatency(0) + 1 + ScLatency(0) + BranchShortLatency() + 1; ++ case kWord32AtomicCompareExchangeInt8: ++ return Word32AtomicCompareExchangeLatency(true, 8); ++ case kWord32AtomicCompareExchangeUint8: ++ return Word32AtomicCompareExchangeLatency(false, 8); ++ case kWord32AtomicCompareExchangeInt16: ++ return Word32AtomicCompareExchangeLatency(true, 16); ++ case kWord32AtomicCompareExchangeUint16: ++ return Word32AtomicCompareExchangeLatency(false, 16); ++ case kWord32AtomicCompareExchangeWord32: ++ return 3 + LlLatency(0) + BranchShortLatency() + 1 + ScLatency(0) + ++ BranchShortLatency() + 1; ++ case kRiscvAssertEqual: ++ return AssertLatency(); ++ default: ++ return 1; ++ } ++} ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/compiler/backend/riscv64/instruction-selector-riscv64.cc +@@ -0,0 +1,2985 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/base/bits.h" ++#include "src/compiler/backend/instruction-selector-impl.h" ++#include "src/compiler/node-matchers.h" ++#include "src/compiler/node-properties.h" ++ ++namespace v8 { ++namespace internal { ++namespace compiler { ++ ++#define TRACE_UNIMPL() \ ++ PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) ++ ++#define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) ++ ++// Adds RISC-V-specific methods for generating InstructionOperands. ++class RiscvOperandGenerator final : public OperandGenerator { ++ public: ++ explicit RiscvOperandGenerator(InstructionSelector* selector) ++ : OperandGenerator(selector) {} ++ ++ InstructionOperand UseOperand(Node* node, InstructionCode opcode) { ++ if (CanBeImmediate(node, opcode)) { ++ return UseImmediate(node); ++ } ++ return UseRegister(node); ++ } ++ ++ // Use the zero register if the node has the immediate value zero, otherwise ++ // assign a register. ++ InstructionOperand UseRegisterOrImmediateZero(Node* node) { ++ if ((IsIntegerConstant(node) && (GetIntegerConstantValue(node) == 0)) || ++ (IsFloatConstant(node) && ++ (bit_cast(GetFloatConstantValue(node)) == 0))) { ++ return UseImmediate(node); ++ } ++ return UseRegister(node); ++ } ++ ++ bool IsIntegerConstant(Node* node) { ++ return (node->opcode() == IrOpcode::kInt32Constant) || ++ (node->opcode() == IrOpcode::kInt64Constant); ++ } ++ ++ int64_t GetIntegerConstantValue(Node* node) { ++ if (node->opcode() == IrOpcode::kInt32Constant) { ++ return OpParameter(node->op()); ++ } ++ DCHECK_EQ(IrOpcode::kInt64Constant, node->opcode()); ++ return OpParameter(node->op()); ++ } ++ ++ bool IsFloatConstant(Node* node) { ++ return (node->opcode() == IrOpcode::kFloat32Constant) || ++ (node->opcode() == IrOpcode::kFloat64Constant); ++ } ++ ++ double GetFloatConstantValue(Node* node) { ++ if (node->opcode() == IrOpcode::kFloat32Constant) { ++ return OpParameter(node->op()); ++ } ++ DCHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); ++ return OpParameter(node->op()); ++ } ++ ++ bool CanBeImmediate(Node* node, InstructionCode mode) { ++ return IsIntegerConstant(node) && ++ CanBeImmediate(GetIntegerConstantValue(node), mode); ++ } ++ ++ bool CanBeImmediate(int64_t value, InstructionCode opcode) { ++ switch (ArchOpcodeField::decode(opcode)) { ++ case kRiscvShl32: ++ case kRiscvSar32: ++ case kRiscvShr32: ++ return is_uint5(value); ++ case kRiscvShl64: ++ case kRiscvSar64: ++ case kRiscvShr64: ++ return is_uint6(value); ++ case kRiscvAdd32: ++ case kRiscvAnd32: ++ case kRiscvAnd: ++ case kRiscvAdd64: ++ case kRiscvOr32: ++ case kRiscvOr: ++ case kRiscvTst: ++ case kRiscvXor: ++ return is_int12(value); ++ case kRiscvLb: ++ case kRiscvLbu: ++ case kRiscvSb: ++ case kRiscvLh: ++ case kRiscvLhu: ++ case kRiscvSh: ++ case kRiscvLw: ++ case kRiscvSw: ++ case kRiscvLd: ++ case kRiscvSd: ++ case kRiscvLoadFloat: ++ case kRiscvStoreFloat: ++ case kRiscvLoadDouble: ++ case kRiscvStoreDouble: ++ return is_int32(value); ++ default: ++ return is_int12(value); ++ } ++ } ++ ++ private: ++ bool ImmediateFitsAddrMode1Instruction(int32_t imm) const { ++ TRACE_UNIMPL(); ++ return false; ++ } ++}; ++ ++static void VisitRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++static void VisitRRI(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ int32_t imm = OpParameter(node->op()); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm)); ++} ++ ++static void VisitSimdShift(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ if (g.IsIntegerConstant(node->InputAt(1))) { ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseImmediate(node->InputAt(1))); ++ } else { ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++ } ++} ++ ++static void VisitRRIR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ int32_t imm = OpParameter(node->op()); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseImmediate(imm), ++ g.UseRegister(node->InputAt(1))); ++} ++ ++static void VisitRRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++} ++ ++static void VisitUniqueRRR(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseUniqueRegister(node->InputAt(0)), ++ g.UseUniqueRegister(node->InputAt(1))); ++} ++ ++void VisitRRRR(InstructionSelector* selector, ArchOpcode opcode, Node* node) { ++ RiscvOperandGenerator g(selector); ++ selector->Emit( ++ opcode, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1)), g.UseRegister(node->InputAt(2))); ++} ++ ++static void VisitRRO(InstructionSelector* selector, ArchOpcode opcode, ++ Node* node) { ++ RiscvOperandGenerator g(selector); ++ selector->Emit(opcode, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), ++ g.UseOperand(node->InputAt(1), opcode)); ++} ++ ++struct ExtendingLoadMatcher { ++ ExtendingLoadMatcher(Node* node, InstructionSelector* selector) ++ : matches_(false), selector_(selector), base_(nullptr), immediate_(0) { ++ Initialize(node); ++ } ++ ++ bool Matches() const { return matches_; } ++ ++ Node* base() const { ++ DCHECK(Matches()); ++ return base_; ++ } ++ int64_t immediate() const { ++ DCHECK(Matches()); ++ return immediate_; ++ } ++ ArchOpcode opcode() const { ++ DCHECK(Matches()); ++ return opcode_; ++ } ++ ++ private: ++ bool matches_; ++ InstructionSelector* selector_; ++ Node* base_; ++ int64_t immediate_; ++ ArchOpcode opcode_; ++ ++ void Initialize(Node* node) { ++ Int64BinopMatcher m(node); ++ // When loading a 64-bit value and shifting by 32, we should ++ // just load and sign-extend the interesting 4 bytes instead. ++ // This happens, for example, when we're loading and untagging SMIs. ++ DCHECK(m.IsWord64Sar()); ++ if (m.left().IsLoad() && m.right().Is(32) && ++ selector_->CanCover(m.node(), m.left().node())) { ++ DCHECK_EQ(selector_->GetEffectLevel(node), ++ selector_->GetEffectLevel(m.left().node())); ++ MachineRepresentation rep = ++ LoadRepresentationOf(m.left().node()->op()).representation(); ++ DCHECK_EQ(3, ElementSizeLog2Of(rep)); ++ if (rep != MachineRepresentation::kTaggedSigned && ++ rep != MachineRepresentation::kTaggedPointer && ++ rep != MachineRepresentation::kTagged && ++ rep != MachineRepresentation::kWord64) { ++ return; ++ } ++ ++ RiscvOperandGenerator g(selector_); ++ Node* load = m.left().node(); ++ Node* offset = load->InputAt(1); ++ base_ = load->InputAt(0); ++ opcode_ = kRiscvLw; ++ if (g.CanBeImmediate(offset, opcode_)) { ++#if defined(V8_TARGET_LITTLE_ENDIAN) ++ immediate_ = g.GetIntegerConstantValue(offset) + 4; ++#elif defined(V8_TARGET_BIG_ENDIAN) ++ immediate_ = g.GetIntegerConstantValue(offset); ++#endif ++ matches_ = g.CanBeImmediate(immediate_, kRiscvLw); ++ } ++ } ++ } ++}; ++ ++bool TryEmitExtendingLoad(InstructionSelector* selector, Node* node, ++ Node* output_node) { ++ ExtendingLoadMatcher m(node, selector); ++ RiscvOperandGenerator g(selector); ++ if (m.Matches()) { ++ InstructionOperand inputs[2]; ++ inputs[0] = g.UseRegister(m.base()); ++ InstructionCode opcode = ++ m.opcode() | AddressingModeField::encode(kMode_MRI); ++ DCHECK(is_int32(m.immediate())); ++ inputs[1] = g.TempImmediate(static_cast(m.immediate())); ++ InstructionOperand outputs[] = {g.DefineAsRegister(output_node)}; ++ selector->Emit(opcode, arraysize(outputs), outputs, arraysize(inputs), ++ inputs); ++ return true; ++ } ++ return false; ++} ++ ++bool TryMatchImmediate(InstructionSelector* selector, ++ InstructionCode* opcode_return, Node* node, ++ size_t* input_count_return, InstructionOperand* inputs) { ++ RiscvOperandGenerator g(selector); ++ if (g.CanBeImmediate(node, *opcode_return)) { ++ *opcode_return |= AddressingModeField::encode(kMode_MRI); ++ inputs[0] = g.UseImmediate(node); ++ *input_count_return = 1; ++ return true; ++ } ++ return false; ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, bool has_reverse_opcode, ++ InstructionCode reverse_opcode, ++ FlagsContinuation* cont) { ++ RiscvOperandGenerator g(selector); ++ Int32BinopMatcher m(node); ++ InstructionOperand inputs[2]; ++ size_t input_count = 0; ++ InstructionOperand outputs[1]; ++ size_t output_count = 0; ++ ++ if (TryMatchImmediate(selector, &opcode, m.right().node(), &input_count, ++ &inputs[1])) { ++ inputs[0] = g.UseRegister(m.left().node()); ++ input_count++; ++ } else if (has_reverse_opcode && ++ TryMatchImmediate(selector, &reverse_opcode, m.left().node(), ++ &input_count, &inputs[1])) { ++ inputs[0] = g.UseRegister(m.right().node()); ++ opcode = reverse_opcode; ++ input_count++; ++ } else { ++ inputs[input_count++] = g.UseRegister(m.left().node()); ++ inputs[input_count++] = g.UseOperand(m.right().node(), opcode); ++ } ++ ++ if (cont->IsDeoptimize()) { ++ // If we can deoptimize as a result of the binop, we need to make sure that ++ // the deopt inputs are not overwritten by the binop result. One way ++ // to achieve that is to declare the output register as same-as-first. ++ outputs[output_count++] = g.DefineSameAsFirst(node); ++ } else { ++ outputs[output_count++] = g.DefineAsRegister(node); ++ } ++ ++ DCHECK_NE(0u, input_count); ++ DCHECK_EQ(1u, output_count); ++ DCHECK_GE(arraysize(inputs), input_count); ++ DCHECK_GE(arraysize(outputs), output_count); ++ ++ selector->EmitWithContinuation(opcode, output_count, outputs, input_count, ++ inputs, cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, bool has_reverse_opcode, ++ InstructionCode reverse_opcode) { ++ FlagsContinuation cont; ++ VisitBinop(selector, node, opcode, has_reverse_opcode, reverse_opcode, &cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont) { ++ VisitBinop(selector, node, opcode, false, kArchNop, cont); ++} ++ ++static void VisitBinop(InstructionSelector* selector, Node* node, ++ InstructionCode opcode) { ++ VisitBinop(selector, node, opcode, false, kArchNop); ++} ++ ++void InstructionSelector::VisitStackSlot(Node* node) { ++ StackSlotRepresentation rep = StackSlotRepresentationOf(node->op()); ++ int alignment = rep.alignment(); ++ int slot = frame_->AllocateSpillSlot(rep.size(), alignment); ++ OperandGenerator g(this); ++ ++ Emit(kArchStackSlot, g.DefineAsRegister(node), ++ sequence()->AddImmediate(Constant(slot)), ++ sequence()->AddImmediate(Constant(alignment)), 0, nullptr); ++} ++ ++void InstructionSelector::VisitAbortCSAAssert(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), a0)); ++} ++ ++void EmitLoad(InstructionSelector* selector, Node* node, InstructionCode opcode, ++ Node* output = nullptr) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(output == nullptr ? node : output), ++ g.UseRegister(base), g.UseImmediate(index)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), ++ addr_reg, g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired load opcode, using temp addr_reg. ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(output == nullptr ? node : output), ++ addr_reg, g.TempImmediate(0)); ++ } ++} ++ ++void InstructionSelector::VisitLoadTransform(Node* node) { ++ LoadTransformParameters params = LoadTransformParametersOf(node->op()); ++ ++ InstructionCode opcode = kArchNop; ++ switch (params.transformation) { ++ case LoadTransformation::kS8x16LoadSplat: ++ opcode = kRiscvS8x16LoadSplat; ++ break; ++ case LoadTransformation::kS16x8LoadSplat: ++ opcode = kRiscvS16x8LoadSplat; ++ break; ++ case LoadTransformation::kS32x4LoadSplat: ++ opcode = kRiscvS32x4LoadSplat; ++ break; ++ case LoadTransformation::kS64x2LoadSplat: ++ opcode = kRiscvS64x2LoadSplat; ++ break; ++ case LoadTransformation::kI16x8Load8x8S: ++ opcode = kRiscvI16x8Load8x8S; ++ break; ++ case LoadTransformation::kI16x8Load8x8U: ++ opcode = kRiscvI16x8Load8x8U; ++ break; ++ case LoadTransformation::kI32x4Load16x4S: ++ opcode = kRiscvI32x4Load16x4S; ++ break; ++ case LoadTransformation::kI32x4Load16x4U: ++ opcode = kRiscvI32x4Load16x4U; ++ break; ++ case LoadTransformation::kI64x2Load32x2S: ++ opcode = kRiscvI64x2Load32x2S; ++ break; ++ case LoadTransformation::kI64x2Load32x2U: ++ opcode = kRiscvI64x2Load32x2U; ++ break; ++ default: ++ UNIMPLEMENTED(); ++ } ++ ++ EmitLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ++ InstructionCode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kFloat32: ++ opcode = kRiscvLoadFloat; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kRiscvLoadDouble; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = load_rep.IsUnsigned() ? kRiscvLbu : kRiscvLb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kRiscvLhu : kRiscvLh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = load_rep.IsUnsigned() ? kRiscvLwu : kRiscvLw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvLd; ++ break; ++ case MachineRepresentation::kSimd128: ++ opcode = kRiscvMsaLd; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ UNREACHABLE(); ++ } ++ if (node->opcode() == IrOpcode::kPoisonedLoad) { ++ CHECK_NE(poisoning_level_, PoisoningMitigationLevel::kDontPoison); ++ opcode |= MiscField::encode(kMemoryAccessPoisoned); ++ } ++ ++ EmitLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitPoisonedLoad(Node* node) { VisitLoad(node); } ++ ++void InstructionSelector::VisitProtectedLoad(Node* node) { ++ // TODO(eholk) ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitStore(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ StoreRepresentation store_rep = StoreRepresentationOf(node->op()); ++ WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); ++ MachineRepresentation rep = store_rep.representation(); ++ ++ // TODO(riscv): I guess this could be done in a better way. ++ if (write_barrier_kind != kNoWriteBarrier && ++ V8_LIKELY(!FLAG_disable_write_barriers)) { ++ DCHECK(CanBeTaggedPointer(rep)); ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ RecordWriteMode record_write_mode = ++ WriteBarrierKindToRecordWriteMode(write_barrier_kind); ++ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; ++ size_t const temp_count = arraysize(temps); ++ InstructionCode code = kArchStoreWithWriteBarrier; ++ code |= MiscField::encode(static_cast(record_write_mode)); ++ Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); ++ } else { ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kFloat32: ++ opcode = kRiscvStoreFloat; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kRiscvStoreDouble; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = kRiscvSb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kRiscvSh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kRiscvSw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvSd; ++ break; ++ case MachineRepresentation::kSimd128: ++ opcode = kRiscvMsaSt; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ UNREACHABLE(); ++ return; ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, ++ g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired store opcode, using temp addr_reg. ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); ++ } ++ } ++} ++ ++void InstructionSelector::VisitProtectedStore(Node* node) { ++ // TODO(eholk) ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitWord32And(Node* node) { ++ VisitBinop(this, node, kRiscvAnd32, true, kRiscvAnd32); ++} ++ ++void InstructionSelector::VisitWord64And(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ if (m.left().IsWord64Shr() && CanCover(node, m.left().node()) && ++ m.right().HasValue()) { ++ uint64_t mask = m.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { ++ // The mask must be contiguous, and occupy the least-significant bits. ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); ++ ++ // Select Dext for And(Shr(x, imm), mask) where the mask is in the least ++ // significant bits. ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue()) { ++ // Any shift value can match; int64 shifts use `value % 64`. ++ uint32_t lsb = static_cast(mleft.right().Value() & 0x3F); ++ ++ // Dext cannot extract bits past the register size, however since ++ // shifting the original value would have introduced some zeros we can ++ // still use Dext with a smaller mask and the remaining bits will be ++ // zeros. ++ if (lsb + mask_width > 64) mask_width = 64 - lsb; ++ ++ if (lsb == 0 && mask_width == 64) { ++ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(mleft.left().node())); ++ return; ++ } ++ } ++ // Other cases fall through to the normal And operation. ++ } ++ } ++ VisitBinop(this, node, kRiscvAnd, true, kRiscvAnd); ++} ++ ++void InstructionSelector::VisitWord32Or(Node* node) { ++ VisitBinop(this, node, kRiscvOr32, true, kRiscvOr32); ++} ++ ++void InstructionSelector::VisitWord64Or(Node* node) { ++ VisitBinop(this, node, kRiscvOr, true, kRiscvOr); ++} ++ ++void InstructionSelector::VisitWord32Xor(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32Or() && CanCover(node, m.left().node()) && ++ m.right().Is(-1)) { ++ Int32BinopMatcher mleft(m.left().node()); ++ if (!mleft.right().HasValue()) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvNor32, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(mleft.right().node())); ++ return; ++ } ++ } ++ if (m.right().Is(-1)) { ++ // Use Nor for bit negation and eliminate constant loading for xori. ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvNor32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0)); ++ return; ++ } ++ VisitBinop(this, node, kRiscvXor32, true, kRiscvXor32); ++} ++ ++void InstructionSelector::VisitWord64Xor(Node* node) { ++ Int64BinopMatcher m(node); ++ if (m.left().IsWord64Or() && CanCover(node, m.left().node()) && ++ m.right().Is(-1)) { ++ Int64BinopMatcher mleft(m.left().node()); ++ if (!mleft.right().HasValue()) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvNor, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseRegister(mleft.right().node())); ++ return; ++ } ++ } ++ if (m.right().Is(-1)) { ++ // Use Nor for bit negation and eliminate constant loading for xori. ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(0)); ++ return; ++ } ++ VisitBinop(this, node, kRiscvXor, true, kRiscvXor); ++} ++ ++void InstructionSelector::VisitWord32Shl(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32And() && CanCover(node, m.left().node()) && ++ m.right().IsInRange(1, 31)) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher mleft(m.left().node()); ++ // Match Word32Shl(Word32And(x, mask), imm) to Shl where the mask is ++ // contiguous, and the shift immediate non-zero. ++ if (mleft.right().HasValue()) { ++ uint32_t mask = mleft.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { ++ uint32_t shift = m.right().Value(); ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); ++ DCHECK_NE(0u, shift); ++ if ((shift + mask_width) >= 32) { ++ // If the mask is contiguous and reaches or extends beyond the top ++ // bit, only the shift is needed. ++ Emit(kRiscvShl32, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ } ++ } ++ VisitRRO(this, kRiscvShl32, node); ++} ++ ++void InstructionSelector::VisitWord32Shr(Node* node) { ++ VisitRRO(this, kRiscvShr32, node); ++} ++ ++void InstructionSelector::VisitWord32Sar(Node* node) { ++ Int32BinopMatcher m(node); ++ if (m.left().IsWord32Shl() && CanCover(node, m.left().node())) { ++ Int32BinopMatcher mleft(m.left().node()); ++ if (m.right().HasValue() && mleft.right().HasValue()) { ++ RiscvOperandGenerator g(this); ++ uint32_t sar = m.right().Value(); ++ uint32_t shl = mleft.right().Value(); ++ if ((sar == shl) && (sar == 16)) { ++ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node())); ++ return; ++ } else if ((sar == shl) && (sar == 24)) { ++ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node())); ++ return; ++ } else if ((sar == shl) && (sar == 32)) { ++ Emit(kRiscvShl32, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), g.TempImmediate(0)); ++ return; ++ } ++ } ++ } ++ VisitRRO(this, kRiscvSar32, node); ++} ++ ++void InstructionSelector::VisitWord64Shl(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ if ((m.left().IsChangeInt32ToInt64() || m.left().IsChangeUint32ToUint64()) && ++ m.right().IsInRange(32, 63) && CanCover(node, m.left().node())) { ++ // There's no need to sign/zero-extend to 64-bit if we shift out the upper ++ // 32 bits anyway. ++ Emit(kRiscvShl64, g.DefineSameAsFirst(node), ++ g.UseRegister(m.left().node()->InputAt(0)), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ if (m.left().IsWord64And() && CanCover(node, m.left().node()) && ++ m.right().IsInRange(1, 63)) { ++ // Match Word64Shl(Word64And(x, mask), imm) to Dshl where the mask is ++ // contiguous, and the shift immediate non-zero. ++ Int64BinopMatcher mleft(m.left().node()); ++ if (mleft.right().HasValue()) { ++ uint64_t mask = mleft.right().Value(); ++ uint32_t mask_width = base::bits::CountPopulation(mask); ++ uint32_t mask_msb = base::bits::CountLeadingZeros64(mask); ++ if ((mask_width != 0) && (mask_msb + mask_width == 64)) { ++ uint64_t shift = m.right().Value(); ++ DCHECK_EQ(0u, base::bits::CountTrailingZeros64(mask)); ++ DCHECK_NE(0u, shift); ++ ++ if ((shift + mask_width) >= 64) { ++ // If the mask is contiguous and reaches or extends beyond the top ++ // bit, only the shift is needed. ++ Emit(kRiscvShl64, g.DefineAsRegister(node), ++ g.UseRegister(mleft.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ } ++ } ++ VisitRRO(this, kRiscvShl64, node); ++} ++ ++void InstructionSelector::VisitWord64Shr(Node* node) { ++ VisitRRO(this, kRiscvShr64, node); ++} ++ ++void InstructionSelector::VisitWord64Sar(Node* node) { ++ if (TryEmitExtendingLoad(this, node, node)) return; ++ VisitRRO(this, kRiscvSar64, node); ++} ++ ++void InstructionSelector::VisitWord32Rol(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64Rol(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord32Ror(Node* node) { ++ VisitRRO(this, kRiscvRor32, node); ++} ++ ++void InstructionSelector::VisitWord32Clz(Node* node) { ++ VisitRR(this, kRiscvClz32, node); ++} ++ ++void InstructionSelector::VisitWord32ReverseBits(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64ReverseBits(Node* node) { UNREACHABLE(); } ++ ++void InstructionSelector::VisitWord64ReverseBytes(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvByteSwap64, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord32ReverseBytes(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvByteSwap32, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSimd128ReverseBytes(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitWord32Ctz(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvCtz32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Ctz(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvCtz64, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord32Popcnt(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvPopcnt32, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Popcnt(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvPopcnt64, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitWord64Ror(Node* node) { ++ VisitRRO(this, kRiscvRor64, node); ++} ++ ++void InstructionSelector::VisitWord64Clz(Node* node) { ++ VisitRR(this, kRiscvClz64, node); ++} ++ ++void InstructionSelector::VisitInt32Add(Node* node) { ++ VisitBinop(this, node, kRiscvAdd32, true, kRiscvAdd32); ++} ++ ++void InstructionSelector::VisitInt64Add(Node* node) { ++ VisitBinop(this, node, kRiscvAdd64, true, kRiscvAdd64); ++} ++ ++void InstructionSelector::VisitInt32Sub(Node* node) { ++ VisitBinop(this, node, kRiscvSub32); ++} ++ ++void InstructionSelector::VisitInt64Sub(Node* node) { ++ VisitBinop(this, node, kRiscvSub64); ++} ++ ++void InstructionSelector::VisitInt32Mul(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ if (m.right().HasValue() && m.right().Value() > 0) { ++ uint32_t value = static_cast(m.right().Value()); ++ if (base::bits::IsPowerOfTwo(value)) { ++ Emit(kRiscvShl32 | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value + 1)) { ++ InstructionOperand temp = g.TempRegister(); ++ Emit(kRiscvShl32 | AddressingModeField::encode(kMode_None), temp, ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); ++ Emit(kRiscvSub32 | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); ++ return; ++ } ++ } ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher leftInput(left), rightInput(right); ++ if (leftInput.right().Is(32) && rightInput.right().Is(32)) { ++ // Combine untagging shifts with Dmul high. ++ Emit(kRiscvMulHigh64, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ VisitRRR(this, kRiscvMul32, node); ++} ++ ++void InstructionSelector::VisitInt32MulHigh(Node* node) { ++ VisitRRR(this, kRiscvMulHigh32, node); ++} ++ ++void InstructionSelector::VisitUint32MulHigh(Node* node) { ++ VisitRRR(this, kRiscvMulHighU32, node); ++} ++ ++void InstructionSelector::VisitInt64Mul(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ // TODO(dusmil): Add optimization for shifts larger than 32. ++ if (m.right().HasValue() && m.right().Value() > 0) { ++ uint32_t value = static_cast(m.right().Value()); ++ if (base::bits::IsPowerOfTwo(value)) { ++ Emit(kRiscvShl64 | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value))); ++ return; ++ } ++ if (base::bits::IsPowerOfTwo(value + 1)) { ++ InstructionOperand temp = g.TempRegister(); ++ Emit(kRiscvShl64 | AddressingModeField::encode(kMode_None), temp, ++ g.UseRegister(m.left().node()), ++ g.TempImmediate(base::bits::WhichPowerOfTwo(value + 1))); ++ Emit(kRiscvSub64 | AddressingModeField::encode(kMode_None), ++ g.DefineAsRegister(node), temp, g.UseRegister(m.left().node())); ++ return; ++ } ++ } ++ Emit(kRiscvMul64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt32Div(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher rightInput(right), leftInput(left); ++ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { ++ // Combine both shifted operands with Ddiv. ++ Emit(kRiscvDiv64, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ Emit(kRiscvDiv32, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint32Div(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Emit(kRiscvDivU32, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt32Mod(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ if (CanCover(node, left) && CanCover(node, right)) { ++ if (left->opcode() == IrOpcode::kWord64Sar && ++ right->opcode() == IrOpcode::kWord64Sar) { ++ Int64BinopMatcher rightInput(right), leftInput(left); ++ if (rightInput.right().Is(32) && leftInput.right().Is(32)) { ++ // Combine both shifted operands with Dmod. ++ Emit(kRiscvMod64, g.DefineSameAsFirst(node), ++ g.UseRegister(leftInput.left().node()), ++ g.UseRegister(rightInput.left().node())); ++ return; ++ } ++ } ++ } ++ Emit(kRiscvMod32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint32Mod(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int32BinopMatcher m(node); ++ Emit(kRiscvModU32, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt64Div(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kRiscvDiv64, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint64Div(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kRiscvDivU64, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitInt64Mod(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kRiscvMod64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitUint64Mod(Node* node) { ++ RiscvOperandGenerator g(this); ++ Int64BinopMatcher m(node); ++ Emit(kRiscvModU64, g.DefineAsRegister(node), g.UseRegister(m.left().node()), ++ g.UseRegister(m.right().node())); ++} ++ ++void InstructionSelector::VisitChangeFloat32ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDS, node); ++} ++ ++void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) { ++ VisitRR(this, kRiscvCvtSW, node); ++} ++ ++void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) { ++ VisitRR(this, kRiscvCvtSUw, node); ++} ++ ++void InstructionSelector::VisitChangeInt32ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDW, node); ++} ++ ++void InstructionSelector::VisitChangeInt64ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDL, node); ++} ++ ++void InstructionSelector::VisitChangeUint32ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDUw, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat32ToInt32(Node* node) { ++ VisitRR(this, kRiscvTruncWS, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat32ToUint32(Node* node) { ++ VisitRR(this, kRiscvTruncUwS, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToInt32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ // Match ChangeFloat64ToInt32(Float64Round##OP) to corresponding instruction ++ // which does rounding and conversion to integer format. ++ if (CanCover(node, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kFloat64RoundDown: ++ Emit(kRiscvFloorWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundUp: ++ Emit(kRiscvCeilWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundTiesEven: ++ Emit(kRiscvRoundWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ case IrOpcode::kFloat64RoundTruncate: ++ Emit(kRiscvTruncWD, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ default: ++ break; ++ } ++ if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) { ++ Node* next = value->InputAt(0); ++ if (CanCover(value, next)) { ++ // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP)) ++ switch (next->opcode()) { ++ case IrOpcode::kFloat32RoundDown: ++ Emit(kRiscvFloorWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundUp: ++ Emit(kRiscvCeilWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundTiesEven: ++ Emit(kRiscvRoundWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ case IrOpcode::kFloat32RoundTruncate: ++ Emit(kRiscvTruncWS, g.DefineAsRegister(node), ++ g.UseRegister(next->InputAt(0))); ++ return; ++ default: ++ Emit(kRiscvTruncWS, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ } else { ++ // Match float32 -> float64 -> int32 representation change path. ++ Emit(kRiscvTruncWS, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ } ++ } ++ VisitRR(this, kRiscvTruncWD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToInt64(Node* node) { ++ VisitRR(this, kRiscvTruncLD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { ++ VisitRR(this, kRiscvTruncUwD, node); ++} ++ ++void InstructionSelector::VisitChangeFloat64ToUint64(Node* node) { ++ VisitRR(this, kRiscvTruncUlD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToUint32(Node* node) { ++ VisitRR(this, kRiscvTruncUwD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToInt64(Node* node) { ++ VisitRR(this, kRiscvTruncLD, node); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat32ToInt64(Node* node) { ++ RiscvOperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ this->Emit(kRiscvTruncLS, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat64ToInt64(Node* node) { ++ RiscvOperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kRiscvTruncLD, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat32ToUint64(Node* node) { ++ RiscvOperandGenerator g(this); ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kRiscvTruncUlS, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) { ++ RiscvOperandGenerator g(this); ++ ++ InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))}; ++ InstructionOperand outputs[2]; ++ size_t output_count = 0; ++ outputs[output_count++] = g.DefineAsRegister(node); ++ ++ Node* success_output = NodeProperties::FindProjection(node, 1); ++ if (success_output) { ++ outputs[output_count++] = g.DefineAsRegister(success_output); ++ } ++ ++ Emit(kRiscvTruncUlD, output_count, outputs, 1, inputs); ++} ++ ++void InstructionSelector::VisitBitcastWord32ToWord64(Node* node) { ++ UNIMPLEMENTED(); ++} ++ ++void InstructionSelector::VisitChangeInt32ToInt64(Node* node) { ++ Node* value = node->InputAt(0); ++ if (value->opcode() == IrOpcode::kLoad && CanCover(node, value)) { ++ // Generate sign-extending load. ++ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); ++ InstructionCode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ opcode = load_rep.IsUnsigned() ? kRiscvLbu : kRiscvLb; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kRiscvLhu : kRiscvLh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kRiscvLw; ++ break; ++ default: ++ UNREACHABLE(); ++ return; ++ } ++ EmitLoad(this, value, opcode, node); ++ } else { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvShl32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0)); ++ } ++} ++ ++void InstructionSelector::VisitChangeUint32ToUint64(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ switch (value->opcode()) { ++ case IrOpcode::kLoad: { ++ LoadRepresentation load_rep = LoadRepresentationOf(value->op()); ++ if (load_rep.IsUnsigned()) { ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ case MachineRepresentation::kWord16: ++ case MachineRepresentation::kWord32: ++ Emit(kArchNop, g.DefineSameAsFirst(node), g.Use(value)); ++ return; ++ default: ++ break; ++ } ++ } ++ break; ++ } ++ default: ++ break; ++ } ++ Emit(kRiscvZeroExtendWord, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ if (CanCover(node, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kWord64Sar: { ++ if (CanCover(value, value->InputAt(0)) && ++ TryEmitExtendingLoad(this, value, node)) { ++ return; ++ } else { ++ Int64BinopMatcher m(value); ++ if (m.right().IsInRange(32, 63)) { ++ // After smi untagging no need for truncate. Combine sequence. ++ Emit(kRiscvSar64, g.DefineSameAsFirst(node), ++ g.UseRegister(m.left().node()), ++ g.UseImmediate(m.right().node())); ++ return; ++ } ++ } ++ break; ++ } ++ default: ++ break; ++ } ++ } ++ ++ // Semantics of this machine IR is not clear. For example, x86 zero-extend the ++ // truncated value; arm treats it as nop thus the upper 32-bit as undefined; ++ // mips emits ext instruction which zero-extend the 32-bit value; for riscv, ++ // we do sign-extension of the truncated value ++ Emit(kRiscvSignExtendWord, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* value = node->InputAt(0); ++ // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding ++ // instruction. ++ if (CanCover(node, value) && ++ value->opcode() == IrOpcode::kChangeInt32ToFloat64) { ++ Emit(kRiscvCvtSW, g.DefineAsRegister(node), ++ g.UseRegister(value->InputAt(0))); ++ return; ++ } ++ VisitRR(this, kRiscvCvtSD, node); ++} ++ ++void InstructionSelector::VisitTruncateFloat64ToWord32(Node* node) { ++ VisitRR(this, kArchTruncateDoubleToI, node); ++} ++ ++void InstructionSelector::VisitRoundFloat64ToInt32(Node* node) { ++ VisitRR(this, kRiscvTruncWD, node); ++} ++ ++void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) { ++ VisitRR(this, kRiscvCvtSL, node); ++} ++ ++void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDL, node); ++} ++ ++void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { ++ VisitRR(this, kRiscvCvtSUl, node); ++} ++ ++void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { ++ VisitRR(this, kRiscvCvtDUl, node); ++} ++ ++void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) { ++ VisitRR(this, kRiscvBitcastFloat32ToInt32, node); ++} ++ ++void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { ++ VisitRR(this, kRiscvBitcastDL, node); ++} ++ ++void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) { ++ VisitRR(this, kRiscvBitcastInt32ToFloat32, node); ++} ++ ++void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { ++ VisitRR(this, kRiscvBitcastLD, node); ++} ++ ++void InstructionSelector::VisitFloat32Add(Node* node) { ++ VisitRRR(this, kRiscvAddS, node); ++} ++ ++void InstructionSelector::VisitFloat64Add(Node* node) { ++ VisitRRR(this, kRiscvAddD, node); ++} ++ ++void InstructionSelector::VisitFloat32Sub(Node* node) { ++ VisitRRR(this, kRiscvSubS, node); ++} ++ ++void InstructionSelector::VisitFloat64Sub(Node* node) { ++ VisitRRR(this, kRiscvSubD, node); ++} ++ ++void InstructionSelector::VisitFloat32Mul(Node* node) { ++ VisitRRR(this, kRiscvMulS, node); ++} ++ ++void InstructionSelector::VisitFloat64Mul(Node* node) { ++ VisitRRR(this, kRiscvMulD, node); ++} ++ ++void InstructionSelector::VisitFloat32Div(Node* node) { ++ VisitRRR(this, kRiscvDivS, node); ++} ++ ++void InstructionSelector::VisitFloat64Div(Node* node) { ++ VisitRRR(this, kRiscvDivD, node); ++} ++ ++void InstructionSelector::VisitFloat64Mod(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvModD, g.DefineAsFixed(node, fa0), ++ g.UseFixed(node->InputAt(0), fa0), g.UseFixed(node->InputAt(1), fa1)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::VisitFloat32Max(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvFloat32Max, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat64Max(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvFloat64Max, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat32Min(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvFloat32Min, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat64Min(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvFloat64Min, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1))); ++} ++ ++void InstructionSelector::VisitFloat32Abs(Node* node) { ++ VisitRR(this, kRiscvAbsS, node); ++} ++ ++void InstructionSelector::VisitFloat64Abs(Node* node) { ++ VisitRR(this, kRiscvAbsD, node); ++} ++ ++void InstructionSelector::VisitFloat32Sqrt(Node* node) { ++ VisitRR(this, kRiscvSqrtS, node); ++} ++ ++void InstructionSelector::VisitFloat64Sqrt(Node* node) { ++ VisitRR(this, kRiscvSqrtD, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundDown(Node* node) { ++ VisitRR(this, kRiscvFloat32RoundDown, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundDown(Node* node) { ++ VisitRR(this, kRiscvFloat64RoundDown, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundUp(Node* node) { ++ VisitRR(this, kRiscvFloat32RoundUp, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundUp(Node* node) { ++ VisitRR(this, kRiscvFloat64RoundUp, node); ++} ++ ++void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { ++ VisitRR(this, kRiscvFloat32RoundTruncate, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { ++ VisitRR(this, kRiscvFloat64RoundTruncate, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { ++ VisitRR(this, kRiscvFloat32RoundTiesEven, node); ++} ++ ++void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { ++ VisitRR(this, kRiscvFloat64RoundTiesEven, node); ++} ++ ++void InstructionSelector::VisitFloat32Neg(Node* node) { ++ VisitRR(this, kRiscvNegS, node); ++} ++ ++void InstructionSelector::VisitFloat64Neg(Node* node) { ++ VisitRR(this, kRiscvNegD, node); ++} ++ ++void InstructionSelector::VisitFloat64Ieee754Binop(Node* node, ++ InstructionCode opcode) { ++ RiscvOperandGenerator g(this); ++ Emit(opcode, g.DefineAsFixed(node, fa0), g.UseFixed(node->InputAt(0), fa0), ++ g.UseFixed(node->InputAt(1), fa1)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::VisitFloat64Ieee754Unop(Node* node, ++ InstructionCode opcode) { ++ RiscvOperandGenerator g(this); ++ Emit(opcode, g.DefineAsFixed(node, fa0), g.UseFixed(node->InputAt(0), fa1)) ++ ->MarkAsCall(); ++} ++ ++void InstructionSelector::EmitPrepareArguments( ++ ZoneVector* arguments, const CallDescriptor* call_descriptor, ++ Node* node) { ++ RiscvOperandGenerator g(this); ++ ++ // Prepare for C function call. ++ if (call_descriptor->IsCFunctionCall()) { ++ Emit(kArchPrepareCallCFunction | MiscField::encode(static_cast( ++ call_descriptor->ParameterCount())), ++ 0, nullptr, 0, nullptr); ++ ++ // Poke any stack arguments. ++ int slot = kCArgSlotCount; ++ for (PushParameter input : (*arguments)) { ++ Emit(kRiscvStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), ++ g.TempImmediate(slot << kSystemPointerSizeLog2)); ++ ++slot; ++ } ++ } else { ++ int push_count = static_cast(call_descriptor->StackParameterCount()); ++ if (push_count > 0) { ++ // Calculate needed space ++ int stack_size = 0; ++ for (PushParameter input : (*arguments)) { ++ if (input.node) { ++ stack_size += input.location.GetSizeInPointers(); ++ } ++ } ++ Emit(kRiscvStackClaim, g.NoOutput(), ++ g.TempImmediate(stack_size << kSystemPointerSizeLog2)); ++ } ++ for (size_t n = 0; n < arguments->size(); ++n) { ++ PushParameter input = (*arguments)[n]; ++ if (input.node) { ++ Emit(kRiscvStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), ++ g.TempImmediate(static_cast(n << kSystemPointerSizeLog2))); ++ } ++ } ++ } ++} ++ ++void InstructionSelector::EmitPrepareResults( ++ ZoneVector* results, const CallDescriptor* call_descriptor, ++ Node* node) { ++ RiscvOperandGenerator g(this); ++ ++ int reverse_slot = 0; ++ for (PushParameter output : *results) { ++ if (!output.location.IsCallerFrameSlot()) continue; ++ // Skip any alignment holes in nodes. ++ if (output.node != nullptr) { ++ DCHECK(!call_descriptor->IsCFunctionCall()); ++ if (output.location.GetType() == MachineType::Float32()) { ++ MarkAsFloat32(output.node); ++ } else if (output.location.GetType() == MachineType::Float64()) { ++ MarkAsFloat64(output.node); ++ } ++ Emit(kRiscvPeek, g.DefineAsRegister(output.node), ++ g.UseImmediate(reverse_slot)); ++ } ++ reverse_slot += output.location.GetSizeInPointers(); ++ } ++} ++ ++bool InstructionSelector::IsTailCallAddressImmediate() { return false; } ++ ++int InstructionSelector::GetTempsCountForTailCallFromJSFunction() { return 3; } ++ ++void InstructionSelector::VisitUnalignedLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ RiscvOperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kFloat32: ++ opcode = kRiscvULoadFloat; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kRiscvULoadDouble; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ UNREACHABLE(); ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsUnsigned() ? kRiscvUlhu : kRiscvUlh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = load_rep.IsUnsigned() ? kRiscvUlwu : kRiscvUlw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvUld; ++ break; ++ case MachineRepresentation::kSimd128: ++ opcode = kRiscvMsaLd; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ UNREACHABLE(); ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(index)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, ++ g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired load opcode, using temp addr_reg. ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); ++ } ++} ++ ++void InstructionSelector::VisitUnalignedStore(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ UnalignedStoreRepresentation rep = UnalignedStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kFloat32: ++ opcode = kRiscvUStoreFloat; ++ break; ++ case MachineRepresentation::kFloat64: ++ opcode = kRiscvUStoreDouble; ++ break; ++ case MachineRepresentation::kBit: // Fall through. ++ case MachineRepresentation::kWord8: ++ UNREACHABLE(); ++ case MachineRepresentation::kWord16: ++ opcode = kRiscvUsh; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kRiscvUsw; ++ break; ++ case MachineRepresentation::kTaggedSigned: // Fall through. ++ case MachineRepresentation::kTaggedPointer: // Fall through. ++ case MachineRepresentation::kTagged: // Fall through. ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvUsd; ++ break; ++ case MachineRepresentation::kSimd128: ++ opcode = kRiscvMsaSt; ++ break; ++ case MachineRepresentation::kCompressedPointer: // Fall through. ++ case MachineRepresentation::kCompressed: // Fall through. ++ case MachineRepresentation::kNone: ++ UNREACHABLE(); ++ } ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), addr_reg, ++ g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired store opcode, using temp addr_reg. ++ Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), ++ addr_reg, g.TempImmediate(0), g.UseRegisterOrImmediateZero(value)); ++ } ++} ++ ++namespace { ++ ++// Shared routine for multiple compare operations. ++static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, ++ InstructionOperand left, InstructionOperand right, ++ FlagsContinuation* cont) { ++ selector->EmitWithContinuation(opcode, left, right, cont); ++} ++ ++// Shared routine for multiple float32 compare operations. ++void VisitFloat32Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ RiscvOperandGenerator g(selector); ++ Float32BinopMatcher m(node); ++ InstructionOperand lhs, rhs; ++ ++ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) ++ : g.UseRegister(m.left().node()); ++ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) ++ : g.UseRegister(m.right().node()); ++ VisitCompare(selector, kRiscvCmpS, lhs, rhs, cont); ++} ++ ++// Shared routine for multiple float64 compare operations. ++void VisitFloat64Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ RiscvOperandGenerator g(selector); ++ Float64BinopMatcher m(node); ++ InstructionOperand lhs, rhs; ++ ++ lhs = m.left().IsZero() ? g.UseImmediate(m.left().node()) ++ : g.UseRegister(m.left().node()); ++ rhs = m.right().IsZero() ? g.UseImmediate(m.right().node()) ++ : g.UseRegister(m.right().node()); ++ VisitCompare(selector, kRiscvCmpD, lhs, rhs, cont); ++} ++ ++// Shared routine for multiple word compare operations. ++void VisitWordCompare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont, ++ bool commutative) { ++ RiscvOperandGenerator g(selector); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ ++ // Match immediates on left or right side of comparison. ++ if (g.CanBeImmediate(right, opcode)) { ++ if (opcode == kRiscvTst) { ++ VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), ++ cont); ++ } else { ++ switch (cont->condition()) { ++ case kEqual: ++ case kNotEqual: ++ if (cont->IsSet()) { ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseImmediate(right), cont); ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseRegister(right), cont); ++ } ++ break; ++ case kSignedLessThan: ++ case kSignedGreaterThanOrEqual: ++ case kUnsignedLessThan: ++ case kUnsignedGreaterThanOrEqual: ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseImmediate(right), cont); ++ break; ++ default: ++ VisitCompare(selector, opcode, g.UseRegister(left), ++ g.UseRegister(right), cont); ++ } ++ } ++ } else if (g.CanBeImmediate(left, opcode)) { ++ if (!commutative) cont->Commute(); ++ if (opcode == kRiscvTst) { ++ VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), ++ cont); ++ } else { ++ switch (cont->condition()) { ++ case kEqual: ++ case kNotEqual: ++ if (cont->IsSet()) { ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseImmediate(left), cont); ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseRegister(left), cont); ++ } ++ break; ++ case kSignedLessThan: ++ case kSignedGreaterThanOrEqual: ++ case kUnsignedLessThan: ++ case kUnsignedGreaterThanOrEqual: ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseImmediate(left), cont); ++ break; ++ default: ++ VisitCompare(selector, opcode, g.UseRegister(right), ++ g.UseRegister(left), cont); ++ } ++ } ++ } else { ++ VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), ++ cont); ++ } ++} ++ ++bool IsNodeUnsigned(Node* n) { ++ NodeMatcher m(n); ++ ++ if (m.IsLoad() || m.IsUnalignedLoad() || m.IsPoisonedLoad() || ++ m.IsProtectedLoad() || m.IsWord32AtomicLoad() || m.IsWord64AtomicLoad()) { ++ LoadRepresentation load_rep = LoadRepresentationOf(n->op()); ++ return load_rep.IsUnsigned(); ++ } else { ++ return m.IsUint32Div() || m.IsUint32LessThan() || ++ m.IsUint32LessThanOrEqual() || m.IsUint32Mod() || ++ m.IsUint32MulHigh() || m.IsChangeFloat64ToUint32() || ++ m.IsTruncateFloat64ToUint32() || m.IsTruncateFloat32ToUint32(); ++ } ++} ++ ++// Shared routine for multiple word compare operations. ++void VisitFullWord32Compare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, FlagsContinuation* cont) { ++ RiscvOperandGenerator g(selector); ++ InstructionOperand leftOp = g.TempRegister(); ++ InstructionOperand rightOp = g.TempRegister(); ++ ++ selector->Emit(kRiscvShl64, leftOp, g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(32)); ++ selector->Emit(kRiscvShl64, rightOp, g.UseRegister(node->InputAt(1)), ++ g.TempImmediate(32)); ++ ++ VisitCompare(selector, opcode, leftOp, rightOp, cont); ++} ++ ++void VisitOptimizedWord32Compare(InstructionSelector* selector, Node* node, ++ InstructionCode opcode, ++ FlagsContinuation* cont) { ++ if (FLAG_debug_code) { ++ RiscvOperandGenerator g(selector); ++ InstructionOperand leftOp = g.TempRegister(); ++ InstructionOperand rightOp = g.TempRegister(); ++ InstructionOperand optimizedResult = g.TempRegister(); ++ InstructionOperand fullResult = g.TempRegister(); ++ FlagsCondition condition = cont->condition(); ++ InstructionCode testOpcode = opcode | ++ FlagsConditionField::encode(condition) | ++ FlagsModeField::encode(kFlags_set); ++ ++ selector->Emit(testOpcode, optimizedResult, g.UseRegister(node->InputAt(0)), ++ g.UseRegister(node->InputAt(1))); ++ ++ selector->Emit(kRiscvShl64, leftOp, g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(32)); ++ selector->Emit(kRiscvShl64, rightOp, g.UseRegister(node->InputAt(1)), ++ g.TempImmediate(32)); ++ selector->Emit(testOpcode, fullResult, leftOp, rightOp); ++ ++ selector->Emit(kRiscvAssertEqual, g.NoOutput(), optimizedResult, fullResult, ++ g.TempImmediate(static_cast( ++ AbortReason::kUnsupportedNonPrimitiveCompare))); ++ } ++ ++ VisitWordCompare(selector, node, opcode, cont, false); ++} ++ ++void VisitWord32Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ // RISC-V doesn't support Word32 compare instructions. Instead it relies ++ // that the values in registers are correctly sign-extended and uses ++ // Word64 comparison instead. This behavior is correct in most cases, ++ // but doesn't work when comparing signed with unsigned operands. ++ // We could simulate full Word32 compare in all cases but this would ++ // create an unnecessary overhead since unsigned integers are rarely ++ // used in JavaScript. ++ // The solution proposed here tries to match a comparison of signed ++ // with unsigned operand, and perform full Word32Compare only ++ // in those cases. Unfortunately, the solution is not complete because ++ // it might skip cases where Word32 full compare is needed, so ++ // basically it is a hack. ++ // When call to a host function in simulator, if the function return a ++ // int32 value, the simulator do not sign-extended to int64 because in ++ // simulator we do not know the function whether return a int32 or int64. ++ // so we need do a full word32 compare in this case. ++#ifndef USE_SIMULATOR ++ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1))) { ++#else ++ if (IsNodeUnsigned(node->InputAt(0)) != IsNodeUnsigned(node->InputAt(1)) || ++ node->InputAt(0)->opcode() == IrOpcode::kCall || ++ node->InputAt(1)->opcode() == IrOpcode::kCall) { ++#endif ++ VisitFullWord32Compare(selector, node, kRiscvCmp, cont); ++ } else { ++ VisitOptimizedWord32Compare(selector, node, kRiscvCmp, cont); ++ } ++} ++ ++void VisitWord64Compare(InstructionSelector* selector, Node* node, ++ FlagsContinuation* cont) { ++ VisitWordCompare(selector, node, kRiscvCmp, cont, false); ++} ++ ++void EmitWordCompareZero(InstructionSelector* selector, Node* value, ++ FlagsContinuation* cont) { ++ RiscvOperandGenerator g(selector); ++ selector->EmitWithContinuation(kRiscvCmp, g.UseRegister(value), ++ g.TempImmediate(0), cont); ++} ++ ++void VisitAtomicLoad(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), g.UseRegister(base), ++ g.UseImmediate(index)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), ++ addr_reg, g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired load opcode, using temp addr_reg. ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.DefineAsRegister(node), addr_reg, g.TempImmediate(0)); ++ } ++} ++ ++void VisitAtomicStore(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ if (g.CanBeImmediate(index, opcode)) { ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.NoOutput(), g.UseRegister(base), g.UseImmediate(index), ++ g.UseRegisterOrImmediateZero(value)); ++ } else { ++ InstructionOperand addr_reg = g.TempRegister(); ++ selector->Emit(kRiscvAdd64 | AddressingModeField::encode(kMode_None), ++ addr_reg, g.UseRegister(index), g.UseRegister(base)); ++ // Emit desired store opcode, using temp addr_reg. ++ selector->Emit(opcode | AddressingModeField::encode(kMode_MRI), ++ g.NoOutput(), addr_reg, g.TempImmediate(0), ++ g.UseRegisterOrImmediateZero(value)); ++ } ++} ++ ++void VisitAtomicExchange(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temp[3]; ++ temp[0] = g.TempRegister(); ++ temp[1] = g.TempRegister(); ++ temp[2] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); ++} ++ ++void VisitAtomicCompareExchange(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* old_value = node->InputAt(2); ++ Node* new_value = node->InputAt(3); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[4]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(old_value); ++ inputs[input_count++] = g.UseUniqueRegister(new_value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temp[3]; ++ temp[0] = g.TempRegister(); ++ temp[1] = g.TempRegister(); ++ temp[2] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 3, temp); ++} ++ ++void VisitAtomicBinop(InstructionSelector* selector, Node* node, ++ ArchOpcode opcode) { ++ RiscvOperandGenerator g(selector); ++ Node* base = node->InputAt(0); ++ Node* index = node->InputAt(1); ++ Node* value = node->InputAt(2); ++ ++ AddressingMode addressing_mode = kMode_MRI; ++ InstructionOperand inputs[3]; ++ size_t input_count = 0; ++ inputs[input_count++] = g.UseUniqueRegister(base); ++ inputs[input_count++] = g.UseUniqueRegister(index); ++ inputs[input_count++] = g.UseUniqueRegister(value); ++ InstructionOperand outputs[1]; ++ outputs[0] = g.UseUniqueRegister(node); ++ InstructionOperand temps[4]; ++ temps[0] = g.TempRegister(); ++ temps[1] = g.TempRegister(); ++ temps[2] = g.TempRegister(); ++ temps[3] = g.TempRegister(); ++ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode); ++ selector->Emit(code, 1, outputs, input_count, inputs, 4, temps); ++} ++ ++} // namespace ++ ++void InstructionSelector::VisitStackPointerGreaterThan( ++ Node* node, FlagsContinuation* cont) { ++ StackCheckKind kind = StackCheckKindOf(node->op()); ++ InstructionCode opcode = ++ kArchStackPointerGreaterThan | MiscField::encode(static_cast(kind)); ++ ++ RiscvOperandGenerator g(this); ++ ++ // No outputs. ++ InstructionOperand* const outputs = nullptr; ++ const int output_count = 0; ++ ++ // Applying an offset to this stack check requires a temp register. Offsets ++ // are only applied to the first stack check. If applying an offset, we must ++ // ensure the input and temp registers do not alias, thus kUniqueRegister. ++ InstructionOperand temps[] = {g.TempRegister()}; ++ const int temp_count = (kind == StackCheckKind::kJSFunctionEntry ? 1 : 0); ++ const auto register_mode = (kind == StackCheckKind::kJSFunctionEntry) ++ ? OperandGenerator::kUniqueRegister ++ : OperandGenerator::kRegister; ++ ++ Node* const value = node->InputAt(0); ++ InstructionOperand inputs[] = {g.UseRegisterWithMode(value, register_mode)}; ++ static constexpr int input_count = arraysize(inputs); ++ ++ EmitWithContinuation(opcode, output_count, outputs, input_count, inputs, ++ temp_count, temps, cont); ++} ++ ++// Shared routine for word comparisons against zero. ++void InstructionSelector::VisitWordCompareZero(Node* user, Node* value, ++ FlagsContinuation* cont) { ++ // Try to combine with comparisons against 0 by simply inverting the branch. ++ while (CanCover(user, value)) { ++ if (value->opcode() == IrOpcode::kWord32Equal) { ++ Int32BinopMatcher m(value); ++ if (!m.right().Is(0)) break; ++ user = value; ++ value = m.left().node(); ++ } else if (value->opcode() == IrOpcode::kWord64Equal) { ++ Int64BinopMatcher m(value); ++ if (!m.right().Is(0)) break; ++ user = value; ++ value = m.left().node(); ++ } else { ++ break; ++ } ++ ++ cont->Negate(); ++ } ++ ++ if (CanCover(user, value)) { ++ switch (value->opcode()) { ++ case IrOpcode::kWord32Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kInt32LessThan: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThan); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kInt32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kUint32LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kUint32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitWord32Compare(this, value, cont); ++ case IrOpcode::kWord64Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kInt64LessThan: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThan); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kInt64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kSignedLessThanOrEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kUint64LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kUint64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitWord64Compare(this, value, cont); ++ case IrOpcode::kFloat32Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat32LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat32LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitFloat32Compare(this, value, cont); ++ case IrOpcode::kFloat64Equal: ++ cont->OverwriteAndNegateIfEqual(kEqual); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kFloat64LessThan: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kFloat64LessThanOrEqual: ++ cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); ++ return VisitFloat64Compare(this, value, cont); ++ case IrOpcode::kProjection: ++ // Check if this is the overflow output projection of an ++ // WithOverflow node. ++ if (ProjectionIndexOf(value->op()) == 1u) { ++ // We cannot combine the WithOverflow with this branch ++ // unless the 0th projection (the use of the actual value of the ++ // is either nullptr, which means there's no use of the ++ // actual value, or was already defined, which means it is scheduled ++ // *AFTER* this branch). ++ Node* const node = value->InputAt(0); ++ Node* const result = NodeProperties::FindProjection(node, 0); ++ if (result == nullptr || IsDefined(result)) { ++ switch (node->opcode()) { ++ case IrOpcode::kInt32AddWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kRiscvAdd64, cont); ++ case IrOpcode::kInt32SubWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kRiscvSub64, cont); ++ case IrOpcode::kInt32MulWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kRiscvMulOvf32, cont); ++ case IrOpcode::kInt64AddWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kRiscvAddOvf64, cont); ++ case IrOpcode::kInt64SubWithOverflow: ++ cont->OverwriteAndNegateIfEqual(kOverflow); ++ return VisitBinop(this, node, kRiscvSubOvf64, cont); ++ default: ++ break; ++ } ++ } ++ } ++ break; ++ case IrOpcode::kWord32And: ++ case IrOpcode::kWord64And: ++ return VisitWordCompare(this, value, kRiscvTst, cont, true); ++ case IrOpcode::kStackPointerGreaterThan: ++ cont->OverwriteAndNegateIfEqual(kStackPointerGreaterThanCondition); ++ return VisitStackPointerGreaterThan(value, cont); ++ default: ++ break; ++ } ++ } ++ ++ // Continuation could not be combined with a compare, emit compare against 0. ++ EmitWordCompareZero(this, value, cont); ++} ++ ++void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { ++ RiscvOperandGenerator g(this); ++ InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); ++ ++ // Emit either ArchTableSwitch or ArchBinarySearchSwitch. ++ if (enable_switch_jump_table_ == kEnableSwitchJumpTable) { ++ static const size_t kMaxTableSwitchValueRange = 2 << 16; ++ size_t table_space_cost = 10 + 2 * sw.value_range(); ++ size_t table_time_cost = 3; ++ size_t lookup_space_cost = 2 + 2 * sw.case_count(); ++ size_t lookup_time_cost = sw.case_count(); ++ if (sw.case_count() > 0 && ++ table_space_cost + 3 * table_time_cost <= ++ lookup_space_cost + 3 * lookup_time_cost && ++ sw.min_value() > std::numeric_limits::min() && ++ sw.value_range() <= kMaxTableSwitchValueRange) { ++ InstructionOperand index_operand = value_operand; ++ if (sw.min_value()) { ++ index_operand = g.TempRegister(); ++ Emit(kRiscvSub32, index_operand, value_operand, ++ g.TempImmediate(sw.min_value())); ++ } ++ // Generate a table lookup. ++ return EmitTableSwitch(sw, index_operand); ++ } ++ } ++ ++ // Generate a tree of conditional jumps. ++ return EmitBinarySearchSwitch(sw, value_operand); ++} ++ ++void InstructionSelector::VisitWord32Equal(Node* const node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ Int32BinopMatcher m(node); ++ if (m.right().Is(0)) { ++ return VisitWordCompareZero(m.node(), m.left().node(), &cont); ++ } ++ ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitWord32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kRiscvAdd64, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kRiscvAdd64, &cont); ++} ++ ++void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kRiscvSub64, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kRiscvSub64, &cont); ++} ++ ++void InstructionSelector::VisitInt32MulWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kRiscvMulOvf32, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kRiscvMulOvf32, &cont); ++} ++ ++void InstructionSelector::VisitInt64AddWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kRiscvAddOvf64, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kRiscvAddOvf64, &cont); ++} ++ ++void InstructionSelector::VisitInt64SubWithOverflow(Node* node) { ++ if (Node* ovf = NodeProperties::FindProjection(node, 1)) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kOverflow, ovf); ++ return VisitBinop(this, node, kRiscvSubOvf64, &cont); ++ } ++ FlagsContinuation cont; ++ VisitBinop(this, node, kRiscvSubOvf64, &cont); ++} ++ ++void InstructionSelector::VisitWord64Equal(Node* const node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ Int64BinopMatcher m(node); ++ if (m.right().Is(0)) { ++ return VisitWordCompareZero(m.node(), m.left().node(), &cont); ++ } ++ ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kSignedLessThan, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitInt64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kSignedLessThanOrEqual, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitUint64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitWord64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32Equal(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat32LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitFloat32Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64Equal(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64LessThan(Node* node) { ++ FlagsContinuation cont = FlagsContinuation::ForSet(kUnsignedLessThan, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) { ++ FlagsContinuation cont = ++ FlagsContinuation::ForSet(kUnsignedLessThanOrEqual, node); ++ VisitFloat64Compare(this, node, &cont); ++} ++ ++void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { ++ VisitRR(this, kRiscvFloat64ExtractLowWord32, node); ++} ++ ++void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { ++ VisitRR(this, kRiscvFloat64ExtractHighWord32, node); ++} ++ ++void InstructionSelector::VisitFloat64SilenceNaN(Node* node) { ++ VisitRR(this, kRiscvFloat64SilenceNaN, node); ++} ++ ++void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ Emit(kRiscvFloat64InsertLowWord32, g.DefineSameAsFirst(node), ++ g.UseRegister(left), g.UseRegister(right)); ++} ++ ++void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Node* left = node->InputAt(0); ++ Node* right = node->InputAt(1); ++ Emit(kRiscvFloat64InsertHighWord32, g.DefineSameAsFirst(node), ++ g.UseRegister(left), g.UseRegister(right)); ++} ++ ++void InstructionSelector::VisitMemoryBarrier(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvSync, g.NoOutput()); ++} ++ ++void InstructionSelector::VisitWord32AtomicLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ opcode = ++ load_rep.IsSigned() ? kWord32AtomicLoadInt8 : kWord32AtomicLoadUint8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = load_rep.IsSigned() ? kWord32AtomicLoadInt16 ++ : kWord32AtomicLoadUint16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kWord32AtomicLoadWord32; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ VisitAtomicLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicStore(Node* node) { ++ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kWord8: ++ opcode = kWord32AtomicStoreWord8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kWord32AtomicStoreWord16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kWord32AtomicStoreWord32; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ VisitAtomicStore(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicLoad(Node* node) { ++ LoadRepresentation load_rep = LoadRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (load_rep.representation()) { ++ case MachineRepresentation::kWord8: ++ opcode = kRiscvWord64AtomicLoadUint8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kRiscvWord64AtomicLoadUint16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kRiscvWord64AtomicLoadUint32; ++ break; ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvWord64AtomicLoadUint64; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ VisitAtomicLoad(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicStore(Node* node) { ++ MachineRepresentation rep = AtomicStoreRepresentationOf(node->op()); ++ ArchOpcode opcode = kArchNop; ++ switch (rep) { ++ case MachineRepresentation::kWord8: ++ opcode = kRiscvWord64AtomicStoreWord8; ++ break; ++ case MachineRepresentation::kWord16: ++ opcode = kRiscvWord64AtomicStoreWord16; ++ break; ++ case MachineRepresentation::kWord32: ++ opcode = kRiscvWord64AtomicStoreWord32; ++ break; ++ case MachineRepresentation::kWord64: ++ opcode = kRiscvWord64AtomicStoreWord64; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ VisitAtomicStore(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = kWord32AtomicExchangeInt8; ++ } else if (type == MachineType::Uint8()) { ++ opcode = kWord32AtomicExchangeUint8; ++ } else if (type == MachineType::Int16()) { ++ opcode = kWord32AtomicExchangeInt16; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kWord32AtomicExchangeUint16; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = kWord32AtomicExchangeWord32; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = kRiscvWord64AtomicExchangeUint8; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kRiscvWord64AtomicExchangeUint16; ++ } else if (type == MachineType::Uint32()) { ++ opcode = kRiscvWord64AtomicExchangeUint32; ++ } else if (type == MachineType::Uint64()) { ++ opcode = kRiscvWord64AtomicExchangeUint64; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord32AtomicCompareExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = kWord32AtomicCompareExchangeInt8; ++ } else if (type == MachineType::Uint8()) { ++ opcode = kWord32AtomicCompareExchangeUint8; ++ } else if (type == MachineType::Int16()) { ++ opcode = kWord32AtomicCompareExchangeInt16; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kWord32AtomicCompareExchangeUint16; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = kWord32AtomicCompareExchangeWord32; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicCompareExchange(this, node, opcode); ++} ++ ++void InstructionSelector::VisitWord64AtomicCompareExchange(Node* node) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = kRiscvWord64AtomicCompareExchangeUint8; ++ } else if (type == MachineType::Uint16()) { ++ opcode = kRiscvWord64AtomicCompareExchangeUint16; ++ } else if (type == MachineType::Uint32()) { ++ opcode = kRiscvWord64AtomicCompareExchangeUint32; ++ } else if (type == MachineType::Uint64()) { ++ opcode = kRiscvWord64AtomicCompareExchangeUint64; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicCompareExchange(this, node, opcode); ++} ++void InstructionSelector::VisitWord32AtomicBinaryOperation( ++ Node* node, ArchOpcode int8_op, ArchOpcode uint8_op, ArchOpcode int16_op, ++ ArchOpcode uint16_op, ArchOpcode word32_op) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Int8()) { ++ opcode = int8_op; ++ } else if (type == MachineType::Uint8()) { ++ opcode = uint8_op; ++ } else if (type == MachineType::Int16()) { ++ opcode = int16_op; ++ } else if (type == MachineType::Uint16()) { ++ opcode = uint16_op; ++ } else if (type == MachineType::Int32() || type == MachineType::Uint32()) { ++ opcode = word32_op; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ ++ VisitAtomicBinop(this, node, opcode); ++} ++ ++#define VISIT_ATOMIC_BINOP(op) \ ++ void InstructionSelector::VisitWord32Atomic##op(Node* node) { \ ++ VisitWord32AtomicBinaryOperation( \ ++ node, kWord32Atomic##op##Int8, kWord32Atomic##op##Uint8, \ ++ kWord32Atomic##op##Int16, kWord32Atomic##op##Uint16, \ ++ kWord32Atomic##op##Word32); \ ++ } ++VISIT_ATOMIC_BINOP(Add) ++VISIT_ATOMIC_BINOP(Sub) ++VISIT_ATOMIC_BINOP(And) ++VISIT_ATOMIC_BINOP(Or) ++VISIT_ATOMIC_BINOP(Xor) ++#undef VISIT_ATOMIC_BINOP ++ ++void InstructionSelector::VisitWord64AtomicBinaryOperation( ++ Node* node, ArchOpcode uint8_op, ArchOpcode uint16_op, ArchOpcode uint32_op, ++ ArchOpcode uint64_op) { ++ ArchOpcode opcode = kArchNop; ++ MachineType type = AtomicOpType(node->op()); ++ if (type == MachineType::Uint8()) { ++ opcode = uint8_op; ++ } else if (type == MachineType::Uint16()) { ++ opcode = uint16_op; ++ } else if (type == MachineType::Uint32()) { ++ opcode = uint32_op; ++ } else if (type == MachineType::Uint64()) { ++ opcode = uint64_op; ++ } else { ++ UNREACHABLE(); ++ return; ++ } ++ VisitAtomicBinop(this, node, opcode); ++} ++ ++#define VISIT_ATOMIC_BINOP(op) \ ++ void InstructionSelector::VisitWord64Atomic##op(Node* node) { \ ++ VisitWord64AtomicBinaryOperation( \ ++ node, kRiscvWord64Atomic##op##Uint8, kRiscvWord64Atomic##op##Uint16, \ ++ kRiscvWord64Atomic##op##Uint32, kRiscvWord64Atomic##op##Uint64); \ ++ } ++VISIT_ATOMIC_BINOP(Add) ++VISIT_ATOMIC_BINOP(Sub) ++VISIT_ATOMIC_BINOP(And) ++VISIT_ATOMIC_BINOP(Or) ++VISIT_ATOMIC_BINOP(Xor) ++#undef VISIT_ATOMIC_BINOP ++ ++void InstructionSelector::VisitInt32AbsWithOverflow(Node* node) { ++ UNREACHABLE(); ++} ++ ++void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { ++ UNREACHABLE(); ++} ++ ++#define SIMD_TYPE_LIST(V) \ ++ V(F32x4) \ ++ V(I32x4) \ ++ V(I16x8) \ ++ V(I8x16) ++ ++#define SIMD_UNOP_LIST(V) \ ++ V(F64x2Abs, kRiscvF64x2Abs) \ ++ V(F64x2Neg, kRiscvF64x2Neg) \ ++ V(F64x2Sqrt, kRiscvF64x2Sqrt) \ ++ V(F64x2Ceil, kRiscvF64x2Ceil) \ ++ V(F64x2Floor, kRiscvF64x2Floor) \ ++ V(F64x2Trunc, kRiscvF64x2Trunc) \ ++ V(F64x2NearestInt, kRiscvF64x2NearestInt) \ ++ V(I64x2Neg, kRiscvI64x2Neg) \ ++ V(F32x4SConvertI32x4, kRiscvF32x4SConvertI32x4) \ ++ V(F32x4UConvertI32x4, kRiscvF32x4UConvertI32x4) \ ++ V(F32x4Abs, kRiscvF32x4Abs) \ ++ V(F32x4Neg, kRiscvF32x4Neg) \ ++ V(F32x4Sqrt, kRiscvF32x4Sqrt) \ ++ V(F32x4RecipApprox, kRiscvF32x4RecipApprox) \ ++ V(F32x4RecipSqrtApprox, kRiscvF32x4RecipSqrtApprox) \ ++ V(F32x4Ceil, kRiscvF32x4Ceil) \ ++ V(F32x4Floor, kRiscvF32x4Floor) \ ++ V(F32x4Trunc, kRiscvF32x4Trunc) \ ++ V(F32x4NearestInt, kRiscvF32x4NearestInt) \ ++ V(I32x4SConvertF32x4, kRiscvI32x4SConvertF32x4) \ ++ V(I32x4UConvertF32x4, kRiscvI32x4UConvertF32x4) \ ++ V(I32x4Neg, kRiscvI32x4Neg) \ ++ V(I32x4SConvertI16x8Low, kRiscvI32x4SConvertI16x8Low) \ ++ V(I32x4SConvertI16x8High, kRiscvI32x4SConvertI16x8High) \ ++ V(I32x4UConvertI16x8Low, kRiscvI32x4UConvertI16x8Low) \ ++ V(I32x4UConvertI16x8High, kRiscvI32x4UConvertI16x8High) \ ++ V(I32x4Abs, kRiscvI32x4Abs) \ ++ V(I32x4BitMask, kRiscvI32x4BitMask) \ ++ V(I16x8Neg, kRiscvI16x8Neg) \ ++ V(I16x8SConvertI8x16Low, kRiscvI16x8SConvertI8x16Low) \ ++ V(I16x8SConvertI8x16High, kRiscvI16x8SConvertI8x16High) \ ++ V(I16x8UConvertI8x16Low, kRiscvI16x8UConvertI8x16Low) \ ++ V(I16x8UConvertI8x16High, kRiscvI16x8UConvertI8x16High) \ ++ V(I16x8Abs, kRiscvI16x8Abs) \ ++ V(I16x8BitMask, kRiscvI16x8BitMask) \ ++ V(I8x16Neg, kRiscvI8x16Neg) \ ++ V(I8x16Abs, kRiscvI8x16Abs) \ ++ V(I8x16BitMask, kRiscvI8x16BitMask) \ ++ V(S128Not, kRiscvS128Not) \ ++ V(V32x4AnyTrue, kRiscvV32x4AnyTrue) \ ++ V(V32x4AllTrue, kRiscvV32x4AllTrue) \ ++ V(V16x8AnyTrue, kRiscvV16x8AnyTrue) \ ++ V(V16x8AllTrue, kRiscvV16x8AllTrue) \ ++ V(V8x16AnyTrue, kRiscvV8x16AnyTrue) \ ++ V(V8x16AllTrue, kRiscvV8x16AllTrue) ++ ++#define SIMD_SHIFT_OP_LIST(V) \ ++ V(I64x2Shl) \ ++ V(I64x2ShrS) \ ++ V(I64x2ShrU) \ ++ V(I32x4Shl) \ ++ V(I32x4ShrS) \ ++ V(I32x4ShrU) \ ++ V(I16x8Shl) \ ++ V(I16x8ShrS) \ ++ V(I16x8ShrU) \ ++ V(I8x16Shl) \ ++ V(I8x16ShrS) \ ++ V(I8x16ShrU) ++ ++#define SIMD_BINOP_LIST(V) \ ++ V(F64x2Add, kRiscvF64x2Add) \ ++ V(F64x2Sub, kRiscvF64x2Sub) \ ++ V(F64x2Mul, kRiscvF64x2Mul) \ ++ V(F64x2Div, kRiscvF64x2Div) \ ++ V(F64x2Min, kRiscvF64x2Min) \ ++ V(F64x2Max, kRiscvF64x2Max) \ ++ V(F64x2Eq, kRiscvF64x2Eq) \ ++ V(F64x2Ne, kRiscvF64x2Ne) \ ++ V(F64x2Lt, kRiscvF64x2Lt) \ ++ V(F64x2Le, kRiscvF64x2Le) \ ++ V(I64x2Add, kRiscvI64x2Add) \ ++ V(I64x2Sub, kRiscvI64x2Sub) \ ++ V(I64x2Mul, kRiscvI64x2Mul) \ ++ V(F32x4Add, kRiscvF32x4Add) \ ++ V(F32x4AddHoriz, kRiscvF32x4AddHoriz) \ ++ V(F32x4Sub, kRiscvF32x4Sub) \ ++ V(F32x4Mul, kRiscvF32x4Mul) \ ++ V(F32x4Div, kRiscvF32x4Div) \ ++ V(F32x4Max, kRiscvF32x4Max) \ ++ V(F32x4Min, kRiscvF32x4Min) \ ++ V(F32x4Eq, kRiscvF32x4Eq) \ ++ V(F32x4Ne, kRiscvF32x4Ne) \ ++ V(F32x4Lt, kRiscvF32x4Lt) \ ++ V(F32x4Le, kRiscvF32x4Le) \ ++ V(I32x4Add, kRiscvI32x4Add) \ ++ V(I32x4AddHoriz, kRiscvI32x4AddHoriz) \ ++ V(I32x4Sub, kRiscvI32x4Sub) \ ++ V(I32x4Mul, kRiscvI32x4Mul) \ ++ V(I32x4MaxS, kRiscvI32x4MaxS) \ ++ V(I32x4MinS, kRiscvI32x4MinS) \ ++ V(I32x4MaxU, kRiscvI32x4MaxU) \ ++ V(I32x4MinU, kRiscvI32x4MinU) \ ++ V(I32x4Eq, kRiscvI32x4Eq) \ ++ V(I32x4Ne, kRiscvI32x4Ne) \ ++ V(I32x4GtS, kRiscvI32x4GtS) \ ++ V(I32x4GeS, kRiscvI32x4GeS) \ ++ V(I32x4GtU, kRiscvI32x4GtU) \ ++ V(I32x4GeU, kRiscvI32x4GeU) \ ++ V(I16x8Add, kRiscvI16x8Add) \ ++ V(I16x8AddSaturateS, kRiscvI16x8AddSaturateS) \ ++ V(I16x8AddSaturateU, kRiscvI16x8AddSaturateU) \ ++ V(I16x8AddHoriz, kRiscvI16x8AddHoriz) \ ++ V(I16x8Sub, kRiscvI16x8Sub) \ ++ V(I16x8SubSaturateS, kRiscvI16x8SubSaturateS) \ ++ V(I16x8SubSaturateU, kRiscvI16x8SubSaturateU) \ ++ V(I16x8Mul, kRiscvI16x8Mul) \ ++ V(I16x8MaxS, kRiscvI16x8MaxS) \ ++ V(I16x8MinS, kRiscvI16x8MinS) \ ++ V(I16x8MaxU, kRiscvI16x8MaxU) \ ++ V(I16x8MinU, kRiscvI16x8MinU) \ ++ V(I16x8Eq, kRiscvI16x8Eq) \ ++ V(I16x8Ne, kRiscvI16x8Ne) \ ++ V(I16x8GtS, kRiscvI16x8GtS) \ ++ V(I16x8GeS, kRiscvI16x8GeS) \ ++ V(I16x8GtU, kRiscvI16x8GtU) \ ++ V(I16x8GeU, kRiscvI16x8GeU) \ ++ V(I16x8RoundingAverageU, kRiscvI16x8RoundingAverageU) \ ++ V(I16x8SConvertI32x4, kRiscvI16x8SConvertI32x4) \ ++ V(I16x8UConvertI32x4, kRiscvI16x8UConvertI32x4) \ ++ V(I8x16Add, kRiscvI8x16Add) \ ++ V(I8x16AddSaturateS, kRiscvI8x16AddSaturateS) \ ++ V(I8x16AddSaturateU, kRiscvI8x16AddSaturateU) \ ++ V(I8x16Sub, kRiscvI8x16Sub) \ ++ V(I8x16SubSaturateS, kRiscvI8x16SubSaturateS) \ ++ V(I8x16SubSaturateU, kRiscvI8x16SubSaturateU) \ ++ V(I8x16Mul, kRiscvI8x16Mul) \ ++ V(I8x16MaxS, kRiscvI8x16MaxS) \ ++ V(I8x16MinS, kRiscvI8x16MinS) \ ++ V(I8x16MaxU, kRiscvI8x16MaxU) \ ++ V(I8x16MinU, kRiscvI8x16MinU) \ ++ V(I8x16Eq, kRiscvI8x16Eq) \ ++ V(I8x16Ne, kRiscvI8x16Ne) \ ++ V(I8x16GtS, kRiscvI8x16GtS) \ ++ V(I8x16GeS, kRiscvI8x16GeS) \ ++ V(I8x16GtU, kRiscvI8x16GtU) \ ++ V(I8x16GeU, kRiscvI8x16GeU) \ ++ V(I8x16RoundingAverageU, kRiscvI8x16RoundingAverageU) \ ++ V(I8x16SConvertI16x8, kRiscvI8x16SConvertI16x8) \ ++ V(I8x16UConvertI16x8, kRiscvI8x16UConvertI16x8) \ ++ V(S128And, kRiscvS128And) \ ++ V(S128Or, kRiscvS128Or) \ ++ V(S128Xor, kRiscvS128Xor) \ ++ V(S128AndNot, kRiscvS128AndNot) ++ ++void InstructionSelector::VisitS128Const(Node* node) { ++ RiscvOperandGenerator g(this); ++ static const int kUint32Immediates = kSimd128Size / sizeof(uint32_t); ++ uint32_t val[kUint32Immediates]; ++ memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size); ++ // If all bytes are zeros or ones, avoid emitting code for generic constants ++ bool all_zeros = !(val[0] || val[1] || val[2] || val[3]); ++ bool all_ones = val[0] == UINT32_MAX && val[1] == UINT32_MAX && ++ val[2] == UINT32_MAX && val[3] == UINT32_MAX; ++ InstructionOperand dst = g.DefineAsRegister(node); ++ if (all_zeros) { ++ Emit(kRiscvS128Zero, dst); ++ } else if (all_ones) { ++ Emit(kRiscvS128AllOnes, dst); ++ } else { ++ Emit(kRiscvS128Const, dst, g.UseImmediate(val[0]), g.UseImmediate(val[1]), ++ g.UseImmediate(val[2]), g.UseImmediate(val[3])); ++ } ++} ++ ++void InstructionSelector::VisitS128Zero(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvS128Zero, g.DefineAsRegister(node)); ++} ++ ++#define SIMD_VISIT_SPLAT(Type) \ ++ void InstructionSelector::Visit##Type##Splat(Node* node) { \ ++ VisitRR(this, kRiscv##Type##Splat, node); \ ++ } ++SIMD_TYPE_LIST(SIMD_VISIT_SPLAT) ++SIMD_VISIT_SPLAT(F64x2) ++#undef SIMD_VISIT_SPLAT ++ ++#define SIMD_VISIT_EXTRACT_LANE(Type, Sign) \ ++ void InstructionSelector::Visit##Type##ExtractLane##Sign(Node* node) { \ ++ VisitRRI(this, kRiscv##Type##ExtractLane##Sign, node); \ ++ } ++SIMD_VISIT_EXTRACT_LANE(F64x2, ) ++SIMD_VISIT_EXTRACT_LANE(F32x4, ) ++SIMD_VISIT_EXTRACT_LANE(I32x4, ) ++SIMD_VISIT_EXTRACT_LANE(I16x8, U) ++SIMD_VISIT_EXTRACT_LANE(I16x8, S) ++SIMD_VISIT_EXTRACT_LANE(I8x16, U) ++SIMD_VISIT_EXTRACT_LANE(I8x16, S) ++#undef SIMD_VISIT_EXTRACT_LANE ++ ++#define SIMD_VISIT_REPLACE_LANE(Type) \ ++ void InstructionSelector::Visit##Type##ReplaceLane(Node* node) { \ ++ VisitRRIR(this, kRiscv##Type##ReplaceLane, node); \ ++ } ++SIMD_TYPE_LIST(SIMD_VISIT_REPLACE_LANE) ++SIMD_VISIT_REPLACE_LANE(F64x2) ++#undef SIMD_VISIT_REPLACE_LANE ++ ++#define SIMD_VISIT_UNOP(Name, instruction) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitRR(this, instruction, node); \ ++ } ++SIMD_UNOP_LIST(SIMD_VISIT_UNOP) ++#undef SIMD_VISIT_UNOP ++ ++#define SIMD_VISIT_SHIFT_OP(Name) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitSimdShift(this, kRiscv##Name, node); \ ++ } ++SIMD_SHIFT_OP_LIST(SIMD_VISIT_SHIFT_OP) ++#undef SIMD_VISIT_SHIFT_OP ++ ++#define SIMD_VISIT_BINOP(Name, instruction) \ ++ void InstructionSelector::Visit##Name(Node* node) { \ ++ VisitRRR(this, instruction, node); \ ++ } ++SIMD_BINOP_LIST(SIMD_VISIT_BINOP) ++#undef SIMD_VISIT_BINOP ++ ++void InstructionSelector::VisitS128Select(Node* node) { ++ VisitRRRR(this, kRiscvS128Select, node); ++} ++ ++namespace { ++ ++struct ShuffleEntry { ++ uint8_t shuffle[kSimd128Size]; ++ ArchOpcode opcode; ++}; ++ ++static const ShuffleEntry arch_shuffles[] = { ++ {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}, ++ kRiscvS32x4InterleaveRight}, ++ {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}, ++ kRiscvS32x4InterleaveLeft}, ++ {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}, ++ kRiscvS32x4PackEven}, ++ {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}, ++ kRiscvS32x4PackOdd}, ++ {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}, ++ kRiscvS32x4InterleaveEven}, ++ {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}, ++ kRiscvS32x4InterleaveOdd}, ++ ++ {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}, ++ kRiscvS16x8InterleaveRight}, ++ {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}, ++ kRiscvS16x8InterleaveLeft}, ++ {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}, ++ kRiscvS16x8PackEven}, ++ {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}, ++ kRiscvS16x8PackOdd}, ++ {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}, ++ kRiscvS16x8InterleaveEven}, ++ {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}, ++ kRiscvS16x8InterleaveOdd}, ++ {{6, 7, 4, 5, 2, 3, 0, 1, 14, 15, 12, 13, 10, 11, 8, 9}, ++ kRiscvS16x4Reverse}, ++ {{2, 3, 0, 1, 6, 7, 4, 5, 10, 11, 8, 9, 14, 15, 12, 13}, ++ kRiscvS16x2Reverse}, ++ ++ {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}, ++ kRiscvS8x16InterleaveRight}, ++ {{8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31}, ++ kRiscvS8x16InterleaveLeft}, ++ {{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}, ++ kRiscvS8x16PackEven}, ++ {{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, ++ kRiscvS8x16PackOdd}, ++ {{0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30}, ++ kRiscvS8x16InterleaveEven}, ++ {{1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31}, ++ kRiscvS8x16InterleaveOdd}, ++ {{7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8}, kRiscvS8x8Reverse}, ++ {{3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12}, kRiscvS8x4Reverse}, ++ {{1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14}, ++ kRiscvS8x2Reverse}}; ++ ++bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table, ++ size_t num_entries, bool is_swizzle, ++ ArchOpcode* opcode) { ++ uint8_t mask = is_swizzle ? kSimd128Size - 1 : 2 * kSimd128Size - 1; ++ for (size_t i = 0; i < num_entries; ++i) { ++ const ShuffleEntry& entry = table[i]; ++ int j = 0; ++ for (; j < kSimd128Size; ++j) { ++ if ((entry.shuffle[j] & mask) != (shuffle[j] & mask)) { ++ break; ++ } ++ } ++ if (j == kSimd128Size) { ++ *opcode = entry.opcode; ++ return true; ++ } ++ } ++ return false; ++} ++ ++} // namespace ++ ++void InstructionSelector::VisitI8x16Shuffle(Node* node) { ++ uint8_t shuffle[kSimd128Size]; ++ bool is_swizzle; ++ CanonicalizeShuffle(node, shuffle, &is_swizzle); ++ uint8_t shuffle32x4[4]; ++ ArchOpcode opcode; ++ if (TryMatchArchShuffle(shuffle, arch_shuffles, arraysize(arch_shuffles), ++ is_swizzle, &opcode)) { ++ VisitRRR(this, opcode, node); ++ return; ++ } ++ Node* input0 = node->InputAt(0); ++ Node* input1 = node->InputAt(1); ++ uint8_t offset; ++ RiscvOperandGenerator g(this); ++ if (wasm::SimdShuffle::TryMatchConcat(shuffle, &offset)) { ++ Emit(kRiscvS8x16Concat, g.DefineSameAsFirst(node), g.UseRegister(input1), ++ g.UseRegister(input0), g.UseImmediate(offset)); ++ return; ++ } ++ if (wasm::SimdShuffle::TryMatch32x4Shuffle(shuffle, shuffle32x4)) { ++ Emit(kRiscvS32x4Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), ++ g.UseRegister(input1), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4))); ++ return; ++ } ++ Emit(kRiscvI8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0), ++ g.UseRegister(input1), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)), ++ g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12))); ++} ++ ++void InstructionSelector::VisitI8x16Swizzle(Node* node) { ++ RiscvOperandGenerator g(this); ++ InstructionOperand temps[] = {g.TempSimd128Register()}; ++ // We don't want input 0 or input 1 to be the same as output, since we will ++ // modify output before do the calculation. ++ Emit(kRiscvI8x16Swizzle, g.DefineAsRegister(node), ++ g.UseUniqueRegister(node->InputAt(0)), ++ g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); ++} ++ ++void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord16ToInt32(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord8ToInt64(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvSignExtendByte, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord16ToInt64(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvSignExtendShort, g.DefineAsRegister(node), ++ g.UseRegister(node->InputAt(0))); ++} ++ ++void InstructionSelector::VisitSignExtendWord32ToInt64(Node* node) { ++ RiscvOperandGenerator g(this); ++ Emit(kRiscvShl32, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), ++ g.TempImmediate(0)); ++} ++ ++void InstructionSelector::VisitF32x4Pmin(Node* node) { ++ VisitUniqueRRR(this, kRiscvF32x4Pmin, node); ++} ++ ++void InstructionSelector::VisitF32x4Pmax(Node* node) { ++ VisitUniqueRRR(this, kRiscvF32x4Pmax, node); ++} ++ ++void InstructionSelector::VisitF64x2Pmin(Node* node) { ++ VisitUniqueRRR(this, kRiscvF64x2Pmin, node); ++} ++ ++void InstructionSelector::VisitF64x2Pmax(Node* node) { ++ VisitUniqueRRR(this, kRiscvF64x2Pmax, node); ++} ++ ++// static ++MachineOperatorBuilder::Flags ++InstructionSelector::SupportedMachineOperatorFlags() { ++ MachineOperatorBuilder::Flags flags = MachineOperatorBuilder::kNoFlags; ++ return flags | MachineOperatorBuilder::kWord32ShiftIsSafe | ++ MachineOperatorBuilder::kInt32DivIsSafe | ++ MachineOperatorBuilder::kUint32DivIsSafe | ++ MachineOperatorBuilder::kFloat64RoundDown | ++ MachineOperatorBuilder::kFloat32RoundDown | ++ MachineOperatorBuilder::kFloat64RoundUp | ++ MachineOperatorBuilder::kFloat32RoundUp | ++ MachineOperatorBuilder::kFloat64RoundTruncate | ++ MachineOperatorBuilder::kFloat32RoundTruncate | ++ MachineOperatorBuilder::kFloat64RoundTiesEven | ++ MachineOperatorBuilder::kFloat32RoundTiesEven; ++} ++ ++// static ++MachineOperatorBuilder::AlignmentRequirements ++InstructionSelector::AlignmentRequirements() { ++ return MachineOperatorBuilder::AlignmentRequirements:: ++ NoUnalignedAccessSupport(); ++} ++ ++#undef SIMD_BINOP_LIST ++#undef SIMD_SHIFT_OP_LIST ++#undef SIMD_UNOP_LIST ++#undef SIMD_TYPE_LIST ++#undef TRACE_UNIMPL ++#undef TRACE ++ ++} // namespace compiler ++} // namespace internal ++} // namespace v8 +--- a/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc ++++ b/src/3rdparty/chromium/v8/src/compiler/c-linkage.cc +@@ -131,6 +131,19 @@ + d8.bit() | d9.bit() | d10.bit() | d11.bit() | d12.bit() | d13.bit() | \ + d14.bit() | d15.bit() + ++#elif V8_TARGET_ARCH_RISCV64 ++// =========================================================================== ++// == riscv64 ================================================================= ++// =========================================================================== ++#define PARAM_REGISTERS a0, a1, a2, a3, a4, a5, a6, a7 ++// fp is not part of CALLEE_SAVE_REGISTERS (similar to how MIPS64 or PPC defines ++// it) ++#define CALLEE_SAVE_REGISTERS \ ++ s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | s6.bit() | s7.bit() | \ ++ s8.bit() | s9.bit() | s10.bit() | s11.bit() ++#define CALLEE_SAVE_FP_REGISTERS \ ++ fs0.bit() | fs1.bit() | fs2.bit() | fs3.bit() | fs4.bit() | fs5.bit() | \ ++ fs6.bit() | fs7.bit() | fs8.bit() | fs9.bit() | fs10.bit() | fs11.bit() + #else + // =========================================================================== + // == unknown ================================================================ +--- a/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc ++++ b/src/3rdparty/chromium/v8/src/debug/debug-evaluate.cc +@@ -1060,8 +1060,10 @@ + } + } + CHECK(!failed); +-#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ +- defined(V8_TARGET_ARCH_MIPS64) ++ // FIXME (RISCV): does RISCV need this? ++#if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ ++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_RISCV64) || \ ++ defined(V8_TARGET_ARCH_RISCV) + // Isolate-independent builtin calls and jumps do not emit reloc infos + // on PPC. We try to avoid using PC relative code due to performance + // issue with especially older hardwares. +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/debug/riscv64/debug-riscv64.cc +@@ -0,0 +1,55 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/debug/debug.h" ++#include "src/debug/liveedit.h" ++#include "src/execution/frames-inl.h" ++ ++namespace v8 { ++namespace internal { ++ ++#define __ ACCESS_MASM(masm) ++ ++void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { ++ { ++ FrameScope scope(masm, StackFrame::INTERNAL); ++ __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); ++ } ++ __ MaybeDropFrames(); ++ ++ // Return to caller. ++ __ Ret(); ++} ++ ++void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { ++ // Frame is being dropped: ++ // - Drop to the target frame specified by a1. ++ // - Look up current function on the frame. ++ // - Leave the frame. ++ // - Restart the frame by calling the function. ++ __ mv(fp, a1); ++ __ Ld(a1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ ++ // Pop return address and frame. ++ __ LeaveFrame(StackFrame::INTERNAL); ++ ++ __ Ld(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); ++ __ Lhu(a0, ++ FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); ++ __ mv(a2, a0); ++ ++ __ InvokeFunction(a1, a2, a0, JUMP_FUNCTION); ++} ++ ++const bool LiveEdit::kFrameDropperSupported = true; ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/deoptimizer/riscv64/deoptimizer-riscv64.cc +@@ -0,0 +1,240 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/register-configuration.h" ++#include "src/codegen/safepoint-table.h" ++#include "src/deoptimizer/deoptimizer.h" ++ ++namespace v8 { ++namespace internal { ++ ++const bool Deoptimizer::kSupportsFixedDeoptExitSizes = false; ++const int Deoptimizer::kNonLazyDeoptExitSize = 0; ++const int Deoptimizer::kLazyDeoptExitSize = 0; ++ ++#define __ masm-> ++ ++// This code tries to be close to ia32 code so that any changes can be ++// easily ported. ++void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm, ++ Isolate* isolate, ++ DeoptimizeKind deopt_kind) { ++ NoRootArrayScope no_root_array(masm); ++ ++ // Unlike on ARM we don't save all the registers, just the useful ones. ++ // For the rest, there are gaps on the stack, so the offsets remain the same. ++ const int kNumberOfRegisters = Register::kNumRegisters; ++ ++ RegList restored_regs = kJSCallerSaved | kCalleeSaved; ++ RegList saved_regs = restored_regs | sp.bit() | ra.bit(); ++ ++ const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; ++ ++ // Save all double FPU registers before messing with them. ++ __ Sub64(sp, sp, Operand(kDoubleRegsSize)); ++ const RegisterConfiguration* config = RegisterConfiguration::Default(); ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); ++ int offset = code * kDoubleSize; ++ __ StoreDouble(fpu_reg, MemOperand(sp, offset)); ++ } ++ ++ // Push saved_regs (needed to populate FrameDescription::registers_). ++ // Leave gaps for other registers. ++ __ Sub64(sp, sp, kNumberOfRegisters * kPointerSize); ++ for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { ++ if ((saved_regs & (1 << i)) != 0) { ++ __ Sd(ToRegister(i), MemOperand(sp, kPointerSize * i)); ++ } ++ } ++ ++ __ li(a2, Operand(ExternalReference::Create( ++ IsolateAddressId::kCEntryFPAddress, isolate))); ++ __ Sd(fp, MemOperand(a2)); ++ ++ const int kSavedRegistersAreaSize = ++ (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; ++ ++ // Get the bailout is passed as kRootRegister by the caller. ++ __ mv(a2, kRootRegister); ++ ++ // Get the address of the location in the code object (a3) (return ++ // address for lazy deoptimization) and compute the fp-to-sp delta in ++ // register a4. ++ __ mv(a3, ra); ++ __ Add64(a4, sp, Operand(kSavedRegistersAreaSize)); ++ ++ __ Sub64(a4, fp, a4); ++ ++ // Allocate a new deoptimizer object. ++ __ PrepareCallCFunction(6, a5); ++ // Pass six arguments, according to n64 ABI. ++ __ mv(a0, zero_reg); ++ Label context_check; ++ __ Ld(a1, MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); ++ __ JumpIfSmi(a1, &context_check); ++ __ Ld(a0, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); ++ __ bind(&context_check); ++ __ li(a1, Operand(static_cast(deopt_kind))); ++ // a2: bailout id already loaded. ++ // a3: code address or 0 already loaded. ++ // a4: already has fp-to-sp delta. ++ __ li(a5, Operand(ExternalReference::isolate_address(isolate))); ++ ++ // Call Deoptimizer::New(). ++ { ++ AllowExternalCallThatCantCauseGC scope(masm); ++ __ CallCFunction(ExternalReference::new_deoptimizer_function(), 6); ++ } ++ ++ // Preserve "deoptimizer" object in register a0 and get the input ++ // frame descriptor pointer to a1 (deoptimizer->input_); ++ // Move deopt-obj to a0 for call to Deoptimizer::ComputeOutputFrames() below. ++ __ Ld(a1, MemOperand(a0, Deoptimizer::input_offset())); ++ ++ // Copy core registers into FrameDescription::registers_[kNumRegisters]. ++ DCHECK_EQ(Register::kNumRegisters, kNumberOfRegisters); ++ for (int i = 0; i < kNumberOfRegisters; i++) { ++ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); ++ if ((saved_regs & (1 << i)) != 0) { ++ __ Ld(a2, MemOperand(sp, i * kPointerSize)); ++ __ Sd(a2, MemOperand(a1, offset)); ++ } else if (FLAG_debug_code) { ++ __ li(a2, kDebugZapValue); ++ __ Sd(a2, MemOperand(a1, offset)); ++ } ++ } ++ ++ int double_regs_offset = FrameDescription::double_registers_offset(); ++ // Copy FPU registers to ++ // double_registers_[DoubleRegister::kNumAllocatableRegisters] ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ int dst_offset = code * kDoubleSize + double_regs_offset; ++ int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; ++ __ LoadDouble(ft0, MemOperand(sp, src_offset)); ++ __ StoreDouble(ft0, MemOperand(a1, dst_offset)); ++ } ++ ++ // Remove the saved registers from the stack. ++ __ Add64(sp, sp, Operand(kSavedRegistersAreaSize)); ++ ++ // Compute a pointer to the unwinding limit in register a2; that is ++ // the first stack slot not part of the input frame. ++ __ Ld(a2, MemOperand(a1, FrameDescription::frame_size_offset())); ++ __ Add64(a2, a2, sp); ++ ++ // Unwind the stack down to - but not including - the unwinding ++ // limit and copy the contents of the activation frame to the input ++ // frame description. ++ __ Add64(a3, a1, Operand(FrameDescription::frame_content_offset())); ++ Label pop_loop; ++ Label pop_loop_header; ++ __ BranchShort(&pop_loop_header); ++ __ bind(&pop_loop); ++ __ pop(a4); ++ __ Sd(a4, MemOperand(a3, 0)); ++ __ addi(a3, a3, sizeof(uint64_t)); ++ __ bind(&pop_loop_header); ++ __ BranchShort(&pop_loop, ne, a2, Operand(sp)); ++ // Compute the output frame in the deoptimizer. ++ __ push(a0); // Preserve deoptimizer object across call. ++ // a0: deoptimizer object; a1: scratch. ++ __ PrepareCallCFunction(1, a1); ++ // Call Deoptimizer::ComputeOutputFrames(). ++ { ++ AllowExternalCallThatCantCauseGC scope(masm); ++ __ CallCFunction(ExternalReference::compute_output_frames_function(), 1); ++ } ++ __ pop(a0); // Restore deoptimizer object (class Deoptimizer). ++ ++ __ Ld(sp, MemOperand(a0, Deoptimizer::caller_frame_top_offset())); ++ ++ // Replace the current (input) frame with the output frames. ++ Label outer_push_loop, inner_push_loop, outer_loop_header, inner_loop_header; ++ // Outer loop state: a4 = current "FrameDescription** output_", ++ // a1 = one past the last FrameDescription**. ++ __ Lw(a1, MemOperand(a0, Deoptimizer::output_count_offset())); ++ __ Ld(a4, MemOperand(a0, Deoptimizer::output_offset())); // a4 is output_. ++ __ CalcScaledAddress(a1, a4, a1, kPointerSizeLog2); ++ __ BranchShort(&outer_loop_header); ++ __ bind(&outer_push_loop); ++ // Inner loop state: a2 = current FrameDescription*, a3 = loop index. ++ __ Ld(a2, MemOperand(a4, 0)); // output_[ix] ++ __ Ld(a3, MemOperand(a2, FrameDescription::frame_size_offset())); ++ __ BranchShort(&inner_loop_header); ++ __ bind(&inner_push_loop); ++ __ Sub64(a3, a3, Operand(sizeof(uint64_t))); ++ __ Add64(a6, a2, Operand(a3)); ++ __ Ld(a7, MemOperand(a6, FrameDescription::frame_content_offset())); ++ __ push(a7); ++ __ bind(&inner_loop_header); ++ __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); ++ ++ __ Add64(a4, a4, Operand(kPointerSize)); ++ __ bind(&outer_loop_header); ++ __ BranchShort(&outer_push_loop, lt, a4, Operand(a1)); ++ ++ __ Ld(a1, MemOperand(a0, Deoptimizer::input_offset())); ++ for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { ++ int code = config->GetAllocatableDoubleCode(i); ++ const DoubleRegister fpu_reg = DoubleRegister::from_code(code); ++ int src_offset = code * kDoubleSize + double_regs_offset; ++ __ LoadDouble(fpu_reg, MemOperand(a1, src_offset)); ++ } ++ ++ // Push pc and continuation from the last output frame. ++ __ Ld(a6, MemOperand(a2, FrameDescription::pc_offset())); ++ __ push(a6); ++ __ Ld(a6, MemOperand(a2, FrameDescription::continuation_offset())); ++ __ push(a6); ++ ++ // Technically restoring 't3' should work unless zero_reg is also restored ++ // but it's safer to check for this. ++ DCHECK(!(t3.bit() & restored_regs)); ++ // Restore the registers from the last output frame. ++ __ mv(t3, a2); ++ for (int i = kNumberOfRegisters - 1; i >= 0; i--) { ++ int offset = (i * kPointerSize) + FrameDescription::registers_offset(); ++ if ((restored_regs & (1 << i)) != 0) { ++ __ Ld(ToRegister(i), MemOperand(t3, offset)); ++ } ++ } ++ ++ __ pop(t3); // Get continuation, leave pc on stack. ++ __ pop(ra); ++ __ Jump(t3); ++ __ stop(); ++} ++ ++// Maximum size of a table entry generated below. ++// FIXME(RISCV): Is this value correct? ++const int Deoptimizer::table_entry_size_ = 2 * kInstrSize; ++ ++Float32 RegisterValues::GetFloatRegister(unsigned n) const { ++ return Float32::FromBits( ++ static_cast(double_registers_[n].get_bits())); ++} ++ ++void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { ++ SetFrameSlot(offset, value); ++} ++ ++void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { ++ SetFrameSlot(offset, value); ++} ++ ++void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { ++ // No embedded constant pool support. ++ UNREACHABLE(); ++} ++ ++void FrameDescription::SetPc(intptr_t pc) { pc_ = pc; } ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 +--- a/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h ++++ b/src/3rdparty/chromium/v8/src/diagnostics/perf-jit.h +@@ -86,6 +86,7 @@ + static const uint32_t kElfMachARM64 = 183; + static const uint32_t kElfMachS390x = 22; + static const uint32_t kElfMachPPC64 = 21; ++ static const uint32_t kElfMachRISCV = 243; + + uint32_t GetElfMach() { + #if V8_TARGET_ARCH_IA32 +@@ -104,6 +105,8 @@ + return kElfMachS390x; + #elif V8_TARGET_ARCH_PPC64 + return kElfMachPPC64; ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ return kElfMachRISCV; + #else + UNIMPLEMENTED(); + return 0; +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/diagnostics/riscv64/disasm-riscv64.cc +@@ -0,0 +1,1448 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// A Disassembler object is used to disassemble a block of code instruction by ++// instruction. The default implementation of the NameConverter object can be ++// overriden to modify register names or to do symbol lookup on addresses. ++// ++// The example below will disassemble a block of code and print it to stdout. ++// ++// NameConverter converter; ++// Disassembler d(converter); ++// for (byte* pc = begin; pc < end;) { ++// v8::internal::EmbeddedVector buffer; ++// byte* prev_pc = pc; ++// pc += d.InstructionDecode(buffer, pc); ++// printf("%p %08x %s\n", ++// prev_pc, *reinterpret_cast(prev_pc), buffer); ++// } ++// ++// The Disassembler class also has a convenience method to disassemble a block ++// of code into a FILE*, meaning that the above functionality could also be ++// achieved by just calling Disassembler::Disassemble(stdout, begin, end); ++ ++#include ++#include ++#include ++#include ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/base/platform/platform.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/diagnostics/disasm.h" ++ ++namespace v8 { ++namespace internal { ++ ++//------------------------------------------------------------------------------ ++ ++// Decoder decodes and disassembles instructions into an output buffer. ++// It uses the converter to convert register names and call destinations into ++// more informative description. ++class Decoder { ++ public: ++ Decoder(const disasm::NameConverter& converter, ++ v8::internal::Vector out_buffer) ++ : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) { ++ out_buffer_[out_buffer_pos_] = '\0'; ++ } ++ ++ ~Decoder() {} ++ ++ // Writes one disassembled instruction into 'buffer' (0-terminated). ++ // Returns the length of the disassembled machine instruction in bytes. ++ int InstructionDecode(byte* instruction); ++ ++ private: ++ // Bottleneck functions to print into the out_buffer. ++ void PrintChar(const char ch); ++ void Print(const char* str); ++ ++ // Printing of common values. ++ void PrintRegister(int reg); ++ void PrintFPURegister(int freg); ++ void PrintFPUStatusRegister(int freg); ++ void PrintRs1(Instruction* instr); ++ void PrintRs2(Instruction* instr); ++ void PrintRd(Instruction* instr); ++ void PrintVs1(Instruction* instr); ++ void PrintFRs1(Instruction* instr); ++ void PrintFRs2(Instruction* instr); ++ void PrintFRs3(Instruction* instr); ++ void PrintFRd(Instruction* instr); ++ void PrintImm12(Instruction* instr); ++ void PrintImm12X(Instruction* instr); ++ void PrintImm20U(Instruction* instr); ++ void PrintImm20J(Instruction* instr); ++ void PrintShamt(Instruction* instr); ++ void PrintShamt32(Instruction* instr); ++ void PrintAcquireRelease(Instruction* instr); ++ void PrintBranchOffset(Instruction* instr); ++ void PrintStoreOffset(Instruction* instr); ++ void PrintCSRReg(Instruction* instr); ++ void PrintRoundingMode(Instruction* instr); ++ void PrintMemoryOrder(Instruction* instr, bool is_pred); ++ ++ // Each of these functions decodes one particular instruction type. ++ void DecodeRType(Instruction* instr); ++ void DecodeR4Type(Instruction* instr); ++ void DecodeRAType(Instruction* instr); ++ void DecodeRFPType(Instruction* instr); ++ void DecodeIType(Instruction* instr); ++ void DecodeSType(Instruction* instr); ++ void DecodeBType(Instruction* instr); ++ void DecodeUType(Instruction* instr); ++ void DecodeJType(Instruction* instr); ++ ++ // Printing of instruction name. ++ void PrintInstructionName(Instruction* instr); ++ ++ // Handle formatting of instructions and their options. ++ int FormatRegister(Instruction* instr, const char* option); ++ int FormatFPURegisterOrRoundMode(Instruction* instr, const char* option); ++ int FormatOption(Instruction* instr, const char* option); ++ void Format(Instruction* instr, const char* format); ++ void Unknown(Instruction* instr); ++ ++ const disasm::NameConverter& converter_; ++ v8::internal::Vector out_buffer_; ++ int out_buffer_pos_; ++ ++ DISALLOW_COPY_AND_ASSIGN(Decoder); ++}; ++ ++// Support for assertions in the Decoder formatting functions. ++#define STRING_STARTS_WITH(string, compare_string) \ ++ (strncmp(string, compare_string, strlen(compare_string)) == 0) ++ ++// Append the ch to the output buffer. ++void Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; } ++ ++// Append the str to the output buffer. ++void Decoder::Print(const char* str) { ++ char cur = *str++; ++ while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) { ++ PrintChar(cur); ++ cur = *str++; ++ } ++ out_buffer_[out_buffer_pos_] = 0; ++} ++ ++// Print the register name according to the active name converter. ++void Decoder::PrintRegister(int reg) { ++ Print(converter_.NameOfCPURegister(reg)); ++} ++ ++void Decoder::PrintRs1(Instruction* instr) { ++ int reg = instr->Rs1Value(); ++ PrintRegister(reg); ++} ++ ++void Decoder::PrintRs2(Instruction* instr) { ++ int reg = instr->Rs2Value(); ++ PrintRegister(reg); ++} ++ ++void Decoder::PrintRd(Instruction* instr) { ++ int reg = instr->RdValue(); ++ PrintRegister(reg); ++} ++ ++void Decoder::PrintVs1(Instruction* instr) { ++ int val = instr->Rs1Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", val); ++} ++ ++// Print the FPUregister name according to the active name converter. ++void Decoder::PrintFPURegister(int freg) { ++ Print(converter_.NameOfXMMRegister(freg)); ++} ++ ++void Decoder::PrintFRs1(Instruction* instr) { ++ int reg = instr->Rs1Value(); ++ PrintFPURegister(reg); ++} ++ ++void Decoder::PrintFRs2(Instruction* instr) { ++ int reg = instr->Rs2Value(); ++ PrintFPURegister(reg); ++} ++ ++void Decoder::PrintFRs3(Instruction* instr) { ++ int reg = instr->Rs3Value(); ++ PrintFPURegister(reg); ++} ++ ++void Decoder::PrintFRd(Instruction* instr) { ++ int reg = instr->RdValue(); ++ PrintFPURegister(reg); ++} ++ ++void Decoder::PrintImm12X(Instruction* instr) { ++ int32_t imm = instr->Imm12Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm); ++} ++ ++void Decoder::PrintImm12(Instruction* instr) { ++ int32_t imm = instr->Imm12Value(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); ++} ++ ++void Decoder::PrintBranchOffset(Instruction* instr) { ++ int32_t imm = instr->BranchOffset(); ++ const char* target = converter_.NameOfAddress(reinterpret_cast(instr) + imm); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d -> %s", imm, target); ++} ++ ++void Decoder::PrintStoreOffset(Instruction* instr) { ++ int32_t imm = instr->StoreOffset(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); ++} ++ ++void Decoder::PrintImm20U(Instruction* instr) { ++ int32_t imm = instr->Imm20UValue(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", imm); ++} ++ ++void Decoder::PrintImm20J(Instruction* instr) { ++ int32_t imm = instr->Imm20JValue(); ++ const char* target = converter_.NameOfAddress(reinterpret_cast(instr) + imm); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d -> %s", imm, target); ++} ++ ++void Decoder::PrintShamt(Instruction* instr) { ++ int32_t imm = instr->Shamt(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); ++} ++ ++void Decoder::PrintShamt32(Instruction* instr) { ++ int32_t imm = instr->Shamt32(); ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", imm); ++} ++ ++void Decoder::PrintAcquireRelease(Instruction* instr) { ++ bool aq = instr->AqValue(); ++ bool rl = instr->RlValue(); ++ if (aq || rl) { ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "."); ++ } ++ if (aq) { ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "aq"); ++ } ++ if (rl) { ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "rl"); ++ } ++} ++ ++void Decoder::PrintCSRReg(Instruction* instr) { ++ int32_t csr_reg = instr->CsrValue(); ++ std::string s; ++ switch (csr_reg) { ++ case csr_fflags: // Floating-Point Accrued Exceptions (RW) ++ s = "csr_fflags"; ++ break; ++ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) ++ s = "csr_frm"; ++ break; ++ case csr_fcsr: // Floating-Point Control and Status Register (RW) ++ s = "csr_fcsr"; ++ break; ++ case csr_cycle: ++ s = "csr_cycle"; ++ break; ++ case csr_time: ++ s = "csr_time"; ++ break; ++ case csr_instret: ++ s = "csr_instret"; ++ break; ++ case csr_cycleh: ++ s = "csr_cycleh"; ++ break; ++ case csr_timeh: ++ s = "csr_timeh"; ++ break; ++ case csr_instreth: ++ s = "csr_instreth"; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); ++} ++ ++void Decoder::PrintRoundingMode(Instruction* instr) { ++ int frm = instr->RoundMode(); ++ std::string s; ++ switch (frm) { ++ case RNE: ++ s = "RNE"; ++ break; ++ case RTZ: ++ s = "RTZ"; ++ break; ++ case RDN: ++ s = "RDN"; ++ break; ++ case RUP: ++ s = "RUP"; ++ break; ++ case RMM: ++ s = "RMM"; ++ break; ++ case DYN: ++ s = "DYN"; ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); ++} ++ ++void Decoder::PrintMemoryOrder(Instruction* instr, bool is_pred) { ++ int memOrder = instr->MemoryOrder(is_pred); ++ std::string s; ++ if ((memOrder & PSI) == PSI) { ++ s += "i"; ++ } ++ if ((memOrder & PSO) == PSO) { ++ s += "o"; ++ } ++ if ((memOrder & PSR) == PSR) { ++ s += "r"; ++ } ++ if ((memOrder & PSW) == PSW) { ++ s += "w"; ++ } ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%s", s.c_str()); ++} ++ ++// Printing of instruction name. ++void Decoder::PrintInstructionName(Instruction* instr) {} ++ ++// Handle all register based formatting in this function to reduce the ++// complexity of FormatOption. ++int Decoder::FormatRegister(Instruction* instr, const char* format) { ++ DCHECK_EQ(format[0], 'r'); ++ if (format[1] == 's') { // 'rs[12]: Rs register. ++ if (format[2] == '1') { ++ int reg = instr->Rs1Value(); ++ PrintRegister(reg); ++ return 3; ++ } else if (format[2] == '2') { ++ int reg = instr->Rs2Value(); ++ PrintRegister(reg); ++ return 3; ++ } ++ UNREACHABLE(); ++ } else if (format[1] == 'd') { // 'rd: rd register. ++ int reg = instr->RdValue(); ++ PrintRegister(reg); ++ return 2; ++ } ++ UNREACHABLE(); ++} ++ ++// Handle all FPUregister based formatting in this function to reduce the ++// complexity of FormatOption. ++int Decoder::FormatFPURegisterOrRoundMode(Instruction* instr, ++ const char* format) { ++ DCHECK_EQ(format[0], 'f'); ++ if (format[1] == 's') { // 'fs[1-3]: Rs register. ++ if (format[2] == '1') { ++ int reg = instr->Rs1Value(); ++ PrintFPURegister(reg); ++ return 3; ++ } else if (format[2] == '2') { ++ int reg = instr->Rs2Value(); ++ PrintFPURegister(reg); ++ return 3; ++ } else if (format[2] == '3') { ++ int reg = instr->Rs3Value(); ++ PrintFPURegister(reg); ++ return 3; ++ } ++ UNREACHABLE(); ++ } else if (format[1] == 'd') { // 'fd: fd register. ++ int reg = instr->RdValue(); ++ PrintFPURegister(reg); ++ return 2; ++ } else if (format[1] == 'r') { // 'frm ++ DCHECK(STRING_STARTS_WITH(format, "frm")); ++ PrintRoundingMode(instr); ++ return 3; ++ } ++ UNREACHABLE(); ++} ++ ++// FormatOption takes a formatting string and interprets it based on ++// the current instructions. The format string points to the first ++// character of the option string (the option escape has already been ++// consumed by the caller.) FormatOption returns the number of ++// characters that were consumed from the formatting string. ++int Decoder::FormatOption(Instruction* instr, const char* format) { ++ switch (format[0]) { ++ case 'c': { // `csr: CSR registers ++ if (format[1] == 's') { ++ if (format[2] == 'r') { ++ PrintCSRReg(instr); ++ return 3; ++ } ++ } ++ UNREACHABLE(); ++ } ++ case 'i': { // 'imm12, 'imm12x, 'imm20U, or 'imm20J: Immediates. ++ if (format[3] == '1') { ++ if (format[4] == '2') { ++ DCHECK(STRING_STARTS_WITH(format, "imm12")); ++ if (format[5] == 'x') { ++ PrintImm12X(instr); ++ return 6; ++ } ++ PrintImm12(instr); ++ return 5; ++ } ++ } else if (format[3] == '2' && format[4] == '0') { ++ DCHECK(STRING_STARTS_WITH(format, "imm20")); ++ switch (format[5]) { ++ case 'U': ++ DCHECK(STRING_STARTS_WITH(format, "imm20U")); ++ PrintImm20U(instr); ++ break; ++ case 'J': ++ DCHECK(STRING_STARTS_WITH(format, "imm20J")); ++ PrintImm20J(instr); ++ break; ++ } ++ return 6; ++ } ++ UNREACHABLE(); ++ } ++ case 'o': { // 'offB or 'offS: Offsets. ++ if (format[3] == 'B') { ++ DCHECK(STRING_STARTS_WITH(format, "offB")); ++ PrintBranchOffset(instr); ++ return 4; ++ } else if (format[3] == 'S') { ++ DCHECK(STRING_STARTS_WITH(format, "offS")); ++ PrintStoreOffset(instr); ++ return 4; ++ } ++ UNREACHABLE(); ++ } ++ case 'r': { // 'r: registers. ++ return FormatRegister(instr, format); ++ } ++ case 'f': { // 'f: FPUregisters or `frm ++ return FormatFPURegisterOrRoundMode(instr, format); ++ } ++ case 'a': { // 'a: Atomic acquire and release. ++ PrintAcquireRelease(instr); ++ return 1; ++ } ++ case 'p': { // `pre ++ DCHECK(STRING_STARTS_WITH(format, "pre")); ++ PrintMemoryOrder(instr, true); ++ return 3; ++ } ++ case 's': { // 's32 or 's64: Shift amount. ++ if (format[1] == '3') { ++ DCHECK(STRING_STARTS_WITH(format, "s32")); ++ PrintShamt32(instr); ++ return 3; ++ } else if (format[1] == '6') { ++ DCHECK(STRING_STARTS_WITH(format, "s64")); ++ PrintShamt(instr); ++ return 3; ++ } else if (format[1] == 'u') { ++ DCHECK(STRING_STARTS_WITH(format, "suc")); ++ PrintMemoryOrder(instr, false); ++ return 3; ++ } ++ UNREACHABLE(); ++ } ++ case 'v': { // 'vs1: Raw values from register fields ++ DCHECK(STRING_STARTS_WITH(format, "vs1")); ++ PrintVs1(instr); ++ return 3; ++ } ++ } ++ UNREACHABLE(); ++} ++ ++// Format takes a formatting string for a whole instruction and prints it into ++// the output buffer. All escaped options are handed to FormatOption to be ++// parsed further. ++void Decoder::Format(Instruction* instr, const char* format) { ++ char cur = *format++; ++ while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) { ++ if (cur == '\'') { // Single quote is used as the formatting escape. ++ format += FormatOption(instr, format); ++ } else { ++ out_buffer_[out_buffer_pos_++] = cur; ++ } ++ cur = *format++; ++ } ++ out_buffer_[out_buffer_pos_] = '\0'; ++} ++ ++// For currently unimplemented decodings the disassembler calls Unknown(instr) ++// which will just print "unknown" of the instruction bits. ++void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); } ++ ++// RISCV Instruction Decode Routine ++void Decoder::DecodeRType(Instruction* instr) { ++ switch (instr->InstructionBits() & kRTypeMask) { ++ case RO_ADD: ++ Format(instr, "add 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SUB: ++ if (instr->Rs1Value() == zero_reg.code()) ++ Format(instr, "neg 'rd, rs2"); ++ else ++ Format(instr, "sub 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SLL: ++ Format(instr, "sll 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SLT: ++ if (instr->Rs2Value() == zero_reg.code()) ++ Format(instr, "sltz 'rd, 'rs1"); ++ else if (instr->Rs1Value() == zero_reg.code()) ++ Format(instr, "sgtz 'rd, 'rs2"); ++ else ++ Format(instr, "slt 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SLTU: ++ if (instr->Rs1Value() == zero_reg.code()) ++ Format(instr, "snez 'rd, 'rs2"); ++ else ++ Format(instr, "sltu 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_XOR: ++ Format(instr, "xor 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SRL: ++ Format(instr, "srl 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SRA: ++ Format(instr, "sra 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_OR: ++ Format(instr, "or 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_AND: ++ Format(instr, "and 'rd, 'rs1, 'rs2"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_ADDW: ++ Format(instr, "addw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SUBW: ++ if (instr->Rs1Value() == zero_reg.code()) ++ Format(instr, "negw 'rd, 'rs2"); ++ else ++ Format(instr, "subw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SLLW: ++ Format(instr, "sllw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SRLW: ++ Format(instr, "srlw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_SRAW: ++ Format(instr, "sraw 'rd, 'rs1, 'rs2"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ // TODO: Add RISCV M extension macro ++ case RO_MUL: ++ Format(instr, "mul 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_MULH: ++ Format(instr, "mulh 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_MULHSU: ++ Format(instr, "mulhsu 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_MULHU: ++ Format(instr, "mulhu 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_DIV: ++ Format(instr, "div 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_DIVU: ++ Format(instr, "divu 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_REM: ++ Format(instr, "rem 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_REMU: ++ Format(instr, "remu 'rd, 'rs1, 'rs2"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_MULW: ++ Format(instr, "mulw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_DIVW: ++ Format(instr, "divw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_DIVUW: ++ Format(instr, "divuw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_REMW: ++ Format(instr, "remw 'rd, 'rs1, 'rs2"); ++ break; ++ case RO_REMUW: ++ Format(instr, "remuw 'rd, 'rs1, 'rs2"); ++ break; ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: End Add RISCV M extension macro ++ default: { ++ switch (instr->BaseOpcode()) { ++ case AMO: ++ DecodeRAType(instr); ++ break; ++ case OP_FP: ++ DecodeRFPType(instr); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ } ++ } ++} ++ ++void Decoder::DecodeRAType(Instruction* instr) { ++ // TODO: Add macro for RISCV A extension ++ // Special handling for A extension instructions because it uses func5 ++ // For all A extension instruction, V8 simulator is pure sequential. No ++ // Memory address lock or other synchronizaiton behaviors. ++ switch (instr->InstructionBits() & kRATypeMask) { ++ case RO_LR_W: ++ Format(instr, "lr.w'a 'rd, ('rs1)"); ++ break; ++ case RO_SC_W: ++ Format(instr, "sc.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOSWAP_W: ++ Format(instr, "amoswap.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOADD_W: ++ Format(instr, "amoadd.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOXOR_W: ++ Format(instr, "amoxor.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOAND_W: ++ Format(instr, "amoand.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOOR_W: ++ Format(instr, "amoor.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMIN_W: ++ Format(instr, "amomin.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMAX_W: ++ Format(instr, "amomax.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMINU_W: ++ Format(instr, "amominu.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMAXU_W: ++ Format(instr, "amomaxu.w'a 'rd, 'rs2, ('rs1)"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_LR_D: ++ Format(instr, "lr.d'a 'rd, ('rs1)"); ++ break; ++ case RO_SC_D: ++ Format(instr, "sc.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOSWAP_D: ++ Format(instr, "amoswap.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOADD_D: ++ Format(instr, "amoadd.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOXOR_D: ++ Format(instr, "amoxor.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOAND_D: ++ Format(instr, "amoand.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOOR_D: ++ Format(instr, "amoor.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMIN_D: ++ Format(instr, "amomin.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMAX_D: ++ Format(instr, "amoswap.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMINU_D: ++ Format(instr, "amominu.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++ case RO_AMOMAXU_D: ++ Format(instr, "amomaxu.d'a 'rd, 'rs2, ('rs1)"); ++ break; ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: End Add macro for RISCV A extension ++ default: { ++ UNSUPPORTED_RISCV(); ++ } ++ } ++} ++ ++void Decoder::DecodeRFPType(Instruction* instr) { ++ // OP_FP instructions (F/D) uses func7 first. Some further uses fun3 and rs2() ++ ++ // kRATypeMask is only for func7 ++ switch (instr->InstructionBits() & kRFPTypeMask) { ++ // TODO: Add macro for RISCV F extension ++ case RO_FADD_S: ++ Format(instr, "fadd.s 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FSUB_S: ++ Format(instr, "fsub.s 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FMUL_S: ++ Format(instr, "fmul.s 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FDIV_S: ++ Format(instr, "fdiv.s 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FSQRT_S: ++ Format(instr, "fsqrt.s 'fd, 'fs1"); ++ break; ++ case RO_FSGNJ_S: { // RO_FSGNJN_S RO_FSGNJX_S ++ switch (instr->Funct3Value()) { ++ case 0b000: // RO_FSGNJ_S ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fmv.s 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnj.s 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FSGNJN_S ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fneg.s 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnjn.s 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b010: // RO_FSGNJX_S ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fabs.s 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnjx.s 'fd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FMIN_S: { // RO_FMAX_S ++ switch (instr->Funct3Value()) { ++ case 0b000: // RO_FMIN_S ++ Format(instr, "fmin.s 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FMAX_S ++ Format(instr, "fmax.s 'fd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FCVT_W_S: { // RO_FCVT_WU_S , 64F RO_FCVT_L_S RO_FCVT_LU_S ++ switch (instr->Rs2Value()) { ++ case 0b00000: // RO_FCVT_W_S ++ Format(instr, "fcvt.w.s ['frm] 'rd, 'fs1"); ++ break; ++ case 0b00001: // RO_FCVT_WU_S ++ Format(instr, "fcvt.wu.s ['frm] 'rd, 'fs1"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: // RO_FCVT_L_S ++ Format(instr, "fcvt.l.s ['frm] 'rd, 'fs1"); ++ break; ++ case 0b00011: // RO_FCVT_LU_S ++ Format(instr, "fcvt.lu.s ['frm] 'rd, 'fs1"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FMV: { // RO_FCLASS_S ++ if (instr->Rs2Value() != 0b00000) { ++ UNSUPPORTED_RISCV(); ++ } ++ switch (instr->Funct3Value()) { ++ case 0b000: // RO_FMV_X_W ++ Format(instr, "fmv.x.w 'rd, 'fs1"); ++ break; ++ case 0b001: // RO_FCLASS_S ++ Format(instr, "fclass.s 'rd, 'fs1"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FLE_S: { // RO_FEQ_S RO_FLT_S RO_FLE_S ++ switch (instr->Funct3Value()) { ++ case 0b010: // RO_FEQ_S ++ Format(instr, "feq.s 'rd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FLT_S ++ Format(instr, "flt.s 'rd, 'fs1, 'fs2"); ++ break; ++ case 0b000: // RO_FLE_S ++ Format(instr, "fle.s 'rd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FCVT_S_W: { // RO_FCVT_S_WU , 64F RO_FCVT_S_L RO_FCVT_S_LU ++ switch (instr->Rs2Value()) { ++ case 0b00000: // RO_FCVT_S_W ++ Format(instr, "fcvt.s.w 'fd, 'rs1"); ++ break; ++ case 0b00001: // RO_FCVT_S_WU ++ Format(instr, "fcvt.s.wu 'fd, 'rs1"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: // RO_FCVT_S_L ++ Format(instr, "fcvt.s.l 'fd, 'rs1"); ++ break; ++ case 0b00011: // RO_FCVT_S_LU ++ Format(instr, "fcvt.s.lu 'fd, 'rs1"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED_RISCV(); ++ } ++ } ++ break; ++ } ++ case RO_FMV_W_X: { ++ if (instr->Funct3Value() == 0b000) { ++ Format(instr, "fmv.w.x 'fd, 'rs1"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ // TODO: Add macro for RISCV D extension ++ case RO_FADD_D: ++ Format(instr, "fadd.d 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FSUB_D: ++ Format(instr, "fsub.d 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FMUL_D: ++ Format(instr, "fmul.d 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FDIV_D: ++ Format(instr, "fdiv.d 'fd, 'fs1, 'fs2"); ++ break; ++ case RO_FSQRT_D: { ++ if (instr->Rs2Value() == 0b00000) { ++ Format(instr, "fsqrt.d 'fd, 'fs1"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FSGNJ_D: { // RO_FSGNJN_D RO_FSGNJX_D ++ switch (instr->Funct3Value()) { ++ case 0b000: // RO_FSGNJ_D ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fmv.d 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnj.d 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FSGNJN_D ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fneg.d 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnjn.d 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b010: // RO_FSGNJX_D ++ if (instr->Rs1Value() == instr->Rs2Value()) ++ Format(instr, "fabs.d 'fd, 'fs1"); ++ else ++ Format(instr, "fsgnjx.d 'fd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FMIN_D: { // RO_FMAX_D ++ switch (instr->Funct3Value()) { ++ case 0b000: // RO_FMIN_D ++ Format(instr, "fmin.d 'fd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FMAX_D ++ Format(instr, "fmax.d 'fd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case (RO_FCVT_S_D & kRFPTypeMask): { ++ if (instr->Rs2Value() == 0b00001) { ++ Format(instr, "fcvt.s.d ['frm] 'fd, 'rs1"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FCVT_D_S: { ++ if (instr->Rs2Value() == 0b00000) { ++ Format(instr, "fcvt.d.s 'fd, 'fs1"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FLE_D: { // RO_FEQ_D RO_FLT_D RO_FLE_D ++ switch (instr->Funct3Value()) { ++ case 0b010: // RO_FEQ_S ++ Format(instr, "feq.d 'rd, 'fs1, 'fs2"); ++ break; ++ case 0b001: // RO_FLT_D ++ Format(instr, "flt.d 'rd, 'fs1, 'fs2"); ++ break; ++ case 0b000: // RO_FLE_D ++ Format(instr, "fle.d 'rd, 'fs1, 'fs2"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case (RO_FCLASS_D & kRFPTypeMask): { // RO_FCLASS_D , 64D RO_FMV_X_D ++ if (instr->Rs2Value() != 0b00000) { ++ UNSUPPORTED_RISCV(); ++ break; ++ } ++ switch (instr->Funct3Value()) { ++ case 0b001: // RO_FCLASS_D ++ Format(instr, "fclass.d 'rd, 'fs1"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b000: // RO_FMV_X_D ++ Format(instr, "fmv.x.d 'rd, 'fs1"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FCVT_W_D: { // RO_FCVT_WU_D , 64F RO_FCVT_L_D RO_FCVT_LU_D ++ switch (instr->Rs2Value()) { ++ case 0b00000: // RO_FCVT_W_D ++ Format(instr, "fcvt.w.d ['frm] 'rd, 'fs1"); ++ break; ++ case 0b00001: // RO_FCVT_WU_D ++ Format(instr, "fcvt.wu.d ['frm] 'rd, 'fs1"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: // RO_FCVT_L_D ++ Format(instr, "fcvt.l.d ['frm] 'rd, 'fs1"); ++ break; ++ case 0b00011: // RO_FCVT_LU_D ++ Format(instr, "fcvt.lu.d ['frm] 'rd, 'fs1"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ case RO_FCVT_D_W: { // RO_FCVT_D_WU , 64F RO_FCVT_D_L RO_FCVT_D_LU ++ switch (instr->Rs2Value()) { ++ case 0b00000: // RO_FCVT_D_W ++ Format(instr, "fcvt.d.w 'fd, 'rs1"); ++ break; ++ case 0b00001: // RO_FCVT_D_WU ++ Format(instr, "fcvt.d.wu 'fd, 'rs1"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: // RO_FCVT_D_L ++ Format(instr, "fcvt.d.l 'fd, 'rs1"); ++ break; ++ case 0b00011: // RO_FCVT_D_LU ++ Format(instr, "fcvt.d.lu 'fd, 'rs1"); ++ break; ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_FMV_D_X: { ++ if (instr->Funct3Value() == 0b000 && instr->Rs2Value() == 0b00000) { ++ Format(instr, "fmv.d.x 'fd, 'rs1"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED_RISCV(); ++ } ++ } ++} ++ ++void Decoder::DecodeR4Type(Instruction* instr) { ++ switch (instr->InstructionBits() & kR4TypeMask) { ++ // TODO: use F Extension macro block ++ case RO_FMADD_S: ++ Format(instr, "fmadd.s 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FMSUB_S: ++ Format(instr, "fmsub.s 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FNMSUB_S: ++ Format(instr, "fnmsub.s 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FNMADD_S: ++ Format(instr, "fnmadd.s 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ // TODO: use F Extension macro block ++ case RO_FMADD_D: ++ Format(instr, "fmadd.d 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FMSUB_D: ++ Format(instr, "fmsub.d 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FNMSUB_D: ++ Format(instr, "fnmsub.d 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ case RO_FNMADD_D: ++ Format(instr, "fnmadd.d 'fd, 'fs1, 'fs2, 'fs3"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++ ++void Decoder::DecodeIType(Instruction* instr) { ++ switch (instr->InstructionBits() & kITypeMask) { ++ case RO_JALR: ++ if (instr->RdValue() == zero_reg.code() && ++ instr->Rs1Value() == ra.code() && instr->Imm12Value() == 0) ++ Format(instr, "ret"); ++ else if (instr->RdValue() == zero_reg.code() && instr->Imm12Value() == 0) ++ Format(instr, "jr 'rs1"); ++ else if (instr->RdValue() == ra.code() && instr->Imm12Value() == 0) ++ Format(instr, "jalr 'rs1"); ++ else ++ Format(instr, "jalr 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LB: ++ Format(instr, "lb 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LH: ++ Format(instr, "lh 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LW: ++ Format(instr, "lw 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LBU: ++ Format(instr, "lbu 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LHU: ++ Format(instr, "lhu 'rd, 'imm12('rs1)"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_LWU: ++ Format(instr, "lwu 'rd, 'imm12('rs1)"); ++ break; ++ case RO_LD: ++ Format(instr, "ld 'rd, 'imm12('rs1)"); ++ break; ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ case RO_ADDI: ++ if (instr->Imm12Value() == 0) { ++ if (instr->RdValue() == zero_reg.code() && ++ instr->Rs1Value() == zero_reg.code()) ++ Format(instr, "nop"); ++ else ++ Format(instr, "mv 'rd, 'rs1"); ++ } else if (instr->Rs1Value() == zero_reg.code()) { ++ Format(instr, "li 'rd, 'imm12"); ++ } else { ++ Format(instr, "addi 'rd, 'rs1, 'imm12"); ++ } ++ break; ++ case RO_SLTI: ++ Format(instr, "slti 'rd, 'rs1, 'imm12"); ++ break; ++ case RO_SLTIU: ++ if (instr->Imm12Value() == 1) ++ Format(instr, "seqz 'rd, 'rs1"); ++ else ++ Format(instr, "sltiu 'rd, 'rs1, 'imm12"); ++ break; ++ case RO_XORI: ++ if (instr->Imm12Value() == -1) ++ Format(instr, "not 'rd, 'rs1"); ++ else ++ Format(instr, "xori 'rd, 'rs1, 'imm12x"); ++ break; ++ case RO_ORI: ++ Format(instr, "ori 'rd, 'rs1, 'imm12x"); ++ break; ++ case RO_ANDI: ++ Format(instr, "andi 'rd, 'rs1, 'imm12x"); ++ break; ++ case RO_SLLI: ++ Format(instr, "slli 'rd, 'rs1, 's64"); ++ break; ++ case RO_SRLI: { // RO_SRAI ++ if (!instr->IsArithShift()) { ++ Format(instr, "srli 'rd, 'rs1, 's64"); ++ } else { ++ Format(instr, "srai 'rd, 'rs1, 's64"); ++ } ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_ADDIW: ++ if (instr->Imm12Value() == 0) ++ Format(instr, "sext.w 'rd, 'rs1"); ++ else ++ Format(instr, "addiw 'rd, 'rs1, 'imm12"); ++ break; ++ case RO_SLLIW: ++ Format(instr, "slliw 'rd, 'rs1, 's32"); ++ break; ++ case RO_SRLIW: { // RO_SRAIW ++ if (!instr->IsArithShift()) { ++ Format(instr, "srliw 'rd, 'rs1, 's32"); ++ } else { ++ Format(instr, "sraiw 'rd, 'rs1, 's32"); ++ } ++ break; ++ } ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ case RO_FENCE: ++ if (instr->MemoryOrder(true) == PSIORW && ++ instr->MemoryOrder(false) == PSIORW) ++ Format(instr, "fence"); ++ else ++ Format(instr, "fence 'pre, 'suc"); ++ break; ++ case RO_ECALL: { // RO_EBREAK ++ if (instr->Imm12Value() == 0) { // ECALL ++ Format(instr, "ecall"); ++ } else if (instr->Imm12Value() == 1) { // EBREAK ++ Format(instr, "ebreak"); ++ } else { ++ UNSUPPORTED_RISCV(); ++ } ++ break; ++ } ++ // TODO: use Zifencei Standard Extension macro block ++ case RO_FENCE_I: ++ Format(instr, "fence.i"); ++ break; ++ // TODO: use Zicsr Standard Extension macro block ++ // FIXME(RISC-V): Add special formatting for CSR registers ++ case RO_CSRRW: ++ if (instr->CsrValue() == csr_fcsr) { ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "fscsr 'rs1"); ++ else ++ Format(instr, "fscsr 'rd, 'rs1"); ++ } else if (instr->CsrValue() == csr_frm) { ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "fsrm 'rs1"); ++ else ++ Format(instr, "fsrm 'rd, 'rs1"); ++ } else if (instr->CsrValue() == csr_fflags) { ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "fsflags 'rs1"); ++ else ++ Format(instr, "fsflags 'rd, 'rs1"); ++ } else if (instr->RdValue() == zero_reg.code()) { ++ Format(instr, "csrw 'csr, 'rs1"); ++ } else { ++ Format(instr, "csrrw 'rd, 'csr, 'rs1"); ++ } ++ break; ++ case RO_CSRRS: ++ if (instr->Rs1Value() == zero_reg.code()) { ++ switch (instr->CsrValue()) { ++ case csr_instret: ++ Format(instr, "rdinstret 'rd"); ++ break; ++ case csr_instreth: ++ Format(instr, "rdinstreth 'rd"); ++ break; ++ case csr_time: ++ Format(instr, "rdtime 'rd"); ++ break; ++ case csr_timeh: ++ Format(instr, "rdtimeh 'rd"); ++ break; ++ case csr_cycle: ++ Format(instr, "rdcycle 'rd"); ++ break; ++ case csr_cycleh: ++ Format(instr, "rdcycleh 'rd"); ++ break; ++ case csr_fflags: ++ Format(instr, "frflags 'rd"); ++ break; ++ case csr_frm: ++ Format(instr, "frrm 'rd"); ++ break; ++ case csr_fcsr: ++ Format(instr, "frcsr 'rd"); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } else if (instr->Rs1Value() == zero_reg.code()) { ++ Format(instr, "csrr 'rd, 'csr"); ++ } else if (instr->RdValue() == zero_reg.code()) { ++ Format(instr, "csrs 'csr, 'rs1"); ++ } else ++ Format(instr, "csrrs 'rd, 'csr, 'rs1"); ++ break; ++ case RO_CSRRC: ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "csrc 'csr, 'rs1"); ++ else ++ Format(instr, "csrrc 'rd, 'csr, 'rs1"); ++ break; ++ case RO_CSRRWI: ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "csrwi 'csr, 'vs1"); ++ else ++ Format(instr, "csrrwi 'rd, 'csr, 'vs1"); ++ break; ++ case RO_CSRRSI: ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "csrsi 'csr, 'vs1"); ++ else ++ Format(instr, "csrrsi 'rd, 'csr, 'vs1"); ++ break; ++ case RO_CSRRCI: ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "csrci 'csr, 'vs1"); ++ else ++ Format(instr, "csrrci 'rd, 'csr, 'vs1"); ++ break; ++ // TODO: use F Extension macro block ++ case RO_FLW: ++ Format(instr, "flw 'fd, 'imm12('rs1)"); ++ break; ++ // TODO: use D Extension macro block ++ case RO_FLD: ++ Format(instr, "fld 'fd, 'imm12('rs1)"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++ ++void Decoder::DecodeSType(Instruction* instr) { ++ switch (instr->InstructionBits() & kSTypeMask) { ++ case RO_SB: ++ Format(instr, "sb 'rs2, 'offS('rs1)"); ++ break; ++ case RO_SH: ++ Format(instr, "sh 'rs2, 'offS('rs1)"); ++ break; ++ case RO_SW: ++ Format(instr, "sw 'rs2, 'offS('rs1)"); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_SD: ++ Format(instr, "sd 'rs2, 'offS('rs1)"); ++ break; ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: use F Extension macro block ++ case RO_FSW: ++ Format(instr, "fsw 'fs2, 'offS('rs1)"); ++ break; ++ // TODO: use D Extension macro block ++ case RO_FSD: ++ Format(instr, "fsd 'fs2, 'offS('rs1)"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++ ++void Decoder::DecodeBType(Instruction* instr) { ++ switch (instr->InstructionBits() & kBTypeMask) { ++ case RO_BEQ: ++ Format(instr, "beq 'rs1, 'rs2, 'offB"); ++ break; ++ case RO_BNE: ++ Format(instr, "bne 'rs1, 'rs2, 'offB"); ++ break; ++ case RO_BLT: ++ Format(instr, "blt 'rs1, 'rs2, 'offB"); ++ break; ++ case RO_BGE: ++ Format(instr, "bge 'rs1, 'rs2, 'offB"); ++ break; ++ case RO_BLTU: ++ Format(instr, "bltu 'rs1, 'rs2, 'offB"); ++ break; ++ case RO_BGEU: ++ Format(instr, "bgeu 'rs1, 'rs2, 'offB"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++void Decoder::DecodeUType(Instruction* instr) { ++ // U Type doesn't have additional mask ++ switch (instr->BaseOpcodeFieldRaw()) { ++ case RO_LUI: ++ Format(instr, "lui 'rd, 'imm20U"); ++ break; ++ case RO_AUIPC: ++ Format(instr, "auipc 'rd, 'imm20U"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++void Decoder::DecodeJType(Instruction* instr) { ++ // J Type doesn't have additional mask ++ switch (instr->BaseOpcodeValue()) { ++ case RO_JAL: ++ if (instr->RdValue() == zero_reg.code()) ++ Format(instr, "j 'imm20J"); ++ else if (instr->RdValue() == ra.code()) ++ Format(instr, "jal 'imm20J"); ++ else ++ Format(instr, "jal 'rd, 'imm20J"); ++ break; ++ default: ++ UNSUPPORTED_RISCV(); ++ } ++} ++ ++// Disassemble the instruction at *instr_ptr into the output buffer. ++// All instructions are one word long, except for the simulator ++// pseudo-instruction stop(msg). For that one special case, we return ++// size larger than one kInstrSize. ++int Decoder::InstructionDecode(byte* instr_ptr) { ++ Instruction* instr = Instruction::At(instr_ptr); ++ // Print raw instruction bytes. ++ out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x ", ++ instr->InstructionBits()); ++ switch (instr->InstructionType()) { ++ case Instruction::kRType: ++ DecodeRType(instr); ++ break; ++ case Instruction::kR4Type: ++ DecodeR4Type(instr); ++ break; ++ case Instruction::kIType: ++ DecodeIType(instr); ++ break; ++ case Instruction::kSType: ++ DecodeSType(instr); ++ break; ++ case Instruction::kBType: ++ DecodeBType(instr); ++ break; ++ case Instruction::kUType: ++ DecodeUType(instr); ++ break; ++ case Instruction::kJType: ++ DecodeJType(instr); ++ break; ++ default: ++ Format(instr, "UNSUPPORTED"); ++ UNSUPPORTED_RISCV(); ++ } ++ return kInstrSize; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++//------------------------------------------------------------------------------ ++ ++namespace disasm { ++ ++const char* NameConverter::NameOfAddress(byte* addr) const { ++ v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast(addr)); ++ return tmp_buffer_.begin(); ++} ++ ++const char* NameConverter::NameOfConstant(byte* addr) const { ++ return NameOfAddress(addr); ++} ++ ++const char* NameConverter::NameOfCPURegister(int reg) const { ++ return v8::internal::Registers::Name(reg); ++} ++ ++const char* NameConverter::NameOfXMMRegister(int reg) const { ++ return v8::internal::FPURegisters::Name(reg); ++} ++ ++const char* NameConverter::NameOfByteCPURegister(int reg) const { ++ UNREACHABLE(); // RISC-V does not have the concept of a byte register. ++ return "nobytereg"; ++} ++ ++const char* NameConverter::NameInCode(byte* addr) const { ++ // The default name converter is called for unknown code. So we will not try ++ // to access any memory. ++ return ""; ++} ++ ++//------------------------------------------------------------------------------ ++ ++int Disassembler::InstructionDecode(v8::internal::Vector buffer, ++ byte* instruction) { ++ v8::internal::Decoder d(converter_, buffer); ++ return d.InstructionDecode(instruction); ++} ++ ++// The RISC-V assembler does not currently use constant pools. ++int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; } ++ ++void Disassembler::Disassemble(FILE* f, byte* begin, byte* end, ++ UnimplementedOpcodeAction unimplemented_action) { ++ NameConverter converter; ++ Disassembler d(converter, unimplemented_action); ++ for (byte* pc = begin; pc < end;) { ++ v8::internal::EmbeddedVector buffer; ++ buffer[0] = '\0'; ++ byte* prev_pc = pc; ++ pc += d.InstructionDecode(buffer, pc); ++ v8::internal::PrintF(f, "%p %08x %s\n", static_cast(prev_pc), ++ *reinterpret_cast(prev_pc), buffer.begin()); ++ } ++} ++ ++#undef STRING_STARTS_WITH ++ ++} // namespace disasm ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- a/src/3rdparty/chromium/v8/src/execution/frame-constants.h ++++ b/src/3rdparty/chromium/v8/src/execution/frame-constants.h +@@ -356,6 +356,10 @@ + #include "src/execution/mips64/frame-constants-mips64.h" // NOLINT + #elif V8_TARGET_ARCH_S390 + #include "src/execution/s390/frame-constants-s390.h" // NOLINT ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/execution/riscv64/frame-constants-riscv64.h" // NOLINT ++#elif V8_TARGET_ARCH_RISCV ++#include "src/execution/riscv/frame-constants-riscv.h" // NOLINT + #else + #error Unsupported target architecture. + #endif +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/execution/riscv64/frame-constants-riscv64.cc +@@ -0,0 +1,32 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/codegen/riscv64/assembler-riscv64-inl.h" ++#include "src/execution/frame-constants.h" ++#include "src/execution/frames.h" ++ ++#include "src/execution/riscv64/frame-constants-riscv64.h" ++ ++namespace v8 { ++namespace internal { ++ ++Register JavaScriptFrame::fp_register() { return v8::internal::fp; } ++Register JavaScriptFrame::context_register() { return cp; } ++Register JavaScriptFrame::constant_pool_pointer_register() { UNREACHABLE(); } ++ ++int InterpreterFrameConstants::RegisterStackSlotCount(int register_count) { ++ return register_count; ++} ++ ++int BuiltinContinuationFrameConstants::PaddingSlotCount(int register_count) { ++ USE(register_count); ++ return 0; ++} ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/execution/riscv64/frame-constants-riscv64.h +@@ -0,0 +1,87 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ ++#define V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ ++ ++#include "src/base/bits.h" ++#include "src/base/macros.h" ++#include "src/execution/frame-constants.h" ++#include "src/wasm/baseline/liftoff-assembler-defs.h" ++#include "src/wasm/wasm-linkage.h" ++ ++namespace v8 { ++namespace internal { ++ ++class EntryFrameConstants : public AllStatic { ++ public: ++ // This is the offset to where JSEntry pushes the current value of ++ // Isolate::c_entry_fp onto the stack. ++ static constexpr int kCallerFPOffset = ++ -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); ++}; ++ ++class WasmCompileLazyFrameConstants : public TypedFrameConstants { ++ public: ++ static constexpr int kNumberOfSavedGpParamRegs = ++ arraysize(wasm::kGpParamRegisters); ++ static constexpr int kNumberOfSavedFpParamRegs = ++ arraysize(wasm::kFpParamRegisters); ++ ++ // FP-relative. ++ // Builtins::Generate_WasmCompileLazy pushes WasmInstance to the stack after ++ // pushing SavedGPParamRegs and SavedFpParamRegs onto the stack, therefore ++ // kWasmInstanceOffset is setup as such ++ static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET( ++ kNumberOfSavedGpParamRegs + kNumberOfSavedGpParamRegs); ++ static constexpr int kFixedFrameSizeFromFp = ++ TypedFrameConstants::kFixedFrameSizeFromFp + ++ kNumberOfSavedGpParamRegs * kPointerSize + ++ kNumberOfSavedFpParamRegs * kDoubleSize; ++}; ++ ++// Frame constructed by the {WasmDebugBreak} builtin. ++// After pushing the frame type marker, the builtin pushes all Liftoff cache ++// registers (see liftoff-assembler-defs.h). ++class WasmDebugBreakFrameConstants : public TypedFrameConstants { ++ public: ++ // constexpr RegList kLiftoffAssemblerGpCacheRegs = ++ // Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); ++ static constexpr uint32_t kPushedGpRegs = wasm::kLiftoffAssemblerGpCacheRegs; ++ ++ // constexpr RegList kLiftoffAssemblerFpCacheRegs = DoubleRegister::ListOf( ++ // ft0, ft1, ft2, ft3, ft4, ft5, ft6, ft7, fa0, fa1, fa2, fa3, fa4, fa5, ++ // fa6, fa7, ft8, ft9, ft10, ft11); ++ static constexpr uint32_t kPushedFpRegs = wasm::kLiftoffAssemblerFpCacheRegs; ++ ++ static constexpr int kNumPushedGpRegisters = ++ base::bits::CountPopulation(kPushedGpRegs); ++ static constexpr int kNumPushedFpRegisters = ++ base::bits::CountPopulation(kPushedFpRegs); ++ ++ static constexpr int kLastPushedGpRegisterOffset = ++ -kFixedFrameSizeFromFp - kNumPushedGpRegisters * kSystemPointerSize; ++ static constexpr int kLastPushedFpRegisterOffset = ++ kLastPushedGpRegisterOffset - kNumPushedFpRegisters * kDoubleSize; ++ ++ // Offsets are fp-relative. ++ static int GetPushedGpRegisterOffset(int reg_code) { ++ DCHECK_NE(0, kPushedGpRegs & (1 << reg_code)); ++ uint32_t lower_regs = kPushedGpRegs & ((uint32_t{1} << reg_code) - 1); ++ return kLastPushedGpRegisterOffset + ++ base::bits::CountPopulation(lower_regs) * kSystemPointerSize; ++ } ++ ++ static int GetPushedFpRegisterOffset(int reg_code) { ++ DCHECK_NE(0, kPushedFpRegs & (1 << reg_code)); ++ uint32_t lower_regs = kPushedFpRegs & ((uint32_t{1} << reg_code) - 1); ++ return kLastPushedFpRegisterOffset + ++ base::bits::CountPopulation(lower_regs) * kDoubleSize; ++ } ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_EXECUTION_RISCV_FRAME_CONSTANTS_RISCV_H_ +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/execution/riscv64/simulator-riscv64.cc +@@ -0,0 +1,3509 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Copyright(c) 2010 - 2017, ++// The Regents of the University of California(Regents).All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, ++// with or without modification, ++// are permitted provided that the following ++// conditions are met : 1. Redistributions of source code must retain the ++// above copyright notice, this list of conditions and the following ++// disclaimer.2. Redistributions in binary form must reproduce the above ++// copyright notice, this list of conditions and the following disclaimer in ++// the ++// documentation and / ++// or ++// other materials provided with the distribution.3. Neither the name of ++// the Regents nor the names of its contributors may be used to endorse ++// or ++// promote products derived from ++// this software without specific prior written permission. ++// ++// IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, ++// INDIRECT, SPECIAL, ++// INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ++// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, ++// EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++// ++// REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, ++// INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ++// PARTICULAR PURPOSE.THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, ++// IF ANY, ++// PROVIDED HEREUNDER IS PROVIDED ++// "AS IS".REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, ++// SUPPORT, UPDATES, ENHANCEMENTS, ++// OR MODIFICATIONS. ++ ++// The original source code covered by the above license above has been ++// modified significantly by the v8 project authors. ++ ++#include "src/execution/riscv64/simulator-riscv64.h" ++ ++// Only build the simulator if not compiling for real RISCV hardware. ++#if defined(USE_SIMULATOR) ++ ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include "src/base/bits.h" ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/diagnostics/disasm.h" ++#include "src/heap/combined-heap.h" ++#include "src/runtime/runtime-utils.h" ++#include "src/utils/ostreams.h" ++#include "src/utils/vector.h" ++ ++namespace v8 { ++namespace internal { ++ ++DEFINE_LAZY_LEAKY_OBJECT_GETTER(Simulator::GlobalMonitor, ++ Simulator::GlobalMonitor::Get) ++ ++// Util functions. ++inline bool HaveSameSign(int64_t a, int64_t b) { return ((a ^ b) >= 0); } ++ ++uint32_t get_fcsr_condition_bit(uint32_t cc) { ++ if (cc == 0) { ++ return 23; ++ } else { ++ return 24 + cc; ++ } ++} ++ ++// Generated by Assembler::break_()/stop(), ebreak code is passed as immediate ++// field of a subsequent LUI instruction; otherwise returns -1 ++static inline int32_t get_ebreak_code(Instruction* instr) { ++ DCHECK(instr->InstructionBits() == kBreakInstr); ++ byte* cur = reinterpret_cast(instr); ++ Instruction* next_instr = reinterpret_cast(cur + kInstrSize); ++ if (next_instr->BaseOpcodeFieldRaw() == RO_LUI) ++ return (next_instr->Imm20UValue()); ++ else ++ return -1; ++} ++ ++// This macro provides a platform independent use of sscanf. The reason for ++// SScanF not being implemented in a platform independent was through ++// ::v8::internal::OS in the same way as SNPrintF is that the Windows C Run-Time ++// Library does not provide vsscanf. ++#define SScanF sscanf // NOLINT ++ ++// The RiscvDebugger class is used by the simulator while debugging simulated ++// code. ++class RiscvDebugger { ++ public: ++ explicit RiscvDebugger(Simulator* sim) : sim_(sim) {} ++ ++ void Debug(); ++ // Print all registers with a nice formatting. ++ void PrintRegs(char name_prefix, int start_index, int end_index); ++ void PrintAllRegs(); ++ void PrintAllRegsIncludingFPU(); ++ ++ static const Instr kNopInstr = 0x0; ++ ++ private: ++ Simulator* sim_; ++ ++ int64_t GetRegisterValue(int regnum); ++ int64_t GetFPURegisterValue(int regnum); ++ float GetFPURegisterValueFloat(int regnum); ++ double GetFPURegisterValueDouble(int regnum); ++ bool GetValue(const char* desc, int64_t* value); ++}; ++ ++inline void UNSUPPORTED() { ++ printf("Sim: Unsupported instruction.\n"); ++ base::OS::Abort(); ++} ++ ++int64_t RiscvDebugger::GetRegisterValue(int regnum) { ++ if (regnum == kNumSimuRegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_register(regnum); ++ } ++} ++ ++int64_t RiscvDebugger::GetFPURegisterValue(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register(regnum); ++ } ++} ++ ++float RiscvDebugger::GetFPURegisterValueFloat(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register_float(regnum); ++ } ++} ++ ++double RiscvDebugger::GetFPURegisterValueDouble(int regnum) { ++ if (regnum == kNumFPURegisters) { ++ return sim_->get_pc(); ++ } else { ++ return sim_->get_fpu_register_double(regnum); ++ } ++} ++ ++bool RiscvDebugger::GetValue(const char* desc, int64_t* value) { ++ int regnum = Registers::Number(desc); ++ int fpuregnum = FPURegisters::Number(desc); ++ ++ if (regnum != kInvalidRegister) { ++ *value = GetRegisterValue(regnum); ++ return true; ++ } else if (fpuregnum != kInvalidFPURegister) { ++ *value = GetFPURegisterValue(fpuregnum); ++ return true; ++ } else if (strncmp(desc, "0x", 2) == 0) { ++ return SScanF(desc + 2, "%" SCNx64, reinterpret_cast(value)) == ++ 1; ++ } else { ++ return SScanF(desc, "%" SCNu64, reinterpret_cast(value)) == 1; ++ } ++ return false; ++} ++ ++#define REG_INFO(name) \ ++ name, GetRegisterValue(Registers::Number(name)), \ ++ GetRegisterValue(Registers::Number(name)) ++ ++void RiscvDebugger::PrintRegs(char name_prefix, int start_index, ++ int end_index) { ++ EmbeddedVector name1, name2; ++ DCHECK(name_prefix == 'a' || name_prefix == 't' || name_prefix == 's'); ++ DCHECK(start_index >= 0 && end_index <= 99); ++ int num_registers = (end_index - start_index) + 1; ++ for (int i = 0; i < num_registers / 2; i++) { ++ SNPrintF(name1, "%c%d", name_prefix, start_index + 2 * i); ++ SNPrintF(name2, "%c%d", name_prefix, start_index + 2 * i + 1); ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \t%3s: 0x%016" PRIx64 ++ " %14" PRId64 " \n", ++ REG_INFO(name1.begin()), REG_INFO(name2.begin())); ++ } ++ if (num_registers % 2 == 1) { ++ SNPrintF(name1, "%c%d", name_prefix, end_index); ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 " \n", REG_INFO(name1.begin())); ++ } ++} ++ ++void RiscvDebugger::PrintAllRegs() { ++ PrintF("\n"); ++ // ra, sp, gp ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 ++ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", ++ REG_INFO("ra"), REG_INFO("sp"), REG_INFO("gp")); ++ ++ // tp, fp, pc ++ PrintF("%3s: 0x%016" PRIx64 " %14" PRId64 "\t%3s: 0x%016" PRIx64 " %14" PRId64 ++ "\t%3s: 0x%016" PRIx64 " %14" PRId64 "\n", ++ REG_INFO("tp"), REG_INFO("fp"), REG_INFO("pc")); ++ ++ // print register a0, .., a7 ++ PrintRegs('a', 0, 7); ++ // print registers s1, ..., s11 ++ PrintRegs('s', 1, 11); ++ // print registers t0, ..., t6 ++ PrintRegs('t', 0, 6); ++} ++ ++#undef REG_INFO ++ ++void RiscvDebugger::PrintAllRegsIncludingFPU() { ++#define FPU_REG_INFO(n) \ ++ FPURegisters::Name(n), GetFPURegisterValue(n), GetFPURegisterValueDouble(n) ++ ++ PrintAllRegs(); ++ ++ PrintF("\n\n"); ++ // f0, f1, f2, ... f31. ++ DCHECK(kNumFPURegisters % 2 == 0); ++ for (int i = 0; i < kNumFPURegisters; i += 2) ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e \t%3s: 0x%016" PRIx64 " %16.4e\n", ++ FPU_REG_INFO(i), FPU_REG_INFO(i + 1)); ++#undef FPU_REG_INFO ++} ++ ++void RiscvDebugger::Debug() { ++ intptr_t last_pc = -1; ++ bool done = false; ++ ++#define COMMAND_SIZE 63 ++#define ARG_SIZE 255 ++ ++#define STR(a) #a ++#define XSTR(a) STR(a) ++ ++ char cmd[COMMAND_SIZE + 1]; ++ char arg1[ARG_SIZE + 1]; ++ char arg2[ARG_SIZE + 1]; ++ char* argv[3] = {cmd, arg1, arg2}; ++ ++ // Make sure to have a proper terminating character if reaching the limit. ++ cmd[COMMAND_SIZE] = 0; ++ arg1[ARG_SIZE] = 0; ++ arg2[ARG_SIZE] = 0; ++ ++ while (!done && (sim_->get_pc() != Simulator::end_sim_pc)) { ++ if (last_pc != sim_->get_pc()) { ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ dasm.InstructionDecode(buffer, reinterpret_cast(sim_->get_pc())); ++ PrintF(" 0x%016" PRIx64 " %s\n", sim_->get_pc(), buffer.begin()); ++ last_pc = sim_->get_pc(); ++ } ++ char* line = ReadLine("sim> "); ++ if (line == nullptr) { ++ break; ++ } else { ++ char* last_input = sim_->last_debugger_input(); ++ if (strcmp(line, "\n") == 0 && last_input != nullptr) { ++ line = last_input; ++ } else { ++ // Ownership is transferred to sim_; ++ sim_->set_last_debugger_input(line); ++ } ++ // Use sscanf to parse the individual parts of the command line. At the ++ // moment no command expects more than two parameters. ++ int argc = SScanF( ++ line, ++ "%" XSTR(COMMAND_SIZE) "s " ++ "%" XSTR(ARG_SIZE) "s " ++ "%" XSTR(ARG_SIZE) "s", ++ cmd, arg1, arg2); ++ if ((strcmp(cmd, "si") == 0) || (strcmp(cmd, "stepi") == 0)) { ++ Instruction* instr = reinterpret_cast(sim_->get_pc()); ++ if (!(instr->IsTrap()) || ++ instr->InstructionBits() == rtCallRedirInstr) { ++ sim_->InstructionDecode( ++ reinterpret_cast(sim_->get_pc())); ++ } else { ++ // Allow si to jump over generated breakpoints. ++ PrintF("/!\\ Jumping over generated breakpoint.\n"); ++ sim_->set_pc(sim_->get_pc() + kInstrSize); ++ } ++ } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { ++ // Execute the one instruction we broke at with breakpoints disabled. ++ sim_->InstructionDecode(reinterpret_cast(sim_->get_pc())); ++ // Leave the debugger shell. ++ done = true; ++ } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { ++ if (argc == 2) { ++ int64_t value; ++ double dvalue; ++ if (strcmp(arg1, "all") == 0) { ++ PrintAllRegs(); ++ } else if (strcmp(arg1, "allf") == 0) { ++ PrintAllRegsIncludingFPU(); ++ } else { ++ int regnum = Registers::Number(arg1); ++ int fpuregnum = FPURegisters::Number(arg1); ++ ++ if (regnum != kInvalidRegister) { ++ value = GetRegisterValue(regnum); ++ PrintF("%s: 0x%08" PRIx64 " %" PRId64 " \n", arg1, value, ++ value); ++ } else if (fpuregnum != kInvalidFPURegister) { ++ value = GetFPURegisterValue(fpuregnum); ++ dvalue = GetFPURegisterValueDouble(fpuregnum); ++ PrintF("%3s: 0x%016" PRIx64 " %16.4e\n", ++ FPURegisters::Name(fpuregnum), value, dvalue); ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } ++ } else { ++ if (argc == 3) { ++ if (strcmp(arg2, "single") == 0) { ++ int64_t value; ++ float fvalue; ++ int fpuregnum = FPURegisters::Number(arg1); ++ ++ if (fpuregnum != kInvalidFPURegister) { ++ value = GetFPURegisterValue(fpuregnum); ++ value &= 0xFFFFFFFFUL; ++ fvalue = GetFPURegisterValueFloat(fpuregnum); ++ PrintF("%s: 0x%08" PRIx64 " %11.4e\n", arg1, value, fvalue); ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } else { ++ PrintF("print single\n"); ++ } ++ } else { ++ PrintF("print or print single\n"); ++ } ++ } ++ } else if ((strcmp(cmd, "po") == 0) || ++ (strcmp(cmd, "printobject") == 0)) { ++ if (argc == 2) { ++ int64_t value; ++ StdoutStream os; ++ if (GetValue(arg1, &value)) { ++ Object obj(value); ++ os << arg1 << ": \n"; ++#ifdef DEBUG ++ obj.Print(os); ++ os << "\n"; ++#else ++ os << Brief(obj) << "\n"; ++#endif ++ } else { ++ os << arg1 << " unrecognized\n"; ++ } ++ } else { ++ PrintF("printobject \n"); ++ } ++ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) { ++ int64_t* cur = nullptr; ++ int64_t* end = nullptr; ++ int next_arg = 1; ++ ++ if (strcmp(cmd, "stack") == 0) { ++ cur = reinterpret_cast(sim_->get_register(Simulator::sp)); ++ } else { // Command "mem". ++ if (argc < 2) { ++ PrintF("Need to specify
to mem command\n"); ++ continue; ++ } ++ int64_t value; ++ if (!GetValue(arg1, &value)) { ++ PrintF("%s unrecognized\n", arg1); ++ continue; ++ } ++ cur = reinterpret_cast(value); ++ next_arg++; ++ } ++ ++ int64_t words; ++ if (argc == next_arg) { ++ words = 10; ++ } else { ++ if (!GetValue(argv[next_arg], &words)) { ++ words = 10; ++ } ++ } ++ end = cur + words; ++ ++ while (cur < end) { ++ PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ", ++ reinterpret_cast(cur), *cur, *cur); ++ Object obj(*cur); ++ Heap* current_heap = sim_->isolate_->heap(); ++ if (obj.IsSmi() || ++ IsValidHeapObject(current_heap, HeapObject::cast(obj))) { ++ PrintF(" ("); ++ if (obj.IsSmi()) { ++ PrintF("smi %d", Smi::ToInt(obj)); ++ } else { ++ obj.ShortPrint(); ++ } ++ PrintF(")"); ++ } ++ PrintF("\n"); ++ cur++; ++ } ++ ++ } else if ((strcmp(cmd, "disasm") == 0) || (strcmp(cmd, "dpc") == 0) || ++ (strcmp(cmd, "di") == 0)) { ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ ++ byte* cur = nullptr; ++ byte* end = nullptr; ++ ++ if (argc == 1) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ end = cur + (10 * kInstrSize); ++ } else if (argc == 2) { ++ int regnum = Registers::Number(arg1); ++ if (regnum != kInvalidRegister || strncmp(arg1, "0x", 2) == 0) { ++ // The argument is an address or a register name. ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(value); ++ // Disassemble 10 instructions at . ++ end = cur + (10 * kInstrSize); ++ } ++ } else { ++ // The argument is the number of instructions. ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ // Disassemble instructions. ++ end = cur + (value * kInstrSize); ++ } ++ } ++ } else { ++ int64_t value1; ++ int64_t value2; ++ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { ++ cur = reinterpret_cast(value1); ++ end = cur + (value2 * kInstrSize); ++ } ++ } ++ ++ while (cur < end) { ++ dasm.InstructionDecode(buffer, cur); ++ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), ++ buffer.begin()); ++ cur += kInstrSize; ++ } ++ } else if (strcmp(cmd, "gdb") == 0) { ++ PrintF("relinquishing control to gdb\n"); ++ v8::base::OS::DebugBreak(); ++ PrintF("regaining control from gdb\n"); ++ } else if (strcmp(cmd, "break") == 0 ++ || strcmp(cmd, "b") == 0 ++ || strcmp(cmd, "tbreak") == 0) { ++ bool is_tbreak = strcmp(cmd, "tbreak") == 0; ++ if (argc == 2) { ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ sim_->SetBreakpoint(reinterpret_cast(value), is_tbreak); ++ } else { ++ PrintF("%s unrecognized\n", arg1); ++ } ++ } else { ++ sim_->ListBreakpoints(); ++ PrintF("Use `break
` to set or disable a breakpoint\n"); ++ PrintF("Use `tbreak
` to set or disable a temporary breakpoint\n"); ++ } ++ } else if (strcmp(cmd, "flags") == 0) { ++ PrintF("No flags on RISC-V !\n"); ++ } else if (strcmp(cmd, "stop") == 0) { ++ int64_t value; ++ if (argc == 3) { ++ // Print information about all/the specified breakpoint(s). ++ if (strcmp(arg1, "info") == 0) { ++ if (strcmp(arg2, "all") == 0) { ++ PrintF("Stop information:\n"); ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->PrintStopInfo(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->PrintStopInfo(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } else if (strcmp(arg1, "enable") == 0) { ++ // Enable all/the specified breakpoint(s). ++ if (strcmp(arg2, "all") == 0) { ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->EnableStop(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->EnableStop(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } else if (strcmp(arg1, "disable") == 0) { ++ // Disable all/the specified breakpoint(s). ++ if (strcmp(arg2, "all") == 0) { ++ for (uint32_t i = kMaxWatchpointCode + 1; i <= kMaxStopCode; ++ i++) { ++ sim_->DisableStop(i); ++ } ++ } else if (GetValue(arg2, &value)) { ++ sim_->DisableStop(value); ++ } else { ++ PrintF("Unrecognized argument.\n"); ++ } ++ } ++ } else { ++ PrintF("Wrong usage. Use help command for more information.\n"); ++ } ++ } else if ((strcmp(cmd, "stat") == 0) || (strcmp(cmd, "st") == 0)) { ++ // Print registers and disassemble. ++ PrintAllRegs(); ++ PrintF("\n"); ++ ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ v8::internal::EmbeddedVector buffer; ++ ++ byte* cur = nullptr; ++ byte* end = nullptr; ++ ++ if (argc == 1) { ++ cur = reinterpret_cast(sim_->get_pc()); ++ end = cur + (10 * kInstrSize); ++ } else if (argc == 2) { ++ int64_t value; ++ if (GetValue(arg1, &value)) { ++ cur = reinterpret_cast(value); ++ // no length parameter passed, assume 10 instructions ++ end = cur + (10 * kInstrSize); ++ } ++ } else { ++ int64_t value1; ++ int64_t value2; ++ if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { ++ cur = reinterpret_cast(value1); ++ end = cur + (value2 * kInstrSize); ++ } ++ } ++ ++ while (cur < end) { ++ dasm.InstructionDecode(buffer, cur); ++ PrintF(" 0x%08" PRIxPTR " %s\n", reinterpret_cast(cur), ++ buffer.begin()); ++ cur += kInstrSize; ++ } ++ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) { ++ PrintF("cont (alias 'c')\n"); ++ PrintF(" Continue execution\n"); ++ PrintF("stepi (alias 'si')\n"); ++ PrintF(" Step one instruction\n"); ++ PrintF("print (alias 'p')\n"); ++ PrintF(" print \n"); ++ PrintF(" Print register content\n"); ++ PrintF(" Use register name 'all' to print all GPRs\n"); ++ PrintF(" Use register name 'allf' to print all GPRs and FPRs\n"); ++ PrintF("printobject (alias 'po')\n"); ++ PrintF(" printobject \n"); ++ PrintF(" Print an object from a register\n"); ++ PrintF("stack\n"); ++ PrintF(" stack []\n"); ++ PrintF(" Dump stack content, default dump 10 words)\n"); ++ PrintF("mem\n"); ++ PrintF(" mem
[]\n"); ++ PrintF(" Dump memory content, default dump 10 words)\n"); ++ PrintF("flags\n"); ++ PrintF(" print flags\n"); ++ PrintF("disasm (alias 'di')\n"); ++ PrintF(" disasm []\n"); ++ PrintF(" disasm [
] (e.g., disasm pc) \n"); ++ PrintF(" disasm [[
] ]\n"); ++ PrintF(" Disassemble code, default is 10 instructions\n"); ++ PrintF(" from pc\n"); ++ PrintF("gdb \n"); ++ PrintF(" Return to gdb if the simulator was started with gdb\n"); ++ PrintF("break (alias 'b')\n"); ++ PrintF(" break : list all breakpoints\n"); ++ PrintF(" break
: set / enable / disable a breakpoint.\n"); ++ PrintF("tbreak\n"); ++ PrintF(" tbreak : list all breakpoints\n"); ++ PrintF(" tbreak
: set / enable / disable a temporary breakpoint.\n"); ++ PrintF(" Set a breakpoint enabled only for one stop. \n"); ++ PrintF("stop feature:\n"); ++ PrintF(" Description:\n"); ++ PrintF(" Stops are debug instructions inserted by\n"); ++ PrintF(" the Assembler::stop() function.\n"); ++ PrintF(" When hitting a stop, the Simulator will\n"); ++ PrintF(" stop and give control to the Debugger.\n"); ++ PrintF(" All stop codes are watched:\n"); ++ PrintF(" - They can be enabled / disabled: the Simulator\n"); ++ PrintF(" will / won't stop when hitting them.\n"); ++ PrintF(" - The Simulator keeps track of how many times they \n"); ++ PrintF(" are met. (See the info command.) Going over a\n"); ++ PrintF(" disabled stop still increases its counter. \n"); ++ PrintF(" Commands:\n"); ++ PrintF(" stop info all/ : print infos about number \n"); ++ PrintF(" or all stop(s).\n"); ++ PrintF(" stop enable/disable all/ : enables / disables\n"); ++ PrintF(" all or number stop(s)\n"); ++ } else { ++ PrintF("Unknown command: %s\n", cmd); ++ } ++ } ++ } ++ ++#undef COMMAND_SIZE ++#undef ARG_SIZE ++ ++#undef STR ++#undef XSTR ++} ++ ++void Simulator::SetBreakpoint(Instruction* location, bool is_tbreak) { ++ for (unsigned i = 0; i < breakpoints_.size(); i++) { ++ if (breakpoints_.at(i).location == location) { ++ if (breakpoints_.at(i).is_tbreak != is_tbreak) { ++ PrintF("Change breakpoint at %p to %s breakpoint\n", ++ reinterpret_cast(location), ++ is_tbreak ? "temporary" : "regular"); ++ breakpoints_.at(i).is_tbreak = is_tbreak; ++ return; ++ } ++ PrintF("Existing breakpoint at %p was %s\n", ++ reinterpret_cast(location), ++ breakpoints_.at(i).enabled ? "disabled" : "enabled"); ++ breakpoints_.at(i).enabled = !breakpoints_.at(i).enabled; ++ return; ++ } ++ } ++ Breakpoint new_breakpoint = {location, true, is_tbreak}; ++ breakpoints_.push_back(new_breakpoint); ++ PrintF("Set a %sbreakpoint at %p\n", ++ is_tbreak ? "temporary " : "", ++ reinterpret_cast(location)); ++} ++ ++void Simulator::ListBreakpoints() { ++ PrintF("Breakpoints:\n"); ++ for (unsigned i = 0; i < breakpoints_.size(); i++) { ++ PrintF("%p : %s %s\n", ++ reinterpret_cast(breakpoints_.at(i).location), ++ breakpoints_.at(i).enabled ? "enabled" : "disabled", ++ breakpoints_.at(i).is_tbreak ? ": temporary" : ""); ++ } ++} ++ ++void Simulator::CheckBreakpoints() { ++ bool hit_a_breakpoint = false; ++ bool is_tbreak = false; ++ Instruction* pc_ = reinterpret_cast(get_pc()); ++ for (unsigned i = 0; i < breakpoints_.size(); i++) { ++ if ((breakpoints_.at(i).location == pc_) && breakpoints_.at(i).enabled) { ++ hit_a_breakpoint = true; ++ if (breakpoints_.at(i).is_tbreak) { ++ // Disable a temporary breakpoint. ++ is_tbreak = true; ++ breakpoints_.at(i).enabled = false; ++ } ++ break; ++ } ++ } ++ if (hit_a_breakpoint) { ++ PrintF("Hit %sa breakpoint at %p.\n", ++ is_tbreak ? "and disabled " : "", ++ reinterpret_cast(pc_)); ++ RiscvDebugger dbg(this); ++ dbg.Debug(); ++ } ++} ++ ++bool Simulator::ICacheMatch(void* one, void* two) { ++ DCHECK_EQ(reinterpret_cast(one) & CachePage::kPageMask, 0); ++ DCHECK_EQ(reinterpret_cast(two) & CachePage::kPageMask, 0); ++ return one == two; ++} ++ ++static uint32_t ICacheHash(void* key) { ++ return static_cast(reinterpret_cast(key)) >> 2; ++} ++ ++static bool AllOnOnePage(uintptr_t start, size_t size) { ++ intptr_t start_page = (start & ~CachePage::kPageMask); ++ intptr_t end_page = ((start + size) & ~CachePage::kPageMask); ++ return start_page == end_page; ++} ++ ++void Simulator::set_last_debugger_input(char* input) { ++ DeleteArray(last_debugger_input_); ++ last_debugger_input_ = input; ++} ++ ++void Simulator::SetRedirectInstruction(Instruction* instruction) { ++ instruction->SetInstructionBits(rtCallRedirInstr); ++} ++ ++void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, ++ void* start_addr, size_t size) { ++ int64_t start = reinterpret_cast(start_addr); ++ int64_t intra_line = (start & CachePage::kLineMask); ++ start -= intra_line; ++ size += intra_line; ++ size = ((size - 1) | CachePage::kLineMask) + 1; ++ int offset = (start & CachePage::kPageMask); ++ while (!AllOnOnePage(start, size - 1)) { ++ int bytes_to_flush = CachePage::kPageSize - offset; ++ FlushOnePage(i_cache, start, bytes_to_flush); ++ start += bytes_to_flush; ++ size -= bytes_to_flush; ++ DCHECK_EQ((int64_t)0, start & CachePage::kPageMask); ++ offset = 0; ++ } ++ if (size != 0) { ++ FlushOnePage(i_cache, start, size); ++ } ++} ++ ++CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, ++ void* page) { ++ base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); ++ if (entry->value == nullptr) { ++ CachePage* new_page = new CachePage(); ++ entry->value = new_page; ++ } ++ return reinterpret_cast(entry->value); ++} ++ ++// Flush from start up to and not including start + size. ++void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, ++ intptr_t start, size_t size) { ++ DCHECK_LE(size, CachePage::kPageSize); ++ DCHECK(AllOnOnePage(start, size - 1)); ++ DCHECK_EQ(start & CachePage::kLineMask, 0); ++ DCHECK_EQ(size & CachePage::kLineMask, 0); ++ void* page = reinterpret_cast(start & (~CachePage::kPageMask)); ++ int offset = (start & CachePage::kPageMask); ++ CachePage* cache_page = GetCachePage(i_cache, page); ++ char* valid_bytemap = cache_page->ValidityByte(offset); ++ memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); ++} ++ ++void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, ++ Instruction* instr) { ++ int64_t address = reinterpret_cast(instr); ++ void* page = reinterpret_cast(address & (~CachePage::kPageMask)); ++ void* line = reinterpret_cast(address & (~CachePage::kLineMask)); ++ int offset = (address & CachePage::kPageMask); ++ CachePage* cache_page = GetCachePage(i_cache, page); ++ char* cache_valid_byte = cache_page->ValidityByte(offset); ++ bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); ++ char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); ++ if (cache_hit) { ++ // Check that the data in memory matches the contents of the I-cache. ++ CHECK_EQ(0, memcmp(reinterpret_cast(instr), ++ cache_page->CachedData(offset), kInstrSize)); ++ } else { ++ // Cache miss. Load memory into the cache. ++ memcpy(cached_line, line, CachePage::kLineLength); ++ *cache_valid_byte = CachePage::LINE_VALID; ++ } ++} ++ ++Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { ++ // Set up simulator support first. Some of this information is needed to ++ // setup the architecture state. ++ stack_size_ = FLAG_sim_stack_size * KB; ++ stack_ = reinterpret_cast(malloc(stack_size_)); ++ pc_modified_ = false; ++ icount_ = 0; ++ break_count_ = 0; ++ // Reset debug helpers. ++ breakpoints_.clear(); ++ // TODO: 'next' command ++ //break_on_next_ = false; ++ ++ // Set up architecture state. ++ // All registers are initialized to zero to start with. ++ for (int i = 0; i < kNumSimuRegisters; i++) { ++ registers_[i] = 0; ++ } ++ ++ for (int i = 0; i < kNumFPURegisters; i++) { ++ FPUregisters_[i] = 0; ++ } ++ ++ FCSR_ = 0; ++ ++ // The sp is initialized to point to the bottom (high address) of the ++ // allocated stack area. To be safe in potential stack underflows we leave ++ // some buffer below. ++ registers_[sp] = reinterpret_cast(stack_) + stack_size_ - 64; ++ // The ra and pc are initialized to a known bad value that will cause an ++ // access violation if the simulator ever tries to execute it. ++ registers_[pc] = bad_ra; ++ registers_[ra] = bad_ra; ++ ++ last_debugger_input_ = nullptr; ++} ++ ++Simulator::~Simulator() { ++ GlobalMonitor::Get()->RemoveLinkedAddress(&global_monitor_thread_); ++ free(stack_); ++} ++ ++// Get the active Simulator for the current thread. ++Simulator* Simulator::current(Isolate* isolate) { ++ v8::internal::Isolate::PerIsolateThreadData* isolate_data = ++ isolate->FindOrAllocatePerThreadDataForThisThread(); ++ DCHECK_NOT_NULL(isolate_data); ++ ++ Simulator* sim = isolate_data->simulator(); ++ if (sim == nullptr) { ++ // TODO(146): delete the simulator object when a thread/isolate goes away. ++ sim = new Simulator(isolate); ++ isolate_data->set_simulator(sim); ++ } ++ return sim; ++} ++ ++// Sets the register in the architecture state. It will also deal with ++// updating Simulator internal state for special registers such as PC. ++void Simulator::set_register(int reg, int64_t value) { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ if (reg == pc) { ++ pc_modified_ = true; ++ } ++ ++ // Zero register always holds 0. ++ registers_[reg] = (reg == 0) ? 0 : value; ++} ++ ++void Simulator::set_dw_register(int reg, const int* dbl) { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ registers_[reg] = dbl[1]; ++ registers_[reg] = registers_[reg] << 32; ++ registers_[reg] += dbl[0]; ++} ++ ++void Simulator::set_fpu_register(int fpureg, int64_t value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ FPUregisters_[fpureg] = value; ++} ++ ++void Simulator::set_fpu_register_word(int fpureg, int32_t value) { ++ // Set ONLY lower 32-bits, leaving upper bits untouched. ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ int32_t* pword; ++ if (kArchEndian == kLittle) { ++ pword = reinterpret_cast(&FPUregisters_[fpureg]); ++ } else { ++ pword = reinterpret_cast(&FPUregisters_[fpureg]) + 1; ++ } ++ *pword = value; ++} ++ ++void Simulator::set_fpu_register_hi_word(int fpureg, int32_t value) { ++ // Set ONLY upper 32-bits, leaving lower bits untouched. ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ int32_t* phiword; ++ if (kArchEndian == kLittle) { ++ phiword = (reinterpret_cast(&FPUregisters_[fpureg])) + 1; ++ } else { ++ phiword = reinterpret_cast(&FPUregisters_[fpureg]); ++ } ++ *phiword = value; ++} ++ ++void Simulator::set_fpu_register_float(int fpureg, float value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ FPUregisters_[fpureg] = box_float(value); ++} ++ ++void Simulator::set_fpu_register_double(int fpureg, double value) { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ *bit_cast(&FPUregisters_[fpureg]) = value; ++} ++ ++// Get the register from the architecture state. This function does handle ++// the special case of accessing the PC register. ++int64_t Simulator::get_register(int reg) const { ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters)); ++ if (reg == 0) ++ return 0; ++ else ++ return registers_[reg] + ((reg == pc) ? Instruction::kPCReadOffset : 0); ++} ++ ++double Simulator::get_double_from_register_pair(int reg) { ++ // TODO(plind): bad ABI stuff, refactor or remove. ++ DCHECK((reg >= 0) && (reg < kNumSimuRegisters) && ((reg % 2) == 0)); ++ ++ double dm_val = 0.0; ++ // Read the bits from the unsigned integer register_[] array ++ // into the double precision floating point value and return it. ++ char buffer[sizeof(registers_[0])]; ++ memcpy(buffer, ®isters_[reg], sizeof(registers_[0])); ++ memcpy(&dm_val, buffer, sizeof(registers_[0])); ++ return (dm_val); ++} ++ ++int64_t Simulator::get_fpu_register(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return FPUregisters_[fpureg]; ++} ++ ++int32_t Simulator::get_fpu_register_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); ++} ++ ++int32_t Simulator::get_fpu_register_signed_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast(FPUregisters_[fpureg] & 0xFFFFFFFF); ++} ++ ++int32_t Simulator::get_fpu_register_hi_word(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return static_cast((FPUregisters_[fpureg] >> 32) & 0xFFFFFFFF); ++} ++ ++float Simulator::get_fpu_register_float(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ if (!is_boxed_float(FPUregisters_[fpureg])) { ++ return std::numeric_limits::quiet_NaN(); ++ } ++ return *bit_cast(const_cast(&FPUregisters_[fpureg])); ++} ++ ++double Simulator::get_fpu_register_double(int fpureg) const { ++ DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); ++ return *bit_cast(&FPUregisters_[fpureg]); ++} ++ ++// Runtime FP routines take up to two double arguments and zero ++// or one integer arguments. All are constructed here, ++// from fa0, fa1, and a0. ++void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { ++ *x = get_fpu_register_double(fa0); ++ *y = get_fpu_register_double(fa1); ++ *z = static_cast(get_register(a0)); ++} ++ ++// The return value is in fa0. ++void Simulator::SetFpResult(const double& result) { ++ set_fpu_register_double(fa0, result); ++} ++ ++// helper functions to read/write/set/clear CRC values/bits ++uint32_t Simulator::read_csr_value(uint32_t csr) { ++ switch (csr) { ++ case csr_fflags: // Floating-Point Accrued Exceptions (RW) ++ return (FCSR_ & kFcsrFlagsMask); ++ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) ++ return (FCSR_ & kFcsrFrmMask) >> kFcsrFrmShift; ++ case csr_fcsr: // Floating-Point Control and Status Register (RW) ++ return (FCSR_ & kFcsrMask); ++ default: ++ UNIMPLEMENTED(); ++ } ++} ++ ++uint32_t Simulator::get_dynamic_rounding_mode() { ++ return read_csr_value(csr_frm); ++} ++ ++void Simulator::write_csr_value(uint32_t csr, uint64_t val) { ++ uint32_t value = (uint32_t)val; ++ switch (csr) { ++ case csr_fflags: // Floating-Point Accrued Exceptions (RW) ++ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); ++ FCSR_ = (FCSR_ & (~kFcsrFlagsMask)) | value; ++ break; ++ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) ++ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); ++ FCSR_ = (FCSR_ & (~kFcsrFrmMask)) | (value << kFcsrFrmShift); ++ break; ++ case csr_fcsr: // Floating-Point Control and Status Register (RW) ++ DCHECK(value <= ((1 << kFcsrBits) - 1)); ++ FCSR_ = (FCSR_ & (~kFcsrMask)) | value; ++ break; ++ default: ++ UNIMPLEMENTED(); ++ } ++} ++ ++void Simulator::set_csr_bits(uint32_t csr, uint64_t val) { ++ uint32_t value = (uint32_t)val; ++ switch (csr) { ++ case csr_fflags: // Floating-Point Accrued Exceptions (RW) ++ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); ++ FCSR_ = FCSR_ | value; ++ break; ++ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) ++ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); ++ FCSR_ = FCSR_ | (value << kFcsrFrmShift); ++ break; ++ case csr_fcsr: // Floating-Point Control and Status Register (RW) ++ DCHECK(value <= ((1 << kFcsrBits) - 1)); ++ FCSR_ = FCSR_ | value; ++ break; ++ default: ++ UNIMPLEMENTED(); ++ } ++} ++ ++void Simulator::clear_csr_bits(uint32_t csr, uint64_t val) { ++ uint32_t value = (uint32_t)val; ++ switch (csr) { ++ case csr_fflags: // Floating-Point Accrued Exceptions (RW) ++ DCHECK(value <= ((1 << kFcsrFlagsBits) - 1)); ++ FCSR_ = FCSR_ & (~value); ++ break; ++ case csr_frm: // Floating-Point Dynamic Rounding Mode (RW) ++ DCHECK(value <= ((1 << kFcsrFrmBits) - 1)); ++ FCSR_ = FCSR_ & (~(value << kFcsrFrmShift)); ++ break; ++ case csr_fcsr: // Floating-Point Control and Status Register (RW) ++ DCHECK(value <= ((1 << kFcsrBits) - 1)); ++ FCSR_ = FCSR_ & (~value); ++ break; ++ default: ++ UNIMPLEMENTED(); ++ } ++} ++ ++bool Simulator::test_fflags_bits(uint32_t mask) { ++ return (FCSR_ & kFcsrFlagsMask & mask) != 0; ++} ++ ++template ++T Simulator::FMaxMinHelper(T a, T b, MaxMinKind kind) { ++ // set invalid bit for signaling nan ++ if ((a == std::numeric_limits::signaling_NaN()) || ++ (b == std::numeric_limits::signaling_NaN())) { ++ // FIXME: NV -> kInvalidOperation ++ set_csr_bits(csr_fflags, kInvalidOperation); ++ } ++ ++ T result = 0; ++ if (std::isnan(a) && std::isnan(b)) { ++ result = a; ++ } else if (std::isnan(a)) { ++ result = b; ++ } else if (std::isnan(b)) { ++ result = a; ++ } else if (b == a) { // Handle -0.0 == 0.0 case. ++ if (kind == MaxMinKind::kMax) { ++ result = std::signbit(b) ? a : b; ++ } else { ++ result = std::signbit(b) ? b : a; ++ } ++ } else { ++ result = (kind == MaxMinKind::kMax) ? fmax(a, b) : fmin(a, b); ++ } ++ ++ return result; ++} ++ ++// Raw access to the PC register. ++void Simulator::set_pc(int64_t value) { ++ pc_modified_ = true; ++ registers_[pc] = value; ++ DCHECK(has_bad_pc() || ((value % kInstrSize) == 0)); ++} ++ ++bool Simulator::has_bad_pc() const { ++ return ((registers_[pc] == bad_ra) || (registers_[pc] == end_sim_pc)); ++} ++ ++// Raw access to the PC register without the special adjustment when reading. ++int64_t Simulator::get_pc() const { return registers_[pc]; } ++ ++// The RISC-V spec leaves it open to the implementation on how to handle ++// unaligned reads and writes. For now, we simply disallow unaligned reads but ++// at some point, we may want to implement some other behavior. ++ ++// TODO(plind): refactor this messy debug code when we do unaligned access. ++void Simulator::DieOrDebug() { ++ if ((1)) { // Flag for this was removed. ++ RiscvDebugger dbg(this); ++ dbg.Debug(); ++ } else { ++ base::OS::Abort(); ++ } ++} ++ ++void Simulator::TraceRegWr(int64_t value, TraceType t) { ++ if (::v8::internal::FLAG_trace_sim) { ++ union { ++ int64_t fmt_int64; ++ int32_t fmt_int32[2]; ++ float fmt_float[2]; ++ double fmt_double; ++ } v; ++ v.fmt_int64 = value; ++ ++ switch (t) { ++ case WORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 ++ " uint32:%" PRIu32, ++ v.fmt_int64, icount_, v.fmt_int32[0], v.fmt_int32[0]); ++ break; ++ case DWORD: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 ++ " uint64:%" PRIu64, ++ value, icount_, value, value); ++ break; ++ case FLOAT: ++ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") flt:%e", ++ v.fmt_int64, icount_, v.fmt_float[0]); ++ break; ++ case DOUBLE: ++ SNPrintF(trace_buf_, "%016" PRIx64 " (%" PRId64 ") dbl:%e", ++ v.fmt_int64, icount_, v.fmt_double); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++// TODO(plind): consider making icount_ printing a flag option. ++template ++void Simulator::TraceMemRd(int64_t addr, T value, int64_t reg_value) { ++ if (::v8::internal::FLAG_trace_sim) { ++ if (std::is_integral::value) { ++ switch (sizeof(T)) { ++ case 1: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int8:%" PRId8 ++ " uint8:%" PRIu8 " <-- [addr: %" PRIx64 "]", ++ reg_value, icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ case 2: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int16:%" PRId16 ++ " uint16:%" PRIu16 " <-- [addr: %" PRIx64 "]", ++ reg_value, icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ case 4: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int32:%" PRId32 ++ " uint32:%" PRIu32 " <-- [addr: %" PRIx64 "]", ++ reg_value, icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ case 8: ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") int64:%" PRId64 ++ " uint64:%" PRIu64 " <-- [addr: %" PRIx64 "]", ++ reg_value, icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } else if (std::is_same::value) { ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") flt:%e <-- [addr: %" PRIx64 ++ "]", ++ reg_value, icount_, static_cast(value), addr); ++ } else if (std::is_same::value) { ++ SNPrintF(trace_buf_, ++ "%016" PRIx64 " (%" PRId64 ") dbl:%e <-- [addr: %" PRIx64 ++ "]", ++ reg_value, icount_, static_cast(value), addr); ++ } else { ++ UNREACHABLE(); ++ } ++ } ++} ++ ++template ++void Simulator::TraceMemWr(int64_t addr, T value) { ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (sizeof(T)) { ++ case 1: ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ") int8:%" PRId8 ++ " uint8:%" PRIu8 " --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ case 2: ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ") int16:%" PRId16 ++ " uint16:%" PRIu16 " --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), ++ static_cast(value), addr); ++ break; ++ case 4: ++ if (std::is_integral::value) { ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ") int32:%" PRId32 ++ " uint32:%" PRIu32 " --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), ++ static_cast(value), addr); ++ } else { ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ++ ") flt:%e --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), addr); ++ } ++ break; ++ case 8: ++ if (std::is_integral::value) { ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ") int64:%" PRId64 ++ " uint64:%" PRIu64 " --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), ++ static_cast(value), addr); ++ } else { ++ SNPrintF(trace_buf_, ++ " (%" PRIu64 ++ ") dbl:%e --> [addr: %" PRIx64 "]", ++ icount_, static_cast(value), addr); ++ } ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++// RISCV Memory Read/Write functions ++ ++// FIXME (RISCV): check whether the specific board supports unaligned load/store ++// (determined by EEI). For now, we assume the board does not support unaligned ++// load/store (e.g., trapping) ++template ++T Simulator::ReadMem(int64_t addr, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory read from bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ ++ // check for natural alignment ++ if ((addr & (sizeof(T) - 1)) != 0) { ++ PrintF("Unaligned read at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, ++ reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ ++ T* ptr = reinterpret_cast(addr); ++ T value = *ptr; ++ return value; ++} ++ ++template ++void Simulator::WriteMem(int64_t addr, T value, Instruction* instr) { ++ if (addr >= 0 && addr < 0x400) { ++ // This has to be a nullptr-dereference, drop into debugger. ++ PrintF("Memory write to bad address: 0x%08" PRIx64 " , pc=0x%08" PRIxPTR ++ " \n", ++ addr, reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ ++ // check for natural alignment ++ if ((addr & (sizeof(T) - 1)) != 0) { ++ PrintF("Unaligned write at 0x%08" PRIx64 " , pc=0x%08" V8PRIxPTR "\n", addr, ++ reinterpret_cast(instr)); ++ DieOrDebug(); ++ } ++ ++ T* ptr = reinterpret_cast(addr); ++ TraceMemWr(addr, value); ++ *ptr = value; ++} ++ ++// Returns the limit of the stack area to enable checking for stack overflows. ++uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { ++ // The simulator uses a separate JS stack. If we have exhausted the C stack, ++ // we also drop down the JS limit to reflect the exhaustion on the JS stack. ++ if (GetCurrentStackPosition() < c_limit) { ++ return reinterpret_cast(get_sp()); ++ } ++ ++ // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes ++ // to prevent overrunning the stack when pushing values. ++ return reinterpret_cast(stack_) + 1024; ++} ++ ++// Unsupported instructions use Format to print an error and stop execution. ++void Simulator::Format(Instruction* instr, const char* format) { ++ PrintF("Simulator found unsupported instruction:\n 0x%08" PRIxPTR " : %s\n", ++ reinterpret_cast(instr), format); ++ UNIMPLEMENTED_RISCV(); ++} ++ ++// Calls into the V8 runtime are based on this very simple interface. ++// Note: To be able to return two values from some calls the code in ++// runtime.cc uses the ObjectPair which is essentially two 32-bit values ++// stuffed into a 64-bit value. With the code below we assume that all runtime ++// calls return 64 bits of result. If they don't, the a1 result register ++// contains a bogus value, which is fine because it is caller-saved. ++ ++using SimulatorRuntimeCall = ObjectPair (*)(int64_t arg0, int64_t arg1, ++ int64_t arg2, int64_t arg3, ++ int64_t arg4, int64_t arg5, ++ int64_t arg6, int64_t arg7, ++ int64_t arg8, int64_t arg9); ++ ++// These prototypes handle the four types of FP calls. ++using SimulatorRuntimeCompareCall = int64_t (*)(double darg0, double darg1); ++using SimulatorRuntimeFPFPCall = double (*)(double darg0, double darg1); ++using SimulatorRuntimeFPCall = double (*)(double darg0); ++using SimulatorRuntimeFPIntCall = double (*)(double darg0, int32_t arg0); ++ ++// This signature supports direct call in to API function native callback ++// (refer to InvocationCallback in v8.h). ++using SimulatorRuntimeDirectApiCall = void (*)(int64_t arg0); ++using SimulatorRuntimeProfilingApiCall = void (*)(int64_t arg0, void* arg1); ++ ++// This signature supports direct call to accessor getter callback. ++using SimulatorRuntimeDirectGetterCall = void (*)(int64_t arg0, int64_t arg1); ++using SimulatorRuntimeProfilingGetterCall = void (*)(int64_t arg0, int64_t arg1, ++ void* arg2); ++ ++// Software interrupt instructions are used by the simulator to call into the ++// C-based V8 runtime. They are also used for debugging with simulator. ++void Simulator::SoftwareInterrupt() { ++ // There are two instructions that could get us here, the ebreak or ecall ++ // instructions are "SYSTEM" class opcode distinuished by Imm12Value field w/ ++ // the rest of instruction fields being zero ++ int32_t func = instr_.Imm12Value(); ++ // We first check if we met a call_rt_redirected. ++ if (instr_.InstructionBits() == rtCallRedirInstr) { // ECALL ++ Redirection* redirection = Redirection::FromInstruction(instr_.instr()); ++ ++ int64_t* stack_pointer = reinterpret_cast(get_register(sp)); ++ ++ int64_t arg0 = get_register(a0); ++ int64_t arg1 = get_register(a1); ++ int64_t arg2 = get_register(a2); ++ int64_t arg3 = get_register(a3); ++ int64_t arg4 = get_register(a4); ++ int64_t arg5 = get_register(a5); ++ int64_t arg6 = get_register(a6); ++ int64_t arg7 = get_register(a7); ++ int64_t arg8 = stack_pointer[0]; ++ int64_t arg9 = stack_pointer[1]; ++ STATIC_ASSERT(kMaxCParameters == 10); ++ ++ bool fp_call = ++ (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || ++ (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); ++ ++ // This is dodgy but it works because the C entry stubs are never moved. ++ // See comment in codegen-arm.cc and bug 1242173. ++ int64_t saved_ra = get_register(ra); ++ ++ intptr_t external = ++ reinterpret_cast(redirection->external_function()); ++ ++ if (fp_call) { ++ double dval0, dval1; // one or two double parameters ++ int32_t ival; // zero or one integer parameters ++ int64_t iresult = 0; // integer return value ++ double dresult = 0; // double return value ++ GetFpArgs(&dval0, &dval1, &ival); ++ SimulatorRuntimeCall generic_target = ++ reinterpret_cast(external); ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_FP_FP_CALL: ++ case ExternalReference::BUILTIN_COMPARE_CALL: ++ PrintF("Call to host function at %p with args %f, %f", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0, dval1); ++ break; ++ case ExternalReference::BUILTIN_FP_CALL: ++ PrintF("Call to host function at %p with arg %f", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0); ++ break; ++ case ExternalReference::BUILTIN_FP_INT_CALL: ++ PrintF("Call to host function at %p with args %f, %d", ++ reinterpret_cast(FUNCTION_ADDR(generic_target)), ++ dval0, ival); ++ break; ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ } ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_COMPARE_CALL: { ++ SimulatorRuntimeCompareCall target = ++ reinterpret_cast(external); ++ iresult = target(dval0, dval1); ++ set_register(a0, static_cast(iresult)); ++ // set_register(a1, static_cast(iresult >> 32)); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_FP_CALL: { ++ SimulatorRuntimeFPFPCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0, dval1); ++ SetFpResult(dresult); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_CALL: { ++ SimulatorRuntimeFPCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0); ++ SetFpResult(dresult); ++ break; ++ } ++ case ExternalReference::BUILTIN_FP_INT_CALL: { ++ SimulatorRuntimeFPIntCall target = ++ reinterpret_cast(external); ++ dresult = target(dval0, ival); ++ SetFpResult(dresult); ++ break; ++ } ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ if (::v8::internal::FLAG_trace_sim) { ++ switch (redirection->type()) { ++ case ExternalReference::BUILTIN_COMPARE_CALL: ++ PrintF("Returned %08x\n", static_cast(iresult)); ++ break; ++ case ExternalReference::BUILTIN_FP_FP_CALL: ++ case ExternalReference::BUILTIN_FP_CALL: ++ case ExternalReference::BUILTIN_FP_INT_CALL: ++ PrintF("Returned %f\n", dresult); ++ break; ++ default: ++ UNREACHABLE(); ++ break; ++ } ++ } ++ } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " \n", ++ reinterpret_cast(external), arg0); ++ } ++ SimulatorRuntimeDirectApiCall target = ++ reinterpret_cast(external); ++ target(arg0); ++ } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " \n", ++ reinterpret_cast(external), arg0, arg1); ++ } ++ SimulatorRuntimeProfilingApiCall target = ++ reinterpret_cast(external); ++ target(arg0, Redirection::ReverseRedirection(arg1)); ++ } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " \n", ++ reinterpret_cast(external), arg0, arg1); ++ } ++ SimulatorRuntimeDirectGetterCall target = ++ reinterpret_cast(external); ++ target(arg0, arg1); ++ } else if (redirection->type() == ++ ExternalReference::PROFILING_GETTER_CALL) { ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Call to host function at %p args %08" PRIx64 " %08" PRIx64 ++ " %08" PRIx64 " \n", ++ reinterpret_cast(external), arg0, arg1, arg2); ++ } ++ SimulatorRuntimeProfilingGetterCall target = ++ reinterpret_cast(external); ++ target(arg0, arg1, Redirection::ReverseRedirection(arg2)); ++ } else { ++ DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL || ++ redirection->type() == ExternalReference::BUILTIN_CALL_PAIR); ++ SimulatorRuntimeCall target = ++ reinterpret_cast(external); ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF( ++ "Call to host function at %p " ++ "args %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 ++ " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 " , %08" PRIx64 ++ " , %08" PRIx64 " , %08" PRIx64 " \n", ++ reinterpret_cast(FUNCTION_ADDR(target)), arg0, arg1, arg2, ++ arg3, arg4, arg5, arg6, arg7, arg8, arg9); ++ } ++ ObjectPair result = ++ target(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); ++ set_register(a0, (int64_t)(result.x)); ++ set_register(a1, (int64_t)(result.y)); ++ } ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF("Returned %08" PRIx64 " : %08" PRIx64 " \n", get_register(a1), ++ get_register(a0)); ++ } ++ set_register(ra, saved_ra); ++ set_pc(get_register(ra)); ++ ++ } else if (func == 1) { // EBREAK ++ int32_t code = get_ebreak_code(instr_.instr()); ++ set_pc(get_pc() + kInstrSize * 2); ++ if (code != -1 && static_cast(code) <= kMaxStopCode) { ++ if (IsWatchpoint(code)) { ++ PrintWatchpoint(code); ++ } else { ++ IncreaseStopCounter(code); ++ HandleStop(code); ++ } ++ } else { ++ // All remaining break_ codes, and all traps are handled here. ++ RiscvDebugger dbg(this); ++ dbg.Debug(); ++ } ++ } else { ++ UNREACHABLE(); ++ } ++} ++ ++// Stop helper functions. ++bool Simulator::IsWatchpoint(uint64_t code) { ++ return (code <= kMaxWatchpointCode); ++} ++ ++void Simulator::PrintWatchpoint(uint64_t code) { ++ RiscvDebugger dbg(this); ++ ++break_count_; ++ PrintF("\n---- watchpoint %" PRId64 " marker: %3d (instr count: %8" PRId64 ++ " ) ----------" ++ "----------------------------------", ++ code, break_count_, icount_); ++ dbg.PrintAllRegs(); // Print registers and continue running. ++} ++ ++void Simulator::HandleStop(uint64_t code) { ++ // Stop if it is enabled, otherwise go on jumping over the stop ++ // and the message address. ++ if (IsEnabledStop(code)) { ++ RiscvDebugger dbg(this); ++ PrintF("Simulator hit stop (%" PRId64 ")\n", code); ++ dbg.Debug(); ++ } ++} ++ ++bool Simulator::IsStopInstruction(Instruction* instr) { ++ if (instr->InstructionBits() != kBreakInstr) return false; ++ int32_t code = get_ebreak_code(instr); ++ return code != -1 && static_cast(code) > kMaxWatchpointCode && ++ static_cast(code) <= kMaxStopCode; ++} ++ ++bool Simulator::IsEnabledStop(uint64_t code) { ++ DCHECK_LE(code, kMaxStopCode); ++ DCHECK_GT(code, kMaxWatchpointCode); ++ return !(watched_stops_[code].count & kStopDisabledBit); ++} ++ ++void Simulator::EnableStop(uint64_t code) { ++ if (!IsEnabledStop(code)) { ++ watched_stops_[code].count &= ~kStopDisabledBit; ++ } ++} ++ ++void Simulator::DisableStop(uint64_t code) { ++ if (IsEnabledStop(code)) { ++ watched_stops_[code].count |= kStopDisabledBit; ++ } ++} ++ ++void Simulator::IncreaseStopCounter(uint64_t code) { ++ DCHECK_LE(code, kMaxStopCode); ++ if ((watched_stops_[code].count & ~(1 << 31)) == 0x7FFFFFFF) { ++ PrintF("Stop counter for code %" PRId64 ++ " has overflowed.\n" ++ "Enabling this code and reseting the counter to 0.\n", ++ code); ++ watched_stops_[code].count = 0; ++ EnableStop(code); ++ } else { ++ watched_stops_[code].count++; ++ } ++} ++ ++// Print a stop status. ++void Simulator::PrintStopInfo(uint64_t code) { ++ if (code <= kMaxWatchpointCode) { ++ PrintF("That is a watchpoint, not a stop.\n"); ++ return; ++ } else if (code > kMaxStopCode) { ++ PrintF("Code too large, only %u stops can be used\n", kMaxStopCode + 1); ++ return; ++ } ++ const char* state = IsEnabledStop(code) ? "Enabled" : "Disabled"; ++ int32_t count = watched_stops_[code].count & ~kStopDisabledBit; ++ // Don't print the state of unused breakpoints. ++ if (count != 0) { ++ if (watched_stops_[code].desc) { ++ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i, \t%s\n", ++ code, code, state, count, watched_stops_[code].desc); ++ } else { ++ PrintF("stop %" PRId64 " - 0x%" PRIx64 " : \t%s, \tcounter = %i\n", code, ++ code, state, count); ++ } ++ } ++} ++ ++void Simulator::SignalException(Exception e) { ++ FATAL("Error: Exception %i raised.", static_cast(e)); ++} ++ ++// RISCV Instruction Decode Routine ++void Simulator::DecodeRVRType() { ++ switch (instr_.InstructionBits() & kRTypeMask) { ++ case RO_ADD: { ++ set_rd(sext_xlen(rs1() + rs2())); ++ break; ++ } ++ case RO_SUB: { ++ set_rd(sext_xlen(rs1() - rs2())); ++ break; ++ } ++ case RO_SLL: { ++ set_rd(sext_xlen(rs1() << (rs2() & (xlen - 1)))); ++ break; ++ } ++ case RO_SLT: { ++ set_rd(sreg_t(rs1()) < sreg_t(rs2())); ++ break; ++ } ++ case RO_SLTU: { ++ set_rd(reg_t(rs1()) < reg_t(rs2())); ++ break; ++ } ++ case RO_XOR: { ++ set_rd(rs1() ^ rs2()); ++ break; ++ } ++ case RO_SRL: { ++ set_rd(sext_xlen(zext_xlen(rs1()) >> (rs2() & (xlen - 1)))); ++ break; ++ } ++ case RO_SRA: { ++ set_rd(sext_xlen(sext_xlen(rs1()) >> (rs2() & (xlen - 1)))); ++ break; ++ } ++ case RO_OR: { ++ set_rd(rs1() | rs2()); ++ break; ++ } ++ case RO_AND: { ++ set_rd(rs1() & rs2()); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_ADDW: { ++ set_rd(sext32(rs1() + rs2())); ++ break; ++ } ++ case RO_SUBW: { ++ set_rd(sext32(rs1() - rs2())); ++ break; ++ } ++ case RO_SLLW: { ++ set_rd(sext32(rs1() << (rs2() & 0x1F))); ++ break; ++ } ++ case RO_SRLW: { ++ set_rd(sext32(uint32_t(rs1()) >> (rs2() & 0x1F))); ++ break; ++ } ++ case RO_SRAW: { ++ set_rd(sext32(int32_t(rs1()) >> (rs2() & 0x1F))); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ // TODO: Add RISCV M extension macro ++ case RO_MUL: { ++ set_rd(rs1() * rs2()); ++ break; ++ } ++ case RO_MULH: { ++ set_rd(mulh(rs1(), rs2())); ++ break; ++ } ++ case RO_MULHSU: { ++ set_rd(mulhsu(rs1(), rs2())); ++ break; ++ } ++ case RO_MULHU: { ++ set_rd(mulhu(rs1(), rs2())); ++ break; ++ } ++ case RO_DIV: { ++ sreg_t lhs = sext_xlen(rs1()); ++ sreg_t rhs = sext_xlen(rs2()); ++ if (rhs == 0) { ++ set_rd(-1); ++ } else if (lhs == INT64_MIN && rhs == -1) { ++ set_rd(lhs); ++ } else { ++ set_rd(sext_xlen(lhs / rhs)); ++ } ++ break; ++ } ++ case RO_DIVU: { ++ reg_t lhs = zext_xlen(rs1()); ++ reg_t rhs = zext_xlen(rs2()); ++ if (rhs == 0) { ++ set_rd(UINT64_MAX); ++ } else { ++ set_rd(zext_xlen(lhs / rhs)); ++ } ++ break; ++ } ++ case RO_REM: { ++ sreg_t lhs = sext_xlen(rs1()); ++ sreg_t rhs = sext_xlen(rs2()); ++ if (rhs == 0) { ++ set_rd(lhs); ++ } else if (lhs == INT64_MIN && rhs == -1) { ++ set_rd(0); ++ } else { ++ set_rd(sext_xlen(lhs % rhs)); ++ } ++ break; ++ } ++ case RO_REMU: { ++ reg_t lhs = zext_xlen(rs1()); ++ reg_t rhs = zext_xlen(rs2()); ++ if (rhs == 0) { ++ set_rd(lhs); ++ } else { ++ set_rd(zext_xlen(lhs % rhs)); ++ } ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_MULW: { ++ set_rd(sext32(sext32(rs1()) * sext32(rs2()))); ++ break; ++ } ++ case RO_DIVW: { ++ sreg_t lhs = sext32(rs1()); ++ sreg_t rhs = sext32(rs2()); ++ if (rhs == 0) { ++ set_rd(-1); ++ } else if (lhs == INT32_MIN && rhs == -1) { ++ set_rd(lhs); ++ } else { ++ set_rd(sext32(lhs / rhs)); ++ } ++ break; ++ } ++ case RO_DIVUW: { ++ reg_t lhs = zext32(rs1()); ++ reg_t rhs = zext32(rs2()); ++ if (rhs == 0) { ++ set_rd(UINT32_MAX); ++ } else { ++ set_rd(zext32(lhs / rhs)); ++ } ++ break; ++ } ++ case RO_REMW: { ++ sreg_t lhs = sext32(rs1()); ++ sreg_t rhs = sext32(rs2()); ++ if (rhs == 0) { ++ set_rd(lhs); ++ } else if (lhs == INT32_MIN && rhs == -1) { ++ set_rd(0); ++ } else { ++ set_rd(sext32(lhs % rhs)); ++ } ++ break; ++ } ++ case RO_REMUW: { ++ reg_t lhs = zext32(rs1()); ++ reg_t rhs = zext32(rs2()); ++ if (rhs == 0) { ++ set_rd(zext32(lhs)); ++ } else { ++ set_rd(zext32(lhs % rhs)); ++ } ++ break; ++ } ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: End Add RISCV M extension macro ++ default: { ++ switch (instr_.BaseOpcode()) { ++ case AMO: ++ DecodeRVRAType(); ++ break; ++ case OP_FP: ++ DecodeRVRFPType(); ++ break; ++ default: ++ UNSUPPORTED(); ++ } ++ } ++ } ++} ++ ++float Simulator::RoundF2FHelper(float input_val, int rmode) { ++ if (rmode == DYN) rmode = get_dynamic_rounding_mode(); ++ ++ float rounded = 0; ++ switch (rmode) { ++ case RNE: { // Round to Nearest, tiest to Even ++ int curr_mode = fegetround(); ++ fesetround(FE_TONEAREST); ++ rounded = std::nearbyintf(input_val); ++ fesetround(curr_mode); ++ break; ++ } ++ case RTZ: // Round towards Zero ++ rounded = std::truncf(input_val); ++ break; ++ case RDN: // Round Down (towards -infinity) ++ rounded = floorf(input_val); ++ break; ++ case RUP: // Round Up (towards +infinity) ++ rounded = ceilf(input_val); ++ break; ++ case RMM: // Round to Nearest, tiest to Max Magnitude ++ rounded = std::roundf(input_val); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ return rounded; ++} ++ ++double Simulator::RoundF2FHelper(double input_val, int rmode) { ++ if (rmode == DYN) rmode = get_dynamic_rounding_mode(); ++ ++ double rounded = 0; ++ switch (rmode) { ++ case RNE: { // Round to Nearest, tiest to Even ++ int curr_mode = fegetround(); ++ fesetround(FE_TONEAREST); ++ rounded = std::nearbyint(input_val); ++ fesetround(curr_mode); ++ break; ++ } ++ case RTZ: // Round towards Zero ++ rounded = std::trunc(input_val); ++ break; ++ case RDN: // Round Down (towards -infinity) ++ rounded = std::floor(input_val); ++ break; ++ case RUP: // Round Up (towards +infinity) ++ rounded = std::ceil(input_val); ++ break; ++ case RMM: // Round to Nearest, tiest to Max Magnitude ++ rounded = std::round(input_val); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ return rounded; ++} ++ ++// convert rounded floating-point to integer types, handle input values that ++// are out-of-range, underflow, or NaN, and set appropriate fflags ++template ++I_TYPE Simulator::RoundF2IHelper(F_TYPE original, int rmode) { ++ DCHECK(std::is_integral::value); ++ ++ DCHECK((std::is_same::value || ++ std::is_same::value)); ++ ++ I_TYPE max_i = std::numeric_limits::max(); ++ I_TYPE min_i = std::numeric_limits::min(); ++ ++ if (!std::isfinite(original)) { ++ set_fflags(kInvalidOperation); ++ if (std::isnan(original) || ++ original == std::numeric_limits::infinity()) { ++ return max_i; ++ } else { ++ DCHECK(original == -std::numeric_limits::infinity()); ++ return min_i; ++ } ++ } ++ ++ F_TYPE rounded = RoundF2FHelper(original, rmode); ++ if (original != rounded) set_fflags(kInexact); ++ ++ if (!std::isfinite(rounded)) { ++ set_fflags(kInvalidOperation); ++ if (std::isnan(rounded) || ++ rounded == std::numeric_limits::infinity()) { ++ return max_i; ++ } else { ++ DCHECK(rounded == -std::numeric_limits::infinity()); ++ return min_i; ++ } ++ } ++ ++ // FIXME (RISCV): comparison of rounded (float) and max_i (integer) may not ++ // be precise because max_i is promoted to floating point during comparison. ++ // Rounding up may happen when converting max_i to floating-point, e.g., ++ // max is 9223372036854775807 vs. (double)max is ++ // 9223372036854775808.00000000000000 ++ ++ // Since integer max values are either all 1s (for unsigned) or all 1s ++ // except for sign-bit (for signed), they cannot be represented precisely in ++ // floating point, in order to precisely tell whether the rounded floating ++ // point is within the max range, we compare against (max_i+1) which would ++ // have a single 1 w/ many trailing zeros ++ float max_i_plus_1 = ++ std::is_same::value ++ ? 0x1p64f // uint64_t::max + 1 cannot be represented in integers, ++ // so use its float representation directly ++ : static_cast(static_cast(max_i) + 1); ++ if (rounded >= max_i_plus_1) { ++ set_fflags(kOverflow | kInvalidOperation); ++ return max_i; ++ } ++ ++ // Since min_i (either 0 for unsigned, or for signed) is represented ++ // precisely in floating-point, comparing rounded directly against min_i ++ if (rounded <= min_i) { ++ if (rounded < min_i) set_fflags(kOverflow | kInvalidOperation); ++ return min_i; ++ } ++ ++ F_TYPE underflow_fval = ++ std::is_same::value ? FLT_MIN : DBL_MIN; ++ if (rounded < underflow_fval && rounded > -underflow_fval && rounded != 0) { ++ set_fflags(kUnderflow); ++ } ++ ++ return static_cast(rounded); ++} ++ ++template ++static int64_t FclassHelper(T value) { ++ switch (std::fpclassify(value)) { ++ case FP_INFINITE: ++ return (std::signbit(value) ? kNegativeInfinity : kPositiveInfinity); ++ case FP_NAN: ++ return (isSnan(value) ? kSignalingNaN : kQuietNaN); ++ case FP_NORMAL: ++ return (std::signbit(value) ? kNegativeNormalNumber ++ : kPositiveNormalNumber); ++ case FP_SUBNORMAL: ++ return (std::signbit(value) ? kNegativeSubnormalNumber ++ : kPositiveSubnormalNumber); ++ case FP_ZERO: ++ return (std::signbit(value) ? kNegativeZero : kPositiveZero); ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++template ++bool Simulator::CompareFHelper(T input1, T input2, FPUCondition cc) { ++ DCHECK(std::is_floating_point::value); ++ bool result = false; ++ switch (cc) { ++ case LT: ++ case LE: ++ // FLT, FLE are signaling compares ++ if (std::isnan(input1) || std::isnan(input2)) { ++ set_fflags(kInvalidOperation); ++ result = false; ++ } else { ++ result = (cc == LT) ? (input1 < input2) : (input1 <= input2); ++ } ++ break; ++ ++ case EQ: ++ if (std::numeric_limits::signaling_NaN() == input1 || ++ std::numeric_limits::signaling_NaN() == input2) { ++ set_fflags(kInvalidOperation); ++ } ++ if (std::isnan(input1) || std::isnan(input2)) { ++ result = false; ++ } else { ++ result = (input1 == input2); ++ } ++ break; ++ ++ default: ++ UNREACHABLE(); ++ } ++ return result; ++} ++ ++template ++static inline bool is_invalid_fmul(T src1, T src2) { ++ return (isinf(src1) && src2 == static_cast(0.0)) || ++ (src1 == static_cast(0.0) && isinf(src2)); ++} ++ ++template ++static inline bool is_invalid_fadd(T src1, T src2) { ++ return (isinf(src1) && isinf(src2) && ++ std::signbit(src1) != std::signbit(src2)); ++} ++ ++template ++static inline bool is_invalid_fsub(T src1, T src2) { ++ return (isinf(src1) && isinf(src2) && ++ std::signbit(src1) == std::signbit(src2)); ++} ++ ++template ++static inline bool is_invalid_fdiv(T src1, T src2) { ++ return ((src1 == 0 && src2 == 0) || (isinf(src1) && isinf(src2))); ++} ++ ++template ++static inline bool is_invalid_fsqrt(T src1) { ++ return (src1 < 0); ++} ++ ++void Simulator::DecodeRVRAType() { ++ // TODO: Add macro for RISCV A extension ++ // Special handling for A extension instructions because it uses func5 ++ // For all A extension instruction, V8 simulator is pure sequential. No ++ // Memory address lock or other synchronizaiton behaviors. ++ switch (instr_.InstructionBits() & kRATypeMask) { ++ case RO_LR_W: { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ int64_t addr = rs1(); ++ auto val = ReadMem(addr, instr_.instr()); ++ set_rd(sext32(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ local_monitor_.NotifyLoadLinked(addr, TransactionSize::Word); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, ++ &global_monitor_thread_); ++ break; ++ } ++ case RO_SC_W: { ++ int64_t addr = rs1(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ if (local_monitor_.NotifyStoreConditional(addr, TransactionSize::Word) && ++ GlobalMonitor::Get()->NotifyStoreConditional_Locked( ++ addr, &global_monitor_thread_)) { ++ local_monitor_.NotifyStore(); ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ WriteMem(rs1(), (int32_t)rs2(), instr_.instr()); ++ set_rd(0, false); ++ } else { ++ set_rd(1, false); ++ } ++ break; ++ } ++ case RO_AMOSWAP_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return (uint32_t)rs2(); }, instr_.instr(), ++ WORD))); ++ break; ++ } ++ case RO_AMOADD_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return lhs + (uint32_t)rs2(); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOXOR_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return lhs ^ (uint32_t)rs2(); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOAND_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return lhs & (uint32_t)rs2(); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOOR_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return lhs | (uint32_t)rs2(); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOMIN_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](int32_t lhs) { return std::min(lhs, (int32_t)rs2()); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOMAX_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](int32_t lhs) { return std::max(lhs, (int32_t)rs2()); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOMINU_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return std::min(lhs, (uint32_t)rs2()); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++ case RO_AMOMAXU_W: { ++ set_rd(sext32(amo( ++ rs1(), [&](uint32_t lhs) { return std::max(lhs, (uint32_t)rs2()); }, ++ instr_.instr(), WORD))); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_LR_D: { ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ int64_t addr = rs1(); ++ auto val = ReadMem(addr, instr_.instr()); ++ set_rd(val, false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ local_monitor_.NotifyLoadLinked(addr, TransactionSize::DoubleWord); ++ GlobalMonitor::Get()->NotifyLoadLinked_Locked(addr, ++ &global_monitor_thread_); ++ break; ++ } ++ case RO_SC_D: { ++ int64_t addr = rs1(); ++ base::MutexGuard lock_guard(&GlobalMonitor::Get()->mutex); ++ if (local_monitor_.NotifyStoreConditional(addr, ++ TransactionSize::DoubleWord) && ++ (GlobalMonitor::Get()->NotifyStoreConditional_Locked( ++ addr, &global_monitor_thread_))) { ++ GlobalMonitor::Get()->NotifyStore_Locked(&global_monitor_thread_); ++ WriteMem(rs1(), rs2(), instr_.instr()); ++ set_rd(0, false); ++ } else { ++ set_rd(1, false); ++ } ++ break; ++ } ++ case RO_AMOSWAP_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return rs2(); }, instr_.instr(), DWORD)); ++ break; ++ } ++ case RO_AMOADD_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return lhs + rs2(); }, instr_.instr(), ++ DWORD)); ++ break; ++ } ++ case RO_AMOXOR_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return lhs ^ rs2(); }, instr_.instr(), ++ DWORD)); ++ break; ++ } ++ case RO_AMOAND_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return lhs & rs2(); }, instr_.instr(), ++ DWORD)); ++ break; ++ } ++ case RO_AMOOR_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return lhs | rs2(); }, instr_.instr(), ++ DWORD)); ++ break; ++ } ++ case RO_AMOMIN_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return std::min(lhs, rs2()); }, ++ instr_.instr(), DWORD)); ++ break; ++ } ++ case RO_AMOMAX_D: { ++ set_rd(amo( ++ rs1(), [&](int64_t lhs) { return std::max(lhs, rs2()); }, ++ instr_.instr(), DWORD)); ++ break; ++ } ++ case RO_AMOMINU_D: { ++ set_rd(amo( ++ rs1(), [&](uint64_t lhs) { return std::min(lhs, (uint64_t)rs2()); }, ++ instr_.instr(), DWORD)); ++ break; ++ } ++ case RO_AMOMAXU_D: { ++ set_rd(amo( ++ rs1(), [&](uint64_t lhs) { return std::max(lhs, (uint64_t)rs2()); }, ++ instr_.instr(), DWORD)); ++ break; ++ } ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: End Add macro for RISCV A extension ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++} ++ ++void Simulator::DecodeRVRFPType() { ++ // OP_FP instructions (F/D) uses func7 first. Some further uses fun3 and ++ // rs2() ++ ++ // kRATypeMask is only for func7 ++ switch (instr_.InstructionBits() & kRFPTypeMask) { ++ // TODO: Add macro for RISCV F extension ++ case RO_FADD_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2) { ++ if (is_invalid_fadd(frs1, frs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return frs1 + frs2; ++ } ++ }; ++ set_frd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FSUB_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2) { ++ if (is_invalid_fsub(frs1, frs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return frs1 - frs2; ++ } ++ }; ++ set_frd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FMUL_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2) { ++ if (is_invalid_fmul(frs1, frs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return frs1 * frs2; ++ } ++ }; ++ set_frd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FDIV_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2) { ++ if (is_invalid_fdiv(frs1, frs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else if (frs2 == 0.0f) { ++ this->set_fflags(kDivideByZero); ++ return (std::signbit(frs1) == std::signbit(frs2) ++ ? std::numeric_limits::infinity() ++ : -std::numeric_limits::infinity()); ++ } else { ++ return frs1 / frs2; ++ } ++ }; ++ set_frd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FSQRT_S: { ++ if (instr_.Rs2Value() == 0b00000) { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs) { ++ if (is_invalid_fsqrt(frs)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::sqrt(frs); ++ } ++ }; ++ set_frd(CanonicalizeFPUOp1(fn)); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ case RO_FSGNJ_S: { // RO_FSGNJN_S RO_FSQNJX_S ++ switch (instr_.Funct3Value()) { ++ case 0b000: { // RO_FSGNJ_S ++ set_frd(fsgnj32(frs1(), frs2(), false, false)); ++ break; ++ } ++ case 0b001: { // RO_FSGNJN_S ++ set_frd(fsgnj32(frs1(), frs2(), true, false)); ++ break; ++ } ++ case 0b010: { // RO_FSQNJX_S ++ set_frd(fsgnj32(frs1(), frs2(), false, true)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FMIN_S: { // RO_FMAX_S ++ switch (instr_.Funct3Value()) { ++ case 0b000: { // RO_FMIN_S ++ set_frd(FMaxMinHelper(frs1(), frs2(), MaxMinKind::kMin)); ++ break; ++ } ++ case 0b001: { // RO_FMAX_S ++ set_frd(FMaxMinHelper(frs1(), frs2(), MaxMinKind::kMax)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FCVT_W_S: { // RO_FCVT_WU_S , 64F RO_FCVT_L_S RO_FCVT_LU_S ++ float original_val = frs1(); ++ switch (instr_.Rs2Value()) { ++ case 0b00000: { // RO_FCVT_W_S ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++ case 0b00001: { // RO_FCVT_WU_S ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: { // RO_FCVT_L_S ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++ case 0b00011: { // RO_FCVT_LU_S ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FMV: { // RO_FCLASS_S ++ switch (instr_.Funct3Value()) { ++ case 0b000: { ++ if (instr_.Rs2Value() == 0b00000) { ++ // RO_FMV_X_W ++ set_rd(sext_xlen(get_fpu_register_word(rs1_reg()))); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ case 0b001: { // RO_FCLASS_S ++ set_rd(FclassHelper(frs1())); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ // FIXME (RISCV): implement handling of NaN (quiet and signalling) ++ case RO_FLE_S: { // RO_FEQ_S RO_FLT_S RO_FLE_S ++ switch (instr_.Funct3Value()) { ++ case 0b010: { // RO_FEQ_S ++ set_rd(CompareFHelper(frs1(), frs2(), EQ)); ++ break; ++ } ++ case 0b001: { // RO_FLT_S ++ set_rd(CompareFHelper(frs1(), frs2(), LT)); ++ break; ++ } ++ case 0b000: { // RO_FLE_S ++ set_rd(CompareFHelper(frs1(), frs2(), LE)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FCVT_S_W: { // RO_FCVT_S_WU , 64F RO_FCVT_S_L RO_FCVT_S_LU ++ switch (instr_.Rs2Value()) { ++ case 0b00000: { // RO_FCVT_S_W ++ set_frd((float)(int32_t)rs1()); ++ break; ++ } ++ case 0b00001: { // RO_FCVT_S_WU ++ set_frd((float)(uint32_t)rs1()); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: { // RO_FCVT_S_L ++ set_frd((float)(int64_t)rs1()); ++ break; ++ } ++ case 0b00011: { // RO_FCVT_S_LU ++ set_frd((float)(uint64_t)rs1()); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FMV_W_X: { ++ if (instr_.Funct3Value() == 0b000) { ++ // since FMV preserves source bit-pattern, no need to canonize ++ set_frd(bit_cast((uint32_t)rs1())); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ // TODO: Add macro for RISCV D extension ++ case RO_FADD_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2) { ++ if (is_invalid_fadd(drs1, drs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return drs1 + drs2; ++ } ++ }; ++ set_drd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FSUB_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2) { ++ if (is_invalid_fsub(drs1, drs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return drs1 - drs2; ++ } ++ }; ++ set_drd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FMUL_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2) { ++ if (is_invalid_fmul(drs1, drs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return drs1 * drs2; ++ } ++ }; ++ set_drd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FDIV_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2) { ++ if (is_invalid_fdiv(drs1, drs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else if (drs2 == 0.0) { ++ this->set_fflags(kDivideByZero); ++ return (std::signbit(drs1) == std::signbit(drs2) ++ ? std::numeric_limits::infinity() ++ : -std::numeric_limits::infinity()); ++ } else { ++ return drs1 / drs2; ++ } ++ }; ++ set_drd(CanonicalizeFPUOp2(fn)); ++ break; ++ } ++ case RO_FSQRT_D: { ++ if (instr_.Rs2Value() == 0b00000) { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs) { ++ if (is_invalid_fsqrt(drs)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::sqrt(drs); ++ } ++ }; ++ set_drd(CanonicalizeFPUOp1(fn)); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ case RO_FSGNJ_D: { // RO_FSGNJN_D RO_FSQNJX_D ++ switch (instr_.Funct3Value()) { ++ case 0b000: { // RO_FSGNJ_D ++ set_drd(fsgnj64(drs1(), drs2(), false, false)); ++ break; ++ } ++ case 0b001: { // RO_FSGNJN_D ++ set_drd(fsgnj64(drs1(), drs2(), true, false)); ++ break; ++ } ++ case 0b010: { // RO_FSQNJX_D ++ set_drd(fsgnj64(drs1(), drs2(), false, true)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FMIN_D: { // RO_FMAX_D ++ switch (instr_.Funct3Value()) { ++ case 0b000: { // RO_FMIN_D ++ set_drd(FMaxMinHelper(drs1(), drs2(), MaxMinKind::kMin)); ++ break; ++ } ++ case 0b001: { // RO_FMAX_D ++ set_drd(FMaxMinHelper(drs1(), drs2(), MaxMinKind::kMax)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case (RO_FCVT_S_D & kRFPTypeMask): { ++ if (instr_.Rs2Value() == 0b00001) { ++ auto fn = [](double drs) { return (float)drs; }; ++ set_frd(CanonicalizeDoubleToFloatOperation(fn)); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ case RO_FCVT_D_S: { ++ if (instr_.Rs2Value() == 0b00000) { ++ auto fn = [](float frs) { return (double)frs; }; ++ set_drd(CanonicalizeFloatToDoubleOperation(fn)); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ case RO_FLE_D: { // RO_FEQ_D RO_FLT_D RO_FLE_D ++ switch (instr_.Funct3Value()) { ++ case 0b010: { // RO_FEQ_S ++ set_rd(CompareFHelper(drs1(), drs2(), EQ)); ++ break; ++ } ++ case 0b001: { // RO_FLT_D ++ set_rd(CompareFHelper(drs1(), drs2(), LT)); ++ break; ++ } ++ case 0b000: { // RO_FLE_D ++ set_rd(CompareFHelper(drs1(), drs2(), LE)); ++ break; ++ } ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case (RO_FCLASS_D & kRFPTypeMask): { // RO_FCLASS_D , 64D RO_FMV_X_D ++ if (instr_.Rs2Value() != 0b00000) { ++ UNSUPPORTED(); ++ break; ++ } ++ switch (instr_.Funct3Value()) { ++ case 0b001: { // RO_FCLASS_D ++ set_rd(FclassHelper(drs1())); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b000: { // RO_FMV_X_D ++ set_rd(bit_cast(drs1())); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FCVT_W_D: { // RO_FCVT_WU_D , 64F RO_FCVT_L_D RO_FCVT_LU_D ++ double original_val = drs1(); ++ switch (instr_.Rs2Value()) { ++ case 0b00000: { // RO_FCVT_W_D ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++ case 0b00001: { // RO_FCVT_WU_D ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: { // RO_FCVT_L_D ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++ case 0b00011: { // RO_FCVT_LU_D ++ set_rd(RoundF2IHelper(original_val, instr_.RoundMode())); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++ case RO_FCVT_D_W: { // RO_FCVT_D_WU , 64F RO_FCVT_D_L RO_FCVT_D_LU ++ switch (instr_.Rs2Value()) { ++ case 0b00000: { // RO_FCVT_D_W ++ set_drd((int32_t)rs1()); ++ break; ++ } ++ case 0b00001: { // RO_FCVT_D_WU ++ set_drd((uint32_t)rs1()); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case 0b00010: { // RO_FCVT_D_L ++ set_drd((int64_t)rs1()); ++ break; ++ } ++ case 0b00011: { // RO_FCVT_D_LU ++ set_drd((uint64_t)rs1()); ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_FMV_D_X: { ++ if (instr_.Funct3Value() == 0b000 && instr_.Rs2Value() == 0b00000) { ++ // Since FMV preserves source bit-pattern, no need to canonize ++ set_drd(bit_cast(rs1())); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++#endif /* V8_TARGET_ARCH_64_BIT */ ++ default: { ++ UNSUPPORTED(); ++ } ++ } ++} ++ ++void Simulator::DecodeRVR4Type() { ++ switch (instr_.InstructionBits() & kR4TypeMask) { ++ // TODO: use F Extension macro block ++ case RO_FMADD_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2, float frs3) { ++ if (is_invalid_fmul(frs1, frs2) || is_invalid_fadd(frs1 * frs2, frs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::fma(frs1, frs2, frs3); ++ } ++ }; ++ set_frd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FMSUB_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2, float frs3) { ++ if (is_invalid_fmul(frs1, frs2) || is_invalid_fsub(frs1 * frs2, frs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::fma(frs1, frs2, -frs3); ++ } ++ }; ++ set_frd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FNMSUB_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2, float frs3) { ++ if (is_invalid_fmul(frs1, frs2) || is_invalid_fsub(frs3, frs1 * frs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return -std::fma(frs1, frs2, -frs3); ++ } ++ }; ++ set_frd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FNMADD_S: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](float frs1, float frs2, float frs3) { ++ if (is_invalid_fmul(frs1, frs2) || is_invalid_fadd(frs1 * frs2, frs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return -std::fma(frs1, frs2, frs3); ++ } ++ }; ++ set_frd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ // TODO: use F Extension macro block ++ case RO_FMADD_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2, double drs3) { ++ if (is_invalid_fmul(drs1, drs2) || is_invalid_fadd(drs1 * drs2, drs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::fma(drs1, drs2, drs3); ++ } ++ }; ++ set_drd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FMSUB_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2, double drs3) { ++ if (is_invalid_fmul(drs1, drs2) || is_invalid_fsub(drs1 * drs2, drs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return std::fma(drs1, drs2, -drs3); ++ } ++ }; ++ set_drd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FNMSUB_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2, double drs3) { ++ if (is_invalid_fmul(drs1, drs2) || is_invalid_fsub(drs3, drs1 * drs2)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return -std::fma(drs1, drs2, -drs3); ++ } ++ }; ++ set_drd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ case RO_FNMADD_D: { ++ // TODO: use rm value (round mode) ++ auto fn = [this](double drs1, double drs2, double drs3) { ++ if (is_invalid_fmul(drs1, drs2) || is_invalid_fadd(drs1 * drs2, drs3)) { ++ this->set_fflags(kInvalidOperation); ++ return std::numeric_limits::quiet_NaN(); ++ } else { ++ return -std::fma(drs1, drs2, drs3); ++ } ++ }; ++ set_drd(CanonicalizeFPUOp3(fn)); ++ break; ++ } ++ default: ++ UNSUPPORTED(); ++ } ++} ++ ++void Simulator::DecodeRVIType() { ++ switch (instr_.InstructionBits() & kITypeMask) { ++ case RO_JALR: { ++ set_rd(get_pc() + kInstrSize); ++ // Note: No need to shift 2 for JALR's imm12, but set lowest bit to 0. ++ int64_t next_pc = (rs1() + imm12()) & ~reg_t(1); ++ set_pc(next_pc); ++ break; ++ } ++ case RO_LB: { ++ int64_t addr = rs1() + imm12(); ++ int8_t val = ReadMem(addr, instr_.instr()); ++ set_rd(sext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++ case RO_LH: { ++ int64_t addr = rs1() + imm12(); ++ int16_t val = ReadMem(addr, instr_.instr()); ++ set_rd(sext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++ case RO_LW: { ++ int64_t addr = rs1() + imm12(); ++ int32_t val = ReadMem(addr, instr_.instr()); ++ set_rd(sext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++ case RO_LBU: { ++ int64_t addr = rs1() + imm12(); ++ uint8_t val = ReadMem(addr, instr_.instr()); ++ set_rd(zext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++ case RO_LHU: { ++ int64_t addr = rs1() + imm12(); ++ uint16_t val = ReadMem(addr, instr_.instr()); ++ set_rd(zext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_LWU: { ++ int64_t addr = rs1() + imm12(); ++ uint32_t val = ReadMem(addr, instr_.instr()); ++ set_rd(zext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++ case RO_LD: { ++ int64_t addr = rs1() + imm12(); ++ int64_t val = ReadMem(addr, instr_.instr()); ++ set_rd(sext_xlen(val), false); ++ TraceMemRd(addr, val, get_register(rd_reg())); ++ break; ++ } ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ case RO_ADDI: { ++ set_rd(sext_xlen(rs1() + imm12())); ++ break; ++ } ++ case RO_SLTI: { ++ set_rd(sreg_t(rs1()) < sreg_t(imm12())); ++ break; ++ } ++ case RO_SLTIU: { ++ set_rd(reg_t(rs1()) < reg_t(imm12())); ++ break; ++ } ++ case RO_XORI: { ++ set_rd(imm12() ^ rs1()); ++ break; ++ } ++ case RO_ORI: { ++ set_rd(imm12() | rs1()); ++ break; ++ } ++ case RO_ANDI: { ++ set_rd(imm12() & rs1()); ++ break; ++ } ++ case RO_SLLI: { ++ require(shamt() < xlen); ++ set_rd(sext_xlen(rs1() << shamt())); ++ break; ++ } ++ case RO_SRLI: { // RO_SRAI ++ if (!instr_.IsArithShift()) { ++ require(shamt() < xlen); ++ set_rd(sext_xlen(zext_xlen(rs1()) >> shamt())); ++ } else { ++ require(shamt() < xlen); ++ set_rd(sext_xlen(sext_xlen(rs1()) >> shamt())); ++ } ++ break; ++ } ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_ADDIW: { ++ set_rd(sext32(rs1() + imm12())); ++ break; ++ } ++ case RO_SLLIW: { ++ set_rd(sext32(rs1() << shamt32())); ++ break; ++ } ++ case RO_SRLIW: { // RO_SRAIW ++ if (!instr_.IsArithShift()) { ++ set_rd(sext32(uint32_t(rs1()) >> shamt32())); ++ } else { ++ set_rd(sext32(int32_t(rs1()) >> shamt32())); ++ } ++ break; ++ } ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ case RO_FENCE: { ++ // DO nothing in sumulator ++ break; ++ } ++ case RO_ECALL: { // RO_EBREAK ++ if (instr_.Imm12Value() == 0) { // ECALL ++ SoftwareInterrupt(); ++ } else if (instr_.Imm12Value() == 1) { // EBREAK ++ SoftwareInterrupt(); ++ } else { ++ UNSUPPORTED(); ++ } ++ break; ++ } ++ // TODO: use Zifencei Standard Extension macro block ++ case RO_FENCE_I: { ++ // spike: flush icache. ++ break; ++ } ++ // TODO: use Zicsr Standard Extension macro block ++ case RO_CSRRW: { ++ if (rd_reg() != zero_reg) { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ } ++ write_csr_value(csr_reg(), rs1()); ++ break; ++ } ++ case RO_CSRRS: { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ if (rs1_reg() != zero_reg) { ++ set_csr_bits(csr_reg(), rs1()); ++ } ++ break; ++ } ++ case RO_CSRRC: { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ if (rs1_reg() != zero_reg) { ++ clear_csr_bits(csr_reg(), rs1()); ++ } ++ break; ++ } ++ case RO_CSRRWI: { ++ if (rd_reg() != zero_reg) { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ } ++ write_csr_value(csr_reg(), imm5CSR()); ++ break; ++ } ++ case RO_CSRRSI: { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ if (imm5CSR() != 0) { ++ set_csr_bits(csr_reg(), imm5CSR()); ++ } ++ break; ++ } ++ case RO_CSRRCI: { ++ set_rd(zext_xlen(read_csr_value(csr_reg()))); ++ if (imm5CSR() != 0) { ++ clear_csr_bits(csr_reg(), imm5CSR()); ++ } ++ break; ++ } ++ // TODO: use F Extension macro block ++ case RO_FLW: { ++ int64_t addr = rs1() + imm12(); ++ float val = ReadMem(addr, instr_.instr()); ++ set_frd(val, false); ++ TraceMemRd(addr, val, get_fpu_register(frd_reg())); ++ break; ++ } ++ // TODO: use D Extension macro block ++ case RO_FLD: { ++ int64_t addr = rs1() + imm12(); ++ double val = ReadMem(addr, instr_.instr()); ++ set_drd(val, false); ++ TraceMemRd(addr, val, get_fpu_register(frd_reg())); ++ break; ++ } ++ default: ++ UNSUPPORTED(); ++ } ++} ++ ++void Simulator::DecodeRVSType() { ++ switch (instr_.InstructionBits() & kSTypeMask) { ++ case RO_SB: ++ WriteMem(rs1() + s_imm12(), (uint8_t)rs2(), instr_.instr()); ++ break; ++ case RO_SH: ++ WriteMem(rs1() + s_imm12(), (uint16_t)rs2(), instr_.instr()); ++ break; ++ case RO_SW: ++ WriteMem(rs1() + s_imm12(), (uint32_t)rs2(), instr_.instr()); ++ break; ++#ifdef V8_TARGET_ARCH_64_BIT ++ case RO_SD: ++ WriteMem(rs1() + s_imm12(), (uint64_t)rs2(), instr_.instr()); ++ break; ++#endif /*V8_TARGET_ARCH_64_BIT*/ ++ // TODO: use F Extension macro block ++ case RO_FSW: { ++ WriteMem(rs1() + s_imm12(), ++ (uint32_t)get_fpu_register_word(rs2_reg()), ++ instr_.instr()); ++ break; ++ } ++ // TODO: use D Extension macro block ++ case RO_FSD: { ++ WriteMem(rs1() + s_imm12(), drs2(), instr_.instr()); ++ break; ++ } ++ default: ++ UNSUPPORTED(); ++ } ++} ++ ++void Simulator::DecodeRVBType() { ++ switch (instr_.InstructionBits() & kBTypeMask) { ++ case RO_BEQ: ++ if (rs1() == rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ case RO_BNE: ++ if (rs1() != rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ case RO_BLT: ++ if (rs1() < rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ case RO_BGE: ++ if (rs1() >= rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ case RO_BLTU: ++ if ((reg_t)rs1() < (reg_t)rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ case RO_BGEU: ++ if ((reg_t)rs1() >= (reg_t)rs2()) { ++ int64_t next_pc = get_pc() + boffset(); ++ set_pc(next_pc); ++ } ++ break; ++ default: ++ UNSUPPORTED(); ++ } ++} ++void Simulator::DecodeRVUType() { ++ // U Type doesn't have additoinal mask ++ switch (instr_.BaseOpcodeFieldRaw()) { ++ case RO_LUI: ++ set_rd(u_imm()); ++ break; ++ case RO_AUIPC: ++ set_rd(sext_xlen(u_imm() + get_pc())); ++ break; ++ default: ++ UNSUPPORTED(); ++ } ++} ++void Simulator::DecodeRVJType() { ++ // J Type doesn't have additional mask ++ switch (instr_.BaseOpcodeValue()) { ++ case RO_JAL: { ++ set_rd(get_pc() + kInstrSize); ++ int64_t next_pc = get_pc() + imm20J(); ++ set_pc(next_pc); ++ break; ++ } ++ default: ++ UNSUPPORTED(); ++ } ++} ++ ++// Executes the current instruction. ++void Simulator::InstructionDecode(Instruction* instr) { ++ if (v8::internal::FLAG_check_icache) { ++ CheckICache(i_cache(), instr); ++ } ++ pc_modified_ = false; ++ ++ v8::internal::EmbeddedVector buffer; ++ ++ if (::v8::internal::FLAG_trace_sim) { ++ SNPrintF(trace_buf_, " "); ++ disasm::NameConverter converter; ++ disasm::Disassembler dasm(converter); ++ // Use a reasonably large buffer. ++ dasm.InstructionDecode(buffer, reinterpret_cast(instr)); ++ ++ // PrintF("EXECUTING 0x%08" PRIxPTR " %-44s\n", ++ // reinterpret_cast(instr), buffer.begin()); ++ } ++ ++ instr_ = instr; ++ switch (instr_.InstructionType()) { ++ case Instruction::kRType: ++ DecodeRVRType(); ++ break; ++ case Instruction::kR4Type: ++ DecodeRVR4Type(); ++ break; ++ case Instruction::kIType: ++ DecodeRVIType(); ++ break; ++ case Instruction::kSType: ++ DecodeRVSType(); ++ break; ++ case Instruction::kBType: ++ DecodeRVBType(); ++ break; ++ case Instruction::kUType: ++ DecodeRVUType(); ++ break; ++ case Instruction::kJType: ++ DecodeRVJType(); ++ break; ++ default: ++ if (::v8::internal::FLAG_trace_sim) { ++ std::cout << "Unrecognized instruction [@pc=0x" << std::hex ++ << registers_[pc] << "]: 0x" << instr->InstructionBits() ++ << std::endl; ++ } ++ UNSUPPORTED(); ++ } ++ ++ if (::v8::internal::FLAG_trace_sim) { ++ PrintF(" 0x%012" PRIxPTR " %-44s %s\n", ++ reinterpret_cast(instr), buffer.begin(), ++ trace_buf_.begin()); ++ } ++ ++ if (!pc_modified_) { ++ set_register(pc, reinterpret_cast(instr) + kInstrSize); ++ } ++} ++ ++void Simulator::Execute() { ++ // Get the PC to simulate. Cannot use the accessor here as we need the ++ // raw PC value and not the one used as input to arithmetic instructions. ++ int64_t program_counter = get_pc(); ++ while (program_counter != end_sim_pc) { ++ Instruction* instr = reinterpret_cast(program_counter); ++ icount_++; ++ if (icount_ == static_cast(::v8::internal::FLAG_stop_sim_at)) { ++ RiscvDebugger dbg(this); ++ dbg.Debug(); ++ } else { ++ InstructionDecode(instr); ++ } ++ CheckBreakpoints(); ++ program_counter = get_pc(); ++ } ++} ++ ++void Simulator::CallInternal(Address entry) { ++ // Adjust JS-based stack limit to C-based stack limit. ++ isolate_->stack_guard()->AdjustStackLimitForSimulator(); ++ ++ // Prepare to execute the code at entry. ++ set_register(pc, static_cast(entry)); ++ // Put down marker for end of simulation. The simulator will stop simulation ++ // when the PC reaches this value. By saving the "end simulation" value into ++ // the LR the simulation stops when returning to this call point. ++ set_register(ra, end_sim_pc); ++ ++ // Remember the values of callee-saved registers. ++ // The code below assumes that r9 is not used as sb (static base) in ++ // simulator code and therefore is regarded as a callee-saved register. ++ int64_t s0_val = get_register(s0); ++ int64_t s1_val = get_register(s1); ++ int64_t s2_val = get_register(s2); ++ int64_t s3_val = get_register(s3); ++ int64_t s4_val = get_register(s4); ++ int64_t s5_val = get_register(s5); ++ int64_t s6_val = get_register(s6); ++ int64_t s7_val = get_register(s7); ++ int64_t gp_val = get_register(gp); ++ int64_t sp_val = get_register(sp); ++ int64_t fp_val = get_register(fp); ++ ++ // Set up the callee-saved registers with a known value. To be able to check ++ // that they are preserved properly across JS execution. ++ int64_t callee_saved_value = icount_; ++ set_register(s0, callee_saved_value); ++ set_register(s1, callee_saved_value); ++ set_register(s2, callee_saved_value); ++ set_register(s3, callee_saved_value); ++ set_register(s4, callee_saved_value); ++ set_register(s5, callee_saved_value); ++ set_register(s6, callee_saved_value); ++ set_register(s7, callee_saved_value); ++ set_register(gp, callee_saved_value); ++ set_register(fp, callee_saved_value); ++ ++ // Start the simulation. ++ Execute(); ++ ++ // Check that the callee-saved registers have been preserved. ++ CHECK_EQ(callee_saved_value, get_register(s0)); ++ CHECK_EQ(callee_saved_value, get_register(s1)); ++ CHECK_EQ(callee_saved_value, get_register(s2)); ++ CHECK_EQ(callee_saved_value, get_register(s3)); ++ CHECK_EQ(callee_saved_value, get_register(s4)); ++ CHECK_EQ(callee_saved_value, get_register(s5)); ++ CHECK_EQ(callee_saved_value, get_register(s6)); ++ CHECK_EQ(callee_saved_value, get_register(s7)); ++ CHECK_EQ(callee_saved_value, get_register(gp)); ++ CHECK_EQ(callee_saved_value, get_register(fp)); ++ ++ // Restore callee-saved registers with the original value. ++ set_register(s0, s0_val); ++ set_register(s1, s1_val); ++ set_register(s2, s2_val); ++ set_register(s3, s3_val); ++ set_register(s4, s4_val); ++ set_register(s5, s5_val); ++ set_register(s6, s6_val); ++ set_register(s7, s7_val); ++ set_register(gp, gp_val); ++ set_register(sp, sp_val); ++ set_register(fp, fp_val); ++} ++ ++intptr_t Simulator::CallImpl(Address entry, int argument_count, ++ const intptr_t* arguments) { ++ constexpr int kRegisterPassedArguments = 8; ++ // Set up arguments. ++ ++ // First four arguments passed in registers in both ABI's. ++ int reg_arg_count = std::min(kRegisterPassedArguments, argument_count); ++ if (reg_arg_count > 0) set_register(a0, arguments[0]); ++ if (reg_arg_count > 1) set_register(a1, arguments[1]); ++ if (reg_arg_count > 2) set_register(a2, arguments[2]); ++ if (reg_arg_count > 3) set_register(a3, arguments[3]); ++ ++ // Up to eight arguments passed in registers in N64 ABI. ++ // TODO(plind): N64 ABI calls these regs a4 - a7. Clarify this. ++ if (reg_arg_count > 4) set_register(a4, arguments[4]); ++ if (reg_arg_count > 5) set_register(a5, arguments[5]); ++ if (reg_arg_count > 6) set_register(a6, arguments[6]); ++ if (reg_arg_count > 7) set_register(a7, arguments[7]); ++ ++ if (::v8::internal::FLAG_trace_sim) { ++ std::cout << "CallImpl: reg_arg_count = " << reg_arg_count << std::hex ++ << " entry-pc (JSEntry) = 0x" << entry << " a0 (Isolate) = 0x" ++ << get_register(a0) << " a1 (orig_func/new_target) = 0x" ++ << get_register(a1) << " a2 (func/target) = 0x" ++ << get_register(a2) << " a3 (receiver) = 0x" << get_register(a3) ++ << " a4 (argc) = 0x" << get_register(a4) << " a5 (argv) = 0x" ++ << get_register(a5) << std::endl; ++ } ++ ++ // Remaining arguments passed on stack. ++ int64_t original_stack = get_register(sp); ++ // Compute position of stack on entry to generated code. ++ int stack_args_count = argument_count - reg_arg_count; ++ int stack_args_size = stack_args_count * sizeof(*arguments) + kCArgsSlotsSize; ++ int64_t entry_stack = original_stack - stack_args_size; ++ ++ if (base::OS::ActivationFrameAlignment() != 0) { ++ entry_stack &= -base::OS::ActivationFrameAlignment(); ++ } ++ // Store remaining arguments on stack, from low to high memory. ++ intptr_t* stack_argument = reinterpret_cast(entry_stack); ++ memcpy(stack_argument + kCArgSlotCount, arguments + reg_arg_count, ++ stack_args_count * sizeof(*arguments)); ++ set_register(sp, entry_stack); ++ ++ CallInternal(entry); ++ ++ // Pop stack passed arguments. ++ CHECK_EQ(entry_stack, get_register(sp)); ++ set_register(sp, original_stack); ++ ++ // return get_register(a0); ++ // RISCV uses a0 to return result ++ return get_register(a0); ++} ++ ++double Simulator::CallFP(Address entry, double d0, double d1) { ++ set_fpu_register_double(fa0, d0); ++ set_fpu_register_double(fa1, d1); ++ CallInternal(entry); ++ return get_fpu_register_double(fa0); ++} ++ ++uintptr_t Simulator::PushAddress(uintptr_t address) { ++ int64_t new_sp = get_register(sp) - sizeof(uintptr_t); ++ uintptr_t* stack_slot = reinterpret_cast(new_sp); ++ *stack_slot = address; ++ set_register(sp, new_sp); ++ return new_sp; ++} ++ ++uintptr_t Simulator::PopAddress() { ++ int64_t current_sp = get_register(sp); ++ uintptr_t* stack_slot = reinterpret_cast(current_sp); ++ uintptr_t address = *stack_slot; ++ set_register(sp, current_sp + sizeof(uintptr_t)); ++ return address; ++} ++ ++Simulator::LocalMonitor::LocalMonitor() ++ : access_state_(MonitorAccess::Open), ++ tagged_addr_(0), ++ size_(TransactionSize::None) {} ++ ++void Simulator::LocalMonitor::Clear() { ++ access_state_ = MonitorAccess::Open; ++ tagged_addr_ = 0; ++ size_ = TransactionSize::None; ++} ++ ++void Simulator::LocalMonitor::NotifyLoad() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non linked load could clear the local monitor. As a result, it's ++ // most strict to unconditionally clear the local monitor on load. ++ Clear(); ++ } ++} ++ ++void Simulator::LocalMonitor::NotifyLoadLinked(uintptr_t addr, ++ TransactionSize size) { ++ access_state_ = MonitorAccess::RMW; ++ tagged_addr_ = addr; ++ size_ = size; ++} ++ ++void Simulator::LocalMonitor::NotifyStore() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non exclusive store could clear the local monitor. As a result, it's ++ // most strict to unconditionally clear the local monitor on store. ++ Clear(); ++ } ++} ++ ++bool Simulator::LocalMonitor::NotifyStoreConditional(uintptr_t addr, ++ TransactionSize size) { ++ if (access_state_ == MonitorAccess::RMW) { ++ if (addr == tagged_addr_ && size_ == size) { ++ Clear(); ++ return true; ++ } else { ++ return false; ++ } ++ } else { ++ DCHECK(access_state_ == MonitorAccess::Open); ++ return false; ++ } ++} ++ ++Simulator::GlobalMonitor::LinkedAddress::LinkedAddress() ++ : access_state_(MonitorAccess::Open), ++ tagged_addr_(0), ++ next_(nullptr), ++ prev_(nullptr), ++ failure_counter_(0) {} ++ ++void Simulator::GlobalMonitor::LinkedAddress::Clear_Locked() { ++ access_state_ = MonitorAccess::Open; ++ tagged_addr_ = 0; ++} ++ ++void Simulator::GlobalMonitor::LinkedAddress::NotifyLoadLinked_Locked( ++ uintptr_t addr) { ++ access_state_ = MonitorAccess::RMW; ++ tagged_addr_ = addr; ++} ++ ++void Simulator::GlobalMonitor::LinkedAddress::NotifyStore_Locked() { ++ if (access_state_ == MonitorAccess::RMW) { ++ // A non exclusive store could clear the global monitor. As a result, it's ++ // most strict to unconditionally clear global monitors on store. ++ Clear_Locked(); ++ } ++} ++ ++bool Simulator::GlobalMonitor::LinkedAddress::NotifyStoreConditional_Locked( ++ uintptr_t addr, bool is_requesting_thread) { ++ if (access_state_ == MonitorAccess::RMW) { ++ if (is_requesting_thread) { ++ if (addr == tagged_addr_) { ++ Clear_Locked(); ++ // Introduce occasional sc/scd failures. This is to simulate the ++ // behavior of hardware, which can randomly fail due to background ++ // cache evictions. ++ if (failure_counter_++ >= kMaxFailureCounter) { ++ failure_counter_ = 0; ++ return false; ++ } else { ++ return true; ++ } ++ } ++ } else if ((addr & kExclusiveTaggedAddrMask) == ++ (tagged_addr_ & kExclusiveTaggedAddrMask)) { ++ // Check the masked addresses when responding to a successful lock by ++ // another thread so the implementation is more conservative (i.e. the ++ // granularity of locking is as large as possible.) ++ Clear_Locked(); ++ return false; ++ } ++ } ++ return false; ++} ++ ++void Simulator::GlobalMonitor::NotifyLoadLinked_Locked( ++ uintptr_t addr, LinkedAddress* linked_address) { ++ linked_address->NotifyLoadLinked_Locked(addr); ++ PrependProcessor_Locked(linked_address); ++} ++ ++void Simulator::GlobalMonitor::NotifyStore_Locked( ++ LinkedAddress* linked_address) { ++ // Notify each thread of the store operation. ++ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { ++ iter->NotifyStore_Locked(); ++ } ++} ++ ++bool Simulator::GlobalMonitor::NotifyStoreConditional_Locked( ++ uintptr_t addr, LinkedAddress* linked_address) { ++ DCHECK(IsProcessorInLinkedList_Locked(linked_address)); ++ if (linked_address->NotifyStoreConditional_Locked(addr, true)) { ++ // Notify the other processors that this StoreConditional succeeded. ++ for (LinkedAddress* iter = head_; iter; iter = iter->next_) { ++ if (iter != linked_address) { ++ iter->NotifyStoreConditional_Locked(addr, false); ++ } ++ } ++ return true; ++ } else { ++ return false; ++ } ++} ++ ++bool Simulator::GlobalMonitor::IsProcessorInLinkedList_Locked( ++ LinkedAddress* linked_address) const { ++ return head_ == linked_address || linked_address->next_ || ++ linked_address->prev_; ++} ++ ++void Simulator::GlobalMonitor::PrependProcessor_Locked( ++ LinkedAddress* linked_address) { ++ if (IsProcessorInLinkedList_Locked(linked_address)) { ++ return; ++ } ++ ++ if (head_) { ++ head_->prev_ = linked_address; ++ } ++ linked_address->prev_ = nullptr; ++ linked_address->next_ = head_; ++ head_ = linked_address; ++} ++ ++void Simulator::GlobalMonitor::RemoveLinkedAddress( ++ LinkedAddress* linked_address) { ++ base::MutexGuard lock_guard(&mutex); ++ if (!IsProcessorInLinkedList_Locked(linked_address)) { ++ return; ++ } ++ ++ if (linked_address->prev_) { ++ linked_address->prev_->next_ = linked_address->next_; ++ } else { ++ head_ = linked_address->next_; ++ } ++ if (linked_address->next_) { ++ linked_address->next_->prev_ = linked_address->prev_; ++ } ++ linked_address->prev_ = nullptr; ++ linked_address->next_ = nullptr; ++} ++ ++#undef SScanF ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // USE_SIMULATOR +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/execution/riscv64/simulator-riscv64.h +@@ -0,0 +1,764 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Copyright(c) 2010 - 2017, ++// The Regents of the University of California(Regents).All Rights Reserved. ++// ++// Redistribution and use in source and binary forms, ++// with or without modification, ++// are permitted provided that the following ++// conditions are met : 1. Redistributions of source code must retain the ++// above copyright notice, this list of conditions and the following ++// disclaimer.2. Redistributions in binary form must reproduce the above ++// copyright notice, this list of conditions and the following disclaimer in ++// the ++// documentation and / ++// or ++// other materials provided with the distribution.3. Neither the name of ++// the Regents nor the names of its contributors may be used to endorse ++// or ++// promote products derived from ++// this software without specific prior written permission. ++// ++// IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, ++// INDIRECT, SPECIAL, ++// INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ++// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, ++// EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++// ++// REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, ++// INCLUDING, BUT NOT LIMITED TO, ++// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ++// PARTICULAR PURPOSE.THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, ++// IF ANY, ++// PROVIDED HEREUNDER IS PROVIDED ++// "AS IS".REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, ++// SUPPORT, UPDATES, ENHANCEMENTS, ++// OR MODIFICATIONS. ++ ++// The original source code covered by the above license above has been ++// modified significantly by the v8 project authors. ++ ++// Declares a Simulator for RISC-V instructions if we are not generating a ++// native RISC-V binary. This Simulator allows us to run and debug RISC-V code ++// generation on regular desktop machines. V8 calls into generated code via the ++// GeneratedCode wrapper, which will start execution in the Simulator or ++// forwards to the real entry on a RISC-V HW platform. ++ ++#ifndef V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ ++#define V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ ++ ++// globals.h defines USE_SIMULATOR. ++#include "src/common/globals.h" ++ ++template ++int Compare(const T& a, const T& b) { ++ if (a == b) ++ return 0; ++ else if (a < b) ++ return -1; ++ else ++ return 1; ++} ++ ++// Returns the negative absolute value of its argument. ++template ::value>::type> ++T Nabs(T a) { ++ return a < 0 ? a : -a; ++} ++ ++#if defined(USE_SIMULATOR) ++// Running with a simulator. ++ ++#include "src/base/hashmap.h" ++#include "src/codegen/assembler.h" ++#include "src/codegen/riscv64/constants-riscv64.h" ++#include "src/execution/simulator-base.h" ++#include "src/utils/allocation.h" ++ ++namespace v8 { ++namespace internal { ++ ++// ----------------------------------------------------------------------------- ++// Utility types and functions for RISCV ++// TODO: Add Spike License here ++#ifdef V8_TARGET_ARCH_32_BIT ++using sreg_t = int32_t; ++using reg_t = uint32_t; ++#define xlen 32 ++#elif V8_TARGET_ARCH_64_BIT ++using sreg_t = int64_t; ++using reg_t = uint64_t; ++#define xlen 64 ++#else ++#error "Cannot detect Riscv's bitwidth" ++#endif ++ ++#define sext32(x) ((sreg_t)(int32_t)(x)) ++#define zext32(x) ((reg_t)(uint32_t)(x)) ++#define sext_xlen(x) (((sreg_t)(x) << (64 - xlen)) >> (64 - xlen)) ++#define zext_xlen(x) (((reg_t)(x) << (64 - xlen)) >> (64 - xlen)) ++ ++#define BIT(n) (0x1LL << n) ++#define QUIET_BIT_S(nan) (bit_cast(nan) & BIT(22)) ++#define QUIET_BIT_D(nan) (bit_cast(nan) & BIT(51)) ++static inline bool isSnan(float fp) { return !QUIET_BIT_S(fp); } ++static inline bool isSnan(double fp) { return !QUIET_BIT_D(fp); } ++#undef QUIET_BIT_S ++#undef QUIET_BIT_D ++ ++inline uint64_t mulhu(uint64_t a, uint64_t b) { ++ __uint128_t full_result = ((__uint128_t)a) * ((__uint128_t)b); ++ return full_result >> 64; ++} ++ ++inline int64_t mulh(int64_t a, int64_t b) { ++ __int128_t full_result = ((__int128_t)a) * ((__int128_t)b); ++ return full_result >> 64; ++} ++ ++inline int64_t mulhsu(int64_t a, uint64_t b) { ++ __int128_t full_result = ((__int128_t)a) * ((__uint128_t)b); ++ return full_result >> 64; ++} ++ ++// Floating point helpers ++#define F32_SIGN ((uint32_t)1 << 31) ++union u32_f32 { ++ uint32_t u; ++ float f; ++}; ++inline float fsgnj32(float rs1, float rs2, bool n, bool x) { ++ u32_f32 a = {.f = rs1}, b = {.f = rs2}; ++ u32_f32 res; ++ res.u = ++ (a.u & ~F32_SIGN) | ((((x) ? a.u : (n) ? F32_SIGN : 0) ^ b.u) & F32_SIGN); ++ return res.f; ++} ++#define F64_SIGN ((uint64_t)1 << 63) ++union u64_f64 { ++ uint64_t u; ++ double d; ++}; ++inline double fsgnj64(double rs1, double rs2, bool n, bool x) { ++ u64_f64 a = {.d = rs1}, b = {.d = rs2}; ++ u64_f64 res; ++ res.u = ++ (a.u & ~F64_SIGN) | ((((x) ? a.u : (n) ? F64_SIGN : 0) ^ b.u) & F64_SIGN); ++ return res.d; ++} ++ ++inline bool is_boxed_float(int64_t v) { ++ return (uint32_t)((v >> 32) + 1) == 0; ++} ++inline int64_t box_float(float v) { ++ return (0xFFFFFFFF00000000 | bit_cast(v)); ++} ++ ++// ----------------------------------------------------------------------------- ++// Utility functions ++ ++class CachePage { ++ public: ++ static const int LINE_VALID = 0; ++ static const int LINE_INVALID = 1; ++ ++ static const int kPageShift = 12; ++ static const int kPageSize = 1 << kPageShift; ++ static const int kPageMask = kPageSize - 1; ++ static const int kLineShift = 2; // The cache line is only 4 bytes right now. ++ static const int kLineLength = 1 << kLineShift; ++ static const int kLineMask = kLineLength - 1; ++ ++ CachePage() { memset(&validity_map_, LINE_INVALID, sizeof(validity_map_)); } ++ ++ char* ValidityByte(int offset) { ++ return &validity_map_[offset >> kLineShift]; ++ } ++ ++ char* CachedData(int offset) { return &data_[offset]; } ++ ++ private: ++ char data_[kPageSize]; // The cached data. ++ static const int kValidityMapSize = kPageSize >> kLineShift; ++ char validity_map_[kValidityMapSize]; // One byte per line. ++}; ++ ++class SimInstructionBase : public InstructionBase { ++ public: ++ Type InstructionType() const { return type_; } ++ inline Instruction* instr() const { return instr_; } ++ inline int32_t operand() const { return operand_; } ++ ++ protected: ++ SimInstructionBase() : operand_(-1), instr_(nullptr), type_(kUnsupported) {} ++ explicit SimInstructionBase(Instruction* instr) {} ++ ++ int32_t operand_; ++ Instruction* instr_; ++ Type type_; ++ ++ private: ++ DISALLOW_ASSIGN(SimInstructionBase); ++}; ++ ++class SimInstruction : public InstructionGetters { ++ public: ++ SimInstruction() {} ++ ++ explicit SimInstruction(Instruction* instr) { *this = instr; } ++ ++ SimInstruction& operator=(Instruction* instr) { ++ operand_ = *reinterpret_cast(instr); ++ instr_ = instr; ++ type_ = InstructionBase::InstructionType(); ++ DCHECK(reinterpret_cast(&operand_) == this); ++ return *this; ++ } ++}; ++ ++class Simulator : public SimulatorBase { ++ public: ++ friend class RiscvDebugger; ++ ++ // Registers are declared in order. See SMRL chapter 2. ++ enum Register { ++ no_reg = -1, ++ zero_reg = 0, ++ ra, ++ sp, ++ gp, ++ tp, ++ t0, ++ t1, ++ t2, ++ s0, ++ s1, ++ a0, ++ a1, ++ a2, ++ a3, ++ a4, ++ a5, ++ a6, ++ a7, ++ s2, ++ s3, ++ s4, ++ s5, ++ s6, ++ s7, ++ s8, ++ s9, ++ s10, ++ s11, ++ t3, ++ t4, ++ t5, ++ t6, ++ pc, // pc must be the last register. ++ kNumSimuRegisters, ++ // aliases ++ fp = s0 ++ }; ++ ++ // Coprocessor registers. ++ // Generated code will always use doubles. So we will only use even registers. ++ enum FPURegister { ++ ft0, ++ ft1, ++ ft2, ++ ft3, ++ ft4, ++ ft5, ++ ft6, ++ ft7, ++ fs0, ++ fs1, ++ fa0, ++ fa1, ++ fa2, ++ fa3, ++ fa4, ++ fa5, ++ fa6, ++ fa7, ++ fs2, ++ fs3, ++ fs4, ++ fs5, ++ fs6, ++ fs7, ++ fs8, ++ fs9, ++ fs10, ++ fs11, ++ ft8, ++ ft9, ++ ft10, ++ ft11, ++ kNumFPURegisters ++ }; ++ ++ explicit Simulator(Isolate* isolate); ++ ~Simulator(); ++ ++ // The currently executing Simulator instance. Potentially there can be one ++ // for each native thread. ++ V8_EXPORT_PRIVATE static Simulator* current(v8::internal::Isolate* isolate); ++ ++ // Accessors for register state. Reading the pc value adheres to the RISC-V ++ // architecture specification and is off by a 8 from the currently executing ++ // instruction. ++ void set_register(int reg, int64_t value); ++ void set_register_word(int reg, int32_t value); ++ void set_dw_register(int dreg, const int* dbl); ++ int64_t get_register(int reg) const; ++ double get_double_from_register_pair(int reg); ++ ++ // Same for FPURegisters. ++ void set_fpu_register(int fpureg, int64_t value); ++ void set_fpu_register_word(int fpureg, int32_t value); ++ void set_fpu_register_hi_word(int fpureg, int32_t value); ++ void set_fpu_register_float(int fpureg, float value); ++ void set_fpu_register_double(int fpureg, double value); ++ ++ int64_t get_fpu_register(int fpureg) const; ++ int32_t get_fpu_register_word(int fpureg) const; ++ int32_t get_fpu_register_signed_word(int fpureg) const; ++ int32_t get_fpu_register_hi_word(int fpureg) const; ++ float get_fpu_register_float(int fpureg) const; ++ double get_fpu_register_double(int fpureg) const; ++ ++ // RV CSR manipulation ++ uint32_t read_csr_value(uint32_t csr); ++ void write_csr_value(uint32_t csr, uint64_t value); ++ void set_csr_bits(uint32_t csr, uint64_t flags); ++ void clear_csr_bits(uint32_t csr, uint64_t flags); ++ ++ void set_fflags(uint32_t flags) { set_csr_bits(csr_fflags, flags); } ++ void clear_fflags(int32_t flags) { clear_csr_bits(csr_fflags, flags); } ++ ++ inline uint32_t get_dynamic_rounding_mode(); ++ inline bool test_fflags_bits(uint32_t mask); ++ ++ float RoundF2FHelper(float input_val, int rmode); ++ double RoundF2FHelper(double input_val, int rmode); ++ template ++ I_TYPE RoundF2IHelper(F_TYPE original, int rmode); ++ ++ template ++ T FMaxMinHelper(T a, T b, MaxMinKind kind); ++ ++ template ++ bool CompareFHelper(T input1, T input2, FPUCondition cc); ++ ++ // Special case of set_register and get_register to access the raw PC value. ++ void set_pc(int64_t value); ++ int64_t get_pc() const; ++ ++ Address get_sp() const { return static_cast
(get_register(sp)); } ++ ++ // Accessor to the internal simulator stack area. ++ uintptr_t StackLimit(uintptr_t c_limit) const; ++ ++ // Executes RISC-V instructions until the PC reaches end_sim_pc. ++ void Execute(); ++ ++ template ++ Return Call(Address entry, Args... args) { ++ return VariadicCall(this, &Simulator::CallImpl, entry, args...); ++ } ++ ++ // Alternative: call a 2-argument double function. ++ double CallFP(Address entry, double d0, double d1); ++ ++ // Push an address onto the JS stack. ++ uintptr_t PushAddress(uintptr_t address); ++ ++ // Pop an address from the JS stack. ++ uintptr_t PopAddress(); ++ ++ // Debugger input. ++ void set_last_debugger_input(char* input); ++ char* last_debugger_input() { return last_debugger_input_; } ++ ++ // Redirection support. ++ static void SetRedirectInstruction(Instruction* instruction); ++ ++ // ICache checking. ++ static bool ICacheMatch(void* one, void* two); ++ static void FlushICache(base::CustomMatcherHashMap* i_cache, void* start, ++ size_t size); ++ ++ // Returns true if pc register contains one of the 'special_values' defined ++ // below (bad_ra, end_sim_pc). ++ bool has_bad_pc() const; ++ ++ private: ++ enum special_values { ++ // Known bad pc value to ensure that the simulator does not execute ++ // without being properly setup. ++ bad_ra = -1, ++ // A pc value used to signal the simulator to stop execution. Generally ++ // the ra is set to this value on transition from native C code to ++ // simulated execution, so that the simulator can "return" to the native ++ // C code. ++ end_sim_pc = -2, ++ // Unpredictable value. ++ Unpredictable = 0xbadbeaf ++ }; ++ ++ V8_EXPORT_PRIVATE intptr_t CallImpl(Address entry, int argument_count, ++ const intptr_t* arguments); ++ ++ // Unsupported instructions use Format to print an error and stop execution. ++ void Format(Instruction* instr, const char* format); ++ ++ // Helpers for data value tracing. ++ enum TraceType { ++ BYTE, ++ HALF, ++ WORD, ++ DWORD, ++ FLOAT, ++ DOUBLE, ++ // FLOAT_DOUBLE, ++ // WORD_DWORD ++ }; ++ ++ // RISCV Memory read/write methods ++ template ++ T ReadMem(int64_t addr, Instruction* instr); ++ template ++ void WriteMem(int64_t addr, T value, Instruction* instr); ++ template ++ T amo(int64_t addr, OP f, Instruction* instr, TraceType t) { ++ auto lhs = ReadMem(addr, instr); ++ // FIXME: trace memory read for AMO ++ WriteMem(addr, (T)f(lhs), instr); ++ return lhs; ++ } ++ ++ // Helper for debugging memory access. ++ inline void DieOrDebug(); ++ ++ void TraceRegWr(int64_t value, TraceType t = DWORD); ++ void TraceMemWr(int64_t addr, int64_t value, TraceType t); ++ template ++ void TraceMemRd(int64_t addr, T value, int64_t reg_value); ++ template ++ void TraceMemWr(int64_t addr, T value); ++ ++ SimInstruction instr_; ++ ++ // RISCV utlity API to access register value ++ inline int32_t rs1_reg() const { return instr_.Rs1Value(); } ++ inline int64_t rs1() const { return get_register(rs1_reg()); } ++ inline float frs1() const { return get_fpu_register_float(rs1_reg()); } ++ inline double drs1() const { return get_fpu_register_double(rs1_reg()); } ++ inline int32_t rs2_reg() const { return instr_.Rs2Value(); } ++ inline int64_t rs2() const { return get_register(rs2_reg()); } ++ inline float frs2() const { return get_fpu_register_float(rs2_reg()); } ++ inline double drs2() const { return get_fpu_register_double(rs2_reg()); } ++ inline int32_t rs3_reg() const { return instr_.Rs3Value(); } ++ inline int64_t rs3() const { return get_register(rs3_reg()); } ++ inline float frs3() const { return get_fpu_register_float(rs3_reg()); } ++ inline double drs3() const { return get_fpu_register_double(rs3_reg()); } ++ inline int32_t rd_reg() const { return instr_.RdValue(); } ++ inline int32_t frd_reg() const { return instr_.RdValue(); } ++ inline int16_t boffset() const { return instr_.BranchOffset(); } ++ inline int16_t imm12() const { return instr_.Imm12Value(); } ++ inline int32_t imm20J() const { return instr_.Imm20JValue(); } ++ inline int32_t imm5CSR() const { return instr_.Rs1Value(); } ++ inline int16_t csr_reg() const { return instr_.CsrValue(); } ++ ++ inline void set_rd(int64_t value, bool trace = true) { ++ set_register(rd_reg(), value); ++ if (trace) TraceRegWr(get_register(rd_reg()), DWORD); ++ } ++ inline void set_frd(float value, bool trace = true) { ++ set_fpu_register_float(rd_reg(), value); ++ if (trace) TraceRegWr(get_fpu_register_word(rd_reg()), FLOAT); ++ } ++ inline void set_drd(double value, bool trace = true) { ++ set_fpu_register_double(rd_reg(), value); ++ if (trace) TraceRegWr(get_fpu_register(rd_reg()), DOUBLE); ++ } ++ inline int16_t shamt() const { return (imm12() & 0x3F); } ++ inline int16_t shamt32() const { return (imm12() & 0x1F); } ++ inline int32_t s_imm12() const { return instr_.StoreOffset(); } ++ inline int32_t u_imm() const { return instr_.Imm20UValue() << 12; } ++ inline void require(bool check) { ++ if (!check) { ++ SignalException(kIllegalInstruction); ++ } ++ } ++ ++ template ++ inline T CanonicalizeFPUOp3(Func fn) { ++ DCHECK(std::is_floating_point::value); ++ T src1 = std::is_same::value ? frs1() : drs1(); ++ T src2 = std::is_same::value ? frs2() : drs2(); ++ T src3 = std::is_same::value ? frs3() : drs3(); ++ auto alu_out = fn(src1, src2, src3); ++ // if any input or result is NaN, the result is quiet_NaN ++ if (std::isnan(alu_out) || std::isnan(src1) || std::isnan(src2) || ++ std::isnan(src3)) { ++ // signaling_nan sets kInvalidOperation bit ++ if (isSnan(alu_out) || isSnan(src1) || isSnan(src2) || isSnan(src3)) ++ set_fflags(kInvalidOperation); ++ alu_out = std::numeric_limits::quiet_NaN(); ++ } ++ return alu_out; ++ } ++ ++ template ++ inline T CanonicalizeFPUOp2(Func fn) { ++ DCHECK(std::is_floating_point::value); ++ T src1 = std::is_same::value ? frs1() : drs1(); ++ T src2 = std::is_same::value ? frs2() : drs2(); ++ auto alu_out = fn(src1, src2); ++ // if any input or result is NaN, the result is quiet_NaN ++ if (std::isnan(alu_out) || std::isnan(src1) || std::isnan(src2)) { ++ // signaling_nan sets kInvalidOperation bit ++ if (isSnan(alu_out) || isSnan(src1) || isSnan(src2)) ++ set_fflags(kInvalidOperation); ++ alu_out = std::numeric_limits::quiet_NaN(); ++ } ++ return alu_out; ++ } ++ ++ template ++ inline T CanonicalizeFPUOp1(Func fn) { ++ DCHECK(std::is_floating_point::value); ++ T src1 = std::is_same::value ? frs1() : drs1(); ++ auto alu_out = fn(src1); ++ // if any input or result is NaN, the result is quiet_NaN ++ if (std::isnan(alu_out) || std::isnan(src1)) { ++ // signaling_nan sets kInvalidOperation bit ++ if (isSnan(alu_out) || isSnan(src1)) set_fflags(kInvalidOperation); ++ alu_out = std::numeric_limits::quiet_NaN(); ++ } ++ return alu_out; ++ } ++ ++ template ++ inline float CanonicalizeDoubleToFloatOperation(Func fn) { ++ float alu_out = fn(drs1()); ++ if (std::isnan(alu_out) || std::isnan(drs1())) ++ alu_out = std::numeric_limits::quiet_NaN(); ++ return alu_out; ++ } ++ ++ template ++ inline float CanonicalizeFloatToDoubleOperation(Func fn) { ++ double alu_out = fn(frs1()); ++ if (std::isnan(alu_out) || std::isnan(frs1())) ++ alu_out = std::numeric_limits::quiet_NaN(); ++ return alu_out; ++ } ++ ++ // RISCV decoding routine ++ void DecodeRVRType(); ++ void DecodeRVR4Type(); ++ void DecodeRVRFPType(); // Special routine for R/OP_FP type ++ void DecodeRVRAType(); // Special routine for R/AMO type ++ void DecodeRVIType(); ++ void DecodeRVSType(); ++ void DecodeRVBType(); ++ void DecodeRVUType(); ++ void DecodeRVJType(); ++ ++ // Used for breakpoints and traps. ++ void SoftwareInterrupt(); ++ ++ // Debug helpers ++ ++ // Simulator breakpoints. ++ struct Breakpoint { ++ Instruction* location; ++ bool enabled; ++ bool is_tbreak; ++ }; ++ std::vector breakpoints_; ++ void SetBreakpoint(Instruction* breakpoint, bool is_tbreak); ++ void ListBreakpoints(); ++ void CheckBreakpoints(); ++ ++ // Stop helper functions. ++ bool IsWatchpoint(uint64_t code); ++ void PrintWatchpoint(uint64_t code); ++ void HandleStop(uint64_t code); ++ bool IsStopInstruction(Instruction* instr); ++ bool IsEnabledStop(uint64_t code); ++ void EnableStop(uint64_t code); ++ void DisableStop(uint64_t code); ++ void IncreaseStopCounter(uint64_t code); ++ void PrintStopInfo(uint64_t code); ++ ++ // Executes one instruction. ++ void InstructionDecode(Instruction* instr); ++ ++ // ICache. ++ static void CheckICache(base::CustomMatcherHashMap* i_cache, ++ Instruction* instr); ++ static void FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, ++ size_t size); ++ static CachePage* GetCachePage(base::CustomMatcherHashMap* i_cache, ++ void* page); ++ ++ enum Exception { ++ none, ++ kIntegerOverflow, ++ kIntegerUnderflow, ++ kDivideByZero, ++ kNumExceptions, ++ // RISCV illegual instruction exception ++ kIllegalInstruction, ++ }; ++ ++ // Exceptions. ++ void SignalException(Exception e); ++ ++ // Handle arguments and return value for runtime FP functions. ++ void GetFpArgs(double* x, double* y, int32_t* z); ++ void SetFpResult(const double& result); ++ ++ void CallInternal(Address entry); ++ ++ // Architecture state. ++ // Registers. ++ int64_t registers_[kNumSimuRegisters]; ++ // Coprocessor Registers. ++ int64_t FPUregisters_[kNumFPURegisters]; ++ // Floating-point control and status register. ++ uint32_t FCSR_; ++ ++ // Simulator support. ++ // Allocate 1MB for stack. ++ size_t stack_size_; ++ char* stack_; ++ bool pc_modified_; ++ int64_t icount_; ++ int break_count_; ++ EmbeddedVector trace_buf_; ++ ++ // Debugger input. ++ char* last_debugger_input_; ++ ++ v8::internal::Isolate* isolate_; ++ ++ // Stop is disabled if bit 31 is set. ++ static const uint32_t kStopDisabledBit = 1 << 31; ++ ++ // A stop is enabled, meaning the simulator will stop when meeting the ++ // instruction, if bit 31 of watched_stops_[code].count is unset. ++ // The value watched_stops_[code].count & ~(1 << 31) indicates how many times ++ // the breakpoint was hit or gone through. ++ struct StopCountAndDesc { ++ uint32_t count; ++ char* desc; ++ }; ++ StopCountAndDesc watched_stops_[kMaxStopCode + 1]; ++ ++ // Synchronization primitives. ++ enum class MonitorAccess { ++ Open, ++ RMW, ++ }; ++ ++ enum class TransactionSize { ++ None = 0, ++ Word = 4, ++ DoubleWord = 8, ++ }; ++ ++ // The least-significant bits of the address are ignored. The number of bits ++ // is implementation-defined, between 3 and minimum page size. ++ static const uintptr_t kExclusiveTaggedAddrMask = ~((1 << 3) - 1); ++ ++ class LocalMonitor { ++ public: ++ LocalMonitor(); ++ ++ // These functions manage the state machine for the local monitor, but do ++ // not actually perform loads and stores. NotifyStoreConditional only ++ // returns true if the store conditional is allowed; the global monitor will ++ // still have to be checked to see whether the memory should be updated. ++ void NotifyLoad(); ++ void NotifyLoadLinked(uintptr_t addr, TransactionSize size); ++ void NotifyStore(); ++ bool NotifyStoreConditional(uintptr_t addr, TransactionSize size); ++ ++ private: ++ void Clear(); ++ ++ MonitorAccess access_state_; ++ uintptr_t tagged_addr_; ++ TransactionSize size_; ++ }; ++ ++ class GlobalMonitor { ++ public: ++ class LinkedAddress { ++ public: ++ LinkedAddress(); ++ ++ private: ++ friend class GlobalMonitor; ++ // These functions manage the state machine for the global monitor, but do ++ // not actually perform loads and stores. ++ void Clear_Locked(); ++ void NotifyLoadLinked_Locked(uintptr_t addr); ++ void NotifyStore_Locked(); ++ bool NotifyStoreConditional_Locked(uintptr_t addr, ++ bool is_requesting_thread); ++ ++ MonitorAccess access_state_; ++ uintptr_t tagged_addr_; ++ LinkedAddress* next_; ++ LinkedAddress* prev_; ++ // A scd can fail due to background cache evictions. Rather than ++ // simulating this, we'll just occasionally introduce cases where an ++ // store conditional fails. This will happen once after every ++ // kMaxFailureCounter exclusive stores. ++ static const int kMaxFailureCounter = 5; ++ int failure_counter_; ++ }; ++ ++ // Exposed so it can be accessed by Simulator::{Read,Write}Ex*. ++ base::Mutex mutex; ++ ++ void NotifyLoadLinked_Locked(uintptr_t addr, LinkedAddress* linked_address); ++ void NotifyStore_Locked(LinkedAddress* linked_address); ++ bool NotifyStoreConditional_Locked(uintptr_t addr, ++ LinkedAddress* linked_address); ++ ++ // Called when the simulator is destroyed. ++ void RemoveLinkedAddress(LinkedAddress* linked_address); ++ ++ static GlobalMonitor* Get(); ++ ++ private: ++ // Private constructor. Call {GlobalMonitor::Get()} to get the singleton. ++ GlobalMonitor() = default; ++ friend class base::LeakyObject; ++ ++ bool IsProcessorInLinkedList_Locked(LinkedAddress* linked_address) const; ++ void PrependProcessor_Locked(LinkedAddress* linked_address); ++ ++ LinkedAddress* head_ = nullptr; ++ }; ++ ++ LocalMonitor local_monitor_; ++ GlobalMonitor::LinkedAddress global_monitor_thread_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // defined(USE_SIMULATOR) ++#endif // V8_EXECUTION_RISCV_SIMULATOR_RISCV_H_ +--- a/src/3rdparty/chromium/v8/src/execution/simulator-base.h ++++ b/src/3rdparty/chromium/v8/src/execution/simulator-base.h +@@ -89,9 +89,10 @@ + static typename std::enable_if::value, intptr_t>::type + ConvertArg(T arg) { + static_assert(sizeof(T) <= sizeof(intptr_t), "type bigger than ptrsize"); +-#if V8_TARGET_ARCH_MIPS64 +- // The MIPS64 calling convention is to sign extend all values, even unsigned +- // ones. ++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 ++ // The MIPS64 and RISCV64 calling convention is to sign extend all values, ++ // even unsigned ones. ++ // FIXME (RISCV): what about RISCV calling contention? + using signed_t = typename std::make_signed::type; + return static_cast(static_cast(arg)); + #else +@@ -125,6 +126,7 @@ + // - V8_TARGET_ARCH_PPC: svc (Supervisor Call) + // - V8_TARGET_ARCH_PPC64: svc (Supervisor Call) + // - V8_TARGET_ARCH_S390: svc (Supervisor Call) ++// - V8_TARGET_ARCH_RISCV64: ecall (Supervisor Call) + class Redirection { + public: + Redirection(Address external_function, ExternalReference::Type type); +--- a/src/3rdparty/chromium/v8/src/execution/simulator.h ++++ b/src/3rdparty/chromium/v8/src/execution/simulator.h +@@ -26,6 +26,10 @@ + #include "src/execution/mips64/simulator-mips64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/execution/s390/simulator-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/execution/riscv64/simulator-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/execution/riscv/simulator-riscv.h" + #else + #error Unsupported target architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/flags/flag-definitions.h ++++ b/src/3rdparty/chromium/v8/src/flags/flag-definitions.h +@@ -1182,6 +1182,7 @@ + DEFINE_STRING(sim_arm64_optional_features, "none", + "enable optional features on the simulator for testing: none or " + "all") ++DEFINE_BOOL(debug_riscv, false, "enable debug prints") + + // Controlling source positions for Torque/CSA code. + DEFINE_BOOL(enable_source_at_csa_bind, false, +@@ -1372,7 +1373,7 @@ + "Check icache flushes in ARM and MIPS simulator") + DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions") + #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) || \ +- defined(V8_TARGET_ARCH_PPC64) ++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_RISCV64) + DEFINE_INT(sim_stack_alignment, 16, + "Stack alignment in bytes in simulator. This must be a power of two " + "and it must be at least 16. 16 is default.") +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/heap/base/asm/riscv64/push_registers_asm.cc +@@ -0,0 +1,47 @@ ++// Copyright 2020 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Push all callee-saved registers to get them on the stack for conservative ++// stack scanning. ++// ++// See asm/x64/push_registers_clang.cc for why the function is not generated ++// using clang. ++// ++// Do not depend on V8_TARGET_OS_* defines as some embedders may override the ++// GN toolchain (e.g. ChromeOS) and not provide them. ++asm( ++ ".global PushAllRegistersAndIterateStack \n" ++ ".type PushAllRegistersAndIterateStack, %function \n" ++ ".hidden PushAllRegistersAndIterateStack \n" ++ "PushAllRegistersAndIterateStack: \n" ++ // Push all callee-saved registers and save return address. ++ " addi sp, sp, -96 \n" ++ " sd ra, 88(sp) \n" ++ " sd s8, 80(sp) \n" ++ " sd sp, 72(sp) \n" ++ " sd gp, 64(sp) \n" ++ " sd s7, 56(sp) \n" ++ " sd s6, 48(sp) \n" ++ " sd s5, 40(sp) \n" ++ " sd s4, 32(sp) \n" ++ " sd s3, 24(sp) \n" ++ " sd s2, 16(sp) \n" ++ " sd s1, 8(sp) \n" ++ " sd s0, 0(sp) \n" ++ // Maintain frame pointer. ++ " mv s8, sp \n" ++ // Pass 1st parameter (a0) unchanged (Stack*). ++ // Pass 2nd parameter (a1) unchanged (StackVisitor*). ++ // Save 3rd parameter (a2; IterateStackCallback). ++ " mv a3, a2 \n" ++ " mv a2, sp \n" ++ // Call the callback. ++ " jalr a3 \n" ++ // Load return address. ++ " ld ra, 88(sp) \n" ++ // Restore frame pointer. ++ " ld s8, 80(sp) \n" ++ " addi sp, sp, 96 \n" ++ " jr ra \n"); ++ +--- a/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc ++++ b/src/3rdparty/chromium/v8/src/interpreter/interpreter-assembler.cc +@@ -1348,7 +1348,8 @@ + + // static + bool InterpreterAssembler::TargetSupportsUnalignedAccess() { +-#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 || \ ++ V8_TARGET_ARCH_RISCV + return false; + #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390 || \ + V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC || \ +--- a/src/3rdparty/chromium/v8/src/libsampler/sampler.cc ++++ b/src/3rdparty/chromium/v8/src/libsampler/sampler.cc +@@ -442,6 +442,12 @@ + state->sp = reinterpret_cast(ucontext->uc_mcontext.gregs[15]); + state->fp = reinterpret_cast(ucontext->uc_mcontext.gregs[11]); + state->lr = reinterpret_cast(ucontext->uc_mcontext.gregs[14]); ++#elif V8_HOST_ARCH_RISCV64 || V8_HOST_ARCH_RISCV ++ // Spec CH.25 RISC-V Assembly Programmer’s Handbook ++ state->pc = reinterpret_cast(mcontext.__gregs[REG_PC]); ++ state->sp = reinterpret_cast(mcontext.__gregs[REG_SP]); ++ state->fp = reinterpret_cast(mcontext.__gregs[REG_S0]); ++ state->lr = reinterpret_cast(mcontext.__gregs[REG_RA]); + #endif // V8_HOST_ARCH_* + #elif V8_OS_IOS + +--- a/src/3rdparty/chromium/v8/src/logging/log.cc ++++ b/src/3rdparty/chromium/v8/src/logging/log.cc +@@ -594,6 +594,14 @@ + const char arch[] = "arm64"; + #elif V8_TARGET_ARCH_S390 + const char arch[] = "s390"; ++#elif V8_TARGET_ARCH_RISCV64 ++ // FIXME (RISCV) porting: need more specific arch strings based on cpu ++ // features ++ const char arch[] = "riscv64"; ++#elif V8_TARGET_ARCH_RISCV ++ // FIXME (RISCV) porting: need more specific arch strings based on cpu ++ // features ++ const char arch[] = "riscv"; + #else + const char arch[] = "unknown"; + #endif +--- a/src/3rdparty/chromium/v8/src/objects/backing-store.cc ++++ b/src/3rdparty/chromium/v8/src/objects/backing-store.cc +@@ -29,7 +29,8 @@ + constexpr bool kUseGuardRegions = false; + #endif + +-#if V8_TARGET_ARCH_MIPS64 ++#if V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_RISCV64 ++// FIXME(RISCV): Check this value + // MIPS64 has a user space of 2^40 bytes on most processors, + // address space limits needs to be smaller. + constexpr size_t kAddressSpaceLimit = 0x8000000000L; // 512 GiB +@@ -39,6 +40,10 @@ + constexpr size_t kAddressSpaceLimit = 0xC0000000; // 3 GiB + #endif + ++#if V8_TARGET_ARCH_RISCV ++#erro RISCV(32) architecture not supported ++#endif ++ + constexpr uint64_t kOneGiB = 1024 * 1024 * 1024; + constexpr uint64_t kNegativeGuardSize = 2 * kOneGiB; + +--- a/src/3rdparty/chromium/v8/src/objects/code.cc ++++ b/src/3rdparty/chromium/v8/src/objects/code.cc +@@ -234,7 +234,7 @@ + RelocInfo::ModeMask(RelocInfo::WASM_STUB_CALL))); + + #if defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) || \ +- defined(V8_TARGET_ARCH_MIPS64) ++ defined(V8_TARGET_ARCH_MIPS64) || defined(V8_TARGET_ARCH_RISCV64) + return RelocIterator(*this, kModeMask).done(); + #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_ARM64) || \ + defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) || \ +--- a/src/3rdparty/chromium/v8/src/objects/code.h ++++ b/src/3rdparty/chromium/v8/src/objects/code.h +@@ -461,6 +461,10 @@ + : (COMPRESS_POINTERS_BOOL ? 16 : 28); + #elif V8_TARGET_ARCH_S390X + static constexpr int kHeaderPaddingSize = COMPRESS_POINTERS_BOOL ? 16 : 28; ++#elif V8_TARGET_ARCH_RISCV64 ++ static constexpr int kHeaderPaddingSize = 28; ++#elif V8_TARGET_ARCH_RISCV ++#error riscv32 unsupported yet + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc ++++ b/src/3rdparty/chromium/v8/src/profiler/tick-sample.cc +@@ -125,6 +125,13 @@ + state->sp = reinterpret_cast(simulator->get_register(Simulator::sp)); + state->fp = reinterpret_cast(simulator->get_register(Simulator::fp)); + state->lr = reinterpret_cast(simulator->get_register(Simulator::ra)); ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ if (!simulator->has_bad_pc()) { ++ state->pc = reinterpret_cast(simulator->get_pc()); ++ } ++ state->sp = reinterpret_cast(simulator->get_register(Simulator::sp)); ++ state->fp = reinterpret_cast(simulator->get_register(Simulator::fp)); ++ state->lr = reinterpret_cast(simulator->get_register(Simulator::ra)); + #endif + if (state->sp == 0 || state->fp == 0) { + // It possible that the simulator is interrupted while it is updating +--- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h ++++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler-arch.h +@@ -23,6 +23,10 @@ + #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/regexp/s390/regexp-macro-assembler-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/regexp/riscv64/regexp-macro-assembler-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/regexp/riscv/regexp-macro-assembler-riscv.h" + #else + #error Unsupported target architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h ++++ b/src/3rdparty/chromium/v8/src/regexp/regexp-macro-assembler.h +@@ -44,6 +44,7 @@ + kARMImplementation, + kARM64Implementation, + kMIPSImplementation, ++ kRISCVImplementation, + kS390Implementation, + kPPCImplementation, + kX64Implementation, +--- a/src/3rdparty/chromium/v8/src/regexp/regexp.cc ++++ b/src/3rdparty/chromium/v8/src/regexp/regexp.cc +@@ -815,6 +815,9 @@ + #elif V8_TARGET_ARCH_MIPS64 + macro_assembler.reset(new RegExpMacroAssemblerMIPS(isolate, zone, mode, + output_register_count)); ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++ macro_assembler.reset(new RegExpMacroAssemblerRISCV(isolate, zone, mode, ++ output_register_count)); + #else + #error "Unsupported architecture" + #endif +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/regexp/riscv64/regexp-macro-assembler-riscv64.cc +@@ -0,0 +1,1260 @@ ++// Copyright 2012 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#if V8_TARGET_ARCH_RISCV64 ++ ++#include "src/regexp/riscv64/regexp-macro-assembler-riscv64.h" ++ ++#include "src/codegen/assembler-inl.h" ++#include "src/codegen/macro-assembler.h" ++#include "src/logging/log.h" ++#include "src/objects/objects-inl.h" ++#include "src/regexp/regexp-macro-assembler.h" ++#include "src/regexp/regexp-stack.h" ++#include "src/snapshot/embedded/embedded-data.h" ++#include "src/strings/unicode.h" ++ ++namespace v8 { ++namespace internal { ++ ++/* clang-format off ++ * ++ * This assembler uses the following register assignment convention ++ * - t4 : Temporarily stores the index of capture start after a matching pass ++ * for a global regexp. ++ * - a5 : Pointer to current Code object including heap object tag. ++ * - a6 : Current position in input, as negative offset from end of string. ++ * Please notice that this is the byte offset, not the character offset! ++ * - a7 : Currently loaded character. Must be loaded using ++ * LoadCurrentCharacter before using any of the dispatch methods. ++ * - t0 : Points to tip of backtrack stack ++ * - t1 : Unused. ++ * - t2 : End of input (points to byte after last character in input). ++ * - fp : Frame pointer. Used to access arguments, local variables and ++ * RegExp registers. ++ * - sp : Points to tip of C stack. ++ * ++ * The remaining registers are free for computations. ++ * Each call to a public method should retain this convention. ++ * ++ * The stack will have the following structure: ++ * FIXME(RISCV): Verify that this stack description is correct ++ * ++ * - fp[80] Isolate* isolate (address of the current isolate) kIsolate ++ * kStackFrameHeader ++ * --- sp when called --- ++ * - fp[72] ra Return from RegExp code (ra). kReturnAddress ++ * - fp[64] s9, old-fp Old fp, callee saved(s9). ++ * - fp[0..63] fp..s7 Callee-saved registers fp..s7. ++ * --- frame pointer ---- ++ * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime) kDirectCall ++ * - fp[-16] stack_base (Top of backtracking stack). kStackHighEnd ++ * - fp[-24] capture array size (may fit multiple sets of matches) kNumOutputRegisters ++ * - fp[-32] int* capture_array (int[num_saved_registers_], for output). kRegisterOutput ++ * - fp[-40] end of input (address of end of string). kInputEnd ++ * - fp[-48] start of input (address of first character in string). kInputStart ++ * - fp[-56] start index (character index of start). kStartIndex ++ * - fp[-64] void* input_string (location of a handle containing the string). kInputString ++ * - fp[-72] success counter (only for global regexps to count matches). kSuccessfulCaptures ++ * - fp[-80] Offset of location before start of input (effectively character kStringStartMinusOne ++ * position -1). Used to initialize capture registers to a ++ * non-position. ++ * --------- The following output registers are 32-bit values. --------- ++ * - fp[-88] register 0 (Only positions must be stored in the first kRegisterZero ++ * - register 1 num_saved_registers_ registers) ++ * - ... ++ * - register num_registers-1 ++ * --- sp --- ++ * ++ * The first num_saved_registers_ registers are initialized to point to ++ * "character -1" in the string (i.e., char_size() bytes before the first ++ * character of the string). The remaining registers start out as garbage. ++ * ++ * The data up to the return address must be placed there by the calling ++ * code and the remaining arguments are passed in registers, e.g. by calling the ++ * code entry as cast to a function with the signature: ++ * int (*match)(String input_string, ++ * int start_index, ++ * Address start, ++ * Address end, ++ * int* capture_output_array, ++ * int num_capture_registers, ++ * byte* stack_area_base, ++ * bool direct_call = false, ++ * Isolate* isolate); ++ * The call is performed by NativeRegExpMacroAssembler::Execute() ++ * (in regexp-macro-assembler.cc) via the GeneratedCode wrapper. ++ * ++ * clang-format on ++ */ ++ ++#define __ ACCESS_MASM(masm_) ++ ++const int RegExpMacroAssemblerRISCV::kRegExpCodeSize; ++ ++RegExpMacroAssemblerRISCV::RegExpMacroAssemblerRISCV(Isolate* isolate, ++ Zone* zone, Mode mode, ++ int registers_to_save) ++ : NativeRegExpMacroAssembler(isolate, zone), ++ masm_(new MacroAssembler(isolate, CodeObjectRequired::kYes, ++ NewAssemblerBuffer(kRegExpCodeSize))), ++ mode_(mode), ++ num_registers_(registers_to_save), ++ num_saved_registers_(registers_to_save), ++ entry_label_(), ++ start_label_(), ++ success_label_(), ++ backtrack_label_(), ++ exit_label_(), ++ internal_failure_label_() { ++ masm_->set_root_array_available(false); ++ ++ DCHECK_EQ(0, registers_to_save % 2); ++ __ jmp(&entry_label_); // We'll write the entry code later. ++ // If the code gets too big or corrupted, an internal exception will be ++ // raised, and we will exit right away. ++ __ bind(&internal_failure_label_); ++ __ li(a0, Operand(FAILURE)); ++ __ Ret(); ++ __ bind(&start_label_); // And then continue from here. ++} ++ ++RegExpMacroAssemblerRISCV::~RegExpMacroAssemblerRISCV() { ++ delete masm_; ++ // Unuse labels in case we throw away the assembler without calling GetCode. ++ entry_label_.Unuse(); ++ start_label_.Unuse(); ++ success_label_.Unuse(); ++ backtrack_label_.Unuse(); ++ exit_label_.Unuse(); ++ check_preempt_label_.Unuse(); ++ stack_overflow_label_.Unuse(); ++ internal_failure_label_.Unuse(); ++} ++ ++int RegExpMacroAssemblerRISCV::stack_limit_slack() { ++ return RegExpStack::kStackLimitSlack; ++} ++ ++void RegExpMacroAssemblerRISCV::AdvanceCurrentPosition(int by) { ++ if (by != 0) { ++ __ Add64(current_input_offset(), current_input_offset(), ++ Operand(by * char_size())); ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::AdvanceRegister(int reg, int by) { ++ DCHECK_LE(0, reg); ++ DCHECK_GT(num_registers_, reg); ++ if (by != 0) { ++ __ Ld(a0, register_location(reg)); ++ __ Add64(a0, a0, Operand(by)); ++ __ Sd(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::Backtrack() { ++ CheckPreemption(); ++ if (has_backtrack_limit()) { ++ Label next; ++ __ Ld(a0, MemOperand(frame_pointer(), kBacktrackCount)); ++ __ Add64(a0, a0, Operand(1)); ++ __ Sd(a0, MemOperand(frame_pointer(), kBacktrackCount)); ++ __ Branch(&next, ne, a0, Operand(backtrack_limit())); ++ ++ // Exceeded limits are treated as a failed match. ++ Fail(); ++ ++ __ bind(&next); ++ } ++ // Pop Code offset from backtrack stack, add Code and jump to location. ++ Pop(a0); ++ __ Add64(a0, a0, code_pointer()); ++ __ Jump(a0); ++} ++ ++void RegExpMacroAssemblerRISCV::Bind(Label* label) { __ bind(label); } ++ ++void RegExpMacroAssemblerRISCV::CheckCharacter(uint32_t c, Label* on_equal) { ++ BranchOrBacktrack(on_equal, eq, current_character(), Operand(c)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckCharacterGT(uc16 limit, ++ Label* on_greater) { ++ BranchOrBacktrack(on_greater, gt, current_character(), Operand(limit)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckAtStart(int cp_offset, ++ Label* on_at_start) { ++ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add64(a0, current_input_offset(), ++ Operand(-char_size() + cp_offset * char_size())); ++ BranchOrBacktrack(on_at_start, eq, a0, Operand(a1)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotAtStart(int cp_offset, ++ Label* on_not_at_start) { ++ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add64(a0, current_input_offset(), ++ Operand(-char_size() + cp_offset * char_size())); ++ BranchOrBacktrack(on_not_at_start, ne, a0, Operand(a1)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckCharacterLT(uc16 limit, Label* on_less) { ++ BranchOrBacktrack(on_less, lt, current_character(), Operand(limit)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckGreedyLoop(Label* on_equal) { ++ Label backtrack_non_equal; ++ __ Lw(a0, MemOperand(backtrack_stackpointer(), 0)); ++ __ Branch(&backtrack_non_equal, ne, current_input_offset(), Operand(a0)); ++ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), ++ Operand(kIntSize)); ++ __ bind(&backtrack_non_equal); ++ BranchOrBacktrack(on_equal, eq, current_input_offset(), Operand(a0)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotBackReferenceIgnoreCase( ++ int start_reg, bool read_backward, bool unicode, Label* on_no_match) { ++ Label fallthrough; ++ __ Ld(a0, register_location(start_reg)); // Index of start of capture. ++ __ Ld(a1, register_location(start_reg + 1)); // Index of end of capture. ++ __ Sub64(a1, a1, a0); // Length of capture. ++ ++ // At this point, the capture registers are either both set or both cleared. ++ // If the capture length is zero, then the capture is either empty or cleared. ++ // Fall through in both cases. ++ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); ++ ++ if (read_backward) { ++ __ Ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add64(t1, t1, a1); ++ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); ++ } else { ++ __ Add64(t1, a1, current_input_offset()); ++ // Check that there are enough characters left in the input. ++ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); ++ } ++ ++ if (mode_ == LATIN1) { ++ Label success; ++ Label fail; ++ Label loop_check; ++ ++ // a0 - offset of start of capture. ++ // a1 - length of capture. ++ __ Add64(a0, a0, Operand(end_of_input_address())); ++ __ Add64(a2, end_of_input_address(), Operand(current_input_offset())); ++ if (read_backward) { ++ __ Sub64(a2, a2, Operand(a1)); ++ } ++ __ Add64(a1, a0, Operand(a1)); ++ ++ // a0 - Address of start of capture. ++ // a1 - Address of end of capture. ++ // a2 - Address of current input position. ++ ++ Label loop; ++ __ bind(&loop); ++ __ Lbu(a3, MemOperand(a0, 0)); ++ __ addi(a0, a0, char_size()); ++ __ Lbu(a4, MemOperand(a2, 0)); ++ __ addi(a2, a2, char_size()); ++ ++ __ Branch(&loop_check, eq, a4, Operand(a3)); ++ ++ // Mismatch, try case-insensitive match (converting letters to lower-case). ++ __ Or(a3, a3, Operand(0x20)); // Convert capture character to lower-case. ++ __ Or(a4, a4, Operand(0x20)); // Also convert input character. ++ __ Branch(&fail, ne, a4, Operand(a3)); ++ __ Sub64(a3, a3, Operand('a')); ++ __ Branch(&loop_check, Uless_equal, a3, Operand('z' - 'a')); ++ // Latin-1: Check for values in range [224,254] but not 247. ++ __ Sub64(a3, a3, Operand(224 - 'a')); ++ // Weren't Latin-1 letters. ++ __ Branch(&fail, Ugreater, a3, Operand(254 - 224)); ++ // Check for 247. ++ __ Branch(&fail, eq, a3, Operand(247 - 224)); ++ ++ __ bind(&loop_check); ++ __ Branch(&loop, lt, a0, Operand(a1)); ++ __ jmp(&success); ++ ++ __ bind(&fail); ++ GoTo(on_no_match); ++ ++ __ bind(&success); ++ // Compute new value of character position after the matched part. ++ __ Sub64(current_input_offset(), a2, end_of_input_address()); ++ if (read_backward) { ++ __ Ld(t1, register_location(start_reg)); // Index of start of capture. ++ __ Ld(a2, register_location(start_reg + 1)); // Index of end of capture. ++ __ Add64(current_input_offset(), current_input_offset(), Operand(t1)); ++ __ Sub64(current_input_offset(), current_input_offset(), Operand(a2)); ++ } ++ } else { ++ DCHECK(mode_ == UC16); ++ // Put regexp engine registers on stack. ++ RegList regexp_registers_to_retain = current_input_offset().bit() | ++ current_character().bit() | ++ backtrack_stackpointer().bit(); ++ __ MultiPush(regexp_registers_to_retain); ++ ++ int argument_count = 4; ++ __ PrepareCallCFunction(argument_count, a2); ++ ++ // a0 - offset of start of capture. ++ // a1 - length of capture. ++ ++ // Put arguments into arguments registers. ++ // Parameters are ++ // a0: Address byte_offset1 - Address captured substring's start. ++ // a1: Address byte_offset2 - Address of current character position. ++ // a2: size_t byte_length - length of capture in bytes(!). ++ // a3: Isolate* isolate. ++ ++ // Address of start of capture. ++ __ Add64(a0, a0, Operand(end_of_input_address())); ++ // Length of capture. ++ __ mv(a2, a1); ++ // Save length in callee-save register for use on return. ++ __ mv(s3, a1); ++ // Address of current input position. ++ __ Add64(a1, current_input_offset(), Operand(end_of_input_address())); ++ if (read_backward) { ++ __ Sub64(a1, a1, Operand(s3)); ++ } ++ // Isolate. ++ __ li(a3, Operand(ExternalReference::isolate_address(masm_->isolate()))); ++ ++ { ++ AllowExternalCallThatCantCauseGC scope(masm_); ++ ExternalReference function = ++ unicode ? ExternalReference::re_case_insensitive_compare_unicode( ++ isolate()) ++ : ExternalReference::re_case_insensitive_compare_non_unicode( ++ isolate()); ++ __ CallCFunction(function, argument_count); ++ } ++ ++ // Restore regexp engine registers. ++ __ MultiPop(regexp_registers_to_retain); ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ ++ // Check if function returned non-zero for success or zero for failure. ++ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); ++ // On success, increment position by length of capture. ++ if (read_backward) { ++ __ Sub64(current_input_offset(), current_input_offset(), Operand(s3)); ++ } else { ++ __ Add64(current_input_offset(), current_input_offset(), Operand(s3)); ++ } ++ } ++ ++ __ bind(&fallthrough); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotBackReference(int start_reg, ++ bool read_backward, ++ Label* on_no_match) { ++ Label fallthrough; ++ ++ // Find length of back-referenced capture. ++ __ Ld(a0, register_location(start_reg)); ++ __ Ld(a1, register_location(start_reg + 1)); ++ __ Sub64(a1, a1, a0); // Length to check. ++ ++ // At this point, the capture registers are either both set or both cleared. ++ // If the capture length is zero, then the capture is either empty or cleared. ++ // Fall through in both cases. ++ __ Branch(&fallthrough, eq, a1, Operand(zero_reg)); ++ ++ if (read_backward) { ++ __ Ld(t1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add64(t1, t1, a1); ++ BranchOrBacktrack(on_no_match, le, current_input_offset(), Operand(t1)); ++ } else { ++ __ Add64(t1, a1, current_input_offset()); ++ // Check that there are enough characters left in the input. ++ BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); ++ } ++ ++ // Compute pointers to match string and capture string. ++ __ Add64(a0, a0, Operand(end_of_input_address())); ++ __ Add64(a2, end_of_input_address(), Operand(current_input_offset())); ++ if (read_backward) { ++ __ Sub64(a2, a2, Operand(a1)); ++ } ++ __ Add64(a1, a1, Operand(a0)); ++ ++ Label loop; ++ __ bind(&loop); ++ if (mode_ == LATIN1) { ++ __ Lbu(a3, MemOperand(a0, 0)); ++ __ addi(a0, a0, char_size()); ++ __ Lbu(a4, MemOperand(a2, 0)); ++ __ addi(a2, a2, char_size()); ++ } else { ++ DCHECK(mode_ == UC16); ++ __ Lhu(a3, MemOperand(a0, 0)); ++ __ addi(a0, a0, char_size()); ++ __ Lhu(a4, MemOperand(a2, 0)); ++ __ addi(a2, a2, char_size()); ++ } ++ BranchOrBacktrack(on_no_match, ne, a3, Operand(a4)); ++ __ Branch(&loop, lt, a0, Operand(a1)); ++ ++ // Move current character position to position after match. ++ __ Sub64(current_input_offset(), a2, end_of_input_address()); ++ if (read_backward) { ++ __ Ld(t1, register_location(start_reg)); // Index of start of capture. ++ __ Ld(a2, register_location(start_reg + 1)); // Index of end of capture. ++ __ Add64(current_input_offset(), current_input_offset(), Operand(t1)); ++ __ Sub64(current_input_offset(), current_input_offset(), Operand(a2)); ++ } ++ __ bind(&fallthrough); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotCharacter(uint32_t c, ++ Label* on_not_equal) { ++ BranchOrBacktrack(on_not_equal, ne, current_character(), Operand(c)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckCharacterAfterAnd(uint32_t c, ++ uint32_t mask, ++ Label* on_equal) { ++ __ And(a0, current_character(), Operand(mask)); ++ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); ++ BranchOrBacktrack(on_equal, eq, a0, rhs); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotCharacterAfterAnd(uint32_t c, ++ uint32_t mask, ++ Label* on_not_equal) { ++ __ And(a0, current_character(), Operand(mask)); ++ Operand rhs = (c == 0) ? Operand(zero_reg) : Operand(c); ++ BranchOrBacktrack(on_not_equal, ne, a0, rhs); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckNotCharacterAfterMinusAnd( ++ uc16 c, uc16 minus, uc16 mask, Label* on_not_equal) { ++ DCHECK_GT(String::kMaxUtf16CodeUnit, minus); ++ __ Sub64(a0, current_character(), Operand(minus)); ++ __ And(a0, a0, Operand(mask)); ++ BranchOrBacktrack(on_not_equal, ne, a0, Operand(c)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckCharacterInRange(uc16 from, uc16 to, ++ Label* on_in_range) { ++ __ Sub64(a0, current_character(), Operand(from)); ++ // Unsigned lower-or-same condition. ++ BranchOrBacktrack(on_in_range, Uless_equal, a0, Operand(to - from)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckCharacterNotInRange( ++ uc16 from, uc16 to, Label* on_not_in_range) { ++ __ Sub64(a0, current_character(), Operand(from)); ++ // Unsigned higher condition. ++ BranchOrBacktrack(on_not_in_range, Ugreater, a0, Operand(to - from)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckBitInTable(Handle table, ++ Label* on_bit_set) { ++ __ li(a0, Operand(table)); ++ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { ++ __ And(a1, current_character(), Operand(kTableSize - 1)); ++ __ Add64(a0, a0, a1); ++ } else { ++ __ Add64(a0, a0, current_character()); ++ } ++ ++ __ Lbu(a0, FieldMemOperand(a0, ByteArray::kHeaderSize)); ++ BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg)); ++} ++ ++bool RegExpMacroAssemblerRISCV::CheckSpecialCharacterClass(uc16 type, ++ Label* on_no_match) { ++ // Range checks (c in min..max) are generally implemented by an unsigned ++ // (c - min) <= (max - min) check. ++ switch (type) { ++ case 's': ++ // Match space-characters. ++ if (mode_ == LATIN1) { ++ // One byte space characters are '\t'..'\r', ' ' and \u00a0. ++ Label success; ++ __ Branch(&success, eq, current_character(), Operand(' ')); ++ // Check range 0x09..0x0D. ++ __ Sub64(a0, current_character(), Operand('\t')); ++ __ Branch(&success, Uless_equal, a0, Operand('\r' - '\t')); ++ // \u00a0 (NBSP). ++ BranchOrBacktrack(on_no_match, ne, a0, Operand(0x00A0 - '\t')); ++ __ bind(&success); ++ return true; ++ } ++ return false; ++ case 'S': ++ // The emitted code for generic character classes is good enough. ++ return false; ++ case 'd': ++ // Match Latin1 digits ('0'..'9'). ++ __ Sub64(a0, current_character(), Operand('0')); ++ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand('9' - '0')); ++ return true; ++ case 'D': ++ // Match non Latin1-digits. ++ __ Sub64(a0, current_character(), Operand('0')); ++ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand('9' - '0')); ++ return true; ++ case '.': { ++ // Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). ++ __ Xor(a0, current_character(), Operand(0x01)); ++ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. ++ __ Sub64(a0, a0, Operand(0x0B)); ++ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand(0x0C - 0x0B)); ++ if (mode_ == UC16) { ++ // Compare original value to 0x2028 and 0x2029, using the already ++ // computed (current_char ^ 0x01 - 0x0B). I.e., check for ++ // 0x201D (0x2028 - 0x0B) or 0x201E. ++ __ Sub64(a0, a0, Operand(0x2028 - 0x0B)); ++ BranchOrBacktrack(on_no_match, Uless_equal, a0, Operand(1)); ++ } ++ return true; ++ } ++ case 'n': { ++ // Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029). ++ __ Xor(a0, current_character(), Operand(0x01)); ++ // See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C. ++ __ Sub64(a0, a0, Operand(0x0B)); ++ if (mode_ == LATIN1) { ++ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand(0x0C - 0x0B)); ++ } else { ++ Label done; ++ BranchOrBacktrack(&done, Uless_equal, a0, Operand(0x0C - 0x0B)); ++ // Compare original value to 0x2028 and 0x2029, using the already ++ // computed (current_char ^ 0x01 - 0x0B). I.e., check for ++ // 0x201D (0x2028 - 0x0B) or 0x201E. ++ __ Sub64(a0, a0, Operand(0x2028 - 0x0B)); ++ BranchOrBacktrack(on_no_match, Ugreater, a0, Operand(1)); ++ __ bind(&done); ++ } ++ return true; ++ } ++ case 'w': { ++ if (mode_ != LATIN1) { ++ // Table is 256 entries, so all Latin1 characters can be tested. ++ BranchOrBacktrack(on_no_match, Ugreater, current_character(), ++ Operand('z')); ++ } ++ ExternalReference map = ++ ExternalReference::re_word_character_map(isolate()); ++ __ li(a0, Operand(map)); ++ __ Add64(a0, a0, current_character()); ++ __ Lbu(a0, MemOperand(a0, 0)); ++ BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg)); ++ return true; ++ } ++ case 'W': { ++ Label done; ++ if (mode_ != LATIN1) { ++ // Table is 256 entries, so all Latin1 characters can be tested. ++ __ Branch(&done, Ugreater, current_character(), Operand('z')); ++ } ++ ExternalReference map = ++ ExternalReference::re_word_character_map(isolate()); ++ __ li(a0, Operand(map)); ++ __ Add64(a0, a0, current_character()); ++ __ Lbu(a0, MemOperand(a0, 0)); ++ BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); ++ if (mode_ != LATIN1) { ++ __ bind(&done); ++ } ++ return true; ++ } ++ case '*': ++ // Match any character. ++ return true; ++ // No custom implementation (yet): s(UC16), S(UC16). ++ default: ++ return false; ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::Fail() { ++ __ li(a0, Operand(FAILURE)); ++ __ jmp(&exit_label_); ++} ++ ++Handle RegExpMacroAssemblerRISCV::GetCode(Handle source) { ++ Label return_a0; ++ if (masm_->has_exception()) { ++ // If the code gets corrupted due to long regular expressions and lack of ++ // space on trampolines, an internal exception flag is set. If this case ++ // is detected, we will jump into exit sequence right away. ++ __ bind_to(&entry_label_, internal_failure_label_.pos()); ++ } else { ++ // Finalize code - write the entry point code now we know how many ++ // registers we need. ++ ++ // Entry code: ++ __ bind(&entry_label_); ++ ++ // Tell the system that we have a stack frame. Because the type is MANUAL, ++ // no is generated. ++ FrameScope scope(masm_, StackFrame::MANUAL); ++ ++ // Actually emit code to start a new stack frame. ++ // Push arguments ++ // Save callee-save registers. ++ // Start new stack frame. ++ // Store link register in existing stack-cell. ++ // Order here should correspond to order of offset constants in header file. ++ // TODO(plind): we save fp..s11, but ONLY use s3 here - use the regs ++ // or dont save. ++ // ++ // FIXME (RISCV): how about saving only s*registers that are actually used? ++ RegList registers_to_retain = ++ fp.bit() | s1.bit() | s2.bit() | s3.bit() | s4.bit() | s5.bit() | ++ s6.bit() | s7.bit() | s8.bit() /*| s9.bit() | s10.bit() | s11.bit()*/; ++ DCHECK(NumRegs(registers_to_retain) == kNumCalleeRegsToRetain); ++ ++ // The remaining arguments are passed in registers, e.g.by calling the code ++ // entry as cast to a function with the signature: ++ // ++ // *int(*match)(String input_string, // a0 ++ // int start_index, // a1 ++ // Address start, // a2 ++ // Address end, // a3 ++ // int*capture_output_array, // a4 ++ // int num_capture_registers, // a5 ++ // byte* stack_area_base, // a6 ++ // bool direct_call = false, // a7 ++ // Isolate * isolate); // on the stack ++ RegList argument_registers = a0.bit() | a1.bit() | a2.bit() | a3.bit() | ++ a4.bit() | a5.bit() | a6.bit() | a7.bit(); ++ ++ // According to MultiPush implementation, registers will be pushed in the ++ // order of ra, fp, then s8, ..., s1, and finally a7,...a0 ++ __ MultiPush(ra.bit() | registers_to_retain | argument_registers); ++ ++ // Set frame pointer in space for it if this is not a direct call ++ // from generated code. ++ __ Add64(frame_pointer(), sp, ++ Operand(NumRegs(argument_registers) * kPointerSize)); ++ ++ STATIC_ASSERT(kSuccessfulCaptures == kInputString - kSystemPointerSize); ++ __ mv(a0, zero_reg); ++ __ push(a0); // Make room for success counter and initialize it to 0. ++ STATIC_ASSERT(kStringStartMinusOne == ++ kSuccessfulCaptures - kSystemPointerSize); ++ __ push(a0); // Make room for "string start - 1" constant. ++ STATIC_ASSERT(kBacktrackCount == kStringStartMinusOne - kSystemPointerSize); ++ __ push(a0); // The backtrack counter ++ ++ // Check if we have space on the stack for registers. ++ Label stack_limit_hit; ++ Label stack_ok; ++ ++ ExternalReference stack_limit = ++ ExternalReference::address_of_jslimit(masm_->isolate()); ++ __ li(a0, Operand(stack_limit)); ++ __ Ld(a0, MemOperand(a0)); ++ __ Sub64(a0, sp, a0); ++ // Handle it if the stack pointer is already below the stack limit. ++ __ Branch(&stack_limit_hit, le, a0, Operand(zero_reg)); ++ // Check if there is room for the variable number of registers above ++ // the stack limit. ++ __ Branch(&stack_ok, Ugreater_equal, a0, ++ Operand(num_registers_ * kPointerSize)); ++ // Exit with OutOfMemory exception. There is not enough space on the stack ++ // for our working registers. ++ __ li(a0, Operand(EXCEPTION)); ++ __ jmp(&return_a0); ++ ++ __ bind(&stack_limit_hit); ++ CallCheckStackGuardState(a0); ++ // If returned value is non-zero, we exit with the returned value as result. ++ __ Branch(&return_a0, ne, a0, Operand(zero_reg)); ++ ++ __ bind(&stack_ok); ++ // Allocate space on stack for registers. ++ __ Sub64(sp, sp, Operand(num_registers_ * kPointerSize)); ++ // Load string end. ++ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ // Load input start. ++ __ Ld(a0, MemOperand(frame_pointer(), kInputStart)); ++ // Find negative length (offset of start relative to end). ++ __ Sub64(current_input_offset(), a0, end_of_input_address()); ++ // Set a0 to address of char before start of the input string ++ // (effectively string position -1). ++ __ Ld(a1, MemOperand(frame_pointer(), kStartIndex)); ++ __ Sub64(a0, current_input_offset(), Operand(char_size())); ++ __ slli(t1, a1, (mode_ == UC16) ? 1 : 0); ++ __ Sub64(a0, a0, t1); ++ // Store this value in a local variable, for use when clearing ++ // position registers. ++ __ Sd(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ ++ // Initialize code pointer register ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ ++ Label load_char_start_regexp, start_regexp; ++ // Load newline if index is at start, previous character otherwise. ++ __ Branch(&load_char_start_regexp, ne, a1, Operand(zero_reg)); ++ __ li(current_character(), Operand('\n')); ++ __ jmp(&start_regexp); ++ ++ // Global regexp restarts matching here. ++ __ bind(&load_char_start_regexp); ++ // Load previous char as initial value of current character register. ++ LoadCurrentCharacterUnchecked(-1, 1); ++ __ bind(&start_regexp); ++ ++ // Initialize on-stack registers. ++ if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. ++ // Fill saved registers with initial value = start offset - 1. ++ if (num_saved_registers_ > 8) { ++ // Address of register 0. ++ __ Add64(a1, frame_pointer(), Operand(kRegisterZero)); ++ __ li(a2, Operand(num_saved_registers_)); ++ Label init_loop; ++ __ bind(&init_loop); ++ __ Sd(a0, MemOperand(a1)); ++ __ Add64(a1, a1, Operand(-kPointerSize)); ++ __ Sub64(a2, a2, Operand(1)); ++ __ Branch(&init_loop, ne, a2, Operand(zero_reg)); ++ } else { ++ for (int i = 0; i < num_saved_registers_; i++) { ++ __ Sd(a0, register_location(i)); ++ } ++ } ++ } ++ ++ // Initialize backtrack stack pointer. ++ __ Ld(backtrack_stackpointer(), MemOperand(frame_pointer(), kStackHighEnd)); ++ ++ __ jmp(&start_label_); ++ ++ // Exit code: ++ if (success_label_.is_linked()) { ++ // Save captures when successful. ++ __ bind(&success_label_); ++ if (num_saved_registers_ > 0) { ++ // Copy captures to output. ++ __ Ld(a1, MemOperand(frame_pointer(), kInputStart)); ++ __ Ld(a0, MemOperand(frame_pointer(), kRegisterOutput)); ++ __ Ld(a2, MemOperand(frame_pointer(), kStartIndex)); ++ __ Sub64(a1, end_of_input_address(), a1); ++ // a1 is length of input in bytes. ++ if (mode_ == UC16) { ++ __ srli(a1, a1, 1); ++ } ++ // a1 is length of input in characters. ++ __ Add64(a1, a1, Operand(a2)); ++ // a1 is length of string in characters. ++ ++ DCHECK_EQ(0, num_saved_registers_ % 2); ++ // Always an even number of capture registers. This allows us to ++ // unroll the loop once to add an operation between a load of a register ++ // and the following use of that register. ++ for (int i = 0; i < num_saved_registers_; i += 2) { ++ __ Ld(a2, register_location(i)); ++ __ Ld(a3, register_location(i + 1)); ++ if (i == 0 && global_with_zero_length_check()) { ++ // Keep capture start in a4 for the zero-length check later. ++ __ mv(t4, a2); ++ } ++ if (mode_ == UC16) { ++ __ srai(a2, a2, 1); ++ __ Add64(a2, a2, a1); ++ __ srai(a3, a3, 1); ++ __ Add64(a3, a3, a1); ++ } else { ++ __ Add64(a2, a1, Operand(a2)); ++ __ Add64(a3, a1, Operand(a3)); ++ } ++ // V8 expects the output to be an int32_t array. ++ __ Sw(a2, MemOperand(a0)); ++ __ Add64(a0, a0, kIntSize); ++ __ Sw(a3, MemOperand(a0)); ++ __ Add64(a0, a0, kIntSize); ++ } ++ } ++ ++ if (global()) { ++ // Restart matching if the regular expression is flagged as global. ++ __ Ld(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ __ Ld(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); ++ __ Ld(a2, MemOperand(frame_pointer(), kRegisterOutput)); ++ // Increment success counter. ++ __ Add64(a0, a0, 1); ++ __ Sd(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ // Capture results have been stored, so the number of remaining global ++ // output registers is reduced by the number of stored captures. ++ __ Sub64(a1, a1, num_saved_registers_); ++ // Check whether we have enough room for another set of capture results. ++ __ Branch(&return_a0, lt, a1, Operand(num_saved_registers_)); ++ ++ __ Sd(a1, MemOperand(frame_pointer(), kNumOutputRegisters)); ++ // Advance the location for output. ++ __ Add64(a2, a2, num_saved_registers_ * kIntSize); ++ __ Sd(a2, MemOperand(frame_pointer(), kRegisterOutput)); ++ ++ // Prepare a0 to initialize registers with its value in the next run. ++ __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ ++ if (global_with_zero_length_check()) { ++ // Special case for zero-length matches. ++ // t4: capture start index ++ // Not a zero-length match, restart. ++ __ Branch(&load_char_start_regexp, ne, current_input_offset(), ++ Operand(t4)); ++ // Offset from the end is zero if we already reached the end. ++ __ Branch(&exit_label_, eq, current_input_offset(), ++ Operand(zero_reg)); ++ // Advance current position after a zero-length match. ++ Label advance; ++ __ bind(&advance); ++ __ Add64(current_input_offset(), current_input_offset(), ++ Operand((mode_ == UC16) ? 2 : 1)); ++ if (global_unicode()) CheckNotInSurrogatePair(0, &advance); ++ } ++ ++ __ Branch(&load_char_start_regexp); ++ } else { ++ __ li(a0, Operand(SUCCESS)); ++ } ++ } ++ // Exit and return a0. ++ __ bind(&exit_label_); ++ if (global()) { ++ __ Ld(a0, MemOperand(frame_pointer(), kSuccessfulCaptures)); ++ } ++ ++ __ bind(&return_a0); ++ // Skip sp past regexp registers and local variables.. ++ __ mv(sp, frame_pointer()); ++ ++ // Restore registers fp..s11 and return (restoring ra to pc). ++ __ MultiPop(registers_to_retain | ra.bit()); ++ ++ __ Ret(); ++ ++ // Backtrack code (branch target for conditional backtracks). ++ if (backtrack_label_.is_linked()) { ++ __ bind(&backtrack_label_); ++ Backtrack(); ++ } ++ ++ Label exit_with_exception; ++ ++ // Preempt-code. ++ if (check_preempt_label_.is_linked()) { ++ SafeCallTarget(&check_preempt_label_); ++ // Put regexp engine registers on stack. ++ RegList regexp_registers_to_retain = current_input_offset().bit() | ++ current_character().bit() | ++ backtrack_stackpointer().bit(); ++ __ MultiPush(regexp_registers_to_retain); ++ CallCheckStackGuardState(a0); ++ __ MultiPop(regexp_registers_to_retain); ++ // If returning non-zero, we should end execution with the given ++ // result as return value. ++ __ Branch(&return_a0, ne, a0, Operand(zero_reg)); ++ ++ // String might have moved: Reload end of string from frame. ++ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ SafeReturn(); ++ } ++ ++ // Backtrack stack overflow code. ++ if (stack_overflow_label_.is_linked()) { ++ SafeCallTarget(&stack_overflow_label_); ++ // Reached if the backtrack-stack limit has been hit. ++ // Put regexp engine registers on stack first. ++ RegList regexp_registers = ++ current_input_offset().bit() | current_character().bit(); ++ __ MultiPush(regexp_registers); ++ ++ // Call GrowStack(backtrack_stackpointer(), &stack_base) ++ static const int num_arguments = 3; ++ __ PrepareCallCFunction(num_arguments, a0); ++ __ mv(a0, backtrack_stackpointer()); ++ __ Add64(a1, frame_pointer(), Operand(kStackHighEnd)); ++ __ li(a2, Operand(ExternalReference::isolate_address(masm_->isolate()))); ++ ExternalReference grow_stack = ++ ExternalReference::re_grow_stack(masm_->isolate()); ++ __ CallCFunction(grow_stack, num_arguments); ++ // Restore regexp registers. ++ __ MultiPop(regexp_registers); ++ // If return nullptr, we have failed to grow the stack, and ++ // must exit with a stack-overflow exception. ++ __ Branch(&exit_with_exception, eq, a0, Operand(zero_reg)); ++ // Otherwise use return value as new stack pointer. ++ __ mv(backtrack_stackpointer(), a0); ++ // Restore saved registers and continue. ++ __ li(code_pointer(), Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ __ Ld(end_of_input_address(), MemOperand(frame_pointer(), kInputEnd)); ++ SafeReturn(); ++ } ++ ++ if (exit_with_exception.is_linked()) { ++ // If any of the code above needed to exit with an exception. ++ __ bind(&exit_with_exception); ++ // Exit with Result EXCEPTION(-1) to signal thrown exception. ++ __ li(a0, Operand(EXCEPTION)); ++ __ jmp(&return_a0); ++ } ++ } ++ ++ CodeDesc code_desc; ++ masm_->GetCode(isolate(), &code_desc); ++ Handle code = ++ Factory::CodeBuilder(isolate(), code_desc, CodeKind::REGEXP) ++ .set_self_reference(masm_->CodeObject()) ++ .Build(); ++ LOG(masm_->isolate(), ++ RegExpCodeCreateEvent(Handle::cast(code), source)); ++ return Handle::cast(code); ++} ++ ++void RegExpMacroAssemblerRISCV::GoTo(Label* to) { ++ if (to == nullptr) { ++ Backtrack(); ++ return; ++ } ++ __ jmp(to); ++ return; ++} ++ ++void RegExpMacroAssemblerRISCV::IfRegisterGE(int reg, int comparand, ++ Label* if_ge) { ++ __ Ld(a0, register_location(reg)); ++ BranchOrBacktrack(if_ge, ge, a0, Operand(comparand)); ++} ++ ++void RegExpMacroAssemblerRISCV::IfRegisterLT(int reg, int comparand, ++ Label* if_lt) { ++ __ Ld(a0, register_location(reg)); ++ BranchOrBacktrack(if_lt, lt, a0, Operand(comparand)); ++} ++ ++void RegExpMacroAssemblerRISCV::IfRegisterEqPos(int reg, Label* if_eq) { ++ __ Ld(a0, register_location(reg)); ++ BranchOrBacktrack(if_eq, eq, a0, Operand(current_input_offset())); ++} ++ ++RegExpMacroAssembler::IrregexpImplementation ++RegExpMacroAssemblerRISCV::Implementation() { ++ return kRISCVImplementation; ++} ++ ++void RegExpMacroAssemblerRISCV::PopCurrentPosition() { ++ Pop(current_input_offset()); ++} ++ ++void RegExpMacroAssemblerRISCV::PopRegister(int register_index) { ++ Pop(a0); ++ __ Sd(a0, register_location(register_index)); ++} ++ ++void RegExpMacroAssemblerRISCV::PushBacktrack(Label* label) { ++ if (label->is_bound()) { ++ int target = label->pos(); ++ __ li(a0, Operand(target + Code::kHeaderSize - kHeapObjectTag)); ++ } else { ++ Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); ++ Label after_constant; ++ __ Branch(&after_constant); ++ int offset = masm_->pc_offset(); ++ int cp_offset = offset + Code::kHeaderSize - kHeapObjectTag; ++ __ emit(0); ++ masm_->label_at_put(label, offset); ++ __ bind(&after_constant); ++ if (is_int16(cp_offset)) { ++ __ Lwu(a0, MemOperand(code_pointer(), cp_offset)); ++ } else { ++ __ Add64(a0, code_pointer(), cp_offset); ++ __ Lwu(a0, MemOperand(a0, 0)); ++ } ++ } ++ Push(a0); ++ CheckStackLimit(); ++} ++ ++void RegExpMacroAssemblerRISCV::PushCurrentPosition() { ++ Push(current_input_offset()); ++} ++ ++void RegExpMacroAssemblerRISCV::PushRegister(int register_index, ++ StackCheckFlag check_stack_limit) { ++ __ Ld(a0, register_location(register_index)); ++ Push(a0); ++ if (check_stack_limit) CheckStackLimit(); ++} ++ ++void RegExpMacroAssemblerRISCV::ReadCurrentPositionFromRegister(int reg) { ++ __ Ld(current_input_offset(), register_location(reg)); ++} ++ ++void RegExpMacroAssemblerRISCV::ReadStackPointerFromRegister(int reg) { ++ __ Ld(backtrack_stackpointer(), register_location(reg)); ++ __ Ld(a0, MemOperand(frame_pointer(), kStackHighEnd)); ++ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), Operand(a0)); ++} ++ ++void RegExpMacroAssemblerRISCV::SetCurrentPositionFromEnd(int by) { ++ Label after_position; ++ __ Branch(&after_position, ge, current_input_offset(), ++ Operand(-by * char_size())); ++ __ li(current_input_offset(), -by * char_size()); ++ // On RegExp code entry (where this operation is used), the character before ++ // the current position is expected to be already loaded. ++ // We have advanced the position, so it's safe to read backwards. ++ LoadCurrentCharacterUnchecked(-1, 1); ++ __ bind(&after_position); ++} ++ ++void RegExpMacroAssemblerRISCV::SetRegister(int register_index, int to) { ++ DCHECK(register_index >= num_saved_registers_); // Reserved for positions! ++ __ li(a0, Operand(to)); ++ __ Sd(a0, register_location(register_index)); ++} ++ ++bool RegExpMacroAssemblerRISCV::Succeed() { ++ __ jmp(&success_label_); ++ return global(); ++} ++ ++void RegExpMacroAssemblerRISCV::WriteCurrentPositionToRegister(int reg, ++ int cp_offset) { ++ if (cp_offset == 0) { ++ __ Sd(current_input_offset(), register_location(reg)); ++ } else { ++ __ Add64(a0, current_input_offset(), Operand(cp_offset * char_size())); ++ __ Sd(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::ClearRegisters(int reg_from, int reg_to) { ++ DCHECK(reg_from <= reg_to); ++ __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ for (int reg = reg_from; reg <= reg_to; reg++) { ++ __ Sd(a0, register_location(reg)); ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::WriteStackPointerToRegister(int reg) { ++ __ Ld(a1, MemOperand(frame_pointer(), kStackHighEnd)); ++ __ Sub64(a0, backtrack_stackpointer(), a1); ++ __ Sd(a0, register_location(reg)); ++} ++ ++bool RegExpMacroAssemblerRISCV::CanReadUnaligned() { return false; } ++ ++// Private methods: ++ ++void RegExpMacroAssemblerRISCV::CallCheckStackGuardState(Register scratch) { ++ DCHECK(!isolate()->IsGeneratingEmbeddedBuiltins()); ++ DCHECK(!masm_->options().isolate_independent_code); ++ ++ int stack_alignment = base::OS::ActivationFrameAlignment(); ++ ++ // Align the stack pointer and save the original sp value on the stack. ++ __ mv(scratch, sp); ++ __ Sub64(sp, sp, Operand(kPointerSize)); ++ DCHECK(base::bits::IsPowerOfTwo(stack_alignment)); ++ __ And(sp, sp, Operand(-stack_alignment)); ++ __ Sd(scratch, MemOperand(sp)); ++ ++ __ mv(a2, frame_pointer()); ++ // Code of self. ++ __ li(a1, Operand(masm_->CodeObject()), CONSTANT_SIZE); ++ ++ // We need to make room for the return address on the stack. ++ DCHECK(IsAligned(stack_alignment, kPointerSize)); ++ __ Sub64(sp, sp, Operand(stack_alignment)); ++ ++ // The stack pointer now points to cell where the return address will be ++ // written. Arguments are in registers, meaning we treat the return address as ++ // argument 5. Since DirectCEntry will handle allocating space for the C ++ // argument slots, we don't need to care about that here. This is how the ++ // stack will look (sp meaning the value of sp at this moment): ++ // [sp + 3] - empty slot if needed for alignment. ++ // [sp + 2] - saved sp. ++ // [sp + 1] - second word reserved for return value. ++ // [sp + 0] - first word reserved for return value. ++ ++ // a0 will point to the return address, placed by DirectCEntry. ++ __ mv(a0, sp); ++ ++ ExternalReference stack_guard_check = ++ ExternalReference::re_check_stack_guard_state(masm_->isolate()); ++ __ li(t6, Operand(stack_guard_check)); ++ ++ EmbeddedData d = EmbeddedData::FromBlob(); ++ CHECK(Builtins::IsIsolateIndependent(Builtins::kDirectCEntry)); ++ Address entry = d.InstructionStartOfBuiltin(Builtins::kDirectCEntry); ++ __ li(kScratchReg, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); ++ __ Call(kScratchReg); ++ ++ // DirectCEntry allocated space for the C argument slots so we have to ++ // drop them with the return address from the stack with loading saved sp. ++ // At this point stack must look: ++ // [sp + 7] - empty slot if needed for alignment. ++ // [sp + 6] - saved sp. ++ // [sp + 5] - second word reserved for return value. ++ // [sp + 4] - first word reserved for return value. ++ // [sp + 3] - C argument slot. ++ // [sp + 2] - C argument slot. ++ // [sp + 1] - C argument slot. ++ // [sp + 0] - C argument slot. ++ __ Ld(sp, MemOperand(sp, stack_alignment + kCArgsSlotsSize)); ++ ++ __ li(code_pointer(), Operand(masm_->CodeObject())); ++} ++ ++// Helper function for reading a value out of a stack frame. ++template ++static T& frame_entry(Address re_frame, int frame_offset) { ++ return reinterpret_cast(Memory(re_frame + frame_offset)); ++} ++ ++template ++static T* frame_entry_address(Address re_frame, int frame_offset) { ++ return reinterpret_cast(re_frame + frame_offset); ++} ++ ++int64_t RegExpMacroAssemblerRISCV::CheckStackGuardState(Address* return_address, ++ Address raw_code, ++ Address re_frame) { ++ Code re_code = Code::cast(Object(raw_code)); ++ return NativeRegExpMacroAssembler::CheckStackGuardState( ++ frame_entry(re_frame, kIsolate), ++ static_cast(frame_entry(re_frame, kStartIndex)), ++ static_cast( ++ frame_entry(re_frame, kDirectCall)), ++ return_address, re_code, ++ frame_entry_address
(re_frame, kInputString), ++ frame_entry_address(re_frame, kInputStart), ++ frame_entry_address(re_frame, kInputEnd)); ++} ++ ++MemOperand RegExpMacroAssemblerRISCV::register_location(int register_index) { ++ DCHECK(register_index < (1 << 30)); ++ if (num_registers_ <= register_index) { ++ num_registers_ = register_index + 1; ++ } ++ return MemOperand(frame_pointer(), ++ kRegisterZero - register_index * kPointerSize); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckPosition(int cp_offset, ++ Label* on_outside_input) { ++ if (cp_offset >= 0) { ++ BranchOrBacktrack(on_outside_input, ge, current_input_offset(), ++ Operand(-cp_offset * char_size())); ++ } else { ++ __ Ld(a1, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ __ Add64(a0, current_input_offset(), Operand(cp_offset * char_size())); ++ BranchOrBacktrack(on_outside_input, le, a0, Operand(a1)); ++ } ++} ++ ++void RegExpMacroAssemblerRISCV::BranchOrBacktrack(Label* to, ++ Condition condition, ++ Register rs, ++ const Operand& rt) { ++ if (condition == al) { // Unconditional. ++ if (to == nullptr) { ++ Backtrack(); ++ return; ++ } ++ __ jmp(to); ++ return; ++ } ++ if (to == nullptr) { ++ __ Branch(&backtrack_label_, condition, rs, rt); ++ return; ++ } ++ __ Branch(to, condition, rs, rt); ++} ++ ++void RegExpMacroAssemblerRISCV::SafeCall(Label* to, Condition cond, Register rs, ++ const Operand& rt) { ++ __ BranchAndLink(to, cond, rs, rt); ++} ++ ++void RegExpMacroAssemblerRISCV::SafeReturn() { ++ __ pop(ra); ++ __ Add64(t1, ra, Operand(masm_->CodeObject())); ++ __ Jump(t1); ++} ++ ++void RegExpMacroAssemblerRISCV::SafeCallTarget(Label* name) { ++ __ bind(name); ++ __ Sub64(ra, ra, Operand(masm_->CodeObject())); ++ __ push(ra); ++} ++ ++void RegExpMacroAssemblerRISCV::Push(Register source) { ++ DCHECK(source != backtrack_stackpointer()); ++ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), ++ Operand(-kIntSize)); ++ __ Sw(source, MemOperand(backtrack_stackpointer())); ++} ++ ++void RegExpMacroAssemblerRISCV::Pop(Register target) { ++ DCHECK(target != backtrack_stackpointer()); ++ __ Lw(target, MemOperand(backtrack_stackpointer())); ++ __ Add64(backtrack_stackpointer(), backtrack_stackpointer(), kIntSize); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckPreemption() { ++ // Check for preemption. ++ ExternalReference stack_limit = ++ ExternalReference::address_of_jslimit(masm_->isolate()); ++ __ li(a0, Operand(stack_limit)); ++ __ Ld(a0, MemOperand(a0)); ++ SafeCall(&check_preempt_label_, Uless_equal, sp, Operand(a0)); ++} ++ ++void RegExpMacroAssemblerRISCV::CheckStackLimit() { ++ ExternalReference stack_limit = ++ ExternalReference::address_of_regexp_stack_limit_address( ++ masm_->isolate()); ++ ++ __ li(a0, Operand(stack_limit)); ++ __ Ld(a0, MemOperand(a0)); ++ SafeCall(&stack_overflow_label_, Uless_equal, backtrack_stackpointer(), ++ Operand(a0)); ++} ++ ++void RegExpMacroAssemblerRISCV::LoadCurrentCharacterUnchecked(int cp_offset, ++ int characters) { ++ Register offset = current_input_offset(); ++ if (cp_offset != 0) { ++ // t4 is not being used to store the capture start index at this point. ++ __ Add64(t4, current_input_offset(), Operand(cp_offset * char_size())); ++ offset = t4; ++ } ++ // We assume that we cannot do unaligned loads on RISC-V, so this function ++ // must only be used to load a single character at a time. ++ DCHECK_EQ(1, characters); ++ __ Add64(t1, end_of_input_address(), Operand(offset)); ++ if (mode_ == LATIN1) { ++ __ Lbu(current_character(), MemOperand(t1, 0)); ++ } else { ++ DCHECK(mode_ == UC16); ++ __ Lhu(current_character(), MemOperand(t1, 0)); ++ } ++} ++ ++#undef __ ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_TARGET_ARCH_RISCV64 +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/regexp/riscv64/regexp-macro-assembler-riscv64.h +@@ -0,0 +1,213 @@ ++// Copyright 2011 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ ++#define V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ ++ ++#include "src/codegen/macro-assembler.h" ++#include "src/codegen/riscv64/assembler-riscv64.h" ++#include "src/regexp/regexp-macro-assembler.h" ++ ++namespace v8 { ++namespace internal { ++ ++class V8_EXPORT_PRIVATE RegExpMacroAssemblerRISCV ++ : public NativeRegExpMacroAssembler { ++ public: ++ RegExpMacroAssemblerRISCV(Isolate* isolate, Zone* zone, Mode mode, ++ int registers_to_save); ++ virtual ~RegExpMacroAssemblerRISCV(); ++ virtual int stack_limit_slack(); ++ virtual void AdvanceCurrentPosition(int by); ++ virtual void AdvanceRegister(int reg, int by); ++ virtual void Backtrack(); ++ virtual void Bind(Label* label); ++ virtual void CheckAtStart(int cp_offset, Label* on_at_start); ++ virtual void CheckCharacter(uint32_t c, Label* on_equal); ++ virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, ++ Label* on_equal); ++ virtual void CheckCharacterGT(uc16 limit, Label* on_greater); ++ virtual void CheckCharacterLT(uc16 limit, Label* on_less); ++ // A "greedy loop" is a loop that is both greedy and with a simple ++ // body. It has a particularly simple implementation. ++ virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); ++ virtual void CheckNotAtStart(int cp_offset, Label* on_not_at_start); ++ virtual void CheckNotBackReference(int start_reg, bool read_backward, ++ Label* on_no_match); ++ virtual void CheckNotBackReferenceIgnoreCase(int start_reg, ++ bool read_backward, bool unicode, ++ Label* on_no_match); ++ virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); ++ virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, ++ Label* on_not_equal); ++ virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask, ++ Label* on_not_equal); ++ virtual void CheckCharacterInRange(uc16 from, uc16 to, Label* on_in_range); ++ virtual void CheckCharacterNotInRange(uc16 from, uc16 to, ++ Label* on_not_in_range); ++ virtual void CheckBitInTable(Handle table, Label* on_bit_set); ++ ++ // Checks whether the given offset from the current position is before ++ // the end of the string. ++ virtual void CheckPosition(int cp_offset, Label* on_outside_input); ++ virtual bool CheckSpecialCharacterClass(uc16 type, Label* on_no_match); ++ virtual void Fail(); ++ virtual Handle GetCode(Handle source); ++ virtual void GoTo(Label* label); ++ virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); ++ virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); ++ virtual void IfRegisterEqPos(int reg, Label* if_eq); ++ virtual IrregexpImplementation Implementation(); ++ virtual void LoadCurrentCharacterUnchecked(int cp_offset, ++ int character_count); ++ virtual void PopCurrentPosition(); ++ virtual void PopRegister(int register_index); ++ virtual void PushBacktrack(Label* label); ++ virtual void PushCurrentPosition(); ++ virtual void PushRegister(int register_index, ++ StackCheckFlag check_stack_limit); ++ virtual void ReadCurrentPositionFromRegister(int reg); ++ virtual void ReadStackPointerFromRegister(int reg); ++ virtual void SetCurrentPositionFromEnd(int by); ++ virtual void SetRegister(int register_index, int to); ++ virtual bool Succeed(); ++ virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); ++ virtual void ClearRegisters(int reg_from, int reg_to); ++ virtual void WriteStackPointerToRegister(int reg); ++ virtual bool CanReadUnaligned(); ++ ++ // Called from RegExp if the stack-guard is triggered. ++ // If the code object is relocated, the return address is fixed before ++ // returning. ++ // {raw_code} is an Address because this is called via ExternalReference. ++ static int64_t CheckStackGuardState(Address* return_address, Address raw_code, ++ Address re_frame); ++ ++ void print_regexp_frame_constants(); ++ ++ private: ++ // Offsets from frame_pointer() of function parameters and stored registers. ++ static const int kFramePointer = 0; ++ ++ // Above the frame pointer - Stored registers and stack passed parameters. ++ // Registers s1 to s8, fp, and ra. ++ static const int kStoredRegisters = kFramePointer; ++ // Return address (stored from link register, read into pc on return). ++ ++ // This 9 is 8 s-regs (s1..s8) plus fp. ++ static const int kNumCalleeRegsToRetain = 9; ++ static const int kReturnAddress = ++ kStoredRegisters + kNumCalleeRegsToRetain * kPointerSize; ++ ++ // Stack frame header. ++ static const int kStackFrameHeader = kReturnAddress; ++ // Stack parameters placed by caller. ++ static const int kIsolate = kStackFrameHeader + kPointerSize; ++ ++ // Below the frame pointer. ++ // Register parameters stored by setup code. ++ static const int kDirectCall = kFramePointer - kPointerSize; ++ static const int kStackHighEnd = kDirectCall - kPointerSize; ++ static const int kNumOutputRegisters = kStackHighEnd - kPointerSize; ++ static const int kRegisterOutput = kNumOutputRegisters - kPointerSize; ++ static const int kInputEnd = kRegisterOutput - kPointerSize; ++ static const int kInputStart = kInputEnd - kPointerSize; ++ static const int kStartIndex = kInputStart - kPointerSize; ++ static const int kInputString = kStartIndex - kPointerSize; ++ // When adding local variables remember to push space for them in ++ // the frame in GetCode. ++ static const int kSuccessfulCaptures = kInputString - kPointerSize; ++ static const int kStringStartMinusOne = kSuccessfulCaptures - kPointerSize; ++ static const int kBacktrackCount = kStringStartMinusOne - kSystemPointerSize; ++ // First register address. Following registers are below it on the stack. ++ static const int kRegisterZero = kBacktrackCount - kSystemPointerSize; ++ ++ // Initial size of code buffer. ++ static const int kRegExpCodeSize = 1024; ++ ++ // Check whether preemption has been requested. ++ void CheckPreemption(); ++ ++ // Check whether we are exceeding the stack limit on the backtrack stack. ++ void CheckStackLimit(); ++ ++ // Generate a call to CheckStackGuardState. ++ void CallCheckStackGuardState(Register scratch); ++ ++ // The ebp-relative location of a regexp register. ++ MemOperand register_location(int register_index); ++ ++ // Register holding the current input position as negative offset from ++ // the end of the string. ++ inline Register current_input_offset() { return a6; } ++ ++ // The register containing the current character after LoadCurrentCharacter. ++ inline Register current_character() { return a7; } ++ ++ // Register holding address of the end of the input string. ++ inline Register end_of_input_address() { return t2; } ++ ++ // Register holding the frame address. Local variables, parameters and ++ // regexp registers are addressed relative to this. ++ inline Register frame_pointer() { return fp; } ++ ++ // The register containing the backtrack stack top. Provides a meaningful ++ // name to the register. ++ inline Register backtrack_stackpointer() { return t0; } ++ ++ // Register holding pointer to the current code object. ++ inline Register code_pointer() { return a5; } ++ ++ // Byte size of chars in the string to match (decided by the Mode argument). ++ inline int char_size() { return static_cast(mode_); } ++ ++ // Equivalent to a conditional branch to the label, unless the label ++ // is nullptr, in which case it is a conditional Backtrack. ++ void BranchOrBacktrack(Label* to, Condition condition, Register rs, ++ const Operand& rt); ++ ++ // Call and return internally in the generated code in a way that ++ // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) ++ inline void SafeCall(Label* to, Condition cond, Register rs, ++ const Operand& rt); ++ inline void SafeReturn(); ++ inline void SafeCallTarget(Label* name); ++ ++ // Pushes the value of a register on the backtrack stack. Decrements the ++ // stack pointer by a word size and stores the register's value there. ++ inline void Push(Register source); ++ ++ // Pops a value from the backtrack stack. Reads the word at the stack pointer ++ // and increments it by a word size. ++ inline void Pop(Register target); ++ ++ Isolate* isolate() const { return masm_->isolate(); } ++ ++ MacroAssembler* masm_; ++ ++ // Which mode to generate code for (Latin1 or UC16). ++ Mode mode_; ++ ++ // One greater than maximal register index actually used. ++ int num_registers_; ++ ++ // Number of registers to output at the end (the saved registers ++ // are always 0..num_saved_registers_-1). ++ int num_saved_registers_; ++ ++ // Labels used internally. ++ Label entry_label_; ++ Label start_label_; ++ Label success_label_; ++ Label backtrack_label_; ++ Label exit_label_; ++ Label check_preempt_label_; ++ Label stack_overflow_label_; ++ Label internal_failure_label_; ++}; ++ ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_REGEXP_RISCV_REGEXP_MACRO_ASSEMBLER_RISCV_H_ +--- a/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc ++++ b/src/3rdparty/chromium/v8/src/runtime/runtime-atomics.cc +@@ -19,7 +19,8 @@ + + // Other platforms have CSA support, see builtins-sharedarraybuffer-gen.h. + #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ +- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X ++ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X || \ ++ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + + namespace { + +@@ -568,6 +569,6 @@ + + #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 + // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X +- ++ // || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV + } // namespace internal + } // namespace v8 +--- a/src/3rdparty/chromium/v8/src/snapshot/deserializer.h ++++ b/src/3rdparty/chromium/v8/src/snapshot/deserializer.h +@@ -29,9 +29,10 @@ + + // Used for platforms with embedded constant pools to trigger deserialization + // of objects found in code. +-#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ +- defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ +- defined(V8_TARGET_ARCH_PPC64) || V8_EMBEDDED_CONSTANT_POOL ++#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \ ++ defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390) || \ ++ defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_RISCV64) || \ ++ defined(V8_TARGET_ARCH_RISCV) || V8_EMBEDDED_CONSTANT_POOL + #define V8_CODE_EMBEDS_OBJECT_POINTER 1 + #else + #define V8_CODE_EMBEDS_OBJECT_POINTER 0 +--- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h ++++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler-defs.h +@@ -69,6 +69,23 @@ + d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d16, d17, + d18, d19, d20, d21, d22, d23, d24, d25, d26, d27, d28, d29); + ++#elif V8_TARGET_ARCH_RISCV64 ++ ++// Any change of kLiftoffAssemblerGpCacheRegs also need to update ++// kPushedGpRegs in frame-constants-riscv64.h ++constexpr RegList kLiftoffAssemblerGpCacheRegs = ++ Register::ListOf(a0, a1, a2, a3, a4, a5, a6, a7, t0, t1, t2, s7); ++ ++// Any change of kLiftoffAssemblerGpCacheRegs also need to update ++// kPushedFpRegs in frame-constants-riscv64.h ++constexpr RegList kLiftoffAssemblerFpCacheRegs = ++ DoubleRegister::ListOf(ft0, ft1, ft2, ft3, ft4, ft5, ft6, ft7, fa0, fa1, ++ fa2, fa3, fa4, fa5, fa6, fa7, ft8, ft9, ft10, ft11); ++ ++#elif V8_TARGET_ARCH_RISCV ++ ++#error RISCV (32) architecture not supported yet ++ + #else + + constexpr RegList kLiftoffAssemblerGpCacheRegs = 0xff; +@@ -116,6 +133,18 @@ + constexpr Condition kUnsignedGreaterThan = hi; + constexpr Condition kUnsignedGreaterEqual = hs; + ++#elif V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV ++constexpr Condition kEqual = eq; ++constexpr Condition kUnequal = ne; ++constexpr Condition kSignedLessThan = lt; ++constexpr Condition kSignedLessEqual = le; ++constexpr Condition kSignedGreaterThan = gt; ++constexpr Condition kSignedGreaterEqual = ge; ++constexpr Condition kUnsignedLessThan = ult; ++constexpr Condition kUnsignedLessEqual = ule; ++constexpr Condition kUnsignedGreaterThan = ugt; ++constexpr Condition kUnsignedGreaterEqual = uge; ++ + #else + + // On unimplemented platforms, just make this compile. +--- a/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h ++++ b/src/3rdparty/chromium/v8/src/wasm/baseline/liftoff-assembler.h +@@ -1353,6 +1353,10 @@ + #include "src/wasm/baseline/mips64/liftoff-assembler-mips64.h" + #elif V8_TARGET_ARCH_S390 + #include "src/wasm/baseline/s390/liftoff-assembler-s390.h" ++#elif V8_TARGET_ARCH_RISCV64 ++#include "src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h" ++#elif V8_TARGET_ARCH_RISCV ++#include "src/wasm/baseline/riscv/liftoff-assembler-riscv.h" + #else + #error Unsupported architecture. + #endif +--- /dev/null ++++ b/src/3rdparty/chromium/v8/src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h +@@ -0,0 +1,2335 @@ ++// Copyright 2017 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ ++#define V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ ++ ++#include "src/wasm/baseline/liftoff-assembler.h" ++ ++namespace v8 { ++namespace internal { ++namespace wasm { ++ ++namespace liftoff { ++ ++// Liftoff Frames. ++// ++// slot Frame ++// +--------------------+--------------------------- ++// n+4 | optional padding slot to keep the stack 16 byte aligned. ++// n+3 | parameter n | ++// ... | ... | ++// 4 | parameter 1 | or parameter 2 ++// 3 | parameter 0 | or parameter 1 ++// 2 | (result address) | or parameter 0 ++// -----+--------------------+--------------------------- ++// 1 | return addr (ra) | ++// 0 | previous frame (fp)| ++// -----+--------------------+ <-- frame ptr (fp) ++// -1 | 0xa: WASM | ++// -2 | instance | ++// -----+--------------------+--------------------------- ++// -3 | slot 0 | ^ ++// -4 | slot 1 | | ++// | | Frame slots ++// | | | ++// | | v ++// | optional padding slot to keep the stack 16 byte aligned. ++// -----+--------------------+ <-- stack ptr (sp) ++// ++ ++// fp-8 holds the stack marker, fp-16 is the instance parameter. ++constexpr int kInstanceOffset = 16; ++ ++inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); } ++ ++inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } ++ ++inline void Load(LiftoffAssembler* assm, LiftoffRegister dst, MemOperand src, ++ ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->Lw(dst.gp(), src); ++ break; ++ case ValueType::kI64: ++ assm->Ld(dst.gp(), src); ++ break; ++ case ValueType::kF32: ++ assm->LoadFloat(dst.fp(), src); ++ break; ++ case ValueType::kF64: ++ assm->LoadDouble(dst.fp(), src); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++inline void Store(LiftoffAssembler* assm, Register base, int32_t offset, ++ LiftoffRegister src, ValueType type) { ++ MemOperand dst(base, offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->Usw(src.gp(), dst); ++ break; ++ case ValueType::kI64: ++ assm->Usd(src.gp(), dst); ++ break; ++ case ValueType::kF32: ++ assm->UStoreFloat(src.fp(), dst, t5); ++ break; ++ case ValueType::kF64: ++ assm->UStoreDouble(src.fp(), dst, t5); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++inline void push(LiftoffAssembler* assm, LiftoffRegister reg, ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kI32: ++ assm->addi(sp, sp, -kSystemPointerSize); ++ assm->Sw(reg.gp(), MemOperand(sp, 0)); ++ break; ++ case ValueType::kI64: ++ assm->push(reg.gp()); ++ break; ++ case ValueType::kF32: ++ assm->addi(sp, sp, -kSystemPointerSize); ++ assm->StoreFloat(reg.fp(), MemOperand(sp, 0)); ++ break; ++ case ValueType::kF64: ++ assm->addi(sp, sp, -kSystemPointerSize); ++ assm->StoreDouble(reg.fp(), MemOperand(sp, 0)); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++#if defined(V8_TARGET_BIG_ENDIAN) ++inline void ChangeEndiannessLoad(LiftoffAssembler* assm, LiftoffRegister dst, ++ LoadType type, LiftoffRegList pinned) { ++ bool is_float = false; ++ LiftoffRegister tmp = dst; ++ switch (type.value()) { ++ case LoadType::kI64Load8U: ++ case LoadType::kI64Load8S: ++ case LoadType::kI32Load8U: ++ case LoadType::kI32Load8S: ++ // No need to change endianness for byte size. ++ return; ++ case LoadType::kF32Load: ++ is_float = true; ++ tmp = assm->GetUnusedRegister(kGpReg, pinned); ++ assm->emit_type_conversion(kExprI32ReinterpretF32, tmp, dst); ++ V8_FALLTHROUGH; ++ case LoadType::kI64Load32U: ++ assm->TurboAssembler::ByteSwapUnsigned(tmp.gp(), tmp.gp(), 4); ++ break; ++ case LoadType::kI32Load: ++ case LoadType::kI64Load32S: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); ++ break; ++ case LoadType::kI32Load16S: ++ case LoadType::kI64Load16S: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); ++ break; ++ case LoadType::kI32Load16U: ++ case LoadType::kI64Load16U: ++ assm->TurboAssembler::ByteSwapUnsigned(tmp.gp(), tmp.gp(), 2); ++ break; ++ case LoadType::kF64Load: ++ is_float = true; ++ tmp = assm->GetUnusedRegister(kGpReg, pinned); ++ assm->emit_type_conversion(kExprI64ReinterpretF64, tmp, dst); ++ V8_FALLTHROUGH; ++ case LoadType::kI64Load: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 8); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ if (is_float) { ++ switch (type.value()) { ++ case LoadType::kF32Load: ++ assm->emit_type_conversion(kExprF32ReinterpretI32, dst, tmp); ++ break; ++ case LoadType::kF64Load: ++ assm->emit_type_conversion(kExprF64ReinterpretI64, dst, tmp); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++ ++inline void ChangeEndiannessStore(LiftoffAssembler* assm, LiftoffRegister src, ++ StoreType type, LiftoffRegList pinned) { ++ bool is_float = false; ++ LiftoffRegister tmp = src; ++ switch (type.value()) { ++ case StoreType::kI64Store8: ++ case StoreType::kI32Store8: ++ // No need to change endianness for byte size. ++ return; ++ case StoreType::kF32Store: ++ is_float = true; ++ tmp = assm->GetUnusedRegister(kGpReg, pinned); ++ assm->emit_type_conversion(kExprI32ReinterpretF32, tmp, src); ++ V8_FALLTHROUGH; ++ case StoreType::kI32Store: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); ++ break; ++ case StoreType::kI32Store16: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); ++ break; ++ case StoreType::kF64Store: ++ is_float = true; ++ tmp = assm->GetUnusedRegister(kGpReg, pinned); ++ assm->emit_type_conversion(kExprI64ReinterpretF64, tmp, src); ++ V8_FALLTHROUGH; ++ case StoreType::kI64Store: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 8); ++ break; ++ case StoreType::kI64Store32: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 4); ++ break; ++ case StoreType::kI64Store16: ++ assm->TurboAssembler::ByteSwapSigned(tmp.gp(), tmp.gp(), 2); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ if (is_float) { ++ switch (type.value()) { ++ case StoreType::kF32Store: ++ assm->emit_type_conversion(kExprF32ReinterpretI32, src, tmp); ++ break; ++ case StoreType::kF64Store: ++ assm->emit_type_conversion(kExprF64ReinterpretI64, src, tmp); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ } ++} ++#endif // V8_TARGET_BIG_ENDIAN ++ ++} // namespace liftoff ++ ++int LiftoffAssembler::PrepareStackFrame() { ++ int offset = pc_offset(); ++ // When constant that represents size of stack frame can't be represented ++ // as 16bit we need three instructions to add it to sp, so we reserve space ++ // for this case. ++ Add64(sp, sp, Operand(0L)); ++ nop(); ++ nop(); ++ return offset; ++} ++ ++void LiftoffAssembler::PrepareTailCall(int num_callee_stack_params, ++ int stack_param_delta) { ++ UseScratchRegisterScope temps(this); ++ Register scratch = temps.Acquire(); ++ ++ // Push the return address and frame pointer to complete the stack frame. ++ Ld(scratch, MemOperand(fp, 8)); ++ Push(scratch); ++ Ld(scratch, MemOperand(fp, 0)); ++ Push(scratch); ++ ++ // Shift the whole frame upwards. ++ int slot_count = num_callee_stack_params + 2; ++ for (int i = slot_count - 1; i >= 0; --i) { ++ Ld(scratch, MemOperand(sp, i * 8)); ++ Sd(scratch, MemOperand(fp, (i - stack_param_delta) * 8)); ++ } ++ ++ // Set the new stack and frame pointer. ++ Add64(sp, fp, -stack_param_delta * 8); ++ Pop(ra, fp); ++} ++ ++void LiftoffAssembler::PatchPrepareStackFrame(int offset, int frame_size) { ++ // We can't run out of space, just pass anything big enough to not cause the ++ // assembler to try to grow the buffer. ++ constexpr int kAvailableSpace = 256; ++ TurboAssembler patching_assembler( ++ nullptr, AssemblerOptions{}, CodeObjectRequired::kNo, ++ ExternalAssemblerBuffer(buffer_start_ + offset, kAvailableSpace)); ++ // If bytes can be represented as 16bit, addi will be generated and two ++ // nops will stay untouched. Otherwise, lui-ori sequence will load it to ++ // register and, as third instruction, daddu will be generated. ++ patching_assembler.Add64(sp, sp, Operand(-frame_size)); ++} ++ ++void LiftoffAssembler::FinishCode() {} ++ ++void LiftoffAssembler::AbortCompilation() {} ++ ++// static ++constexpr int LiftoffAssembler::StaticStackFrameSize() { ++ return liftoff::kInstanceOffset; ++} ++ ++int LiftoffAssembler::SlotSizeForType(ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kS128: ++ return type.element_size_bytes(); ++ default: ++ return kStackSlotSize; ++ } ++} ++ ++bool LiftoffAssembler::NeedsAlignment(ValueType type) { ++ switch (type.kind()) { ++ case ValueType::kS128: ++ return true; ++ default: ++ // No alignment because all other types are kStackSlotSize. ++ return false; ++ } ++} ++ ++void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value, ++ RelocInfo::Mode rmode) { ++ switch (value.type().kind()) { ++ case ValueType::kI32: ++ TurboAssembler::li(reg.gp(), Operand(value.to_i32(), rmode)); ++ break; ++ case ValueType::kI64: ++ TurboAssembler::li(reg.gp(), Operand(value.to_i64(), rmode)); ++ break; ++ case ValueType::kF32: ++ TurboAssembler::LoadFPRImmediate(reg.fp(), ++ value.to_f32_boxed().get_bits()); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::LoadFPRImmediate(reg.fp(), ++ value.to_f64_boxed().get_bits()); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::LoadFromInstance(Register dst, uint32_t offset, ++ int size) { ++ DCHECK_LE(offset, kMaxInt); ++ Ld(dst, liftoff::GetInstanceOperand()); ++ DCHECK(size == 4 || size == 8); ++ if (size == 4) { ++ Lw(dst, MemOperand(dst, offset)); ++ } else { ++ Ld(dst, MemOperand(dst, offset)); ++ } ++} ++ ++void LiftoffAssembler::LoadTaggedPointerFromInstance(Register dst, ++ uint32_t offset) { ++ LoadFromInstance(dst, offset, kTaggedSize); ++} ++ ++void LiftoffAssembler::SpillInstance(Register instance) { ++ Sd(instance, liftoff::GetInstanceOperand()); ++} ++ ++void LiftoffAssembler::FillInstanceInto(Register dst) { ++ Ld(dst, liftoff::GetInstanceOperand()); ++} ++ ++void LiftoffAssembler::LoadTaggedPointer(Register dst, Register src_addr, ++ Register offset_reg, ++ int32_t offset_imm, ++ LiftoffRegList pinned) { ++ STATIC_ASSERT(kTaggedSize == kInt64Size); ++ Load(LiftoffRegister(dst), src_addr, offset_reg, ++ static_cast(offset_imm), LoadType::kI64Load, pinned); ++} ++ ++void LiftoffAssembler::StoreTaggedPointer(Register dst_addr, ++ int32_t offset_imm, ++ LiftoffRegister src, ++ LiftoffRegList pinned) { ++ bailout(kRefTypes, "GlobalSet"); ++} ++ ++void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, LiftoffRegList pinned, ++ uint32_t* protected_load_pc, bool is_load_mem) { ++ Register src = no_reg; ++ if (offset_reg != no_reg) { ++ src = GetUnusedRegister(kGpReg, pinned).gp(); ++ emit_ptrsize_add(src, src_addr, offset_reg); ++ } ++ MemOperand src_op = (offset_reg != no_reg) ? MemOperand(src, offset_imm) ++ : MemOperand(src_addr, offset_imm); ++ ++ if (protected_load_pc) *protected_load_pc = pc_offset(); ++ switch (type.value()) { ++ case LoadType::kI32Load8U: ++ case LoadType::kI64Load8U: ++ Lbu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load8S: ++ case LoadType::kI64Load8S: ++ Lb(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load16U: ++ case LoadType::kI64Load16U: ++ TurboAssembler::Ulhu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load16S: ++ case LoadType::kI64Load16S: ++ TurboAssembler::Ulh(dst.gp(), src_op); ++ break; ++ case LoadType::kI64Load32U: ++ TurboAssembler::Ulwu(dst.gp(), src_op); ++ break; ++ case LoadType::kI32Load: ++ case LoadType::kI64Load32S: ++ TurboAssembler::Ulw(dst.gp(), src_op); ++ break; ++ case LoadType::kI64Load: ++ TurboAssembler::Uld(dst.gp(), src_op); ++ break; ++ case LoadType::kF32Load: ++ TurboAssembler::ULoadFloat(dst.fp(), src_op, t5); ++ break; ++ case LoadType::kF64Load: ++ TurboAssembler::ULoadDouble(dst.fp(), src_op, t5); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++#if defined(V8_TARGET_BIG_ENDIAN) ++ if (is_load_mem) { ++ pinned.set(src_op.rm()); ++ liftoff::ChangeEndiannessLoad(this, dst, type, pinned); ++ } ++#endif ++} ++ ++void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister src, ++ StoreType type, LiftoffRegList pinned, ++ uint32_t* protected_store_pc, bool is_store_mem) { ++ Register dst = no_reg; ++ MemOperand dst_op = MemOperand(dst_addr, offset_imm); ++ if (offset_reg != no_reg) { ++ if (is_store_mem) { ++ pinned.set(src); ++ } ++ dst = GetUnusedRegister(kGpReg, pinned).gp(); ++ emit_ptrsize_add(dst, dst_addr, offset_reg); ++ dst_op = MemOperand(dst, offset_imm); ++ } ++ ++#if defined(V8_TARGET_BIG_ENDIAN) ++ if (is_store_mem) { ++ pinned.set(dst_op.rm()); ++ LiftoffRegister tmp = GetUnusedRegister(src.reg_class(), pinned); ++ // Save original value. ++ Move(tmp, src, type.value_type()); ++ ++ src = tmp; ++ pinned.set(tmp); ++ liftoff::ChangeEndiannessStore(this, src, type, pinned); ++ } ++#endif ++ ++ if (protected_store_pc) *protected_store_pc = pc_offset(); ++ ++ // FIXME (RISCV): current implementation treats all stores as unaligned ++ switch (type.value()) { ++ case StoreType::kI32Store8: ++ case StoreType::kI64Store8: ++ Sb(src.gp(), dst_op); ++ break; ++ case StoreType::kI32Store16: ++ case StoreType::kI64Store16: ++ TurboAssembler::Ush(src.gp(), dst_op); ++ break; ++ case StoreType::kI32Store: ++ case StoreType::kI64Store32: ++ TurboAssembler::Usw(src.gp(), dst_op); ++ break; ++ case StoreType::kI64Store: ++ TurboAssembler::Usd(src.gp(), dst_op); ++ break; ++ case StoreType::kF32Store: ++ TurboAssembler::UStoreFloat(src.fp(), dst_op, t5); ++ break; ++ case StoreType::kF64Store: ++ TurboAssembler::UStoreDouble(src.fp(), dst_op, t5); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, LiftoffRegList pinned) { ++ bailout(kAtomics, "AtomicLoad"); ++} ++ ++void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister src, ++ StoreType type, LiftoffRegList pinned) { ++ bailout(kAtomics, "AtomicStore"); ++} ++ ++void LiftoffAssembler::AtomicAdd(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicAdd"); ++} ++ ++void LiftoffAssembler::AtomicSub(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicSub"); ++} ++ ++void LiftoffAssembler::AtomicAnd(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicAnd"); ++} ++ ++void LiftoffAssembler::AtomicOr(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicOr"); ++} ++ ++void LiftoffAssembler::AtomicXor(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicXor"); ++} ++ ++void LiftoffAssembler::AtomicExchange(Register dst_addr, Register offset_reg, ++ uint32_t offset_imm, ++ LiftoffRegister value, ++ LiftoffRegister result, StoreType type) { ++ bailout(kAtomics, "AtomicExchange"); ++} ++ ++void LiftoffAssembler::AtomicCompareExchange( ++ Register dst_addr, Register offset_reg, uint32_t offset_imm, ++ LiftoffRegister expected, LiftoffRegister new_value, LiftoffRegister result, ++ StoreType type) { ++ bailout(kAtomics, "AtomicCompareExchange"); ++} ++ ++void LiftoffAssembler::AtomicFence() { sync(); } ++ ++void LiftoffAssembler::LoadCallerFrameSlot(LiftoffRegister dst, ++ uint32_t caller_slot_idx, ++ ValueType type) { ++ MemOperand src(fp, kSystemPointerSize * (caller_slot_idx + 1)); ++ liftoff::Load(this, dst, src, type); ++} ++ ++void LiftoffAssembler::StoreCallerFrameSlot(LiftoffRegister src, ++ uint32_t caller_slot_idx, ++ ValueType type) { ++ int32_t offset = kSystemPointerSize * (caller_slot_idx + 1); ++ liftoff::Store(this, fp, offset, src, type); ++} ++ ++void LiftoffAssembler::LoadReturnStackSlot(LiftoffRegister dst, int offset, ++ ValueType type) { ++ liftoff::Load(this, dst, MemOperand(sp, offset), type); ++} ++ ++void LiftoffAssembler::MoveStackValue(uint32_t dst_offset, uint32_t src_offset, ++ ValueType type) { ++ DCHECK_NE(dst_offset, src_offset); ++ LiftoffRegister reg = GetUnusedRegister(reg_class_for(type), {}); ++ Fill(reg, src_offset, type); ++ Spill(dst_offset, reg, type); ++} ++ ++void LiftoffAssembler::Move(Register dst, Register src, ValueType type) { ++ DCHECK_NE(dst, src); ++ // TODO(ksreten): Handle different sizes here. ++ TurboAssembler::Move(dst, src); ++} ++ ++void LiftoffAssembler::Move(DoubleRegister dst, DoubleRegister src, ++ ValueType type) { ++ DCHECK_NE(dst, src); ++ TurboAssembler::Move(dst, src); ++} ++ ++void LiftoffAssembler::Spill(int offset, LiftoffRegister reg, ValueType type) { ++ RecordUsedSpillOffset(offset); ++ MemOperand dst = liftoff::GetStackSlot(offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ Sw(reg.gp(), dst); ++ break; ++ case ValueType::kI64: ++ Sd(reg.gp(), dst); ++ break; ++ case ValueType::kF32: ++ StoreFloat(reg.fp(), dst); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::StoreDouble(reg.fp(), dst); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Spill(int offset, WasmValue value) { ++ RecordUsedSpillOffset(offset); ++ MemOperand dst = liftoff::GetStackSlot(offset); ++ switch (value.type().kind()) { ++ case ValueType::kI32: { ++ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); ++ TurboAssembler::li(tmp.gp(), Operand(value.to_i32())); ++ Sw(tmp.gp(), dst); ++ break; ++ } ++ case ValueType::kI64: { ++ LiftoffRegister tmp = GetUnusedRegister(kGpReg, {}); ++ TurboAssembler::li(tmp.gp(), value.to_i64()); ++ Sd(tmp.gp(), dst); ++ break; ++ } ++ default: ++ // kWasmF32 and kWasmF64 are unreachable, since those ++ // constants are not tracked. ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::Fill(LiftoffRegister reg, int offset, ValueType type) { ++ MemOperand src = liftoff::GetStackSlot(offset); ++ switch (type.kind()) { ++ case ValueType::kI32: ++ Lw(reg.gp(), src); ++ break; ++ case ValueType::kI64: ++ Ld(reg.gp(), src); ++ break; ++ case ValueType::kF32: ++ LoadFloat(reg.fp(), src); ++ break; ++ case ValueType::kF64: ++ TurboAssembler::LoadDouble(reg.fp(), src); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++} ++ ++void LiftoffAssembler::FillI64Half(Register, int offset, RegPairHalf) { ++ UNREACHABLE(); ++} ++ ++void LiftoffAssembler::FillStackSlotsWithZero(int start, int size) { ++ DCHECK_LT(0, size); ++ RecordUsedSpillOffset(start + size); ++ ++ if (size <= 12 * kStackSlotSize) { ++ // Special straight-line code for up to 12 slots. Generates one ++ // instruction per slot (<= 12 instructions total). ++ uint32_t remainder = size; ++ for (; remainder >= kStackSlotSize; remainder -= kStackSlotSize) { ++ Sd(zero_reg, liftoff::GetStackSlot(start + remainder)); ++ } ++ DCHECK(remainder == 4 || remainder == 0); ++ if (remainder) { ++ Sw(zero_reg, liftoff::GetStackSlot(start + remainder)); ++ } ++ } else { ++ // General case for bigger counts (12 instructions). ++ // Use a0 for start address (inclusive), a1 for end address (exclusive). ++ Push(a1, a0); ++ Add64(a0, fp, Operand(-start - size)); ++ Add64(a1, fp, Operand(-start)); ++ ++ Label loop; ++ bind(&loop); ++ Sd(zero_reg, MemOperand(a0)); ++ addi(a0, a0, kSystemPointerSize); ++ BranchShort(&loop, ne, a0, Operand(a1)); ++ ++ Pop(a1, a0); ++ } ++} ++ ++void LiftoffAssembler::emit_i64_clz(LiftoffRegister dst, LiftoffRegister src) { ++ TurboAssembler::Clz64(dst.gp(), src.gp()); ++} ++ ++void LiftoffAssembler::emit_i64_ctz(LiftoffRegister dst, LiftoffRegister src) { ++ TurboAssembler::Ctz64(dst.gp(), src.gp()); ++} ++ ++bool LiftoffAssembler::emit_i64_popcnt(LiftoffRegister dst, ++ LiftoffRegister src) { ++ TurboAssembler::Popcnt64(dst.gp(), src.gp()); ++ return true; ++} ++ ++void LiftoffAssembler::emit_i32_mul(Register dst, Register lhs, Register rhs) { ++ TurboAssembler::Mul32(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero, ++ Label* trap_div_unrepresentable) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ ++ // Check if lhs == kMinInt and rhs == -1, since this case is unrepresentable. ++ TurboAssembler::CompareI(kScratchReg, lhs, Operand(kMinInt), ne); ++ TurboAssembler::CompareI(kScratchReg2, rhs, Operand(-1), ne); ++ add(kScratchReg, kScratchReg, kScratchReg2); ++ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, ++ Operand(zero_reg)); ++ ++ TurboAssembler::Div32(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Divu32(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Mod32(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_i32_remu(Register dst, Register lhs, Register rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs, Operand(zero_reg)); ++ TurboAssembler::Modu32(dst, lhs, rhs); ++} ++ ++#define I32_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name(Register dst, Register lhs, \ ++ Register rhs) { \ ++ instruction(dst, lhs, rhs); \ ++ } ++ ++// clang-format off ++I32_BINOP(add, addw) ++I32_BINOP(sub, subw) ++I32_BINOP(and, and_) ++I32_BINOP(or, or_) ++I32_BINOP(xor, xor_) ++// clang-format on ++ ++#undef I32_BINOP ++ ++#define I32_BINOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register lhs, \ ++ int32_t imm) { \ ++ instruction(dst, lhs, Operand(imm)); \ ++ } ++ ++// clang-format off ++I32_BINOP_I(add, Add32) ++I32_BINOP_I(and, And) ++I32_BINOP_I(or, Or) ++I32_BINOP_I(xor, Xor) ++// clang-format on ++ ++#undef I32_BINOP_I ++ ++void LiftoffAssembler::emit_i32_clz(Register dst, Register src) { ++ TurboAssembler::Clz32(dst, src); ++} ++ ++void LiftoffAssembler::emit_i32_ctz(Register dst, Register src) { ++ TurboAssembler::Ctz32(dst, src); ++} ++ ++bool LiftoffAssembler::emit_i32_popcnt(Register dst, Register src) { ++ TurboAssembler::Popcnt32(dst, src); ++ return true; ++} ++ ++#define I32_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name(Register dst, Register src, \ ++ Register amount) { \ ++ instruction(dst, src, amount); \ ++ } ++#define I32_SHIFTOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i32_##name##i(Register dst, Register src, \ ++ int amount) { \ ++ instruction(dst, src, amount); \ ++ } ++ ++I32_SHIFTOP(shl, sllw) ++I32_SHIFTOP(sar, sraw) ++I32_SHIFTOP(shr, srlw) ++ ++I32_SHIFTOP_I(shl, slliw) ++I32_SHIFTOP_I(sar, sraiw) ++I32_SHIFTOP_I(shr, srliw) ++ ++#undef I32_SHIFTOP ++#undef I32_SHIFTOP_I ++ ++void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ TurboAssembler::Mul64(dst.gp(), lhs.gp(), rhs.gp()); ++} ++ ++bool LiftoffAssembler::emit_i64_divs(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero, ++ Label* trap_div_unrepresentable) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ ++ // Check if lhs == MinInt64 and rhs == -1, since this case is unrepresentable. ++ TurboAssembler::CompareI(kScratchReg, lhs.gp(), ++ Operand(std::numeric_limits::min()), ne); ++ TurboAssembler::CompareI(kScratchReg2, rhs.gp(), Operand(-1), ne); ++ add(kScratchReg, kScratchReg, kScratchReg2); ++ TurboAssembler::Branch(trap_div_unrepresentable, eq, kScratchReg, ++ Operand(zero_reg)); ++ ++ TurboAssembler::Div64(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_divu(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Divu64(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_rems(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Mod64(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_i64_remu(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ Label* trap_div_by_zero) { ++ TurboAssembler::Branch(trap_div_by_zero, eq, rhs.gp(), Operand(zero_reg)); ++ TurboAssembler::Modu64(dst.gp(), lhs.gp(), rhs.gp()); ++ return true; ++} ++ ++#define I64_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name( \ ++ LiftoffRegister dst, LiftoffRegister lhs, LiftoffRegister rhs) { \ ++ instruction(dst.gp(), lhs.gp(), rhs.gp()); \ ++ } ++ ++// clang-format off ++I64_BINOP(add, add) ++I64_BINOP(sub, sub) ++I64_BINOP(and, and_) ++I64_BINOP(or, or_) ++I64_BINOP(xor, xor_) ++// clang-format on ++ ++#undef I64_BINOP ++ ++#define I64_BINOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name##i( \ ++ LiftoffRegister dst, LiftoffRegister lhs, int32_t imm) { \ ++ instruction(dst.gp(), lhs.gp(), Operand(imm)); \ ++ } ++ ++// clang-format off ++I64_BINOP_I(add, Add64) ++I64_BINOP_I(and, And) ++I64_BINOP_I(or, Or) ++I64_BINOP_I(xor, Xor) ++// clang-format on ++ ++#undef I64_BINOP_I ++ ++#define I64_SHIFTOP(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name( \ ++ LiftoffRegister dst, LiftoffRegister src, Register amount) { \ ++ instruction(dst.gp(), src.gp(), amount); \ ++ } ++#define I64_SHIFTOP_I(name, instruction) \ ++ void LiftoffAssembler::emit_i64_##name##i(LiftoffRegister dst, \ ++ LiftoffRegister src, int amount) { \ ++ DCHECK(is_uint6(amount)); \ ++ instruction(dst.gp(), src.gp(), amount); \ ++ } ++ ++I64_SHIFTOP(shl, sll) ++I64_SHIFTOP(sar, sra) ++I64_SHIFTOP(shr, srl) ++ ++I64_SHIFTOP_I(shl, slli) ++I64_SHIFTOP_I(sar, srai) ++I64_SHIFTOP_I(shr, srli) ++ ++#undef I64_SHIFTOP ++#undef I64_SHIFTOP_I ++ ++void LiftoffAssembler::emit_u32_to_intptr(Register dst, Register src) { ++ addw(dst, src, zero_reg); ++} ++ ++void LiftoffAssembler::emit_f32_neg(DoubleRegister dst, DoubleRegister src) { ++ TurboAssembler::Neg_s(dst, src); ++} ++ ++void LiftoffAssembler::emit_f64_neg(DoubleRegister dst, DoubleRegister src) { ++ TurboAssembler::Neg_d(dst, src); ++} ++ ++void LiftoffAssembler::emit_f32_min(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ TurboAssembler::Float32Min(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_f32_max(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ TurboAssembler::Float32Max(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_f32_copysign(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ bailout(kComplexOperation, "f32_copysign"); ++} ++ ++void LiftoffAssembler::emit_f64_min(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ TurboAssembler::Float64Min(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_f64_max(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ TurboAssembler::Float64Max(dst, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_f64_copysign(DoubleRegister dst, DoubleRegister lhs, ++ DoubleRegister rhs) { ++ bailout(kComplexOperation, "f64_copysign"); ++} ++ ++#define FP_BINOP(name, instruction) \ ++ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister lhs, \ ++ DoubleRegister rhs) { \ ++ instruction(dst, lhs, rhs); \ ++ } ++#define FP_UNOP(name, instruction) \ ++ void LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ ++ instruction(dst, src); \ ++ } ++#define FP_UNOP_RETURN_TRUE(name, instruction) \ ++ bool LiftoffAssembler::emit_##name(DoubleRegister dst, DoubleRegister src) { \ ++ instruction(dst, src, kScratchDoubleReg); \ ++ return true; \ ++ } ++ ++FP_BINOP(f32_add, fadd_s) ++FP_BINOP(f32_sub, fsub_s) ++FP_BINOP(f32_mul, fmul_s) ++FP_BINOP(f32_div, fdiv_s) ++FP_UNOP(f32_abs, fabs_s) ++FP_UNOP_RETURN_TRUE(f32_ceil, Ceil_s_s) ++FP_UNOP_RETURN_TRUE(f32_floor, Floor_s_s) ++FP_UNOP_RETURN_TRUE(f32_trunc, Trunc_s_s) ++FP_UNOP_RETURN_TRUE(f32_nearest_int, Round_s_s) ++FP_UNOP(f32_sqrt, fsqrt_s) ++FP_BINOP(f64_add, fadd_d) ++FP_BINOP(f64_sub, fsub_d) ++FP_BINOP(f64_mul, fmul_d) ++FP_BINOP(f64_div, fdiv_d) ++FP_UNOP(f64_abs, fabs_d) ++FP_UNOP_RETURN_TRUE(f64_ceil, Ceil_d_d) ++FP_UNOP_RETURN_TRUE(f64_floor, Floor_d_d) ++FP_UNOP_RETURN_TRUE(f64_trunc, Trunc_d_d) ++FP_UNOP_RETURN_TRUE(f64_nearest_int, Round_d_d) ++FP_UNOP(f64_sqrt, fsqrt_d) ++ ++#undef FP_BINOP ++#undef FP_UNOP ++#undef FP_UNOP_RETURN_TRUE ++ ++bool LiftoffAssembler::emit_type_conversion(WasmOpcode opcode, ++ LiftoffRegister dst, ++ LiftoffRegister src, Label* trap) { ++ switch (opcode) { ++ case kExprI32ConvertI64: ++ // According to WebAssembly spec, if I64 value does not fit the range of ++ // I32, the value is undefined. Therefore, We use sign extension to ++ // implement I64 to I32 truncation ++ TurboAssembler::SignExtendWord(dst.gp(), src.gp()); ++ return true; ++ case kExprI32SConvertF32: ++ case kExprI32UConvertF32: ++ case kExprI32SConvertF64: ++ case kExprI32UConvertF64: ++ case kExprI64SConvertF32: ++ case kExprI64UConvertF32: ++ case kExprI64SConvertF64: ++ case kExprI64UConvertF64: ++ case kExprF32ConvertF64: { ++ // real conversion, if src is out-of-bound of target integer types, ++ // kScratchReg is set to 0 ++ switch (opcode) { ++ case kExprI32SConvertF32: ++ Trunc_w_s(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI32UConvertF32: ++ Trunc_uw_s(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI32SConvertF64: ++ Trunc_w_d(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI32UConvertF64: ++ Trunc_uw_d(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI64SConvertF32: ++ Trunc_l_s(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI64UConvertF32: ++ Trunc_ul_s(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI64SConvertF64: ++ Trunc_l_d(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprI64UConvertF64: ++ Trunc_ul_d(dst.gp(), src.fp(), kScratchReg); ++ break; ++ case kExprF32ConvertF64: ++ fcvt_s_d(dst.fp(), src.fp()); ++ // FIXME (?): what if double cannot be represented by float? ++ // Trunc_s_d(dst.gp(), src.fp(), kScratchReg); ++ break; ++ default: ++ UNREACHABLE(); ++ } ++ ++ // Checking if trap. ++ TurboAssembler::Branch(trap, eq, kScratchReg, Operand(zero_reg)); ++ ++ return true; ++ } ++ case kExprI32ReinterpretF32: ++ TurboAssembler::ExtractLowWordFromF64(dst.gp(), src.fp()); ++ return true; ++ case kExprI64SConvertI32: ++ TurboAssembler::SignExtendWord(dst.gp(), src.gp()); ++ return true; ++ case kExprI64UConvertI32: ++ TurboAssembler::ZeroExtendWord(dst.gp(), src.gp()); ++ return true; ++ case kExprI64ReinterpretF64: ++ fmv_x_d(dst.gp(), src.fp()); ++ return true; ++ case kExprF32SConvertI32: { ++ TurboAssembler::Cvt_s_w(dst.fp(), src.gp()); ++ return true; ++ } ++ case kExprF32UConvertI32: ++ TurboAssembler::Cvt_s_uw(dst.fp(), src.gp()); ++ return true; ++ case kExprF32ReinterpretI32: ++ fmv_w_x(dst.fp(), src.gp()); ++ return true; ++ case kExprF64SConvertI32: { ++ TurboAssembler::Cvt_d_w(dst.fp(), src.gp()); ++ return true; ++ } ++ case kExprF64UConvertI32: ++ TurboAssembler::Cvt_d_uw(dst.fp(), src.gp()); ++ return true; ++ case kExprF64ConvertF32: ++ fcvt_d_s(dst.fp(), src.fp()); ++ return true; ++ case kExprF64ReinterpretI64: ++ fmv_d_x(dst.fp(), src.gp()); ++ return true; ++ case kExprI32SConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF32"); ++ return true; ++ case kExprI32UConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF32"); ++ return true; ++ case kExprI32SConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI32SConvertSatF64"); ++ return true; ++ case kExprI32UConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI32UConvertSatF64"); ++ return true; ++ case kExprI64SConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF32"); ++ return true; ++ case kExprI64UConvertSatF32: ++ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF32"); ++ return true; ++ case kExprI64SConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI64SConvertSatF64"); ++ return true; ++ case kExprI64UConvertSatF64: ++ bailout(kNonTrappingFloatToInt, "kExprI64UConvertSatF64"); ++ return true; ++ default: ++ return false; ++ } ++} ++ ++void LiftoffAssembler::emit_i32_signextend_i8(Register dst, Register src) { ++ slliw(dst, src, 32 - 8); ++ sraiw(dst, dst, 32 - 8); ++} ++ ++void LiftoffAssembler::emit_i32_signextend_i16(Register dst, Register src) { ++ slliw(dst, src, 32 - 16); ++ sraiw(dst, dst, 32 - 16); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i8(LiftoffRegister dst, ++ LiftoffRegister src) { ++ slli(dst.gp(), src.gp(), 64 - 8); ++ srai(dst.gp(), dst.gp(), 64 - 8); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i16(LiftoffRegister dst, ++ LiftoffRegister src) { ++ slli(dst.gp(), src.gp(), 64 - 16); ++ srai(dst.gp(), dst.gp(), 64 - 16); ++} ++ ++void LiftoffAssembler::emit_i64_signextend_i32(LiftoffRegister dst, ++ LiftoffRegister src) { ++ slli(dst.gp(), src.gp(), 64 - 32); ++ srai(dst.gp(), dst.gp(), 64 - 32); ++} ++ ++void LiftoffAssembler::emit_jump(Label* label) { ++ TurboAssembler::Branch(label); ++} ++ ++void LiftoffAssembler::emit_jump(Register target) { ++ TurboAssembler::Jump(target); ++} ++ ++void LiftoffAssembler::emit_cond_jump(Condition cond, Label* label, ++ ValueType type, Register lhs, ++ Register rhs) { ++ if (rhs != no_reg) { ++ TurboAssembler::Branch(label, cond, lhs, Operand(rhs)); ++ } else { ++ TurboAssembler::Branch(label, cond, lhs, Operand(zero_reg)); ++ } ++} ++ ++void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) { ++ TurboAssembler::Sltu(dst, src, 1); ++} ++ ++void LiftoffAssembler::emit_i32_set_cond(Condition cond, Register dst, ++ Register lhs, Register rhs) { ++ TurboAssembler::CompareI(dst, lhs, Operand(rhs), cond); ++} ++ ++void LiftoffAssembler::emit_i64_eqz(Register dst, LiftoffRegister src) { ++ TurboAssembler::Sltu(dst, src.gp(), 1); ++} ++ ++void LiftoffAssembler::emit_i64_set_cond(Condition cond, Register dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ TurboAssembler::CompareI(dst, lhs.gp(), Operand(rhs.gp()), cond); ++} ++ ++static FPUCondition ConditionToConditionCmpFPU(Condition condition) { ++ switch (condition) { ++ case kEqual: ++ return EQ; ++ case kUnequal: ++ return NE; ++ case kUnsignedLessThan: ++ return LT; ++ case kUnsignedGreaterEqual: ++ return GE; ++ case kUnsignedLessEqual: ++ return LE; ++ case kUnsignedGreaterThan: ++ return GT; ++ default: ++ break; ++ } ++ UNREACHABLE(); ++} ++ ++void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst, ++ DoubleRegister lhs, ++ DoubleRegister rhs) { ++ FPUCondition fcond = ConditionToConditionCmpFPU(cond); ++ TurboAssembler::CompareF32(dst, fcond, lhs, rhs); ++} ++ ++void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ++ DoubleRegister lhs, ++ DoubleRegister rhs) { ++ FPUCondition fcond = ConditionToConditionCmpFPU(cond); ++ TurboAssembler::CompareF64(dst, fcond, lhs, rhs); ++} ++ ++bool LiftoffAssembler::emit_select(LiftoffRegister dst, Register condition, ++ LiftoffRegister true_value, ++ LiftoffRegister false_value, ++ ValueType type) { ++ return false; ++} ++ ++void LiftoffAssembler::LoadTransform(LiftoffRegister dst, Register src_addr, ++ Register offset_reg, uint32_t offset_imm, ++ LoadType type, ++ LoadTransformationKind transform, ++ uint32_t* protected_load_pc) { ++ bailout(kSimd, "load extend and load splat unimplemented"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs, ++ const uint8_t shuffle[16], ++ bool is_swizzle) { ++ bailout(kSimd, "emit_i8x16_shuffle"); ++} ++ ++void LiftoffAssembler::emit_i8x16_swizzle(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_swizzle"); ++} ++ ++void LiftoffAssembler::emit_i8x16_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_splat"); ++} ++ ++void LiftoffAssembler::emit_i16x8_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_splat"); ++} ++ ++void LiftoffAssembler::emit_i32x4_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_splat"); ++} ++ ++void LiftoffAssembler::emit_i64x2_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i64x2_splat"); ++} ++ ++void LiftoffAssembler::emit_f32x4_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_splat"); ++} ++ ++void LiftoffAssembler::emit_f64x2_splat(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_splat"); ++} ++ ++void LiftoffAssembler::emit_i8x16_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_eq"); ++} ++ ++void LiftoffAssembler::emit_i8x16_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_ne"); ++} ++ ++void LiftoffAssembler::emit_i8x16_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_gt_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_gt_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_ge_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_ge_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_eq"); ++} ++ ++void LiftoffAssembler::emit_i16x8_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_ne"); ++} ++ ++void LiftoffAssembler::emit_i16x8_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_gt_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_gt_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_ge_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_ge_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_eq"); ++} ++ ++void LiftoffAssembler::emit_i32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_ne"); ++} ++ ++void LiftoffAssembler::emit_i32x4_gt_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_gt_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_gt_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_gt_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_ge_s(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_ge_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_ge_u(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_ge_u"); ++} ++ ++void LiftoffAssembler::emit_f32x4_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_eq"); ++} ++ ++void LiftoffAssembler::emit_f32x4_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_ne"); ++} ++ ++void LiftoffAssembler::emit_f32x4_lt(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_lt"); ++} ++ ++void LiftoffAssembler::emit_f32x4_le(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_le"); ++} ++ ++void LiftoffAssembler::emit_f64x2_eq(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_eq"); ++} ++ ++void LiftoffAssembler::emit_f64x2_ne(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_ne"); ++} ++ ++void LiftoffAssembler::emit_f64x2_lt(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_lt"); ++} ++ ++void LiftoffAssembler::emit_f64x2_le(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_le"); ++} ++ ++void LiftoffAssembler::emit_s128_const(LiftoffRegister dst, ++ const uint8_t imms[16]) { ++ bailout(kSimd, "emit_s128_const"); ++} ++ ++void LiftoffAssembler::emit_s128_not(LiftoffRegister dst, LiftoffRegister src) { ++ bailout(kSimd, "emit_s128_not"); ++} ++ ++void LiftoffAssembler::emit_s128_and(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_s128_and"); ++} ++ ++void LiftoffAssembler::emit_s128_or(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_s128_or"); ++} ++ ++void LiftoffAssembler::emit_s128_xor(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_s128_xor"); ++} ++ ++void LiftoffAssembler::emit_s128_and_not(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_s128_and_not"); ++} ++ ++void LiftoffAssembler::emit_s128_select(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ LiftoffRegister mask) { ++ bailout(kSimd, "emit_s128_select"); ++} ++ ++void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_neg"); ++} ++ ++void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_anytrue"); ++} ++ ++void LiftoffAssembler::emit_v8x16_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_alltrue"); ++} ++ ++void LiftoffAssembler::emit_i8x16_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_bitmask"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_shl"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) { ++ bailout(kSimd, "emit_i8x16_shli"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_shr_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i8x16_shri_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_shr_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i8x16_shri_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_add"); ++} ++ ++void LiftoffAssembler::emit_i8x16_add_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_add_saturate_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_add_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_add_saturate_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_sub"); ++} ++ ++void LiftoffAssembler::emit_i8x16_sub_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_sub_saturate_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_sub_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_sub_saturate_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_mul"); ++} ++ ++void LiftoffAssembler::emit_i8x16_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_min_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_min_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_max_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_max_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_neg"); ++} ++ ++void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_anytrue"); ++} ++ ++void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_alltrue"); ++} ++ ++void LiftoffAssembler::emit_i16x8_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_bitmask"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_shl"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) { ++ bailout(kSimd, "emit_i16x8_shli"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_shr_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i16x8_shri_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_shr_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i16x8_shri_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_add"); ++} ++ ++void LiftoffAssembler::emit_i16x8_add_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_add_saturate_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_add_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_add_saturate_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_sub"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sub_saturate_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_sub_saturate_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sub_saturate_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_sub_saturate_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_mul"); ++} ++ ++void LiftoffAssembler::emit_i16x8_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_min_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_min_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_max_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_max_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_neg"); ++} ++ ++void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_v32x4_anytrue"); ++} ++ ++void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_v32x4_alltrue"); ++} ++ ++void LiftoffAssembler::emit_i32x4_bitmask(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_bitmask"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_shl"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) { ++ bailout(kSimd, "emit_i32x4_shli"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_shr_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i32x4_shri_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_shr_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i32x4_shri_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_add"); ++} ++ ++void LiftoffAssembler::emit_i32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_sub"); ++} ++ ++void LiftoffAssembler::emit_i32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_mul"); ++} ++ ++void LiftoffAssembler::emit_i32x4_min_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_min_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_min_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_min_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_max_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_max_s"); ++} ++ ++void LiftoffAssembler::emit_i32x4_max_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i32x4_max_u"); ++} ++ ++void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i64x2_neg"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shl(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_shl"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shli(LiftoffRegister dst, LiftoffRegister lhs, ++ int32_t rhs) { ++ bailout(kSimd, "emit_i64x2_shli"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shr_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_shr_s"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shri_s(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i64x2_shri_s"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shr_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_shr_u"); ++} ++ ++void LiftoffAssembler::emit_i64x2_shri_u(LiftoffRegister dst, ++ LiftoffRegister lhs, int32_t rhs) { ++ bailout(kSimd, "emit_i64x2_shri_u"); ++} ++ ++void LiftoffAssembler::emit_i64x2_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_add"); ++} ++ ++void LiftoffAssembler::emit_i64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_sub"); ++} ++ ++void LiftoffAssembler::emit_i64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i64x2_mul"); ++} ++ ++void LiftoffAssembler::emit_f32x4_abs(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_abs"); ++} ++ ++void LiftoffAssembler::emit_f32x4_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_neg"); ++} ++ ++void LiftoffAssembler::emit_f32x4_sqrt(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_sqrt"); ++} ++ ++bool LiftoffAssembler::emit_f32x4_ceil(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_ceil"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f32x4_floor(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_floor"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f32x4_trunc(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_trunc"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f32x4_nearest_int(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_nearest_int"); ++ return true; ++} ++ ++void LiftoffAssembler::emit_f32x4_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_add"); ++} ++ ++void LiftoffAssembler::emit_f32x4_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_sub"); ++} ++ ++void LiftoffAssembler::emit_f32x4_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_mul"); ++} ++ ++void LiftoffAssembler::emit_f32x4_div(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_div"); ++} ++ ++void LiftoffAssembler::emit_f32x4_min(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_min"); ++} ++ ++void LiftoffAssembler::emit_f32x4_max(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_max"); ++} ++ ++void LiftoffAssembler::emit_f32x4_pmin(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_pmin"); ++} ++ ++void LiftoffAssembler::emit_f32x4_pmax(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f32x4_pmax"); ++} ++ ++void LiftoffAssembler::emit_f64x2_abs(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_abs"); ++} ++ ++void LiftoffAssembler::emit_f64x2_neg(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_neg"); ++} ++ ++void LiftoffAssembler::emit_f64x2_sqrt(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_sqrt"); ++} ++ ++bool LiftoffAssembler::emit_f64x2_ceil(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_ceil"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f64x2_floor(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_floor"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f64x2_trunc(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_trunc"); ++ return true; ++} ++ ++bool LiftoffAssembler::emit_f64x2_nearest_int(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f64x2_nearest_int"); ++ return true; ++} ++ ++void LiftoffAssembler::emit_f64x2_add(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_add"); ++} ++ ++void LiftoffAssembler::emit_f64x2_sub(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_sub"); ++} ++ ++void LiftoffAssembler::emit_f64x2_mul(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_mul"); ++} ++ ++void LiftoffAssembler::emit_f64x2_div(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_div"); ++} ++ ++void LiftoffAssembler::emit_f64x2_min(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_min"); ++} ++ ++void LiftoffAssembler::emit_f64x2_max(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_max"); ++} ++ ++void LiftoffAssembler::emit_f64x2_pmin(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_pmin"); ++} ++ ++void LiftoffAssembler::emit_f64x2_pmax(LiftoffRegister dst, LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_f64x2_pmax"); ++} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_f32x4(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_sconvert_f32x4"); ++} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_f32x4(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_uconvert_f32x4"); ++} ++ ++void LiftoffAssembler::emit_f32x4_sconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_sconvert_i32x4"); ++} ++ ++void LiftoffAssembler::emit_f32x4_uconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_f32x4_uconvert_i32x4"); ++} ++ ++void LiftoffAssembler::emit_i8x16_sconvert_i16x8(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_sconvert_i16x8"); ++} ++ ++void LiftoffAssembler::emit_i8x16_uconvert_i16x8(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_uconvert_i16x8"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_sconvert_i32x4"); ++} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i32x4(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_uconvert_i32x4"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i8x16_low(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_sconvert_i8x16_low"); ++} ++ ++void LiftoffAssembler::emit_i16x8_sconvert_i8x16_high(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_sconvert_i8x16_high"); ++} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i8x16_low(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_uconvert_i8x16_low"); ++} ++ ++void LiftoffAssembler::emit_i16x8_uconvert_i8x16_high(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_uconvert_i8x16_high"); ++} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_i16x8_low(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_sconvert_i16x8_low"); ++} ++ ++void LiftoffAssembler::emit_i32x4_sconvert_i16x8_high(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_sconvert_i16x8_high"); ++} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_i16x8_low(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_uconvert_i16x8_low"); ++} ++ ++void LiftoffAssembler::emit_i32x4_uconvert_i16x8_high(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_uconvert_i16x8_high"); ++} ++ ++void LiftoffAssembler::emit_i8x16_rounding_average_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i8x16_rounding_average_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_rounding_average_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ LiftoffRegister rhs) { ++ bailout(kSimd, "emit_i16x8_rounding_average_u"); ++} ++ ++void LiftoffAssembler::emit_i8x16_abs(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i8x16_abs"); ++} ++ ++void LiftoffAssembler::emit_i16x8_abs(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i16x8_abs"); ++} ++ ++void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst, ++ LiftoffRegister src) { ++ bailout(kSimd, "emit_i32x4_abs"); ++} ++ ++void LiftoffAssembler::emit_i8x16_extract_lane_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i8x16_extract_lane_s"); ++} ++ ++void LiftoffAssembler::emit_i8x16_extract_lane_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i8x16_extract_lane_u"); ++} ++ ++void LiftoffAssembler::emit_i16x8_extract_lane_s(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i16x8_extract_lane_s"); ++} ++ ++void LiftoffAssembler::emit_i16x8_extract_lane_u(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i16x8_extract_lane_u"); ++} ++ ++void LiftoffAssembler::emit_i32x4_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i32x4_extract_lane"); ++} ++ ++void LiftoffAssembler::emit_i64x2_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i64x2_extract_lane"); ++} ++ ++void LiftoffAssembler::emit_f32x4_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_f32x4_extract_lane"); ++} ++ ++void LiftoffAssembler::emit_f64x2_extract_lane(LiftoffRegister dst, ++ LiftoffRegister lhs, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_f64x2_extract_lane"); ++} ++ ++void LiftoffAssembler::emit_i8x16_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i8x16_replace_lane"); ++} ++ ++void LiftoffAssembler::emit_i16x8_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i16x8_replace_lane"); ++} ++ ++void LiftoffAssembler::emit_i32x4_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i32x4_replace_lane"); ++} ++ ++void LiftoffAssembler::emit_i64x2_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_i64x2_replace_lane"); ++} ++ ++void LiftoffAssembler::emit_f32x4_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_f32x4_replace_lane"); ++} ++ ++void LiftoffAssembler::emit_f64x2_replace_lane(LiftoffRegister dst, ++ LiftoffRegister src1, ++ LiftoffRegister src2, ++ uint8_t imm_lane_idx) { ++ bailout(kSimd, "emit_f64x2_replace_lane"); ++} ++ ++void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) { ++ TurboAssembler::Uld(limit_address, MemOperand(limit_address)); ++ TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address)); ++} ++ ++void LiftoffAssembler::CallTrapCallbackForTesting() { ++ PrepareCallCFunction(0, GetUnusedRegister(kGpReg, {}).gp()); ++ CallCFunction(ExternalReference::wasm_call_trap_callback_for_testing(), 0); ++} ++ ++void LiftoffAssembler::AssertUnreachable(AbortReason reason) { ++ if (emit_debug_code()) Abort(reason); ++} ++ ++void LiftoffAssembler::PushRegisters(LiftoffRegList regs) { ++ LiftoffRegList gp_regs = regs & kGpCacheRegList; ++ unsigned num_gp_regs = gp_regs.GetNumRegsSet(); ++ if (num_gp_regs) { ++ unsigned offset = num_gp_regs * kSystemPointerSize; ++ Add64(sp, sp, Operand(-offset)); ++ while (!gp_regs.is_empty()) { ++ LiftoffRegister reg = gp_regs.GetFirstRegSet(); ++ offset -= kSystemPointerSize; ++ Sd(reg.gp(), MemOperand(sp, offset)); ++ gp_regs.clear(reg); ++ } ++ DCHECK_EQ(offset, 0); ++ } ++ LiftoffRegList fp_regs = regs & kFpCacheRegList; ++ unsigned num_fp_regs = fp_regs.GetNumRegsSet(); ++ if (num_fp_regs) { ++ Add64(sp, sp, Operand(-(num_fp_regs * kStackSlotSize))); ++ unsigned offset = 0; ++ while (!fp_regs.is_empty()) { ++ LiftoffRegister reg = fp_regs.GetFirstRegSet(); ++ TurboAssembler::StoreDouble(reg.fp(), MemOperand(sp, offset)); ++ fp_regs.clear(reg); ++ offset += sizeof(double); ++ } ++ DCHECK_EQ(offset, num_fp_regs * sizeof(double)); ++ } ++} ++ ++void LiftoffAssembler::PopRegisters(LiftoffRegList regs) { ++ LiftoffRegList fp_regs = regs & kFpCacheRegList; ++ unsigned fp_offset = 0; ++ while (!fp_regs.is_empty()) { ++ LiftoffRegister reg = fp_regs.GetFirstRegSet(); ++ TurboAssembler::LoadDouble(reg.fp(), MemOperand(sp, fp_offset)); ++ fp_regs.clear(reg); ++ fp_offset += sizeof(double); ++ } ++ if (fp_offset) Add64(sp, sp, Operand(fp_offset)); ++ LiftoffRegList gp_regs = regs & kGpCacheRegList; ++ unsigned gp_offset = 0; ++ while (!gp_regs.is_empty()) { ++ LiftoffRegister reg = gp_regs.GetLastRegSet(); ++ Ld(reg.gp(), MemOperand(sp, gp_offset)); ++ gp_regs.clear(reg); ++ gp_offset += kSystemPointerSize; ++ } ++ Add64(sp, sp, Operand(gp_offset)); ++} ++ ++void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) { ++ TurboAssembler::DropAndRet(static_cast(num_stack_slots)); ++} ++ ++void LiftoffAssembler::CallC(const wasm::FunctionSig* sig, ++ const LiftoffRegister* args, ++ const LiftoffRegister* rets, ++ ValueType out_argument_type, int stack_bytes, ++ ExternalReference ext_ref) { ++ Add64(sp, sp, Operand(-stack_bytes)); ++ ++ int arg_bytes = 0; ++ for (ValueType param_type : sig->parameters()) { ++ liftoff::Store(this, sp, arg_bytes, *args++, param_type); ++ arg_bytes += param_type.element_size_bytes(); ++ } ++ DCHECK_LE(arg_bytes, stack_bytes); ++ ++ // Pass a pointer to the buffer with the arguments to the C function. ++ // On RISC-V, the first argument is passed in {a0}. ++ constexpr Register kFirstArgReg = a0; ++ mv(kFirstArgReg, sp); ++ ++ // Now call the C function. ++ constexpr int kNumCCallArgs = 1; ++ PrepareCallCFunction(kNumCCallArgs, kScratchReg); ++ CallCFunction(ext_ref, kNumCCallArgs); ++ ++ // Move return value to the right register. ++ const LiftoffRegister* next_result_reg = rets; ++ if (sig->return_count() > 0) { ++ DCHECK_EQ(1, sig->return_count()); ++ constexpr Register kReturnReg = a0; ++ if (kReturnReg != next_result_reg->gp()) { ++ Move(*next_result_reg, LiftoffRegister(kReturnReg), sig->GetReturn(0)); ++ } ++ ++next_result_reg; ++ } ++ ++ // Load potential output value from the buffer on the stack. ++ if (out_argument_type != kWasmStmt) { ++ liftoff::Load(this, *next_result_reg, MemOperand(sp, 0), out_argument_type); ++ } ++ ++ Add64(sp, sp, Operand(stack_bytes)); ++} ++ ++void LiftoffAssembler::CallNativeWasmCode(Address addr) { ++ Call(addr, RelocInfo::WASM_CALL); ++} ++ ++void LiftoffAssembler::TailCallNativeWasmCode(Address addr) { ++ Jump(addr, RelocInfo::WASM_CALL); ++} ++ ++void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig, ++ compiler::CallDescriptor* call_descriptor, ++ Register target) { ++ if (target == no_reg) { ++ pop(kScratchReg); ++ Call(kScratchReg); ++ } else { ++ Call(target); ++ } ++} ++ ++void LiftoffAssembler::TailCallIndirect(Register target) { ++ if (target == no_reg) { ++ Pop(kScratchReg); ++ Jump(kScratchReg); ++ } else { ++ Jump(target); ++ } ++} ++ ++void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) { ++ // A direct call to a wasm runtime stub defined in this module. ++ // Just encode the stub index. This will be patched at relocation. ++ Call(static_cast
(sid), RelocInfo::WASM_STUB_CALL); ++} ++ ++void LiftoffAssembler::AllocateStackSlot(Register addr, uint32_t size) { ++ Add64(sp, sp, Operand(-size)); ++ TurboAssembler::Move(addr, sp); ++} ++ ++void LiftoffAssembler::DeallocateStackSlot(uint32_t size) { ++ Add64(sp, sp, Operand(size)); ++} ++ ++void LiftoffStackSlots::Construct() { ++ for (auto& slot : slots_) { ++ const LiftoffAssembler::VarState& src = slot.src_; ++ switch (src.loc()) { ++ case LiftoffAssembler::VarState::kStack: ++ asm_->Ld(kScratchReg, liftoff::GetStackSlot(slot.src_offset_)); ++ asm_->push(kScratchReg); ++ break; ++ case LiftoffAssembler::VarState::kRegister: ++ liftoff::push(asm_, src.reg(), src.type()); ++ break; ++ case LiftoffAssembler::VarState::kIntConst: { ++ asm_->li(kScratchReg, Operand(src.i32_const())); ++ asm_->push(kScratchReg); ++ break; ++ } ++ } ++ } ++} ++ ++} // namespace wasm ++} // namespace internal ++} // namespace v8 ++ ++#endif // V8_WASM_BASELINE_RISCV_LIFTOFF_ASSEMBLER_RISCV_H_ +--- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc ++++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.cc +@@ -307,6 +307,40 @@ + } + } + ++#elif V8_TARGET_ARCH_RISCV64 ++void JumpTableAssembler::EmitLazyCompileJumpSlot(uint32_t func_index, ++ Address lazy_compile_target) { ++ int start = pc_offset(); ++ li(kWasmCompileLazyFuncIndexRegister, func_index); // max. 2 instr ++ // Jump produces max. 9 instructions (8 for li + 1 for jr) ++ Jump(lazy_compile_target, RelocInfo::NONE); ++ int nop_bytes = start + kLazyCompileTableSlotSize - pc_offset(); ++ DCHECK_EQ(nop_bytes % kInstrSize, 0); ++ for (int i = 0; i < nop_bytes; i += kInstrSize) nop(); ++} ++ ++bool JumpTableAssembler::EmitJumpSlot(Address target) { ++ PatchAndJump(target); ++ return true; ++} ++ ++void JumpTableAssembler::EmitFarJumpSlot(Address target) { ++ JumpToInstructionStream(target); ++} ++ ++// static ++void JumpTableAssembler::PatchFarJumpSlot(Address slot, Address target) { ++ UNREACHABLE(); ++} ++ ++void JumpTableAssembler::NopBytes(int bytes) { ++ DCHECK_LE(0, bytes); ++ DCHECK_EQ(0, bytes % kInstrSize); ++ for (; bytes > 0; bytes -= kInstrSize) { ++ nop(); ++ } ++} ++ + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h ++++ b/src/3rdparty/chromium/v8/src/wasm/jump-table-assembler.h +@@ -215,6 +215,11 @@ + static constexpr int kJumpTableSlotSize = 8 * kInstrSize; + static constexpr int kFarJumpTableSlotSize = 6 * kInstrSize; + static constexpr int kLazyCompileTableSlotSize = 8 * kInstrSize; ++#elif V8_TARGET_ARCH_RISCV64 ++ static constexpr int kJumpTableLineSize = 6 * kInstrSize; ++ static constexpr int kJumpTableSlotSize = 6 * kInstrSize; ++ static constexpr int kFarJumpTableSlotSize = 9 * kInstrSize; ++ static constexpr int kLazyCompileTableSlotSize = 9 * kInstrSize; + #else + #error Unknown architecture. + #endif +--- a/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h ++++ b/src/3rdparty/chromium/v8/src/wasm/wasm-linkage.h +@@ -102,6 +102,22 @@ + constexpr DoubleRegister kFpParamRegisters[] = {d0, d2}; + constexpr DoubleRegister kFpReturnRegisters[] = {d0, d2}; + ++#elif V8_TARGET_ARCH_RISCV64 ++// =========================================================================== ++// == riscv64 ================================================================= ++// =========================================================================== ++// Note that kGpParamRegisters and kFpParamRegisters are used in ++// Builtins::Generate_WasmCompileLazy (builtins-riscv64.cc) ++constexpr Register kGpParamRegisters[] = {a0, a2, a3, a4, a5, a6, a7}; ++constexpr Register kGpReturnRegisters[] = {a0, a1}; ++constexpr DoubleRegister kFpParamRegisters[] = {fa0, fa1, fa2, fa3, ++ fa4, fa5, fa6}; ++constexpr DoubleRegister kFpReturnRegisters[] = {fa0, fa1}; ++ ++#elif V8_TARGET_ARCH_RISCV ++ ++#error RISCV(32) architecture not supported ++ + #else + // =========================================================================== + // == unknown ================================================================ +--- a/src/3rdparty/chromium/v8/src/wasm/wasm-serialization.cc ++++ b/src/3rdparty/chromium/v8/src/wasm/wasm-serialization.cc +@@ -368,7 +368,8 @@ + writer->WriteVector(code->source_positions()); + writer->WriteVector(code->protected_instructions_data()); + #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM || \ +- V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X ++ V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X || \ ++ V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV32 + // On platforms that don't support misaligned word stores, copy to an aligned + // buffer if necessary so we can relocate the serialized code. + std::unique_ptr aligned_buffer; +--- a/configure.pri ++++ b/configure.pri +@@ -123,6 +123,7 @@ + contains(QT_ARCH, "arm")|contains(QT_ARCH, "arm64"): return(true) + contains(QT_ARCH, "mips"): return(true) + contains(QT_ARCH, "mips64"): return(true) ++ contains(QT_ARCH, "riscv64"): return(true) + qtLog("Architecture not supported.") + return(false) + } +--- a/mkspecs/features/functions.prf ++++ b/mkspecs/features/functions.prf +@@ -112,6 +112,7 @@ + contains(qtArch, "mips"): return(mipsel) + contains(qtArch, "mips64"): return(mips64el) + contains(qtArch, "mips64el"): return(mips64el) ++ contains(qtArch, "riscv64"): return(riscv64) + return(unknown) + } + +--- a/src/3rdparty/chromium/base/process/launch_posix.cc ++++ b/src/3rdparty/chromium/base/process/launch_posix.cc +@@ -704,7 +704,7 @@ + alignas(16) char stack_buf[PTHREAD_STACK_MIN]; + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_S390_FAMILY) || \ +- defined(ARCH_CPU_PPC64_FAMILY) ++ defined(ARCH_CPU_PPC64_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) + // The stack grows downward. + void* stack = stack_buf + sizeof(stack_buf); + #else +--- a/src/3rdparty/chromium/build/build_config.h ++++ b/src/3rdparty/chromium/build/build_config.h +@@ -193,6 +193,11 @@ + #define ARCH_CPU_32_BITS 1 + #define ARCH_CPU_BIG_ENDIAN 1 + #endif ++#elif defined(__riscv) && __riscv_xlen == 64 ++#define ARCH_CPU_RISCV_FAMILY 1 ++#define ARCH_CPU_RISCV64 1 ++#define ARCH_CPU_64_BITS 1 ++#define ARCH_CPU_LITTLE_ENDIAN 1 + #else + #error Please add support for your architecture in build/build_config.h + #endif +--- a/src/3rdparty/chromium/build/config/BUILD.gn ++++ b/src/3rdparty/chromium/build/config/BUILD.gn +@@ -238,6 +238,7 @@ + "dl", + "pthread", + "rt", ++ "atomic", + ] + } + } +--- a/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn ++++ b/src/3rdparty/chromium/build/toolchain/linux/BUILD.gn +@@ -298,3 +298,20 @@ + is_clang = false + } + } ++ ++gcc_toolchain("riscv64") { ++ cc = "gcc" ++ cxx = "g++" ++ ++ readelf = "readelf" ++ nm = "nm" ++ ar = "ar" ++ ld = cxx ++ ++ toolchain_args = { ++ current_cpu = "riscv64" ++ current_os = "linux" ++ is_clang = false ++ } ++} ++ +--- a/src/3rdparty/chromium/sandbox/features.gni ++++ b/src/3rdparty/chromium/sandbox/features.gni +@@ -11,7 +11,8 @@ + use_seccomp_bpf = (is_linux || is_chromeos || is_android) && + (current_cpu == "x86" || current_cpu == "x64" || + current_cpu == "arm" || current_cpu == "arm64" || +- current_cpu == "mipsel" || current_cpu == "mips64el") ++ current_cpu == "mipsel" || current_cpu == "mips64el" || ++ current_cpu == "riscv64") + + use_seccomp_bpf = use_seccomp_bpf || is_nacl_nonsfi + +--- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h ++++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/linux_syscall_ranges.h +@@ -49,6 +49,12 @@ + #define MAX_PUBLIC_SYSCALL __NR_syscalls + #define MAX_SYSCALL MAX_PUBLIC_SYSCALL + ++#elif defined(__riscv) ++ ++#define MIN_SYSCALL 0u ++#define MAX_PUBLIC_SYSCALL 1024u ++#define MAX_SYSCALL MAX_PUBLIC_SYSCALL ++ + #else + #error "Unsupported architecture" + #endif +--- a/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h ++++ b/src/3rdparty/chromium/sandbox/linux/bpf_dsl/seccomp_macros.h +@@ -346,6 +346,46 @@ + #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3] + #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4] + #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5] ++ ++#elif defined(__riscv) ++struct regs_struct { ++ unsigned long regs[32]; ++}; ++ ++#define SECCOMP_ARCH AUDIT_ARCH_RISCV64 ++ ++#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg]) ++ ++#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_A0) ++#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_A0+7) ++#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__gregs[REG_PC] ++#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_A0) ++#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_A0+1) ++#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_A0+2) ++#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_A0+3) ++#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_A0+4) ++#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_A0+5) ++ ++#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr)) ++#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch)) ++#define SECCOMP_IP_MSB_IDX \ ++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4) ++#define SECCOMP_IP_LSB_IDX \ ++ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0) ++#define SECCOMP_ARG_MSB_IDX(nr) \ ++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4) ++#define SECCOMP_ARG_LSB_IDX(nr) \ ++ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0) ++ ++#define SECCOMP_PT_RESULT(_regs) (_regs).regs[REG_A0] ++#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[REG_A0+7] ++#define SECCOMP_PT_IP(_regs) (_regs).regs[REG_PC] ++#define SECCOMP_PT_PARM1(_regs) (_regs).regs[REG_A0] ++#define SECCOMP_PT_PARM2(_regs) (_regs).regs[REG_A0+1] ++#define SECCOMP_PT_PARM3(_regs) (_regs).regs[REG_A0+2] ++#define SECCOMP_PT_PARM4(_regs) (_regs).regs[REG_A0+3] ++#define SECCOMP_PT_PARM5(_regs) (_regs).regs[REG_A0+4] ++#define SECCOMP_PT_PARM6(_regs) (_regs).regs[REG_A0+5] + #else + #error Unsupported target platform + +--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc ++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +@@ -181,7 +181,7 @@ + return RestrictFcntlCommands(); + #endif + +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + // fork() is never used as a system call (clone() is used instead), but we + // have seen it in fallback code on Android. + if (sysno == __NR_fork) { +@@ -231,7 +231,7 @@ + } + + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + if (sysno == __NR_mmap) + return RestrictMmapFlags(); + #endif +@@ -249,7 +249,7 @@ + return RestrictPrctl(); + + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + if (sysno == __NR_socketpair) { + // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen. + static_assert(AF_UNIX == PF_UNIX, +--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc +@@ -37,7 +37,7 @@ + #include + #include + #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(__arm__) && \ +- !defined(__aarch64__) && !defined(PTRACE_GET_THREAD_AREA) ++ !defined(__aarch64__) && !defined(__riscv) && !defined(PTRACE_GET_THREAD_AREA) + // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance + // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA. + // asm/ptrace-abi.h doesn't exist on arm32 and PTRACE_GET_THREAD_AREA isn't +@@ -410,7 +410,7 @@ + ResultExpr RestrictPtrace() { + const Arg request(0); + return Switch(request).CASES(( +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + PTRACE_GETREGS, + PTRACE_GETFPREGS, + #if defined(TRACE_GET_THREAD_AREA) +--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc ++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc +@@ -86,7 +86,7 @@ + // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. + bool SyscallSets::IsFileSystem(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_access: // EPERM not a valid errno. + case __NR_chmod: + case __NR_chown: +@@ -118,7 +118,7 @@ + case __NR_faccessat: // EPERM not a valid errno. + case __NR_fchmodat: + case __NR_fchownat: // Should be called chownat ? +-#if defined(__x86_64__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv) + case __NR_newfstatat: // fstatat(). EPERM not a valid errno. + #elif defined(__i386__) || defined(__arm__) || \ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) +@@ -202,7 +202,7 @@ + case __NR_oldfstat: + #endif + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_sync_file_range: // EPERM not a valid errno. + #elif defined(__arm__) + case __NR_arm_sync_file_range: // EPERM not a valid errno. +@@ -226,7 +226,7 @@ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR_ftruncate64: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_getdents: // EPERM not a valid errno. + #endif + case __NR_getdents64: // EPERM not a valid errno. +@@ -305,7 +305,7 @@ + bool SyscallSets::IsProcessGroupOrSession(int sysno) { + switch (sysno) { + case __NR_setpgid: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_getpgrp: + #endif + case __NR_setsid: +@@ -334,7 +334,7 @@ + case __NR_rt_sigsuspend: + case __NR_rt_tgsigqueueinfo: + case __NR_sigaltstack: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_signalfd: + #endif + case __NR_signalfd4: +@@ -358,12 +358,12 @@ + switch (sysno) { + case __NR_close: + case __NR_dup: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_dup2: + #endif + case __NR_dup3: + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_shutdown: + #endif + return true; +@@ -402,7 +402,7 @@ + return true; + case __NR_clone: // Should be parameter-restricted. + case __NR_setns: // Privileged. +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_fork: + #endif + #if defined(__i386__) || defined(__x86_64__) +@@ -413,7 +413,7 @@ + #endif + case __NR_set_tid_address: + case __NR_unshare: +-#if !defined(__mips__) && !defined(__aarch64__) ++#if !defined(__mips__) && !defined(__aarch64__) && !defined(__riscv) + case __NR_vfork: + #endif + default: +@@ -434,7 +434,7 @@ + + bool SyscallSets::IsAllowedEpoll(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_epoll_create: + case __NR_epoll_wait: + #endif +@@ -455,14 +455,14 @@ + + bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_pipe: + #endif + case __NR_pipe2: + return true; + default: + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_socketpair: // We will want to inspect its argument. + #endif + return false; +@@ -472,7 +472,7 @@ + bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { + switch (sysno) { + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_accept: + case __NR_accept4: + case __NR_bind: +@@ -526,7 +526,7 @@ + case __NR_mincore: + case __NR_mlockall: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_mmap: + #endif + #if defined(__i386__) || defined(__arm__) || \ +@@ -559,7 +559,7 @@ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR__llseek: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_poll: + #endif + case __NR_ppoll: +@@ -572,7 +572,7 @@ + case __NR_recv: + #endif + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_recvfrom: // Could specify source. + case __NR_recvmsg: // Could specify source. + #endif +@@ -587,7 +587,7 @@ + case __NR_send: + #endif + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_sendmsg: // Could specify destination. + case __NR_sendto: // Could specify destination. + #endif +@@ -637,7 +637,7 @@ + bool SyscallSets::IsAllowedBasicScheduler(int sysno) { + switch (sysno) { + case __NR_sched_yield: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_pause: + #endif + case __NR_nanosleep: +@@ -721,7 +721,7 @@ + case __NR_getcpu: + case __NR_mbind: + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_migrate_pages: + #endif + case __NR_move_pages: +@@ -750,7 +750,7 @@ + switch (sysno) { + case __NR_acct: // Privileged. + #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + case __NR_getrlimit: + #endif + #if defined(__i386__) || defined(__arm__) +@@ -785,7 +785,7 @@ + + bool SyscallSets::IsGlobalSystemStatus(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR__sysctl: + case __NR_sysfs: + #endif +@@ -803,7 +803,7 @@ + + bool SyscallSets::IsEventFd(int sysno) { + switch (sysno) { +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_eventfd: + #endif + case __NR_eventfd2: +@@ -839,7 +839,8 @@ + } + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + bool SyscallSets::IsSystemVSemaphores(int sysno) { + switch (sysno) { + case __NR_semctl: +@@ -855,7 +856,8 @@ + + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + // These give a lot of ambient authority and bypass the setuid sandbox. + bool SyscallSets::IsSystemVSharedMemory(int sysno) { + switch (sysno) { +@@ -871,7 +873,8 @@ + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + bool SyscallSets::IsSystemVMessageQueue(int sysno) { + switch (sysno) { + case __NR_msgctl: +@@ -902,7 +905,8 @@ + + bool SyscallSets::IsAnySystemV(int sysno) { + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || + IsSystemVSharedMemory(sysno); + #elif defined(__i386__) || \ +@@ -935,7 +939,7 @@ + bool SyscallSets::IsInotify(int sysno) { + switch (sysno) { + case __NR_inotify_add_watch: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_inotify_init: + #endif + case __NR_inotify_init1: +@@ -1066,7 +1070,7 @@ + #if defined(__x86_64__) + case __NR_tuxcall: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_vserver: + #endif + return true; +--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h ++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h +@@ -49,7 +49,7 @@ + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + static bool IsNetworkSocketInformation(int sysno); + #endif + +@@ -72,18 +72,21 @@ + static bool IsAsyncIo(int sysno); + static bool IsKeyManagement(int sysno); + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + static bool IsSystemVSemaphores(int sysno); + #endif + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + // These give a lot of ambient authority and bypass the setuid sandbox. + static bool IsSystemVSharedMemory(int sysno); + #endif + + #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ +- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) ++ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(__riscv) + static bool IsSystemVMessageQueue(int sysno); + #endif + +--- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc ++++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf/syscall.cc +@@ -18,7 +18,7 @@ + namespace { + + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ +- defined(ARCH_CPU_MIPS_FAMILY) ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) + // Number that's not currently used by any Linux kernel ABIs. + const int kInvalidSyscallNumber = 0x351d3; + #else +@@ -312,6 +312,28 @@ + "2:ret\n" + ".cfi_endproc\n" + ".size SyscallAsm, .-SyscallAsm\n" ++#elif defined(__riscv) ++ ".text\n" ++ ".align 2\n" ++ ".type SyscallAsm, %function\n" ++ "SyscallAsm:\n" ++ ".cfi_startproc\n" ++ "bgez a0,1f\n" ++ "la a0,2f\n" ++ "j 2f\n" ++ "1:mv a7, a0\n" ++ "ld a0, (t0)\n" ++ "ld a1, 8(t0)\n" ++ "ld a2, 16(t0)\n" ++ "ld a3, 24(t0)\n" ++ "ld a4, 32(t0)\n" ++ "ld a5, 40(t0)\n" ++ "ld a6, 48(t0)\n" ++ // Enter the kernel ++ "scall\n" ++ "2:ret\n" ++ ".cfi_endproc\n" ++ ".size SyscallAsm, .-SyscallAsm\n" + #endif + ); // asm + +@@ -429,6 +451,18 @@ + ret = inout; + } + ++#elif defined(__riscv) ++ intptr_t ret; ++ { ++ register intptr_t inout __asm__("a0") = nr; ++ register const intptr_t* data __asm__("t0") = args; ++ asm volatile("jal SyscallAsm\n" ++ : "+r"(inout) ++ : "r"(data) ++ : "memory", "a1", "a2", "a3", "a4", "a5", "a6"); ++ ret = inout; ++ } ++ + #else + #error "Unimplemented architecture" + #endif +--- a/src/3rdparty/chromium/sandbox/linux/services/credentials.cc ++++ b/src/3rdparty/chromium/sandbox/linux/services/credentials.cc +@@ -81,7 +81,7 @@ + pid_t pid = -1; + alignas(16) char stack_buf[PTHREAD_STACK_MIN]; + #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \ +- defined(ARCH_CPU_MIPS_FAMILY) ++ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY) + // The stack grows downward. + void* stack = stack_buf + sizeof(stack_buf); + #else +--- a/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc ++++ b/src/3rdparty/chromium/sandbox/linux/syscall_broker/broker_process.cc +@@ -128,43 +128,43 @@ + // and are default disabled in Android. So, we should refuse to broker them + // to be consistent with the platform's restrictions. + switch (sysno) { +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_access: + #endif + case __NR_faccessat: + return !fast_check || allowed_command_set_.test(COMMAND_ACCESS); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_mkdir: + #endif + case __NR_mkdirat: + return !fast_check || allowed_command_set_.test(COMMAND_MKDIR); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_open: + #endif + case __NR_openat: + return !fast_check || allowed_command_set_.test(COMMAND_OPEN); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_readlink: + #endif + case __NR_readlinkat: + return !fast_check || allowed_command_set_.test(COMMAND_READLINK); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_rename: + #endif + case __NR_renameat: + case __NR_renameat2: + return !fast_check || allowed_command_set_.test(COMMAND_RENAME); + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_rmdir: + return !fast_check || allowed_command_set_.test(COMMAND_RMDIR); + #endif + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_stat: + case __NR_lstat: + #endif +@@ -174,7 +174,7 @@ + #if defined(__NR_fstatat64) + case __NR_fstatat64: + #endif +-#if defined(__x86_64__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv) + case __NR_newfstatat: + #endif + return !fast_check || allowed_command_set_.test(COMMAND_STAT); +@@ -189,7 +189,7 @@ + return !fast_check || allowed_command_set_.test(COMMAND_STAT); + #endif + +-#if !defined(__aarch64__) && !defined(OS_ANDROID) ++#if !defined(__aarch64__) && !defined(OS_ANDROID) && !defined(__riscv) + case __NR_unlink: + return !fast_check || allowed_command_set_.test(COMMAND_UNLINK); + #endif +--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h ++++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_seccomp.h +@@ -41,6 +41,9 @@ + #ifndef EM_AARCH64 + #define EM_AARCH64 183 + #endif ++#ifndef EM_RISCV ++#define EM_RISCV 243 ++#endif + + #ifndef __AUDIT_ARCH_64BIT + #define __AUDIT_ARCH_64BIT 0x80000000 +@@ -73,6 +76,9 @@ + #ifndef AUDIT_ARCH_AARCH64 + #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE) + #endif ++#ifndef AUDIT_ARCH_RISCV64 ++#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) ++#endif + + // For prctl.h + #ifndef PR_SET_SECCOMP +--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h ++++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_signal.h +@@ -13,7 +13,7 @@ + // (not undefined, but defined different values and in different memory + // layouts). So, fill the gap here. + #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ +- defined(__aarch64__) ++ defined(__aarch64__) || defined(__riscv) + + #define LINUX_SIGHUP 1 + #define LINUX_SIGINT 2 +--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h ++++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_stat.h +@@ -150,7 +150,7 @@ + int st_blocks; + int st_pad4[14]; + }; +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__riscv) + struct kernel_stat { + unsigned long st_dev; + unsigned long st_ino; +--- a/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h ++++ b/src/3rdparty/chromium/sandbox/linux/system_headers/linux_syscalls.h +@@ -35,5 +35,9 @@ + #include "sandbox/linux/system_headers/arm64_linux_syscalls.h" + #endif + ++#if defined(__riscv) && __riscv_xlen == 64 ++#include "sandbox/linux/system_headers/riscv64_linux_syscalls.h" ++#endif ++ + #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_ + +--- /dev/null ++++ b/src/3rdparty/chromium/sandbox/linux/system_headers/riscv64_linux_syscalls.h +@@ -0,0 +1,1066 @@ ++// Copyright 2014 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ ++#define SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ ++ ++#include ++ ++#if !defined(__NR_io_setup) ++#define __NR_io_setup 0 ++#endif ++ ++#if !defined(__NR_io_destroy) ++#define __NR_io_destroy 1 ++#endif ++ ++#if !defined(__NR_io_submit) ++#define __NR_io_submit 2 ++#endif ++ ++#if !defined(__NR_io_cancel) ++#define __NR_io_cancel 3 ++#endif ++ ++#if !defined(__NR_io_getevents) ++#define __NR_io_getevents 4 ++#endif ++ ++#if !defined(__NR_setxattr) ++#define __NR_setxattr 5 ++#endif ++ ++#if !defined(__NR_lsetxattr) ++#define __NR_lsetxattr 6 ++#endif ++ ++#if !defined(__NR_fsetxattr) ++#define __NR_fsetxattr 7 ++#endif ++ ++#if !defined(__NR_getxattr) ++#define __NR_getxattr 8 ++#endif ++ ++#if !defined(__NR_lgetxattr) ++#define __NR_lgetxattr 9 ++#endif ++ ++#if !defined(__NR_fgetxattr) ++#define __NR_fgetxattr 10 ++#endif ++ ++#if !defined(__NR_listxattr) ++#define __NR_listxattr 11 ++#endif ++ ++#if !defined(__NR_llistxattr) ++#define __NR_llistxattr 12 ++#endif ++ ++#if !defined(__NR_flistxattr) ++#define __NR_flistxattr 13 ++#endif ++ ++#if !defined(__NR_removexattr) ++#define __NR_removexattr 14 ++#endif ++ ++#if !defined(__NR_lremovexattr) ++#define __NR_lremovexattr 15 ++#endif ++ ++#if !defined(__NR_fremovexattr) ++#define __NR_fremovexattr 16 ++#endif ++ ++#if !defined(__NR_getcwd) ++#define __NR_getcwd 17 ++#endif ++ ++#if !defined(__NR_lookup_dcookie) ++#define __NR_lookup_dcookie 18 ++#endif ++ ++#if !defined(__NR_eventfd2) ++#define __NR_eventfd2 19 ++#endif ++ ++#if !defined(__NR_epoll_create1) ++#define __NR_epoll_create1 20 ++#endif ++ ++#if !defined(__NR_epoll_ctl) ++#define __NR_epoll_ctl 21 ++#endif ++ ++#if !defined(__NR_epoll_pwait) ++#define __NR_epoll_pwait 22 ++#endif ++ ++#if !defined(__NR_dup) ++#define __NR_dup 23 ++#endif ++ ++#if !defined(__NR_dup3) ++#define __NR_dup3 24 ++#endif ++ ++#if !defined(__NR_fcntl) ++#define __NR_fcntl 25 ++#endif ++ ++#if !defined(__NR_inotify_init1) ++#define __NR_inotify_init1 26 ++#endif ++ ++#if !defined(__NR_inotify_add_watch) ++#define __NR_inotify_add_watch 27 ++#endif ++ ++#if !defined(__NR_inotify_rm_watch) ++#define __NR_inotify_rm_watch 28 ++#endif ++ ++#if !defined(__NR_ioctl) ++#define __NR_ioctl 29 ++#endif ++ ++#if !defined(__NR_ioprio_set) ++#define __NR_ioprio_set 30 ++#endif ++ ++#if !defined(__NR_ioprio_get) ++#define __NR_ioprio_get 31 ++#endif ++ ++#if !defined(__NR_flock) ++#define __NR_flock 32 ++#endif ++ ++#if !defined(__NR_mknodat) ++#define __NR_mknodat 33 ++#endif ++ ++#if !defined(__NR_mkdirat) ++#define __NR_mkdirat 34 ++#endif ++ ++#if !defined(__NR_unlinkat) ++#define __NR_unlinkat 35 ++#endif ++ ++#if !defined(__NR_symlinkat) ++#define __NR_symlinkat 36 ++#endif ++ ++#if !defined(__NR_linkat) ++#define __NR_linkat 37 ++#endif ++ ++#if !defined(__NR_renameat) ++#define __NR_renameat 38 ++#endif ++ ++#if !defined(__NR_umount2) ++#define __NR_umount2 39 ++#endif ++ ++#if !defined(__NR_mount) ++#define __NR_mount 40 ++#endif ++ ++#if !defined(__NR_pivot_root) ++#define __NR_pivot_root 41 ++#endif ++ ++#if !defined(__NR_nfsservctl) ++#define __NR_nfsservctl 42 ++#endif ++ ++#if !defined(__NR_statfs) ++#define __NR_statfs 43 ++#endif ++ ++#if !defined(__NR_fstatfs) ++#define __NR_fstatfs 44 ++#endif ++ ++#if !defined(__NR_truncate) ++#define __NR_truncate 45 ++#endif ++ ++#if !defined(__NR_ftruncate) ++#define __NR_ftruncate 46 ++#endif ++ ++#if !defined(__NR_fallocate) ++#define __NR_fallocate 47 ++#endif ++ ++#if !defined(__NR_faccessat) ++#define __NR_faccessat 48 ++#endif ++ ++#if !defined(__NR_chdir) ++#define __NR_chdir 49 ++#endif ++ ++#if !defined(__NR_fchdir) ++#define __NR_fchdir 50 ++#endif ++ ++#if !defined(__NR_chroot) ++#define __NR_chroot 51 ++#endif ++ ++#if !defined(__NR_fchmod) ++#define __NR_fchmod 52 ++#endif ++ ++#if !defined(__NR_fchmodat) ++#define __NR_fchmodat 53 ++#endif ++ ++#if !defined(__NR_fchownat) ++#define __NR_fchownat 54 ++#endif ++ ++#if !defined(__NR_fchown) ++#define __NR_fchown 55 ++#endif ++ ++#if !defined(__NR_openat) ++#define __NR_openat 56 ++#endif ++ ++#if !defined(__NR_close) ++#define __NR_close 57 ++#endif ++ ++#if !defined(__NR_vhangup) ++#define __NR_vhangup 58 ++#endif ++ ++#if !defined(__NR_pipe2) ++#define __NR_pipe2 59 ++#endif ++ ++#if !defined(__NR_quotactl) ++#define __NR_quotactl 60 ++#endif ++ ++#if !defined(__NR_getdents64) ++#define __NR_getdents64 61 ++#endif ++ ++#if !defined(__NR_lseek) ++#define __NR_lseek 62 ++#endif ++ ++#if !defined(__NR_read) ++#define __NR_read 63 ++#endif ++ ++#if !defined(__NR_write) ++#define __NR_write 64 ++#endif ++ ++#if !defined(__NR_readv) ++#define __NR_readv 65 ++#endif ++ ++#if !defined(__NR_writev) ++#define __NR_writev 66 ++#endif ++ ++#if !defined(__NR_pread64) ++#define __NR_pread64 67 ++#endif ++ ++#if !defined(__NR_pwrite64) ++#define __NR_pwrite64 68 ++#endif ++ ++#if !defined(__NR_preadv) ++#define __NR_preadv 69 ++#endif ++ ++#if !defined(__NR_pwritev) ++#define __NR_pwritev 70 ++#endif ++ ++#if !defined(__NR_sendfile) ++#define __NR_sendfile 71 ++#endif ++ ++#if !defined(__NR_pselect6) ++#define __NR_pselect6 72 ++#endif ++ ++#if !defined(__NR_ppoll) ++#define __NR_ppoll 73 ++#endif ++ ++#if !defined(__NR_signalfd4) ++#define __NR_signalfd4 74 ++#endif ++ ++#if !defined(__NR_vmsplice) ++#define __NR_vmsplice 75 ++#endif ++ ++#if !defined(__NR_splice) ++#define __NR_splice 76 ++#endif ++ ++#if !defined(__NR_tee) ++#define __NR_tee 77 ++#endif ++ ++#if !defined(__NR_readlinkat) ++#define __NR_readlinkat 78 ++#endif ++ ++#if !defined(__NR_newfstatat) ++#define __NR_newfstatat 79 ++#endif ++ ++#if !defined(__NR_fstat) ++#define __NR_fstat 80 ++#endif ++ ++#if !defined(__NR_sync) ++#define __NR_sync 81 ++#endif ++ ++#if !defined(__NR_fsync) ++#define __NR_fsync 82 ++#endif ++ ++#if !defined(__NR_fdatasync) ++#define __NR_fdatasync 83 ++#endif ++ ++#if !defined(__NR_sync_file_range) ++#define __NR_sync_file_range 84 ++#endif ++ ++#if !defined(__NR_timerfd_create) ++#define __NR_timerfd_create 85 ++#endif ++ ++#if !defined(__NR_timerfd_settime) ++#define __NR_timerfd_settime 86 ++#endif ++ ++#if !defined(__NR_timerfd_gettime) ++#define __NR_timerfd_gettime 87 ++#endif ++ ++#if !defined(__NR_utimensat) ++#define __NR_utimensat 88 ++#endif ++ ++#if !defined(__NR_acct) ++#define __NR_acct 89 ++#endif ++ ++#if !defined(__NR_capget) ++#define __NR_capget 90 ++#endif ++ ++#if !defined(__NR_capset) ++#define __NR_capset 91 ++#endif ++ ++#if !defined(__NR_personality) ++#define __NR_personality 92 ++#endif ++ ++#if !defined(__NR_exit) ++#define __NR_exit 93 ++#endif ++ ++#if !defined(__NR_exit_group) ++#define __NR_exit_group 94 ++#endif ++ ++#if !defined(__NR_waitid) ++#define __NR_waitid 95 ++#endif ++ ++#if !defined(__NR_set_tid_address) ++#define __NR_set_tid_address 96 ++#endif ++ ++#if !defined(__NR_unshare) ++#define __NR_unshare 97 ++#endif ++ ++#if !defined(__NR_futex) ++#define __NR_futex 98 ++#endif ++ ++#if !defined(__NR_set_robust_list) ++#define __NR_set_robust_list 99 ++#endif ++ ++#if !defined(__NR_get_robust_list) ++#define __NR_get_robust_list 100 ++#endif ++ ++#if !defined(__NR_nanosleep) ++#define __NR_nanosleep 101 ++#endif ++ ++#if !defined(__NR_getitimer) ++#define __NR_getitimer 102 ++#endif ++ ++#if !defined(__NR_setitimer) ++#define __NR_setitimer 103 ++#endif ++ ++#if !defined(__NR_kexec_load) ++#define __NR_kexec_load 104 ++#endif ++ ++#if !defined(__NR_init_module) ++#define __NR_init_module 105 ++#endif ++ ++#if !defined(__NR_delete_module) ++#define __NR_delete_module 106 ++#endif ++ ++#if !defined(__NR_timer_create) ++#define __NR_timer_create 107 ++#endif ++ ++#if !defined(__NR_timer_gettime) ++#define __NR_timer_gettime 108 ++#endif ++ ++#if !defined(__NR_timer_getoverrun) ++#define __NR_timer_getoverrun 109 ++#endif ++ ++#if !defined(__NR_timer_settime) ++#define __NR_timer_settime 110 ++#endif ++ ++#if !defined(__NR_timer_delete) ++#define __NR_timer_delete 111 ++#endif ++ ++#if !defined(__NR_clock_settime) ++#define __NR_clock_settime 112 ++#endif ++ ++#if !defined(__NR_clock_gettime) ++#define __NR_clock_gettime 113 ++#endif ++ ++#if !defined(__NR_clock_getres) ++#define __NR_clock_getres 114 ++#endif ++ ++#if !defined(__NR_clock_nanosleep) ++#define __NR_clock_nanosleep 115 ++#endif ++ ++#if !defined(__NR_syslog) ++#define __NR_syslog 116 ++#endif ++ ++#if !defined(__NR_ptrace) ++#define __NR_ptrace 117 ++#endif ++ ++#if !defined(__NR_sched_setparam) ++#define __NR_sched_setparam 118 ++#endif ++ ++#if !defined(__NR_sched_setscheduler) ++#define __NR_sched_setscheduler 119 ++#endif ++ ++#if !defined(__NR_sched_getscheduler) ++#define __NR_sched_getscheduler 120 ++#endif ++ ++#if !defined(__NR_sched_getparam) ++#define __NR_sched_getparam 121 ++#endif ++ ++#if !defined(__NR_sched_setaffinity) ++#define __NR_sched_setaffinity 122 ++#endif ++ ++#if !defined(__NR_sched_getaffinity) ++#define __NR_sched_getaffinity 123 ++#endif ++ ++#if !defined(__NR_sched_yield) ++#define __NR_sched_yield 124 ++#endif ++ ++#if !defined(__NR_sched_get_priority_max) ++#define __NR_sched_get_priority_max 125 ++#endif ++ ++#if !defined(__NR_sched_get_priority_min) ++#define __NR_sched_get_priority_min 126 ++#endif ++ ++#if !defined(__NR_sched_rr_get_interval) ++#define __NR_sched_rr_get_interval 127 ++#endif ++ ++#if !defined(__NR_restart_syscall) ++#define __NR_restart_syscall 128 ++#endif ++ ++#if !defined(__NR_kill) ++#define __NR_kill 129 ++#endif ++ ++#if !defined(__NR_tkill) ++#define __NR_tkill 130 ++#endif ++ ++#if !defined(__NR_tgkill) ++#define __NR_tgkill 131 ++#endif ++ ++#if !defined(__NR_sigaltstack) ++#define __NR_sigaltstack 132 ++#endif ++ ++#if !defined(__NR_rt_sigsuspend) ++#define __NR_rt_sigsuspend 133 ++#endif ++ ++#if !defined(__NR_rt_sigaction) ++#define __NR_rt_sigaction 134 ++#endif ++ ++#if !defined(__NR_rt_sigprocmask) ++#define __NR_rt_sigprocmask 135 ++#endif ++ ++#if !defined(__NR_rt_sigpending) ++#define __NR_rt_sigpending 136 ++#endif ++ ++#if !defined(__NR_rt_sigtimedwait) ++#define __NR_rt_sigtimedwait 137 ++#endif ++ ++#if !defined(__NR_rt_sigqueueinfo) ++#define __NR_rt_sigqueueinfo 138 ++#endif ++ ++#if !defined(__NR_rt_sigreturn) ++#define __NR_rt_sigreturn 139 ++#endif ++ ++#if !defined(__NR_setpriority) ++#define __NR_setpriority 140 ++#endif ++ ++#if !defined(__NR_getpriority) ++#define __NR_getpriority 141 ++#endif ++ ++#if !defined(__NR_reboot) ++#define __NR_reboot 142 ++#endif ++ ++#if !defined(__NR_setregid) ++#define __NR_setregid 143 ++#endif ++ ++#if !defined(__NR_setgid) ++#define __NR_setgid 144 ++#endif ++ ++#if !defined(__NR_setreuid) ++#define __NR_setreuid 145 ++#endif ++ ++#if !defined(__NR_setuid) ++#define __NR_setuid 146 ++#endif ++ ++#if !defined(__NR_setresuid) ++#define __NR_setresuid 147 ++#endif ++ ++#if !defined(__NR_getresuid) ++#define __NR_getresuid 148 ++#endif ++ ++#if !defined(__NR_setresgid) ++#define __NR_setresgid 149 ++#endif ++ ++#if !defined(__NR_getresgid) ++#define __NR_getresgid 150 ++#endif ++ ++#if !defined(__NR_setfsuid) ++#define __NR_setfsuid 151 ++#endif ++ ++#if !defined(__NR_setfsgid) ++#define __NR_setfsgid 152 ++#endif ++ ++#if !defined(__NR_times) ++#define __NR_times 153 ++#endif ++ ++#if !defined(__NR_setpgid) ++#define __NR_setpgid 154 ++#endif ++ ++#if !defined(__NR_getpgid) ++#define __NR_getpgid 155 ++#endif ++ ++#if !defined(__NR_getsid) ++#define __NR_getsid 156 ++#endif ++ ++#if !defined(__NR_setsid) ++#define __NR_setsid 157 ++#endif ++ ++#if !defined(__NR_getgroups) ++#define __NR_getgroups 158 ++#endif ++ ++#if !defined(__NR_setgroups) ++#define __NR_setgroups 159 ++#endif ++ ++#if !defined(__NR_uname) ++#define __NR_uname 160 ++#endif ++ ++#if !defined(__NR_sethostname) ++#define __NR_sethostname 161 ++#endif ++ ++#if !defined(__NR_setdomainname) ++#define __NR_setdomainname 162 ++#endif ++ ++#if !defined(__NR_getrlimit) ++#define __NR_getrlimit 163 ++#endif ++ ++#if !defined(__NR_setrlimit) ++#define __NR_setrlimit 164 ++#endif ++ ++#if !defined(__NR_getrusage) ++#define __NR_getrusage 165 ++#endif ++ ++#if !defined(__NR_umask) ++#define __NR_umask 166 ++#endif ++ ++#if !defined(__NR_prctl) ++#define __NR_prctl 167 ++#endif ++ ++#if !defined(__NR_getcpu) ++#define __NR_getcpu 168 ++#endif ++ ++#if !defined(__NR_gettimeofday) ++#define __NR_gettimeofday 169 ++#endif ++ ++#if !defined(__NR_settimeofday) ++#define __NR_settimeofday 170 ++#endif ++ ++#if !defined(__NR_adjtimex) ++#define __NR_adjtimex 171 ++#endif ++ ++#if !defined(__NR_getpid) ++#define __NR_getpid 172 ++#endif ++ ++#if !defined(__NR_getppid) ++#define __NR_getppid 173 ++#endif ++ ++#if !defined(__NR_getuid) ++#define __NR_getuid 174 ++#endif ++ ++#if !defined(__NR_geteuid) ++#define __NR_geteuid 175 ++#endif ++ ++#if !defined(__NR_getgid) ++#define __NR_getgid 176 ++#endif ++ ++#if !defined(__NR_getegid) ++#define __NR_getegid 177 ++#endif ++ ++#if !defined(__NR_gettid) ++#define __NR_gettid 178 ++#endif ++ ++#if !defined(__NR_sysinfo) ++#define __NR_sysinfo 179 ++#endif ++ ++#if !defined(__NR_mq_open) ++#define __NR_mq_open 180 ++#endif ++ ++#if !defined(__NR_mq_unlink) ++#define __NR_mq_unlink 181 ++#endif ++ ++#if !defined(__NR_mq_timedsend) ++#define __NR_mq_timedsend 182 ++#endif ++ ++#if !defined(__NR_mq_timedreceive) ++#define __NR_mq_timedreceive 183 ++#endif ++ ++#if !defined(__NR_mq_notify) ++#define __NR_mq_notify 184 ++#endif ++ ++#if !defined(__NR_mq_getsetattr) ++#define __NR_mq_getsetattr 185 ++#endif ++ ++#if !defined(__NR_msgget) ++#define __NR_msgget 186 ++#endif ++ ++#if !defined(__NR_msgctl) ++#define __NR_msgctl 187 ++#endif ++ ++#if !defined(__NR_msgrcv) ++#define __NR_msgrcv 188 ++#endif ++ ++#if !defined(__NR_msgsnd) ++#define __NR_msgsnd 189 ++#endif ++ ++#if !defined(__NR_semget) ++#define __NR_semget 190 ++#endif ++ ++#if !defined(__NR_semctl) ++#define __NR_semctl 191 ++#endif ++ ++#if !defined(__NR_semtimedop) ++#define __NR_semtimedop 192 ++#endif ++ ++#if !defined(__NR_semop) ++#define __NR_semop 193 ++#endif ++ ++#if !defined(__NR_shmget) ++#define __NR_shmget 194 ++#endif ++ ++#if !defined(__NR_shmctl) ++#define __NR_shmctl 195 ++#endif ++ ++#if !defined(__NR_shmat) ++#define __NR_shmat 196 ++#endif ++ ++#if !defined(__NR_shmdt) ++#define __NR_shmdt 197 ++#endif ++ ++#if !defined(__NR_socket) ++#define __NR_socket 198 ++#endif ++ ++#if !defined(__NR_socketpair) ++#define __NR_socketpair 199 ++#endif ++ ++#if !defined(__NR_bind) ++#define __NR_bind 200 ++#endif ++ ++#if !defined(__NR_listen) ++#define __NR_listen 201 ++#endif ++ ++#if !defined(__NR_accept) ++#define __NR_accept 202 ++#endif ++ ++#if !defined(__NR_connect) ++#define __NR_connect 203 ++#endif ++ ++#if !defined(__NR_getsockname) ++#define __NR_getsockname 204 ++#endif ++ ++#if !defined(__NR_getpeername) ++#define __NR_getpeername 205 ++#endif ++ ++#if !defined(__NR_sendto) ++#define __NR_sendto 206 ++#endif ++ ++#if !defined(__NR_recvfrom) ++#define __NR_recvfrom 207 ++#endif ++ ++#if !defined(__NR_setsockopt) ++#define __NR_setsockopt 208 ++#endif ++ ++#if !defined(__NR_getsockopt) ++#define __NR_getsockopt 209 ++#endif ++ ++#if !defined(__NR_shutdown) ++#define __NR_shutdown 210 ++#endif ++ ++#if !defined(__NR_sendmsg) ++#define __NR_sendmsg 211 ++#endif ++ ++#if !defined(__NR_recvmsg) ++#define __NR_recvmsg 212 ++#endif ++ ++#if !defined(__NR_readahead) ++#define __NR_readahead 213 ++#endif ++ ++#if !defined(__NR_brk) ++#define __NR_brk 214 ++#endif ++ ++#if !defined(__NR_munmap) ++#define __NR_munmap 215 ++#endif ++ ++#if !defined(__NR_mremap) ++#define __NR_mremap 216 ++#endif ++ ++#if !defined(__NR_add_key) ++#define __NR_add_key 217 ++#endif ++ ++#if !defined(__NR_request_key) ++#define __NR_request_key 218 ++#endif ++ ++#if !defined(__NR_keyctl) ++#define __NR_keyctl 219 ++#endif ++ ++#if !defined(__NR_clone) ++#define __NR_clone 220 ++#endif ++ ++#if !defined(__NR_execve) ++#define __NR_execve 221 ++#endif ++ ++#if !defined(__NR_mmap) ++#define __NR_mmap 222 ++#endif ++ ++#if !defined(__NR_fadvise64) ++#define __NR_fadvise64 223 ++#endif ++ ++#if !defined(__NR_swapon) ++#define __NR_swapon 224 ++#endif ++ ++#if !defined(__NR_swapoff) ++#define __NR_swapoff 225 ++#endif ++ ++#if !defined(__NR_mprotect) ++#define __NR_mprotect 226 ++#endif ++ ++#if !defined(__NR_msync) ++#define __NR_msync 227 ++#endif ++ ++#if !defined(__NR_mlock) ++#define __NR_mlock 228 ++#endif ++ ++#if !defined(__NR_munlock) ++#define __NR_munlock 229 ++#endif ++ ++#if !defined(__NR_mlockall) ++#define __NR_mlockall 230 ++#endif ++ ++#if !defined(__NR_munlockall) ++#define __NR_munlockall 231 ++#endif ++ ++#if !defined(__NR_mincore) ++#define __NR_mincore 232 ++#endif ++ ++#if !defined(__NR_madvise) ++#define __NR_madvise 233 ++#endif ++ ++#if !defined(__NR_remap_file_pages) ++#define __NR_remap_file_pages 234 ++#endif ++ ++#if !defined(__NR_mbind) ++#define __NR_mbind 235 ++#endif ++ ++#if !defined(__NR_get_mempolicy) ++#define __NR_get_mempolicy 236 ++#endif ++ ++#if !defined(__NR_set_mempolicy) ++#define __NR_set_mempolicy 237 ++#endif ++ ++#if !defined(__NR_migrate_pages) ++#define __NR_migrate_pages 238 ++#endif ++ ++#if !defined(__NR_move_pages) ++#define __NR_move_pages 239 ++#endif ++ ++#if !defined(__NR_rt_tgsigqueueinfo) ++#define __NR_rt_tgsigqueueinfo 240 ++#endif ++ ++#if !defined(__NR_perf_event_open) ++#define __NR_perf_event_open 241 ++#endif ++ ++#if !defined(__NR_accept4) ++#define __NR_accept4 242 ++#endif ++ ++#if !defined(__NR_recvmmsg) ++#define __NR_recvmmsg 243 ++#endif ++ ++#if !defined(__NR_wait4) ++#define __NR_wait4 260 ++#endif ++ ++#if !defined(__NR_prlimit64) ++#define __NR_prlimit64 261 ++#endif ++ ++#if !defined(__NR_fanotify_init) ++#define __NR_fanotify_init 262 ++#endif ++ ++#if !defined(__NR_fanotify_mark) ++#define __NR_fanotify_mark 263 ++#endif ++ ++#if !defined(__NR_name_to_handle_at) ++#define __NR_name_to_handle_at 264 ++#endif ++ ++#if !defined(__NR_open_by_handle_at) ++#define __NR_open_by_handle_at 265 ++#endif ++ ++#if !defined(__NR_clock_adjtime) ++#define __NR_clock_adjtime 266 ++#endif ++ ++#if !defined(__NR_syncfs) ++#define __NR_syncfs 267 ++#endif ++ ++#if !defined(__NR_setns) ++#define __NR_setns 268 ++#endif ++ ++#if !defined(__NR_sendmmsg) ++#define __NR_sendmmsg 269 ++#endif ++ ++#if !defined(__NR_process_vm_readv) ++#define __NR_process_vm_readv 270 ++#endif ++ ++#if !defined(__NR_process_vm_writev) ++#define __NR_process_vm_writev 271 ++#endif ++ ++#if !defined(__NR_kcmp) ++#define __NR_kcmp 272 ++#endif ++ ++#if !defined(__NR_finit_module) ++#define __NR_finit_module 273 ++#endif ++ ++#if !defined(__NR_sched_setattr) ++#define __NR_sched_setattr 274 ++#endif ++ ++#if !defined(__NR_sched_getattr) ++#define __NR_sched_getattr 275 ++#endif ++ ++#if !defined(__NR_renameat2) ++#define __NR_renameat2 276 ++#endif ++ ++#if !defined(__NR_seccomp) ++#define __NR_seccomp 277 ++#endif ++ ++#if !defined(__NR_getrandom) ++#define __NR_getrandom 278 ++#endif ++ ++#if !defined(__NR_memfd_create) ++#define __NR_memfd_create 279 ++#endif ++ ++#endif // SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_ +--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc ++++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc +@@ -38,7 +38,7 @@ + case __NR_sched_setscheduler: + case __NR_sysinfo: + case __NR_uname: +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_readlink: + case __NR_stat: + #endif +--- a/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc ++++ b/src/3rdparty/chromium/sandbox/policy/linux/bpf_gpu_policy_linux.cc +@@ -70,7 +70,7 @@ + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) + case __NR_ftruncate64: + #endif +-#if !defined(__aarch64__) ++#if !defined(__aarch64__) && !defined(__riscv) + case __NR_getdents: + #endif + case __NR_getdents64: +--- a/src/3rdparty/chromium/sandbox/policy/linux/sandbox_seccomp_bpf_linux.cc ++++ b/src/3rdparty/chromium/sandbox/policy/linux/sandbox_seccomp_bpf_linux.cc +@@ -64,7 +64,7 @@ + + // Make sure that seccomp-bpf does not get disabled by mistake. Also make sure + // that we think twice about this when adding a new architecture. +-#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) ++#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) && !defined(ARCH_CPU_RISCV64) + #error "Seccomp-bpf disabled on supported architecture!" + #endif // !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL) + +--- a/src/3rdparty/chromium/skia/BUILD.gn ++++ b/src/3rdparty/chromium/skia/BUILD.gn +@@ -821,6 +821,8 @@ + sources = skia_opts.none_sources + } else if (current_cpu == "s390x") { + sources = skia_opts.none_sources ++ } else if (current_cpu == "riscv64") { ++ sources = skia_opts.none_sources + } else { + assert(false, "Need to port cpu specific stuff from skia_library_opts.gyp") + } +--- a/src/3rdparty/chromium/third_party/angle/gni/angle.gni ++++ b/src/3rdparty/chromium/third_party/angle/gni/angle.gni +@@ -54,7 +54,7 @@ + declare_args() { + if (current_cpu == "arm64" || current_cpu == "x64" || + current_cpu == "mips64el" || current_cpu == "s390x" || +- current_cpu == "ppc64") { ++ current_cpu == "ppc64" || current_cpu == "riscv64") { + angle_64bit_current_cpu = true + } else if (current_cpu == "arm" || current_cpu == "x86" || + current_cpu == "mipsel" || current_cpu == "s390" || +--- a/src/3rdparty/chromium/third_party/angle/include/platform/PlatformMethods.h ++++ b/src/3rdparty/chromium/third_party/angle/include/platform/PlatformMethods.h +@@ -9,6 +9,7 @@ + #ifndef ANGLE_PLATFORMMETHODS_H + #define ANGLE_PLATFORMMETHODS_H + ++#include + #include + #include + #include +--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn ++++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/BUILD.gn +@@ -38,6 +38,8 @@ + sources = [ "SaveRegisters_mips64.S" ] + } else if (current_cpu == "ppc64") { + sources = [ "SaveRegisters_ppc64.S" ] ++ } else if (current_cpu == "riscv64") { ++ sources = [ "SaveRegisters_riscv64.S" ] + } + + if (current_cpu == "arm") { +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/heap/asm/SaveRegisters_riscv64.S +@@ -0,0 +1,45 @@ ++/* ++ * typedef void (*PushAllRegistersCallback)(ThreadState*, intptr_t*); ++ * extern "C" void PushAllRegisters(ThreadState*, PushAllRegistersCallback) ++ */ ++ ++.type PushAllRegisters, %function ++.global PushAllRegisters ++.hidden PushAllRegisters ++PushAllRegisters: ++ /* Push all callee-saves registers to get them ++ * on the stack for conservative stack scanning. ++ * Reserve space for callee-saved registers and return address. ++ */ ++ addi sp,sp,-112 ++ /* Save the callee-saved registers and the return address. */ ++ sd ra,0(sp) ++ sd s0,8(sp) ++ sd s1,16(sp) ++ sd s2,24(sp) ++ sd s3,32(sp) ++ sd s4,40(sp) ++ sd s5,48(sp) ++ sd s6,56(sp) ++ sd s7,64(sp) ++ sd s8,72(sp) ++ sd s9,80(sp) ++ sd s10,88(sp) ++ sd s11,96(sp) ++ /* Note: the callee-saved floating point registers do not need to be ++ * copied to the stack, because fp registers never hold heap pointers ++ * and so do not need to be kept visible to the garbage collector. ++ * Pass the first argument untouched in a0 and the ++ * stack pointer to the callback. ++ */ ++ mv ra,a1 ++ mv a1,sp ++ jalr ra ++ /* Restore return address, adjust stack and return. ++ * Note: the copied registers do not need to be reloaded here, ++ * because they were preserved by the called routine. ++ */ ++ ld ra,0(sp) ++ addi sp,sp,112 ++ ret ++.size PushAllRegisters, . - PushAllRegisters +--- a/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h ++++ b/src/3rdparty/chromium/third_party/boringssl/src/include/openssl/base.h +@@ -114,6 +114,8 @@ + #define OPENSSL_32_BIT + #elif defined(__myriad2__) + #define OPENSSL_32_BIT ++#elif defined(__riscv) && __riscv_xlen == 64 ++#define OPENSSL_64_BIT + #else + // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, + // little-endian architectures. Functions will not produce the correct answer +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h +@@ -44,6 +44,8 @@ + typedef MDRawContextARM64_Old RawContextCPU; + #elif defined(__mips__) + typedef MDRawContextMIPS RawContextCPU; ++#elif defined(__riscv) ++typedef MDRawContextRISCV64 RawContextCPU; + #else + #error "This code has not been ported to your platform yet." + #endif +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc +@@ -270,7 +270,23 @@ + out->float_save.fir = mcontext.fpc_eir; + #endif + } +-#endif // __mips__ ++#elif defined(__riscv) ++ ++uintptr_t ThreadInfo::GetInstructionPointer() const { ++ return mcontext.__gregs[REG_PC]; ++} ++ ++void ThreadInfo::FillCPUContext(RawContextCPU* out) const { ++ out->context_flags = MD_CONTEXT_RISCV64_FULL; ++ ++ my_memcpy (out->iregs, mcontext.__gregs, MD_CONTEXT_RISCV64_GPR_COUNT * 8); ++ ++ out->float_save.fcsr = mcontext.__fpregs.__d.__fcsr; ++ my_memcpy(&out->float_save.regs, &mcontext.__fpregs.__d.__f, ++ MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT * 8); ++} ++ ++#endif // __riscv + + void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) { + assert(gp_regs || size); +@@ -279,6 +295,11 @@ + *gp_regs = mcontext.gregs; + if (size) + *size = sizeof(mcontext.gregs); ++#elif defined(__riscv) ++ if (gp_regs) ++ *gp_regs = mcontext.__gregs; ++ if (size) ++ *size = sizeof(mcontext.__gregs); + #else + if (gp_regs) + *gp_regs = ®s; +@@ -294,6 +315,11 @@ + *fp_regs = &mcontext.fpregs; + if (size) + *size = sizeof(mcontext.fpregs); ++#elif defined(__riscv) ++ if (fp_regs) ++ *fp_regs = &mcontext.__fpregs; ++ if (size) ++ *size = sizeof(mcontext.__fpregs); + #else + if (fp_regs) + *fp_regs = &fpregs; +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h +@@ -68,7 +68,7 @@ + // Use the structures defined in + struct user_regs_struct regs; + struct user_fpsimd_struct fpregs; +-#elif defined(__mips__) ++#elif defined(__mips__) || defined(__riscv) + // Use the structure defined in . + mcontext_t mcontext; + #endif +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc +@@ -461,7 +461,7 @@ + memcpy(&g_crash_context_.float_state, fp_ptr, + sizeof(g_crash_context_.float_state)); + } +-#elif !defined(__ARM_EABI__) && !defined(__mips__) ++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + // FP state is not part of user ABI on ARM Linux. + // In case of MIPS Linux FP state is already part of ucontext_t + // and 'float_state' is not a member of CrashContext. +@@ -701,7 +701,7 @@ + } + #endif + +-#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) && !defined(__riscv) + // FPU state is not part of ARM EABI ucontext_t. + memcpy(&context.float_state, context.context.uc_mcontext.fpregs, + sizeof(context.float_state)); +@@ -726,6 +726,9 @@ + #elif defined(__mips__) + context.siginfo.si_addr = + reinterpret_cast(context.context.uc_mcontext.pc); ++#elif defined(__riscv) ++ context.siginfo.si_addr = ++ reinterpret_cast(context.context.uc_mcontext.__gregs[REG_PC]); + #else + #error "This code has not been ported to your platform yet." + #endif +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h +@@ -192,7 +192,7 @@ + siginfo_t siginfo; + pid_t tid; // the crashing thread. + ucontext_t context; +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + // #ifdef this out because FP state is not part of user ABI for Linux ARM. + // In case of MIPS Linux FP state is already part of ucontext_t so + // 'float_state' is not required. +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc +@@ -138,7 +138,7 @@ + const MicrodumpExtraInfo& microdump_extra_info, + LinuxDumper* dumper) + : ucontext_(context ? &context->context : NULL), +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + float_state_(context ? &context->float_state : NULL), + #endif + dumper_(dumper), +@@ -337,6 +337,12 @@ + # else + # error "This mips ABI is currently not supported (n32)" + #endif ++#elif defined(__riscv) ++# if __riscv_xlen == 64 ++ const char kArch[] = "riscv64"; ++# else ++# error "This RISC-V ABI is currently not supported" ++#endif + #else + #error "This code has not been ported to your platform yet" + #endif +@@ -409,7 +415,7 @@ + void DumpCPUState() { + RawContextCPU cpu; + my_memset(&cpu, 0, sizeof(RawContextCPU)); +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + UContextReader::FillCPUContext(&cpu, ucontext_, float_state_); + #else + UContextReader::FillCPUContext(&cpu, ucontext_); +@@ -605,7 +611,7 @@ + void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } + + const ucontext_t* const ucontext_; +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + const google_breakpad::fpstate_t* const float_state_; + #endif + LinuxDumper* dumper_; +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc +@@ -112,6 +112,9 @@ + #elif defined(__mips__) + stack_pointer = + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); ++#elif defined(__riscv) ++ stack_pointer = ++ reinterpret_cast(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]); + #else + #error "This code hasn't been ported to your platform yet." + #endif +@@ -208,6 +211,8 @@ + info.mcontext.mdlo = status->pr_reg[EF_LO]; + info.mcontext.mdhi = status->pr_reg[EF_HI]; + info.mcontext.pc = status->pr_reg[EF_CP0_EPC]; ++#elif defined(__riscv) ++ memcpy(info.mcontext.__gregs, status->pr_reg, sizeof(info.mcontext.__gregs)); + #else // __mips__ + memcpy(&info.regs, status->pr_reg, sizeof(info.regs)); + #endif // __mips__ +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h +@@ -63,7 +63,8 @@ + (defined(__mips__) && _MIPS_SIM == _ABIO32) + typedef Elf32_auxv_t elf_aux_entry; + #elif defined(__x86_64) || defined(__aarch64__) || \ +- (defined(__mips__) && _MIPS_SIM != _ABIO32) ++ (defined(__mips__) && _MIPS_SIM != _ABIO32) || \ ++ (defined(__riscv) && __riscv_xlen == 64) + typedef Elf64_auxv_t elf_aux_entry; + #endif + +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc +@@ -298,6 +298,9 @@ + #elif defined(__mips__) + stack_pointer = + reinterpret_cast(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); ++#elif defined(__riscv) ++ stack_pointer = ++ reinterpret_cast(info->mcontext.__gregs[MD_CONTEXT_RISCV64_REG_SP]); + #else + #error "This code hasn't been ported to your platform yet." + #endif +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc +@@ -136,7 +136,7 @@ + : fd_(minidump_fd), + path_(minidump_path), + ucontext_(context ? &context->context : NULL), +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + float_state_(context ? &context->float_state : NULL), + #endif + dumper_(dumper), +@@ -468,7 +468,7 @@ + if (!cpu.Allocate()) + return false; + my_memset(cpu.get(), 0, sizeof(RawContextCPU)); +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_); + #else + UContextReader::FillCPUContext(cpu.get(), ucontext_); +@@ -897,7 +897,7 @@ + dirent->location.rva = 0; + } + +-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) ++#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || defined(__riscv) + bool WriteCPUInformation(MDRawSystemInfo* sys_info) { + char vendor_id[sizeof(sys_info->cpu.x86_cpu_info.vendor_id) + 1] = {0}; + static const char vendor_id_name[] = "vendor_id"; +@@ -925,6 +925,12 @@ + # else + # error "This mips ABI is currently not supported (n32)" + #endif ++#elif defined(__riscv) ++# if __riscv_xlen == 64 ++ MD_CPU_ARCHITECTURE_RISCV64; ++# else ++# error "This RISC-V ABI is currently not supported" ++# endif + #elif defined(__i386__) + MD_CPU_ARCHITECTURE_X86; + #else +@@ -1333,7 +1339,7 @@ + const char* path_; // Path to the file where the minidum should be written. + + const ucontext_t* const ucontext_; // also from the signal handler +-#if !defined(__ARM_EABI__) && !defined(__mips__) ++#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + const google_breakpad::fpstate_t* const float_state_; // ditto + #endif + LinuxDumper* dumper_; +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h +@@ -48,7 +48,7 @@ + + #if defined(__aarch64__) + typedef struct fpsimd_context fpstate_t; +-#elif !defined(__ARM_EABI__) && !defined(__mips__) ++#elif !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) + typedef std::remove_pointer::type fpstate_t; + #endif + +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/breakpad_getcontext.S +@@ -481,6 +481,68 @@ + .cfi_endproc + .size breakpad_getcontext, . - breakpad_getcontext + ++#elif defined(__riscv) && __riscv_xlen == 64 ++ ++#define __NR_rt_sigprocmask 135 ++#define _NSIG8 64 / 8 ++#define SIG_BLOCK 0 ++ ++ .text ++ .global breakpad_getcontext ++ .hidden breakpad_getcontext ++ .type breakpad_getcontext, @function ++ .align 2 ++breakpad_getcontext: ++ sd ra, MCONTEXT_GREGS_OFFSET + 0*8(a0) ++ sd ra, MCONTEXT_GREGS_OFFSET + 1*8(a0) ++ sd sp, MCONTEXT_GREGS_OFFSET + 2*8(a0) ++ sd s0, MCONTEXT_GREGS_OFFSET + 8*8(a0) ++ sd s1, MCONTEXT_GREGS_OFFSET + 9*8(a0) ++ sd x0, MCONTEXT_GREGS_OFFSET + 10*8(a0) /* return 0 by overwriting a0. */ ++ sd s2, MCONTEXT_GREGS_OFFSET + 18*8(a0) ++ sd s3, MCONTEXT_GREGS_OFFSET + 19*8(a0) ++ sd s4, MCONTEXT_GREGS_OFFSET + 20*8(a0) ++ sd s5, MCONTEXT_GREGS_OFFSET + 21*8(a0) ++ sd s6, MCONTEXT_GREGS_OFFSET + 22*8(a0) ++ sd s7, MCONTEXT_GREGS_OFFSET + 23*8(a0) ++ sd s8, MCONTEXT_GREGS_OFFSET + 24*8(a0) ++ sd s9, MCONTEXT_GREGS_OFFSET + 25*8(a0) ++ sd s10, MCONTEXT_GREGS_OFFSET + 26*8(a0) ++ sd s11, MCONTEXT_GREGS_OFFSET + 27*8(a0) ++ ++#ifndef __riscv_float_abi_soft ++ frsr a1 ++ ++ fsd fs0, MCONTEXT_FPREGS_OFFSET + 8*8(a0) ++ fsd fs1, MCONTEXT_FPREGS_OFFSET + 9*8(a0) ++ fsd fs2, MCONTEXT_FPREGS_OFFSET + 18*8(a0) ++ fsd fs3, MCONTEXT_FPREGS_OFFSET + 19*8(a0) ++ fsd fs4, MCONTEXT_FPREGS_OFFSET + 20*8(a0) ++ fsd fs5, MCONTEXT_FPREGS_OFFSET + 21*8(a0) ++ fsd fs6, MCONTEXT_FPREGS_OFFSET + 22*8(a0) ++ fsd fs7, MCONTEXT_FPREGS_OFFSET + 23*8(a0) ++ fsd fs8, MCONTEXT_FPREGS_OFFSET + 24*8(a0) ++ fsd fs9, MCONTEXT_FPREGS_OFFSET + 25*8(a0) ++ fsd fs10, MCONTEXT_FPREGS_OFFSET + 26*8(a0) ++ fsd fs11, MCONTEXT_FPREGS_OFFSET + 27*8(a0) ++ ++ sw a1, MCONTEXT_FSR_OFFSET(a0) ++#endif /* __riscv_float_abi_soft */ ++ ++/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG / 8) */ ++ li a3, _NSIG8 ++ add a2, a0, UCONTEXT_SIGMASK_OFFSET ++ mv a1, zero ++ li a0, SIG_BLOCK ++ ++ li a7, __NR_rt_sigprocmask ++ scall ++ ++ /* Always return 0 for success, even if sigprocmask failed. */ ++ mv a0, zero ++ ret ++ .size breakpad_getcontext, . - breakpad_getcontext ++ + #else + #error "This file has not been ported for your CPU!" + #endif +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc +@@ -65,7 +65,8 @@ + } + + #if defined(__x86_64__) || defined(__aarch64__) || \ +- (defined(__mips__) && _MIPS_SIM == _ABI64) ++ (defined(__mips__) && _MIPS_SIM == _ABI64) || \ ++ (defined(__riscv) && __riscv_xlen == 64) + + struct kernel_stat st; + if (sys_fstat(fd, &st) == -1 || st.st_size < 0) { +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/common/linux/ucontext_constants.h +@@ -146,6 +146,14 @@ + #endif + #define FPREGS_OFFSET_MXCSR 24 + ++#elif defined(__riscv) ++ ++#define UCONTEXT_SIGMASK_OFFSET 40 ++ ++#define MCONTEXT_GREGS_OFFSET 176 ++#define MCONTEXT_FPREGS_OFFSET 432 ++#define MCONTEXT_FSR_OFFSET (MCONTEXT_FPREGS_OFFSET + 32*8) ++ + #else + #error "This header has not been ported for your CPU" + #endif +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_cpu_riscv64.h +@@ -0,0 +1,121 @@ ++/* Copyright 2013 Google Inc. ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are ++ * met: ++ * ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above ++ * copyright notice, this list of conditions and the following disclaimer ++ * in the documentation and/or other materials provided with the ++ * distribution. ++ * * Neither the name of Google Inc. nor the names of its ++ * contributors may be used to endorse or promote products derived from ++ * this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ++ ++/* minidump_format.h: A cross-platform reimplementation of minidump-related ++ * portions of DbgHelp.h from the Windows Platform SDK. ++ * ++ * (This is C99 source, please don't corrupt it with C++.) ++ * ++ * This file contains the necessary definitions to read minidump files ++ * produced on ARM. These files may be read on any platform provided ++ * that the alignments of these structures on the processing system are ++ * identical to the alignments of these structures on the producing system. ++ * For this reason, precise-sized types are used. The structures defined ++ * by this file have been laid out to minimize alignment problems by ++ * ensuring that all members are aligned on their natural boundaries. ++ * In some cases, tail-padding may be significant when different ABIs specify ++ * different tail-padding behaviors. To avoid problems when reading or ++ * writing affected structures, MD_*_SIZE macros are provided where needed, ++ * containing the useful size of the structures without padding. ++ * ++ * Structures that are defined by Microsoft to contain a zero-length array ++ * are instead defined here to contain an array with one element, as ++ * zero-length arrays are forbidden by standard C and C++. In these cases, ++ * *_minsize constants are provided to be used in place of sizeof. For a ++ * cleaner interface to these sizes when using C++, see minidump_size.h. ++ * ++ * These structures are also sufficient to populate minidump files. ++ * ++ * Because precise data type sizes are crucial for this implementation to ++ * function properly and portably, a set of primitive types with known sizes ++ * are used as the basis of each structure defined by this file. ++ * ++ * Author: Colin Blundell ++ */ ++ ++/* ++ * RISCV64 support ++ */ ++ ++#ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ ++#define GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ ++ ++#include "google_breakpad/common/breakpad_types.h" ++ ++#define MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT 32 ++#define MD_CONTEXT_RISCV64_GPR_COUNT 32 ++ ++typedef struct { ++ /* 32 64-bit floating point registers, f0 .. f31. */ ++ uint64_t regs[MD_FLOATINGSAVEAREA_RISCV64_FPR_COUNT]; ++ ++ uint32_t fcsr; /* FPU control and status register */ ++} MDFloatingSaveAreaRISCV64; ++ ++/* For (MDRawContextRISCV64).context_flags. These values indicate the type of ++ * context stored in the structure. */ ++#define MD_CONTEXT_RISCV64 0x00400000 ++#define MD_CONTEXT_RISCV64_CONTROL (MD_CONTEXT_RISCV64 | 0x00000001) ++#define MD_CONTEXT_RISCV64_INTEGER (MD_CONTEXT_RISCV64 | 0x00000002) ++#define MD_CONTEXT_RISCV64_FLOATING_POINT (MD_CONTEXT_RISCV64 | 0x00000004) ++#define MD_CONTEXT_RISCV64_DEBUG (MD_CONTEXT_RISCV64 | 0x00000008) ++#define MD_CONTEXT_RISCV64_FULL (MD_CONTEXT_RISCV64_CONTROL | \ ++ MD_CONTEXT_RISCV64_INTEGER | \ ++ MD_CONTEXT_RISCV64_FLOATING_POINT) ++#define MD_CONTEXT_RISCV64_ALL (MD_CONTEXT_RISCV64_FULL | MD_CONTEXT_RISCV64_DEBUG) ++ ++typedef struct { ++ /* Determines which fields of this struct are populated */ ++ uint32_t context_flags; ++ ++ /* 32 64-bit integer registers, x1 .. x31 + the PC ++ * Note the following fixed uses: ++ * x8 is the frame pointer ++ * x1 is the link register ++ * x2 is the stack pointer ++ * The PC is effectively x0. ++ */ ++ uint64_t iregs[MD_CONTEXT_RISCV64_GPR_COUNT]; ++ ++ /* The next field is included with MD_CONTEXT64_ARM_FLOATING_POINT */ ++ MDFloatingSaveAreaRISCV64 float_save; ++ ++} MDRawContextRISCV64; ++ ++/* Indices into iregs for registers with a dedicated or conventional ++ * purpose. ++ */ ++enum MDRISCV64RegisterNumbers { ++ MD_CONTEXT_RISCV64_REG_FP = 8, ++ MD_CONTEXT_RISCV64_REG_RA = 1, ++ MD_CONTEXT_RISCV64_REG_SP = 2, ++ MD_CONTEXT_RISCV64_REG_PC = 0 ++}; ++ ++#endif /* GOOGLE_BREAKPAD_COMMON_MINIDUMP_CPU_RISCV64_H__ */ +--- a/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h ++++ b/src/3rdparty/chromium/third_party/breakpad/breakpad/src/google_breakpad/common/minidump_format.h +@@ -118,6 +118,7 @@ + #include "minidump_cpu_mips.h" + #include "minidump_cpu_ppc.h" + #include "minidump_cpu_ppc64.h" ++#include "minidump_cpu_riscv64.h" + #include "minidump_cpu_sparc.h" + #include "minidump_cpu_x86.h" + +@@ -660,6 +661,7 @@ + MD_CPU_ARCHITECTURE_PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */ + MD_CPU_ARCHITECTURE_ARM64_OLD = 0x8003, /* Breakpad-defined value for ARM64 */ + MD_CPU_ARCHITECTURE_MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */ ++ MD_CPU_ARCHITECTURE_RISCV64 = 0x8005, /* Breakpad-defined value for RISCV64 */ + MD_CPU_ARCHITECTURE_UNKNOWN = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */ + } MDCPUArchitecture; + +--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc ++++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/ptracer.cc +@@ -398,6 +398,51 @@ + return true; + } + ++#elif defined(ARCH_CPU_RISCV_FAMILY) ++ ++template ++bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) { ++ iovec iov; ++ iov.iov_base = dest; ++ iov.iov_len = sizeof(*dest); ++ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast(set), &iov) != 0) { ++ PLOG_IF(ERROR, can_log) << "ptrace"; ++ return false; ++ } ++ if (iov.iov_len != sizeof(*dest)) { ++ LOG_IF(ERROR, can_log) << "Unexpected registers size"; ++ return false; ++ } ++ return true; ++} ++ ++bool GetFloatingPointRegisters32(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return false; ++} ++ ++bool GetFloatingPointRegisters64(pid_t tid, ++ FloatContext* context, ++ bool can_log) { ++ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log); ++} ++ ++bool GetThreadArea32(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ return false; ++} ++ ++bool GetThreadArea64(pid_t tid, ++ const ThreadContext& context, ++ LinuxVMAddress* address, ++ bool can_log) { ++ *address = context.t64.tp; ++ return true; ++} ++ + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +--- a/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h ++++ b/src/3rdparty/chromium/third_party/crashpad/crashpad/util/linux/thread_info.h +@@ -79,6 +79,40 @@ + uint32_t cp0_status; + uint32_t cp0_cause; + uint32_t padding1_; ++#elif defined(ARCH_CPU_RISCV_FAMILY) ++ // Reflects user_regs_struct in asm/ptrace.h. ++ uint32_t pc; ++ uint32_t ra; ++ uint32_t sp; ++ uint32_t gp; ++ uint32_t tp; ++ uint32_t t0; ++ uint32_t t1; ++ uint32_t t2; ++ uint32_t s0; ++ uint32_t s1; ++ uint32_t a0; ++ uint32_t a1; ++ uint32_t a2; ++ uint32_t a3; ++ uint32_t a4; ++ uint32_t a5; ++ uint32_t a6; ++ uint32_t a7; ++ uint32_t s2; ++ uint32_t s3; ++ uint32_t s4; ++ uint32_t s5; ++ uint32_t s6; ++ uint32_t s7; ++ uint32_t s8; ++ uint32_t s9; ++ uint32_t s10; ++ uint32_t s11; ++ uint32_t t3; ++ uint32_t t4; ++ uint32_t t5; ++ uint32_t t6; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -132,6 +166,40 @@ + uint64_t cp0_badvaddr; + uint64_t cp0_status; + uint64_t cp0_cause; ++#elif defined(ARCH_CPU_RISCV_FAMILY) ++ // Reflects user_regs_struct in asm/ptrace.h. ++ uint64_t pc; ++ uint64_t ra; ++ uint64_t sp; ++ uint64_t gp; ++ uint64_t tp; ++ uint64_t t0; ++ uint64_t t1; ++ uint64_t t2; ++ uint64_t s0; ++ uint64_t s1; ++ uint64_t a0; ++ uint64_t a1; ++ uint64_t a2; ++ uint64_t a3; ++ uint64_t a4; ++ uint64_t a5; ++ uint64_t a6; ++ uint64_t a7; ++ uint64_t s2; ++ uint64_t s3; ++ uint64_t s4; ++ uint64_t s5; ++ uint64_t s6; ++ uint64_t s7; ++ uint64_t s8; ++ uint64_t s9; ++ uint64_t s10; ++ uint64_t s11; ++ uint64_t t3; ++ uint64_t t4; ++ uint64_t t5; ++ uint64_t t6; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -143,11 +211,12 @@ + using NativeThreadContext = user_regs; + #elif defined(ARCH_CPU_MIPS_FAMILY) + // No appropriate NativeThreadsContext type available for MIPS ++#elif defined(ARCH_CPU_RISCV_FAMILY) + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64 + +-#if !defined(ARCH_CPU_MIPS_FAMILY) ++#if !defined(ARCH_CPU_MIPS_FAMILY) && !defined(ARCH_CPU_RISCV_FAMILY) + #if defined(ARCH_CPU_32_BITS) + static_assert(sizeof(t32_t) == sizeof(NativeThreadContext), "Size mismatch"); + #else // ARCH_CPU_64_BITS +@@ -218,6 +287,9 @@ + } fpregs[32]; + uint32_t fpcsr; + uint32_t fpu_id; ++#elif defined(ARCH_CPU_RISCV_FAMILY) ++ uint64_t f[32]; ++ uint32_t fcsr; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -252,6 +324,9 @@ + double fpregs[32]; + uint32_t fpcsr; + uint32_t fpu_id; ++#elif defined(ARCH_CPU_RISCV_FAMILY) ++ uint64_t f[32]; ++ uint32_t fcsr; + #else + #error Port. + #endif // ARCH_CPU_X86_FAMILY +@@ -280,6 +355,7 @@ + static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch"); + #elif defined(ARCH_CPU_MIPS_FAMILY) + // No appropriate floating point context native type for available MIPS. ++#elif defined(ARCH_CPU_RISCV_FAMILY) + #else + #error Port. + #endif // ARCH_CPU_X86 +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/dav1d/config/linux/riscv64/config.h +@@ -0,0 +1,38 @@ ++/* ++ * Autogenerated by the Meson build system. ++ * Do not edit, your changes will be lost. ++ */ ++ ++#pragma once ++ ++#define ARCH_AARCH64 0 ++ ++#define ARCH_ARM 0 ++ ++#define ARCH_PPC64LE 0 ++ ++#define ARCH_X86 0 ++ ++#define ARCH_X86_32 0 ++ ++#define ARCH_X86_64 0 ++ ++#define CONFIG_16BPC 1 ++ ++#define CONFIG_8BPC 1 ++ ++// #define CONFIG_LOG 1 -- Logging is controlled by Chromium ++ ++#define ENDIANNESS_BIG 0 ++ ++#define HAVE_ASM 0 ++ ++#define HAVE_AS_FUNC 0 ++ ++#define HAVE_CLOCK_GETTIME 1 ++ ++#define HAVE_GETAUXVAL 1 ++ ++#define HAVE_POSIX_MEMALIGN 1 ++ ++#define HAVE_UNISTD_H 1 +--- a/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h ++++ b/src/3rdparty/chromium/third_party/lss/linux_syscall_support.h +@@ -88,7 +88,7 @@ + */ + #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ + defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \ +- defined(__aarch64__) || defined(__s390__)) \ ++ defined(__aarch64__) || defined(__s390__) || defined(__riscv)) \ + && (defined(__linux) || defined(__ANDROID__)) + + #ifndef SYS_CPLUSPLUS +@@ -301,7 +301,7 @@ + } __attribute__((packed,aligned(4))); + #elif (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) + #define kernel_old_sigaction kernel_sigaction +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__riscv) + // No kernel_old_sigaction defined for arm64. + #endif + +@@ -519,7 +519,7 @@ + int st_blocks; + int st_pad4[14]; + }; +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__riscv) + struct kernel_stat { + unsigned long st_dev; + unsigned long st_ino; +@@ -1065,7 +1065,7 @@ + #define __NR_getrandom (__NR_SYSCALL_BASE + 384) + #endif + /* End of ARM 3/EABI definitions */ +-#elif defined(__aarch64__) ++#elif defined(__aarch64__) || defined(__riscv) + #ifndef __NR_setxattr + #define __NR_setxattr 5 + #endif +@@ -1880,7 +1880,7 @@ + + #undef LSS_RETURN + #if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) \ +- || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__)) ++ || defined(__ARM_EABI__) || defined(__aarch64__) || defined(__s390__) || defined(__riscv)) + /* Failing system calls return a negative result in the range of + * -1..-4095. These are "errno" values with the sign inverted. + */ +@@ -3373,6 +3373,122 @@ + } + LSS_RETURN(int, __ret); + } ++ #elif defined(__riscv) ++ #undef LSS_REG ++ #define LSS_REG(r,a) register int64_t __r##r __asm__("a"#r) = (int64_t)a ++ #undef LSS_BODY ++ #define LSS_BODY(type,name,args...) \ ++ register int64_t __res_a0 __asm__("a0"); \ ++ register int64_t __a7 __asm__("a7") = __NR_##name; \ ++ int64_t __res; \ ++ __asm__ __volatile__ ("scall\n" \ ++ : "=r"(__res_a0) \ ++ : "r"(__a7) , ## args \ ++ : "memory"); \ ++ __res = __res_a0; \ ++ LSS_RETURN(type, __res) ++ #undef _syscall0 ++ #define _syscall0(type, name) \ ++ type LSS_NAME(name)(void) { \ ++ LSS_BODY(type, name); \ ++ } ++ #undef _syscall1 ++ #define _syscall1(type, name, type1, arg1) \ ++ type LSS_NAME(name)(type1 arg1) { \ ++ LSS_REG(0, arg1); LSS_BODY(type, name, "r"(__r0)); \ ++ } ++ #undef _syscall2 ++ #define _syscall2(type, name, type1, arg1, type2, arg2) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1)); \ ++ } ++ #undef _syscall3 ++ #define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2)); \ ++ } ++ #undef _syscall4 ++ #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3)); \ ++ } ++ #undef _syscall5 ++ #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ ++ type5,arg5) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ ++ type5 arg5) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); LSS_REG(4, arg5); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ ++ "r"(__r4)); \ ++ } ++ #undef _syscall6 ++ #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ ++ type5,arg5,type6,arg6) \ ++ type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ ++ type5 arg5, type6 arg6) { \ ++ LSS_REG(0, arg1); LSS_REG(1, arg2); LSS_REG(2, arg3); \ ++ LSS_REG(3, arg4); LSS_REG(4, arg5); LSS_REG(5, arg6); \ ++ LSS_BODY(type, name, "r"(__r0), "r"(__r1), "r"(__r2), "r"(__r3), \ ++ "r"(__r4), "r"(__r5)); \ ++ } ++ ++ LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, ++ int flags, void *arg, int *parent_tidptr, ++ void *newtls, int *child_tidptr) { ++ int64_t __res; ++ { ++ register int64_t __res_a0 __asm__("a0"); ++ register uint64_t __flags __asm__("a0") = flags; ++ register void *__stack __asm__("a1") = child_stack; ++ register void *__ptid __asm__("a2") = parent_tidptr; ++ register void *__tls __asm__("a3") = newtls; ++ register int *__ctid __asm__("a4") = child_tidptr; ++ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be ++ * used by the child. ++ */ ++ "addi %2,%2,-16\n" ++ "sd %1, 0(%2)\n" ++ "sd %4, 8(%2)\n" ++ ++ /* %a0 = syscall(%a0 = flags, ++ * %a1 = child_stack, ++ * %a2 = parent_tidptr, ++ * %a3 = newtls, ++ * %a4 = child_tidptr) ++ */ ++ "li a7, %8\n" ++ "scall\n" ++ ++ /* if (%a0 != 0) ++ * return %a0; ++ */ ++ "bnez %0, 1f\n" ++ ++ /* In the child, now. Call "fn(arg)". ++ */ ++ "ld a1, 0(sp)\n" ++ "ld a0, 8(sp)\n" ++ "jalr a1\n" ++ ++ /* Call _exit(%a0). ++ */ ++ "li a7, %9\n" ++ "scall\n" ++ "1:\n" ++ : "=r" (__res_a0) ++ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), ++ "r"(__ptid), "r"(__tls), "r"(__ctid), ++ "i"(__NR_clone), "i"(__NR_exit) ++ : "cc", "memory"); ++ __res = __res_a0; ++ } ++ LSS_RETURN(int, __res); ++ } + #endif + #define __NR__exit __NR_exit + #define __NR__gettid __NR_gettid +@@ -4181,7 +4297,7 @@ + LSS_SC_BODY(4, int, 8, d, type, protocol, sv); + } + #endif +- #if defined(__ARM_EABI__) || defined (__aarch64__) ++ #if defined(__ARM_EABI__) || defined (__aarch64__) || defined(__riscv) + LSS_INLINE _syscall3(ssize_t, recvmsg, int, s, struct kernel_msghdr*, msg, + int, flags) + LSS_INLINE _syscall3(ssize_t, sendmsg, int, s, const struct kernel_msghdr*, +@@ -4503,7 +4619,7 @@ + // TODO: define this in an arch-independant way instead of inlining the clone + // syscall body. + +-# if defined(__aarch64__) ++# if defined(__aarch64__) || defined(__riscv) + LSS_INLINE pid_t LSS_NAME(fork)(void) { + // No fork syscall on aarch64 - implement by means of the clone syscall. + // Note that this does not reset glibc's cached view of the PID/TID, so +--- a/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn ++++ b/src/3rdparty/chromium/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn +@@ -149,6 +149,7 @@ + deps += [ ":swiftshader_llvm_ppc" ] + } else if (current_cpu == "x86" || current_cpu == "x64") { + deps += [ ":swiftshader_llvm_x86" ] ++ } else if (current_cpu == "riscv64") { + } else { + assert(false, "Unsupported current_cpu") + } +--- a/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc ++++ b/src/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/differ_block.cc +@@ -30,7 +30,7 @@ + static bool (*diff_proc)(const uint8_t*, const uint8_t*) = nullptr; + + if (!diff_proc) { +-#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) ++#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_MIPS_FAMILY) || defined(WEBRTC_ARCH_RISCV_FAMILY) + // For ARM and MIPS processors, always use C version. + // TODO(hclam): Implement a NEON version. + diff_proc = &VectorDifference_C; +--- a/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h ++++ b/src/3rdparty/chromium/third_party/webrtc/rtc_base/system/arch.h +@@ -50,6 +50,10 @@ + #elif defined(__EMSCRIPTEN__) + #define WEBRTC_ARCH_32_BITS + #define WEBRTC_ARCH_LITTLE_ENDIAN ++#elif defined(__riscv) && __riscv_xlen == 64 ++#define WEBRTC_ARCH_RISCV_FAMILY ++#define WEBRTC_ARCH_64_BITS ++#define WEBRTC_ARCH_LITTLE_ENDIAN + #else + #error Please add support for your architecture in rtc_base/system/arch.h + #endif +--- a/src/3rdparty/gn/tools/gn/args.cc ++++ b/src/3rdparty/gn/tools/gn/args.cc +@@ -329,6 +329,7 @@ + static const char kMips64[] = "mips64el"; + static const char kS390X[] = "s390x"; + static const char kPPC64[] = "ppc64"; ++ static const char kRiscv64[] = "riscv64"; + const char* arch = nullptr; + + // Set the host CPU architecture based on the underlying OS, not +@@ -353,6 +354,8 @@ + // This allows us to use the same toolchain as ppc64 BE + // and specific flags are included using the host_byteorder logic. + arch = kPPC64; ++ else if (os_arch == "riscv64") ++ arch = kRiscv64; + else + CHECK(false) << "OS architecture not handled. (" << os_arch << ")"; + +--- a/src/3rdparty/gn/util/build_config.h ++++ b/src/3rdparty/gn/util/build_config.h +@@ -172,6 +172,16 @@ + #define ARCH_CPU_32_BITS 1 + #define ARCH_CPU_BIG_ENDIAN 1 + #endif ++#elif defined(__riscv) ++#define ARCH_CPU_RISCV_FAMILY 1 ++#if __riscv_xlen == 64 ++#define ARCH_CPU_RISCV64 1 ++#define ARCH_CPU_64_BITS 1 ++#else ++#define ARCH_CPU_RISCV32 1 ++#define ARCH_CPU_32_BITS 1 ++#endif ++#define ARCH_CPU_LITTLE_ENDIAN 1 + #else + #error Please add support for your architecture in build_config.h + #endif +--- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/build_ffmpeg.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # Copyright 2014 The Chromium Authors. All rights reserved. + # Use of this source code is governed by a BSD-style license that can be +@@ -37,7 +37,7 @@ + 'android': ['ia32', 'x64', 'arm-neon', 'arm64'], + 'linux': [ + 'ia32', 'x64', 'mipsel', 'mips64el', 'noasm-x64', 'arm', 'arm-neon', +- 'arm64' ++ 'arm64', 'riscv64' + ], + 'mac': ['x64', 'arm64'], + 'win': ['ia32', 'x64', 'arm64'], +@@ -139,6 +139,8 @@ + host_arch = 'mips64el' + elif platform.machine().startswith('arm'): + host_arch = 'arm' ++ elif platform.machine() == 'riscv64': ++ host_arch = 'riscv64' + else: + return None + +@@ -820,6 +822,10 @@ + '--extra-cflags=--target=mips64el-linux-gnuabi64', + '--extra-ldflags=--target=mips64el-linux-gnuabi64', + ]) ++ elif target_arch == 'riscv64': ++ configure_flags['Common'].extend([ ++ '--arch=riscv64', ++ ]) + else: + print( + 'Error: Unknown target arch %r for target OS %r!' % (target_arch, +@@ -833,7 +839,9 @@ + '--disable-inline-asm', + ]) + +- if 'win' not in target_os: ++ if platform.machine() == 'riscv64': ++ pass ++ elif 'win' not in target_os: + configure_flags['Common'].extend([ + '--enable-pic', + '--cc=clang', +--- a/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/scripts/copy_config.sh +@@ -10,7 +10,7 @@ + # Copy config files for various architectures: + # - ia32/x64 have config.asm, config.h + # - arm/arm-neon have config.h +- for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el; do ++ for arch in arm arm-neon arm64 ia32 x64 mipsel mips64el riscv64; do + # Don't waste time on non-existent configs, if no config.h then skip. + [ ! -e "build.$arch.$os/$target/config.h" ] && continue + for f in config.h config.asm libavutil/avconfig.h libavutil/ffversion.h libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c; do +--- a/src/3rdparty/chromium/third_party/ffmpeg/configure ++++ b/src/3rdparty/chromium/third_party/ffmpeg/configure +@@ -1990,6 +1990,7 @@ + parisc + ppc + ppc64 ++ riscv + s390 + sh4 + sparc +@@ -2597,7 +2598,7 @@ + done + + aligned_stack_if_any="aarch64 ppc x86" +-fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64" ++fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 riscv64 sparc64 x86_64" + fast_clz_if_any="aarch64 alpha avr32 mips ppc x86" + fast_unaligned_if_any="aarch64 ppc x86" + simd_align_16_if_any="altivec neon sse" +@@ -4890,6 +4891,9 @@ + "Power Macintosh"|ppc*|powerpc*) + arch="ppc" + ;; ++ riscv*) ++ arch="riscv" ++ ;; + s390|s390x) + arch="s390" + ;; +@@ -5290,6 +5294,10 @@ + check_64bit ppc ppc64 + enabled shared && enable_weak pic + ;; ++ riscv) ++ check_64bit riscv32 riscv64 ++ enabled shared && enable_weak pic ++ ;; + s390) + check_64bit s390 s390x + enabled shared && enable_weak pic +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/config.h +@@ -0,0 +1,2626 @@ ++/* Automatically generated by configure - do not modify! */ ++#ifndef FFMPEG_CONFIG_H ++#define FFMPEG_CONFIG_H ++/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64 --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264'" -- elide long configuration string from binary */ ++#define FFMPEG_LICENSE "LGPL version 2.1 or later" ++#define CONFIG_THIS_YEAR 2020 ++#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" ++#define AVCONV_DATADIR "/usr/local/share/ffmpeg" ++#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" ++#define av_restrict restrict ++#define EXTERN_PREFIX "" ++#define EXTERN_ASM ++#define BUILDSUF "" ++#define SLIBSUF ".so" ++#define HAVE_MMX2 HAVE_MMXEXT ++#define SWS_MAX_FILTER_SIZE 256 ++#define ARCH_AARCH64 0 ++#define ARCH_ALPHA 0 ++#define ARCH_ARM 0 ++#define ARCH_AVR32 0 ++#define ARCH_AVR32_AP 0 ++#define ARCH_AVR32_UC 0 ++#define ARCH_BFIN 0 ++#define ARCH_IA64 0 ++#define ARCH_M68K 0 ++#define ARCH_MIPS 0 ++#define ARCH_MIPS64 0 ++#define ARCH_PARISC 0 ++#define ARCH_PPC 0 ++#define ARCH_PPC64 0 ++#define ARCH_RISCV 1 ++#define ARCH_S390 0 ++#define ARCH_SH4 0 ++#define ARCH_SPARC 0 ++#define ARCH_SPARC64 0 ++#define ARCH_TILEGX 0 ++#define ARCH_TILEPRO 0 ++#define ARCH_TOMI 0 ++#define ARCH_X86 0 ++#define ARCH_X86_32 0 ++#define ARCH_X86_64 0 ++#define HAVE_ARMV5TE 0 ++#define HAVE_ARMV6 0 ++#define HAVE_ARMV6T2 0 ++#define HAVE_ARMV8 0 ++#define HAVE_NEON 0 ++#define HAVE_VFP 0 ++#define HAVE_VFPV3 0 ++#define HAVE_SETEND 0 ++#define HAVE_ALTIVEC 0 ++#define HAVE_DCBZL 0 ++#define HAVE_LDBRX 0 ++#define HAVE_POWER8 0 ++#define HAVE_PPC4XX 0 ++#define HAVE_VSX 0 ++#define HAVE_AESNI 0 ++#define HAVE_AMD3DNOW 0 ++#define HAVE_AMD3DNOWEXT 0 ++#define HAVE_AVX 0 ++#define HAVE_AVX2 0 ++#define HAVE_AVX512 0 ++#define HAVE_FMA3 0 ++#define HAVE_FMA4 0 ++#define HAVE_MMX 0 ++#define HAVE_MMXEXT 0 ++#define HAVE_SSE 0 ++#define HAVE_SSE2 0 ++#define HAVE_SSE3 0 ++#define HAVE_SSE4 0 ++#define HAVE_SSE42 0 ++#define HAVE_SSSE3 0 ++#define HAVE_XOP 0 ++#define HAVE_CPUNOP 0 ++#define HAVE_I686 0 ++#define HAVE_MIPSFPU 0 ++#define HAVE_MIPS32R2 0 ++#define HAVE_MIPS32R5 0 ++#define HAVE_MIPS64R2 0 ++#define HAVE_MIPS32R6 0 ++#define HAVE_MIPS64R6 0 ++#define HAVE_MIPSDSP 0 ++#define HAVE_MIPSDSPR2 0 ++#define HAVE_MSA 0 ++#define HAVE_MSA2 0 ++#define HAVE_LOONGSON2 0 ++#define HAVE_LOONGSON3 0 ++#define HAVE_MMI 0 ++#define HAVE_ARMV5TE_EXTERNAL 0 ++#define HAVE_ARMV6_EXTERNAL 0 ++#define HAVE_ARMV6T2_EXTERNAL 0 ++#define HAVE_ARMV8_EXTERNAL 0 ++#define HAVE_NEON_EXTERNAL 0 ++#define HAVE_VFP_EXTERNAL 0 ++#define HAVE_VFPV3_EXTERNAL 0 ++#define HAVE_SETEND_EXTERNAL 0 ++#define HAVE_ALTIVEC_EXTERNAL 0 ++#define HAVE_DCBZL_EXTERNAL 0 ++#define HAVE_LDBRX_EXTERNAL 0 ++#define HAVE_POWER8_EXTERNAL 0 ++#define HAVE_PPC4XX_EXTERNAL 0 ++#define HAVE_VSX_EXTERNAL 0 ++#define HAVE_AESNI_EXTERNAL 0 ++#define HAVE_AMD3DNOW_EXTERNAL 0 ++#define HAVE_AMD3DNOWEXT_EXTERNAL 0 ++#define HAVE_AVX_EXTERNAL 0 ++#define HAVE_AVX2_EXTERNAL 0 ++#define HAVE_AVX512_EXTERNAL 0 ++#define HAVE_FMA3_EXTERNAL 0 ++#define HAVE_FMA4_EXTERNAL 0 ++#define HAVE_MMX_EXTERNAL 0 ++#define HAVE_MMXEXT_EXTERNAL 0 ++#define HAVE_SSE_EXTERNAL 0 ++#define HAVE_SSE2_EXTERNAL 0 ++#define HAVE_SSE3_EXTERNAL 0 ++#define HAVE_SSE4_EXTERNAL 0 ++#define HAVE_SSE42_EXTERNAL 0 ++#define HAVE_SSSE3_EXTERNAL 0 ++#define HAVE_XOP_EXTERNAL 0 ++#define HAVE_CPUNOP_EXTERNAL 0 ++#define HAVE_I686_EXTERNAL 0 ++#define HAVE_MIPSFPU_EXTERNAL 0 ++#define HAVE_MIPS32R2_EXTERNAL 0 ++#define HAVE_MIPS32R5_EXTERNAL 0 ++#define HAVE_MIPS64R2_EXTERNAL 0 ++#define HAVE_MIPS32R6_EXTERNAL 0 ++#define HAVE_MIPS64R6_EXTERNAL 0 ++#define HAVE_MIPSDSP_EXTERNAL 0 ++#define HAVE_MIPSDSPR2_EXTERNAL 0 ++#define HAVE_MSA_EXTERNAL 0 ++#define HAVE_MSA2_EXTERNAL 0 ++#define HAVE_LOONGSON2_EXTERNAL 0 ++#define HAVE_LOONGSON3_EXTERNAL 0 ++#define HAVE_MMI_EXTERNAL 0 ++#define HAVE_ARMV5TE_INLINE 0 ++#define HAVE_ARMV6_INLINE 0 ++#define HAVE_ARMV6T2_INLINE 0 ++#define HAVE_ARMV8_INLINE 0 ++#define HAVE_NEON_INLINE 0 ++#define HAVE_VFP_INLINE 0 ++#define HAVE_VFPV3_INLINE 0 ++#define HAVE_SETEND_INLINE 0 ++#define HAVE_ALTIVEC_INLINE 0 ++#define HAVE_DCBZL_INLINE 0 ++#define HAVE_LDBRX_INLINE 0 ++#define HAVE_POWER8_INLINE 0 ++#define HAVE_PPC4XX_INLINE 0 ++#define HAVE_VSX_INLINE 0 ++#define HAVE_AESNI_INLINE 0 ++#define HAVE_AMD3DNOW_INLINE 0 ++#define HAVE_AMD3DNOWEXT_INLINE 0 ++#define HAVE_AVX_INLINE 0 ++#define HAVE_AVX2_INLINE 0 ++#define HAVE_AVX512_INLINE 0 ++#define HAVE_FMA3_INLINE 0 ++#define HAVE_FMA4_INLINE 0 ++#define HAVE_MMX_INLINE 0 ++#define HAVE_MMXEXT_INLINE 0 ++#define HAVE_SSE_INLINE 0 ++#define HAVE_SSE2_INLINE 0 ++#define HAVE_SSE3_INLINE 0 ++#define HAVE_SSE4_INLINE 0 ++#define HAVE_SSE42_INLINE 0 ++#define HAVE_SSSE3_INLINE 0 ++#define HAVE_XOP_INLINE 0 ++#define HAVE_CPUNOP_INLINE 0 ++#define HAVE_I686_INLINE 0 ++#define HAVE_MIPSFPU_INLINE 0 ++#define HAVE_MIPS32R2_INLINE 0 ++#define HAVE_MIPS32R5_INLINE 0 ++#define HAVE_MIPS64R2_INLINE 0 ++#define HAVE_MIPS32R6_INLINE 0 ++#define HAVE_MIPS64R6_INLINE 0 ++#define HAVE_MIPSDSP_INLINE 0 ++#define HAVE_MIPSDSPR2_INLINE 0 ++#define HAVE_MSA_INLINE 0 ++#define HAVE_MSA2_INLINE 0 ++#define HAVE_LOONGSON2_INLINE 0 ++#define HAVE_LOONGSON3_INLINE 0 ++#define HAVE_MMI_INLINE 0 ++#define HAVE_ALIGNED_STACK 0 ++#define HAVE_FAST_64BIT 1 ++#define HAVE_FAST_CLZ 0 ++#define HAVE_FAST_CMOV 0 ++#define HAVE_LOCAL_ALIGNED 0 ++#define HAVE_SIMD_ALIGN_16 0 ++#define HAVE_SIMD_ALIGN_32 0 ++#define HAVE_SIMD_ALIGN_64 0 ++#define HAVE_ATOMIC_CAS_PTR 0 ++#define HAVE_MACHINE_RW_BARRIER 0 ++#define HAVE_MEMORYBARRIER 0 ++#define HAVE_MM_EMPTY 0 ++#define HAVE_RDTSC 0 ++#define HAVE_SEM_TIMEDWAIT 1 ++#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 ++#define HAVE_CABS 0 ++#define HAVE_CEXP 0 ++#define HAVE_INLINE_ASM 1 ++#define HAVE_SYMVER 0 ++#define HAVE_X86ASM 0 ++#define HAVE_BIGENDIAN 0 ++#define HAVE_FAST_UNALIGNED 0 ++#define HAVE_ARPA_INET_H 0 ++#define HAVE_ASM_TYPES_H 1 ++#define HAVE_CDIO_PARANOIA_H 0 ++#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 ++#define HAVE_CUDA_H 0 ++#define HAVE_DISPATCH_DISPATCH_H 0 ++#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 ++#define HAVE_DEV_IC_BT8XX_H 0 ++#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 ++#define HAVE_DIRECT_H 0 ++#define HAVE_DIRENT_H 1 ++#define HAVE_DXGIDEBUG_H 0 ++#define HAVE_DXVA_H 0 ++#define HAVE_ES2_GL_H 0 ++#define HAVE_GSM_H 0 ++#define HAVE_IO_H 0 ++#define HAVE_LINUX_PERF_EVENT_H 1 ++#define HAVE_MACHINE_IOCTL_BT848_H 0 ++#define HAVE_MACHINE_IOCTL_METEOR_H 0 ++#define HAVE_MALLOC_H 1 ++#define HAVE_OPENCV2_CORE_CORE_C_H 0 ++#define HAVE_OPENGL_GL3_H 0 ++#define HAVE_POLL_H 1 ++#define HAVE_SYS_PARAM_H 1 ++#define HAVE_SYS_RESOURCE_H 1 ++#define HAVE_SYS_SELECT_H 1 ++#define HAVE_SYS_SOUNDCARD_H 1 ++#define HAVE_SYS_TIME_H 1 ++#define HAVE_SYS_UN_H 1 ++#define HAVE_SYS_VIDEOIO_H 0 ++#define HAVE_TERMIOS_H 1 ++#define HAVE_UDPLITE_H 0 ++#define HAVE_UNISTD_H 1 ++#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ ++#define HAVE_WINDOWS_H 0 ++#define HAVE_WINSOCK2_H 0 ++#define HAVE_INTRINSICS_NEON 0 ++#define HAVE_ATANF 1 ++#define HAVE_ATAN2F 1 ++#define HAVE_CBRT 1 ++#define HAVE_CBRTF 1 ++#define HAVE_COPYSIGN 1 ++#define HAVE_COSF 1 ++#define HAVE_ERF 1 ++#define HAVE_EXP2 1 ++#define HAVE_EXP2F 1 ++#define HAVE_EXPF 1 ++#define HAVE_HYPOT 1 ++#define HAVE_ISFINITE 1 ++#define HAVE_ISINF 1 ++#define HAVE_ISNAN 1 ++#define HAVE_LDEXPF 1 ++#define HAVE_LLRINT 1 ++#define HAVE_LLRINTF 1 ++#define HAVE_LOG2 1 ++#define HAVE_LOG2F 1 ++#define HAVE_LOG10F 1 ++#define HAVE_LRINT 1 ++#define HAVE_LRINTF 1 ++#define HAVE_POWF 1 ++#define HAVE_RINT 1 ++#define HAVE_ROUND 1 ++#define HAVE_ROUNDF 1 ++#define HAVE_SINF 1 ++#define HAVE_TRUNC 1 ++#define HAVE_TRUNCF 1 ++#define HAVE_DOS_PATHS 0 ++#define HAVE_LIBC_MSVCRT 0 ++#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 ++#define HAVE_SECTION_DATA_REL_RO 1 ++#define HAVE_THREADS 1 ++#define HAVE_UWP 0 ++#define HAVE_WINRT 0 ++#define HAVE_ACCESS 1 ++#define HAVE_ALIGNED_MALLOC 0 ++#define HAVE_ARC4RANDOM 0 ++#define HAVE_CLOCK_GETTIME 1 ++#define HAVE_CLOSESOCKET 0 ++#define HAVE_COMMANDLINETOARGVW 0 ++#define HAVE_FCNTL 1 ++#define HAVE_GETADDRINFO 0 ++#define HAVE_GETHRTIME 0 ++#define HAVE_GETOPT 1 ++#define HAVE_GETMODULEHANDLE 0 ++#define HAVE_GETPROCESSAFFINITYMASK 0 ++#define HAVE_GETPROCESSMEMORYINFO 0 ++#define HAVE_GETPROCESSTIMES 0 ++#define HAVE_GETRUSAGE 1 ++#define HAVE_GETSTDHANDLE 0 ++#define HAVE_GETSYSTEMTIMEASFILETIME 0 ++#define HAVE_GETTIMEOFDAY 1 ++#define HAVE_GLOB 1 ++#define HAVE_GLXGETPROCADDRESS 0 ++#define HAVE_GMTIME_R 1 ++#define HAVE_INET_ATON 0 ++#define HAVE_ISATTY 1 ++#define HAVE_KBHIT 0 ++#define HAVE_LOCALTIME_R 1 ++#define HAVE_LSTAT 1 ++#define HAVE_LZO1X_999_COMPRESS 0 ++#define HAVE_MACH_ABSOLUTE_TIME 0 ++#define HAVE_MAPVIEWOFFILE 0 ++#define HAVE_MEMALIGN 1 ++#define HAVE_MKSTEMP 1 ++#define HAVE_MMAP 1 ++#define HAVE_MPROTECT 1 ++#define HAVE_NANOSLEEP 1 ++#define HAVE_PEEKNAMEDPIPE 0 ++#define HAVE_POSIX_MEMALIGN 1 ++#define HAVE_PTHREAD_CANCEL 1 ++#define HAVE_SCHED_GETAFFINITY 1 ++#define HAVE_SECITEMIMPORT 0 ++#define HAVE_SETCONSOLETEXTATTRIBUTE 0 ++#define HAVE_SETCONSOLECTRLHANDLER 0 ++#define HAVE_SETDLLDIRECTORY 0 ++#define HAVE_SETMODE 0 ++#define HAVE_SETRLIMIT 1 ++#define HAVE_SLEEP 0 ++#define HAVE_STRERROR_R 1 ++#define HAVE_SYSCONF 1 ++#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ ++#define HAVE_USLEEP 1 ++#define HAVE_UTGETOSTYPEFROMSTRING 0 ++#define HAVE_VIRTUALALLOC 0 ++#define HAVE_WGLGETPROCADDRESS 0 ++#define HAVE_BCRYPT 0 ++#define HAVE_VAAPI_DRM 0 ++#define HAVE_VAAPI_X11 0 ++#define HAVE_VDPAU_X11 0 ++#define HAVE_PTHREADS 1 ++#define HAVE_OS2THREADS 0 ++#define HAVE_W32THREADS 0 ++#define HAVE_AS_ARCH_DIRECTIVE 0 ++#define HAVE_AS_DN_DIRECTIVE 0 ++#define HAVE_AS_FPU_DIRECTIVE 0 ++#define HAVE_AS_FUNC 0 ++#define HAVE_AS_OBJECT_ARCH 0 ++#define HAVE_ASM_MOD_Q 0 ++#define HAVE_BLOCKS_EXTENSION 0 ++#define HAVE_EBP_AVAILABLE 0 ++#define HAVE_EBX_AVAILABLE 0 ++#define HAVE_GNU_AS 0 ++#define HAVE_GNU_WINDRES 0 ++#define HAVE_IBM_ASM 0 ++#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 ++#define HAVE_INLINE_ASM_LABELS 1 ++#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 ++#define HAVE_PRAGMA_DEPRECATED 1 ++#define HAVE_RSYNC_CONTIMEOUT 0 ++#define HAVE_SYMVER_ASM_LABEL 0 ++#define HAVE_SYMVER_GNU_ASM 1 ++#define HAVE_VFP_ARGS 0 ++#define HAVE_XFORM_ASM 0 ++#define HAVE_XMM_CLOBBERS 0 ++#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 ++#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 ++#define HAVE_SOCKLEN_T 0 ++#define HAVE_STRUCT_ADDRINFO 0 ++#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 ++#define HAVE_STRUCT_IP_MREQ_SOURCE 0 ++#define HAVE_STRUCT_IPV6_MREQ 0 ++#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 ++#define HAVE_STRUCT_POLLFD 0 ++#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 ++#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 ++#define HAVE_STRUCT_SOCKADDR_IN6 0 ++#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 ++#define HAVE_STRUCT_SOCKADDR_STORAGE 0 ++#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 ++#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 ++#define HAVE_LIBDRM_GETFB2 0 ++#define HAVE_MAKEINFO 0 ++#define HAVE_MAKEINFO_HTML 0 ++#define HAVE_OPENCL_D3D11 0 ++#define HAVE_OPENCL_DRM_ARM 0 ++#define HAVE_OPENCL_DRM_BEIGNET 0 ++#define HAVE_OPENCL_DXVA2 0 ++#define HAVE_OPENCL_VAAPI_BEIGNET 0 ++#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 ++#define HAVE_PERL 1 ++#define HAVE_POD2MAN 1 ++#define HAVE_TEXI2HTML 0 ++#define CONFIG_DOC 0 ++#define CONFIG_HTMLPAGES 0 ++#define CONFIG_MANPAGES 0 ++#define CONFIG_PODPAGES 0 ++#define CONFIG_TXTPAGES 0 ++#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 ++#define CONFIG_AVIO_READING_EXAMPLE 1 ++#define CONFIG_DECODE_AUDIO_EXAMPLE 1 ++#define CONFIG_DECODE_VIDEO_EXAMPLE 1 ++#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 ++#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 ++#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 ++#define CONFIG_EXTRACT_MVS_EXAMPLE 1 ++#define CONFIG_FILTER_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 ++#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 ++#define CONFIG_HW_DECODE_EXAMPLE 1 ++#define CONFIG_METADATA_EXAMPLE 1 ++#define CONFIG_MUXING_EXAMPLE 0 ++#define CONFIG_QSVDEC_EXAMPLE 0 ++#define CONFIG_REMUXING_EXAMPLE 1 ++#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 ++#define CONFIG_SCALING_VIDEO_EXAMPLE 0 ++#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 ++#define CONFIG_TRANSCODING_EXAMPLE 0 ++#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 ++#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 ++#define CONFIG_AVISYNTH 0 ++#define CONFIG_FREI0R 0 ++#define CONFIG_LIBCDIO 0 ++#define CONFIG_LIBDAVS2 0 ++#define CONFIG_LIBRUBBERBAND 0 ++#define CONFIG_LIBVIDSTAB 0 ++#define CONFIG_LIBX264 0 ++#define CONFIG_LIBX265 0 ++#define CONFIG_LIBXAVS 0 ++#define CONFIG_LIBXAVS2 0 ++#define CONFIG_LIBXVID 0 ++#define CONFIG_DECKLINK 0 ++#define CONFIG_LIBFDK_AAC 0 ++#define CONFIG_OPENSSL 0 ++#define CONFIG_LIBTLS 0 ++#define CONFIG_GMP 0 ++#define CONFIG_LIBARIBB24 0 ++#define CONFIG_LIBLENSFUN 0 ++#define CONFIG_LIBOPENCORE_AMRNB 0 ++#define CONFIG_LIBOPENCORE_AMRWB 0 ++#define CONFIG_LIBVO_AMRWBENC 0 ++#define CONFIG_MBEDTLS 0 ++#define CONFIG_RKMPP 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_CHROMAPRINT 0 ++#define CONFIG_GCRYPT 0 ++#define CONFIG_GNUTLS 0 ++#define CONFIG_JNI 0 ++#define CONFIG_LADSPA 0 ++#define CONFIG_LIBAOM 0 ++#define CONFIG_LIBASS 0 ++#define CONFIG_LIBBLURAY 0 ++#define CONFIG_LIBBS2B 0 ++#define CONFIG_LIBCACA 0 ++#define CONFIG_LIBCELT 0 ++#define CONFIG_LIBCODEC2 0 ++#define CONFIG_LIBDAV1D 0 ++#define CONFIG_LIBDC1394 0 ++#define CONFIG_LIBDRM 0 ++#define CONFIG_LIBFLITE 0 ++#define CONFIG_LIBFONTCONFIG 0 ++#define CONFIG_LIBFREETYPE 0 ++#define CONFIG_LIBFRIBIDI 0 ++#define CONFIG_LIBGLSLANG 0 ++#define CONFIG_LIBGME 0 ++#define CONFIG_LIBGSM 0 ++#define CONFIG_LIBIEC61883 0 ++#define CONFIG_LIBILBC 0 ++#define CONFIG_LIBJACK 0 ++#define CONFIG_LIBKLVANC 0 ++#define CONFIG_LIBKVAZAAR 0 ++#define CONFIG_LIBMODPLUG 0 ++#define CONFIG_LIBMP3LAME 0 ++#define CONFIG_LIBMYSOFA 0 ++#define CONFIG_LIBOPENCV 0 ++#define CONFIG_LIBOPENH264 0 ++#define CONFIG_LIBOPENJPEG 0 ++#define CONFIG_LIBOPENMPT 0 ++#define CONFIG_LIBOPENVINO 0 ++#define CONFIG_LIBOPUS 1 ++#define CONFIG_LIBPULSE 0 ++#define CONFIG_LIBRABBITMQ 0 ++#define CONFIG_LIBRAV1E 0 ++#define CONFIG_LIBRSVG 0 ++#define CONFIG_LIBRTMP 0 ++#define CONFIG_LIBSHINE 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_LIBSNAPPY 0 ++#define CONFIG_LIBSOXR 0 ++#define CONFIG_LIBSPEEX 0 ++#define CONFIG_LIBSRT 0 ++#define CONFIG_LIBSSH 0 ++#define CONFIG_LIBSVTAV1 0 ++#define CONFIG_LIBTENSORFLOW 0 ++#define CONFIG_LIBTESSERACT 0 ++#define CONFIG_LIBTHEORA 0 ++#define CONFIG_LIBTWOLAME 0 ++#define CONFIG_LIBV4L2 0 ++#define CONFIG_LIBVMAF 0 ++#define CONFIG_LIBVORBIS 0 ++#define CONFIG_LIBVPX 0 ++#define CONFIG_LIBWAVPACK 0 ++#define CONFIG_LIBWEBP 0 ++#define CONFIG_LIBXML2 0 ++#define CONFIG_LIBZIMG 0 ++#define CONFIG_LIBZMQ 0 ++#define CONFIG_LIBZVBI 0 ++#define CONFIG_LV2 0 ++#define CONFIG_MEDIACODEC 0 ++#define CONFIG_OPENAL 0 ++#define CONFIG_OPENGL 0 ++#define CONFIG_POCKETSPHINX 0 ++#define CONFIG_VAPOURSYNTH 0 ++#define CONFIG_ALSA 0 ++#define CONFIG_APPKIT 0 ++#define CONFIG_AVFOUNDATION 0 ++#define CONFIG_BZLIB 0 ++#define CONFIG_COREIMAGE 0 ++#define CONFIG_ICONV 0 ++#define CONFIG_LIBXCB 0 ++#define CONFIG_LIBXCB_SHM 0 ++#define CONFIG_LIBXCB_SHAPE 0 ++#define CONFIG_LIBXCB_XFIXES 0 ++#define CONFIG_LZMA 0 ++#define CONFIG_MEDIAFOUNDATION 0 ++#define CONFIG_SCHANNEL 0 ++#define CONFIG_SDL2 0 ++#define CONFIG_SECURETRANSPORT 0 ++#define CONFIG_SNDIO 0 ++#define CONFIG_XLIB 0 ++#define CONFIG_ZLIB 0 ++#define CONFIG_CUDA_NVCC 0 ++#define CONFIG_CUDA_SDK 0 ++#define CONFIG_LIBNPP 0 ++#define CONFIG_LIBMFX 0 ++#define CONFIG_MMAL 0 ++#define CONFIG_OMX 0 ++#define CONFIG_OPENCL 0 ++#define CONFIG_VULKAN 0 ++#define CONFIG_AMF 0 ++#define CONFIG_AUDIOTOOLBOX 0 ++#define CONFIG_CRYSTALHD 0 ++#define CONFIG_CUDA 0 ++#define CONFIG_CUDA_LLVM 0 ++#define CONFIG_CUVID 0 ++#define CONFIG_D3D11VA 0 ++#define CONFIG_DXVA2 0 ++#define CONFIG_FFNVCODEC 0 ++#define CONFIG_NVDEC 0 ++#define CONFIG_NVENC 0 ++#define CONFIG_VAAPI 0 ++#define CONFIG_VDPAU 0 ++#define CONFIG_VIDEOTOOLBOX 0 ++#define CONFIG_V4L2_M2M 0 ++#define CONFIG_XVMC 0 ++#define CONFIG_FTRAPV 0 ++#define CONFIG_GRAY 0 ++#define CONFIG_HARDCODED_TABLES 0 ++#define CONFIG_OMX_RPI 0 ++#define CONFIG_RUNTIME_CPUDETECT 1 ++#define CONFIG_SAFE_BITSTREAM_READER 1 ++#define CONFIG_SHARED 0 ++#define CONFIG_SMALL 0 ++#define CONFIG_STATIC 1 ++#define CONFIG_SWSCALE_ALPHA 1 ++#define CONFIG_GPL 0 ++#define CONFIG_NONFREE 0 ++#define CONFIG_VERSION3 0 ++#define CONFIG_AVDEVICE 0 ++#define CONFIG_AVFILTER 0 ++#define CONFIG_SWSCALE 0 ++#define CONFIG_POSTPROC 0 ++#define CONFIG_AVFORMAT 1 ++#define CONFIG_AVCODEC 1 ++#define CONFIG_SWRESAMPLE 0 ++#define CONFIG_AVRESAMPLE 0 ++#define CONFIG_AVUTIL 1 ++#define CONFIG_FFPLAY 0 ++#define CONFIG_FFPROBE 0 ++#define CONFIG_FFMPEG 0 ++#define CONFIG_DCT 1 ++#define CONFIG_DWT 0 ++#define CONFIG_ERROR_RESILIENCE 0 ++#define CONFIG_FAAN 0 ++#define CONFIG_FAST_UNALIGNED 0 ++#define CONFIG_FFT 1 ++#define CONFIG_LSP 0 ++#define CONFIG_LZO 0 ++#define CONFIG_MDCT 1 ++#define CONFIG_PIXELUTILS 0 ++#define CONFIG_NETWORK 0 ++#define CONFIG_RDFT 1 ++#define CONFIG_AUTODETECT 0 ++#define CONFIG_FONTCONFIG 0 ++#define CONFIG_LARGE_TESTS 1 ++#define CONFIG_LINUX_PERF 0 ++#define CONFIG_MEMORY_POISONING 0 ++#define CONFIG_NEON_CLOBBER_TEST 0 ++#define CONFIG_OSSFUZZ 0 ++#define CONFIG_PIC 1 ++#define CONFIG_THUMB 0 ++#define CONFIG_VALGRIND_BACKTRACE 0 ++#define CONFIG_XMM_CLOBBER_TEST 0 ++#define CONFIG_BSFS 1 ++#define CONFIG_DECODERS 1 ++#define CONFIG_ENCODERS 0 ++#define CONFIG_HWACCELS 0 ++#define CONFIG_PARSERS 1 ++#define CONFIG_INDEVS 0 ++#define CONFIG_OUTDEVS 0 ++#define CONFIG_FILTERS 0 ++#define CONFIG_DEMUXERS 1 ++#define CONFIG_MUXERS 0 ++#define CONFIG_PROTOCOLS 0 ++#define CONFIG_AANDCTTABLES 0 ++#define CONFIG_AC3DSP 0 ++#define CONFIG_ADTS_HEADER 1 ++#define CONFIG_ATSC_A53 1 ++#define CONFIG_AUDIO_FRAME_QUEUE 0 ++#define CONFIG_AUDIODSP 0 ++#define CONFIG_BLOCKDSP 0 ++#define CONFIG_BSWAPDSP 0 ++#define CONFIG_CABAC 1 ++#define CONFIG_CBS 0 ++#define CONFIG_CBS_AV1 0 ++#define CONFIG_CBS_H264 0 ++#define CONFIG_CBS_H265 0 ++#define CONFIG_CBS_JPEG 0 ++#define CONFIG_CBS_MPEG2 0 ++#define CONFIG_CBS_VP9 0 ++#define CONFIG_DIRAC_PARSE 1 ++#define CONFIG_DNN 0 ++#define CONFIG_DVPROFILE 0 ++#define CONFIG_EXIF 0 ++#define CONFIG_FAANDCT 0 ++#define CONFIG_FAANIDCT 0 ++#define CONFIG_FDCTDSP 0 ++#define CONFIG_FLACDSP 1 ++#define CONFIG_FMTCONVERT 0 ++#define CONFIG_FRAME_THREAD_ENCODER 0 ++#define CONFIG_G722DSP 0 ++#define CONFIG_GOLOMB 1 ++#define CONFIG_GPLV3 0 ++#define CONFIG_H263DSP 0 ++#define CONFIG_H264CHROMA 1 ++#define CONFIG_H264DSP 1 ++#define CONFIG_H264PARSE 1 ++#define CONFIG_H264PRED 1 ++#define CONFIG_H264QPEL 1 ++#define CONFIG_HEVCPARSE 0 ++#define CONFIG_HPELDSP 1 ++#define CONFIG_HUFFMAN 0 ++#define CONFIG_HUFFYUVDSP 0 ++#define CONFIG_HUFFYUVENCDSP 0 ++#define CONFIG_IDCTDSP 0 ++#define CONFIG_IIRFILTER 0 ++#define CONFIG_MDCT15 1 ++#define CONFIG_INTRAX8 0 ++#define CONFIG_ISO_MEDIA 1 ++#define CONFIG_IVIDSP 0 ++#define CONFIG_JPEGTABLES 0 ++#define CONFIG_LGPLV3 0 ++#define CONFIG_LIBX262 0 ++#define CONFIG_LLAUDDSP 0 ++#define CONFIG_LLVIDDSP 0 ++#define CONFIG_LLVIDENCDSP 0 ++#define CONFIG_LPC 0 ++#define CONFIG_LZF 0 ++#define CONFIG_ME_CMP 0 ++#define CONFIG_MPEG_ER 0 ++#define CONFIG_MPEGAUDIO 1 ++#define CONFIG_MPEGAUDIODSP 1 ++#define CONFIG_MPEGAUDIOHEADER 1 ++#define CONFIG_MPEGVIDEO 0 ++#define CONFIG_MPEGVIDEOENC 0 ++#define CONFIG_MSS34DSP 0 ++#define CONFIG_PIXBLOCKDSP 0 ++#define CONFIG_QPELDSP 0 ++#define CONFIG_QSV 0 ++#define CONFIG_QSVDEC 0 ++#define CONFIG_QSVENC 0 ++#define CONFIG_QSVVPP 0 ++#define CONFIG_RANGECODER 0 ++#define CONFIG_RIFFDEC 1 ++#define CONFIG_RIFFENC 0 ++#define CONFIG_RTPDEC 0 ++#define CONFIG_RTPENC_CHAIN 0 ++#define CONFIG_RV34DSP 0 ++#define CONFIG_SCENE_SAD 0 ++#define CONFIG_SINEWIN 1 ++#define CONFIG_SNAPPY 0 ++#define CONFIG_SRTP 0 ++#define CONFIG_STARTCODE 1 ++#define CONFIG_TEXTUREDSP 0 ++#define CONFIG_TEXTUREDSPENC 0 ++#define CONFIG_TPELDSP 0 ++#define CONFIG_VAAPI_1 0 ++#define CONFIG_VAAPI_ENCODE 0 ++#define CONFIG_VC1DSP 0 ++#define CONFIG_VIDEODSP 1 ++#define CONFIG_VP3DSP 1 ++#define CONFIG_VP56DSP 0 ++#define CONFIG_VP8DSP 1 ++#define CONFIG_WMA_FREQS 0 ++#define CONFIG_WMV2DSP 0 ++#define CONFIG_AAC_ADTSTOASC_BSF 0 ++#define CONFIG_AV1_FRAME_MERGE_BSF 0 ++#define CONFIG_AV1_FRAME_SPLIT_BSF 0 ++#define CONFIG_AV1_METADATA_BSF 0 ++#define CONFIG_CHOMP_BSF 0 ++#define CONFIG_DUMP_EXTRADATA_BSF 0 ++#define CONFIG_DCA_CORE_BSF 0 ++#define CONFIG_EAC3_CORE_BSF 0 ++#define CONFIG_EXTRACT_EXTRADATA_BSF 0 ++#define CONFIG_FILTER_UNITS_BSF 0 ++#define CONFIG_H264_METADATA_BSF 0 ++#define CONFIG_H264_MP4TOANNEXB_BSF 0 ++#define CONFIG_H264_REDUNDANT_PPS_BSF 0 ++#define CONFIG_HAPQA_EXTRACT_BSF 0 ++#define CONFIG_HEVC_METADATA_BSF 0 ++#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 ++#define CONFIG_IMX_DUMP_HEADER_BSF 0 ++#define CONFIG_MJPEG2JPEG_BSF 0 ++#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 ++#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 ++#define CONFIG_MPEG2_METADATA_BSF 0 ++#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 ++#define CONFIG_MOV2TEXTSUB_BSF 0 ++#define CONFIG_NOISE_BSF 0 ++#define CONFIG_NULL_BSF 1 ++#define CONFIG_OPUS_METADATA_BSF 0 ++#define CONFIG_PCM_RECHUNK_BSF 0 ++#define CONFIG_PRORES_METADATA_BSF 0 ++#define CONFIG_REMOVE_EXTRADATA_BSF 0 ++#define CONFIG_TEXT2MOVSUB_BSF 0 ++#define CONFIG_TRACE_HEADERS_BSF 0 ++#define CONFIG_TRUEHD_CORE_BSF 0 ++#define CONFIG_VP9_METADATA_BSF 0 ++#define CONFIG_VP9_RAW_REORDER_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 ++#define CONFIG_AASC_DECODER 0 ++#define CONFIG_AIC_DECODER 0 ++#define CONFIG_ALIAS_PIX_DECODER 0 ++#define CONFIG_AGM_DECODER 0 ++#define CONFIG_AMV_DECODER 0 ++#define CONFIG_ANM_DECODER 0 ++#define CONFIG_ANSI_DECODER 0 ++#define CONFIG_APNG_DECODER 0 ++#define CONFIG_ARBC_DECODER 0 ++#define CONFIG_ASV1_DECODER 0 ++#define CONFIG_ASV2_DECODER 0 ++#define CONFIG_AURA_DECODER 0 ++#define CONFIG_AURA2_DECODER 0 ++#define CONFIG_AVRP_DECODER 0 ++#define CONFIG_AVRN_DECODER 0 ++#define CONFIG_AVS_DECODER 0 ++#define CONFIG_AVUI_DECODER 0 ++#define CONFIG_AYUV_DECODER 0 ++#define CONFIG_BETHSOFTVID_DECODER 0 ++#define CONFIG_BFI_DECODER 0 ++#define CONFIG_BINK_DECODER 0 ++#define CONFIG_BITPACKED_DECODER 0 ++#define CONFIG_BMP_DECODER 0 ++#define CONFIG_BMV_VIDEO_DECODER 0 ++#define CONFIG_BRENDER_PIX_DECODER 0 ++#define CONFIG_C93_DECODER 0 ++#define CONFIG_CAVS_DECODER 0 ++#define CONFIG_CDGRAPHICS_DECODER 0 ++#define CONFIG_CDTOONS_DECODER 0 ++#define CONFIG_CDXL_DECODER 0 ++#define CONFIG_CFHD_DECODER 0 ++#define CONFIG_CINEPAK_DECODER 0 ++#define CONFIG_CLEARVIDEO_DECODER 0 ++#define CONFIG_CLJR_DECODER 0 ++#define CONFIG_CLLC_DECODER 0 ++#define CONFIG_COMFORTNOISE_DECODER 0 ++#define CONFIG_CPIA_DECODER 0 ++#define CONFIG_CSCD_DECODER 0 ++#define CONFIG_CYUV_DECODER 0 ++#define CONFIG_DDS_DECODER 0 ++#define CONFIG_DFA_DECODER 0 ++#define CONFIG_DIRAC_DECODER 0 ++#define CONFIG_DNXHD_DECODER 0 ++#define CONFIG_DPX_DECODER 0 ++#define CONFIG_DSICINVIDEO_DECODER 0 ++#define CONFIG_DVAUDIO_DECODER 0 ++#define CONFIG_DVVIDEO_DECODER 0 ++#define CONFIG_DXA_DECODER 0 ++#define CONFIG_DXTORY_DECODER 0 ++#define CONFIG_DXV_DECODER 0 ++#define CONFIG_EACMV_DECODER 0 ++#define CONFIG_EAMAD_DECODER 0 ++#define CONFIG_EATGQ_DECODER 0 ++#define CONFIG_EATGV_DECODER 0 ++#define CONFIG_EATQI_DECODER 0 ++#define CONFIG_EIGHTBPS_DECODER 0 ++#define CONFIG_EIGHTSVX_EXP_DECODER 0 ++#define CONFIG_EIGHTSVX_FIB_DECODER 0 ++#define CONFIG_ESCAPE124_DECODER 0 ++#define CONFIG_ESCAPE130_DECODER 0 ++#define CONFIG_EXR_DECODER 0 ++#define CONFIG_FFV1_DECODER 0 ++#define CONFIG_FFVHUFF_DECODER 0 ++#define CONFIG_FIC_DECODER 0 ++#define CONFIG_FITS_DECODER 0 ++#define CONFIG_FLASHSV_DECODER 0 ++#define CONFIG_FLASHSV2_DECODER 0 ++#define CONFIG_FLIC_DECODER 0 ++#define CONFIG_FLV_DECODER 0 ++#define CONFIG_FMVC_DECODER 0 ++#define CONFIG_FOURXM_DECODER 0 ++#define CONFIG_FRAPS_DECODER 0 ++#define CONFIG_FRWU_DECODER 0 ++#define CONFIG_G2M_DECODER 0 ++#define CONFIG_GDV_DECODER 0 ++#define CONFIG_GIF_DECODER 0 ++#define CONFIG_H261_DECODER 0 ++#define CONFIG_H263_DECODER 0 ++#define CONFIG_H263I_DECODER 0 ++#define CONFIG_H263P_DECODER 0 ++#define CONFIG_H263_V4L2M2M_DECODER 0 ++#define CONFIG_H264_DECODER 1 ++#define CONFIG_H264_CRYSTALHD_DECODER 0 ++#define CONFIG_H264_V4L2M2M_DECODER 0 ++#define CONFIG_H264_MEDIACODEC_DECODER 0 ++#define CONFIG_H264_MMAL_DECODER 0 ++#define CONFIG_H264_QSV_DECODER 0 ++#define CONFIG_H264_RKMPP_DECODER 0 ++#define CONFIG_HAP_DECODER 0 ++#define CONFIG_HEVC_DECODER 0 ++#define CONFIG_HEVC_QSV_DECODER 0 ++#define CONFIG_HEVC_RKMPP_DECODER 0 ++#define CONFIG_HEVC_V4L2M2M_DECODER 0 ++#define CONFIG_HNM4_VIDEO_DECODER 0 ++#define CONFIG_HQ_HQA_DECODER 0 ++#define CONFIG_HQX_DECODER 0 ++#define CONFIG_HUFFYUV_DECODER 0 ++#define CONFIG_HYMT_DECODER 0 ++#define CONFIG_IDCIN_DECODER 0 ++#define CONFIG_IFF_ILBM_DECODER 0 ++#define CONFIG_IMM4_DECODER 0 ++#define CONFIG_IMM5_DECODER 0 ++#define CONFIG_INDEO2_DECODER 0 ++#define CONFIG_INDEO3_DECODER 0 ++#define CONFIG_INDEO4_DECODER 0 ++#define CONFIG_INDEO5_DECODER 0 ++#define CONFIG_INTERPLAY_VIDEO_DECODER 0 ++#define CONFIG_JPEG2000_DECODER 0 ++#define CONFIG_JPEGLS_DECODER 0 ++#define CONFIG_JV_DECODER 0 ++#define CONFIG_KGV1_DECODER 0 ++#define CONFIG_KMVC_DECODER 0 ++#define CONFIG_LAGARITH_DECODER 0 ++#define CONFIG_LOCO_DECODER 0 ++#define CONFIG_LSCR_DECODER 0 ++#define CONFIG_M101_DECODER 0 ++#define CONFIG_MAGICYUV_DECODER 0 ++#define CONFIG_MDEC_DECODER 0 ++#define CONFIG_MIMIC_DECODER 0 ++#define CONFIG_MJPEG_DECODER 0 ++#define CONFIG_MJPEGB_DECODER 0 ++#define CONFIG_MMVIDEO_DECODER 0 ++#define CONFIG_MOTIONPIXELS_DECODER 0 ++#define CONFIG_MPEG1VIDEO_DECODER 0 ++#define CONFIG_MPEG2VIDEO_DECODER 0 ++#define CONFIG_MPEG4_DECODER 0 ++#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG4_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG4_MMAL_DECODER 0 ++#define CONFIG_MPEGVIDEO_DECODER 0 ++#define CONFIG_MPEG1_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_MMAL_DECODER 0 ++#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG2_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_QSV_DECODER 0 ++#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 ++#define CONFIG_MSA1_DECODER 0 ++#define CONFIG_MSCC_DECODER 0 ++#define CONFIG_MSMPEG4V1_DECODER 0 ++#define CONFIG_MSMPEG4V2_DECODER 0 ++#define CONFIG_MSMPEG4V3_DECODER 0 ++#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MSRLE_DECODER 0 ++#define CONFIG_MSS1_DECODER 0 ++#define CONFIG_MSS2_DECODER 0 ++#define CONFIG_MSVIDEO1_DECODER 0 ++#define CONFIG_MSZH_DECODER 0 ++#define CONFIG_MTS2_DECODER 0 ++#define CONFIG_MV30_DECODER 0 ++#define CONFIG_MVC1_DECODER 0 ++#define CONFIG_MVC2_DECODER 0 ++#define CONFIG_MVDV_DECODER 0 ++#define CONFIG_MVHA_DECODER 0 ++#define CONFIG_MWSC_DECODER 0 ++#define CONFIG_MXPEG_DECODER 0 ++#define CONFIG_NOTCHLC_DECODER 0 ++#define CONFIG_NUV_DECODER 0 ++#define CONFIG_PAF_VIDEO_DECODER 0 ++#define CONFIG_PAM_DECODER 0 ++#define CONFIG_PBM_DECODER 0 ++#define CONFIG_PCX_DECODER 0 ++#define CONFIG_PFM_DECODER 0 ++#define CONFIG_PGM_DECODER 0 ++#define CONFIG_PGMYUV_DECODER 0 ++#define CONFIG_PGX_DECODER 0 ++#define CONFIG_PICTOR_DECODER 0 ++#define CONFIG_PIXLET_DECODER 0 ++#define CONFIG_PNG_DECODER 0 ++#define CONFIG_PPM_DECODER 0 ++#define CONFIG_PRORES_DECODER 0 ++#define CONFIG_PROSUMER_DECODER 0 ++#define CONFIG_PSD_DECODER 0 ++#define CONFIG_PTX_DECODER 0 ++#define CONFIG_QDRAW_DECODER 0 ++#define CONFIG_QPEG_DECODER 0 ++#define CONFIG_QTRLE_DECODER 0 ++#define CONFIG_R10K_DECODER 0 ++#define CONFIG_R210_DECODER 0 ++#define CONFIG_RASC_DECODER 0 ++#define CONFIG_RAWVIDEO_DECODER 0 ++#define CONFIG_RL2_DECODER 0 ++#define CONFIG_ROQ_DECODER 0 ++#define CONFIG_RPZA_DECODER 0 ++#define CONFIG_RSCC_DECODER 0 ++#define CONFIG_RV10_DECODER 0 ++#define CONFIG_RV20_DECODER 0 ++#define CONFIG_RV30_DECODER 0 ++#define CONFIG_RV40_DECODER 0 ++#define CONFIG_S302M_DECODER 0 ++#define CONFIG_SANM_DECODER 0 ++#define CONFIG_SCPR_DECODER 0 ++#define CONFIG_SCREENPRESSO_DECODER 0 ++#define CONFIG_SGI_DECODER 0 ++#define CONFIG_SGIRLE_DECODER 0 ++#define CONFIG_SHEERVIDEO_DECODER 0 ++#define CONFIG_SMACKER_DECODER 0 ++#define CONFIG_SMC_DECODER 0 ++#define CONFIG_SMVJPEG_DECODER 0 ++#define CONFIG_SNOW_DECODER 0 ++#define CONFIG_SP5X_DECODER 0 ++#define CONFIG_SPEEDHQ_DECODER 0 ++#define CONFIG_SRGC_DECODER 0 ++#define CONFIG_SUNRAST_DECODER 0 ++#define CONFIG_SVQ1_DECODER 0 ++#define CONFIG_SVQ3_DECODER 0 ++#define CONFIG_TARGA_DECODER 0 ++#define CONFIG_TARGA_Y216_DECODER 0 ++#define CONFIG_TDSC_DECODER 0 ++#define CONFIG_THEORA_DECODER 1 ++#define CONFIG_THP_DECODER 0 ++#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 ++#define CONFIG_TIFF_DECODER 0 ++#define CONFIG_TMV_DECODER 0 ++#define CONFIG_TRUEMOTION1_DECODER 0 ++#define CONFIG_TRUEMOTION2_DECODER 0 ++#define CONFIG_TRUEMOTION2RT_DECODER 0 ++#define CONFIG_TSCC_DECODER 0 ++#define CONFIG_TSCC2_DECODER 0 ++#define CONFIG_TXD_DECODER 0 ++#define CONFIG_ULTI_DECODER 0 ++#define CONFIG_UTVIDEO_DECODER 0 ++#define CONFIG_V210_DECODER 0 ++#define CONFIG_V210X_DECODER 0 ++#define CONFIG_V308_DECODER 0 ++#define CONFIG_V408_DECODER 0 ++#define CONFIG_V410_DECODER 0 ++#define CONFIG_VB_DECODER 0 ++#define CONFIG_VBLE_DECODER 0 ++#define CONFIG_VC1_DECODER 0 ++#define CONFIG_VC1_CRYSTALHD_DECODER 0 ++#define CONFIG_VC1IMAGE_DECODER 0 ++#define CONFIG_VC1_MMAL_DECODER 0 ++#define CONFIG_VC1_QSV_DECODER 0 ++#define CONFIG_VC1_V4L2M2M_DECODER 0 ++#define CONFIG_VCR1_DECODER 0 ++#define CONFIG_VMDVIDEO_DECODER 0 ++#define CONFIG_VMNC_DECODER 0 ++#define CONFIG_VP3_DECODER 1 ++#define CONFIG_VP4_DECODER 0 ++#define CONFIG_VP5_DECODER 0 ++#define CONFIG_VP6_DECODER 0 ++#define CONFIG_VP6A_DECODER 0 ++#define CONFIG_VP6F_DECODER 0 ++#define CONFIG_VP7_DECODER 0 ++#define CONFIG_VP8_DECODER 1 ++#define CONFIG_VP8_RKMPP_DECODER 0 ++#define CONFIG_VP8_V4L2M2M_DECODER 0 ++#define CONFIG_VP9_DECODER 0 ++#define CONFIG_VP9_RKMPP_DECODER 0 ++#define CONFIG_VP9_V4L2M2M_DECODER 0 ++#define CONFIG_VQA_DECODER 0 ++#define CONFIG_WEBP_DECODER 0 ++#define CONFIG_WCMV_DECODER 0 ++#define CONFIG_WRAPPED_AVFRAME_DECODER 0 ++#define CONFIG_WMV1_DECODER 0 ++#define CONFIG_WMV2_DECODER 0 ++#define CONFIG_WMV3_DECODER 0 ++#define CONFIG_WMV3_CRYSTALHD_DECODER 0 ++#define CONFIG_WMV3IMAGE_DECODER 0 ++#define CONFIG_WNV1_DECODER 0 ++#define CONFIG_XAN_WC3_DECODER 0 ++#define CONFIG_XAN_WC4_DECODER 0 ++#define CONFIG_XBM_DECODER 0 ++#define CONFIG_XFACE_DECODER 0 ++#define CONFIG_XL_DECODER 0 ++#define CONFIG_XPM_DECODER 0 ++#define CONFIG_XWD_DECODER 0 ++#define CONFIG_Y41P_DECODER 0 ++#define CONFIG_YLC_DECODER 0 ++#define CONFIG_YOP_DECODER 0 ++#define CONFIG_YUV4_DECODER 0 ++#define CONFIG_ZERO12V_DECODER 0 ++#define CONFIG_ZEROCODEC_DECODER 0 ++#define CONFIG_ZLIB_DECODER 0 ++#define CONFIG_ZMBV_DECODER 0 ++#define CONFIG_AAC_DECODER 1 ++#define CONFIG_AAC_FIXED_DECODER 0 ++#define CONFIG_AAC_LATM_DECODER 0 ++#define CONFIG_AC3_DECODER 0 ++#define CONFIG_AC3_FIXED_DECODER 0 ++#define CONFIG_ACELP_KELVIN_DECODER 0 ++#define CONFIG_ALAC_DECODER 0 ++#define CONFIG_ALS_DECODER 0 ++#define CONFIG_AMRNB_DECODER 0 ++#define CONFIG_AMRWB_DECODER 0 ++#define CONFIG_APE_DECODER 0 ++#define CONFIG_APTX_DECODER 0 ++#define CONFIG_APTX_HD_DECODER 0 ++#define CONFIG_ATRAC1_DECODER 0 ++#define CONFIG_ATRAC3_DECODER 0 ++#define CONFIG_ATRAC3AL_DECODER 0 ++#define CONFIG_ATRAC3P_DECODER 0 ++#define CONFIG_ATRAC3PAL_DECODER 0 ++#define CONFIG_ATRAC9_DECODER 0 ++#define CONFIG_BINKAUDIO_DCT_DECODER 0 ++#define CONFIG_BINKAUDIO_RDFT_DECODER 0 ++#define CONFIG_BMV_AUDIO_DECODER 0 ++#define CONFIG_COOK_DECODER 0 ++#define CONFIG_DCA_DECODER 0 ++#define CONFIG_DOLBY_E_DECODER 0 ++#define CONFIG_DSD_LSBF_DECODER 0 ++#define CONFIG_DSD_MSBF_DECODER 0 ++#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 ++#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 ++#define CONFIG_DSICINAUDIO_DECODER 0 ++#define CONFIG_DSS_SP_DECODER 0 ++#define CONFIG_DST_DECODER 0 ++#define CONFIG_EAC3_DECODER 0 ++#define CONFIG_EVRC_DECODER 0 ++#define CONFIG_FFWAVESYNTH_DECODER 0 ++#define CONFIG_FLAC_DECODER 1 ++#define CONFIG_G723_1_DECODER 0 ++#define CONFIG_G729_DECODER 0 ++#define CONFIG_GSM_DECODER 0 ++#define CONFIG_GSM_MS_DECODER 0 ++#define CONFIG_HCA_DECODER 0 ++#define CONFIG_HCOM_DECODER 0 ++#define CONFIG_IAC_DECODER 0 ++#define CONFIG_ILBC_DECODER 0 ++#define CONFIG_IMC_DECODER 0 ++#define CONFIG_INTERPLAY_ACM_DECODER 0 ++#define CONFIG_MACE3_DECODER 0 ++#define CONFIG_MACE6_DECODER 0 ++#define CONFIG_METASOUND_DECODER 0 ++#define CONFIG_MLP_DECODER 0 ++#define CONFIG_MP1_DECODER 0 ++#define CONFIG_MP1FLOAT_DECODER 0 ++#define CONFIG_MP2_DECODER 0 ++#define CONFIG_MP2FLOAT_DECODER 0 ++#define CONFIG_MP3FLOAT_DECODER 0 ++#define CONFIG_MP3_DECODER 1 ++#define CONFIG_MP3ADUFLOAT_DECODER 0 ++#define CONFIG_MP3ADU_DECODER 0 ++#define CONFIG_MP3ON4FLOAT_DECODER 0 ++#define CONFIG_MP3ON4_DECODER 0 ++#define CONFIG_MPC7_DECODER 0 ++#define CONFIG_MPC8_DECODER 0 ++#define CONFIG_NELLYMOSER_DECODER 0 ++#define CONFIG_ON2AVC_DECODER 0 ++#define CONFIG_OPUS_DECODER 0 ++#define CONFIG_PAF_AUDIO_DECODER 0 ++#define CONFIG_QCELP_DECODER 0 ++#define CONFIG_QDM2_DECODER 0 ++#define CONFIG_QDMC_DECODER 0 ++#define CONFIG_RA_144_DECODER 0 ++#define CONFIG_RA_288_DECODER 0 ++#define CONFIG_RALF_DECODER 0 ++#define CONFIG_SBC_DECODER 0 ++#define CONFIG_SHORTEN_DECODER 0 ++#define CONFIG_SIPR_DECODER 0 ++#define CONFIG_SIREN_DECODER 0 ++#define CONFIG_SMACKAUD_DECODER 0 ++#define CONFIG_SONIC_DECODER 0 ++#define CONFIG_TAK_DECODER 0 ++#define CONFIG_TRUEHD_DECODER 0 ++#define CONFIG_TRUESPEECH_DECODER 0 ++#define CONFIG_TTA_DECODER 0 ++#define CONFIG_TWINVQ_DECODER 0 ++#define CONFIG_VMDAUDIO_DECODER 0 ++#define CONFIG_VORBIS_DECODER 1 ++#define CONFIG_WAVPACK_DECODER 0 ++#define CONFIG_WMALOSSLESS_DECODER 0 ++#define CONFIG_WMAPRO_DECODER 0 ++#define CONFIG_WMAV1_DECODER 0 ++#define CONFIG_WMAV2_DECODER 0 ++#define CONFIG_WMAVOICE_DECODER 0 ++#define CONFIG_WS_SND1_DECODER 0 ++#define CONFIG_XMA1_DECODER 0 ++#define CONFIG_XMA2_DECODER 0 ++#define CONFIG_PCM_ALAW_DECODER 1 ++#define CONFIG_PCM_BLURAY_DECODER 0 ++#define CONFIG_PCM_DVD_DECODER 0 ++#define CONFIG_PCM_F16LE_DECODER 0 ++#define CONFIG_PCM_F24LE_DECODER 0 ++#define CONFIG_PCM_F32BE_DECODER 0 ++#define CONFIG_PCM_F32LE_DECODER 1 ++#define CONFIG_PCM_F64BE_DECODER 0 ++#define CONFIG_PCM_F64LE_DECODER 0 ++#define CONFIG_PCM_LXF_DECODER 0 ++#define CONFIG_PCM_MULAW_DECODER 1 ++#define CONFIG_PCM_S8_DECODER 0 ++#define CONFIG_PCM_S8_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16BE_DECODER 1 ++#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16LE_DECODER 1 ++#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S24BE_DECODER 1 ++#define CONFIG_PCM_S24DAUD_DECODER 0 ++#define CONFIG_PCM_S24LE_DECODER 1 ++#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S32BE_DECODER 0 ++#define CONFIG_PCM_S32LE_DECODER 1 ++#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S64BE_DECODER 0 ++#define CONFIG_PCM_S64LE_DECODER 0 ++#define CONFIG_PCM_U8_DECODER 1 ++#define CONFIG_PCM_U16BE_DECODER 0 ++#define CONFIG_PCM_U16LE_DECODER 0 ++#define CONFIG_PCM_U24BE_DECODER 0 ++#define CONFIG_PCM_U24LE_DECODER 0 ++#define CONFIG_PCM_U32BE_DECODER 0 ++#define CONFIG_PCM_U32LE_DECODER 0 ++#define CONFIG_PCM_VIDC_DECODER 0 ++#define CONFIG_DERF_DPCM_DECODER 0 ++#define CONFIG_GREMLIN_DPCM_DECODER 0 ++#define CONFIG_INTERPLAY_DPCM_DECODER 0 ++#define CONFIG_ROQ_DPCM_DECODER 0 ++#define CONFIG_SDX2_DPCM_DECODER 0 ++#define CONFIG_SOL_DPCM_DECODER 0 ++#define CONFIG_XAN_DPCM_DECODER 0 ++#define CONFIG_ADPCM_4XM_DECODER 0 ++#define CONFIG_ADPCM_ADX_DECODER 0 ++#define CONFIG_ADPCM_AFC_DECODER 0 ++#define CONFIG_ADPCM_AGM_DECODER 0 ++#define CONFIG_ADPCM_AICA_DECODER 0 ++#define CONFIG_ADPCM_ARGO_DECODER 0 ++#define CONFIG_ADPCM_CT_DECODER 0 ++#define CONFIG_ADPCM_DTK_DECODER 0 ++#define CONFIG_ADPCM_EA_DECODER 0 ++#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 ++#define CONFIG_ADPCM_EA_R1_DECODER 0 ++#define CONFIG_ADPCM_EA_R2_DECODER 0 ++#define CONFIG_ADPCM_EA_R3_DECODER 0 ++#define CONFIG_ADPCM_EA_XAS_DECODER 0 ++#define CONFIG_ADPCM_G722_DECODER 0 ++#define CONFIG_ADPCM_G726_DECODER 0 ++#define CONFIG_ADPCM_G726LE_DECODER 0 ++#define CONFIG_ADPCM_IMA_AMV_DECODER 0 ++#define CONFIG_ADPCM_IMA_ALP_DECODER 0 ++#define CONFIG_ADPCM_IMA_APC_DECODER 0 ++#define CONFIG_ADPCM_IMA_APM_DECODER 0 ++#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 ++#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK3_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK4_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_ISS_DECODER 0 ++#define CONFIG_ADPCM_IMA_MTF_DECODER 0 ++#define CONFIG_ADPCM_IMA_OKI_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_DECODER 0 ++#define CONFIG_ADPCM_IMA_RAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_SSI_DECODER 0 ++#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 ++#define CONFIG_ADPCM_IMA_WAV_DECODER 0 ++#define CONFIG_ADPCM_IMA_WS_DECODER 0 ++#define CONFIG_ADPCM_MS_DECODER 0 ++#define CONFIG_ADPCM_MTAF_DECODER 0 ++#define CONFIG_ADPCM_PSX_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_2_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_3_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_4_DECODER 0 ++#define CONFIG_ADPCM_SWF_DECODER 0 ++#define CONFIG_ADPCM_THP_DECODER 0 ++#define CONFIG_ADPCM_THP_LE_DECODER 0 ++#define CONFIG_ADPCM_VIMA_DECODER 0 ++#define CONFIG_ADPCM_XA_DECODER 0 ++#define CONFIG_ADPCM_YAMAHA_DECODER 0 ++#define CONFIG_ADPCM_ZORK_DECODER 0 ++#define CONFIG_SSA_DECODER 0 ++#define CONFIG_ASS_DECODER 0 ++#define CONFIG_CCAPTION_DECODER 0 ++#define CONFIG_DVBSUB_DECODER 0 ++#define CONFIG_DVDSUB_DECODER 0 ++#define CONFIG_JACOSUB_DECODER 0 ++#define CONFIG_MICRODVD_DECODER 0 ++#define CONFIG_MOVTEXT_DECODER 0 ++#define CONFIG_MPL2_DECODER 0 ++#define CONFIG_PGSSUB_DECODER 0 ++#define CONFIG_PJS_DECODER 0 ++#define CONFIG_REALTEXT_DECODER 0 ++#define CONFIG_SAMI_DECODER 0 ++#define CONFIG_SRT_DECODER 0 ++#define CONFIG_STL_DECODER 0 ++#define CONFIG_SUBRIP_DECODER 0 ++#define CONFIG_SUBVIEWER_DECODER 0 ++#define CONFIG_SUBVIEWER1_DECODER 0 ++#define CONFIG_TEXT_DECODER 0 ++#define CONFIG_VPLAYER_DECODER 0 ++#define CONFIG_WEBVTT_DECODER 0 ++#define CONFIG_XSUB_DECODER 0 ++#define CONFIG_AAC_AT_DECODER 0 ++#define CONFIG_AC3_AT_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 ++#define CONFIG_ALAC_AT_DECODER 0 ++#define CONFIG_AMR_NB_AT_DECODER 0 ++#define CONFIG_EAC3_AT_DECODER 0 ++#define CONFIG_GSM_MS_AT_DECODER 0 ++#define CONFIG_ILBC_AT_DECODER 0 ++#define CONFIG_MP1_AT_DECODER 0 ++#define CONFIG_MP2_AT_DECODER 0 ++#define CONFIG_MP3_AT_DECODER 0 ++#define CONFIG_PCM_ALAW_AT_DECODER 0 ++#define CONFIG_PCM_MULAW_AT_DECODER 0 ++#define CONFIG_QDMC_AT_DECODER 0 ++#define CONFIG_QDM2_AT_DECODER 0 ++#define CONFIG_LIBARIBB24_DECODER 0 ++#define CONFIG_LIBCELT_DECODER 0 ++#define CONFIG_LIBCODEC2_DECODER 0 ++#define CONFIG_LIBDAV1D_DECODER 0 ++#define CONFIG_LIBDAVS2_DECODER 0 ++#define CONFIG_LIBFDK_AAC_DECODER 0 ++#define CONFIG_LIBGSM_DECODER 0 ++#define CONFIG_LIBGSM_MS_DECODER 0 ++#define CONFIG_LIBILBC_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 ++#define CONFIG_LIBOPENJPEG_DECODER 0 ++#define CONFIG_LIBOPUS_DECODER 1 ++#define CONFIG_LIBRSVG_DECODER 0 ++#define CONFIG_LIBSPEEX_DECODER 0 ++#define CONFIG_LIBVORBIS_DECODER 0 ++#define CONFIG_LIBVPX_VP8_DECODER 0 ++#define CONFIG_LIBVPX_VP9_DECODER 0 ++#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 ++#define CONFIG_BINTEXT_DECODER 0 ++#define CONFIG_XBIN_DECODER 0 ++#define CONFIG_IDF_DECODER 0 ++#define CONFIG_LIBAOM_AV1_DECODER 0 ++#define CONFIG_LIBOPENH264_DECODER 0 ++#define CONFIG_H264_CUVID_DECODER 0 ++#define CONFIG_HEVC_CUVID_DECODER 0 ++#define CONFIG_HEVC_MEDIACODEC_DECODER 0 ++#define CONFIG_MJPEG_CUVID_DECODER 0 ++#define CONFIG_MJPEG_QSV_DECODER 0 ++#define CONFIG_MPEG1_CUVID_DECODER 0 ++#define CONFIG_MPEG2_CUVID_DECODER 0 ++#define CONFIG_MPEG4_CUVID_DECODER 0 ++#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 ++#define CONFIG_VC1_CUVID_DECODER 0 ++#define CONFIG_VP8_CUVID_DECODER 0 ++#define CONFIG_VP8_MEDIACODEC_DECODER 0 ++#define CONFIG_VP8_QSV_DECODER 0 ++#define CONFIG_VP9_CUVID_DECODER 0 ++#define CONFIG_VP9_MEDIACODEC_DECODER 0 ++#define CONFIG_VP9_QSV_DECODER 0 ++#define CONFIG_A64MULTI_ENCODER 0 ++#define CONFIG_A64MULTI5_ENCODER 0 ++#define CONFIG_ALIAS_PIX_ENCODER 0 ++#define CONFIG_AMV_ENCODER 0 ++#define CONFIG_APNG_ENCODER 0 ++#define CONFIG_ASV1_ENCODER 0 ++#define CONFIG_ASV2_ENCODER 0 ++#define CONFIG_AVRP_ENCODER 0 ++#define CONFIG_AVUI_ENCODER 0 ++#define CONFIG_AYUV_ENCODER 0 ++#define CONFIG_BMP_ENCODER 0 ++#define CONFIG_CFHD_ENCODER 0 ++#define CONFIG_CINEPAK_ENCODER 0 ++#define CONFIG_CLJR_ENCODER 0 ++#define CONFIG_COMFORTNOISE_ENCODER 0 ++#define CONFIG_DNXHD_ENCODER 0 ++#define CONFIG_DPX_ENCODER 0 ++#define CONFIG_DVVIDEO_ENCODER 0 ++#define CONFIG_FFV1_ENCODER 0 ++#define CONFIG_FFVHUFF_ENCODER 0 ++#define CONFIG_FITS_ENCODER 0 ++#define CONFIG_FLASHSV_ENCODER 0 ++#define CONFIG_FLASHSV2_ENCODER 0 ++#define CONFIG_FLV_ENCODER 0 ++#define CONFIG_GIF_ENCODER 0 ++#define CONFIG_H261_ENCODER 0 ++#define CONFIG_H263_ENCODER 0 ++#define CONFIG_H263P_ENCODER 0 ++#define CONFIG_HAP_ENCODER 0 ++#define CONFIG_HUFFYUV_ENCODER 0 ++#define CONFIG_JPEG2000_ENCODER 0 ++#define CONFIG_JPEGLS_ENCODER 0 ++#define CONFIG_LJPEG_ENCODER 0 ++#define CONFIG_MAGICYUV_ENCODER 0 ++#define CONFIG_MJPEG_ENCODER 0 ++#define CONFIG_MPEG1VIDEO_ENCODER 0 ++#define CONFIG_MPEG2VIDEO_ENCODER 0 ++#define CONFIG_MPEG4_ENCODER 0 ++#define CONFIG_MSMPEG4V2_ENCODER 0 ++#define CONFIG_MSMPEG4V3_ENCODER 0 ++#define CONFIG_MSVIDEO1_ENCODER 0 ++#define CONFIG_PAM_ENCODER 0 ++#define CONFIG_PBM_ENCODER 0 ++#define CONFIG_PCX_ENCODER 0 ++#define CONFIG_PGM_ENCODER 0 ++#define CONFIG_PGMYUV_ENCODER 0 ++#define CONFIG_PNG_ENCODER 0 ++#define CONFIG_PPM_ENCODER 0 ++#define CONFIG_PRORES_ENCODER 0 ++#define CONFIG_PRORES_AW_ENCODER 0 ++#define CONFIG_PRORES_KS_ENCODER 0 ++#define CONFIG_QTRLE_ENCODER 0 ++#define CONFIG_R10K_ENCODER 0 ++#define CONFIG_R210_ENCODER 0 ++#define CONFIG_RAWVIDEO_ENCODER 0 ++#define CONFIG_ROQ_ENCODER 0 ++#define CONFIG_RPZA_ENCODER 0 ++#define CONFIG_RV10_ENCODER 0 ++#define CONFIG_RV20_ENCODER 0 ++#define CONFIG_S302M_ENCODER 0 ++#define CONFIG_SGI_ENCODER 0 ++#define CONFIG_SNOW_ENCODER 0 ++#define CONFIG_SUNRAST_ENCODER 0 ++#define CONFIG_SVQ1_ENCODER 0 ++#define CONFIG_TARGA_ENCODER 0 ++#define CONFIG_TIFF_ENCODER 0 ++#define CONFIG_UTVIDEO_ENCODER 0 ++#define CONFIG_V210_ENCODER 0 ++#define CONFIG_V308_ENCODER 0 ++#define CONFIG_V408_ENCODER 0 ++#define CONFIG_V410_ENCODER 0 ++#define CONFIG_VC2_ENCODER 0 ++#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 ++#define CONFIG_WMV1_ENCODER 0 ++#define CONFIG_WMV2_ENCODER 0 ++#define CONFIG_XBM_ENCODER 0 ++#define CONFIG_XFACE_ENCODER 0 ++#define CONFIG_XWD_ENCODER 0 ++#define CONFIG_Y41P_ENCODER 0 ++#define CONFIG_YUV4_ENCODER 0 ++#define CONFIG_ZLIB_ENCODER 0 ++#define CONFIG_ZMBV_ENCODER 0 ++#define CONFIG_AAC_ENCODER 0 ++#define CONFIG_AC3_ENCODER 0 ++#define CONFIG_AC3_FIXED_ENCODER 0 ++#define CONFIG_ALAC_ENCODER 0 ++#define CONFIG_APTX_ENCODER 0 ++#define CONFIG_APTX_HD_ENCODER 0 ++#define CONFIG_DCA_ENCODER 0 ++#define CONFIG_EAC3_ENCODER 0 ++#define CONFIG_FLAC_ENCODER 0 ++#define CONFIG_G723_1_ENCODER 0 ++#define CONFIG_MLP_ENCODER 0 ++#define CONFIG_MP2_ENCODER 0 ++#define CONFIG_MP2FIXED_ENCODER 0 ++#define CONFIG_NELLYMOSER_ENCODER 0 ++#define CONFIG_OPUS_ENCODER 0 ++#define CONFIG_RA_144_ENCODER 0 ++#define CONFIG_SBC_ENCODER 0 ++#define CONFIG_SONIC_ENCODER 0 ++#define CONFIG_SONIC_LS_ENCODER 0 ++#define CONFIG_TRUEHD_ENCODER 0 ++#define CONFIG_TTA_ENCODER 0 ++#define CONFIG_VORBIS_ENCODER 0 ++#define CONFIG_WAVPACK_ENCODER 0 ++#define CONFIG_WMAV1_ENCODER 0 ++#define CONFIG_WMAV2_ENCODER 0 ++#define CONFIG_PCM_ALAW_ENCODER 0 ++#define CONFIG_PCM_DVD_ENCODER 0 ++#define CONFIG_PCM_F32BE_ENCODER 0 ++#define CONFIG_PCM_F32LE_ENCODER 0 ++#define CONFIG_PCM_F64BE_ENCODER 0 ++#define CONFIG_PCM_F64LE_ENCODER 0 ++#define CONFIG_PCM_MULAW_ENCODER 0 ++#define CONFIG_PCM_S8_ENCODER 0 ++#define CONFIG_PCM_S8_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16BE_ENCODER 0 ++#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16LE_ENCODER 0 ++#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S24BE_ENCODER 0 ++#define CONFIG_PCM_S24DAUD_ENCODER 0 ++#define CONFIG_PCM_S24LE_ENCODER 0 ++#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S32BE_ENCODER 0 ++#define CONFIG_PCM_S32LE_ENCODER 0 ++#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S64BE_ENCODER 0 ++#define CONFIG_PCM_S64LE_ENCODER 0 ++#define CONFIG_PCM_U8_ENCODER 0 ++#define CONFIG_PCM_U16BE_ENCODER 0 ++#define CONFIG_PCM_U16LE_ENCODER 0 ++#define CONFIG_PCM_U24BE_ENCODER 0 ++#define CONFIG_PCM_U24LE_ENCODER 0 ++#define CONFIG_PCM_U32BE_ENCODER 0 ++#define CONFIG_PCM_U32LE_ENCODER 0 ++#define CONFIG_PCM_VIDC_ENCODER 0 ++#define CONFIG_ROQ_DPCM_ENCODER 0 ++#define CONFIG_ADPCM_ADX_ENCODER 0 ++#define CONFIG_ADPCM_ARGO_ENCODER 0 ++#define CONFIG_ADPCM_G722_ENCODER 0 ++#define CONFIG_ADPCM_G726_ENCODER 0 ++#define CONFIG_ADPCM_G726LE_ENCODER 0 ++#define CONFIG_ADPCM_IMA_APM_ENCODER 0 ++#define CONFIG_ADPCM_IMA_QT_ENCODER 0 ++#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 ++#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 ++#define CONFIG_ADPCM_MS_ENCODER 0 ++#define CONFIG_ADPCM_SWF_ENCODER 0 ++#define CONFIG_ADPCM_YAMAHA_ENCODER 0 ++#define CONFIG_SSA_ENCODER 0 ++#define CONFIG_ASS_ENCODER 0 ++#define CONFIG_DVBSUB_ENCODER 0 ++#define CONFIG_DVDSUB_ENCODER 0 ++#define CONFIG_MOVTEXT_ENCODER 0 ++#define CONFIG_SRT_ENCODER 0 ++#define CONFIG_SUBRIP_ENCODER 0 ++#define CONFIG_TEXT_ENCODER 0 ++#define CONFIG_WEBVTT_ENCODER 0 ++#define CONFIG_XSUB_ENCODER 0 ++#define CONFIG_AAC_AT_ENCODER 0 ++#define CONFIG_ALAC_AT_ENCODER 0 ++#define CONFIG_ILBC_AT_ENCODER 0 ++#define CONFIG_PCM_ALAW_AT_ENCODER 0 ++#define CONFIG_PCM_MULAW_AT_ENCODER 0 ++#define CONFIG_LIBAOM_AV1_ENCODER 0 ++#define CONFIG_LIBCODEC2_ENCODER 0 ++#define CONFIG_LIBFDK_AAC_ENCODER 0 ++#define CONFIG_LIBGSM_ENCODER 0 ++#define CONFIG_LIBGSM_MS_ENCODER 0 ++#define CONFIG_LIBILBC_ENCODER 0 ++#define CONFIG_LIBMP3LAME_ENCODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 ++#define CONFIG_LIBOPENJPEG_ENCODER 0 ++#define CONFIG_LIBOPUS_ENCODER 0 ++#define CONFIG_LIBRAV1E_ENCODER 0 ++#define CONFIG_LIBSHINE_ENCODER 0 ++#define CONFIG_LIBSPEEX_ENCODER 0 ++#define CONFIG_LIBSVTAV1_ENCODER 0 ++#define CONFIG_LIBTHEORA_ENCODER 0 ++#define CONFIG_LIBTWOLAME_ENCODER 0 ++#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 ++#define CONFIG_LIBVORBIS_ENCODER 0 ++#define CONFIG_LIBVPX_VP8_ENCODER 0 ++#define CONFIG_LIBVPX_VP9_ENCODER 0 ++#define CONFIG_LIBWAVPACK_ENCODER 0 ++#define CONFIG_LIBWEBP_ANIM_ENCODER 0 ++#define CONFIG_LIBWEBP_ENCODER 0 ++#define CONFIG_LIBX262_ENCODER 0 ++#define CONFIG_LIBX264_ENCODER 0 ++#define CONFIG_LIBX264RGB_ENCODER 0 ++#define CONFIG_LIBX265_ENCODER 0 ++#define CONFIG_LIBXAVS_ENCODER 0 ++#define CONFIG_LIBXAVS2_ENCODER 0 ++#define CONFIG_LIBXVID_ENCODER 0 ++#define CONFIG_AAC_MF_ENCODER 0 ++#define CONFIG_AC3_MF_ENCODER 0 ++#define CONFIG_H263_V4L2M2M_ENCODER 0 ++#define CONFIG_LIBOPENH264_ENCODER 0 ++#define CONFIG_H264_AMF_ENCODER 0 ++#define CONFIG_H264_MF_ENCODER 0 ++#define CONFIG_H264_NVENC_ENCODER 0 ++#define CONFIG_H264_OMX_ENCODER 0 ++#define CONFIG_H264_QSV_ENCODER 0 ++#define CONFIG_H264_V4L2M2M_ENCODER 0 ++#define CONFIG_H264_VAAPI_ENCODER 0 ++#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_NVENC_ENCODER 0 ++#define CONFIG_NVENC_H264_ENCODER 0 ++#define CONFIG_NVENC_HEVC_ENCODER 0 ++#define CONFIG_HEVC_AMF_ENCODER 0 ++#define CONFIG_HEVC_MF_ENCODER 0 ++#define CONFIG_HEVC_NVENC_ENCODER 0 ++#define CONFIG_HEVC_QSV_ENCODER 0 ++#define CONFIG_HEVC_V4L2M2M_ENCODER 0 ++#define CONFIG_HEVC_VAAPI_ENCODER 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_LIBKVAZAAR_ENCODER 0 ++#define CONFIG_MJPEG_QSV_ENCODER 0 ++#define CONFIG_MJPEG_VAAPI_ENCODER 0 ++#define CONFIG_MP3_MF_ENCODER 0 ++#define CONFIG_MPEG2_QSV_ENCODER 0 ++#define CONFIG_MPEG2_VAAPI_ENCODER 0 ++#define CONFIG_MPEG4_OMX_ENCODER 0 ++#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_VAAPI_ENCODER 0 ++#define CONFIG_VP9_VAAPI_ENCODER 0 ++#define CONFIG_VP9_QSV_ENCODER 0 ++#define CONFIG_H263_VAAPI_HWACCEL 0 ++#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_H264_D3D11VA_HWACCEL 0 ++#define CONFIG_H264_D3D11VA2_HWACCEL 0 ++#define CONFIG_H264_DXVA2_HWACCEL 0 ++#define CONFIG_H264_NVDEC_HWACCEL 0 ++#define CONFIG_H264_VAAPI_HWACCEL 0 ++#define CONFIG_H264_VDPAU_HWACCEL 0 ++#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 ++#define CONFIG_HEVC_DXVA2_HWACCEL 0 ++#define CONFIG_HEVC_NVDEC_HWACCEL 0 ++#define CONFIG_HEVC_VAAPI_HWACCEL 0 ++#define CONFIG_HEVC_VDPAU_HWACCEL 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MJPEG_NVDEC_HWACCEL 0 ++#define CONFIG_MJPEG_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG1_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG1_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG1_XVMC_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 ++#define CONFIG_MPEG2_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG2_DXVA2_HWACCEL 0 ++#define CONFIG_MPEG2_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG2_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG2_XVMC_HWACCEL 0 ++#define CONFIG_MPEG4_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG4_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG4_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA2_HWACCEL 0 ++#define CONFIG_VC1_DXVA2_HWACCEL 0 ++#define CONFIG_VC1_NVDEC_HWACCEL 0 ++#define CONFIG_VC1_VAAPI_HWACCEL 0 ++#define CONFIG_VC1_VDPAU_HWACCEL 0 ++#define CONFIG_VP8_NVDEC_HWACCEL 0 ++#define CONFIG_VP8_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA2_HWACCEL 0 ++#define CONFIG_VP9_DXVA2_HWACCEL 0 ++#define CONFIG_VP9_NVDEC_HWACCEL 0 ++#define CONFIG_VP9_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_VDPAU_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 ++#define CONFIG_WMV3_DXVA2_HWACCEL 0 ++#define CONFIG_WMV3_NVDEC_HWACCEL 0 ++#define CONFIG_WMV3_VAAPI_HWACCEL 0 ++#define CONFIG_WMV3_VDPAU_HWACCEL 0 ++#define CONFIG_AAC_PARSER 1 ++#define CONFIG_AAC_LATM_PARSER 0 ++#define CONFIG_AC3_PARSER 0 ++#define CONFIG_ADX_PARSER 0 ++#define CONFIG_AV1_PARSER 0 ++#define CONFIG_AVS2_PARSER 0 ++#define CONFIG_BMP_PARSER 0 ++#define CONFIG_CAVSVIDEO_PARSER 0 ++#define CONFIG_COOK_PARSER 0 ++#define CONFIG_DCA_PARSER 0 ++#define CONFIG_DIRAC_PARSER 0 ++#define CONFIG_DNXHD_PARSER 0 ++#define CONFIG_DPX_PARSER 0 ++#define CONFIG_DVAUDIO_PARSER 0 ++#define CONFIG_DVBSUB_PARSER 0 ++#define CONFIG_DVDSUB_PARSER 0 ++#define CONFIG_DVD_NAV_PARSER 0 ++#define CONFIG_FLAC_PARSER 1 ++#define CONFIG_G723_1_PARSER 0 ++#define CONFIG_G729_PARSER 0 ++#define CONFIG_GIF_PARSER 0 ++#define CONFIG_GSM_PARSER 0 ++#define CONFIG_H261_PARSER 0 ++#define CONFIG_H263_PARSER 0 ++#define CONFIG_H264_PARSER 1 ++#define CONFIG_HEVC_PARSER 0 ++#define CONFIG_JPEG2000_PARSER 0 ++#define CONFIG_MJPEG_PARSER 0 ++#define CONFIG_MLP_PARSER 0 ++#define CONFIG_MPEG4VIDEO_PARSER 0 ++#define CONFIG_MPEGAUDIO_PARSER 1 ++#define CONFIG_MPEGVIDEO_PARSER 0 ++#define CONFIG_OPUS_PARSER 1 ++#define CONFIG_PNG_PARSER 0 ++#define CONFIG_PNM_PARSER 0 ++#define CONFIG_RV30_PARSER 0 ++#define CONFIG_RV40_PARSER 0 ++#define CONFIG_SBC_PARSER 0 ++#define CONFIG_SIPR_PARSER 0 ++#define CONFIG_TAK_PARSER 0 ++#define CONFIG_VC1_PARSER 0 ++#define CONFIG_VORBIS_PARSER 1 ++#define CONFIG_VP3_PARSER 1 ++#define CONFIG_VP8_PARSER 1 ++#define CONFIG_VP9_PARSER 1 ++#define CONFIG_WEBP_PARSER 0 ++#define CONFIG_XMA_PARSER 0 ++#define CONFIG_ALSA_INDEV 0 ++#define CONFIG_ANDROID_CAMERA_INDEV 0 ++#define CONFIG_AVFOUNDATION_INDEV 0 ++#define CONFIG_BKTR_INDEV 0 ++#define CONFIG_DECKLINK_INDEV 0 ++#define CONFIG_DSHOW_INDEV 0 ++#define CONFIG_FBDEV_INDEV 0 ++#define CONFIG_GDIGRAB_INDEV 0 ++#define CONFIG_IEC61883_INDEV 0 ++#define CONFIG_JACK_INDEV 0 ++#define CONFIG_KMSGRAB_INDEV 0 ++#define CONFIG_LAVFI_INDEV 0 ++#define CONFIG_OPENAL_INDEV 0 ++#define CONFIG_OSS_INDEV 0 ++#define CONFIG_PULSE_INDEV 0 ++#define CONFIG_SNDIO_INDEV 0 ++#define CONFIG_V4L2_INDEV 0 ++#define CONFIG_VFWCAP_INDEV 0 ++#define CONFIG_XCBGRAB_INDEV 0 ++#define CONFIG_LIBCDIO_INDEV 0 ++#define CONFIG_LIBDC1394_INDEV 0 ++#define CONFIG_ALSA_OUTDEV 0 ++#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 ++#define CONFIG_CACA_OUTDEV 0 ++#define CONFIG_DECKLINK_OUTDEV 0 ++#define CONFIG_FBDEV_OUTDEV 0 ++#define CONFIG_OPENGL_OUTDEV 0 ++#define CONFIG_OSS_OUTDEV 0 ++#define CONFIG_PULSE_OUTDEV 0 ++#define CONFIG_SDL2_OUTDEV 0 ++#define CONFIG_SNDIO_OUTDEV 0 ++#define CONFIG_V4L2_OUTDEV 0 ++#define CONFIG_XV_OUTDEV 0 ++#define CONFIG_ABENCH_FILTER 0 ++#define CONFIG_ACOMPRESSOR_FILTER 0 ++#define CONFIG_ACONTRAST_FILTER 0 ++#define CONFIG_ACOPY_FILTER 0 ++#define CONFIG_ACUE_FILTER 0 ++#define CONFIG_ACROSSFADE_FILTER 0 ++#define CONFIG_ACROSSOVER_FILTER 0 ++#define CONFIG_ACRUSHER_FILTER 0 ++#define CONFIG_ADECLICK_FILTER 0 ++#define CONFIG_ADECLIP_FILTER 0 ++#define CONFIG_ADELAY_FILTER 0 ++#define CONFIG_ADERIVATIVE_FILTER 0 ++#define CONFIG_AECHO_FILTER 0 ++#define CONFIG_AEMPHASIS_FILTER 0 ++#define CONFIG_AEVAL_FILTER 0 ++#define CONFIG_AFADE_FILTER 0 ++#define CONFIG_AFFTDN_FILTER 0 ++#define CONFIG_AFFTFILT_FILTER 0 ++#define CONFIG_AFIR_FILTER 0 ++#define CONFIG_AFORMAT_FILTER 0 ++#define CONFIG_AGATE_FILTER 0 ++#define CONFIG_AIIR_FILTER 0 ++#define CONFIG_AINTEGRAL_FILTER 0 ++#define CONFIG_AINTERLEAVE_FILTER 0 ++#define CONFIG_ALIMITER_FILTER 0 ++#define CONFIG_ALLPASS_FILTER 0 ++#define CONFIG_ALOOP_FILTER 0 ++#define CONFIG_AMERGE_FILTER 0 ++#define CONFIG_AMETADATA_FILTER 0 ++#define CONFIG_AMIX_FILTER 0 ++#define CONFIG_AMULTIPLY_FILTER 0 ++#define CONFIG_ANEQUALIZER_FILTER 0 ++#define CONFIG_ANLMDN_FILTER 0 ++#define CONFIG_ANLMS_FILTER 0 ++#define CONFIG_ANULL_FILTER 0 ++#define CONFIG_APAD_FILTER 0 ++#define CONFIG_APERMS_FILTER 0 ++#define CONFIG_APHASER_FILTER 0 ++#define CONFIG_APULSATOR_FILTER 0 ++#define CONFIG_AREALTIME_FILTER 0 ++#define CONFIG_ARESAMPLE_FILTER 0 ++#define CONFIG_AREVERSE_FILTER 0 ++#define CONFIG_ARNNDN_FILTER 0 ++#define CONFIG_ASELECT_FILTER 0 ++#define CONFIG_ASENDCMD_FILTER 0 ++#define CONFIG_ASETNSAMPLES_FILTER 0 ++#define CONFIG_ASETPTS_FILTER 0 ++#define CONFIG_ASETRATE_FILTER 0 ++#define CONFIG_ASETTB_FILTER 0 ++#define CONFIG_ASHOWINFO_FILTER 0 ++#define CONFIG_ASIDEDATA_FILTER 0 ++#define CONFIG_ASOFTCLIP_FILTER 0 ++#define CONFIG_ASPLIT_FILTER 0 ++#define CONFIG_ASR_FILTER 0 ++#define CONFIG_ASTATS_FILTER 0 ++#define CONFIG_ASTREAMSELECT_FILTER 0 ++#define CONFIG_ASUBBOOST_FILTER 0 ++#define CONFIG_ATEMPO_FILTER 0 ++#define CONFIG_ATRIM_FILTER 0 ++#define CONFIG_AXCORRELATE_FILTER 0 ++#define CONFIG_AZMQ_FILTER 0 ++#define CONFIG_BANDPASS_FILTER 0 ++#define CONFIG_BANDREJECT_FILTER 0 ++#define CONFIG_BASS_FILTER 0 ++#define CONFIG_BIQUAD_FILTER 0 ++#define CONFIG_BS2B_FILTER 0 ++#define CONFIG_CHROMABER_VULKAN_FILTER 0 ++#define CONFIG_CHANNELMAP_FILTER 0 ++#define CONFIG_CHANNELSPLIT_FILTER 0 ++#define CONFIG_CHORUS_FILTER 0 ++#define CONFIG_COMPAND_FILTER 0 ++#define CONFIG_COMPENSATIONDELAY_FILTER 0 ++#define CONFIG_CROSSFEED_FILTER 0 ++#define CONFIG_CRYSTALIZER_FILTER 0 ++#define CONFIG_DCSHIFT_FILTER 0 ++#define CONFIG_DEESSER_FILTER 0 ++#define CONFIG_DRMETER_FILTER 0 ++#define CONFIG_DYNAUDNORM_FILTER 0 ++#define CONFIG_EARWAX_FILTER 0 ++#define CONFIG_EBUR128_FILTER 0 ++#define CONFIG_EQUALIZER_FILTER 0 ++#define CONFIG_EXTRASTEREO_FILTER 0 ++#define CONFIG_FIREQUALIZER_FILTER 0 ++#define CONFIG_FLANGER_FILTER 0 ++#define CONFIG_HAAS_FILTER 0 ++#define CONFIG_HDCD_FILTER 0 ++#define CONFIG_HEADPHONE_FILTER 0 ++#define CONFIG_HIGHPASS_FILTER 0 ++#define CONFIG_HIGHSHELF_FILTER 0 ++#define CONFIG_JOIN_FILTER 0 ++#define CONFIG_LADSPA_FILTER 0 ++#define CONFIG_LOUDNORM_FILTER 0 ++#define CONFIG_LOWPASS_FILTER 0 ++#define CONFIG_LOWSHELF_FILTER 0 ++#define CONFIG_LV2_FILTER 0 ++#define CONFIG_MCOMPAND_FILTER 0 ++#define CONFIG_PAN_FILTER 0 ++#define CONFIG_REPLAYGAIN_FILTER 0 ++#define CONFIG_RESAMPLE_FILTER 0 ++#define CONFIG_RUBBERBAND_FILTER 0 ++#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 ++#define CONFIG_SIDECHAINGATE_FILTER 0 ++#define CONFIG_SILENCEDETECT_FILTER 0 ++#define CONFIG_SILENCEREMOVE_FILTER 0 ++#define CONFIG_SOFALIZER_FILTER 0 ++#define CONFIG_STEREOTOOLS_FILTER 0 ++#define CONFIG_STEREOWIDEN_FILTER 0 ++#define CONFIG_SUPEREQUALIZER_FILTER 0 ++#define CONFIG_SURROUND_FILTER 0 ++#define CONFIG_TREBLE_FILTER 0 ++#define CONFIG_TREMOLO_FILTER 0 ++#define CONFIG_VIBRATO_FILTER 0 ++#define CONFIG_VOLUME_FILTER 0 ++#define CONFIG_VOLUMEDETECT_FILTER 0 ++#define CONFIG_AEVALSRC_FILTER 0 ++#define CONFIG_AFIRSRC_FILTER 0 ++#define CONFIG_ANOISESRC_FILTER 0 ++#define CONFIG_ANULLSRC_FILTER 0 ++#define CONFIG_FLITE_FILTER 0 ++#define CONFIG_HILBERT_FILTER 0 ++#define CONFIG_SINC_FILTER 0 ++#define CONFIG_SINE_FILTER 0 ++#define CONFIG_ANULLSINK_FILTER 0 ++#define CONFIG_ADDROI_FILTER 0 ++#define CONFIG_ALPHAEXTRACT_FILTER 0 ++#define CONFIG_ALPHAMERGE_FILTER 0 ++#define CONFIG_AMPLIFY_FILTER 0 ++#define CONFIG_ASS_FILTER 0 ++#define CONFIG_ATADENOISE_FILTER 0 ++#define CONFIG_AVGBLUR_FILTER 0 ++#define CONFIG_AVGBLUR_OPENCL_FILTER 0 ++#define CONFIG_AVGBLUR_VULKAN_FILTER 0 ++#define CONFIG_BBOX_FILTER 0 ++#define CONFIG_BENCH_FILTER 0 ++#define CONFIG_BILATERAL_FILTER 0 ++#define CONFIG_BITPLANENOISE_FILTER 0 ++#define CONFIG_BLACKDETECT_FILTER 0 ++#define CONFIG_BLACKFRAME_FILTER 0 ++#define CONFIG_BLEND_FILTER 0 ++#define CONFIG_BM3D_FILTER 0 ++#define CONFIG_BOXBLUR_FILTER 0 ++#define CONFIG_BOXBLUR_OPENCL_FILTER 0 ++#define CONFIG_BWDIF_FILTER 0 ++#define CONFIG_CAS_FILTER 0 ++#define CONFIG_CHROMAHOLD_FILTER 0 ++#define CONFIG_CHROMAKEY_FILTER 0 ++#define CONFIG_CHROMANR_FILTER 0 ++#define CONFIG_CHROMASHIFT_FILTER 0 ++#define CONFIG_CIESCOPE_FILTER 0 ++#define CONFIG_CODECVIEW_FILTER 0 ++#define CONFIG_COLORBALANCE_FILTER 0 ++#define CONFIG_COLORCHANNELMIXER_FILTER 0 ++#define CONFIG_COLORKEY_FILTER 0 ++#define CONFIG_COLORKEY_OPENCL_FILTER 0 ++#define CONFIG_COLORHOLD_FILTER 0 ++#define CONFIG_COLORLEVELS_FILTER 0 ++#define CONFIG_COLORMATRIX_FILTER 0 ++#define CONFIG_COLORSPACE_FILTER 0 ++#define CONFIG_CONVOLUTION_FILTER 0 ++#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 ++#define CONFIG_CONVOLVE_FILTER 0 ++#define CONFIG_COPY_FILTER 0 ++#define CONFIG_COREIMAGE_FILTER 0 ++#define CONFIG_COVER_RECT_FILTER 0 ++#define CONFIG_CROP_FILTER 0 ++#define CONFIG_CROPDETECT_FILTER 0 ++#define CONFIG_CUE_FILTER 0 ++#define CONFIG_CURVES_FILTER 0 ++#define CONFIG_DATASCOPE_FILTER 0 ++#define CONFIG_DBLUR_FILTER 0 ++#define CONFIG_DCTDNOIZ_FILTER 0 ++#define CONFIG_DEBAND_FILTER 0 ++#define CONFIG_DEBLOCK_FILTER 0 ++#define CONFIG_DECIMATE_FILTER 0 ++#define CONFIG_DECONVOLVE_FILTER 0 ++#define CONFIG_DEDOT_FILTER 0 ++#define CONFIG_DEFLATE_FILTER 0 ++#define CONFIG_DEFLICKER_FILTER 0 ++#define CONFIG_DEINTERLACE_QSV_FILTER 0 ++#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 ++#define CONFIG_DEJUDDER_FILTER 0 ++#define CONFIG_DELOGO_FILTER 0 ++#define CONFIG_DENOISE_VAAPI_FILTER 0 ++#define CONFIG_DERAIN_FILTER 0 ++#define CONFIG_DESHAKE_FILTER 0 ++#define CONFIG_DESHAKE_OPENCL_FILTER 0 ++#define CONFIG_DESPILL_FILTER 0 ++#define CONFIG_DETELECINE_FILTER 0 ++#define CONFIG_DILATION_FILTER 0 ++#define CONFIG_DILATION_OPENCL_FILTER 0 ++#define CONFIG_DISPLACE_FILTER 0 ++#define CONFIG_DNN_PROCESSING_FILTER 0 ++#define CONFIG_DOUBLEWEAVE_FILTER 0 ++#define CONFIG_DRAWBOX_FILTER 0 ++#define CONFIG_DRAWGRAPH_FILTER 0 ++#define CONFIG_DRAWGRID_FILTER 0 ++#define CONFIG_DRAWTEXT_FILTER 0 ++#define CONFIG_EDGEDETECT_FILTER 0 ++#define CONFIG_ELBG_FILTER 0 ++#define CONFIG_ENTROPY_FILTER 0 ++#define CONFIG_EQ_FILTER 0 ++#define CONFIG_EROSION_FILTER 0 ++#define CONFIG_EROSION_OPENCL_FILTER 0 ++#define CONFIG_EXTRACTPLANES_FILTER 0 ++#define CONFIG_FADE_FILTER 0 ++#define CONFIG_FFTDNOIZ_FILTER 0 ++#define CONFIG_FFTFILT_FILTER 0 ++#define CONFIG_FIELD_FILTER 0 ++#define CONFIG_FIELDHINT_FILTER 0 ++#define CONFIG_FIELDMATCH_FILTER 0 ++#define CONFIG_FIELDORDER_FILTER 0 ++#define CONFIG_FILLBORDERS_FILTER 0 ++#define CONFIG_FIND_RECT_FILTER 0 ++#define CONFIG_FLOODFILL_FILTER 0 ++#define CONFIG_FORMAT_FILTER 0 ++#define CONFIG_FPS_FILTER 0 ++#define CONFIG_FRAMEPACK_FILTER 0 ++#define CONFIG_FRAMERATE_FILTER 0 ++#define CONFIG_FRAMESTEP_FILTER 0 ++#define CONFIG_FREEZEDETECT_FILTER 0 ++#define CONFIG_FREEZEFRAMES_FILTER 0 ++#define CONFIG_FREI0R_FILTER 0 ++#define CONFIG_FSPP_FILTER 0 ++#define CONFIG_GBLUR_FILTER 0 ++#define CONFIG_GEQ_FILTER 0 ++#define CONFIG_GRADFUN_FILTER 0 ++#define CONFIG_GRAPHMONITOR_FILTER 0 ++#define CONFIG_GREYEDGE_FILTER 0 ++#define CONFIG_HALDCLUT_FILTER 0 ++#define CONFIG_HFLIP_FILTER 0 ++#define CONFIG_HISTEQ_FILTER 0 ++#define CONFIG_HISTOGRAM_FILTER 0 ++#define CONFIG_HQDN3D_FILTER 0 ++#define CONFIG_HQX_FILTER 0 ++#define CONFIG_HSTACK_FILTER 0 ++#define CONFIG_HUE_FILTER 0 ++#define CONFIG_HWDOWNLOAD_FILTER 0 ++#define CONFIG_HWMAP_FILTER 0 ++#define CONFIG_HWUPLOAD_FILTER 0 ++#define CONFIG_HWUPLOAD_CUDA_FILTER 0 ++#define CONFIG_HYSTERESIS_FILTER 0 ++#define CONFIG_IDET_FILTER 0 ++#define CONFIG_IL_FILTER 0 ++#define CONFIG_INFLATE_FILTER 0 ++#define CONFIG_INTERLACE_FILTER 0 ++#define CONFIG_INTERLEAVE_FILTER 0 ++#define CONFIG_KERNDEINT_FILTER 0 ++#define CONFIG_LAGFUN_FILTER 0 ++#define CONFIG_LENSCORRECTION_FILTER 0 ++#define CONFIG_LENSFUN_FILTER 0 ++#define CONFIG_LIBVMAF_FILTER 0 ++#define CONFIG_LIMITER_FILTER 0 ++#define CONFIG_LOOP_FILTER 0 ++#define CONFIG_LUMAKEY_FILTER 0 ++#define CONFIG_LUT_FILTER 0 ++#define CONFIG_LUT1D_FILTER 0 ++#define CONFIG_LUT2_FILTER 0 ++#define CONFIG_LUT3D_FILTER 0 ++#define CONFIG_LUTRGB_FILTER 0 ++#define CONFIG_LUTYUV_FILTER 0 ++#define CONFIG_MASKEDCLAMP_FILTER 0 ++#define CONFIG_MASKEDMAX_FILTER 0 ++#define CONFIG_MASKEDMERGE_FILTER 0 ++#define CONFIG_MASKEDMIN_FILTER 0 ++#define CONFIG_MASKEDTHRESHOLD_FILTER 0 ++#define CONFIG_MASKFUN_FILTER 0 ++#define CONFIG_MCDEINT_FILTER 0 ++#define CONFIG_MEDIAN_FILTER 0 ++#define CONFIG_MERGEPLANES_FILTER 0 ++#define CONFIG_MESTIMATE_FILTER 0 ++#define CONFIG_METADATA_FILTER 0 ++#define CONFIG_MIDEQUALIZER_FILTER 0 ++#define CONFIG_MINTERPOLATE_FILTER 0 ++#define CONFIG_MIX_FILTER 0 ++#define CONFIG_MPDECIMATE_FILTER 0 ++#define CONFIG_NEGATE_FILTER 0 ++#define CONFIG_NLMEANS_FILTER 0 ++#define CONFIG_NLMEANS_OPENCL_FILTER 0 ++#define CONFIG_NNEDI_FILTER 0 ++#define CONFIG_NOFORMAT_FILTER 0 ++#define CONFIG_NOISE_FILTER 0 ++#define CONFIG_NORMALIZE_FILTER 0 ++#define CONFIG_NULL_FILTER 0 ++#define CONFIG_OCR_FILTER 0 ++#define CONFIG_OCV_FILTER 0 ++#define CONFIG_OSCILLOSCOPE_FILTER 0 ++#define CONFIG_OVERLAY_FILTER 0 ++#define CONFIG_OVERLAY_OPENCL_FILTER 0 ++#define CONFIG_OVERLAY_QSV_FILTER 0 ++#define CONFIG_OVERLAY_VULKAN_FILTER 0 ++#define CONFIG_OVERLAY_CUDA_FILTER 0 ++#define CONFIG_OWDENOISE_FILTER 0 ++#define CONFIG_PAD_FILTER 0 ++#define CONFIG_PAD_OPENCL_FILTER 0 ++#define CONFIG_PALETTEGEN_FILTER 0 ++#define CONFIG_PALETTEUSE_FILTER 0 ++#define CONFIG_PERMS_FILTER 0 ++#define CONFIG_PERSPECTIVE_FILTER 0 ++#define CONFIG_PHASE_FILTER 0 ++#define CONFIG_PHOTOSENSITIVITY_FILTER 0 ++#define CONFIG_PIXDESCTEST_FILTER 0 ++#define CONFIG_PIXSCOPE_FILTER 0 ++#define CONFIG_PP_FILTER 0 ++#define CONFIG_PP7_FILTER 0 ++#define CONFIG_PREMULTIPLY_FILTER 0 ++#define CONFIG_PREWITT_FILTER 0 ++#define CONFIG_PREWITT_OPENCL_FILTER 0 ++#define CONFIG_PROCAMP_VAAPI_FILTER 0 ++#define CONFIG_PROGRAM_OPENCL_FILTER 0 ++#define CONFIG_PSEUDOCOLOR_FILTER 0 ++#define CONFIG_PSNR_FILTER 0 ++#define CONFIG_PULLUP_FILTER 0 ++#define CONFIG_QP_FILTER 0 ++#define CONFIG_RANDOM_FILTER 0 ++#define CONFIG_READEIA608_FILTER 0 ++#define CONFIG_READVITC_FILTER 0 ++#define CONFIG_REALTIME_FILTER 0 ++#define CONFIG_REMAP_FILTER 0 ++#define CONFIG_REMOVEGRAIN_FILTER 0 ++#define CONFIG_REMOVELOGO_FILTER 0 ++#define CONFIG_REPEATFIELDS_FILTER 0 ++#define CONFIG_REVERSE_FILTER 0 ++#define CONFIG_RGBASHIFT_FILTER 0 ++#define CONFIG_ROBERTS_FILTER 0 ++#define CONFIG_ROBERTS_OPENCL_FILTER 0 ++#define CONFIG_ROTATE_FILTER 0 ++#define CONFIG_SAB_FILTER 0 ++#define CONFIG_SCALE_FILTER 0 ++#define CONFIG_SCALE_CUDA_FILTER 0 ++#define CONFIG_SCALE_NPP_FILTER 0 ++#define CONFIG_SCALE_QSV_FILTER 0 ++#define CONFIG_SCALE_VAAPI_FILTER 0 ++#define CONFIG_SCALE_VULKAN_FILTER 0 ++#define CONFIG_SCALE2REF_FILTER 0 ++#define CONFIG_SCDET_FILTER 0 ++#define CONFIG_SCROLL_FILTER 0 ++#define CONFIG_SELECT_FILTER 0 ++#define CONFIG_SELECTIVECOLOR_FILTER 0 ++#define CONFIG_SENDCMD_FILTER 0 ++#define CONFIG_SEPARATEFIELDS_FILTER 0 ++#define CONFIG_SETDAR_FILTER 0 ++#define CONFIG_SETFIELD_FILTER 0 ++#define CONFIG_SETPARAMS_FILTER 0 ++#define CONFIG_SETPTS_FILTER 0 ++#define CONFIG_SETRANGE_FILTER 0 ++#define CONFIG_SETSAR_FILTER 0 ++#define CONFIG_SETTB_FILTER 0 ++#define CONFIG_SHARPNESS_VAAPI_FILTER 0 ++#define CONFIG_SHOWINFO_FILTER 0 ++#define CONFIG_SHOWPALETTE_FILTER 0 ++#define CONFIG_SHUFFLEFRAMES_FILTER 0 ++#define CONFIG_SHUFFLEPLANES_FILTER 0 ++#define CONFIG_SIDEDATA_FILTER 0 ++#define CONFIG_SIGNALSTATS_FILTER 0 ++#define CONFIG_SIGNATURE_FILTER 0 ++#define CONFIG_SMARTBLUR_FILTER 0 ++#define CONFIG_SOBEL_FILTER 0 ++#define CONFIG_SOBEL_OPENCL_FILTER 0 ++#define CONFIG_SPLIT_FILTER 0 ++#define CONFIG_SPP_FILTER 0 ++#define CONFIG_SR_FILTER 0 ++#define CONFIG_SSIM_FILTER 0 ++#define CONFIG_STEREO3D_FILTER 0 ++#define CONFIG_STREAMSELECT_FILTER 0 ++#define CONFIG_SUBTITLES_FILTER 0 ++#define CONFIG_SUPER2XSAI_FILTER 0 ++#define CONFIG_SWAPRECT_FILTER 0 ++#define CONFIG_SWAPUV_FILTER 0 ++#define CONFIG_TBLEND_FILTER 0 ++#define CONFIG_TELECINE_FILTER 0 ++#define CONFIG_THISTOGRAM_FILTER 0 ++#define CONFIG_THRESHOLD_FILTER 0 ++#define CONFIG_THUMBNAIL_FILTER 0 ++#define CONFIG_THUMBNAIL_CUDA_FILTER 0 ++#define CONFIG_TILE_FILTER 0 ++#define CONFIG_TINTERLACE_FILTER 0 ++#define CONFIG_TLUT2_FILTER 0 ++#define CONFIG_TMEDIAN_FILTER 0 ++#define CONFIG_TMIX_FILTER 0 ++#define CONFIG_TONEMAP_FILTER 0 ++#define CONFIG_TONEMAP_OPENCL_FILTER 0 ++#define CONFIG_TONEMAP_VAAPI_FILTER 0 ++#define CONFIG_TPAD_FILTER 0 ++#define CONFIG_TRANSPOSE_FILTER 0 ++#define CONFIG_TRANSPOSE_NPP_FILTER 0 ++#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 ++#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 ++#define CONFIG_TRIM_FILTER 0 ++#define CONFIG_UNPREMULTIPLY_FILTER 0 ++#define CONFIG_UNSHARP_FILTER 0 ++#define CONFIG_UNSHARP_OPENCL_FILTER 0 ++#define CONFIG_UNTILE_FILTER 0 ++#define CONFIG_USPP_FILTER 0 ++#define CONFIG_V360_FILTER 0 ++#define CONFIG_VAGUEDENOISER_FILTER 0 ++#define CONFIG_VECTORSCOPE_FILTER 0 ++#define CONFIG_VFLIP_FILTER 0 ++#define CONFIG_VFRDET_FILTER 0 ++#define CONFIG_VIBRANCE_FILTER 0 ++#define CONFIG_VIDSTABDETECT_FILTER 0 ++#define CONFIG_VIDSTABTRANSFORM_FILTER 0 ++#define CONFIG_VIGNETTE_FILTER 0 ++#define CONFIG_VMAFMOTION_FILTER 0 ++#define CONFIG_VPP_QSV_FILTER 0 ++#define CONFIG_VSTACK_FILTER 0 ++#define CONFIG_W3FDIF_FILTER 0 ++#define CONFIG_WAVEFORM_FILTER 0 ++#define CONFIG_WEAVE_FILTER 0 ++#define CONFIG_XBR_FILTER 0 ++#define CONFIG_XFADE_FILTER 0 ++#define CONFIG_XFADE_OPENCL_FILTER 0 ++#define CONFIG_XMEDIAN_FILTER 0 ++#define CONFIG_XSTACK_FILTER 0 ++#define CONFIG_YADIF_FILTER 0 ++#define CONFIG_YADIF_CUDA_FILTER 0 ++#define CONFIG_YAEPBLUR_FILTER 0 ++#define CONFIG_ZMQ_FILTER 0 ++#define CONFIG_ZOOMPAN_FILTER 0 ++#define CONFIG_ZSCALE_FILTER 0 ++#define CONFIG_ALLRGB_FILTER 0 ++#define CONFIG_ALLYUV_FILTER 0 ++#define CONFIG_CELLAUTO_FILTER 0 ++#define CONFIG_COLOR_FILTER 0 ++#define CONFIG_COREIMAGESRC_FILTER 0 ++#define CONFIG_FREI0R_SRC_FILTER 0 ++#define CONFIG_GRADIENTS_FILTER 0 ++#define CONFIG_HALDCLUTSRC_FILTER 0 ++#define CONFIG_LIFE_FILTER 0 ++#define CONFIG_MANDELBROT_FILTER 0 ++#define CONFIG_MPTESTSRC_FILTER 0 ++#define CONFIG_NULLSRC_FILTER 0 ++#define CONFIG_OPENCLSRC_FILTER 0 ++#define CONFIG_PAL75BARS_FILTER 0 ++#define CONFIG_PAL100BARS_FILTER 0 ++#define CONFIG_RGBTESTSRC_FILTER 0 ++#define CONFIG_SIERPINSKI_FILTER 0 ++#define CONFIG_SMPTEBARS_FILTER 0 ++#define CONFIG_SMPTEHDBARS_FILTER 0 ++#define CONFIG_TESTSRC_FILTER 0 ++#define CONFIG_TESTSRC2_FILTER 0 ++#define CONFIG_YUVTESTSRC_FILTER 0 ++#define CONFIG_NULLSINK_FILTER 0 ++#define CONFIG_ABITSCOPE_FILTER 0 ++#define CONFIG_ADRAWGRAPH_FILTER 0 ++#define CONFIG_AGRAPHMONITOR_FILTER 0 ++#define CONFIG_AHISTOGRAM_FILTER 0 ++#define CONFIG_APHASEMETER_FILTER 0 ++#define CONFIG_AVECTORSCOPE_FILTER 0 ++#define CONFIG_CONCAT_FILTER 0 ++#define CONFIG_SHOWCQT_FILTER 0 ++#define CONFIG_SHOWFREQS_FILTER 0 ++#define CONFIG_SHOWSPATIAL_FILTER 0 ++#define CONFIG_SHOWSPECTRUM_FILTER 0 ++#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 ++#define CONFIG_SHOWVOLUME_FILTER 0 ++#define CONFIG_SHOWWAVES_FILTER 0 ++#define CONFIG_SHOWWAVESPIC_FILTER 0 ++#define CONFIG_SPECTRUMSYNTH_FILTER 0 ++#define CONFIG_AMOVIE_FILTER 0 ++#define CONFIG_MOVIE_FILTER 0 ++#define CONFIG_AFIFO_FILTER 0 ++#define CONFIG_FIFO_FILTER 0 ++#define CONFIG_AA_DEMUXER 0 ++#define CONFIG_AAC_DEMUXER 1 ++#define CONFIG_AC3_DEMUXER 0 ++#define CONFIG_ACM_DEMUXER 0 ++#define CONFIG_ACT_DEMUXER 0 ++#define CONFIG_ADF_DEMUXER 0 ++#define CONFIG_ADP_DEMUXER 0 ++#define CONFIG_ADS_DEMUXER 0 ++#define CONFIG_ADX_DEMUXER 0 ++#define CONFIG_AEA_DEMUXER 0 ++#define CONFIG_AFC_DEMUXER 0 ++#define CONFIG_AIFF_DEMUXER 0 ++#define CONFIG_AIX_DEMUXER 0 ++#define CONFIG_ALP_DEMUXER 0 ++#define CONFIG_AMR_DEMUXER 0 ++#define CONFIG_AMRNB_DEMUXER 0 ++#define CONFIG_AMRWB_DEMUXER 0 ++#define CONFIG_ANM_DEMUXER 0 ++#define CONFIG_APC_DEMUXER 0 ++#define CONFIG_APE_DEMUXER 0 ++#define CONFIG_APM_DEMUXER 0 ++#define CONFIG_APNG_DEMUXER 0 ++#define CONFIG_APTX_DEMUXER 0 ++#define CONFIG_APTX_HD_DEMUXER 0 ++#define CONFIG_AQTITLE_DEMUXER 0 ++#define CONFIG_ARGO_ASF_DEMUXER 0 ++#define CONFIG_ASF_DEMUXER 0 ++#define CONFIG_ASF_O_DEMUXER 0 ++#define CONFIG_ASS_DEMUXER 0 ++#define CONFIG_AST_DEMUXER 0 ++#define CONFIG_AU_DEMUXER 0 ++#define CONFIG_AV1_DEMUXER 0 ++#define CONFIG_AVI_DEMUXER 0 ++#define CONFIG_AVISYNTH_DEMUXER 0 ++#define CONFIG_AVR_DEMUXER 0 ++#define CONFIG_AVS_DEMUXER 0 ++#define CONFIG_AVS2_DEMUXER 0 ++#define CONFIG_BETHSOFTVID_DEMUXER 0 ++#define CONFIG_BFI_DEMUXER 0 ++#define CONFIG_BINTEXT_DEMUXER 0 ++#define CONFIG_BINK_DEMUXER 0 ++#define CONFIG_BIT_DEMUXER 0 ++#define CONFIG_BMV_DEMUXER 0 ++#define CONFIG_BFSTM_DEMUXER 0 ++#define CONFIG_BRSTM_DEMUXER 0 ++#define CONFIG_BOA_DEMUXER 0 ++#define CONFIG_C93_DEMUXER 0 ++#define CONFIG_CAF_DEMUXER 0 ++#define CONFIG_CAVSVIDEO_DEMUXER 0 ++#define CONFIG_CDG_DEMUXER 0 ++#define CONFIG_CDXL_DEMUXER 0 ++#define CONFIG_CINE_DEMUXER 0 ++#define CONFIG_CODEC2_DEMUXER 0 ++#define CONFIG_CODEC2RAW_DEMUXER 0 ++#define CONFIG_CONCAT_DEMUXER 0 ++#define CONFIG_DASH_DEMUXER 0 ++#define CONFIG_DATA_DEMUXER 0 ++#define CONFIG_DAUD_DEMUXER 0 ++#define CONFIG_DCSTR_DEMUXER 0 ++#define CONFIG_DERF_DEMUXER 0 ++#define CONFIG_DFA_DEMUXER 0 ++#define CONFIG_DHAV_DEMUXER 0 ++#define CONFIG_DIRAC_DEMUXER 0 ++#define CONFIG_DNXHD_DEMUXER 0 ++#define CONFIG_DSF_DEMUXER 0 ++#define CONFIG_DSICIN_DEMUXER 0 ++#define CONFIG_DSS_DEMUXER 0 ++#define CONFIG_DTS_DEMUXER 0 ++#define CONFIG_DTSHD_DEMUXER 0 ++#define CONFIG_DV_DEMUXER 0 ++#define CONFIG_DVBSUB_DEMUXER 0 ++#define CONFIG_DVBTXT_DEMUXER 0 ++#define CONFIG_DXA_DEMUXER 0 ++#define CONFIG_EA_DEMUXER 0 ++#define CONFIG_EA_CDATA_DEMUXER 0 ++#define CONFIG_EAC3_DEMUXER 0 ++#define CONFIG_EPAF_DEMUXER 0 ++#define CONFIG_FFMETADATA_DEMUXER 0 ++#define CONFIG_FILMSTRIP_DEMUXER 0 ++#define CONFIG_FITS_DEMUXER 0 ++#define CONFIG_FLAC_DEMUXER 1 ++#define CONFIG_FLIC_DEMUXER 0 ++#define CONFIG_FLV_DEMUXER 0 ++#define CONFIG_LIVE_FLV_DEMUXER 0 ++#define CONFIG_FOURXM_DEMUXER 0 ++#define CONFIG_FRM_DEMUXER 0 ++#define CONFIG_FSB_DEMUXER 0 ++#define CONFIG_FWSE_DEMUXER 0 ++#define CONFIG_G722_DEMUXER 0 ++#define CONFIG_G723_1_DEMUXER 0 ++#define CONFIG_G726_DEMUXER 0 ++#define CONFIG_G726LE_DEMUXER 0 ++#define CONFIG_G729_DEMUXER 0 ++#define CONFIG_GDV_DEMUXER 0 ++#define CONFIG_GENH_DEMUXER 0 ++#define CONFIG_GIF_DEMUXER 0 ++#define CONFIG_GSM_DEMUXER 0 ++#define CONFIG_GXF_DEMUXER 0 ++#define CONFIG_H261_DEMUXER 0 ++#define CONFIG_H263_DEMUXER 0 ++#define CONFIG_H264_DEMUXER 0 ++#define CONFIG_HCA_DEMUXER 0 ++#define CONFIG_HCOM_DEMUXER 0 ++#define CONFIG_HEVC_DEMUXER 0 ++#define CONFIG_HLS_DEMUXER 0 ++#define CONFIG_HNM_DEMUXER 0 ++#define CONFIG_ICO_DEMUXER 0 ++#define CONFIG_IDCIN_DEMUXER 0 ++#define CONFIG_IDF_DEMUXER 0 ++#define CONFIG_IFF_DEMUXER 0 ++#define CONFIG_IFV_DEMUXER 0 ++#define CONFIG_ILBC_DEMUXER 0 ++#define CONFIG_IMAGE2_DEMUXER 0 ++#define CONFIG_IMAGE2PIPE_DEMUXER 0 ++#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 ++#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 ++#define CONFIG_INGENIENT_DEMUXER 0 ++#define CONFIG_IPMOVIE_DEMUXER 0 ++#define CONFIG_IRCAM_DEMUXER 0 ++#define CONFIG_ISS_DEMUXER 0 ++#define CONFIG_IV8_DEMUXER 0 ++#define CONFIG_IVF_DEMUXER 0 ++#define CONFIG_IVR_DEMUXER 0 ++#define CONFIG_JACOSUB_DEMUXER 0 ++#define CONFIG_JV_DEMUXER 0 ++#define CONFIG_KUX_DEMUXER 0 ++#define CONFIG_KVAG_DEMUXER 0 ++#define CONFIG_LMLM4_DEMUXER 0 ++#define CONFIG_LOAS_DEMUXER 0 ++#define CONFIG_LRC_DEMUXER 0 ++#define CONFIG_LVF_DEMUXER 0 ++#define CONFIG_LXF_DEMUXER 0 ++#define CONFIG_M4V_DEMUXER 0 ++#define CONFIG_MCC_DEMUXER 0 ++#define CONFIG_MATROSKA_DEMUXER 1 ++#define CONFIG_MGSTS_DEMUXER 0 ++#define CONFIG_MICRODVD_DEMUXER 0 ++#define CONFIG_MJPEG_DEMUXER 0 ++#define CONFIG_MJPEG_2000_DEMUXER 0 ++#define CONFIG_MLP_DEMUXER 0 ++#define CONFIG_MLV_DEMUXER 0 ++#define CONFIG_MM_DEMUXER 0 ++#define CONFIG_MMF_DEMUXER 0 ++#define CONFIG_MOV_DEMUXER 1 ++#define CONFIG_MP3_DEMUXER 1 ++#define CONFIG_MPC_DEMUXER 0 ++#define CONFIG_MPC8_DEMUXER 0 ++#define CONFIG_MPEGPS_DEMUXER 0 ++#define CONFIG_MPEGTS_DEMUXER 0 ++#define CONFIG_MPEGTSRAW_DEMUXER 0 ++#define CONFIG_MPEGVIDEO_DEMUXER 0 ++#define CONFIG_MPJPEG_DEMUXER 0 ++#define CONFIG_MPL2_DEMUXER 0 ++#define CONFIG_MPSUB_DEMUXER 0 ++#define CONFIG_MSF_DEMUXER 0 ++#define CONFIG_MSNWC_TCP_DEMUXER 0 ++#define CONFIG_MTAF_DEMUXER 0 ++#define CONFIG_MTV_DEMUXER 0 ++#define CONFIG_MUSX_DEMUXER 0 ++#define CONFIG_MV_DEMUXER 0 ++#define CONFIG_MVI_DEMUXER 0 ++#define CONFIG_MXF_DEMUXER 0 ++#define CONFIG_MXG_DEMUXER 0 ++#define CONFIG_NC_DEMUXER 0 ++#define CONFIG_NISTSPHERE_DEMUXER 0 ++#define CONFIG_NSP_DEMUXER 0 ++#define CONFIG_NSV_DEMUXER 0 ++#define CONFIG_NUT_DEMUXER 0 ++#define CONFIG_NUV_DEMUXER 0 ++#define CONFIG_OBU_DEMUXER 0 ++#define CONFIG_OGG_DEMUXER 1 ++#define CONFIG_OMA_DEMUXER 0 ++#define CONFIG_PAF_DEMUXER 0 ++#define CONFIG_PCM_ALAW_DEMUXER 0 ++#define CONFIG_PCM_MULAW_DEMUXER 0 ++#define CONFIG_PCM_VIDC_DEMUXER 0 ++#define CONFIG_PCM_F64BE_DEMUXER 0 ++#define CONFIG_PCM_F64LE_DEMUXER 0 ++#define CONFIG_PCM_F32BE_DEMUXER 0 ++#define CONFIG_PCM_F32LE_DEMUXER 0 ++#define CONFIG_PCM_S32BE_DEMUXER 0 ++#define CONFIG_PCM_S32LE_DEMUXER 0 ++#define CONFIG_PCM_S24BE_DEMUXER 0 ++#define CONFIG_PCM_S24LE_DEMUXER 0 ++#define CONFIG_PCM_S16BE_DEMUXER 0 ++#define CONFIG_PCM_S16LE_DEMUXER 0 ++#define CONFIG_PCM_S8_DEMUXER 0 ++#define CONFIG_PCM_U32BE_DEMUXER 0 ++#define CONFIG_PCM_U32LE_DEMUXER 0 ++#define CONFIG_PCM_U24BE_DEMUXER 0 ++#define CONFIG_PCM_U24LE_DEMUXER 0 ++#define CONFIG_PCM_U16BE_DEMUXER 0 ++#define CONFIG_PCM_U16LE_DEMUXER 0 ++#define CONFIG_PCM_U8_DEMUXER 0 ++#define CONFIG_PJS_DEMUXER 0 ++#define CONFIG_PMP_DEMUXER 0 ++#define CONFIG_PP_BNK_DEMUXER 0 ++#define CONFIG_PVA_DEMUXER 0 ++#define CONFIG_PVF_DEMUXER 0 ++#define CONFIG_QCP_DEMUXER 0 ++#define CONFIG_R3D_DEMUXER 0 ++#define CONFIG_RAWVIDEO_DEMUXER 0 ++#define CONFIG_REALTEXT_DEMUXER 0 ++#define CONFIG_REDSPARK_DEMUXER 0 ++#define CONFIG_RL2_DEMUXER 0 ++#define CONFIG_RM_DEMUXER 0 ++#define CONFIG_ROQ_DEMUXER 0 ++#define CONFIG_RPL_DEMUXER 0 ++#define CONFIG_RSD_DEMUXER 0 ++#define CONFIG_RSO_DEMUXER 0 ++#define CONFIG_RTP_DEMUXER 0 ++#define CONFIG_RTSP_DEMUXER 0 ++#define CONFIG_S337M_DEMUXER 0 ++#define CONFIG_SAMI_DEMUXER 0 ++#define CONFIG_SAP_DEMUXER 0 ++#define CONFIG_SBC_DEMUXER 0 ++#define CONFIG_SBG_DEMUXER 0 ++#define CONFIG_SCC_DEMUXER 0 ++#define CONFIG_SDP_DEMUXER 0 ++#define CONFIG_SDR2_DEMUXER 0 ++#define CONFIG_SDS_DEMUXER 0 ++#define CONFIG_SDX_DEMUXER 0 ++#define CONFIG_SEGAFILM_DEMUXER 0 ++#define CONFIG_SER_DEMUXER 0 ++#define CONFIG_SHORTEN_DEMUXER 0 ++#define CONFIG_SIFF_DEMUXER 0 ++#define CONFIG_SLN_DEMUXER 0 ++#define CONFIG_SMACKER_DEMUXER 0 ++#define CONFIG_SMJPEG_DEMUXER 0 ++#define CONFIG_SMUSH_DEMUXER 0 ++#define CONFIG_SOL_DEMUXER 0 ++#define CONFIG_SOX_DEMUXER 0 ++#define CONFIG_SPDIF_DEMUXER 0 ++#define CONFIG_SRT_DEMUXER 0 ++#define CONFIG_STR_DEMUXER 0 ++#define CONFIG_STL_DEMUXER 0 ++#define CONFIG_SUBVIEWER1_DEMUXER 0 ++#define CONFIG_SUBVIEWER_DEMUXER 0 ++#define CONFIG_SUP_DEMUXER 0 ++#define CONFIG_SVAG_DEMUXER 0 ++#define CONFIG_SWF_DEMUXER 0 ++#define CONFIG_TAK_DEMUXER 0 ++#define CONFIG_TEDCAPTIONS_DEMUXER 0 ++#define CONFIG_THP_DEMUXER 0 ++#define CONFIG_THREEDOSTR_DEMUXER 0 ++#define CONFIG_TIERTEXSEQ_DEMUXER 0 ++#define CONFIG_TMV_DEMUXER 0 ++#define CONFIG_TRUEHD_DEMUXER 0 ++#define CONFIG_TTA_DEMUXER 0 ++#define CONFIG_TXD_DEMUXER 0 ++#define CONFIG_TTY_DEMUXER 0 ++#define CONFIG_TY_DEMUXER 0 ++#define CONFIG_V210_DEMUXER 0 ++#define CONFIG_V210X_DEMUXER 0 ++#define CONFIG_VAG_DEMUXER 0 ++#define CONFIG_VC1_DEMUXER 0 ++#define CONFIG_VC1T_DEMUXER 0 ++#define CONFIG_VIVIDAS_DEMUXER 0 ++#define CONFIG_VIVO_DEMUXER 0 ++#define CONFIG_VMD_DEMUXER 0 ++#define CONFIG_VOBSUB_DEMUXER 0 ++#define CONFIG_VOC_DEMUXER 0 ++#define CONFIG_VPK_DEMUXER 0 ++#define CONFIG_VPLAYER_DEMUXER 0 ++#define CONFIG_VQF_DEMUXER 0 ++#define CONFIG_W64_DEMUXER 0 ++#define CONFIG_WAV_DEMUXER 1 ++#define CONFIG_WC3_DEMUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 ++#define CONFIG_WEBVTT_DEMUXER 0 ++#define CONFIG_WSAUD_DEMUXER 0 ++#define CONFIG_WSD_DEMUXER 0 ++#define CONFIG_WSVQA_DEMUXER 0 ++#define CONFIG_WTV_DEMUXER 0 ++#define CONFIG_WVE_DEMUXER 0 ++#define CONFIG_WV_DEMUXER 0 ++#define CONFIG_XA_DEMUXER 0 ++#define CONFIG_XBIN_DEMUXER 0 ++#define CONFIG_XMV_DEMUXER 0 ++#define CONFIG_XVAG_DEMUXER 0 ++#define CONFIG_XWMA_DEMUXER 0 ++#define CONFIG_YOP_DEMUXER 0 ++#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 ++#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 ++#define CONFIG_LIBGME_DEMUXER 0 ++#define CONFIG_LIBMODPLUG_DEMUXER 0 ++#define CONFIG_LIBOPENMPT_DEMUXER 0 ++#define CONFIG_VAPOURSYNTH_DEMUXER 0 ++#define CONFIG_A64_MUXER 0 ++#define CONFIG_AC3_MUXER 0 ++#define CONFIG_ADTS_MUXER 0 ++#define CONFIG_ADX_MUXER 0 ++#define CONFIG_AIFF_MUXER 0 ++#define CONFIG_AMR_MUXER 0 ++#define CONFIG_APM_MUXER 0 ++#define CONFIG_APNG_MUXER 0 ++#define CONFIG_APTX_MUXER 0 ++#define CONFIG_APTX_HD_MUXER 0 ++#define CONFIG_ARGO_ASF_MUXER 0 ++#define CONFIG_ASF_MUXER 0 ++#define CONFIG_ASS_MUXER 0 ++#define CONFIG_AST_MUXER 0 ++#define CONFIG_ASF_STREAM_MUXER 0 ++#define CONFIG_AU_MUXER 0 ++#define CONFIG_AVI_MUXER 0 ++#define CONFIG_AVM2_MUXER 0 ++#define CONFIG_AVS2_MUXER 0 ++#define CONFIG_BIT_MUXER 0 ++#define CONFIG_CAF_MUXER 0 ++#define CONFIG_CAVSVIDEO_MUXER 0 ++#define CONFIG_CODEC2_MUXER 0 ++#define CONFIG_CODEC2RAW_MUXER 0 ++#define CONFIG_CRC_MUXER 0 ++#define CONFIG_DASH_MUXER 0 ++#define CONFIG_DATA_MUXER 0 ++#define CONFIG_DAUD_MUXER 0 ++#define CONFIG_DIRAC_MUXER 0 ++#define CONFIG_DNXHD_MUXER 0 ++#define CONFIG_DTS_MUXER 0 ++#define CONFIG_DV_MUXER 0 ++#define CONFIG_EAC3_MUXER 0 ++#define CONFIG_F4V_MUXER 0 ++#define CONFIG_FFMETADATA_MUXER 0 ++#define CONFIG_FIFO_MUXER 0 ++#define CONFIG_FIFO_TEST_MUXER 0 ++#define CONFIG_FILMSTRIP_MUXER 0 ++#define CONFIG_FITS_MUXER 0 ++#define CONFIG_FLAC_MUXER 0 ++#define CONFIG_FLV_MUXER 0 ++#define CONFIG_FRAMECRC_MUXER 0 ++#define CONFIG_FRAMEHASH_MUXER 0 ++#define CONFIG_FRAMEMD5_MUXER 0 ++#define CONFIG_G722_MUXER 0 ++#define CONFIG_G723_1_MUXER 0 ++#define CONFIG_G726_MUXER 0 ++#define CONFIG_G726LE_MUXER 0 ++#define CONFIG_GIF_MUXER 0 ++#define CONFIG_GSM_MUXER 0 ++#define CONFIG_GXF_MUXER 0 ++#define CONFIG_H261_MUXER 0 ++#define CONFIG_H263_MUXER 0 ++#define CONFIG_H264_MUXER 0 ++#define CONFIG_HASH_MUXER 0 ++#define CONFIG_HDS_MUXER 0 ++#define CONFIG_HEVC_MUXER 0 ++#define CONFIG_HLS_MUXER 0 ++#define CONFIG_ICO_MUXER 0 ++#define CONFIG_ILBC_MUXER 0 ++#define CONFIG_IMAGE2_MUXER 0 ++#define CONFIG_IMAGE2PIPE_MUXER 0 ++#define CONFIG_IPOD_MUXER 0 ++#define CONFIG_IRCAM_MUXER 0 ++#define CONFIG_ISMV_MUXER 0 ++#define CONFIG_IVF_MUXER 0 ++#define CONFIG_JACOSUB_MUXER 0 ++#define CONFIG_KVAG_MUXER 0 ++#define CONFIG_LATM_MUXER 0 ++#define CONFIG_LRC_MUXER 0 ++#define CONFIG_M4V_MUXER 0 ++#define CONFIG_MD5_MUXER 0 ++#define CONFIG_MATROSKA_MUXER 0 ++#define CONFIG_MATROSKA_AUDIO_MUXER 0 ++#define CONFIG_MICRODVD_MUXER 0 ++#define CONFIG_MJPEG_MUXER 0 ++#define CONFIG_MLP_MUXER 0 ++#define CONFIG_MMF_MUXER 0 ++#define CONFIG_MOV_MUXER 0 ++#define CONFIG_MP2_MUXER 0 ++#define CONFIG_MP3_MUXER 0 ++#define CONFIG_MP4_MUXER 0 ++#define CONFIG_MPEG1SYSTEM_MUXER 0 ++#define CONFIG_MPEG1VCD_MUXER 0 ++#define CONFIG_MPEG1VIDEO_MUXER 0 ++#define CONFIG_MPEG2DVD_MUXER 0 ++#define CONFIG_MPEG2SVCD_MUXER 0 ++#define CONFIG_MPEG2VIDEO_MUXER 0 ++#define CONFIG_MPEG2VOB_MUXER 0 ++#define CONFIG_MPEGTS_MUXER 0 ++#define CONFIG_MPJPEG_MUXER 0 ++#define CONFIG_MXF_MUXER 0 ++#define CONFIG_MXF_D10_MUXER 0 ++#define CONFIG_MXF_OPATOM_MUXER 0 ++#define CONFIG_NULL_MUXER 0 ++#define CONFIG_NUT_MUXER 0 ++#define CONFIG_OGA_MUXER 0 ++#define CONFIG_OGG_MUXER 0 ++#define CONFIG_OGV_MUXER 0 ++#define CONFIG_OMA_MUXER 0 ++#define CONFIG_OPUS_MUXER 0 ++#define CONFIG_PCM_ALAW_MUXER 0 ++#define CONFIG_PCM_MULAW_MUXER 0 ++#define CONFIG_PCM_VIDC_MUXER 0 ++#define CONFIG_PCM_F64BE_MUXER 0 ++#define CONFIG_PCM_F64LE_MUXER 0 ++#define CONFIG_PCM_F32BE_MUXER 0 ++#define CONFIG_PCM_F32LE_MUXER 0 ++#define CONFIG_PCM_S32BE_MUXER 0 ++#define CONFIG_PCM_S32LE_MUXER 0 ++#define CONFIG_PCM_S24BE_MUXER 0 ++#define CONFIG_PCM_S24LE_MUXER 0 ++#define CONFIG_PCM_S16BE_MUXER 0 ++#define CONFIG_PCM_S16LE_MUXER 0 ++#define CONFIG_PCM_S8_MUXER 0 ++#define CONFIG_PCM_U32BE_MUXER 0 ++#define CONFIG_PCM_U32LE_MUXER 0 ++#define CONFIG_PCM_U24BE_MUXER 0 ++#define CONFIG_PCM_U24LE_MUXER 0 ++#define CONFIG_PCM_U16BE_MUXER 0 ++#define CONFIG_PCM_U16LE_MUXER 0 ++#define CONFIG_PCM_U8_MUXER 0 ++#define CONFIG_PSP_MUXER 0 ++#define CONFIG_RAWVIDEO_MUXER 0 ++#define CONFIG_RM_MUXER 0 ++#define CONFIG_ROQ_MUXER 0 ++#define CONFIG_RSO_MUXER 0 ++#define CONFIG_RTP_MUXER 0 ++#define CONFIG_RTP_MPEGTS_MUXER 0 ++#define CONFIG_RTSP_MUXER 0 ++#define CONFIG_SAP_MUXER 0 ++#define CONFIG_SBC_MUXER 0 ++#define CONFIG_SCC_MUXER 0 ++#define CONFIG_SEGAFILM_MUXER 0 ++#define CONFIG_SEGMENT_MUXER 0 ++#define CONFIG_STREAM_SEGMENT_MUXER 0 ++#define CONFIG_SINGLEJPEG_MUXER 0 ++#define CONFIG_SMJPEG_MUXER 0 ++#define CONFIG_SMOOTHSTREAMING_MUXER 0 ++#define CONFIG_SOX_MUXER 0 ++#define CONFIG_SPX_MUXER 0 ++#define CONFIG_SPDIF_MUXER 0 ++#define CONFIG_SRT_MUXER 0 ++#define CONFIG_STREAMHASH_MUXER 0 ++#define CONFIG_SUP_MUXER 0 ++#define CONFIG_SWF_MUXER 0 ++#define CONFIG_TEE_MUXER 0 ++#define CONFIG_TG2_MUXER 0 ++#define CONFIG_TGP_MUXER 0 ++#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 ++#define CONFIG_TRUEHD_MUXER 0 ++#define CONFIG_TTA_MUXER 0 ++#define CONFIG_UNCODEDFRAMECRC_MUXER 0 ++#define CONFIG_VC1_MUXER 0 ++#define CONFIG_VC1T_MUXER 0 ++#define CONFIG_VOC_MUXER 0 ++#define CONFIG_W64_MUXER 0 ++#define CONFIG_WAV_MUXER 0 ++#define CONFIG_WEBM_MUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 ++#define CONFIG_WEBM_CHUNK_MUXER 0 ++#define CONFIG_WEBP_MUXER 0 ++#define CONFIG_WEBVTT_MUXER 0 ++#define CONFIG_WTV_MUXER 0 ++#define CONFIG_WV_MUXER 0 ++#define CONFIG_YUV4MPEGPIPE_MUXER 0 ++#define CONFIG_CHROMAPRINT_MUXER 0 ++#define CONFIG_ASYNC_PROTOCOL 0 ++#define CONFIG_BLURAY_PROTOCOL 0 ++#define CONFIG_CACHE_PROTOCOL 0 ++#define CONFIG_CONCAT_PROTOCOL 0 ++#define CONFIG_CRYPTO_PROTOCOL 0 ++#define CONFIG_DATA_PROTOCOL 0 ++#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 ++#define CONFIG_FFRTMPHTTP_PROTOCOL 0 ++#define CONFIG_FILE_PROTOCOL 0 ++#define CONFIG_FTP_PROTOCOL 0 ++#define CONFIG_GOPHER_PROTOCOL 0 ++#define CONFIG_HLS_PROTOCOL 0 ++#define CONFIG_HTTP_PROTOCOL 0 ++#define CONFIG_HTTPPROXY_PROTOCOL 0 ++#define CONFIG_HTTPS_PROTOCOL 0 ++#define CONFIG_ICECAST_PROTOCOL 0 ++#define CONFIG_MMSH_PROTOCOL 0 ++#define CONFIG_MMST_PROTOCOL 0 ++#define CONFIG_MD5_PROTOCOL 0 ++#define CONFIG_PIPE_PROTOCOL 0 ++#define CONFIG_PROMPEG_PROTOCOL 0 ++#define CONFIG_RTMP_PROTOCOL 0 ++#define CONFIG_RTMPE_PROTOCOL 0 ++#define CONFIG_RTMPS_PROTOCOL 0 ++#define CONFIG_RTMPT_PROTOCOL 0 ++#define CONFIG_RTMPTE_PROTOCOL 0 ++#define CONFIG_RTMPTS_PROTOCOL 0 ++#define CONFIG_RTP_PROTOCOL 0 ++#define CONFIG_SCTP_PROTOCOL 0 ++#define CONFIG_SRTP_PROTOCOL 0 ++#define CONFIG_SUBFILE_PROTOCOL 0 ++#define CONFIG_TEE_PROTOCOL 0 ++#define CONFIG_TCP_PROTOCOL 0 ++#define CONFIG_TLS_PROTOCOL 0 ++#define CONFIG_UDP_PROTOCOL 0 ++#define CONFIG_UDPLITE_PROTOCOL 0 ++#define CONFIG_UNIX_PROTOCOL 0 ++#define CONFIG_LIBAMQP_PROTOCOL 0 ++#define CONFIG_LIBRTMP_PROTOCOL 0 ++#define CONFIG_LIBRTMPE_PROTOCOL 0 ++#define CONFIG_LIBRTMPS_PROTOCOL 0 ++#define CONFIG_LIBRTMPT_PROTOCOL 0 ++#define CONFIG_LIBRTMPTE_PROTOCOL 0 ++#define CONFIG_LIBSRT_PROTOCOL 0 ++#define CONFIG_LIBSSH_PROTOCOL 0 ++#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 ++#define CONFIG_LIBZMQ_PROTOCOL 0 ++#endif /* FFMPEG_CONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/bsf_list.c +@@ -0,0 +1,3 @@ ++static const AVBitStreamFilter * const bitstream_filters[] = { ++ &ff_null_bsf, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/codec_list.c +@@ -0,0 +1,20 @@ ++static const AVCodec * const codec_list[] = { ++ &ff_h264_decoder, ++ &ff_theora_decoder, ++ &ff_vp3_decoder, ++ &ff_vp8_decoder, ++ &ff_aac_decoder, ++ &ff_flac_decoder, ++ &ff_mp3_decoder, ++ &ff_vorbis_decoder, ++ &ff_pcm_alaw_decoder, ++ &ff_pcm_f32le_decoder, ++ &ff_pcm_mulaw_decoder, ++ &ff_pcm_s16be_decoder, ++ &ff_pcm_s16le_decoder, ++ &ff_pcm_s24be_decoder, ++ &ff_pcm_s24le_decoder, ++ &ff_pcm_s32le_decoder, ++ &ff_pcm_u8_decoder, ++ &ff_libopus_decoder, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavcodec/parser_list.c +@@ -0,0 +1,11 @@ ++static const AVCodecParser * const parser_list[] = { ++ &ff_aac_parser, ++ &ff_flac_parser, ++ &ff_h264_parser, ++ &ff_mpegaudio_parser, ++ &ff_opus_parser, ++ &ff_vorbis_parser, ++ &ff_vp3_parser, ++ &ff_vp8_parser, ++ &ff_vp9_parser, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/demuxer_list.c +@@ -0,0 +1,9 @@ ++static const AVInputFormat * const demuxer_list[] = { ++ &ff_aac_demuxer, ++ &ff_flac_demuxer, ++ &ff_matroska_demuxer, ++ &ff_mov_demuxer, ++ &ff_mp3_demuxer, ++ &ff_ogg_demuxer, ++ &ff_wav_demuxer, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/muxer_list.c +@@ -0,0 +1,2 @@ ++static const AVOutputFormat * const muxer_list[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavformat/protocol_list.c +@@ -0,0 +1,2 @@ ++static const URLProtocol * const url_protocols[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavutil/avconfig.h +@@ -0,0 +1,6 @@ ++/* Generated by ffmpeg configure */ ++#ifndef AVUTIL_AVCONFIG_H ++#define AVUTIL_AVCONFIG_H ++#define AV_HAVE_BIGENDIAN 0 ++#define AV_HAVE_FAST_UNALIGNED 0 ++#endif /* AVUTIL_AVCONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/config.h +@@ -0,0 +1,2626 @@ ++/* Automatically generated by configure - do not modify! */ ++#ifndef FFMPEG_CONFIG_H ++#define FFMPEG_CONFIG_H ++/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64 --enable-decoder='aac,h264' --enable-demuxer=aac --enable-parser='aac,h264' --enable-decoder=mpeg4 --enable-parser='h263,mpeg4video' --enable-demuxer=avi --enable-demuxer=amr --enable-decoder='amrnb,amrwb' --enable-decoder=gsm_ms --enable-parser=gsm" -- elide long configuration string from binary */ ++#define FFMPEG_LICENSE "LGPL version 2.1 or later" ++#define CONFIG_THIS_YEAR 2020 ++#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" ++#define AVCONV_DATADIR "/usr/local/share/ffmpeg" ++#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" ++#define av_restrict restrict ++#define EXTERN_PREFIX "" ++#define EXTERN_ASM ++#define BUILDSUF "" ++#define SLIBSUF ".so" ++#define HAVE_MMX2 HAVE_MMXEXT ++#define SWS_MAX_FILTER_SIZE 256 ++#define ARCH_AARCH64 0 ++#define ARCH_ALPHA 0 ++#define ARCH_ARM 0 ++#define ARCH_AVR32 0 ++#define ARCH_AVR32_AP 0 ++#define ARCH_AVR32_UC 0 ++#define ARCH_BFIN 0 ++#define ARCH_IA64 0 ++#define ARCH_M68K 0 ++#define ARCH_MIPS 0 ++#define ARCH_MIPS64 0 ++#define ARCH_PARISC 0 ++#define ARCH_PPC 0 ++#define ARCH_PPC64 0 ++#define ARCH_RISCV 1 ++#define ARCH_S390 0 ++#define ARCH_SH4 0 ++#define ARCH_SPARC 0 ++#define ARCH_SPARC64 0 ++#define ARCH_TILEGX 0 ++#define ARCH_TILEPRO 0 ++#define ARCH_TOMI 0 ++#define ARCH_X86 0 ++#define ARCH_X86_32 0 ++#define ARCH_X86_64 0 ++#define HAVE_ARMV5TE 0 ++#define HAVE_ARMV6 0 ++#define HAVE_ARMV6T2 0 ++#define HAVE_ARMV8 0 ++#define HAVE_NEON 0 ++#define HAVE_VFP 0 ++#define HAVE_VFPV3 0 ++#define HAVE_SETEND 0 ++#define HAVE_ALTIVEC 0 ++#define HAVE_DCBZL 0 ++#define HAVE_LDBRX 0 ++#define HAVE_POWER8 0 ++#define HAVE_PPC4XX 0 ++#define HAVE_VSX 0 ++#define HAVE_AESNI 0 ++#define HAVE_AMD3DNOW 0 ++#define HAVE_AMD3DNOWEXT 0 ++#define HAVE_AVX 0 ++#define HAVE_AVX2 0 ++#define HAVE_AVX512 0 ++#define HAVE_FMA3 0 ++#define HAVE_FMA4 0 ++#define HAVE_MMX 0 ++#define HAVE_MMXEXT 0 ++#define HAVE_SSE 0 ++#define HAVE_SSE2 0 ++#define HAVE_SSE3 0 ++#define HAVE_SSE4 0 ++#define HAVE_SSE42 0 ++#define HAVE_SSSE3 0 ++#define HAVE_XOP 0 ++#define HAVE_CPUNOP 0 ++#define HAVE_I686 0 ++#define HAVE_MIPSFPU 0 ++#define HAVE_MIPS32R2 0 ++#define HAVE_MIPS32R5 0 ++#define HAVE_MIPS64R2 0 ++#define HAVE_MIPS32R6 0 ++#define HAVE_MIPS64R6 0 ++#define HAVE_MIPSDSP 0 ++#define HAVE_MIPSDSPR2 0 ++#define HAVE_MSA 0 ++#define HAVE_MSA2 0 ++#define HAVE_LOONGSON2 0 ++#define HAVE_LOONGSON3 0 ++#define HAVE_MMI 0 ++#define HAVE_ARMV5TE_EXTERNAL 0 ++#define HAVE_ARMV6_EXTERNAL 0 ++#define HAVE_ARMV6T2_EXTERNAL 0 ++#define HAVE_ARMV8_EXTERNAL 0 ++#define HAVE_NEON_EXTERNAL 0 ++#define HAVE_VFP_EXTERNAL 0 ++#define HAVE_VFPV3_EXTERNAL 0 ++#define HAVE_SETEND_EXTERNAL 0 ++#define HAVE_ALTIVEC_EXTERNAL 0 ++#define HAVE_DCBZL_EXTERNAL 0 ++#define HAVE_LDBRX_EXTERNAL 0 ++#define HAVE_POWER8_EXTERNAL 0 ++#define HAVE_PPC4XX_EXTERNAL 0 ++#define HAVE_VSX_EXTERNAL 0 ++#define HAVE_AESNI_EXTERNAL 0 ++#define HAVE_AMD3DNOW_EXTERNAL 0 ++#define HAVE_AMD3DNOWEXT_EXTERNAL 0 ++#define HAVE_AVX_EXTERNAL 0 ++#define HAVE_AVX2_EXTERNAL 0 ++#define HAVE_AVX512_EXTERNAL 0 ++#define HAVE_FMA3_EXTERNAL 0 ++#define HAVE_FMA4_EXTERNAL 0 ++#define HAVE_MMX_EXTERNAL 0 ++#define HAVE_MMXEXT_EXTERNAL 0 ++#define HAVE_SSE_EXTERNAL 0 ++#define HAVE_SSE2_EXTERNAL 0 ++#define HAVE_SSE3_EXTERNAL 0 ++#define HAVE_SSE4_EXTERNAL 0 ++#define HAVE_SSE42_EXTERNAL 0 ++#define HAVE_SSSE3_EXTERNAL 0 ++#define HAVE_XOP_EXTERNAL 0 ++#define HAVE_CPUNOP_EXTERNAL 0 ++#define HAVE_I686_EXTERNAL 0 ++#define HAVE_MIPSFPU_EXTERNAL 0 ++#define HAVE_MIPS32R2_EXTERNAL 0 ++#define HAVE_MIPS32R5_EXTERNAL 0 ++#define HAVE_MIPS64R2_EXTERNAL 0 ++#define HAVE_MIPS32R6_EXTERNAL 0 ++#define HAVE_MIPS64R6_EXTERNAL 0 ++#define HAVE_MIPSDSP_EXTERNAL 0 ++#define HAVE_MIPSDSPR2_EXTERNAL 0 ++#define HAVE_MSA_EXTERNAL 0 ++#define HAVE_MSA2_EXTERNAL 0 ++#define HAVE_LOONGSON2_EXTERNAL 0 ++#define HAVE_LOONGSON3_EXTERNAL 0 ++#define HAVE_MMI_EXTERNAL 0 ++#define HAVE_ARMV5TE_INLINE 0 ++#define HAVE_ARMV6_INLINE 0 ++#define HAVE_ARMV6T2_INLINE 0 ++#define HAVE_ARMV8_INLINE 0 ++#define HAVE_NEON_INLINE 0 ++#define HAVE_VFP_INLINE 0 ++#define HAVE_VFPV3_INLINE 0 ++#define HAVE_SETEND_INLINE 0 ++#define HAVE_ALTIVEC_INLINE 0 ++#define HAVE_DCBZL_INLINE 0 ++#define HAVE_LDBRX_INLINE 0 ++#define HAVE_POWER8_INLINE 0 ++#define HAVE_PPC4XX_INLINE 0 ++#define HAVE_VSX_INLINE 0 ++#define HAVE_AESNI_INLINE 0 ++#define HAVE_AMD3DNOW_INLINE 0 ++#define HAVE_AMD3DNOWEXT_INLINE 0 ++#define HAVE_AVX_INLINE 0 ++#define HAVE_AVX2_INLINE 0 ++#define HAVE_AVX512_INLINE 0 ++#define HAVE_FMA3_INLINE 0 ++#define HAVE_FMA4_INLINE 0 ++#define HAVE_MMX_INLINE 0 ++#define HAVE_MMXEXT_INLINE 0 ++#define HAVE_SSE_INLINE 0 ++#define HAVE_SSE2_INLINE 0 ++#define HAVE_SSE3_INLINE 0 ++#define HAVE_SSE4_INLINE 0 ++#define HAVE_SSE42_INLINE 0 ++#define HAVE_SSSE3_INLINE 0 ++#define HAVE_XOP_INLINE 0 ++#define HAVE_CPUNOP_INLINE 0 ++#define HAVE_I686_INLINE 0 ++#define HAVE_MIPSFPU_INLINE 0 ++#define HAVE_MIPS32R2_INLINE 0 ++#define HAVE_MIPS32R5_INLINE 0 ++#define HAVE_MIPS64R2_INLINE 0 ++#define HAVE_MIPS32R6_INLINE 0 ++#define HAVE_MIPS64R6_INLINE 0 ++#define HAVE_MIPSDSP_INLINE 0 ++#define HAVE_MIPSDSPR2_INLINE 0 ++#define HAVE_MSA_INLINE 0 ++#define HAVE_MSA2_INLINE 0 ++#define HAVE_LOONGSON2_INLINE 0 ++#define HAVE_LOONGSON3_INLINE 0 ++#define HAVE_MMI_INLINE 0 ++#define HAVE_ALIGNED_STACK 0 ++#define HAVE_FAST_64BIT 1 ++#define HAVE_FAST_CLZ 0 ++#define HAVE_FAST_CMOV 0 ++#define HAVE_LOCAL_ALIGNED 0 ++#define HAVE_SIMD_ALIGN_16 0 ++#define HAVE_SIMD_ALIGN_32 0 ++#define HAVE_SIMD_ALIGN_64 0 ++#define HAVE_ATOMIC_CAS_PTR 0 ++#define HAVE_MACHINE_RW_BARRIER 0 ++#define HAVE_MEMORYBARRIER 0 ++#define HAVE_MM_EMPTY 0 ++#define HAVE_RDTSC 0 ++#define HAVE_SEM_TIMEDWAIT 1 ++#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 ++#define HAVE_CABS 0 ++#define HAVE_CEXP 0 ++#define HAVE_INLINE_ASM 1 ++#define HAVE_SYMVER 0 ++#define HAVE_X86ASM 0 ++#define HAVE_BIGENDIAN 0 ++#define HAVE_FAST_UNALIGNED 0 ++#define HAVE_ARPA_INET_H 0 ++#define HAVE_ASM_TYPES_H 1 ++#define HAVE_CDIO_PARANOIA_H 0 ++#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 ++#define HAVE_CUDA_H 0 ++#define HAVE_DISPATCH_DISPATCH_H 0 ++#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 ++#define HAVE_DEV_IC_BT8XX_H 0 ++#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 ++#define HAVE_DIRECT_H 0 ++#define HAVE_DIRENT_H 1 ++#define HAVE_DXGIDEBUG_H 0 ++#define HAVE_DXVA_H 0 ++#define HAVE_ES2_GL_H 0 ++#define HAVE_GSM_H 0 ++#define HAVE_IO_H 0 ++#define HAVE_LINUX_PERF_EVENT_H 1 ++#define HAVE_MACHINE_IOCTL_BT848_H 0 ++#define HAVE_MACHINE_IOCTL_METEOR_H 0 ++#define HAVE_MALLOC_H 1 ++#define HAVE_OPENCV2_CORE_CORE_C_H 0 ++#define HAVE_OPENGL_GL3_H 0 ++#define HAVE_POLL_H 1 ++#define HAVE_SYS_PARAM_H 1 ++#define HAVE_SYS_RESOURCE_H 1 ++#define HAVE_SYS_SELECT_H 1 ++#define HAVE_SYS_SOUNDCARD_H 1 ++#define HAVE_SYS_TIME_H 1 ++#define HAVE_SYS_UN_H 1 ++#define HAVE_SYS_VIDEOIO_H 0 ++#define HAVE_TERMIOS_H 1 ++#define HAVE_UDPLITE_H 0 ++#define HAVE_UNISTD_H 1 ++#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ ++#define HAVE_WINDOWS_H 0 ++#define HAVE_WINSOCK2_H 0 ++#define HAVE_INTRINSICS_NEON 0 ++#define HAVE_ATANF 1 ++#define HAVE_ATAN2F 1 ++#define HAVE_CBRT 1 ++#define HAVE_CBRTF 1 ++#define HAVE_COPYSIGN 1 ++#define HAVE_COSF 1 ++#define HAVE_ERF 1 ++#define HAVE_EXP2 1 ++#define HAVE_EXP2F 1 ++#define HAVE_EXPF 1 ++#define HAVE_HYPOT 1 ++#define HAVE_ISFINITE 1 ++#define HAVE_ISINF 1 ++#define HAVE_ISNAN 1 ++#define HAVE_LDEXPF 1 ++#define HAVE_LLRINT 1 ++#define HAVE_LLRINTF 1 ++#define HAVE_LOG2 1 ++#define HAVE_LOG2F 1 ++#define HAVE_LOG10F 1 ++#define HAVE_LRINT 1 ++#define HAVE_LRINTF 1 ++#define HAVE_POWF 1 ++#define HAVE_RINT 1 ++#define HAVE_ROUND 1 ++#define HAVE_ROUNDF 1 ++#define HAVE_SINF 1 ++#define HAVE_TRUNC 1 ++#define HAVE_TRUNCF 1 ++#define HAVE_DOS_PATHS 0 ++#define HAVE_LIBC_MSVCRT 0 ++#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 ++#define HAVE_SECTION_DATA_REL_RO 1 ++#define HAVE_THREADS 1 ++#define HAVE_UWP 0 ++#define HAVE_WINRT 0 ++#define HAVE_ACCESS 1 ++#define HAVE_ALIGNED_MALLOC 0 ++#define HAVE_ARC4RANDOM 0 ++#define HAVE_CLOCK_GETTIME 1 ++#define HAVE_CLOSESOCKET 0 ++#define HAVE_COMMANDLINETOARGVW 0 ++#define HAVE_FCNTL 1 ++#define HAVE_GETADDRINFO 0 ++#define HAVE_GETHRTIME 0 ++#define HAVE_GETOPT 1 ++#define HAVE_GETMODULEHANDLE 0 ++#define HAVE_GETPROCESSAFFINITYMASK 0 ++#define HAVE_GETPROCESSMEMORYINFO 0 ++#define HAVE_GETPROCESSTIMES 0 ++#define HAVE_GETRUSAGE 1 ++#define HAVE_GETSTDHANDLE 0 ++#define HAVE_GETSYSTEMTIMEASFILETIME 0 ++#define HAVE_GETTIMEOFDAY 1 ++#define HAVE_GLOB 1 ++#define HAVE_GLXGETPROCADDRESS 0 ++#define HAVE_GMTIME_R 1 ++#define HAVE_INET_ATON 0 ++#define HAVE_ISATTY 1 ++#define HAVE_KBHIT 0 ++#define HAVE_LOCALTIME_R 1 ++#define HAVE_LSTAT 1 ++#define HAVE_LZO1X_999_COMPRESS 0 ++#define HAVE_MACH_ABSOLUTE_TIME 0 ++#define HAVE_MAPVIEWOFFILE 0 ++#define HAVE_MEMALIGN 1 ++#define HAVE_MKSTEMP 1 ++#define HAVE_MMAP 1 ++#define HAVE_MPROTECT 1 ++#define HAVE_NANOSLEEP 1 ++#define HAVE_PEEKNAMEDPIPE 0 ++#define HAVE_POSIX_MEMALIGN 1 ++#define HAVE_PTHREAD_CANCEL 1 ++#define HAVE_SCHED_GETAFFINITY 1 ++#define HAVE_SECITEMIMPORT 0 ++#define HAVE_SETCONSOLETEXTATTRIBUTE 0 ++#define HAVE_SETCONSOLECTRLHANDLER 0 ++#define HAVE_SETDLLDIRECTORY 0 ++#define HAVE_SETMODE 0 ++#define HAVE_SETRLIMIT 1 ++#define HAVE_SLEEP 0 ++#define HAVE_STRERROR_R 1 ++#define HAVE_SYSCONF 1 ++#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ ++#define HAVE_USLEEP 1 ++#define HAVE_UTGETOSTYPEFROMSTRING 0 ++#define HAVE_VIRTUALALLOC 0 ++#define HAVE_WGLGETPROCADDRESS 0 ++#define HAVE_BCRYPT 0 ++#define HAVE_VAAPI_DRM 0 ++#define HAVE_VAAPI_X11 0 ++#define HAVE_VDPAU_X11 0 ++#define HAVE_PTHREADS 1 ++#define HAVE_OS2THREADS 0 ++#define HAVE_W32THREADS 0 ++#define HAVE_AS_ARCH_DIRECTIVE 0 ++#define HAVE_AS_DN_DIRECTIVE 0 ++#define HAVE_AS_FPU_DIRECTIVE 0 ++#define HAVE_AS_FUNC 0 ++#define HAVE_AS_OBJECT_ARCH 0 ++#define HAVE_ASM_MOD_Q 0 ++#define HAVE_BLOCKS_EXTENSION 0 ++#define HAVE_EBP_AVAILABLE 0 ++#define HAVE_EBX_AVAILABLE 0 ++#define HAVE_GNU_AS 0 ++#define HAVE_GNU_WINDRES 0 ++#define HAVE_IBM_ASM 0 ++#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 ++#define HAVE_INLINE_ASM_LABELS 1 ++#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 ++#define HAVE_PRAGMA_DEPRECATED 1 ++#define HAVE_RSYNC_CONTIMEOUT 0 ++#define HAVE_SYMVER_ASM_LABEL 0 ++#define HAVE_SYMVER_GNU_ASM 1 ++#define HAVE_VFP_ARGS 0 ++#define HAVE_XFORM_ASM 0 ++#define HAVE_XMM_CLOBBERS 0 ++#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 ++#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 ++#define HAVE_SOCKLEN_T 0 ++#define HAVE_STRUCT_ADDRINFO 0 ++#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 ++#define HAVE_STRUCT_IP_MREQ_SOURCE 0 ++#define HAVE_STRUCT_IPV6_MREQ 0 ++#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 ++#define HAVE_STRUCT_POLLFD 0 ++#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 ++#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 ++#define HAVE_STRUCT_SOCKADDR_IN6 0 ++#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 ++#define HAVE_STRUCT_SOCKADDR_STORAGE 0 ++#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 ++#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 ++#define HAVE_LIBDRM_GETFB2 0 ++#define HAVE_MAKEINFO 0 ++#define HAVE_MAKEINFO_HTML 0 ++#define HAVE_OPENCL_D3D11 0 ++#define HAVE_OPENCL_DRM_ARM 0 ++#define HAVE_OPENCL_DRM_BEIGNET 0 ++#define HAVE_OPENCL_DXVA2 0 ++#define HAVE_OPENCL_VAAPI_BEIGNET 0 ++#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 ++#define HAVE_PERL 1 ++#define HAVE_POD2MAN 1 ++#define HAVE_TEXI2HTML 0 ++#define CONFIG_DOC 0 ++#define CONFIG_HTMLPAGES 0 ++#define CONFIG_MANPAGES 0 ++#define CONFIG_PODPAGES 0 ++#define CONFIG_TXTPAGES 0 ++#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 ++#define CONFIG_AVIO_READING_EXAMPLE 1 ++#define CONFIG_DECODE_AUDIO_EXAMPLE 1 ++#define CONFIG_DECODE_VIDEO_EXAMPLE 1 ++#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 ++#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 ++#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 ++#define CONFIG_EXTRACT_MVS_EXAMPLE 1 ++#define CONFIG_FILTER_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 ++#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 ++#define CONFIG_HW_DECODE_EXAMPLE 1 ++#define CONFIG_METADATA_EXAMPLE 1 ++#define CONFIG_MUXING_EXAMPLE 0 ++#define CONFIG_QSVDEC_EXAMPLE 0 ++#define CONFIG_REMUXING_EXAMPLE 1 ++#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 ++#define CONFIG_SCALING_VIDEO_EXAMPLE 0 ++#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 ++#define CONFIG_TRANSCODING_EXAMPLE 0 ++#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 ++#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 ++#define CONFIG_AVISYNTH 0 ++#define CONFIG_FREI0R 0 ++#define CONFIG_LIBCDIO 0 ++#define CONFIG_LIBDAVS2 0 ++#define CONFIG_LIBRUBBERBAND 0 ++#define CONFIG_LIBVIDSTAB 0 ++#define CONFIG_LIBX264 0 ++#define CONFIG_LIBX265 0 ++#define CONFIG_LIBXAVS 0 ++#define CONFIG_LIBXAVS2 0 ++#define CONFIG_LIBXVID 0 ++#define CONFIG_DECKLINK 0 ++#define CONFIG_LIBFDK_AAC 0 ++#define CONFIG_OPENSSL 0 ++#define CONFIG_LIBTLS 0 ++#define CONFIG_GMP 0 ++#define CONFIG_LIBARIBB24 0 ++#define CONFIG_LIBLENSFUN 0 ++#define CONFIG_LIBOPENCORE_AMRNB 0 ++#define CONFIG_LIBOPENCORE_AMRWB 0 ++#define CONFIG_LIBVO_AMRWBENC 0 ++#define CONFIG_MBEDTLS 0 ++#define CONFIG_RKMPP 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_CHROMAPRINT 0 ++#define CONFIG_GCRYPT 0 ++#define CONFIG_GNUTLS 0 ++#define CONFIG_JNI 0 ++#define CONFIG_LADSPA 0 ++#define CONFIG_LIBAOM 0 ++#define CONFIG_LIBASS 0 ++#define CONFIG_LIBBLURAY 0 ++#define CONFIG_LIBBS2B 0 ++#define CONFIG_LIBCACA 0 ++#define CONFIG_LIBCELT 0 ++#define CONFIG_LIBCODEC2 0 ++#define CONFIG_LIBDAV1D 0 ++#define CONFIG_LIBDC1394 0 ++#define CONFIG_LIBDRM 0 ++#define CONFIG_LIBFLITE 0 ++#define CONFIG_LIBFONTCONFIG 0 ++#define CONFIG_LIBFREETYPE 0 ++#define CONFIG_LIBFRIBIDI 0 ++#define CONFIG_LIBGLSLANG 0 ++#define CONFIG_LIBGME 0 ++#define CONFIG_LIBGSM 0 ++#define CONFIG_LIBIEC61883 0 ++#define CONFIG_LIBILBC 0 ++#define CONFIG_LIBJACK 0 ++#define CONFIG_LIBKLVANC 0 ++#define CONFIG_LIBKVAZAAR 0 ++#define CONFIG_LIBMODPLUG 0 ++#define CONFIG_LIBMP3LAME 0 ++#define CONFIG_LIBMYSOFA 0 ++#define CONFIG_LIBOPENCV 0 ++#define CONFIG_LIBOPENH264 0 ++#define CONFIG_LIBOPENJPEG 0 ++#define CONFIG_LIBOPENMPT 0 ++#define CONFIG_LIBOPENVINO 0 ++#define CONFIG_LIBOPUS 1 ++#define CONFIG_LIBPULSE 0 ++#define CONFIG_LIBRABBITMQ 0 ++#define CONFIG_LIBRAV1E 0 ++#define CONFIG_LIBRSVG 0 ++#define CONFIG_LIBRTMP 0 ++#define CONFIG_LIBSHINE 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_LIBSNAPPY 0 ++#define CONFIG_LIBSOXR 0 ++#define CONFIG_LIBSPEEX 0 ++#define CONFIG_LIBSRT 0 ++#define CONFIG_LIBSSH 0 ++#define CONFIG_LIBSVTAV1 0 ++#define CONFIG_LIBTENSORFLOW 0 ++#define CONFIG_LIBTESSERACT 0 ++#define CONFIG_LIBTHEORA 0 ++#define CONFIG_LIBTWOLAME 0 ++#define CONFIG_LIBV4L2 0 ++#define CONFIG_LIBVMAF 0 ++#define CONFIG_LIBVORBIS 0 ++#define CONFIG_LIBVPX 0 ++#define CONFIG_LIBWAVPACK 0 ++#define CONFIG_LIBWEBP 0 ++#define CONFIG_LIBXML2 0 ++#define CONFIG_LIBZIMG 0 ++#define CONFIG_LIBZMQ 0 ++#define CONFIG_LIBZVBI 0 ++#define CONFIG_LV2 0 ++#define CONFIG_MEDIACODEC 0 ++#define CONFIG_OPENAL 0 ++#define CONFIG_OPENGL 0 ++#define CONFIG_POCKETSPHINX 0 ++#define CONFIG_VAPOURSYNTH 0 ++#define CONFIG_ALSA 0 ++#define CONFIG_APPKIT 0 ++#define CONFIG_AVFOUNDATION 0 ++#define CONFIG_BZLIB 0 ++#define CONFIG_COREIMAGE 0 ++#define CONFIG_ICONV 0 ++#define CONFIG_LIBXCB 0 ++#define CONFIG_LIBXCB_SHM 0 ++#define CONFIG_LIBXCB_SHAPE 0 ++#define CONFIG_LIBXCB_XFIXES 0 ++#define CONFIG_LZMA 0 ++#define CONFIG_MEDIAFOUNDATION 0 ++#define CONFIG_SCHANNEL 0 ++#define CONFIG_SDL2 0 ++#define CONFIG_SECURETRANSPORT 0 ++#define CONFIG_SNDIO 0 ++#define CONFIG_XLIB 0 ++#define CONFIG_ZLIB 0 ++#define CONFIG_CUDA_NVCC 0 ++#define CONFIG_CUDA_SDK 0 ++#define CONFIG_LIBNPP 0 ++#define CONFIG_LIBMFX 0 ++#define CONFIG_MMAL 0 ++#define CONFIG_OMX 0 ++#define CONFIG_OPENCL 0 ++#define CONFIG_VULKAN 0 ++#define CONFIG_AMF 0 ++#define CONFIG_AUDIOTOOLBOX 0 ++#define CONFIG_CRYSTALHD 0 ++#define CONFIG_CUDA 0 ++#define CONFIG_CUDA_LLVM 0 ++#define CONFIG_CUVID 0 ++#define CONFIG_D3D11VA 0 ++#define CONFIG_DXVA2 0 ++#define CONFIG_FFNVCODEC 0 ++#define CONFIG_NVDEC 0 ++#define CONFIG_NVENC 0 ++#define CONFIG_VAAPI 0 ++#define CONFIG_VDPAU 0 ++#define CONFIG_VIDEOTOOLBOX 0 ++#define CONFIG_V4L2_M2M 0 ++#define CONFIG_XVMC 0 ++#define CONFIG_FTRAPV 0 ++#define CONFIG_GRAY 0 ++#define CONFIG_HARDCODED_TABLES 0 ++#define CONFIG_OMX_RPI 0 ++#define CONFIG_RUNTIME_CPUDETECT 1 ++#define CONFIG_SAFE_BITSTREAM_READER 1 ++#define CONFIG_SHARED 0 ++#define CONFIG_SMALL 0 ++#define CONFIG_STATIC 1 ++#define CONFIG_SWSCALE_ALPHA 1 ++#define CONFIG_GPL 0 ++#define CONFIG_NONFREE 0 ++#define CONFIG_VERSION3 0 ++#define CONFIG_AVDEVICE 0 ++#define CONFIG_AVFILTER 0 ++#define CONFIG_SWSCALE 0 ++#define CONFIG_POSTPROC 0 ++#define CONFIG_AVFORMAT 1 ++#define CONFIG_AVCODEC 1 ++#define CONFIG_SWRESAMPLE 0 ++#define CONFIG_AVRESAMPLE 0 ++#define CONFIG_AVUTIL 1 ++#define CONFIG_FFPLAY 0 ++#define CONFIG_FFPROBE 0 ++#define CONFIG_FFMPEG 0 ++#define CONFIG_DCT 1 ++#define CONFIG_DWT 0 ++#define CONFIG_ERROR_RESILIENCE 1 ++#define CONFIG_FAAN 0 ++#define CONFIG_FAST_UNALIGNED 0 ++#define CONFIG_FFT 1 ++#define CONFIG_LSP 1 ++#define CONFIG_LZO 0 ++#define CONFIG_MDCT 1 ++#define CONFIG_PIXELUTILS 0 ++#define CONFIG_NETWORK 0 ++#define CONFIG_RDFT 1 ++#define CONFIG_AUTODETECT 0 ++#define CONFIG_FONTCONFIG 0 ++#define CONFIG_LARGE_TESTS 1 ++#define CONFIG_LINUX_PERF 0 ++#define CONFIG_MEMORY_POISONING 0 ++#define CONFIG_NEON_CLOBBER_TEST 0 ++#define CONFIG_OSSFUZZ 0 ++#define CONFIG_PIC 1 ++#define CONFIG_THUMB 0 ++#define CONFIG_VALGRIND_BACKTRACE 0 ++#define CONFIG_XMM_CLOBBER_TEST 0 ++#define CONFIG_BSFS 1 ++#define CONFIG_DECODERS 1 ++#define CONFIG_ENCODERS 0 ++#define CONFIG_HWACCELS 0 ++#define CONFIG_PARSERS 1 ++#define CONFIG_INDEVS 0 ++#define CONFIG_OUTDEVS 0 ++#define CONFIG_FILTERS 0 ++#define CONFIG_DEMUXERS 1 ++#define CONFIG_MUXERS 0 ++#define CONFIG_PROTOCOLS 0 ++#define CONFIG_AANDCTTABLES 0 ++#define CONFIG_AC3DSP 0 ++#define CONFIG_ADTS_HEADER 1 ++#define CONFIG_ATSC_A53 1 ++#define CONFIG_AUDIO_FRAME_QUEUE 0 ++#define CONFIG_AUDIODSP 0 ++#define CONFIG_BLOCKDSP 1 ++#define CONFIG_BSWAPDSP 0 ++#define CONFIG_CABAC 1 ++#define CONFIG_CBS 0 ++#define CONFIG_CBS_AV1 0 ++#define CONFIG_CBS_H264 0 ++#define CONFIG_CBS_H265 0 ++#define CONFIG_CBS_JPEG 0 ++#define CONFIG_CBS_MPEG2 0 ++#define CONFIG_CBS_VP9 0 ++#define CONFIG_DIRAC_PARSE 1 ++#define CONFIG_DNN 0 ++#define CONFIG_DVPROFILE 0 ++#define CONFIG_EXIF 1 ++#define CONFIG_FAANDCT 0 ++#define CONFIG_FAANIDCT 0 ++#define CONFIG_FDCTDSP 1 ++#define CONFIG_FLACDSP 1 ++#define CONFIG_FMTCONVERT 0 ++#define CONFIG_FRAME_THREAD_ENCODER 0 ++#define CONFIG_G722DSP 0 ++#define CONFIG_GOLOMB 1 ++#define CONFIG_GPLV3 0 ++#define CONFIG_H263DSP 1 ++#define CONFIG_H264CHROMA 1 ++#define CONFIG_H264DSP 1 ++#define CONFIG_H264PARSE 1 ++#define CONFIG_H264PRED 1 ++#define CONFIG_H264QPEL 1 ++#define CONFIG_HEVCPARSE 0 ++#define CONFIG_HPELDSP 1 ++#define CONFIG_HUFFMAN 0 ++#define CONFIG_HUFFYUVDSP 0 ++#define CONFIG_HUFFYUVENCDSP 0 ++#define CONFIG_IDCTDSP 1 ++#define CONFIG_IIRFILTER 0 ++#define CONFIG_MDCT15 1 ++#define CONFIG_INTRAX8 0 ++#define CONFIG_ISO_MEDIA 1 ++#define CONFIG_IVIDSP 0 ++#define CONFIG_JPEGTABLES 0 ++#define CONFIG_LGPLV3 0 ++#define CONFIG_LIBX262 0 ++#define CONFIG_LLAUDDSP 0 ++#define CONFIG_LLVIDDSP 0 ++#define CONFIG_LLVIDENCDSP 0 ++#define CONFIG_LPC 0 ++#define CONFIG_LZF 0 ++#define CONFIG_ME_CMP 1 ++#define CONFIG_MPEG_ER 1 ++#define CONFIG_MPEGAUDIO 1 ++#define CONFIG_MPEGAUDIODSP 1 ++#define CONFIG_MPEGAUDIOHEADER 1 ++#define CONFIG_MPEGVIDEO 1 ++#define CONFIG_MPEGVIDEOENC 0 ++#define CONFIG_MSS34DSP 0 ++#define CONFIG_PIXBLOCKDSP 1 ++#define CONFIG_QPELDSP 1 ++#define CONFIG_QSV 0 ++#define CONFIG_QSVDEC 0 ++#define CONFIG_QSVENC 0 ++#define CONFIG_QSVVPP 0 ++#define CONFIG_RANGECODER 0 ++#define CONFIG_RIFFDEC 1 ++#define CONFIG_RIFFENC 0 ++#define CONFIG_RTPDEC 0 ++#define CONFIG_RTPENC_CHAIN 0 ++#define CONFIG_RV34DSP 0 ++#define CONFIG_SCENE_SAD 0 ++#define CONFIG_SINEWIN 1 ++#define CONFIG_SNAPPY 0 ++#define CONFIG_SRTP 0 ++#define CONFIG_STARTCODE 1 ++#define CONFIG_TEXTUREDSP 0 ++#define CONFIG_TEXTUREDSPENC 0 ++#define CONFIG_TPELDSP 0 ++#define CONFIG_VAAPI_1 0 ++#define CONFIG_VAAPI_ENCODE 0 ++#define CONFIG_VC1DSP 0 ++#define CONFIG_VIDEODSP 1 ++#define CONFIG_VP3DSP 1 ++#define CONFIG_VP56DSP 0 ++#define CONFIG_VP8DSP 1 ++#define CONFIG_WMA_FREQS 0 ++#define CONFIG_WMV2DSP 0 ++#define CONFIG_AAC_ADTSTOASC_BSF 0 ++#define CONFIG_AV1_FRAME_MERGE_BSF 0 ++#define CONFIG_AV1_FRAME_SPLIT_BSF 0 ++#define CONFIG_AV1_METADATA_BSF 0 ++#define CONFIG_CHOMP_BSF 0 ++#define CONFIG_DUMP_EXTRADATA_BSF 0 ++#define CONFIG_DCA_CORE_BSF 0 ++#define CONFIG_EAC3_CORE_BSF 0 ++#define CONFIG_EXTRACT_EXTRADATA_BSF 0 ++#define CONFIG_FILTER_UNITS_BSF 0 ++#define CONFIG_H264_METADATA_BSF 0 ++#define CONFIG_H264_MP4TOANNEXB_BSF 0 ++#define CONFIG_H264_REDUNDANT_PPS_BSF 0 ++#define CONFIG_HAPQA_EXTRACT_BSF 0 ++#define CONFIG_HEVC_METADATA_BSF 0 ++#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 ++#define CONFIG_IMX_DUMP_HEADER_BSF 0 ++#define CONFIG_MJPEG2JPEG_BSF 0 ++#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 ++#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 ++#define CONFIG_MPEG2_METADATA_BSF 0 ++#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 ++#define CONFIG_MOV2TEXTSUB_BSF 0 ++#define CONFIG_NOISE_BSF 0 ++#define CONFIG_NULL_BSF 1 ++#define CONFIG_OPUS_METADATA_BSF 0 ++#define CONFIG_PCM_RECHUNK_BSF 0 ++#define CONFIG_PRORES_METADATA_BSF 0 ++#define CONFIG_REMOVE_EXTRADATA_BSF 0 ++#define CONFIG_TEXT2MOVSUB_BSF 0 ++#define CONFIG_TRACE_HEADERS_BSF 0 ++#define CONFIG_TRUEHD_CORE_BSF 0 ++#define CONFIG_VP9_METADATA_BSF 0 ++#define CONFIG_VP9_RAW_REORDER_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 ++#define CONFIG_AASC_DECODER 0 ++#define CONFIG_AIC_DECODER 0 ++#define CONFIG_ALIAS_PIX_DECODER 0 ++#define CONFIG_AGM_DECODER 0 ++#define CONFIG_AMV_DECODER 0 ++#define CONFIG_ANM_DECODER 0 ++#define CONFIG_ANSI_DECODER 0 ++#define CONFIG_APNG_DECODER 0 ++#define CONFIG_ARBC_DECODER 0 ++#define CONFIG_ASV1_DECODER 0 ++#define CONFIG_ASV2_DECODER 0 ++#define CONFIG_AURA_DECODER 0 ++#define CONFIG_AURA2_DECODER 0 ++#define CONFIG_AVRP_DECODER 0 ++#define CONFIG_AVRN_DECODER 0 ++#define CONFIG_AVS_DECODER 0 ++#define CONFIG_AVUI_DECODER 0 ++#define CONFIG_AYUV_DECODER 0 ++#define CONFIG_BETHSOFTVID_DECODER 0 ++#define CONFIG_BFI_DECODER 0 ++#define CONFIG_BINK_DECODER 0 ++#define CONFIG_BITPACKED_DECODER 0 ++#define CONFIG_BMP_DECODER 0 ++#define CONFIG_BMV_VIDEO_DECODER 0 ++#define CONFIG_BRENDER_PIX_DECODER 0 ++#define CONFIG_C93_DECODER 0 ++#define CONFIG_CAVS_DECODER 0 ++#define CONFIG_CDGRAPHICS_DECODER 0 ++#define CONFIG_CDTOONS_DECODER 0 ++#define CONFIG_CDXL_DECODER 0 ++#define CONFIG_CFHD_DECODER 0 ++#define CONFIG_CINEPAK_DECODER 0 ++#define CONFIG_CLEARVIDEO_DECODER 0 ++#define CONFIG_CLJR_DECODER 0 ++#define CONFIG_CLLC_DECODER 0 ++#define CONFIG_COMFORTNOISE_DECODER 0 ++#define CONFIG_CPIA_DECODER 0 ++#define CONFIG_CSCD_DECODER 0 ++#define CONFIG_CYUV_DECODER 0 ++#define CONFIG_DDS_DECODER 0 ++#define CONFIG_DFA_DECODER 0 ++#define CONFIG_DIRAC_DECODER 0 ++#define CONFIG_DNXHD_DECODER 0 ++#define CONFIG_DPX_DECODER 0 ++#define CONFIG_DSICINVIDEO_DECODER 0 ++#define CONFIG_DVAUDIO_DECODER 0 ++#define CONFIG_DVVIDEO_DECODER 0 ++#define CONFIG_DXA_DECODER 0 ++#define CONFIG_DXTORY_DECODER 0 ++#define CONFIG_DXV_DECODER 0 ++#define CONFIG_EACMV_DECODER 0 ++#define CONFIG_EAMAD_DECODER 0 ++#define CONFIG_EATGQ_DECODER 0 ++#define CONFIG_EATGV_DECODER 0 ++#define CONFIG_EATQI_DECODER 0 ++#define CONFIG_EIGHTBPS_DECODER 0 ++#define CONFIG_EIGHTSVX_EXP_DECODER 0 ++#define CONFIG_EIGHTSVX_FIB_DECODER 0 ++#define CONFIG_ESCAPE124_DECODER 0 ++#define CONFIG_ESCAPE130_DECODER 0 ++#define CONFIG_EXR_DECODER 0 ++#define CONFIG_FFV1_DECODER 0 ++#define CONFIG_FFVHUFF_DECODER 0 ++#define CONFIG_FIC_DECODER 0 ++#define CONFIG_FITS_DECODER 0 ++#define CONFIG_FLASHSV_DECODER 0 ++#define CONFIG_FLASHSV2_DECODER 0 ++#define CONFIG_FLIC_DECODER 0 ++#define CONFIG_FLV_DECODER 0 ++#define CONFIG_FMVC_DECODER 0 ++#define CONFIG_FOURXM_DECODER 0 ++#define CONFIG_FRAPS_DECODER 0 ++#define CONFIG_FRWU_DECODER 0 ++#define CONFIG_G2M_DECODER 0 ++#define CONFIG_GDV_DECODER 0 ++#define CONFIG_GIF_DECODER 0 ++#define CONFIG_H261_DECODER 0 ++#define CONFIG_H263_DECODER 1 ++#define CONFIG_H263I_DECODER 0 ++#define CONFIG_H263P_DECODER 0 ++#define CONFIG_H263_V4L2M2M_DECODER 0 ++#define CONFIG_H264_DECODER 1 ++#define CONFIG_H264_CRYSTALHD_DECODER 0 ++#define CONFIG_H264_V4L2M2M_DECODER 0 ++#define CONFIG_H264_MEDIACODEC_DECODER 0 ++#define CONFIG_H264_MMAL_DECODER 0 ++#define CONFIG_H264_QSV_DECODER 0 ++#define CONFIG_H264_RKMPP_DECODER 0 ++#define CONFIG_HAP_DECODER 0 ++#define CONFIG_HEVC_DECODER 0 ++#define CONFIG_HEVC_QSV_DECODER 0 ++#define CONFIG_HEVC_RKMPP_DECODER 0 ++#define CONFIG_HEVC_V4L2M2M_DECODER 0 ++#define CONFIG_HNM4_VIDEO_DECODER 0 ++#define CONFIG_HQ_HQA_DECODER 0 ++#define CONFIG_HQX_DECODER 0 ++#define CONFIG_HUFFYUV_DECODER 0 ++#define CONFIG_HYMT_DECODER 0 ++#define CONFIG_IDCIN_DECODER 0 ++#define CONFIG_IFF_ILBM_DECODER 0 ++#define CONFIG_IMM4_DECODER 0 ++#define CONFIG_IMM5_DECODER 0 ++#define CONFIG_INDEO2_DECODER 0 ++#define CONFIG_INDEO3_DECODER 0 ++#define CONFIG_INDEO4_DECODER 0 ++#define CONFIG_INDEO5_DECODER 0 ++#define CONFIG_INTERPLAY_VIDEO_DECODER 0 ++#define CONFIG_JPEG2000_DECODER 0 ++#define CONFIG_JPEGLS_DECODER 0 ++#define CONFIG_JV_DECODER 0 ++#define CONFIG_KGV1_DECODER 0 ++#define CONFIG_KMVC_DECODER 0 ++#define CONFIG_LAGARITH_DECODER 0 ++#define CONFIG_LOCO_DECODER 0 ++#define CONFIG_LSCR_DECODER 0 ++#define CONFIG_M101_DECODER 0 ++#define CONFIG_MAGICYUV_DECODER 0 ++#define CONFIG_MDEC_DECODER 0 ++#define CONFIG_MIMIC_DECODER 0 ++#define CONFIG_MJPEG_DECODER 0 ++#define CONFIG_MJPEGB_DECODER 0 ++#define CONFIG_MMVIDEO_DECODER 0 ++#define CONFIG_MOTIONPIXELS_DECODER 0 ++#define CONFIG_MPEG1VIDEO_DECODER 0 ++#define CONFIG_MPEG2VIDEO_DECODER 0 ++#define CONFIG_MPEG4_DECODER 1 ++#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG4_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG4_MMAL_DECODER 0 ++#define CONFIG_MPEGVIDEO_DECODER 0 ++#define CONFIG_MPEG1_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_MMAL_DECODER 0 ++#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG2_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_QSV_DECODER 0 ++#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 ++#define CONFIG_MSA1_DECODER 0 ++#define CONFIG_MSCC_DECODER 0 ++#define CONFIG_MSMPEG4V1_DECODER 0 ++#define CONFIG_MSMPEG4V2_DECODER 0 ++#define CONFIG_MSMPEG4V3_DECODER 0 ++#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MSRLE_DECODER 0 ++#define CONFIG_MSS1_DECODER 0 ++#define CONFIG_MSS2_DECODER 0 ++#define CONFIG_MSVIDEO1_DECODER 0 ++#define CONFIG_MSZH_DECODER 0 ++#define CONFIG_MTS2_DECODER 0 ++#define CONFIG_MV30_DECODER 0 ++#define CONFIG_MVC1_DECODER 0 ++#define CONFIG_MVC2_DECODER 0 ++#define CONFIG_MVDV_DECODER 0 ++#define CONFIG_MVHA_DECODER 0 ++#define CONFIG_MWSC_DECODER 0 ++#define CONFIG_MXPEG_DECODER 0 ++#define CONFIG_NOTCHLC_DECODER 0 ++#define CONFIG_NUV_DECODER 0 ++#define CONFIG_PAF_VIDEO_DECODER 0 ++#define CONFIG_PAM_DECODER 0 ++#define CONFIG_PBM_DECODER 0 ++#define CONFIG_PCX_DECODER 0 ++#define CONFIG_PFM_DECODER 0 ++#define CONFIG_PGM_DECODER 0 ++#define CONFIG_PGMYUV_DECODER 0 ++#define CONFIG_PGX_DECODER 0 ++#define CONFIG_PICTOR_DECODER 0 ++#define CONFIG_PIXLET_DECODER 0 ++#define CONFIG_PNG_DECODER 0 ++#define CONFIG_PPM_DECODER 0 ++#define CONFIG_PRORES_DECODER 0 ++#define CONFIG_PROSUMER_DECODER 0 ++#define CONFIG_PSD_DECODER 0 ++#define CONFIG_PTX_DECODER 0 ++#define CONFIG_QDRAW_DECODER 0 ++#define CONFIG_QPEG_DECODER 0 ++#define CONFIG_QTRLE_DECODER 0 ++#define CONFIG_R10K_DECODER 0 ++#define CONFIG_R210_DECODER 0 ++#define CONFIG_RASC_DECODER 0 ++#define CONFIG_RAWVIDEO_DECODER 0 ++#define CONFIG_RL2_DECODER 0 ++#define CONFIG_ROQ_DECODER 0 ++#define CONFIG_RPZA_DECODER 0 ++#define CONFIG_RSCC_DECODER 0 ++#define CONFIG_RV10_DECODER 0 ++#define CONFIG_RV20_DECODER 0 ++#define CONFIG_RV30_DECODER 0 ++#define CONFIG_RV40_DECODER 0 ++#define CONFIG_S302M_DECODER 0 ++#define CONFIG_SANM_DECODER 0 ++#define CONFIG_SCPR_DECODER 0 ++#define CONFIG_SCREENPRESSO_DECODER 0 ++#define CONFIG_SGI_DECODER 0 ++#define CONFIG_SGIRLE_DECODER 0 ++#define CONFIG_SHEERVIDEO_DECODER 0 ++#define CONFIG_SMACKER_DECODER 0 ++#define CONFIG_SMC_DECODER 0 ++#define CONFIG_SMVJPEG_DECODER 0 ++#define CONFIG_SNOW_DECODER 0 ++#define CONFIG_SP5X_DECODER 0 ++#define CONFIG_SPEEDHQ_DECODER 0 ++#define CONFIG_SRGC_DECODER 0 ++#define CONFIG_SUNRAST_DECODER 0 ++#define CONFIG_SVQ1_DECODER 0 ++#define CONFIG_SVQ3_DECODER 0 ++#define CONFIG_TARGA_DECODER 0 ++#define CONFIG_TARGA_Y216_DECODER 0 ++#define CONFIG_TDSC_DECODER 0 ++#define CONFIG_THEORA_DECODER 1 ++#define CONFIG_THP_DECODER 0 ++#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 ++#define CONFIG_TIFF_DECODER 0 ++#define CONFIG_TMV_DECODER 0 ++#define CONFIG_TRUEMOTION1_DECODER 0 ++#define CONFIG_TRUEMOTION2_DECODER 0 ++#define CONFIG_TRUEMOTION2RT_DECODER 0 ++#define CONFIG_TSCC_DECODER 0 ++#define CONFIG_TSCC2_DECODER 0 ++#define CONFIG_TXD_DECODER 0 ++#define CONFIG_ULTI_DECODER 0 ++#define CONFIG_UTVIDEO_DECODER 0 ++#define CONFIG_V210_DECODER 0 ++#define CONFIG_V210X_DECODER 0 ++#define CONFIG_V308_DECODER 0 ++#define CONFIG_V408_DECODER 0 ++#define CONFIG_V410_DECODER 0 ++#define CONFIG_VB_DECODER 0 ++#define CONFIG_VBLE_DECODER 0 ++#define CONFIG_VC1_DECODER 0 ++#define CONFIG_VC1_CRYSTALHD_DECODER 0 ++#define CONFIG_VC1IMAGE_DECODER 0 ++#define CONFIG_VC1_MMAL_DECODER 0 ++#define CONFIG_VC1_QSV_DECODER 0 ++#define CONFIG_VC1_V4L2M2M_DECODER 0 ++#define CONFIG_VCR1_DECODER 0 ++#define CONFIG_VMDVIDEO_DECODER 0 ++#define CONFIG_VMNC_DECODER 0 ++#define CONFIG_VP3_DECODER 1 ++#define CONFIG_VP4_DECODER 0 ++#define CONFIG_VP5_DECODER 0 ++#define CONFIG_VP6_DECODER 0 ++#define CONFIG_VP6A_DECODER 0 ++#define CONFIG_VP6F_DECODER 0 ++#define CONFIG_VP7_DECODER 0 ++#define CONFIG_VP8_DECODER 1 ++#define CONFIG_VP8_RKMPP_DECODER 0 ++#define CONFIG_VP8_V4L2M2M_DECODER 0 ++#define CONFIG_VP9_DECODER 0 ++#define CONFIG_VP9_RKMPP_DECODER 0 ++#define CONFIG_VP9_V4L2M2M_DECODER 0 ++#define CONFIG_VQA_DECODER 0 ++#define CONFIG_WEBP_DECODER 0 ++#define CONFIG_WCMV_DECODER 0 ++#define CONFIG_WRAPPED_AVFRAME_DECODER 0 ++#define CONFIG_WMV1_DECODER 0 ++#define CONFIG_WMV2_DECODER 0 ++#define CONFIG_WMV3_DECODER 0 ++#define CONFIG_WMV3_CRYSTALHD_DECODER 0 ++#define CONFIG_WMV3IMAGE_DECODER 0 ++#define CONFIG_WNV1_DECODER 0 ++#define CONFIG_XAN_WC3_DECODER 0 ++#define CONFIG_XAN_WC4_DECODER 0 ++#define CONFIG_XBM_DECODER 0 ++#define CONFIG_XFACE_DECODER 0 ++#define CONFIG_XL_DECODER 0 ++#define CONFIG_XPM_DECODER 0 ++#define CONFIG_XWD_DECODER 0 ++#define CONFIG_Y41P_DECODER 0 ++#define CONFIG_YLC_DECODER 0 ++#define CONFIG_YOP_DECODER 0 ++#define CONFIG_YUV4_DECODER 0 ++#define CONFIG_ZERO12V_DECODER 0 ++#define CONFIG_ZEROCODEC_DECODER 0 ++#define CONFIG_ZLIB_DECODER 0 ++#define CONFIG_ZMBV_DECODER 0 ++#define CONFIG_AAC_DECODER 1 ++#define CONFIG_AAC_FIXED_DECODER 0 ++#define CONFIG_AAC_LATM_DECODER 0 ++#define CONFIG_AC3_DECODER 0 ++#define CONFIG_AC3_FIXED_DECODER 0 ++#define CONFIG_ACELP_KELVIN_DECODER 0 ++#define CONFIG_ALAC_DECODER 0 ++#define CONFIG_ALS_DECODER 0 ++#define CONFIG_AMRNB_DECODER 1 ++#define CONFIG_AMRWB_DECODER 1 ++#define CONFIG_APE_DECODER 0 ++#define CONFIG_APTX_DECODER 0 ++#define CONFIG_APTX_HD_DECODER 0 ++#define CONFIG_ATRAC1_DECODER 0 ++#define CONFIG_ATRAC3_DECODER 0 ++#define CONFIG_ATRAC3AL_DECODER 0 ++#define CONFIG_ATRAC3P_DECODER 0 ++#define CONFIG_ATRAC3PAL_DECODER 0 ++#define CONFIG_ATRAC9_DECODER 0 ++#define CONFIG_BINKAUDIO_DCT_DECODER 0 ++#define CONFIG_BINKAUDIO_RDFT_DECODER 0 ++#define CONFIG_BMV_AUDIO_DECODER 0 ++#define CONFIG_COOK_DECODER 0 ++#define CONFIG_DCA_DECODER 0 ++#define CONFIG_DOLBY_E_DECODER 0 ++#define CONFIG_DSD_LSBF_DECODER 0 ++#define CONFIG_DSD_MSBF_DECODER 0 ++#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 ++#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 ++#define CONFIG_DSICINAUDIO_DECODER 0 ++#define CONFIG_DSS_SP_DECODER 0 ++#define CONFIG_DST_DECODER 0 ++#define CONFIG_EAC3_DECODER 0 ++#define CONFIG_EVRC_DECODER 0 ++#define CONFIG_FFWAVESYNTH_DECODER 0 ++#define CONFIG_FLAC_DECODER 1 ++#define CONFIG_G723_1_DECODER 0 ++#define CONFIG_G729_DECODER 0 ++#define CONFIG_GSM_DECODER 0 ++#define CONFIG_GSM_MS_DECODER 1 ++#define CONFIG_HCA_DECODER 0 ++#define CONFIG_HCOM_DECODER 0 ++#define CONFIG_IAC_DECODER 0 ++#define CONFIG_ILBC_DECODER 0 ++#define CONFIG_IMC_DECODER 0 ++#define CONFIG_INTERPLAY_ACM_DECODER 0 ++#define CONFIG_MACE3_DECODER 0 ++#define CONFIG_MACE6_DECODER 0 ++#define CONFIG_METASOUND_DECODER 0 ++#define CONFIG_MLP_DECODER 0 ++#define CONFIG_MP1_DECODER 0 ++#define CONFIG_MP1FLOAT_DECODER 0 ++#define CONFIG_MP2_DECODER 0 ++#define CONFIG_MP2FLOAT_DECODER 0 ++#define CONFIG_MP3FLOAT_DECODER 0 ++#define CONFIG_MP3_DECODER 1 ++#define CONFIG_MP3ADUFLOAT_DECODER 0 ++#define CONFIG_MP3ADU_DECODER 0 ++#define CONFIG_MP3ON4FLOAT_DECODER 0 ++#define CONFIG_MP3ON4_DECODER 0 ++#define CONFIG_MPC7_DECODER 0 ++#define CONFIG_MPC8_DECODER 0 ++#define CONFIG_NELLYMOSER_DECODER 0 ++#define CONFIG_ON2AVC_DECODER 0 ++#define CONFIG_OPUS_DECODER 0 ++#define CONFIG_PAF_AUDIO_DECODER 0 ++#define CONFIG_QCELP_DECODER 0 ++#define CONFIG_QDM2_DECODER 0 ++#define CONFIG_QDMC_DECODER 0 ++#define CONFIG_RA_144_DECODER 0 ++#define CONFIG_RA_288_DECODER 0 ++#define CONFIG_RALF_DECODER 0 ++#define CONFIG_SBC_DECODER 0 ++#define CONFIG_SHORTEN_DECODER 0 ++#define CONFIG_SIPR_DECODER 0 ++#define CONFIG_SIREN_DECODER 0 ++#define CONFIG_SMACKAUD_DECODER 0 ++#define CONFIG_SONIC_DECODER 0 ++#define CONFIG_TAK_DECODER 0 ++#define CONFIG_TRUEHD_DECODER 0 ++#define CONFIG_TRUESPEECH_DECODER 0 ++#define CONFIG_TTA_DECODER 0 ++#define CONFIG_TWINVQ_DECODER 0 ++#define CONFIG_VMDAUDIO_DECODER 0 ++#define CONFIG_VORBIS_DECODER 1 ++#define CONFIG_WAVPACK_DECODER 0 ++#define CONFIG_WMALOSSLESS_DECODER 0 ++#define CONFIG_WMAPRO_DECODER 0 ++#define CONFIG_WMAV1_DECODER 0 ++#define CONFIG_WMAV2_DECODER 0 ++#define CONFIG_WMAVOICE_DECODER 0 ++#define CONFIG_WS_SND1_DECODER 0 ++#define CONFIG_XMA1_DECODER 0 ++#define CONFIG_XMA2_DECODER 0 ++#define CONFIG_PCM_ALAW_DECODER 1 ++#define CONFIG_PCM_BLURAY_DECODER 0 ++#define CONFIG_PCM_DVD_DECODER 0 ++#define CONFIG_PCM_F16LE_DECODER 0 ++#define CONFIG_PCM_F24LE_DECODER 0 ++#define CONFIG_PCM_F32BE_DECODER 0 ++#define CONFIG_PCM_F32LE_DECODER 1 ++#define CONFIG_PCM_F64BE_DECODER 0 ++#define CONFIG_PCM_F64LE_DECODER 0 ++#define CONFIG_PCM_LXF_DECODER 0 ++#define CONFIG_PCM_MULAW_DECODER 1 ++#define CONFIG_PCM_S8_DECODER 0 ++#define CONFIG_PCM_S8_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16BE_DECODER 1 ++#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16LE_DECODER 1 ++#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S24BE_DECODER 1 ++#define CONFIG_PCM_S24DAUD_DECODER 0 ++#define CONFIG_PCM_S24LE_DECODER 1 ++#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S32BE_DECODER 0 ++#define CONFIG_PCM_S32LE_DECODER 1 ++#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S64BE_DECODER 0 ++#define CONFIG_PCM_S64LE_DECODER 0 ++#define CONFIG_PCM_U8_DECODER 1 ++#define CONFIG_PCM_U16BE_DECODER 0 ++#define CONFIG_PCM_U16LE_DECODER 0 ++#define CONFIG_PCM_U24BE_DECODER 0 ++#define CONFIG_PCM_U24LE_DECODER 0 ++#define CONFIG_PCM_U32BE_DECODER 0 ++#define CONFIG_PCM_U32LE_DECODER 0 ++#define CONFIG_PCM_VIDC_DECODER 0 ++#define CONFIG_DERF_DPCM_DECODER 0 ++#define CONFIG_GREMLIN_DPCM_DECODER 0 ++#define CONFIG_INTERPLAY_DPCM_DECODER 0 ++#define CONFIG_ROQ_DPCM_DECODER 0 ++#define CONFIG_SDX2_DPCM_DECODER 0 ++#define CONFIG_SOL_DPCM_DECODER 0 ++#define CONFIG_XAN_DPCM_DECODER 0 ++#define CONFIG_ADPCM_4XM_DECODER 0 ++#define CONFIG_ADPCM_ADX_DECODER 0 ++#define CONFIG_ADPCM_AFC_DECODER 0 ++#define CONFIG_ADPCM_AGM_DECODER 0 ++#define CONFIG_ADPCM_AICA_DECODER 0 ++#define CONFIG_ADPCM_ARGO_DECODER 0 ++#define CONFIG_ADPCM_CT_DECODER 0 ++#define CONFIG_ADPCM_DTK_DECODER 0 ++#define CONFIG_ADPCM_EA_DECODER 0 ++#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 ++#define CONFIG_ADPCM_EA_R1_DECODER 0 ++#define CONFIG_ADPCM_EA_R2_DECODER 0 ++#define CONFIG_ADPCM_EA_R3_DECODER 0 ++#define CONFIG_ADPCM_EA_XAS_DECODER 0 ++#define CONFIG_ADPCM_G722_DECODER 0 ++#define CONFIG_ADPCM_G726_DECODER 0 ++#define CONFIG_ADPCM_G726LE_DECODER 0 ++#define CONFIG_ADPCM_IMA_AMV_DECODER 0 ++#define CONFIG_ADPCM_IMA_ALP_DECODER 0 ++#define CONFIG_ADPCM_IMA_APC_DECODER 0 ++#define CONFIG_ADPCM_IMA_APM_DECODER 0 ++#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 ++#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK3_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK4_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_ISS_DECODER 0 ++#define CONFIG_ADPCM_IMA_MTF_DECODER 0 ++#define CONFIG_ADPCM_IMA_OKI_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_DECODER 0 ++#define CONFIG_ADPCM_IMA_RAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_SSI_DECODER 0 ++#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 ++#define CONFIG_ADPCM_IMA_WAV_DECODER 0 ++#define CONFIG_ADPCM_IMA_WS_DECODER 0 ++#define CONFIG_ADPCM_MS_DECODER 0 ++#define CONFIG_ADPCM_MTAF_DECODER 0 ++#define CONFIG_ADPCM_PSX_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_2_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_3_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_4_DECODER 0 ++#define CONFIG_ADPCM_SWF_DECODER 0 ++#define CONFIG_ADPCM_THP_DECODER 0 ++#define CONFIG_ADPCM_THP_LE_DECODER 0 ++#define CONFIG_ADPCM_VIMA_DECODER 0 ++#define CONFIG_ADPCM_XA_DECODER 0 ++#define CONFIG_ADPCM_YAMAHA_DECODER 0 ++#define CONFIG_ADPCM_ZORK_DECODER 0 ++#define CONFIG_SSA_DECODER 0 ++#define CONFIG_ASS_DECODER 0 ++#define CONFIG_CCAPTION_DECODER 0 ++#define CONFIG_DVBSUB_DECODER 0 ++#define CONFIG_DVDSUB_DECODER 0 ++#define CONFIG_JACOSUB_DECODER 0 ++#define CONFIG_MICRODVD_DECODER 0 ++#define CONFIG_MOVTEXT_DECODER 0 ++#define CONFIG_MPL2_DECODER 0 ++#define CONFIG_PGSSUB_DECODER 0 ++#define CONFIG_PJS_DECODER 0 ++#define CONFIG_REALTEXT_DECODER 0 ++#define CONFIG_SAMI_DECODER 0 ++#define CONFIG_SRT_DECODER 0 ++#define CONFIG_STL_DECODER 0 ++#define CONFIG_SUBRIP_DECODER 0 ++#define CONFIG_SUBVIEWER_DECODER 0 ++#define CONFIG_SUBVIEWER1_DECODER 0 ++#define CONFIG_TEXT_DECODER 0 ++#define CONFIG_VPLAYER_DECODER 0 ++#define CONFIG_WEBVTT_DECODER 0 ++#define CONFIG_XSUB_DECODER 0 ++#define CONFIG_AAC_AT_DECODER 0 ++#define CONFIG_AC3_AT_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 ++#define CONFIG_ALAC_AT_DECODER 0 ++#define CONFIG_AMR_NB_AT_DECODER 0 ++#define CONFIG_EAC3_AT_DECODER 0 ++#define CONFIG_GSM_MS_AT_DECODER 0 ++#define CONFIG_ILBC_AT_DECODER 0 ++#define CONFIG_MP1_AT_DECODER 0 ++#define CONFIG_MP2_AT_DECODER 0 ++#define CONFIG_MP3_AT_DECODER 0 ++#define CONFIG_PCM_ALAW_AT_DECODER 0 ++#define CONFIG_PCM_MULAW_AT_DECODER 0 ++#define CONFIG_QDMC_AT_DECODER 0 ++#define CONFIG_QDM2_AT_DECODER 0 ++#define CONFIG_LIBARIBB24_DECODER 0 ++#define CONFIG_LIBCELT_DECODER 0 ++#define CONFIG_LIBCODEC2_DECODER 0 ++#define CONFIG_LIBDAV1D_DECODER 0 ++#define CONFIG_LIBDAVS2_DECODER 0 ++#define CONFIG_LIBFDK_AAC_DECODER 0 ++#define CONFIG_LIBGSM_DECODER 0 ++#define CONFIG_LIBGSM_MS_DECODER 0 ++#define CONFIG_LIBILBC_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 ++#define CONFIG_LIBOPENJPEG_DECODER 0 ++#define CONFIG_LIBOPUS_DECODER 1 ++#define CONFIG_LIBRSVG_DECODER 0 ++#define CONFIG_LIBSPEEX_DECODER 0 ++#define CONFIG_LIBVORBIS_DECODER 0 ++#define CONFIG_LIBVPX_VP8_DECODER 0 ++#define CONFIG_LIBVPX_VP9_DECODER 0 ++#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 ++#define CONFIG_BINTEXT_DECODER 0 ++#define CONFIG_XBIN_DECODER 0 ++#define CONFIG_IDF_DECODER 0 ++#define CONFIG_LIBAOM_AV1_DECODER 0 ++#define CONFIG_LIBOPENH264_DECODER 0 ++#define CONFIG_H264_CUVID_DECODER 0 ++#define CONFIG_HEVC_CUVID_DECODER 0 ++#define CONFIG_HEVC_MEDIACODEC_DECODER 0 ++#define CONFIG_MJPEG_CUVID_DECODER 0 ++#define CONFIG_MJPEG_QSV_DECODER 0 ++#define CONFIG_MPEG1_CUVID_DECODER 0 ++#define CONFIG_MPEG2_CUVID_DECODER 0 ++#define CONFIG_MPEG4_CUVID_DECODER 0 ++#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 ++#define CONFIG_VC1_CUVID_DECODER 0 ++#define CONFIG_VP8_CUVID_DECODER 0 ++#define CONFIG_VP8_MEDIACODEC_DECODER 0 ++#define CONFIG_VP8_QSV_DECODER 0 ++#define CONFIG_VP9_CUVID_DECODER 0 ++#define CONFIG_VP9_MEDIACODEC_DECODER 0 ++#define CONFIG_VP9_QSV_DECODER 0 ++#define CONFIG_A64MULTI_ENCODER 0 ++#define CONFIG_A64MULTI5_ENCODER 0 ++#define CONFIG_ALIAS_PIX_ENCODER 0 ++#define CONFIG_AMV_ENCODER 0 ++#define CONFIG_APNG_ENCODER 0 ++#define CONFIG_ASV1_ENCODER 0 ++#define CONFIG_ASV2_ENCODER 0 ++#define CONFIG_AVRP_ENCODER 0 ++#define CONFIG_AVUI_ENCODER 0 ++#define CONFIG_AYUV_ENCODER 0 ++#define CONFIG_BMP_ENCODER 0 ++#define CONFIG_CFHD_ENCODER 0 ++#define CONFIG_CINEPAK_ENCODER 0 ++#define CONFIG_CLJR_ENCODER 0 ++#define CONFIG_COMFORTNOISE_ENCODER 0 ++#define CONFIG_DNXHD_ENCODER 0 ++#define CONFIG_DPX_ENCODER 0 ++#define CONFIG_DVVIDEO_ENCODER 0 ++#define CONFIG_FFV1_ENCODER 0 ++#define CONFIG_FFVHUFF_ENCODER 0 ++#define CONFIG_FITS_ENCODER 0 ++#define CONFIG_FLASHSV_ENCODER 0 ++#define CONFIG_FLASHSV2_ENCODER 0 ++#define CONFIG_FLV_ENCODER 0 ++#define CONFIG_GIF_ENCODER 0 ++#define CONFIG_H261_ENCODER 0 ++#define CONFIG_H263_ENCODER 0 ++#define CONFIG_H263P_ENCODER 0 ++#define CONFIG_HAP_ENCODER 0 ++#define CONFIG_HUFFYUV_ENCODER 0 ++#define CONFIG_JPEG2000_ENCODER 0 ++#define CONFIG_JPEGLS_ENCODER 0 ++#define CONFIG_LJPEG_ENCODER 0 ++#define CONFIG_MAGICYUV_ENCODER 0 ++#define CONFIG_MJPEG_ENCODER 0 ++#define CONFIG_MPEG1VIDEO_ENCODER 0 ++#define CONFIG_MPEG2VIDEO_ENCODER 0 ++#define CONFIG_MPEG4_ENCODER 0 ++#define CONFIG_MSMPEG4V2_ENCODER 0 ++#define CONFIG_MSMPEG4V3_ENCODER 0 ++#define CONFIG_MSVIDEO1_ENCODER 0 ++#define CONFIG_PAM_ENCODER 0 ++#define CONFIG_PBM_ENCODER 0 ++#define CONFIG_PCX_ENCODER 0 ++#define CONFIG_PGM_ENCODER 0 ++#define CONFIG_PGMYUV_ENCODER 0 ++#define CONFIG_PNG_ENCODER 0 ++#define CONFIG_PPM_ENCODER 0 ++#define CONFIG_PRORES_ENCODER 0 ++#define CONFIG_PRORES_AW_ENCODER 0 ++#define CONFIG_PRORES_KS_ENCODER 0 ++#define CONFIG_QTRLE_ENCODER 0 ++#define CONFIG_R10K_ENCODER 0 ++#define CONFIG_R210_ENCODER 0 ++#define CONFIG_RAWVIDEO_ENCODER 0 ++#define CONFIG_ROQ_ENCODER 0 ++#define CONFIG_RPZA_ENCODER 0 ++#define CONFIG_RV10_ENCODER 0 ++#define CONFIG_RV20_ENCODER 0 ++#define CONFIG_S302M_ENCODER 0 ++#define CONFIG_SGI_ENCODER 0 ++#define CONFIG_SNOW_ENCODER 0 ++#define CONFIG_SUNRAST_ENCODER 0 ++#define CONFIG_SVQ1_ENCODER 0 ++#define CONFIG_TARGA_ENCODER 0 ++#define CONFIG_TIFF_ENCODER 0 ++#define CONFIG_UTVIDEO_ENCODER 0 ++#define CONFIG_V210_ENCODER 0 ++#define CONFIG_V308_ENCODER 0 ++#define CONFIG_V408_ENCODER 0 ++#define CONFIG_V410_ENCODER 0 ++#define CONFIG_VC2_ENCODER 0 ++#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 ++#define CONFIG_WMV1_ENCODER 0 ++#define CONFIG_WMV2_ENCODER 0 ++#define CONFIG_XBM_ENCODER 0 ++#define CONFIG_XFACE_ENCODER 0 ++#define CONFIG_XWD_ENCODER 0 ++#define CONFIG_Y41P_ENCODER 0 ++#define CONFIG_YUV4_ENCODER 0 ++#define CONFIG_ZLIB_ENCODER 0 ++#define CONFIG_ZMBV_ENCODER 0 ++#define CONFIG_AAC_ENCODER 0 ++#define CONFIG_AC3_ENCODER 0 ++#define CONFIG_AC3_FIXED_ENCODER 0 ++#define CONFIG_ALAC_ENCODER 0 ++#define CONFIG_APTX_ENCODER 0 ++#define CONFIG_APTX_HD_ENCODER 0 ++#define CONFIG_DCA_ENCODER 0 ++#define CONFIG_EAC3_ENCODER 0 ++#define CONFIG_FLAC_ENCODER 0 ++#define CONFIG_G723_1_ENCODER 0 ++#define CONFIG_MLP_ENCODER 0 ++#define CONFIG_MP2_ENCODER 0 ++#define CONFIG_MP2FIXED_ENCODER 0 ++#define CONFIG_NELLYMOSER_ENCODER 0 ++#define CONFIG_OPUS_ENCODER 0 ++#define CONFIG_RA_144_ENCODER 0 ++#define CONFIG_SBC_ENCODER 0 ++#define CONFIG_SONIC_ENCODER 0 ++#define CONFIG_SONIC_LS_ENCODER 0 ++#define CONFIG_TRUEHD_ENCODER 0 ++#define CONFIG_TTA_ENCODER 0 ++#define CONFIG_VORBIS_ENCODER 0 ++#define CONFIG_WAVPACK_ENCODER 0 ++#define CONFIG_WMAV1_ENCODER 0 ++#define CONFIG_WMAV2_ENCODER 0 ++#define CONFIG_PCM_ALAW_ENCODER 0 ++#define CONFIG_PCM_DVD_ENCODER 0 ++#define CONFIG_PCM_F32BE_ENCODER 0 ++#define CONFIG_PCM_F32LE_ENCODER 0 ++#define CONFIG_PCM_F64BE_ENCODER 0 ++#define CONFIG_PCM_F64LE_ENCODER 0 ++#define CONFIG_PCM_MULAW_ENCODER 0 ++#define CONFIG_PCM_S8_ENCODER 0 ++#define CONFIG_PCM_S8_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16BE_ENCODER 0 ++#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16LE_ENCODER 0 ++#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S24BE_ENCODER 0 ++#define CONFIG_PCM_S24DAUD_ENCODER 0 ++#define CONFIG_PCM_S24LE_ENCODER 0 ++#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S32BE_ENCODER 0 ++#define CONFIG_PCM_S32LE_ENCODER 0 ++#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S64BE_ENCODER 0 ++#define CONFIG_PCM_S64LE_ENCODER 0 ++#define CONFIG_PCM_U8_ENCODER 0 ++#define CONFIG_PCM_U16BE_ENCODER 0 ++#define CONFIG_PCM_U16LE_ENCODER 0 ++#define CONFIG_PCM_U24BE_ENCODER 0 ++#define CONFIG_PCM_U24LE_ENCODER 0 ++#define CONFIG_PCM_U32BE_ENCODER 0 ++#define CONFIG_PCM_U32LE_ENCODER 0 ++#define CONFIG_PCM_VIDC_ENCODER 0 ++#define CONFIG_ROQ_DPCM_ENCODER 0 ++#define CONFIG_ADPCM_ADX_ENCODER 0 ++#define CONFIG_ADPCM_ARGO_ENCODER 0 ++#define CONFIG_ADPCM_G722_ENCODER 0 ++#define CONFIG_ADPCM_G726_ENCODER 0 ++#define CONFIG_ADPCM_G726LE_ENCODER 0 ++#define CONFIG_ADPCM_IMA_APM_ENCODER 0 ++#define CONFIG_ADPCM_IMA_QT_ENCODER 0 ++#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 ++#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 ++#define CONFIG_ADPCM_MS_ENCODER 0 ++#define CONFIG_ADPCM_SWF_ENCODER 0 ++#define CONFIG_ADPCM_YAMAHA_ENCODER 0 ++#define CONFIG_SSA_ENCODER 0 ++#define CONFIG_ASS_ENCODER 0 ++#define CONFIG_DVBSUB_ENCODER 0 ++#define CONFIG_DVDSUB_ENCODER 0 ++#define CONFIG_MOVTEXT_ENCODER 0 ++#define CONFIG_SRT_ENCODER 0 ++#define CONFIG_SUBRIP_ENCODER 0 ++#define CONFIG_TEXT_ENCODER 0 ++#define CONFIG_WEBVTT_ENCODER 0 ++#define CONFIG_XSUB_ENCODER 0 ++#define CONFIG_AAC_AT_ENCODER 0 ++#define CONFIG_ALAC_AT_ENCODER 0 ++#define CONFIG_ILBC_AT_ENCODER 0 ++#define CONFIG_PCM_ALAW_AT_ENCODER 0 ++#define CONFIG_PCM_MULAW_AT_ENCODER 0 ++#define CONFIG_LIBAOM_AV1_ENCODER 0 ++#define CONFIG_LIBCODEC2_ENCODER 0 ++#define CONFIG_LIBFDK_AAC_ENCODER 0 ++#define CONFIG_LIBGSM_ENCODER 0 ++#define CONFIG_LIBGSM_MS_ENCODER 0 ++#define CONFIG_LIBILBC_ENCODER 0 ++#define CONFIG_LIBMP3LAME_ENCODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 ++#define CONFIG_LIBOPENJPEG_ENCODER 0 ++#define CONFIG_LIBOPUS_ENCODER 0 ++#define CONFIG_LIBRAV1E_ENCODER 0 ++#define CONFIG_LIBSHINE_ENCODER 0 ++#define CONFIG_LIBSPEEX_ENCODER 0 ++#define CONFIG_LIBSVTAV1_ENCODER 0 ++#define CONFIG_LIBTHEORA_ENCODER 0 ++#define CONFIG_LIBTWOLAME_ENCODER 0 ++#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 ++#define CONFIG_LIBVORBIS_ENCODER 0 ++#define CONFIG_LIBVPX_VP8_ENCODER 0 ++#define CONFIG_LIBVPX_VP9_ENCODER 0 ++#define CONFIG_LIBWAVPACK_ENCODER 0 ++#define CONFIG_LIBWEBP_ANIM_ENCODER 0 ++#define CONFIG_LIBWEBP_ENCODER 0 ++#define CONFIG_LIBX262_ENCODER 0 ++#define CONFIG_LIBX264_ENCODER 0 ++#define CONFIG_LIBX264RGB_ENCODER 0 ++#define CONFIG_LIBX265_ENCODER 0 ++#define CONFIG_LIBXAVS_ENCODER 0 ++#define CONFIG_LIBXAVS2_ENCODER 0 ++#define CONFIG_LIBXVID_ENCODER 0 ++#define CONFIG_AAC_MF_ENCODER 0 ++#define CONFIG_AC3_MF_ENCODER 0 ++#define CONFIG_H263_V4L2M2M_ENCODER 0 ++#define CONFIG_LIBOPENH264_ENCODER 0 ++#define CONFIG_H264_AMF_ENCODER 0 ++#define CONFIG_H264_MF_ENCODER 0 ++#define CONFIG_H264_NVENC_ENCODER 0 ++#define CONFIG_H264_OMX_ENCODER 0 ++#define CONFIG_H264_QSV_ENCODER 0 ++#define CONFIG_H264_V4L2M2M_ENCODER 0 ++#define CONFIG_H264_VAAPI_ENCODER 0 ++#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_NVENC_ENCODER 0 ++#define CONFIG_NVENC_H264_ENCODER 0 ++#define CONFIG_NVENC_HEVC_ENCODER 0 ++#define CONFIG_HEVC_AMF_ENCODER 0 ++#define CONFIG_HEVC_MF_ENCODER 0 ++#define CONFIG_HEVC_NVENC_ENCODER 0 ++#define CONFIG_HEVC_QSV_ENCODER 0 ++#define CONFIG_HEVC_V4L2M2M_ENCODER 0 ++#define CONFIG_HEVC_VAAPI_ENCODER 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_LIBKVAZAAR_ENCODER 0 ++#define CONFIG_MJPEG_QSV_ENCODER 0 ++#define CONFIG_MJPEG_VAAPI_ENCODER 0 ++#define CONFIG_MP3_MF_ENCODER 0 ++#define CONFIG_MPEG2_QSV_ENCODER 0 ++#define CONFIG_MPEG2_VAAPI_ENCODER 0 ++#define CONFIG_MPEG4_OMX_ENCODER 0 ++#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_VAAPI_ENCODER 0 ++#define CONFIG_VP9_VAAPI_ENCODER 0 ++#define CONFIG_VP9_QSV_ENCODER 0 ++#define CONFIG_H263_VAAPI_HWACCEL 0 ++#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_H264_D3D11VA_HWACCEL 0 ++#define CONFIG_H264_D3D11VA2_HWACCEL 0 ++#define CONFIG_H264_DXVA2_HWACCEL 0 ++#define CONFIG_H264_NVDEC_HWACCEL 0 ++#define CONFIG_H264_VAAPI_HWACCEL 0 ++#define CONFIG_H264_VDPAU_HWACCEL 0 ++#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 ++#define CONFIG_HEVC_DXVA2_HWACCEL 0 ++#define CONFIG_HEVC_NVDEC_HWACCEL 0 ++#define CONFIG_HEVC_VAAPI_HWACCEL 0 ++#define CONFIG_HEVC_VDPAU_HWACCEL 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MJPEG_NVDEC_HWACCEL 0 ++#define CONFIG_MJPEG_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG1_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG1_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG1_XVMC_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 ++#define CONFIG_MPEG2_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG2_DXVA2_HWACCEL 0 ++#define CONFIG_MPEG2_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG2_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG2_XVMC_HWACCEL 0 ++#define CONFIG_MPEG4_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG4_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG4_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA2_HWACCEL 0 ++#define CONFIG_VC1_DXVA2_HWACCEL 0 ++#define CONFIG_VC1_NVDEC_HWACCEL 0 ++#define CONFIG_VC1_VAAPI_HWACCEL 0 ++#define CONFIG_VC1_VDPAU_HWACCEL 0 ++#define CONFIG_VP8_NVDEC_HWACCEL 0 ++#define CONFIG_VP8_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA2_HWACCEL 0 ++#define CONFIG_VP9_DXVA2_HWACCEL 0 ++#define CONFIG_VP9_NVDEC_HWACCEL 0 ++#define CONFIG_VP9_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_VDPAU_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 ++#define CONFIG_WMV3_DXVA2_HWACCEL 0 ++#define CONFIG_WMV3_NVDEC_HWACCEL 0 ++#define CONFIG_WMV3_VAAPI_HWACCEL 0 ++#define CONFIG_WMV3_VDPAU_HWACCEL 0 ++#define CONFIG_AAC_PARSER 1 ++#define CONFIG_AAC_LATM_PARSER 0 ++#define CONFIG_AC3_PARSER 0 ++#define CONFIG_ADX_PARSER 0 ++#define CONFIG_AV1_PARSER 0 ++#define CONFIG_AVS2_PARSER 0 ++#define CONFIG_BMP_PARSER 0 ++#define CONFIG_CAVSVIDEO_PARSER 0 ++#define CONFIG_COOK_PARSER 0 ++#define CONFIG_DCA_PARSER 0 ++#define CONFIG_DIRAC_PARSER 0 ++#define CONFIG_DNXHD_PARSER 0 ++#define CONFIG_DPX_PARSER 0 ++#define CONFIG_DVAUDIO_PARSER 0 ++#define CONFIG_DVBSUB_PARSER 0 ++#define CONFIG_DVDSUB_PARSER 0 ++#define CONFIG_DVD_NAV_PARSER 0 ++#define CONFIG_FLAC_PARSER 1 ++#define CONFIG_G723_1_PARSER 0 ++#define CONFIG_G729_PARSER 0 ++#define CONFIG_GIF_PARSER 0 ++#define CONFIG_GSM_PARSER 1 ++#define CONFIG_H261_PARSER 0 ++#define CONFIG_H263_PARSER 1 ++#define CONFIG_H264_PARSER 1 ++#define CONFIG_HEVC_PARSER 0 ++#define CONFIG_JPEG2000_PARSER 0 ++#define CONFIG_MJPEG_PARSER 0 ++#define CONFIG_MLP_PARSER 0 ++#define CONFIG_MPEG4VIDEO_PARSER 1 ++#define CONFIG_MPEGAUDIO_PARSER 1 ++#define CONFIG_MPEGVIDEO_PARSER 0 ++#define CONFIG_OPUS_PARSER 1 ++#define CONFIG_PNG_PARSER 0 ++#define CONFIG_PNM_PARSER 0 ++#define CONFIG_RV30_PARSER 0 ++#define CONFIG_RV40_PARSER 0 ++#define CONFIG_SBC_PARSER 0 ++#define CONFIG_SIPR_PARSER 0 ++#define CONFIG_TAK_PARSER 0 ++#define CONFIG_VC1_PARSER 0 ++#define CONFIG_VORBIS_PARSER 1 ++#define CONFIG_VP3_PARSER 1 ++#define CONFIG_VP8_PARSER 1 ++#define CONFIG_VP9_PARSER 1 ++#define CONFIG_WEBP_PARSER 0 ++#define CONFIG_XMA_PARSER 0 ++#define CONFIG_ALSA_INDEV 0 ++#define CONFIG_ANDROID_CAMERA_INDEV 0 ++#define CONFIG_AVFOUNDATION_INDEV 0 ++#define CONFIG_BKTR_INDEV 0 ++#define CONFIG_DECKLINK_INDEV 0 ++#define CONFIG_DSHOW_INDEV 0 ++#define CONFIG_FBDEV_INDEV 0 ++#define CONFIG_GDIGRAB_INDEV 0 ++#define CONFIG_IEC61883_INDEV 0 ++#define CONFIG_JACK_INDEV 0 ++#define CONFIG_KMSGRAB_INDEV 0 ++#define CONFIG_LAVFI_INDEV 0 ++#define CONFIG_OPENAL_INDEV 0 ++#define CONFIG_OSS_INDEV 0 ++#define CONFIG_PULSE_INDEV 0 ++#define CONFIG_SNDIO_INDEV 0 ++#define CONFIG_V4L2_INDEV 0 ++#define CONFIG_VFWCAP_INDEV 0 ++#define CONFIG_XCBGRAB_INDEV 0 ++#define CONFIG_LIBCDIO_INDEV 0 ++#define CONFIG_LIBDC1394_INDEV 0 ++#define CONFIG_ALSA_OUTDEV 0 ++#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 ++#define CONFIG_CACA_OUTDEV 0 ++#define CONFIG_DECKLINK_OUTDEV 0 ++#define CONFIG_FBDEV_OUTDEV 0 ++#define CONFIG_OPENGL_OUTDEV 0 ++#define CONFIG_OSS_OUTDEV 0 ++#define CONFIG_PULSE_OUTDEV 0 ++#define CONFIG_SDL2_OUTDEV 0 ++#define CONFIG_SNDIO_OUTDEV 0 ++#define CONFIG_V4L2_OUTDEV 0 ++#define CONFIG_XV_OUTDEV 0 ++#define CONFIG_ABENCH_FILTER 0 ++#define CONFIG_ACOMPRESSOR_FILTER 0 ++#define CONFIG_ACONTRAST_FILTER 0 ++#define CONFIG_ACOPY_FILTER 0 ++#define CONFIG_ACUE_FILTER 0 ++#define CONFIG_ACROSSFADE_FILTER 0 ++#define CONFIG_ACROSSOVER_FILTER 0 ++#define CONFIG_ACRUSHER_FILTER 0 ++#define CONFIG_ADECLICK_FILTER 0 ++#define CONFIG_ADECLIP_FILTER 0 ++#define CONFIG_ADELAY_FILTER 0 ++#define CONFIG_ADERIVATIVE_FILTER 0 ++#define CONFIG_AECHO_FILTER 0 ++#define CONFIG_AEMPHASIS_FILTER 0 ++#define CONFIG_AEVAL_FILTER 0 ++#define CONFIG_AFADE_FILTER 0 ++#define CONFIG_AFFTDN_FILTER 0 ++#define CONFIG_AFFTFILT_FILTER 0 ++#define CONFIG_AFIR_FILTER 0 ++#define CONFIG_AFORMAT_FILTER 0 ++#define CONFIG_AGATE_FILTER 0 ++#define CONFIG_AIIR_FILTER 0 ++#define CONFIG_AINTEGRAL_FILTER 0 ++#define CONFIG_AINTERLEAVE_FILTER 0 ++#define CONFIG_ALIMITER_FILTER 0 ++#define CONFIG_ALLPASS_FILTER 0 ++#define CONFIG_ALOOP_FILTER 0 ++#define CONFIG_AMERGE_FILTER 0 ++#define CONFIG_AMETADATA_FILTER 0 ++#define CONFIG_AMIX_FILTER 0 ++#define CONFIG_AMULTIPLY_FILTER 0 ++#define CONFIG_ANEQUALIZER_FILTER 0 ++#define CONFIG_ANLMDN_FILTER 0 ++#define CONFIG_ANLMS_FILTER 0 ++#define CONFIG_ANULL_FILTER 0 ++#define CONFIG_APAD_FILTER 0 ++#define CONFIG_APERMS_FILTER 0 ++#define CONFIG_APHASER_FILTER 0 ++#define CONFIG_APULSATOR_FILTER 0 ++#define CONFIG_AREALTIME_FILTER 0 ++#define CONFIG_ARESAMPLE_FILTER 0 ++#define CONFIG_AREVERSE_FILTER 0 ++#define CONFIG_ARNNDN_FILTER 0 ++#define CONFIG_ASELECT_FILTER 0 ++#define CONFIG_ASENDCMD_FILTER 0 ++#define CONFIG_ASETNSAMPLES_FILTER 0 ++#define CONFIG_ASETPTS_FILTER 0 ++#define CONFIG_ASETRATE_FILTER 0 ++#define CONFIG_ASETTB_FILTER 0 ++#define CONFIG_ASHOWINFO_FILTER 0 ++#define CONFIG_ASIDEDATA_FILTER 0 ++#define CONFIG_ASOFTCLIP_FILTER 0 ++#define CONFIG_ASPLIT_FILTER 0 ++#define CONFIG_ASR_FILTER 0 ++#define CONFIG_ASTATS_FILTER 0 ++#define CONFIG_ASTREAMSELECT_FILTER 0 ++#define CONFIG_ASUBBOOST_FILTER 0 ++#define CONFIG_ATEMPO_FILTER 0 ++#define CONFIG_ATRIM_FILTER 0 ++#define CONFIG_AXCORRELATE_FILTER 0 ++#define CONFIG_AZMQ_FILTER 0 ++#define CONFIG_BANDPASS_FILTER 0 ++#define CONFIG_BANDREJECT_FILTER 0 ++#define CONFIG_BASS_FILTER 0 ++#define CONFIG_BIQUAD_FILTER 0 ++#define CONFIG_BS2B_FILTER 0 ++#define CONFIG_CHROMABER_VULKAN_FILTER 0 ++#define CONFIG_CHANNELMAP_FILTER 0 ++#define CONFIG_CHANNELSPLIT_FILTER 0 ++#define CONFIG_CHORUS_FILTER 0 ++#define CONFIG_COMPAND_FILTER 0 ++#define CONFIG_COMPENSATIONDELAY_FILTER 0 ++#define CONFIG_CROSSFEED_FILTER 0 ++#define CONFIG_CRYSTALIZER_FILTER 0 ++#define CONFIG_DCSHIFT_FILTER 0 ++#define CONFIG_DEESSER_FILTER 0 ++#define CONFIG_DRMETER_FILTER 0 ++#define CONFIG_DYNAUDNORM_FILTER 0 ++#define CONFIG_EARWAX_FILTER 0 ++#define CONFIG_EBUR128_FILTER 0 ++#define CONFIG_EQUALIZER_FILTER 0 ++#define CONFIG_EXTRASTEREO_FILTER 0 ++#define CONFIG_FIREQUALIZER_FILTER 0 ++#define CONFIG_FLANGER_FILTER 0 ++#define CONFIG_HAAS_FILTER 0 ++#define CONFIG_HDCD_FILTER 0 ++#define CONFIG_HEADPHONE_FILTER 0 ++#define CONFIG_HIGHPASS_FILTER 0 ++#define CONFIG_HIGHSHELF_FILTER 0 ++#define CONFIG_JOIN_FILTER 0 ++#define CONFIG_LADSPA_FILTER 0 ++#define CONFIG_LOUDNORM_FILTER 0 ++#define CONFIG_LOWPASS_FILTER 0 ++#define CONFIG_LOWSHELF_FILTER 0 ++#define CONFIG_LV2_FILTER 0 ++#define CONFIG_MCOMPAND_FILTER 0 ++#define CONFIG_PAN_FILTER 0 ++#define CONFIG_REPLAYGAIN_FILTER 0 ++#define CONFIG_RESAMPLE_FILTER 0 ++#define CONFIG_RUBBERBAND_FILTER 0 ++#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 ++#define CONFIG_SIDECHAINGATE_FILTER 0 ++#define CONFIG_SILENCEDETECT_FILTER 0 ++#define CONFIG_SILENCEREMOVE_FILTER 0 ++#define CONFIG_SOFALIZER_FILTER 0 ++#define CONFIG_STEREOTOOLS_FILTER 0 ++#define CONFIG_STEREOWIDEN_FILTER 0 ++#define CONFIG_SUPEREQUALIZER_FILTER 0 ++#define CONFIG_SURROUND_FILTER 0 ++#define CONFIG_TREBLE_FILTER 0 ++#define CONFIG_TREMOLO_FILTER 0 ++#define CONFIG_VIBRATO_FILTER 0 ++#define CONFIG_VOLUME_FILTER 0 ++#define CONFIG_VOLUMEDETECT_FILTER 0 ++#define CONFIG_AEVALSRC_FILTER 0 ++#define CONFIG_AFIRSRC_FILTER 0 ++#define CONFIG_ANOISESRC_FILTER 0 ++#define CONFIG_ANULLSRC_FILTER 0 ++#define CONFIG_FLITE_FILTER 0 ++#define CONFIG_HILBERT_FILTER 0 ++#define CONFIG_SINC_FILTER 0 ++#define CONFIG_SINE_FILTER 0 ++#define CONFIG_ANULLSINK_FILTER 0 ++#define CONFIG_ADDROI_FILTER 0 ++#define CONFIG_ALPHAEXTRACT_FILTER 0 ++#define CONFIG_ALPHAMERGE_FILTER 0 ++#define CONFIG_AMPLIFY_FILTER 0 ++#define CONFIG_ASS_FILTER 0 ++#define CONFIG_ATADENOISE_FILTER 0 ++#define CONFIG_AVGBLUR_FILTER 0 ++#define CONFIG_AVGBLUR_OPENCL_FILTER 0 ++#define CONFIG_AVGBLUR_VULKAN_FILTER 0 ++#define CONFIG_BBOX_FILTER 0 ++#define CONFIG_BENCH_FILTER 0 ++#define CONFIG_BILATERAL_FILTER 0 ++#define CONFIG_BITPLANENOISE_FILTER 0 ++#define CONFIG_BLACKDETECT_FILTER 0 ++#define CONFIG_BLACKFRAME_FILTER 0 ++#define CONFIG_BLEND_FILTER 0 ++#define CONFIG_BM3D_FILTER 0 ++#define CONFIG_BOXBLUR_FILTER 0 ++#define CONFIG_BOXBLUR_OPENCL_FILTER 0 ++#define CONFIG_BWDIF_FILTER 0 ++#define CONFIG_CAS_FILTER 0 ++#define CONFIG_CHROMAHOLD_FILTER 0 ++#define CONFIG_CHROMAKEY_FILTER 0 ++#define CONFIG_CHROMANR_FILTER 0 ++#define CONFIG_CHROMASHIFT_FILTER 0 ++#define CONFIG_CIESCOPE_FILTER 0 ++#define CONFIG_CODECVIEW_FILTER 0 ++#define CONFIG_COLORBALANCE_FILTER 0 ++#define CONFIG_COLORCHANNELMIXER_FILTER 0 ++#define CONFIG_COLORKEY_FILTER 0 ++#define CONFIG_COLORKEY_OPENCL_FILTER 0 ++#define CONFIG_COLORHOLD_FILTER 0 ++#define CONFIG_COLORLEVELS_FILTER 0 ++#define CONFIG_COLORMATRIX_FILTER 0 ++#define CONFIG_COLORSPACE_FILTER 0 ++#define CONFIG_CONVOLUTION_FILTER 0 ++#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 ++#define CONFIG_CONVOLVE_FILTER 0 ++#define CONFIG_COPY_FILTER 0 ++#define CONFIG_COREIMAGE_FILTER 0 ++#define CONFIG_COVER_RECT_FILTER 0 ++#define CONFIG_CROP_FILTER 0 ++#define CONFIG_CROPDETECT_FILTER 0 ++#define CONFIG_CUE_FILTER 0 ++#define CONFIG_CURVES_FILTER 0 ++#define CONFIG_DATASCOPE_FILTER 0 ++#define CONFIG_DBLUR_FILTER 0 ++#define CONFIG_DCTDNOIZ_FILTER 0 ++#define CONFIG_DEBAND_FILTER 0 ++#define CONFIG_DEBLOCK_FILTER 0 ++#define CONFIG_DECIMATE_FILTER 0 ++#define CONFIG_DECONVOLVE_FILTER 0 ++#define CONFIG_DEDOT_FILTER 0 ++#define CONFIG_DEFLATE_FILTER 0 ++#define CONFIG_DEFLICKER_FILTER 0 ++#define CONFIG_DEINTERLACE_QSV_FILTER 0 ++#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 ++#define CONFIG_DEJUDDER_FILTER 0 ++#define CONFIG_DELOGO_FILTER 0 ++#define CONFIG_DENOISE_VAAPI_FILTER 0 ++#define CONFIG_DERAIN_FILTER 0 ++#define CONFIG_DESHAKE_FILTER 0 ++#define CONFIG_DESHAKE_OPENCL_FILTER 0 ++#define CONFIG_DESPILL_FILTER 0 ++#define CONFIG_DETELECINE_FILTER 0 ++#define CONFIG_DILATION_FILTER 0 ++#define CONFIG_DILATION_OPENCL_FILTER 0 ++#define CONFIG_DISPLACE_FILTER 0 ++#define CONFIG_DNN_PROCESSING_FILTER 0 ++#define CONFIG_DOUBLEWEAVE_FILTER 0 ++#define CONFIG_DRAWBOX_FILTER 0 ++#define CONFIG_DRAWGRAPH_FILTER 0 ++#define CONFIG_DRAWGRID_FILTER 0 ++#define CONFIG_DRAWTEXT_FILTER 0 ++#define CONFIG_EDGEDETECT_FILTER 0 ++#define CONFIG_ELBG_FILTER 0 ++#define CONFIG_ENTROPY_FILTER 0 ++#define CONFIG_EQ_FILTER 0 ++#define CONFIG_EROSION_FILTER 0 ++#define CONFIG_EROSION_OPENCL_FILTER 0 ++#define CONFIG_EXTRACTPLANES_FILTER 0 ++#define CONFIG_FADE_FILTER 0 ++#define CONFIG_FFTDNOIZ_FILTER 0 ++#define CONFIG_FFTFILT_FILTER 0 ++#define CONFIG_FIELD_FILTER 0 ++#define CONFIG_FIELDHINT_FILTER 0 ++#define CONFIG_FIELDMATCH_FILTER 0 ++#define CONFIG_FIELDORDER_FILTER 0 ++#define CONFIG_FILLBORDERS_FILTER 0 ++#define CONFIG_FIND_RECT_FILTER 0 ++#define CONFIG_FLOODFILL_FILTER 0 ++#define CONFIG_FORMAT_FILTER 0 ++#define CONFIG_FPS_FILTER 0 ++#define CONFIG_FRAMEPACK_FILTER 0 ++#define CONFIG_FRAMERATE_FILTER 0 ++#define CONFIG_FRAMESTEP_FILTER 0 ++#define CONFIG_FREEZEDETECT_FILTER 0 ++#define CONFIG_FREEZEFRAMES_FILTER 0 ++#define CONFIG_FREI0R_FILTER 0 ++#define CONFIG_FSPP_FILTER 0 ++#define CONFIG_GBLUR_FILTER 0 ++#define CONFIG_GEQ_FILTER 0 ++#define CONFIG_GRADFUN_FILTER 0 ++#define CONFIG_GRAPHMONITOR_FILTER 0 ++#define CONFIG_GREYEDGE_FILTER 0 ++#define CONFIG_HALDCLUT_FILTER 0 ++#define CONFIG_HFLIP_FILTER 0 ++#define CONFIG_HISTEQ_FILTER 0 ++#define CONFIG_HISTOGRAM_FILTER 0 ++#define CONFIG_HQDN3D_FILTER 0 ++#define CONFIG_HQX_FILTER 0 ++#define CONFIG_HSTACK_FILTER 0 ++#define CONFIG_HUE_FILTER 0 ++#define CONFIG_HWDOWNLOAD_FILTER 0 ++#define CONFIG_HWMAP_FILTER 0 ++#define CONFIG_HWUPLOAD_FILTER 0 ++#define CONFIG_HWUPLOAD_CUDA_FILTER 0 ++#define CONFIG_HYSTERESIS_FILTER 0 ++#define CONFIG_IDET_FILTER 0 ++#define CONFIG_IL_FILTER 0 ++#define CONFIG_INFLATE_FILTER 0 ++#define CONFIG_INTERLACE_FILTER 0 ++#define CONFIG_INTERLEAVE_FILTER 0 ++#define CONFIG_KERNDEINT_FILTER 0 ++#define CONFIG_LAGFUN_FILTER 0 ++#define CONFIG_LENSCORRECTION_FILTER 0 ++#define CONFIG_LENSFUN_FILTER 0 ++#define CONFIG_LIBVMAF_FILTER 0 ++#define CONFIG_LIMITER_FILTER 0 ++#define CONFIG_LOOP_FILTER 0 ++#define CONFIG_LUMAKEY_FILTER 0 ++#define CONFIG_LUT_FILTER 0 ++#define CONFIG_LUT1D_FILTER 0 ++#define CONFIG_LUT2_FILTER 0 ++#define CONFIG_LUT3D_FILTER 0 ++#define CONFIG_LUTRGB_FILTER 0 ++#define CONFIG_LUTYUV_FILTER 0 ++#define CONFIG_MASKEDCLAMP_FILTER 0 ++#define CONFIG_MASKEDMAX_FILTER 0 ++#define CONFIG_MASKEDMERGE_FILTER 0 ++#define CONFIG_MASKEDMIN_FILTER 0 ++#define CONFIG_MASKEDTHRESHOLD_FILTER 0 ++#define CONFIG_MASKFUN_FILTER 0 ++#define CONFIG_MCDEINT_FILTER 0 ++#define CONFIG_MEDIAN_FILTER 0 ++#define CONFIG_MERGEPLANES_FILTER 0 ++#define CONFIG_MESTIMATE_FILTER 0 ++#define CONFIG_METADATA_FILTER 0 ++#define CONFIG_MIDEQUALIZER_FILTER 0 ++#define CONFIG_MINTERPOLATE_FILTER 0 ++#define CONFIG_MIX_FILTER 0 ++#define CONFIG_MPDECIMATE_FILTER 0 ++#define CONFIG_NEGATE_FILTER 0 ++#define CONFIG_NLMEANS_FILTER 0 ++#define CONFIG_NLMEANS_OPENCL_FILTER 0 ++#define CONFIG_NNEDI_FILTER 0 ++#define CONFIG_NOFORMAT_FILTER 0 ++#define CONFIG_NOISE_FILTER 0 ++#define CONFIG_NORMALIZE_FILTER 0 ++#define CONFIG_NULL_FILTER 0 ++#define CONFIG_OCR_FILTER 0 ++#define CONFIG_OCV_FILTER 0 ++#define CONFIG_OSCILLOSCOPE_FILTER 0 ++#define CONFIG_OVERLAY_FILTER 0 ++#define CONFIG_OVERLAY_OPENCL_FILTER 0 ++#define CONFIG_OVERLAY_QSV_FILTER 0 ++#define CONFIG_OVERLAY_VULKAN_FILTER 0 ++#define CONFIG_OVERLAY_CUDA_FILTER 0 ++#define CONFIG_OWDENOISE_FILTER 0 ++#define CONFIG_PAD_FILTER 0 ++#define CONFIG_PAD_OPENCL_FILTER 0 ++#define CONFIG_PALETTEGEN_FILTER 0 ++#define CONFIG_PALETTEUSE_FILTER 0 ++#define CONFIG_PERMS_FILTER 0 ++#define CONFIG_PERSPECTIVE_FILTER 0 ++#define CONFIG_PHASE_FILTER 0 ++#define CONFIG_PHOTOSENSITIVITY_FILTER 0 ++#define CONFIG_PIXDESCTEST_FILTER 0 ++#define CONFIG_PIXSCOPE_FILTER 0 ++#define CONFIG_PP_FILTER 0 ++#define CONFIG_PP7_FILTER 0 ++#define CONFIG_PREMULTIPLY_FILTER 0 ++#define CONFIG_PREWITT_FILTER 0 ++#define CONFIG_PREWITT_OPENCL_FILTER 0 ++#define CONFIG_PROCAMP_VAAPI_FILTER 0 ++#define CONFIG_PROGRAM_OPENCL_FILTER 0 ++#define CONFIG_PSEUDOCOLOR_FILTER 0 ++#define CONFIG_PSNR_FILTER 0 ++#define CONFIG_PULLUP_FILTER 0 ++#define CONFIG_QP_FILTER 0 ++#define CONFIG_RANDOM_FILTER 0 ++#define CONFIG_READEIA608_FILTER 0 ++#define CONFIG_READVITC_FILTER 0 ++#define CONFIG_REALTIME_FILTER 0 ++#define CONFIG_REMAP_FILTER 0 ++#define CONFIG_REMOVEGRAIN_FILTER 0 ++#define CONFIG_REMOVELOGO_FILTER 0 ++#define CONFIG_REPEATFIELDS_FILTER 0 ++#define CONFIG_REVERSE_FILTER 0 ++#define CONFIG_RGBASHIFT_FILTER 0 ++#define CONFIG_ROBERTS_FILTER 0 ++#define CONFIG_ROBERTS_OPENCL_FILTER 0 ++#define CONFIG_ROTATE_FILTER 0 ++#define CONFIG_SAB_FILTER 0 ++#define CONFIG_SCALE_FILTER 0 ++#define CONFIG_SCALE_CUDA_FILTER 0 ++#define CONFIG_SCALE_NPP_FILTER 0 ++#define CONFIG_SCALE_QSV_FILTER 0 ++#define CONFIG_SCALE_VAAPI_FILTER 0 ++#define CONFIG_SCALE_VULKAN_FILTER 0 ++#define CONFIG_SCALE2REF_FILTER 0 ++#define CONFIG_SCDET_FILTER 0 ++#define CONFIG_SCROLL_FILTER 0 ++#define CONFIG_SELECT_FILTER 0 ++#define CONFIG_SELECTIVECOLOR_FILTER 0 ++#define CONFIG_SENDCMD_FILTER 0 ++#define CONFIG_SEPARATEFIELDS_FILTER 0 ++#define CONFIG_SETDAR_FILTER 0 ++#define CONFIG_SETFIELD_FILTER 0 ++#define CONFIG_SETPARAMS_FILTER 0 ++#define CONFIG_SETPTS_FILTER 0 ++#define CONFIG_SETRANGE_FILTER 0 ++#define CONFIG_SETSAR_FILTER 0 ++#define CONFIG_SETTB_FILTER 0 ++#define CONFIG_SHARPNESS_VAAPI_FILTER 0 ++#define CONFIG_SHOWINFO_FILTER 0 ++#define CONFIG_SHOWPALETTE_FILTER 0 ++#define CONFIG_SHUFFLEFRAMES_FILTER 0 ++#define CONFIG_SHUFFLEPLANES_FILTER 0 ++#define CONFIG_SIDEDATA_FILTER 0 ++#define CONFIG_SIGNALSTATS_FILTER 0 ++#define CONFIG_SIGNATURE_FILTER 0 ++#define CONFIG_SMARTBLUR_FILTER 0 ++#define CONFIG_SOBEL_FILTER 0 ++#define CONFIG_SOBEL_OPENCL_FILTER 0 ++#define CONFIG_SPLIT_FILTER 0 ++#define CONFIG_SPP_FILTER 0 ++#define CONFIG_SR_FILTER 0 ++#define CONFIG_SSIM_FILTER 0 ++#define CONFIG_STEREO3D_FILTER 0 ++#define CONFIG_STREAMSELECT_FILTER 0 ++#define CONFIG_SUBTITLES_FILTER 0 ++#define CONFIG_SUPER2XSAI_FILTER 0 ++#define CONFIG_SWAPRECT_FILTER 0 ++#define CONFIG_SWAPUV_FILTER 0 ++#define CONFIG_TBLEND_FILTER 0 ++#define CONFIG_TELECINE_FILTER 0 ++#define CONFIG_THISTOGRAM_FILTER 0 ++#define CONFIG_THRESHOLD_FILTER 0 ++#define CONFIG_THUMBNAIL_FILTER 0 ++#define CONFIG_THUMBNAIL_CUDA_FILTER 0 ++#define CONFIG_TILE_FILTER 0 ++#define CONFIG_TINTERLACE_FILTER 0 ++#define CONFIG_TLUT2_FILTER 0 ++#define CONFIG_TMEDIAN_FILTER 0 ++#define CONFIG_TMIX_FILTER 0 ++#define CONFIG_TONEMAP_FILTER 0 ++#define CONFIG_TONEMAP_OPENCL_FILTER 0 ++#define CONFIG_TONEMAP_VAAPI_FILTER 0 ++#define CONFIG_TPAD_FILTER 0 ++#define CONFIG_TRANSPOSE_FILTER 0 ++#define CONFIG_TRANSPOSE_NPP_FILTER 0 ++#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 ++#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 ++#define CONFIG_TRIM_FILTER 0 ++#define CONFIG_UNPREMULTIPLY_FILTER 0 ++#define CONFIG_UNSHARP_FILTER 0 ++#define CONFIG_UNSHARP_OPENCL_FILTER 0 ++#define CONFIG_UNTILE_FILTER 0 ++#define CONFIG_USPP_FILTER 0 ++#define CONFIG_V360_FILTER 0 ++#define CONFIG_VAGUEDENOISER_FILTER 0 ++#define CONFIG_VECTORSCOPE_FILTER 0 ++#define CONFIG_VFLIP_FILTER 0 ++#define CONFIG_VFRDET_FILTER 0 ++#define CONFIG_VIBRANCE_FILTER 0 ++#define CONFIG_VIDSTABDETECT_FILTER 0 ++#define CONFIG_VIDSTABTRANSFORM_FILTER 0 ++#define CONFIG_VIGNETTE_FILTER 0 ++#define CONFIG_VMAFMOTION_FILTER 0 ++#define CONFIG_VPP_QSV_FILTER 0 ++#define CONFIG_VSTACK_FILTER 0 ++#define CONFIG_W3FDIF_FILTER 0 ++#define CONFIG_WAVEFORM_FILTER 0 ++#define CONFIG_WEAVE_FILTER 0 ++#define CONFIG_XBR_FILTER 0 ++#define CONFIG_XFADE_FILTER 0 ++#define CONFIG_XFADE_OPENCL_FILTER 0 ++#define CONFIG_XMEDIAN_FILTER 0 ++#define CONFIG_XSTACK_FILTER 0 ++#define CONFIG_YADIF_FILTER 0 ++#define CONFIG_YADIF_CUDA_FILTER 0 ++#define CONFIG_YAEPBLUR_FILTER 0 ++#define CONFIG_ZMQ_FILTER 0 ++#define CONFIG_ZOOMPAN_FILTER 0 ++#define CONFIG_ZSCALE_FILTER 0 ++#define CONFIG_ALLRGB_FILTER 0 ++#define CONFIG_ALLYUV_FILTER 0 ++#define CONFIG_CELLAUTO_FILTER 0 ++#define CONFIG_COLOR_FILTER 0 ++#define CONFIG_COREIMAGESRC_FILTER 0 ++#define CONFIG_FREI0R_SRC_FILTER 0 ++#define CONFIG_GRADIENTS_FILTER 0 ++#define CONFIG_HALDCLUTSRC_FILTER 0 ++#define CONFIG_LIFE_FILTER 0 ++#define CONFIG_MANDELBROT_FILTER 0 ++#define CONFIG_MPTESTSRC_FILTER 0 ++#define CONFIG_NULLSRC_FILTER 0 ++#define CONFIG_OPENCLSRC_FILTER 0 ++#define CONFIG_PAL75BARS_FILTER 0 ++#define CONFIG_PAL100BARS_FILTER 0 ++#define CONFIG_RGBTESTSRC_FILTER 0 ++#define CONFIG_SIERPINSKI_FILTER 0 ++#define CONFIG_SMPTEBARS_FILTER 0 ++#define CONFIG_SMPTEHDBARS_FILTER 0 ++#define CONFIG_TESTSRC_FILTER 0 ++#define CONFIG_TESTSRC2_FILTER 0 ++#define CONFIG_YUVTESTSRC_FILTER 0 ++#define CONFIG_NULLSINK_FILTER 0 ++#define CONFIG_ABITSCOPE_FILTER 0 ++#define CONFIG_ADRAWGRAPH_FILTER 0 ++#define CONFIG_AGRAPHMONITOR_FILTER 0 ++#define CONFIG_AHISTOGRAM_FILTER 0 ++#define CONFIG_APHASEMETER_FILTER 0 ++#define CONFIG_AVECTORSCOPE_FILTER 0 ++#define CONFIG_CONCAT_FILTER 0 ++#define CONFIG_SHOWCQT_FILTER 0 ++#define CONFIG_SHOWFREQS_FILTER 0 ++#define CONFIG_SHOWSPATIAL_FILTER 0 ++#define CONFIG_SHOWSPECTRUM_FILTER 0 ++#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 ++#define CONFIG_SHOWVOLUME_FILTER 0 ++#define CONFIG_SHOWWAVES_FILTER 0 ++#define CONFIG_SHOWWAVESPIC_FILTER 0 ++#define CONFIG_SPECTRUMSYNTH_FILTER 0 ++#define CONFIG_AMOVIE_FILTER 0 ++#define CONFIG_MOVIE_FILTER 0 ++#define CONFIG_AFIFO_FILTER 0 ++#define CONFIG_FIFO_FILTER 0 ++#define CONFIG_AA_DEMUXER 0 ++#define CONFIG_AAC_DEMUXER 1 ++#define CONFIG_AC3_DEMUXER 0 ++#define CONFIG_ACM_DEMUXER 0 ++#define CONFIG_ACT_DEMUXER 0 ++#define CONFIG_ADF_DEMUXER 0 ++#define CONFIG_ADP_DEMUXER 0 ++#define CONFIG_ADS_DEMUXER 0 ++#define CONFIG_ADX_DEMUXER 0 ++#define CONFIG_AEA_DEMUXER 0 ++#define CONFIG_AFC_DEMUXER 0 ++#define CONFIG_AIFF_DEMUXER 0 ++#define CONFIG_AIX_DEMUXER 0 ++#define CONFIG_ALP_DEMUXER 0 ++#define CONFIG_AMR_DEMUXER 1 ++#define CONFIG_AMRNB_DEMUXER 0 ++#define CONFIG_AMRWB_DEMUXER 0 ++#define CONFIG_ANM_DEMUXER 0 ++#define CONFIG_APC_DEMUXER 0 ++#define CONFIG_APE_DEMUXER 0 ++#define CONFIG_APM_DEMUXER 0 ++#define CONFIG_APNG_DEMUXER 0 ++#define CONFIG_APTX_DEMUXER 0 ++#define CONFIG_APTX_HD_DEMUXER 0 ++#define CONFIG_AQTITLE_DEMUXER 0 ++#define CONFIG_ARGO_ASF_DEMUXER 0 ++#define CONFIG_ASF_DEMUXER 0 ++#define CONFIG_ASF_O_DEMUXER 0 ++#define CONFIG_ASS_DEMUXER 0 ++#define CONFIG_AST_DEMUXER 0 ++#define CONFIG_AU_DEMUXER 0 ++#define CONFIG_AV1_DEMUXER 0 ++#define CONFIG_AVI_DEMUXER 1 ++#define CONFIG_AVISYNTH_DEMUXER 0 ++#define CONFIG_AVR_DEMUXER 0 ++#define CONFIG_AVS_DEMUXER 0 ++#define CONFIG_AVS2_DEMUXER 0 ++#define CONFIG_BETHSOFTVID_DEMUXER 0 ++#define CONFIG_BFI_DEMUXER 0 ++#define CONFIG_BINTEXT_DEMUXER 0 ++#define CONFIG_BINK_DEMUXER 0 ++#define CONFIG_BIT_DEMUXER 0 ++#define CONFIG_BMV_DEMUXER 0 ++#define CONFIG_BFSTM_DEMUXER 0 ++#define CONFIG_BRSTM_DEMUXER 0 ++#define CONFIG_BOA_DEMUXER 0 ++#define CONFIG_C93_DEMUXER 0 ++#define CONFIG_CAF_DEMUXER 0 ++#define CONFIG_CAVSVIDEO_DEMUXER 0 ++#define CONFIG_CDG_DEMUXER 0 ++#define CONFIG_CDXL_DEMUXER 0 ++#define CONFIG_CINE_DEMUXER 0 ++#define CONFIG_CODEC2_DEMUXER 0 ++#define CONFIG_CODEC2RAW_DEMUXER 0 ++#define CONFIG_CONCAT_DEMUXER 0 ++#define CONFIG_DASH_DEMUXER 0 ++#define CONFIG_DATA_DEMUXER 0 ++#define CONFIG_DAUD_DEMUXER 0 ++#define CONFIG_DCSTR_DEMUXER 0 ++#define CONFIG_DERF_DEMUXER 0 ++#define CONFIG_DFA_DEMUXER 0 ++#define CONFIG_DHAV_DEMUXER 0 ++#define CONFIG_DIRAC_DEMUXER 0 ++#define CONFIG_DNXHD_DEMUXER 0 ++#define CONFIG_DSF_DEMUXER 0 ++#define CONFIG_DSICIN_DEMUXER 0 ++#define CONFIG_DSS_DEMUXER 0 ++#define CONFIG_DTS_DEMUXER 0 ++#define CONFIG_DTSHD_DEMUXER 0 ++#define CONFIG_DV_DEMUXER 0 ++#define CONFIG_DVBSUB_DEMUXER 0 ++#define CONFIG_DVBTXT_DEMUXER 0 ++#define CONFIG_DXA_DEMUXER 0 ++#define CONFIG_EA_DEMUXER 0 ++#define CONFIG_EA_CDATA_DEMUXER 0 ++#define CONFIG_EAC3_DEMUXER 0 ++#define CONFIG_EPAF_DEMUXER 0 ++#define CONFIG_FFMETADATA_DEMUXER 0 ++#define CONFIG_FILMSTRIP_DEMUXER 0 ++#define CONFIG_FITS_DEMUXER 0 ++#define CONFIG_FLAC_DEMUXER 1 ++#define CONFIG_FLIC_DEMUXER 0 ++#define CONFIG_FLV_DEMUXER 0 ++#define CONFIG_LIVE_FLV_DEMUXER 0 ++#define CONFIG_FOURXM_DEMUXER 0 ++#define CONFIG_FRM_DEMUXER 0 ++#define CONFIG_FSB_DEMUXER 0 ++#define CONFIG_FWSE_DEMUXER 0 ++#define CONFIG_G722_DEMUXER 0 ++#define CONFIG_G723_1_DEMUXER 0 ++#define CONFIG_G726_DEMUXER 0 ++#define CONFIG_G726LE_DEMUXER 0 ++#define CONFIG_G729_DEMUXER 0 ++#define CONFIG_GDV_DEMUXER 0 ++#define CONFIG_GENH_DEMUXER 0 ++#define CONFIG_GIF_DEMUXER 0 ++#define CONFIG_GSM_DEMUXER 0 ++#define CONFIG_GXF_DEMUXER 0 ++#define CONFIG_H261_DEMUXER 0 ++#define CONFIG_H263_DEMUXER 0 ++#define CONFIG_H264_DEMUXER 0 ++#define CONFIG_HCA_DEMUXER 0 ++#define CONFIG_HCOM_DEMUXER 0 ++#define CONFIG_HEVC_DEMUXER 0 ++#define CONFIG_HLS_DEMUXER 0 ++#define CONFIG_HNM_DEMUXER 0 ++#define CONFIG_ICO_DEMUXER 0 ++#define CONFIG_IDCIN_DEMUXER 0 ++#define CONFIG_IDF_DEMUXER 0 ++#define CONFIG_IFF_DEMUXER 0 ++#define CONFIG_IFV_DEMUXER 0 ++#define CONFIG_ILBC_DEMUXER 0 ++#define CONFIG_IMAGE2_DEMUXER 0 ++#define CONFIG_IMAGE2PIPE_DEMUXER 0 ++#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 ++#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 ++#define CONFIG_INGENIENT_DEMUXER 0 ++#define CONFIG_IPMOVIE_DEMUXER 0 ++#define CONFIG_IRCAM_DEMUXER 0 ++#define CONFIG_ISS_DEMUXER 0 ++#define CONFIG_IV8_DEMUXER 0 ++#define CONFIG_IVF_DEMUXER 0 ++#define CONFIG_IVR_DEMUXER 0 ++#define CONFIG_JACOSUB_DEMUXER 0 ++#define CONFIG_JV_DEMUXER 0 ++#define CONFIG_KUX_DEMUXER 0 ++#define CONFIG_KVAG_DEMUXER 0 ++#define CONFIG_LMLM4_DEMUXER 0 ++#define CONFIG_LOAS_DEMUXER 0 ++#define CONFIG_LRC_DEMUXER 0 ++#define CONFIG_LVF_DEMUXER 0 ++#define CONFIG_LXF_DEMUXER 0 ++#define CONFIG_M4V_DEMUXER 0 ++#define CONFIG_MCC_DEMUXER 0 ++#define CONFIG_MATROSKA_DEMUXER 1 ++#define CONFIG_MGSTS_DEMUXER 0 ++#define CONFIG_MICRODVD_DEMUXER 0 ++#define CONFIG_MJPEG_DEMUXER 0 ++#define CONFIG_MJPEG_2000_DEMUXER 0 ++#define CONFIG_MLP_DEMUXER 0 ++#define CONFIG_MLV_DEMUXER 0 ++#define CONFIG_MM_DEMUXER 0 ++#define CONFIG_MMF_DEMUXER 0 ++#define CONFIG_MOV_DEMUXER 1 ++#define CONFIG_MP3_DEMUXER 1 ++#define CONFIG_MPC_DEMUXER 0 ++#define CONFIG_MPC8_DEMUXER 0 ++#define CONFIG_MPEGPS_DEMUXER 0 ++#define CONFIG_MPEGTS_DEMUXER 0 ++#define CONFIG_MPEGTSRAW_DEMUXER 0 ++#define CONFIG_MPEGVIDEO_DEMUXER 0 ++#define CONFIG_MPJPEG_DEMUXER 0 ++#define CONFIG_MPL2_DEMUXER 0 ++#define CONFIG_MPSUB_DEMUXER 0 ++#define CONFIG_MSF_DEMUXER 0 ++#define CONFIG_MSNWC_TCP_DEMUXER 0 ++#define CONFIG_MTAF_DEMUXER 0 ++#define CONFIG_MTV_DEMUXER 0 ++#define CONFIG_MUSX_DEMUXER 0 ++#define CONFIG_MV_DEMUXER 0 ++#define CONFIG_MVI_DEMUXER 0 ++#define CONFIG_MXF_DEMUXER 0 ++#define CONFIG_MXG_DEMUXER 0 ++#define CONFIG_NC_DEMUXER 0 ++#define CONFIG_NISTSPHERE_DEMUXER 0 ++#define CONFIG_NSP_DEMUXER 0 ++#define CONFIG_NSV_DEMUXER 0 ++#define CONFIG_NUT_DEMUXER 0 ++#define CONFIG_NUV_DEMUXER 0 ++#define CONFIG_OBU_DEMUXER 0 ++#define CONFIG_OGG_DEMUXER 1 ++#define CONFIG_OMA_DEMUXER 0 ++#define CONFIG_PAF_DEMUXER 0 ++#define CONFIG_PCM_ALAW_DEMUXER 0 ++#define CONFIG_PCM_MULAW_DEMUXER 0 ++#define CONFIG_PCM_VIDC_DEMUXER 0 ++#define CONFIG_PCM_F64BE_DEMUXER 0 ++#define CONFIG_PCM_F64LE_DEMUXER 0 ++#define CONFIG_PCM_F32BE_DEMUXER 0 ++#define CONFIG_PCM_F32LE_DEMUXER 0 ++#define CONFIG_PCM_S32BE_DEMUXER 0 ++#define CONFIG_PCM_S32LE_DEMUXER 0 ++#define CONFIG_PCM_S24BE_DEMUXER 0 ++#define CONFIG_PCM_S24LE_DEMUXER 0 ++#define CONFIG_PCM_S16BE_DEMUXER 0 ++#define CONFIG_PCM_S16LE_DEMUXER 0 ++#define CONFIG_PCM_S8_DEMUXER 0 ++#define CONFIG_PCM_U32BE_DEMUXER 0 ++#define CONFIG_PCM_U32LE_DEMUXER 0 ++#define CONFIG_PCM_U24BE_DEMUXER 0 ++#define CONFIG_PCM_U24LE_DEMUXER 0 ++#define CONFIG_PCM_U16BE_DEMUXER 0 ++#define CONFIG_PCM_U16LE_DEMUXER 0 ++#define CONFIG_PCM_U8_DEMUXER 0 ++#define CONFIG_PJS_DEMUXER 0 ++#define CONFIG_PMP_DEMUXER 0 ++#define CONFIG_PP_BNK_DEMUXER 0 ++#define CONFIG_PVA_DEMUXER 0 ++#define CONFIG_PVF_DEMUXER 0 ++#define CONFIG_QCP_DEMUXER 0 ++#define CONFIG_R3D_DEMUXER 0 ++#define CONFIG_RAWVIDEO_DEMUXER 0 ++#define CONFIG_REALTEXT_DEMUXER 0 ++#define CONFIG_REDSPARK_DEMUXER 0 ++#define CONFIG_RL2_DEMUXER 0 ++#define CONFIG_RM_DEMUXER 0 ++#define CONFIG_ROQ_DEMUXER 0 ++#define CONFIG_RPL_DEMUXER 0 ++#define CONFIG_RSD_DEMUXER 0 ++#define CONFIG_RSO_DEMUXER 0 ++#define CONFIG_RTP_DEMUXER 0 ++#define CONFIG_RTSP_DEMUXER 0 ++#define CONFIG_S337M_DEMUXER 0 ++#define CONFIG_SAMI_DEMUXER 0 ++#define CONFIG_SAP_DEMUXER 0 ++#define CONFIG_SBC_DEMUXER 0 ++#define CONFIG_SBG_DEMUXER 0 ++#define CONFIG_SCC_DEMUXER 0 ++#define CONFIG_SDP_DEMUXER 0 ++#define CONFIG_SDR2_DEMUXER 0 ++#define CONFIG_SDS_DEMUXER 0 ++#define CONFIG_SDX_DEMUXER 0 ++#define CONFIG_SEGAFILM_DEMUXER 0 ++#define CONFIG_SER_DEMUXER 0 ++#define CONFIG_SHORTEN_DEMUXER 0 ++#define CONFIG_SIFF_DEMUXER 0 ++#define CONFIG_SLN_DEMUXER 0 ++#define CONFIG_SMACKER_DEMUXER 0 ++#define CONFIG_SMJPEG_DEMUXER 0 ++#define CONFIG_SMUSH_DEMUXER 0 ++#define CONFIG_SOL_DEMUXER 0 ++#define CONFIG_SOX_DEMUXER 0 ++#define CONFIG_SPDIF_DEMUXER 0 ++#define CONFIG_SRT_DEMUXER 0 ++#define CONFIG_STR_DEMUXER 0 ++#define CONFIG_STL_DEMUXER 0 ++#define CONFIG_SUBVIEWER1_DEMUXER 0 ++#define CONFIG_SUBVIEWER_DEMUXER 0 ++#define CONFIG_SUP_DEMUXER 0 ++#define CONFIG_SVAG_DEMUXER 0 ++#define CONFIG_SWF_DEMUXER 0 ++#define CONFIG_TAK_DEMUXER 0 ++#define CONFIG_TEDCAPTIONS_DEMUXER 0 ++#define CONFIG_THP_DEMUXER 0 ++#define CONFIG_THREEDOSTR_DEMUXER 0 ++#define CONFIG_TIERTEXSEQ_DEMUXER 0 ++#define CONFIG_TMV_DEMUXER 0 ++#define CONFIG_TRUEHD_DEMUXER 0 ++#define CONFIG_TTA_DEMUXER 0 ++#define CONFIG_TXD_DEMUXER 0 ++#define CONFIG_TTY_DEMUXER 0 ++#define CONFIG_TY_DEMUXER 0 ++#define CONFIG_V210_DEMUXER 0 ++#define CONFIG_V210X_DEMUXER 0 ++#define CONFIG_VAG_DEMUXER 0 ++#define CONFIG_VC1_DEMUXER 0 ++#define CONFIG_VC1T_DEMUXER 0 ++#define CONFIG_VIVIDAS_DEMUXER 0 ++#define CONFIG_VIVO_DEMUXER 0 ++#define CONFIG_VMD_DEMUXER 0 ++#define CONFIG_VOBSUB_DEMUXER 0 ++#define CONFIG_VOC_DEMUXER 0 ++#define CONFIG_VPK_DEMUXER 0 ++#define CONFIG_VPLAYER_DEMUXER 0 ++#define CONFIG_VQF_DEMUXER 0 ++#define CONFIG_W64_DEMUXER 0 ++#define CONFIG_WAV_DEMUXER 1 ++#define CONFIG_WC3_DEMUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 ++#define CONFIG_WEBVTT_DEMUXER 0 ++#define CONFIG_WSAUD_DEMUXER 0 ++#define CONFIG_WSD_DEMUXER 0 ++#define CONFIG_WSVQA_DEMUXER 0 ++#define CONFIG_WTV_DEMUXER 0 ++#define CONFIG_WVE_DEMUXER 0 ++#define CONFIG_WV_DEMUXER 0 ++#define CONFIG_XA_DEMUXER 0 ++#define CONFIG_XBIN_DEMUXER 0 ++#define CONFIG_XMV_DEMUXER 0 ++#define CONFIG_XVAG_DEMUXER 0 ++#define CONFIG_XWMA_DEMUXER 0 ++#define CONFIG_YOP_DEMUXER 0 ++#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 ++#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 ++#define CONFIG_LIBGME_DEMUXER 0 ++#define CONFIG_LIBMODPLUG_DEMUXER 0 ++#define CONFIG_LIBOPENMPT_DEMUXER 0 ++#define CONFIG_VAPOURSYNTH_DEMUXER 0 ++#define CONFIG_A64_MUXER 0 ++#define CONFIG_AC3_MUXER 0 ++#define CONFIG_ADTS_MUXER 0 ++#define CONFIG_ADX_MUXER 0 ++#define CONFIG_AIFF_MUXER 0 ++#define CONFIG_AMR_MUXER 0 ++#define CONFIG_APM_MUXER 0 ++#define CONFIG_APNG_MUXER 0 ++#define CONFIG_APTX_MUXER 0 ++#define CONFIG_APTX_HD_MUXER 0 ++#define CONFIG_ARGO_ASF_MUXER 0 ++#define CONFIG_ASF_MUXER 0 ++#define CONFIG_ASS_MUXER 0 ++#define CONFIG_AST_MUXER 0 ++#define CONFIG_ASF_STREAM_MUXER 0 ++#define CONFIG_AU_MUXER 0 ++#define CONFIG_AVI_MUXER 0 ++#define CONFIG_AVM2_MUXER 0 ++#define CONFIG_AVS2_MUXER 0 ++#define CONFIG_BIT_MUXER 0 ++#define CONFIG_CAF_MUXER 0 ++#define CONFIG_CAVSVIDEO_MUXER 0 ++#define CONFIG_CODEC2_MUXER 0 ++#define CONFIG_CODEC2RAW_MUXER 0 ++#define CONFIG_CRC_MUXER 0 ++#define CONFIG_DASH_MUXER 0 ++#define CONFIG_DATA_MUXER 0 ++#define CONFIG_DAUD_MUXER 0 ++#define CONFIG_DIRAC_MUXER 0 ++#define CONFIG_DNXHD_MUXER 0 ++#define CONFIG_DTS_MUXER 0 ++#define CONFIG_DV_MUXER 0 ++#define CONFIG_EAC3_MUXER 0 ++#define CONFIG_F4V_MUXER 0 ++#define CONFIG_FFMETADATA_MUXER 0 ++#define CONFIG_FIFO_MUXER 0 ++#define CONFIG_FIFO_TEST_MUXER 0 ++#define CONFIG_FILMSTRIP_MUXER 0 ++#define CONFIG_FITS_MUXER 0 ++#define CONFIG_FLAC_MUXER 0 ++#define CONFIG_FLV_MUXER 0 ++#define CONFIG_FRAMECRC_MUXER 0 ++#define CONFIG_FRAMEHASH_MUXER 0 ++#define CONFIG_FRAMEMD5_MUXER 0 ++#define CONFIG_G722_MUXER 0 ++#define CONFIG_G723_1_MUXER 0 ++#define CONFIG_G726_MUXER 0 ++#define CONFIG_G726LE_MUXER 0 ++#define CONFIG_GIF_MUXER 0 ++#define CONFIG_GSM_MUXER 0 ++#define CONFIG_GXF_MUXER 0 ++#define CONFIG_H261_MUXER 0 ++#define CONFIG_H263_MUXER 0 ++#define CONFIG_H264_MUXER 0 ++#define CONFIG_HASH_MUXER 0 ++#define CONFIG_HDS_MUXER 0 ++#define CONFIG_HEVC_MUXER 0 ++#define CONFIG_HLS_MUXER 0 ++#define CONFIG_ICO_MUXER 0 ++#define CONFIG_ILBC_MUXER 0 ++#define CONFIG_IMAGE2_MUXER 0 ++#define CONFIG_IMAGE2PIPE_MUXER 0 ++#define CONFIG_IPOD_MUXER 0 ++#define CONFIG_IRCAM_MUXER 0 ++#define CONFIG_ISMV_MUXER 0 ++#define CONFIG_IVF_MUXER 0 ++#define CONFIG_JACOSUB_MUXER 0 ++#define CONFIG_KVAG_MUXER 0 ++#define CONFIG_LATM_MUXER 0 ++#define CONFIG_LRC_MUXER 0 ++#define CONFIG_M4V_MUXER 0 ++#define CONFIG_MD5_MUXER 0 ++#define CONFIG_MATROSKA_MUXER 0 ++#define CONFIG_MATROSKA_AUDIO_MUXER 0 ++#define CONFIG_MICRODVD_MUXER 0 ++#define CONFIG_MJPEG_MUXER 0 ++#define CONFIG_MLP_MUXER 0 ++#define CONFIG_MMF_MUXER 0 ++#define CONFIG_MOV_MUXER 0 ++#define CONFIG_MP2_MUXER 0 ++#define CONFIG_MP3_MUXER 0 ++#define CONFIG_MP4_MUXER 0 ++#define CONFIG_MPEG1SYSTEM_MUXER 0 ++#define CONFIG_MPEG1VCD_MUXER 0 ++#define CONFIG_MPEG1VIDEO_MUXER 0 ++#define CONFIG_MPEG2DVD_MUXER 0 ++#define CONFIG_MPEG2SVCD_MUXER 0 ++#define CONFIG_MPEG2VIDEO_MUXER 0 ++#define CONFIG_MPEG2VOB_MUXER 0 ++#define CONFIG_MPEGTS_MUXER 0 ++#define CONFIG_MPJPEG_MUXER 0 ++#define CONFIG_MXF_MUXER 0 ++#define CONFIG_MXF_D10_MUXER 0 ++#define CONFIG_MXF_OPATOM_MUXER 0 ++#define CONFIG_NULL_MUXER 0 ++#define CONFIG_NUT_MUXER 0 ++#define CONFIG_OGA_MUXER 0 ++#define CONFIG_OGG_MUXER 0 ++#define CONFIG_OGV_MUXER 0 ++#define CONFIG_OMA_MUXER 0 ++#define CONFIG_OPUS_MUXER 0 ++#define CONFIG_PCM_ALAW_MUXER 0 ++#define CONFIG_PCM_MULAW_MUXER 0 ++#define CONFIG_PCM_VIDC_MUXER 0 ++#define CONFIG_PCM_F64BE_MUXER 0 ++#define CONFIG_PCM_F64LE_MUXER 0 ++#define CONFIG_PCM_F32BE_MUXER 0 ++#define CONFIG_PCM_F32LE_MUXER 0 ++#define CONFIG_PCM_S32BE_MUXER 0 ++#define CONFIG_PCM_S32LE_MUXER 0 ++#define CONFIG_PCM_S24BE_MUXER 0 ++#define CONFIG_PCM_S24LE_MUXER 0 ++#define CONFIG_PCM_S16BE_MUXER 0 ++#define CONFIG_PCM_S16LE_MUXER 0 ++#define CONFIG_PCM_S8_MUXER 0 ++#define CONFIG_PCM_U32BE_MUXER 0 ++#define CONFIG_PCM_U32LE_MUXER 0 ++#define CONFIG_PCM_U24BE_MUXER 0 ++#define CONFIG_PCM_U24LE_MUXER 0 ++#define CONFIG_PCM_U16BE_MUXER 0 ++#define CONFIG_PCM_U16LE_MUXER 0 ++#define CONFIG_PCM_U8_MUXER 0 ++#define CONFIG_PSP_MUXER 0 ++#define CONFIG_RAWVIDEO_MUXER 0 ++#define CONFIG_RM_MUXER 0 ++#define CONFIG_ROQ_MUXER 0 ++#define CONFIG_RSO_MUXER 0 ++#define CONFIG_RTP_MUXER 0 ++#define CONFIG_RTP_MPEGTS_MUXER 0 ++#define CONFIG_RTSP_MUXER 0 ++#define CONFIG_SAP_MUXER 0 ++#define CONFIG_SBC_MUXER 0 ++#define CONFIG_SCC_MUXER 0 ++#define CONFIG_SEGAFILM_MUXER 0 ++#define CONFIG_SEGMENT_MUXER 0 ++#define CONFIG_STREAM_SEGMENT_MUXER 0 ++#define CONFIG_SINGLEJPEG_MUXER 0 ++#define CONFIG_SMJPEG_MUXER 0 ++#define CONFIG_SMOOTHSTREAMING_MUXER 0 ++#define CONFIG_SOX_MUXER 0 ++#define CONFIG_SPX_MUXER 0 ++#define CONFIG_SPDIF_MUXER 0 ++#define CONFIG_SRT_MUXER 0 ++#define CONFIG_STREAMHASH_MUXER 0 ++#define CONFIG_SUP_MUXER 0 ++#define CONFIG_SWF_MUXER 0 ++#define CONFIG_TEE_MUXER 0 ++#define CONFIG_TG2_MUXER 0 ++#define CONFIG_TGP_MUXER 0 ++#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 ++#define CONFIG_TRUEHD_MUXER 0 ++#define CONFIG_TTA_MUXER 0 ++#define CONFIG_UNCODEDFRAMECRC_MUXER 0 ++#define CONFIG_VC1_MUXER 0 ++#define CONFIG_VC1T_MUXER 0 ++#define CONFIG_VOC_MUXER 0 ++#define CONFIG_W64_MUXER 0 ++#define CONFIG_WAV_MUXER 0 ++#define CONFIG_WEBM_MUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 ++#define CONFIG_WEBM_CHUNK_MUXER 0 ++#define CONFIG_WEBP_MUXER 0 ++#define CONFIG_WEBVTT_MUXER 0 ++#define CONFIG_WTV_MUXER 0 ++#define CONFIG_WV_MUXER 0 ++#define CONFIG_YUV4MPEGPIPE_MUXER 0 ++#define CONFIG_CHROMAPRINT_MUXER 0 ++#define CONFIG_ASYNC_PROTOCOL 0 ++#define CONFIG_BLURAY_PROTOCOL 0 ++#define CONFIG_CACHE_PROTOCOL 0 ++#define CONFIG_CONCAT_PROTOCOL 0 ++#define CONFIG_CRYPTO_PROTOCOL 0 ++#define CONFIG_DATA_PROTOCOL 0 ++#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 ++#define CONFIG_FFRTMPHTTP_PROTOCOL 0 ++#define CONFIG_FILE_PROTOCOL 0 ++#define CONFIG_FTP_PROTOCOL 0 ++#define CONFIG_GOPHER_PROTOCOL 0 ++#define CONFIG_HLS_PROTOCOL 0 ++#define CONFIG_HTTP_PROTOCOL 0 ++#define CONFIG_HTTPPROXY_PROTOCOL 0 ++#define CONFIG_HTTPS_PROTOCOL 0 ++#define CONFIG_ICECAST_PROTOCOL 0 ++#define CONFIG_MMSH_PROTOCOL 0 ++#define CONFIG_MMST_PROTOCOL 0 ++#define CONFIG_MD5_PROTOCOL 0 ++#define CONFIG_PIPE_PROTOCOL 0 ++#define CONFIG_PROMPEG_PROTOCOL 0 ++#define CONFIG_RTMP_PROTOCOL 0 ++#define CONFIG_RTMPE_PROTOCOL 0 ++#define CONFIG_RTMPS_PROTOCOL 0 ++#define CONFIG_RTMPT_PROTOCOL 0 ++#define CONFIG_RTMPTE_PROTOCOL 0 ++#define CONFIG_RTMPTS_PROTOCOL 0 ++#define CONFIG_RTP_PROTOCOL 0 ++#define CONFIG_SCTP_PROTOCOL 0 ++#define CONFIG_SRTP_PROTOCOL 0 ++#define CONFIG_SUBFILE_PROTOCOL 0 ++#define CONFIG_TEE_PROTOCOL 0 ++#define CONFIG_TCP_PROTOCOL 0 ++#define CONFIG_TLS_PROTOCOL 0 ++#define CONFIG_UDP_PROTOCOL 0 ++#define CONFIG_UDPLITE_PROTOCOL 0 ++#define CONFIG_UNIX_PROTOCOL 0 ++#define CONFIG_LIBAMQP_PROTOCOL 0 ++#define CONFIG_LIBRTMP_PROTOCOL 0 ++#define CONFIG_LIBRTMPE_PROTOCOL 0 ++#define CONFIG_LIBRTMPS_PROTOCOL 0 ++#define CONFIG_LIBRTMPT_PROTOCOL 0 ++#define CONFIG_LIBRTMPTE_PROTOCOL 0 ++#define CONFIG_LIBSRT_PROTOCOL 0 ++#define CONFIG_LIBSSH_PROTOCOL 0 ++#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 ++#define CONFIG_LIBZMQ_PROTOCOL 0 ++#endif /* FFMPEG_CONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/bsf_list.c +@@ -0,0 +1,3 @@ ++static const AVBitStreamFilter * const bitstream_filters[] = { ++ &ff_null_bsf, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/codec_list.c +@@ -0,0 +1,25 @@ ++static const AVCodec * const codec_list[] = { ++ &ff_h263_decoder, ++ &ff_h264_decoder, ++ &ff_mpeg4_decoder, ++ &ff_theora_decoder, ++ &ff_vp3_decoder, ++ &ff_vp8_decoder, ++ &ff_aac_decoder, ++ &ff_amrnb_decoder, ++ &ff_amrwb_decoder, ++ &ff_flac_decoder, ++ &ff_gsm_ms_decoder, ++ &ff_mp3_decoder, ++ &ff_vorbis_decoder, ++ &ff_pcm_alaw_decoder, ++ &ff_pcm_f32le_decoder, ++ &ff_pcm_mulaw_decoder, ++ &ff_pcm_s16be_decoder, ++ &ff_pcm_s16le_decoder, ++ &ff_pcm_s24be_decoder, ++ &ff_pcm_s24le_decoder, ++ &ff_pcm_s32le_decoder, ++ &ff_pcm_u8_decoder, ++ &ff_libopus_decoder, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavcodec/parser_list.c +@@ -0,0 +1,14 @@ ++static const AVCodecParser * const parser_list[] = { ++ &ff_aac_parser, ++ &ff_flac_parser, ++ &ff_gsm_parser, ++ &ff_h263_parser, ++ &ff_h264_parser, ++ &ff_mpeg4video_parser, ++ &ff_mpegaudio_parser, ++ &ff_opus_parser, ++ &ff_vorbis_parser, ++ &ff_vp3_parser, ++ &ff_vp8_parser, ++ &ff_vp9_parser, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/demuxer_list.c +@@ -0,0 +1,11 @@ ++static const AVInputFormat * const demuxer_list[] = { ++ &ff_aac_demuxer, ++ &ff_amr_demuxer, ++ &ff_avi_demuxer, ++ &ff_flac_demuxer, ++ &ff_matroska_demuxer, ++ &ff_mov_demuxer, ++ &ff_mp3_demuxer, ++ &ff_ogg_demuxer, ++ &ff_wav_demuxer, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/muxer_list.c +@@ -0,0 +1,2 @@ ++static const AVOutputFormat * const muxer_list[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavformat/protocol_list.c +@@ -0,0 +1,2 @@ ++static const URLProtocol * const url_protocols[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/ChromeOS/linux/riscv64/libavutil/avconfig.h +@@ -0,0 +1,6 @@ ++/* Generated by ffmpeg configure */ ++#ifndef AVUTIL_AVCONFIG_H ++#define AVUTIL_AVCONFIG_H ++#define AV_HAVE_BIGENDIAN 0 ++#define AV_HAVE_FAST_UNALIGNED 0 ++#endif /* AVUTIL_AVCONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/config.h +@@ -0,0 +1,2626 @@ ++/* Automatically generated by configure - do not modify! */ ++#ifndef FFMPEG_CONFIG_H ++#define FFMPEG_CONFIG_H ++/* #define FFMPEG_CONFIGURATION "--disable-everything --disable-all --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --enable-avcodec --enable-avformat --enable-avutil --enable-fft --enable-rdft --enable-static --enable-libopus --disable-debug --disable-bzlib --disable-error-resilience --disable-iconv --disable-lzo --disable-network --disable-schannel --disable-sdl2 --disable-symver --disable-xlib --disable-zlib --disable-securetransport --disable-faan --disable-alsa --disable-autodetect --enable-decoder='vorbis,libopus,flac' --enable-decoder='pcm_u8,pcm_s16le,pcm_s24le,pcm_s32le,pcm_f32le,mp3' --enable-decoder='pcm_s16be,pcm_s24be,pcm_mulaw,pcm_alaw' --enable-demuxer='ogg,matroska,wav,flac,mp3,mov' --enable-parser='opus,vorbis,flac,mpegaudio,vp9' --extra-cflags=-I/root/qtwebengine-opensource-src/qtwebengine-opensource-src-5.15.12+dfsg/src/3rdparty/chromium/third_party/opus/src/include --disable-linux-perf --x86asmexe=nasm --optflags='\"-O2\"' --enable-decoder='theora,vp8' --enable-parser='vp3,vp8' --arch=riscv64" -- elide long configuration string from binary */ ++#define FFMPEG_LICENSE "LGPL version 2.1 or later" ++#define CONFIG_THIS_YEAR 2020 ++#define FFMPEG_DATADIR "/usr/local/share/ffmpeg" ++#define AVCONV_DATADIR "/usr/local/share/ffmpeg" ++#define CC_IDENT "gcc 12 (Debian 12.2.0-14)" ++#define av_restrict restrict ++#define EXTERN_PREFIX "" ++#define EXTERN_ASM ++#define BUILDSUF "" ++#define SLIBSUF ".so" ++#define HAVE_MMX2 HAVE_MMXEXT ++#define SWS_MAX_FILTER_SIZE 256 ++#define ARCH_AARCH64 0 ++#define ARCH_ALPHA 0 ++#define ARCH_ARM 0 ++#define ARCH_AVR32 0 ++#define ARCH_AVR32_AP 0 ++#define ARCH_AVR32_UC 0 ++#define ARCH_BFIN 0 ++#define ARCH_IA64 0 ++#define ARCH_M68K 0 ++#define ARCH_MIPS 0 ++#define ARCH_MIPS64 0 ++#define ARCH_PARISC 0 ++#define ARCH_PPC 0 ++#define ARCH_PPC64 0 ++#define ARCH_RISCV 1 ++#define ARCH_S390 0 ++#define ARCH_SH4 0 ++#define ARCH_SPARC 0 ++#define ARCH_SPARC64 0 ++#define ARCH_TILEGX 0 ++#define ARCH_TILEPRO 0 ++#define ARCH_TOMI 0 ++#define ARCH_X86 0 ++#define ARCH_X86_32 0 ++#define ARCH_X86_64 0 ++#define HAVE_ARMV5TE 0 ++#define HAVE_ARMV6 0 ++#define HAVE_ARMV6T2 0 ++#define HAVE_ARMV8 0 ++#define HAVE_NEON 0 ++#define HAVE_VFP 0 ++#define HAVE_VFPV3 0 ++#define HAVE_SETEND 0 ++#define HAVE_ALTIVEC 0 ++#define HAVE_DCBZL 0 ++#define HAVE_LDBRX 0 ++#define HAVE_POWER8 0 ++#define HAVE_PPC4XX 0 ++#define HAVE_VSX 0 ++#define HAVE_AESNI 0 ++#define HAVE_AMD3DNOW 0 ++#define HAVE_AMD3DNOWEXT 0 ++#define HAVE_AVX 0 ++#define HAVE_AVX2 0 ++#define HAVE_AVX512 0 ++#define HAVE_FMA3 0 ++#define HAVE_FMA4 0 ++#define HAVE_MMX 0 ++#define HAVE_MMXEXT 0 ++#define HAVE_SSE 0 ++#define HAVE_SSE2 0 ++#define HAVE_SSE3 0 ++#define HAVE_SSE4 0 ++#define HAVE_SSE42 0 ++#define HAVE_SSSE3 0 ++#define HAVE_XOP 0 ++#define HAVE_CPUNOP 0 ++#define HAVE_I686 0 ++#define HAVE_MIPSFPU 0 ++#define HAVE_MIPS32R2 0 ++#define HAVE_MIPS32R5 0 ++#define HAVE_MIPS64R2 0 ++#define HAVE_MIPS32R6 0 ++#define HAVE_MIPS64R6 0 ++#define HAVE_MIPSDSP 0 ++#define HAVE_MIPSDSPR2 0 ++#define HAVE_MSA 0 ++#define HAVE_MSA2 0 ++#define HAVE_LOONGSON2 0 ++#define HAVE_LOONGSON3 0 ++#define HAVE_MMI 0 ++#define HAVE_ARMV5TE_EXTERNAL 0 ++#define HAVE_ARMV6_EXTERNAL 0 ++#define HAVE_ARMV6T2_EXTERNAL 0 ++#define HAVE_ARMV8_EXTERNAL 0 ++#define HAVE_NEON_EXTERNAL 0 ++#define HAVE_VFP_EXTERNAL 0 ++#define HAVE_VFPV3_EXTERNAL 0 ++#define HAVE_SETEND_EXTERNAL 0 ++#define HAVE_ALTIVEC_EXTERNAL 0 ++#define HAVE_DCBZL_EXTERNAL 0 ++#define HAVE_LDBRX_EXTERNAL 0 ++#define HAVE_POWER8_EXTERNAL 0 ++#define HAVE_PPC4XX_EXTERNAL 0 ++#define HAVE_VSX_EXTERNAL 0 ++#define HAVE_AESNI_EXTERNAL 0 ++#define HAVE_AMD3DNOW_EXTERNAL 0 ++#define HAVE_AMD3DNOWEXT_EXTERNAL 0 ++#define HAVE_AVX_EXTERNAL 0 ++#define HAVE_AVX2_EXTERNAL 0 ++#define HAVE_AVX512_EXTERNAL 0 ++#define HAVE_FMA3_EXTERNAL 0 ++#define HAVE_FMA4_EXTERNAL 0 ++#define HAVE_MMX_EXTERNAL 0 ++#define HAVE_MMXEXT_EXTERNAL 0 ++#define HAVE_SSE_EXTERNAL 0 ++#define HAVE_SSE2_EXTERNAL 0 ++#define HAVE_SSE3_EXTERNAL 0 ++#define HAVE_SSE4_EXTERNAL 0 ++#define HAVE_SSE42_EXTERNAL 0 ++#define HAVE_SSSE3_EXTERNAL 0 ++#define HAVE_XOP_EXTERNAL 0 ++#define HAVE_CPUNOP_EXTERNAL 0 ++#define HAVE_I686_EXTERNAL 0 ++#define HAVE_MIPSFPU_EXTERNAL 0 ++#define HAVE_MIPS32R2_EXTERNAL 0 ++#define HAVE_MIPS32R5_EXTERNAL 0 ++#define HAVE_MIPS64R2_EXTERNAL 0 ++#define HAVE_MIPS32R6_EXTERNAL 0 ++#define HAVE_MIPS64R6_EXTERNAL 0 ++#define HAVE_MIPSDSP_EXTERNAL 0 ++#define HAVE_MIPSDSPR2_EXTERNAL 0 ++#define HAVE_MSA_EXTERNAL 0 ++#define HAVE_MSA2_EXTERNAL 0 ++#define HAVE_LOONGSON2_EXTERNAL 0 ++#define HAVE_LOONGSON3_EXTERNAL 0 ++#define HAVE_MMI_EXTERNAL 0 ++#define HAVE_ARMV5TE_INLINE 0 ++#define HAVE_ARMV6_INLINE 0 ++#define HAVE_ARMV6T2_INLINE 0 ++#define HAVE_ARMV8_INLINE 0 ++#define HAVE_NEON_INLINE 0 ++#define HAVE_VFP_INLINE 0 ++#define HAVE_VFPV3_INLINE 0 ++#define HAVE_SETEND_INLINE 0 ++#define HAVE_ALTIVEC_INLINE 0 ++#define HAVE_DCBZL_INLINE 0 ++#define HAVE_LDBRX_INLINE 0 ++#define HAVE_POWER8_INLINE 0 ++#define HAVE_PPC4XX_INLINE 0 ++#define HAVE_VSX_INLINE 0 ++#define HAVE_AESNI_INLINE 0 ++#define HAVE_AMD3DNOW_INLINE 0 ++#define HAVE_AMD3DNOWEXT_INLINE 0 ++#define HAVE_AVX_INLINE 0 ++#define HAVE_AVX2_INLINE 0 ++#define HAVE_AVX512_INLINE 0 ++#define HAVE_FMA3_INLINE 0 ++#define HAVE_FMA4_INLINE 0 ++#define HAVE_MMX_INLINE 0 ++#define HAVE_MMXEXT_INLINE 0 ++#define HAVE_SSE_INLINE 0 ++#define HAVE_SSE2_INLINE 0 ++#define HAVE_SSE3_INLINE 0 ++#define HAVE_SSE4_INLINE 0 ++#define HAVE_SSE42_INLINE 0 ++#define HAVE_SSSE3_INLINE 0 ++#define HAVE_XOP_INLINE 0 ++#define HAVE_CPUNOP_INLINE 0 ++#define HAVE_I686_INLINE 0 ++#define HAVE_MIPSFPU_INLINE 0 ++#define HAVE_MIPS32R2_INLINE 0 ++#define HAVE_MIPS32R5_INLINE 0 ++#define HAVE_MIPS64R2_INLINE 0 ++#define HAVE_MIPS32R6_INLINE 0 ++#define HAVE_MIPS64R6_INLINE 0 ++#define HAVE_MIPSDSP_INLINE 0 ++#define HAVE_MIPSDSPR2_INLINE 0 ++#define HAVE_MSA_INLINE 0 ++#define HAVE_MSA2_INLINE 0 ++#define HAVE_LOONGSON2_INLINE 0 ++#define HAVE_LOONGSON3_INLINE 0 ++#define HAVE_MMI_INLINE 0 ++#define HAVE_ALIGNED_STACK 0 ++#define HAVE_FAST_64BIT 1 ++#define HAVE_FAST_CLZ 0 ++#define HAVE_FAST_CMOV 0 ++#define HAVE_LOCAL_ALIGNED 0 ++#define HAVE_SIMD_ALIGN_16 0 ++#define HAVE_SIMD_ALIGN_32 0 ++#define HAVE_SIMD_ALIGN_64 0 ++#define HAVE_ATOMIC_CAS_PTR 0 ++#define HAVE_MACHINE_RW_BARRIER 0 ++#define HAVE_MEMORYBARRIER 0 ++#define HAVE_MM_EMPTY 0 ++#define HAVE_RDTSC 0 ++#define HAVE_SEM_TIMEDWAIT 1 ++#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 ++#define HAVE_CABS 0 ++#define HAVE_CEXP 0 ++#define HAVE_INLINE_ASM 1 ++#define HAVE_SYMVER 0 ++#define HAVE_X86ASM 0 ++#define HAVE_BIGENDIAN 0 ++#define HAVE_FAST_UNALIGNED 0 ++#define HAVE_ARPA_INET_H 0 ++#define HAVE_ASM_TYPES_H 1 ++#define HAVE_CDIO_PARANOIA_H 0 ++#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 ++#define HAVE_CUDA_H 0 ++#define HAVE_DISPATCH_DISPATCH_H 0 ++#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 ++#define HAVE_DEV_IC_BT8XX_H 0 ++#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 ++#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 ++#define HAVE_DIRECT_H 0 ++#define HAVE_DIRENT_H 1 ++#define HAVE_DXGIDEBUG_H 0 ++#define HAVE_DXVA_H 0 ++#define HAVE_ES2_GL_H 0 ++#define HAVE_GSM_H 0 ++#define HAVE_IO_H 0 ++#define HAVE_LINUX_PERF_EVENT_H 1 ++#define HAVE_MACHINE_IOCTL_BT848_H 0 ++#define HAVE_MACHINE_IOCTL_METEOR_H 0 ++#define HAVE_MALLOC_H 1 ++#define HAVE_OPENCV2_CORE_CORE_C_H 0 ++#define HAVE_OPENGL_GL3_H 0 ++#define HAVE_POLL_H 1 ++#define HAVE_SYS_PARAM_H 1 ++#define HAVE_SYS_RESOURCE_H 1 ++#define HAVE_SYS_SELECT_H 1 ++#define HAVE_SYS_SOUNDCARD_H 1 ++#define HAVE_SYS_TIME_H 1 ++#define HAVE_SYS_UN_H 1 ++#define HAVE_SYS_VIDEOIO_H 0 ++#define HAVE_TERMIOS_H 1 ++#define HAVE_UDPLITE_H 0 ++#define HAVE_UNISTD_H 1 ++#define HAVE_VALGRIND_VALGRIND_H 0 /* #define HAVE_VALGRIND_VALGRIND_H 0 -- forced to 0. See https://crbug.com/590440 */ ++#define HAVE_WINDOWS_H 0 ++#define HAVE_WINSOCK2_H 0 ++#define HAVE_INTRINSICS_NEON 0 ++#define HAVE_ATANF 1 ++#define HAVE_ATAN2F 1 ++#define HAVE_CBRT 1 ++#define HAVE_CBRTF 1 ++#define HAVE_COPYSIGN 1 ++#define HAVE_COSF 1 ++#define HAVE_ERF 1 ++#define HAVE_EXP2 1 ++#define HAVE_EXP2F 1 ++#define HAVE_EXPF 1 ++#define HAVE_HYPOT 1 ++#define HAVE_ISFINITE 1 ++#define HAVE_ISINF 1 ++#define HAVE_ISNAN 1 ++#define HAVE_LDEXPF 1 ++#define HAVE_LLRINT 1 ++#define HAVE_LLRINTF 1 ++#define HAVE_LOG2 1 ++#define HAVE_LOG2F 1 ++#define HAVE_LOG10F 1 ++#define HAVE_LRINT 1 ++#define HAVE_LRINTF 1 ++#define HAVE_POWF 1 ++#define HAVE_RINT 1 ++#define HAVE_ROUND 1 ++#define HAVE_ROUNDF 1 ++#define HAVE_SINF 1 ++#define HAVE_TRUNC 1 ++#define HAVE_TRUNCF 1 ++#define HAVE_DOS_PATHS 0 ++#define HAVE_LIBC_MSVCRT 0 ++#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 ++#define HAVE_SECTION_DATA_REL_RO 1 ++#define HAVE_THREADS 1 ++#define HAVE_UWP 0 ++#define HAVE_WINRT 0 ++#define HAVE_ACCESS 1 ++#define HAVE_ALIGNED_MALLOC 0 ++#define HAVE_ARC4RANDOM 0 ++#define HAVE_CLOCK_GETTIME 1 ++#define HAVE_CLOSESOCKET 0 ++#define HAVE_COMMANDLINETOARGVW 0 ++#define HAVE_FCNTL 1 ++#define HAVE_GETADDRINFO 0 ++#define HAVE_GETHRTIME 0 ++#define HAVE_GETOPT 1 ++#define HAVE_GETMODULEHANDLE 0 ++#define HAVE_GETPROCESSAFFINITYMASK 0 ++#define HAVE_GETPROCESSMEMORYINFO 0 ++#define HAVE_GETPROCESSTIMES 0 ++#define HAVE_GETRUSAGE 1 ++#define HAVE_GETSTDHANDLE 0 ++#define HAVE_GETSYSTEMTIMEASFILETIME 0 ++#define HAVE_GETTIMEOFDAY 1 ++#define HAVE_GLOB 1 ++#define HAVE_GLXGETPROCADDRESS 0 ++#define HAVE_GMTIME_R 1 ++#define HAVE_INET_ATON 0 ++#define HAVE_ISATTY 1 ++#define HAVE_KBHIT 0 ++#define HAVE_LOCALTIME_R 1 ++#define HAVE_LSTAT 1 ++#define HAVE_LZO1X_999_COMPRESS 0 ++#define HAVE_MACH_ABSOLUTE_TIME 0 ++#define HAVE_MAPVIEWOFFILE 0 ++#define HAVE_MEMALIGN 1 ++#define HAVE_MKSTEMP 1 ++#define HAVE_MMAP 1 ++#define HAVE_MPROTECT 1 ++#define HAVE_NANOSLEEP 1 ++#define HAVE_PEEKNAMEDPIPE 0 ++#define HAVE_POSIX_MEMALIGN 1 ++#define HAVE_PTHREAD_CANCEL 1 ++#define HAVE_SCHED_GETAFFINITY 1 ++#define HAVE_SECITEMIMPORT 0 ++#define HAVE_SETCONSOLETEXTATTRIBUTE 0 ++#define HAVE_SETCONSOLECTRLHANDLER 0 ++#define HAVE_SETDLLDIRECTORY 0 ++#define HAVE_SETMODE 0 ++#define HAVE_SETRLIMIT 1 ++#define HAVE_SLEEP 0 ++#define HAVE_STRERROR_R 1 ++#define HAVE_SYSCONF 1 ++#define HAVE_SYSCTL 0 /* #define HAVE_SYSCTL 0 -- forced to 0 for Fuchsia */ ++#define HAVE_USLEEP 1 ++#define HAVE_UTGETOSTYPEFROMSTRING 0 ++#define HAVE_VIRTUALALLOC 0 ++#define HAVE_WGLGETPROCADDRESS 0 ++#define HAVE_BCRYPT 0 ++#define HAVE_VAAPI_DRM 0 ++#define HAVE_VAAPI_X11 0 ++#define HAVE_VDPAU_X11 0 ++#define HAVE_PTHREADS 1 ++#define HAVE_OS2THREADS 0 ++#define HAVE_W32THREADS 0 ++#define HAVE_AS_ARCH_DIRECTIVE 0 ++#define HAVE_AS_DN_DIRECTIVE 0 ++#define HAVE_AS_FPU_DIRECTIVE 0 ++#define HAVE_AS_FUNC 0 ++#define HAVE_AS_OBJECT_ARCH 0 ++#define HAVE_ASM_MOD_Q 0 ++#define HAVE_BLOCKS_EXTENSION 0 ++#define HAVE_EBP_AVAILABLE 0 ++#define HAVE_EBX_AVAILABLE 0 ++#define HAVE_GNU_AS 0 ++#define HAVE_GNU_WINDRES 0 ++#define HAVE_IBM_ASM 0 ++#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 ++#define HAVE_INLINE_ASM_LABELS 1 ++#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 ++#define HAVE_PRAGMA_DEPRECATED 1 ++#define HAVE_RSYNC_CONTIMEOUT 0 ++#define HAVE_SYMVER_ASM_LABEL 0 ++#define HAVE_SYMVER_GNU_ASM 1 ++#define HAVE_VFP_ARGS 0 ++#define HAVE_XFORM_ASM 0 ++#define HAVE_XMM_CLOBBERS 0 ++#define HAVE_KCMVIDEOCODECTYPE_HEVC 0 ++#define HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG 0 ++#define HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR 0 ++#define HAVE_SOCKLEN_T 0 ++#define HAVE_STRUCT_ADDRINFO 0 ++#define HAVE_STRUCT_GROUP_SOURCE_REQ 0 ++#define HAVE_STRUCT_IP_MREQ_SOURCE 0 ++#define HAVE_STRUCT_IPV6_MREQ 0 ++#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 0 ++#define HAVE_STRUCT_POLLFD 0 ++#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 ++#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 ++#define HAVE_STRUCT_SOCKADDR_IN6 0 ++#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 ++#define HAVE_STRUCT_SOCKADDR_STORAGE 0 ++#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 ++#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 ++#define HAVE_LIBDRM_GETFB2 0 ++#define HAVE_MAKEINFO 0 ++#define HAVE_MAKEINFO_HTML 0 ++#define HAVE_OPENCL_D3D11 0 ++#define HAVE_OPENCL_DRM_ARM 0 ++#define HAVE_OPENCL_DRM_BEIGNET 0 ++#define HAVE_OPENCL_DXVA2 0 ++#define HAVE_OPENCL_VAAPI_BEIGNET 0 ++#define HAVE_OPENCL_VAAPI_INTEL_MEDIA 0 ++#define HAVE_PERL 1 ++#define HAVE_POD2MAN 1 ++#define HAVE_TEXI2HTML 0 ++#define CONFIG_DOC 0 ++#define CONFIG_HTMLPAGES 0 ++#define CONFIG_MANPAGES 0 ++#define CONFIG_PODPAGES 0 ++#define CONFIG_TXTPAGES 0 ++#define CONFIG_AVIO_LIST_DIR_EXAMPLE 1 ++#define CONFIG_AVIO_READING_EXAMPLE 1 ++#define CONFIG_DECODE_AUDIO_EXAMPLE 1 ++#define CONFIG_DECODE_VIDEO_EXAMPLE 1 ++#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 ++#define CONFIG_ENCODE_AUDIO_EXAMPLE 1 ++#define CONFIG_ENCODE_VIDEO_EXAMPLE 1 ++#define CONFIG_EXTRACT_MVS_EXAMPLE 1 ++#define CONFIG_FILTER_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_AUDIO_EXAMPLE 0 ++#define CONFIG_FILTERING_VIDEO_EXAMPLE 0 ++#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 ++#define CONFIG_HW_DECODE_EXAMPLE 1 ++#define CONFIG_METADATA_EXAMPLE 1 ++#define CONFIG_MUXING_EXAMPLE 0 ++#define CONFIG_QSVDEC_EXAMPLE 0 ++#define CONFIG_REMUXING_EXAMPLE 1 ++#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 0 ++#define CONFIG_SCALING_VIDEO_EXAMPLE 0 ++#define CONFIG_TRANSCODE_AAC_EXAMPLE 0 ++#define CONFIG_TRANSCODING_EXAMPLE 0 ++#define CONFIG_VAAPI_ENCODE_EXAMPLE 0 ++#define CONFIG_VAAPI_TRANSCODE_EXAMPLE 0 ++#define CONFIG_AVISYNTH 0 ++#define CONFIG_FREI0R 0 ++#define CONFIG_LIBCDIO 0 ++#define CONFIG_LIBDAVS2 0 ++#define CONFIG_LIBRUBBERBAND 0 ++#define CONFIG_LIBVIDSTAB 0 ++#define CONFIG_LIBX264 0 ++#define CONFIG_LIBX265 0 ++#define CONFIG_LIBXAVS 0 ++#define CONFIG_LIBXAVS2 0 ++#define CONFIG_LIBXVID 0 ++#define CONFIG_DECKLINK 0 ++#define CONFIG_LIBFDK_AAC 0 ++#define CONFIG_OPENSSL 0 ++#define CONFIG_LIBTLS 0 ++#define CONFIG_GMP 0 ++#define CONFIG_LIBARIBB24 0 ++#define CONFIG_LIBLENSFUN 0 ++#define CONFIG_LIBOPENCORE_AMRNB 0 ++#define CONFIG_LIBOPENCORE_AMRWB 0 ++#define CONFIG_LIBVO_AMRWBENC 0 ++#define CONFIG_MBEDTLS 0 ++#define CONFIG_RKMPP 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_CHROMAPRINT 0 ++#define CONFIG_GCRYPT 0 ++#define CONFIG_GNUTLS 0 ++#define CONFIG_JNI 0 ++#define CONFIG_LADSPA 0 ++#define CONFIG_LIBAOM 0 ++#define CONFIG_LIBASS 0 ++#define CONFIG_LIBBLURAY 0 ++#define CONFIG_LIBBS2B 0 ++#define CONFIG_LIBCACA 0 ++#define CONFIG_LIBCELT 0 ++#define CONFIG_LIBCODEC2 0 ++#define CONFIG_LIBDAV1D 0 ++#define CONFIG_LIBDC1394 0 ++#define CONFIG_LIBDRM 0 ++#define CONFIG_LIBFLITE 0 ++#define CONFIG_LIBFONTCONFIG 0 ++#define CONFIG_LIBFREETYPE 0 ++#define CONFIG_LIBFRIBIDI 0 ++#define CONFIG_LIBGLSLANG 0 ++#define CONFIG_LIBGME 0 ++#define CONFIG_LIBGSM 0 ++#define CONFIG_LIBIEC61883 0 ++#define CONFIG_LIBILBC 0 ++#define CONFIG_LIBJACK 0 ++#define CONFIG_LIBKLVANC 0 ++#define CONFIG_LIBKVAZAAR 0 ++#define CONFIG_LIBMODPLUG 0 ++#define CONFIG_LIBMP3LAME 0 ++#define CONFIG_LIBMYSOFA 0 ++#define CONFIG_LIBOPENCV 0 ++#define CONFIG_LIBOPENH264 0 ++#define CONFIG_LIBOPENJPEG 0 ++#define CONFIG_LIBOPENMPT 0 ++#define CONFIG_LIBOPENVINO 0 ++#define CONFIG_LIBOPUS 1 ++#define CONFIG_LIBPULSE 0 ++#define CONFIG_LIBRABBITMQ 0 ++#define CONFIG_LIBRAV1E 0 ++#define CONFIG_LIBRSVG 0 ++#define CONFIG_LIBRTMP 0 ++#define CONFIG_LIBSHINE 0 ++#define CONFIG_LIBSMBCLIENT 0 ++#define CONFIG_LIBSNAPPY 0 ++#define CONFIG_LIBSOXR 0 ++#define CONFIG_LIBSPEEX 0 ++#define CONFIG_LIBSRT 0 ++#define CONFIG_LIBSSH 0 ++#define CONFIG_LIBSVTAV1 0 ++#define CONFIG_LIBTENSORFLOW 0 ++#define CONFIG_LIBTESSERACT 0 ++#define CONFIG_LIBTHEORA 0 ++#define CONFIG_LIBTWOLAME 0 ++#define CONFIG_LIBV4L2 0 ++#define CONFIG_LIBVMAF 0 ++#define CONFIG_LIBVORBIS 0 ++#define CONFIG_LIBVPX 0 ++#define CONFIG_LIBWAVPACK 0 ++#define CONFIG_LIBWEBP 0 ++#define CONFIG_LIBXML2 0 ++#define CONFIG_LIBZIMG 0 ++#define CONFIG_LIBZMQ 0 ++#define CONFIG_LIBZVBI 0 ++#define CONFIG_LV2 0 ++#define CONFIG_MEDIACODEC 0 ++#define CONFIG_OPENAL 0 ++#define CONFIG_OPENGL 0 ++#define CONFIG_POCKETSPHINX 0 ++#define CONFIG_VAPOURSYNTH 0 ++#define CONFIG_ALSA 0 ++#define CONFIG_APPKIT 0 ++#define CONFIG_AVFOUNDATION 0 ++#define CONFIG_BZLIB 0 ++#define CONFIG_COREIMAGE 0 ++#define CONFIG_ICONV 0 ++#define CONFIG_LIBXCB 0 ++#define CONFIG_LIBXCB_SHM 0 ++#define CONFIG_LIBXCB_SHAPE 0 ++#define CONFIG_LIBXCB_XFIXES 0 ++#define CONFIG_LZMA 0 ++#define CONFIG_MEDIAFOUNDATION 0 ++#define CONFIG_SCHANNEL 0 ++#define CONFIG_SDL2 0 ++#define CONFIG_SECURETRANSPORT 0 ++#define CONFIG_SNDIO 0 ++#define CONFIG_XLIB 0 ++#define CONFIG_ZLIB 0 ++#define CONFIG_CUDA_NVCC 0 ++#define CONFIG_CUDA_SDK 0 ++#define CONFIG_LIBNPP 0 ++#define CONFIG_LIBMFX 0 ++#define CONFIG_MMAL 0 ++#define CONFIG_OMX 0 ++#define CONFIG_OPENCL 0 ++#define CONFIG_VULKAN 0 ++#define CONFIG_AMF 0 ++#define CONFIG_AUDIOTOOLBOX 0 ++#define CONFIG_CRYSTALHD 0 ++#define CONFIG_CUDA 0 ++#define CONFIG_CUDA_LLVM 0 ++#define CONFIG_CUVID 0 ++#define CONFIG_D3D11VA 0 ++#define CONFIG_DXVA2 0 ++#define CONFIG_FFNVCODEC 0 ++#define CONFIG_NVDEC 0 ++#define CONFIG_NVENC 0 ++#define CONFIG_VAAPI 0 ++#define CONFIG_VDPAU 0 ++#define CONFIG_VIDEOTOOLBOX 0 ++#define CONFIG_V4L2_M2M 0 ++#define CONFIG_XVMC 0 ++#define CONFIG_FTRAPV 0 ++#define CONFIG_GRAY 0 ++#define CONFIG_HARDCODED_TABLES 0 ++#define CONFIG_OMX_RPI 0 ++#define CONFIG_RUNTIME_CPUDETECT 1 ++#define CONFIG_SAFE_BITSTREAM_READER 1 ++#define CONFIG_SHARED 0 ++#define CONFIG_SMALL 0 ++#define CONFIG_STATIC 1 ++#define CONFIG_SWSCALE_ALPHA 1 ++#define CONFIG_GPL 0 ++#define CONFIG_NONFREE 0 ++#define CONFIG_VERSION3 0 ++#define CONFIG_AVDEVICE 0 ++#define CONFIG_AVFILTER 0 ++#define CONFIG_SWSCALE 0 ++#define CONFIG_POSTPROC 0 ++#define CONFIG_AVFORMAT 1 ++#define CONFIG_AVCODEC 1 ++#define CONFIG_SWRESAMPLE 0 ++#define CONFIG_AVRESAMPLE 0 ++#define CONFIG_AVUTIL 1 ++#define CONFIG_FFPLAY 0 ++#define CONFIG_FFPROBE 0 ++#define CONFIG_FFMPEG 0 ++#define CONFIG_DCT 1 ++#define CONFIG_DWT 0 ++#define CONFIG_ERROR_RESILIENCE 0 ++#define CONFIG_FAAN 0 ++#define CONFIG_FAST_UNALIGNED 0 ++#define CONFIG_FFT 1 ++#define CONFIG_LSP 0 ++#define CONFIG_LZO 0 ++#define CONFIG_MDCT 1 ++#define CONFIG_PIXELUTILS 0 ++#define CONFIG_NETWORK 0 ++#define CONFIG_RDFT 1 ++#define CONFIG_AUTODETECT 0 ++#define CONFIG_FONTCONFIG 0 ++#define CONFIG_LARGE_TESTS 1 ++#define CONFIG_LINUX_PERF 0 ++#define CONFIG_MEMORY_POISONING 0 ++#define CONFIG_NEON_CLOBBER_TEST 0 ++#define CONFIG_OSSFUZZ 0 ++#define CONFIG_PIC 1 ++#define CONFIG_THUMB 0 ++#define CONFIG_VALGRIND_BACKTRACE 0 ++#define CONFIG_XMM_CLOBBER_TEST 0 ++#define CONFIG_BSFS 1 ++#define CONFIG_DECODERS 1 ++#define CONFIG_ENCODERS 0 ++#define CONFIG_HWACCELS 0 ++#define CONFIG_PARSERS 1 ++#define CONFIG_INDEVS 0 ++#define CONFIG_OUTDEVS 0 ++#define CONFIG_FILTERS 0 ++#define CONFIG_DEMUXERS 1 ++#define CONFIG_MUXERS 0 ++#define CONFIG_PROTOCOLS 0 ++#define CONFIG_AANDCTTABLES 0 ++#define CONFIG_AC3DSP 0 ++#define CONFIG_ADTS_HEADER 0 ++#define CONFIG_ATSC_A53 0 ++#define CONFIG_AUDIO_FRAME_QUEUE 0 ++#define CONFIG_AUDIODSP 0 ++#define CONFIG_BLOCKDSP 0 ++#define CONFIG_BSWAPDSP 0 ++#define CONFIG_CABAC 0 ++#define CONFIG_CBS 0 ++#define CONFIG_CBS_AV1 0 ++#define CONFIG_CBS_H264 0 ++#define CONFIG_CBS_H265 0 ++#define CONFIG_CBS_JPEG 0 ++#define CONFIG_CBS_MPEG2 0 ++#define CONFIG_CBS_VP9 0 ++#define CONFIG_DIRAC_PARSE 1 ++#define CONFIG_DNN 0 ++#define CONFIG_DVPROFILE 0 ++#define CONFIG_EXIF 0 ++#define CONFIG_FAANDCT 0 ++#define CONFIG_FAANIDCT 0 ++#define CONFIG_FDCTDSP 0 ++#define CONFIG_FLACDSP 1 ++#define CONFIG_FMTCONVERT 0 ++#define CONFIG_FRAME_THREAD_ENCODER 0 ++#define CONFIG_G722DSP 0 ++#define CONFIG_GOLOMB 1 ++#define CONFIG_GPLV3 0 ++#define CONFIG_H263DSP 0 ++#define CONFIG_H264CHROMA 0 ++#define CONFIG_H264DSP 0 ++#define CONFIG_H264PARSE 0 ++#define CONFIG_H264PRED 1 ++#define CONFIG_H264QPEL 0 ++#define CONFIG_HEVCPARSE 0 ++#define CONFIG_HPELDSP 1 ++#define CONFIG_HUFFMAN 0 ++#define CONFIG_HUFFYUVDSP 0 ++#define CONFIG_HUFFYUVENCDSP 0 ++#define CONFIG_IDCTDSP 0 ++#define CONFIG_IIRFILTER 0 ++#define CONFIG_MDCT15 0 ++#define CONFIG_INTRAX8 0 ++#define CONFIG_ISO_MEDIA 1 ++#define CONFIG_IVIDSP 0 ++#define CONFIG_JPEGTABLES 0 ++#define CONFIG_LGPLV3 0 ++#define CONFIG_LIBX262 0 ++#define CONFIG_LLAUDDSP 0 ++#define CONFIG_LLVIDDSP 0 ++#define CONFIG_LLVIDENCDSP 0 ++#define CONFIG_LPC 0 ++#define CONFIG_LZF 0 ++#define CONFIG_ME_CMP 0 ++#define CONFIG_MPEG_ER 0 ++#define CONFIG_MPEGAUDIO 1 ++#define CONFIG_MPEGAUDIODSP 1 ++#define CONFIG_MPEGAUDIOHEADER 1 ++#define CONFIG_MPEGVIDEO 0 ++#define CONFIG_MPEGVIDEOENC 0 ++#define CONFIG_MSS34DSP 0 ++#define CONFIG_PIXBLOCKDSP 0 ++#define CONFIG_QPELDSP 0 ++#define CONFIG_QSV 0 ++#define CONFIG_QSVDEC 0 ++#define CONFIG_QSVENC 0 ++#define CONFIG_QSVVPP 0 ++#define CONFIG_RANGECODER 0 ++#define CONFIG_RIFFDEC 1 ++#define CONFIG_RIFFENC 0 ++#define CONFIG_RTPDEC 0 ++#define CONFIG_RTPENC_CHAIN 0 ++#define CONFIG_RV34DSP 0 ++#define CONFIG_SCENE_SAD 0 ++#define CONFIG_SINEWIN 0 ++#define CONFIG_SNAPPY 0 ++#define CONFIG_SRTP 0 ++#define CONFIG_STARTCODE 0 ++#define CONFIG_TEXTUREDSP 0 ++#define CONFIG_TEXTUREDSPENC 0 ++#define CONFIG_TPELDSP 0 ++#define CONFIG_VAAPI_1 0 ++#define CONFIG_VAAPI_ENCODE 0 ++#define CONFIG_VC1DSP 0 ++#define CONFIG_VIDEODSP 1 ++#define CONFIG_VP3DSP 1 ++#define CONFIG_VP56DSP 0 ++#define CONFIG_VP8DSP 1 ++#define CONFIG_WMA_FREQS 0 ++#define CONFIG_WMV2DSP 0 ++#define CONFIG_AAC_ADTSTOASC_BSF 0 ++#define CONFIG_AV1_FRAME_MERGE_BSF 0 ++#define CONFIG_AV1_FRAME_SPLIT_BSF 0 ++#define CONFIG_AV1_METADATA_BSF 0 ++#define CONFIG_CHOMP_BSF 0 ++#define CONFIG_DUMP_EXTRADATA_BSF 0 ++#define CONFIG_DCA_CORE_BSF 0 ++#define CONFIG_EAC3_CORE_BSF 0 ++#define CONFIG_EXTRACT_EXTRADATA_BSF 0 ++#define CONFIG_FILTER_UNITS_BSF 0 ++#define CONFIG_H264_METADATA_BSF 0 ++#define CONFIG_H264_MP4TOANNEXB_BSF 0 ++#define CONFIG_H264_REDUNDANT_PPS_BSF 0 ++#define CONFIG_HAPQA_EXTRACT_BSF 0 ++#define CONFIG_HEVC_METADATA_BSF 0 ++#define CONFIG_HEVC_MP4TOANNEXB_BSF 0 ++#define CONFIG_IMX_DUMP_HEADER_BSF 0 ++#define CONFIG_MJPEG2JPEG_BSF 0 ++#define CONFIG_MJPEGA_DUMP_HEADER_BSF 0 ++#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 0 ++#define CONFIG_MPEG2_METADATA_BSF 0 ++#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 0 ++#define CONFIG_MOV2TEXTSUB_BSF 0 ++#define CONFIG_NOISE_BSF 0 ++#define CONFIG_NULL_BSF 1 ++#define CONFIG_OPUS_METADATA_BSF 0 ++#define CONFIG_PCM_RECHUNK_BSF 0 ++#define CONFIG_PRORES_METADATA_BSF 0 ++#define CONFIG_REMOVE_EXTRADATA_BSF 0 ++#define CONFIG_TEXT2MOVSUB_BSF 0 ++#define CONFIG_TRACE_HEADERS_BSF 0 ++#define CONFIG_TRUEHD_CORE_BSF 0 ++#define CONFIG_VP9_METADATA_BSF 0 ++#define CONFIG_VP9_RAW_REORDER_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_BSF 0 ++#define CONFIG_VP9_SUPERFRAME_SPLIT_BSF 0 ++#define CONFIG_AASC_DECODER 0 ++#define CONFIG_AIC_DECODER 0 ++#define CONFIG_ALIAS_PIX_DECODER 0 ++#define CONFIG_AGM_DECODER 0 ++#define CONFIG_AMV_DECODER 0 ++#define CONFIG_ANM_DECODER 0 ++#define CONFIG_ANSI_DECODER 0 ++#define CONFIG_APNG_DECODER 0 ++#define CONFIG_ARBC_DECODER 0 ++#define CONFIG_ASV1_DECODER 0 ++#define CONFIG_ASV2_DECODER 0 ++#define CONFIG_AURA_DECODER 0 ++#define CONFIG_AURA2_DECODER 0 ++#define CONFIG_AVRP_DECODER 0 ++#define CONFIG_AVRN_DECODER 0 ++#define CONFIG_AVS_DECODER 0 ++#define CONFIG_AVUI_DECODER 0 ++#define CONFIG_AYUV_DECODER 0 ++#define CONFIG_BETHSOFTVID_DECODER 0 ++#define CONFIG_BFI_DECODER 0 ++#define CONFIG_BINK_DECODER 0 ++#define CONFIG_BITPACKED_DECODER 0 ++#define CONFIG_BMP_DECODER 0 ++#define CONFIG_BMV_VIDEO_DECODER 0 ++#define CONFIG_BRENDER_PIX_DECODER 0 ++#define CONFIG_C93_DECODER 0 ++#define CONFIG_CAVS_DECODER 0 ++#define CONFIG_CDGRAPHICS_DECODER 0 ++#define CONFIG_CDTOONS_DECODER 0 ++#define CONFIG_CDXL_DECODER 0 ++#define CONFIG_CFHD_DECODER 0 ++#define CONFIG_CINEPAK_DECODER 0 ++#define CONFIG_CLEARVIDEO_DECODER 0 ++#define CONFIG_CLJR_DECODER 0 ++#define CONFIG_CLLC_DECODER 0 ++#define CONFIG_COMFORTNOISE_DECODER 0 ++#define CONFIG_CPIA_DECODER 0 ++#define CONFIG_CSCD_DECODER 0 ++#define CONFIG_CYUV_DECODER 0 ++#define CONFIG_DDS_DECODER 0 ++#define CONFIG_DFA_DECODER 0 ++#define CONFIG_DIRAC_DECODER 0 ++#define CONFIG_DNXHD_DECODER 0 ++#define CONFIG_DPX_DECODER 0 ++#define CONFIG_DSICINVIDEO_DECODER 0 ++#define CONFIG_DVAUDIO_DECODER 0 ++#define CONFIG_DVVIDEO_DECODER 0 ++#define CONFIG_DXA_DECODER 0 ++#define CONFIG_DXTORY_DECODER 0 ++#define CONFIG_DXV_DECODER 0 ++#define CONFIG_EACMV_DECODER 0 ++#define CONFIG_EAMAD_DECODER 0 ++#define CONFIG_EATGQ_DECODER 0 ++#define CONFIG_EATGV_DECODER 0 ++#define CONFIG_EATQI_DECODER 0 ++#define CONFIG_EIGHTBPS_DECODER 0 ++#define CONFIG_EIGHTSVX_EXP_DECODER 0 ++#define CONFIG_EIGHTSVX_FIB_DECODER 0 ++#define CONFIG_ESCAPE124_DECODER 0 ++#define CONFIG_ESCAPE130_DECODER 0 ++#define CONFIG_EXR_DECODER 0 ++#define CONFIG_FFV1_DECODER 0 ++#define CONFIG_FFVHUFF_DECODER 0 ++#define CONFIG_FIC_DECODER 0 ++#define CONFIG_FITS_DECODER 0 ++#define CONFIG_FLASHSV_DECODER 0 ++#define CONFIG_FLASHSV2_DECODER 0 ++#define CONFIG_FLIC_DECODER 0 ++#define CONFIG_FLV_DECODER 0 ++#define CONFIG_FMVC_DECODER 0 ++#define CONFIG_FOURXM_DECODER 0 ++#define CONFIG_FRAPS_DECODER 0 ++#define CONFIG_FRWU_DECODER 0 ++#define CONFIG_G2M_DECODER 0 ++#define CONFIG_GDV_DECODER 0 ++#define CONFIG_GIF_DECODER 0 ++#define CONFIG_H261_DECODER 0 ++#define CONFIG_H263_DECODER 0 ++#define CONFIG_H263I_DECODER 0 ++#define CONFIG_H263P_DECODER 0 ++#define CONFIG_H263_V4L2M2M_DECODER 0 ++#define CONFIG_H264_DECODER 0 ++#define CONFIG_H264_CRYSTALHD_DECODER 0 ++#define CONFIG_H264_V4L2M2M_DECODER 0 ++#define CONFIG_H264_MEDIACODEC_DECODER 0 ++#define CONFIG_H264_MMAL_DECODER 0 ++#define CONFIG_H264_QSV_DECODER 0 ++#define CONFIG_H264_RKMPP_DECODER 0 ++#define CONFIG_HAP_DECODER 0 ++#define CONFIG_HEVC_DECODER 0 ++#define CONFIG_HEVC_QSV_DECODER 0 ++#define CONFIG_HEVC_RKMPP_DECODER 0 ++#define CONFIG_HEVC_V4L2M2M_DECODER 0 ++#define CONFIG_HNM4_VIDEO_DECODER 0 ++#define CONFIG_HQ_HQA_DECODER 0 ++#define CONFIG_HQX_DECODER 0 ++#define CONFIG_HUFFYUV_DECODER 0 ++#define CONFIG_HYMT_DECODER 0 ++#define CONFIG_IDCIN_DECODER 0 ++#define CONFIG_IFF_ILBM_DECODER 0 ++#define CONFIG_IMM4_DECODER 0 ++#define CONFIG_IMM5_DECODER 0 ++#define CONFIG_INDEO2_DECODER 0 ++#define CONFIG_INDEO3_DECODER 0 ++#define CONFIG_INDEO4_DECODER 0 ++#define CONFIG_INDEO5_DECODER 0 ++#define CONFIG_INTERPLAY_VIDEO_DECODER 0 ++#define CONFIG_JPEG2000_DECODER 0 ++#define CONFIG_JPEGLS_DECODER 0 ++#define CONFIG_JV_DECODER 0 ++#define CONFIG_KGV1_DECODER 0 ++#define CONFIG_KMVC_DECODER 0 ++#define CONFIG_LAGARITH_DECODER 0 ++#define CONFIG_LOCO_DECODER 0 ++#define CONFIG_LSCR_DECODER 0 ++#define CONFIG_M101_DECODER 0 ++#define CONFIG_MAGICYUV_DECODER 0 ++#define CONFIG_MDEC_DECODER 0 ++#define CONFIG_MIMIC_DECODER 0 ++#define CONFIG_MJPEG_DECODER 0 ++#define CONFIG_MJPEGB_DECODER 0 ++#define CONFIG_MMVIDEO_DECODER 0 ++#define CONFIG_MOTIONPIXELS_DECODER 0 ++#define CONFIG_MPEG1VIDEO_DECODER 0 ++#define CONFIG_MPEG2VIDEO_DECODER 0 ++#define CONFIG_MPEG4_DECODER 0 ++#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG4_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG4_MMAL_DECODER 0 ++#define CONFIG_MPEGVIDEO_DECODER 0 ++#define CONFIG_MPEG1_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_MMAL_DECODER 0 ++#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 ++#define CONFIG_MPEG2_V4L2M2M_DECODER 0 ++#define CONFIG_MPEG2_QSV_DECODER 0 ++#define CONFIG_MPEG2_MEDIACODEC_DECODER 0 ++#define CONFIG_MSA1_DECODER 0 ++#define CONFIG_MSCC_DECODER 0 ++#define CONFIG_MSMPEG4V1_DECODER 0 ++#define CONFIG_MSMPEG4V2_DECODER 0 ++#define CONFIG_MSMPEG4V3_DECODER 0 ++#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 ++#define CONFIG_MSRLE_DECODER 0 ++#define CONFIG_MSS1_DECODER 0 ++#define CONFIG_MSS2_DECODER 0 ++#define CONFIG_MSVIDEO1_DECODER 0 ++#define CONFIG_MSZH_DECODER 0 ++#define CONFIG_MTS2_DECODER 0 ++#define CONFIG_MV30_DECODER 0 ++#define CONFIG_MVC1_DECODER 0 ++#define CONFIG_MVC2_DECODER 0 ++#define CONFIG_MVDV_DECODER 0 ++#define CONFIG_MVHA_DECODER 0 ++#define CONFIG_MWSC_DECODER 0 ++#define CONFIG_MXPEG_DECODER 0 ++#define CONFIG_NOTCHLC_DECODER 0 ++#define CONFIG_NUV_DECODER 0 ++#define CONFIG_PAF_VIDEO_DECODER 0 ++#define CONFIG_PAM_DECODER 0 ++#define CONFIG_PBM_DECODER 0 ++#define CONFIG_PCX_DECODER 0 ++#define CONFIG_PFM_DECODER 0 ++#define CONFIG_PGM_DECODER 0 ++#define CONFIG_PGMYUV_DECODER 0 ++#define CONFIG_PGX_DECODER 0 ++#define CONFIG_PICTOR_DECODER 0 ++#define CONFIG_PIXLET_DECODER 0 ++#define CONFIG_PNG_DECODER 0 ++#define CONFIG_PPM_DECODER 0 ++#define CONFIG_PRORES_DECODER 0 ++#define CONFIG_PROSUMER_DECODER 0 ++#define CONFIG_PSD_DECODER 0 ++#define CONFIG_PTX_DECODER 0 ++#define CONFIG_QDRAW_DECODER 0 ++#define CONFIG_QPEG_DECODER 0 ++#define CONFIG_QTRLE_DECODER 0 ++#define CONFIG_R10K_DECODER 0 ++#define CONFIG_R210_DECODER 0 ++#define CONFIG_RASC_DECODER 0 ++#define CONFIG_RAWVIDEO_DECODER 0 ++#define CONFIG_RL2_DECODER 0 ++#define CONFIG_ROQ_DECODER 0 ++#define CONFIG_RPZA_DECODER 0 ++#define CONFIG_RSCC_DECODER 0 ++#define CONFIG_RV10_DECODER 0 ++#define CONFIG_RV20_DECODER 0 ++#define CONFIG_RV30_DECODER 0 ++#define CONFIG_RV40_DECODER 0 ++#define CONFIG_S302M_DECODER 0 ++#define CONFIG_SANM_DECODER 0 ++#define CONFIG_SCPR_DECODER 0 ++#define CONFIG_SCREENPRESSO_DECODER 0 ++#define CONFIG_SGI_DECODER 0 ++#define CONFIG_SGIRLE_DECODER 0 ++#define CONFIG_SHEERVIDEO_DECODER 0 ++#define CONFIG_SMACKER_DECODER 0 ++#define CONFIG_SMC_DECODER 0 ++#define CONFIG_SMVJPEG_DECODER 0 ++#define CONFIG_SNOW_DECODER 0 ++#define CONFIG_SP5X_DECODER 0 ++#define CONFIG_SPEEDHQ_DECODER 0 ++#define CONFIG_SRGC_DECODER 0 ++#define CONFIG_SUNRAST_DECODER 0 ++#define CONFIG_SVQ1_DECODER 0 ++#define CONFIG_SVQ3_DECODER 0 ++#define CONFIG_TARGA_DECODER 0 ++#define CONFIG_TARGA_Y216_DECODER 0 ++#define CONFIG_TDSC_DECODER 0 ++#define CONFIG_THEORA_DECODER 1 ++#define CONFIG_THP_DECODER 0 ++#define CONFIG_TIERTEXSEQVIDEO_DECODER 0 ++#define CONFIG_TIFF_DECODER 0 ++#define CONFIG_TMV_DECODER 0 ++#define CONFIG_TRUEMOTION1_DECODER 0 ++#define CONFIG_TRUEMOTION2_DECODER 0 ++#define CONFIG_TRUEMOTION2RT_DECODER 0 ++#define CONFIG_TSCC_DECODER 0 ++#define CONFIG_TSCC2_DECODER 0 ++#define CONFIG_TXD_DECODER 0 ++#define CONFIG_ULTI_DECODER 0 ++#define CONFIG_UTVIDEO_DECODER 0 ++#define CONFIG_V210_DECODER 0 ++#define CONFIG_V210X_DECODER 0 ++#define CONFIG_V308_DECODER 0 ++#define CONFIG_V408_DECODER 0 ++#define CONFIG_V410_DECODER 0 ++#define CONFIG_VB_DECODER 0 ++#define CONFIG_VBLE_DECODER 0 ++#define CONFIG_VC1_DECODER 0 ++#define CONFIG_VC1_CRYSTALHD_DECODER 0 ++#define CONFIG_VC1IMAGE_DECODER 0 ++#define CONFIG_VC1_MMAL_DECODER 0 ++#define CONFIG_VC1_QSV_DECODER 0 ++#define CONFIG_VC1_V4L2M2M_DECODER 0 ++#define CONFIG_VCR1_DECODER 0 ++#define CONFIG_VMDVIDEO_DECODER 0 ++#define CONFIG_VMNC_DECODER 0 ++#define CONFIG_VP3_DECODER 1 ++#define CONFIG_VP4_DECODER 0 ++#define CONFIG_VP5_DECODER 0 ++#define CONFIG_VP6_DECODER 0 ++#define CONFIG_VP6A_DECODER 0 ++#define CONFIG_VP6F_DECODER 0 ++#define CONFIG_VP7_DECODER 0 ++#define CONFIG_VP8_DECODER 1 ++#define CONFIG_VP8_RKMPP_DECODER 0 ++#define CONFIG_VP8_V4L2M2M_DECODER 0 ++#define CONFIG_VP9_DECODER 0 ++#define CONFIG_VP9_RKMPP_DECODER 0 ++#define CONFIG_VP9_V4L2M2M_DECODER 0 ++#define CONFIG_VQA_DECODER 0 ++#define CONFIG_WEBP_DECODER 0 ++#define CONFIG_WCMV_DECODER 0 ++#define CONFIG_WRAPPED_AVFRAME_DECODER 0 ++#define CONFIG_WMV1_DECODER 0 ++#define CONFIG_WMV2_DECODER 0 ++#define CONFIG_WMV3_DECODER 0 ++#define CONFIG_WMV3_CRYSTALHD_DECODER 0 ++#define CONFIG_WMV3IMAGE_DECODER 0 ++#define CONFIG_WNV1_DECODER 0 ++#define CONFIG_XAN_WC3_DECODER 0 ++#define CONFIG_XAN_WC4_DECODER 0 ++#define CONFIG_XBM_DECODER 0 ++#define CONFIG_XFACE_DECODER 0 ++#define CONFIG_XL_DECODER 0 ++#define CONFIG_XPM_DECODER 0 ++#define CONFIG_XWD_DECODER 0 ++#define CONFIG_Y41P_DECODER 0 ++#define CONFIG_YLC_DECODER 0 ++#define CONFIG_YOP_DECODER 0 ++#define CONFIG_YUV4_DECODER 0 ++#define CONFIG_ZERO12V_DECODER 0 ++#define CONFIG_ZEROCODEC_DECODER 0 ++#define CONFIG_ZLIB_DECODER 0 ++#define CONFIG_ZMBV_DECODER 0 ++#define CONFIG_AAC_DECODER 0 ++#define CONFIG_AAC_FIXED_DECODER 0 ++#define CONFIG_AAC_LATM_DECODER 0 ++#define CONFIG_AC3_DECODER 0 ++#define CONFIG_AC3_FIXED_DECODER 0 ++#define CONFIG_ACELP_KELVIN_DECODER 0 ++#define CONFIG_ALAC_DECODER 0 ++#define CONFIG_ALS_DECODER 0 ++#define CONFIG_AMRNB_DECODER 0 ++#define CONFIG_AMRWB_DECODER 0 ++#define CONFIG_APE_DECODER 0 ++#define CONFIG_APTX_DECODER 0 ++#define CONFIG_APTX_HD_DECODER 0 ++#define CONFIG_ATRAC1_DECODER 0 ++#define CONFIG_ATRAC3_DECODER 0 ++#define CONFIG_ATRAC3AL_DECODER 0 ++#define CONFIG_ATRAC3P_DECODER 0 ++#define CONFIG_ATRAC3PAL_DECODER 0 ++#define CONFIG_ATRAC9_DECODER 0 ++#define CONFIG_BINKAUDIO_DCT_DECODER 0 ++#define CONFIG_BINKAUDIO_RDFT_DECODER 0 ++#define CONFIG_BMV_AUDIO_DECODER 0 ++#define CONFIG_COOK_DECODER 0 ++#define CONFIG_DCA_DECODER 0 ++#define CONFIG_DOLBY_E_DECODER 0 ++#define CONFIG_DSD_LSBF_DECODER 0 ++#define CONFIG_DSD_MSBF_DECODER 0 ++#define CONFIG_DSD_LSBF_PLANAR_DECODER 0 ++#define CONFIG_DSD_MSBF_PLANAR_DECODER 0 ++#define CONFIG_DSICINAUDIO_DECODER 0 ++#define CONFIG_DSS_SP_DECODER 0 ++#define CONFIG_DST_DECODER 0 ++#define CONFIG_EAC3_DECODER 0 ++#define CONFIG_EVRC_DECODER 0 ++#define CONFIG_FFWAVESYNTH_DECODER 0 ++#define CONFIG_FLAC_DECODER 1 ++#define CONFIG_G723_1_DECODER 0 ++#define CONFIG_G729_DECODER 0 ++#define CONFIG_GSM_DECODER 0 ++#define CONFIG_GSM_MS_DECODER 0 ++#define CONFIG_HCA_DECODER 0 ++#define CONFIG_HCOM_DECODER 0 ++#define CONFIG_IAC_DECODER 0 ++#define CONFIG_ILBC_DECODER 0 ++#define CONFIG_IMC_DECODER 0 ++#define CONFIG_INTERPLAY_ACM_DECODER 0 ++#define CONFIG_MACE3_DECODER 0 ++#define CONFIG_MACE6_DECODER 0 ++#define CONFIG_METASOUND_DECODER 0 ++#define CONFIG_MLP_DECODER 0 ++#define CONFIG_MP1_DECODER 0 ++#define CONFIG_MP1FLOAT_DECODER 0 ++#define CONFIG_MP2_DECODER 0 ++#define CONFIG_MP2FLOAT_DECODER 0 ++#define CONFIG_MP3FLOAT_DECODER 0 ++#define CONFIG_MP3_DECODER 1 ++#define CONFIG_MP3ADUFLOAT_DECODER 0 ++#define CONFIG_MP3ADU_DECODER 0 ++#define CONFIG_MP3ON4FLOAT_DECODER 0 ++#define CONFIG_MP3ON4_DECODER 0 ++#define CONFIG_MPC7_DECODER 0 ++#define CONFIG_MPC8_DECODER 0 ++#define CONFIG_NELLYMOSER_DECODER 0 ++#define CONFIG_ON2AVC_DECODER 0 ++#define CONFIG_OPUS_DECODER 0 ++#define CONFIG_PAF_AUDIO_DECODER 0 ++#define CONFIG_QCELP_DECODER 0 ++#define CONFIG_QDM2_DECODER 0 ++#define CONFIG_QDMC_DECODER 0 ++#define CONFIG_RA_144_DECODER 0 ++#define CONFIG_RA_288_DECODER 0 ++#define CONFIG_RALF_DECODER 0 ++#define CONFIG_SBC_DECODER 0 ++#define CONFIG_SHORTEN_DECODER 0 ++#define CONFIG_SIPR_DECODER 0 ++#define CONFIG_SIREN_DECODER 0 ++#define CONFIG_SMACKAUD_DECODER 0 ++#define CONFIG_SONIC_DECODER 0 ++#define CONFIG_TAK_DECODER 0 ++#define CONFIG_TRUEHD_DECODER 0 ++#define CONFIG_TRUESPEECH_DECODER 0 ++#define CONFIG_TTA_DECODER 0 ++#define CONFIG_TWINVQ_DECODER 0 ++#define CONFIG_VMDAUDIO_DECODER 0 ++#define CONFIG_VORBIS_DECODER 1 ++#define CONFIG_WAVPACK_DECODER 0 ++#define CONFIG_WMALOSSLESS_DECODER 0 ++#define CONFIG_WMAPRO_DECODER 0 ++#define CONFIG_WMAV1_DECODER 0 ++#define CONFIG_WMAV2_DECODER 0 ++#define CONFIG_WMAVOICE_DECODER 0 ++#define CONFIG_WS_SND1_DECODER 0 ++#define CONFIG_XMA1_DECODER 0 ++#define CONFIG_XMA2_DECODER 0 ++#define CONFIG_PCM_ALAW_DECODER 1 ++#define CONFIG_PCM_BLURAY_DECODER 0 ++#define CONFIG_PCM_DVD_DECODER 0 ++#define CONFIG_PCM_F16LE_DECODER 0 ++#define CONFIG_PCM_F24LE_DECODER 0 ++#define CONFIG_PCM_F32BE_DECODER 0 ++#define CONFIG_PCM_F32LE_DECODER 1 ++#define CONFIG_PCM_F64BE_DECODER 0 ++#define CONFIG_PCM_F64LE_DECODER 0 ++#define CONFIG_PCM_LXF_DECODER 0 ++#define CONFIG_PCM_MULAW_DECODER 1 ++#define CONFIG_PCM_S8_DECODER 0 ++#define CONFIG_PCM_S8_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16BE_DECODER 1 ++#define CONFIG_PCM_S16BE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S16LE_DECODER 1 ++#define CONFIG_PCM_S16LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S24BE_DECODER 1 ++#define CONFIG_PCM_S24DAUD_DECODER 0 ++#define CONFIG_PCM_S24LE_DECODER 1 ++#define CONFIG_PCM_S24LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S32BE_DECODER 0 ++#define CONFIG_PCM_S32LE_DECODER 1 ++#define CONFIG_PCM_S32LE_PLANAR_DECODER 0 ++#define CONFIG_PCM_S64BE_DECODER 0 ++#define CONFIG_PCM_S64LE_DECODER 0 ++#define CONFIG_PCM_U8_DECODER 1 ++#define CONFIG_PCM_U16BE_DECODER 0 ++#define CONFIG_PCM_U16LE_DECODER 0 ++#define CONFIG_PCM_U24BE_DECODER 0 ++#define CONFIG_PCM_U24LE_DECODER 0 ++#define CONFIG_PCM_U32BE_DECODER 0 ++#define CONFIG_PCM_U32LE_DECODER 0 ++#define CONFIG_PCM_VIDC_DECODER 0 ++#define CONFIG_DERF_DPCM_DECODER 0 ++#define CONFIG_GREMLIN_DPCM_DECODER 0 ++#define CONFIG_INTERPLAY_DPCM_DECODER 0 ++#define CONFIG_ROQ_DPCM_DECODER 0 ++#define CONFIG_SDX2_DPCM_DECODER 0 ++#define CONFIG_SOL_DPCM_DECODER 0 ++#define CONFIG_XAN_DPCM_DECODER 0 ++#define CONFIG_ADPCM_4XM_DECODER 0 ++#define CONFIG_ADPCM_ADX_DECODER 0 ++#define CONFIG_ADPCM_AFC_DECODER 0 ++#define CONFIG_ADPCM_AGM_DECODER 0 ++#define CONFIG_ADPCM_AICA_DECODER 0 ++#define CONFIG_ADPCM_ARGO_DECODER 0 ++#define CONFIG_ADPCM_CT_DECODER 0 ++#define CONFIG_ADPCM_DTK_DECODER 0 ++#define CONFIG_ADPCM_EA_DECODER 0 ++#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 0 ++#define CONFIG_ADPCM_EA_R1_DECODER 0 ++#define CONFIG_ADPCM_EA_R2_DECODER 0 ++#define CONFIG_ADPCM_EA_R3_DECODER 0 ++#define CONFIG_ADPCM_EA_XAS_DECODER 0 ++#define CONFIG_ADPCM_G722_DECODER 0 ++#define CONFIG_ADPCM_G726_DECODER 0 ++#define CONFIG_ADPCM_G726LE_DECODER 0 ++#define CONFIG_ADPCM_IMA_AMV_DECODER 0 ++#define CONFIG_ADPCM_IMA_ALP_DECODER 0 ++#define CONFIG_ADPCM_IMA_APC_DECODER 0 ++#define CONFIG_ADPCM_IMA_APM_DECODER 0 ++#define CONFIG_ADPCM_IMA_CUNNING_DECODER 0 ++#define CONFIG_ADPCM_IMA_DAT4_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK3_DECODER 0 ++#define CONFIG_ADPCM_IMA_DK4_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 0 ++#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_ISS_DECODER 0 ++#define CONFIG_ADPCM_IMA_MTF_DECODER 0 ++#define CONFIG_ADPCM_IMA_OKI_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_DECODER 0 ++#define CONFIG_ADPCM_IMA_RAD_DECODER 0 ++#define CONFIG_ADPCM_IMA_SSI_DECODER 0 ++#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 0 ++#define CONFIG_ADPCM_IMA_WAV_DECODER 0 ++#define CONFIG_ADPCM_IMA_WS_DECODER 0 ++#define CONFIG_ADPCM_MS_DECODER 0 ++#define CONFIG_ADPCM_MTAF_DECODER 0 ++#define CONFIG_ADPCM_PSX_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_2_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_3_DECODER 0 ++#define CONFIG_ADPCM_SBPRO_4_DECODER 0 ++#define CONFIG_ADPCM_SWF_DECODER 0 ++#define CONFIG_ADPCM_THP_DECODER 0 ++#define CONFIG_ADPCM_THP_LE_DECODER 0 ++#define CONFIG_ADPCM_VIMA_DECODER 0 ++#define CONFIG_ADPCM_XA_DECODER 0 ++#define CONFIG_ADPCM_YAMAHA_DECODER 0 ++#define CONFIG_ADPCM_ZORK_DECODER 0 ++#define CONFIG_SSA_DECODER 0 ++#define CONFIG_ASS_DECODER 0 ++#define CONFIG_CCAPTION_DECODER 0 ++#define CONFIG_DVBSUB_DECODER 0 ++#define CONFIG_DVDSUB_DECODER 0 ++#define CONFIG_JACOSUB_DECODER 0 ++#define CONFIG_MICRODVD_DECODER 0 ++#define CONFIG_MOVTEXT_DECODER 0 ++#define CONFIG_MPL2_DECODER 0 ++#define CONFIG_PGSSUB_DECODER 0 ++#define CONFIG_PJS_DECODER 0 ++#define CONFIG_REALTEXT_DECODER 0 ++#define CONFIG_SAMI_DECODER 0 ++#define CONFIG_SRT_DECODER 0 ++#define CONFIG_STL_DECODER 0 ++#define CONFIG_SUBRIP_DECODER 0 ++#define CONFIG_SUBVIEWER_DECODER 0 ++#define CONFIG_SUBVIEWER1_DECODER 0 ++#define CONFIG_TEXT_DECODER 0 ++#define CONFIG_VPLAYER_DECODER 0 ++#define CONFIG_WEBVTT_DECODER 0 ++#define CONFIG_XSUB_DECODER 0 ++#define CONFIG_AAC_AT_DECODER 0 ++#define CONFIG_AC3_AT_DECODER 0 ++#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 ++#define CONFIG_ALAC_AT_DECODER 0 ++#define CONFIG_AMR_NB_AT_DECODER 0 ++#define CONFIG_EAC3_AT_DECODER 0 ++#define CONFIG_GSM_MS_AT_DECODER 0 ++#define CONFIG_ILBC_AT_DECODER 0 ++#define CONFIG_MP1_AT_DECODER 0 ++#define CONFIG_MP2_AT_DECODER 0 ++#define CONFIG_MP3_AT_DECODER 0 ++#define CONFIG_PCM_ALAW_AT_DECODER 0 ++#define CONFIG_PCM_MULAW_AT_DECODER 0 ++#define CONFIG_QDMC_AT_DECODER 0 ++#define CONFIG_QDM2_AT_DECODER 0 ++#define CONFIG_LIBARIBB24_DECODER 0 ++#define CONFIG_LIBCELT_DECODER 0 ++#define CONFIG_LIBCODEC2_DECODER 0 ++#define CONFIG_LIBDAV1D_DECODER 0 ++#define CONFIG_LIBDAVS2_DECODER 0 ++#define CONFIG_LIBFDK_AAC_DECODER 0 ++#define CONFIG_LIBGSM_DECODER 0 ++#define CONFIG_LIBGSM_MS_DECODER 0 ++#define CONFIG_LIBILBC_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 ++#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 ++#define CONFIG_LIBOPENJPEG_DECODER 0 ++#define CONFIG_LIBOPUS_DECODER 1 ++#define CONFIG_LIBRSVG_DECODER 0 ++#define CONFIG_LIBSPEEX_DECODER 0 ++#define CONFIG_LIBVORBIS_DECODER 0 ++#define CONFIG_LIBVPX_VP8_DECODER 0 ++#define CONFIG_LIBVPX_VP9_DECODER 0 ++#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 ++#define CONFIG_BINTEXT_DECODER 0 ++#define CONFIG_XBIN_DECODER 0 ++#define CONFIG_IDF_DECODER 0 ++#define CONFIG_LIBAOM_AV1_DECODER 0 ++#define CONFIG_LIBOPENH264_DECODER 0 ++#define CONFIG_H264_CUVID_DECODER 0 ++#define CONFIG_HEVC_CUVID_DECODER 0 ++#define CONFIG_HEVC_MEDIACODEC_DECODER 0 ++#define CONFIG_MJPEG_CUVID_DECODER 0 ++#define CONFIG_MJPEG_QSV_DECODER 0 ++#define CONFIG_MPEG1_CUVID_DECODER 0 ++#define CONFIG_MPEG2_CUVID_DECODER 0 ++#define CONFIG_MPEG4_CUVID_DECODER 0 ++#define CONFIG_MPEG4_MEDIACODEC_DECODER 0 ++#define CONFIG_VC1_CUVID_DECODER 0 ++#define CONFIG_VP8_CUVID_DECODER 0 ++#define CONFIG_VP8_MEDIACODEC_DECODER 0 ++#define CONFIG_VP8_QSV_DECODER 0 ++#define CONFIG_VP9_CUVID_DECODER 0 ++#define CONFIG_VP9_MEDIACODEC_DECODER 0 ++#define CONFIG_VP9_QSV_DECODER 0 ++#define CONFIG_A64MULTI_ENCODER 0 ++#define CONFIG_A64MULTI5_ENCODER 0 ++#define CONFIG_ALIAS_PIX_ENCODER 0 ++#define CONFIG_AMV_ENCODER 0 ++#define CONFIG_APNG_ENCODER 0 ++#define CONFIG_ASV1_ENCODER 0 ++#define CONFIG_ASV2_ENCODER 0 ++#define CONFIG_AVRP_ENCODER 0 ++#define CONFIG_AVUI_ENCODER 0 ++#define CONFIG_AYUV_ENCODER 0 ++#define CONFIG_BMP_ENCODER 0 ++#define CONFIG_CFHD_ENCODER 0 ++#define CONFIG_CINEPAK_ENCODER 0 ++#define CONFIG_CLJR_ENCODER 0 ++#define CONFIG_COMFORTNOISE_ENCODER 0 ++#define CONFIG_DNXHD_ENCODER 0 ++#define CONFIG_DPX_ENCODER 0 ++#define CONFIG_DVVIDEO_ENCODER 0 ++#define CONFIG_FFV1_ENCODER 0 ++#define CONFIG_FFVHUFF_ENCODER 0 ++#define CONFIG_FITS_ENCODER 0 ++#define CONFIG_FLASHSV_ENCODER 0 ++#define CONFIG_FLASHSV2_ENCODER 0 ++#define CONFIG_FLV_ENCODER 0 ++#define CONFIG_GIF_ENCODER 0 ++#define CONFIG_H261_ENCODER 0 ++#define CONFIG_H263_ENCODER 0 ++#define CONFIG_H263P_ENCODER 0 ++#define CONFIG_HAP_ENCODER 0 ++#define CONFIG_HUFFYUV_ENCODER 0 ++#define CONFIG_JPEG2000_ENCODER 0 ++#define CONFIG_JPEGLS_ENCODER 0 ++#define CONFIG_LJPEG_ENCODER 0 ++#define CONFIG_MAGICYUV_ENCODER 0 ++#define CONFIG_MJPEG_ENCODER 0 ++#define CONFIG_MPEG1VIDEO_ENCODER 0 ++#define CONFIG_MPEG2VIDEO_ENCODER 0 ++#define CONFIG_MPEG4_ENCODER 0 ++#define CONFIG_MSMPEG4V2_ENCODER 0 ++#define CONFIG_MSMPEG4V3_ENCODER 0 ++#define CONFIG_MSVIDEO1_ENCODER 0 ++#define CONFIG_PAM_ENCODER 0 ++#define CONFIG_PBM_ENCODER 0 ++#define CONFIG_PCX_ENCODER 0 ++#define CONFIG_PGM_ENCODER 0 ++#define CONFIG_PGMYUV_ENCODER 0 ++#define CONFIG_PNG_ENCODER 0 ++#define CONFIG_PPM_ENCODER 0 ++#define CONFIG_PRORES_ENCODER 0 ++#define CONFIG_PRORES_AW_ENCODER 0 ++#define CONFIG_PRORES_KS_ENCODER 0 ++#define CONFIG_QTRLE_ENCODER 0 ++#define CONFIG_R10K_ENCODER 0 ++#define CONFIG_R210_ENCODER 0 ++#define CONFIG_RAWVIDEO_ENCODER 0 ++#define CONFIG_ROQ_ENCODER 0 ++#define CONFIG_RPZA_ENCODER 0 ++#define CONFIG_RV10_ENCODER 0 ++#define CONFIG_RV20_ENCODER 0 ++#define CONFIG_S302M_ENCODER 0 ++#define CONFIG_SGI_ENCODER 0 ++#define CONFIG_SNOW_ENCODER 0 ++#define CONFIG_SUNRAST_ENCODER 0 ++#define CONFIG_SVQ1_ENCODER 0 ++#define CONFIG_TARGA_ENCODER 0 ++#define CONFIG_TIFF_ENCODER 0 ++#define CONFIG_UTVIDEO_ENCODER 0 ++#define CONFIG_V210_ENCODER 0 ++#define CONFIG_V308_ENCODER 0 ++#define CONFIG_V408_ENCODER 0 ++#define CONFIG_V410_ENCODER 0 ++#define CONFIG_VC2_ENCODER 0 ++#define CONFIG_WRAPPED_AVFRAME_ENCODER 0 ++#define CONFIG_WMV1_ENCODER 0 ++#define CONFIG_WMV2_ENCODER 0 ++#define CONFIG_XBM_ENCODER 0 ++#define CONFIG_XFACE_ENCODER 0 ++#define CONFIG_XWD_ENCODER 0 ++#define CONFIG_Y41P_ENCODER 0 ++#define CONFIG_YUV4_ENCODER 0 ++#define CONFIG_ZLIB_ENCODER 0 ++#define CONFIG_ZMBV_ENCODER 0 ++#define CONFIG_AAC_ENCODER 0 ++#define CONFIG_AC3_ENCODER 0 ++#define CONFIG_AC3_FIXED_ENCODER 0 ++#define CONFIG_ALAC_ENCODER 0 ++#define CONFIG_APTX_ENCODER 0 ++#define CONFIG_APTX_HD_ENCODER 0 ++#define CONFIG_DCA_ENCODER 0 ++#define CONFIG_EAC3_ENCODER 0 ++#define CONFIG_FLAC_ENCODER 0 ++#define CONFIG_G723_1_ENCODER 0 ++#define CONFIG_MLP_ENCODER 0 ++#define CONFIG_MP2_ENCODER 0 ++#define CONFIG_MP2FIXED_ENCODER 0 ++#define CONFIG_NELLYMOSER_ENCODER 0 ++#define CONFIG_OPUS_ENCODER 0 ++#define CONFIG_RA_144_ENCODER 0 ++#define CONFIG_SBC_ENCODER 0 ++#define CONFIG_SONIC_ENCODER 0 ++#define CONFIG_SONIC_LS_ENCODER 0 ++#define CONFIG_TRUEHD_ENCODER 0 ++#define CONFIG_TTA_ENCODER 0 ++#define CONFIG_VORBIS_ENCODER 0 ++#define CONFIG_WAVPACK_ENCODER 0 ++#define CONFIG_WMAV1_ENCODER 0 ++#define CONFIG_WMAV2_ENCODER 0 ++#define CONFIG_PCM_ALAW_ENCODER 0 ++#define CONFIG_PCM_DVD_ENCODER 0 ++#define CONFIG_PCM_F32BE_ENCODER 0 ++#define CONFIG_PCM_F32LE_ENCODER 0 ++#define CONFIG_PCM_F64BE_ENCODER 0 ++#define CONFIG_PCM_F64LE_ENCODER 0 ++#define CONFIG_PCM_MULAW_ENCODER 0 ++#define CONFIG_PCM_S8_ENCODER 0 ++#define CONFIG_PCM_S8_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16BE_ENCODER 0 ++#define CONFIG_PCM_S16BE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S16LE_ENCODER 0 ++#define CONFIG_PCM_S16LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S24BE_ENCODER 0 ++#define CONFIG_PCM_S24DAUD_ENCODER 0 ++#define CONFIG_PCM_S24LE_ENCODER 0 ++#define CONFIG_PCM_S24LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S32BE_ENCODER 0 ++#define CONFIG_PCM_S32LE_ENCODER 0 ++#define CONFIG_PCM_S32LE_PLANAR_ENCODER 0 ++#define CONFIG_PCM_S64BE_ENCODER 0 ++#define CONFIG_PCM_S64LE_ENCODER 0 ++#define CONFIG_PCM_U8_ENCODER 0 ++#define CONFIG_PCM_U16BE_ENCODER 0 ++#define CONFIG_PCM_U16LE_ENCODER 0 ++#define CONFIG_PCM_U24BE_ENCODER 0 ++#define CONFIG_PCM_U24LE_ENCODER 0 ++#define CONFIG_PCM_U32BE_ENCODER 0 ++#define CONFIG_PCM_U32LE_ENCODER 0 ++#define CONFIG_PCM_VIDC_ENCODER 0 ++#define CONFIG_ROQ_DPCM_ENCODER 0 ++#define CONFIG_ADPCM_ADX_ENCODER 0 ++#define CONFIG_ADPCM_ARGO_ENCODER 0 ++#define CONFIG_ADPCM_G722_ENCODER 0 ++#define CONFIG_ADPCM_G726_ENCODER 0 ++#define CONFIG_ADPCM_G726LE_ENCODER 0 ++#define CONFIG_ADPCM_IMA_APM_ENCODER 0 ++#define CONFIG_ADPCM_IMA_QT_ENCODER 0 ++#define CONFIG_ADPCM_IMA_SSI_ENCODER 0 ++#define CONFIG_ADPCM_IMA_WAV_ENCODER 0 ++#define CONFIG_ADPCM_MS_ENCODER 0 ++#define CONFIG_ADPCM_SWF_ENCODER 0 ++#define CONFIG_ADPCM_YAMAHA_ENCODER 0 ++#define CONFIG_SSA_ENCODER 0 ++#define CONFIG_ASS_ENCODER 0 ++#define CONFIG_DVBSUB_ENCODER 0 ++#define CONFIG_DVDSUB_ENCODER 0 ++#define CONFIG_MOVTEXT_ENCODER 0 ++#define CONFIG_SRT_ENCODER 0 ++#define CONFIG_SUBRIP_ENCODER 0 ++#define CONFIG_TEXT_ENCODER 0 ++#define CONFIG_WEBVTT_ENCODER 0 ++#define CONFIG_XSUB_ENCODER 0 ++#define CONFIG_AAC_AT_ENCODER 0 ++#define CONFIG_ALAC_AT_ENCODER 0 ++#define CONFIG_ILBC_AT_ENCODER 0 ++#define CONFIG_PCM_ALAW_AT_ENCODER 0 ++#define CONFIG_PCM_MULAW_AT_ENCODER 0 ++#define CONFIG_LIBAOM_AV1_ENCODER 0 ++#define CONFIG_LIBCODEC2_ENCODER 0 ++#define CONFIG_LIBFDK_AAC_ENCODER 0 ++#define CONFIG_LIBGSM_ENCODER 0 ++#define CONFIG_LIBGSM_MS_ENCODER 0 ++#define CONFIG_LIBILBC_ENCODER 0 ++#define CONFIG_LIBMP3LAME_ENCODER 0 ++#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 ++#define CONFIG_LIBOPENJPEG_ENCODER 0 ++#define CONFIG_LIBOPUS_ENCODER 0 ++#define CONFIG_LIBRAV1E_ENCODER 0 ++#define CONFIG_LIBSHINE_ENCODER 0 ++#define CONFIG_LIBSPEEX_ENCODER 0 ++#define CONFIG_LIBSVTAV1_ENCODER 0 ++#define CONFIG_LIBTHEORA_ENCODER 0 ++#define CONFIG_LIBTWOLAME_ENCODER 0 ++#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 ++#define CONFIG_LIBVORBIS_ENCODER 0 ++#define CONFIG_LIBVPX_VP8_ENCODER 0 ++#define CONFIG_LIBVPX_VP9_ENCODER 0 ++#define CONFIG_LIBWAVPACK_ENCODER 0 ++#define CONFIG_LIBWEBP_ANIM_ENCODER 0 ++#define CONFIG_LIBWEBP_ENCODER 0 ++#define CONFIG_LIBX262_ENCODER 0 ++#define CONFIG_LIBX264_ENCODER 0 ++#define CONFIG_LIBX264RGB_ENCODER 0 ++#define CONFIG_LIBX265_ENCODER 0 ++#define CONFIG_LIBXAVS_ENCODER 0 ++#define CONFIG_LIBXAVS2_ENCODER 0 ++#define CONFIG_LIBXVID_ENCODER 0 ++#define CONFIG_AAC_MF_ENCODER 0 ++#define CONFIG_AC3_MF_ENCODER 0 ++#define CONFIG_H263_V4L2M2M_ENCODER 0 ++#define CONFIG_LIBOPENH264_ENCODER 0 ++#define CONFIG_H264_AMF_ENCODER 0 ++#define CONFIG_H264_MF_ENCODER 0 ++#define CONFIG_H264_NVENC_ENCODER 0 ++#define CONFIG_H264_OMX_ENCODER 0 ++#define CONFIG_H264_QSV_ENCODER 0 ++#define CONFIG_H264_V4L2M2M_ENCODER 0 ++#define CONFIG_H264_VAAPI_ENCODER 0 ++#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_NVENC_ENCODER 0 ++#define CONFIG_NVENC_H264_ENCODER 0 ++#define CONFIG_NVENC_HEVC_ENCODER 0 ++#define CONFIG_HEVC_AMF_ENCODER 0 ++#define CONFIG_HEVC_MF_ENCODER 0 ++#define CONFIG_HEVC_NVENC_ENCODER 0 ++#define CONFIG_HEVC_QSV_ENCODER 0 ++#define CONFIG_HEVC_V4L2M2M_ENCODER 0 ++#define CONFIG_HEVC_VAAPI_ENCODER 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_ENCODER 0 ++#define CONFIG_LIBKVAZAAR_ENCODER 0 ++#define CONFIG_MJPEG_QSV_ENCODER 0 ++#define CONFIG_MJPEG_VAAPI_ENCODER 0 ++#define CONFIG_MP3_MF_ENCODER 0 ++#define CONFIG_MPEG2_QSV_ENCODER 0 ++#define CONFIG_MPEG2_VAAPI_ENCODER 0 ++#define CONFIG_MPEG4_OMX_ENCODER 0 ++#define CONFIG_MPEG4_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_V4L2M2M_ENCODER 0 ++#define CONFIG_VP8_VAAPI_ENCODER 0 ++#define CONFIG_VP9_VAAPI_ENCODER 0 ++#define CONFIG_VP9_QSV_ENCODER 0 ++#define CONFIG_H263_VAAPI_HWACCEL 0 ++#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_H264_D3D11VA_HWACCEL 0 ++#define CONFIG_H264_D3D11VA2_HWACCEL 0 ++#define CONFIG_H264_DXVA2_HWACCEL 0 ++#define CONFIG_H264_NVDEC_HWACCEL 0 ++#define CONFIG_H264_VAAPI_HWACCEL 0 ++#define CONFIG_H264_VDPAU_HWACCEL 0 ++#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA_HWACCEL 0 ++#define CONFIG_HEVC_D3D11VA2_HWACCEL 0 ++#define CONFIG_HEVC_DXVA2_HWACCEL 0 ++#define CONFIG_HEVC_NVDEC_HWACCEL 0 ++#define CONFIG_HEVC_VAAPI_HWACCEL 0 ++#define CONFIG_HEVC_VDPAU_HWACCEL 0 ++#define CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MJPEG_NVDEC_HWACCEL 0 ++#define CONFIG_MJPEG_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG1_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG1_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG1_XVMC_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 ++#define CONFIG_MPEG2_D3D11VA2_HWACCEL 0 ++#define CONFIG_MPEG2_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG2_DXVA2_HWACCEL 0 ++#define CONFIG_MPEG2_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG2_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_MPEG2_XVMC_HWACCEL 0 ++#define CONFIG_MPEG4_NVDEC_HWACCEL 0 ++#define CONFIG_MPEG4_VAAPI_HWACCEL 0 ++#define CONFIG_MPEG4_VDPAU_HWACCEL 0 ++#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA_HWACCEL 0 ++#define CONFIG_VC1_D3D11VA2_HWACCEL 0 ++#define CONFIG_VC1_DXVA2_HWACCEL 0 ++#define CONFIG_VC1_NVDEC_HWACCEL 0 ++#define CONFIG_VC1_VAAPI_HWACCEL 0 ++#define CONFIG_VC1_VDPAU_HWACCEL 0 ++#define CONFIG_VP8_NVDEC_HWACCEL 0 ++#define CONFIG_VP8_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA_HWACCEL 0 ++#define CONFIG_VP9_D3D11VA2_HWACCEL 0 ++#define CONFIG_VP9_DXVA2_HWACCEL 0 ++#define CONFIG_VP9_NVDEC_HWACCEL 0 ++#define CONFIG_VP9_VAAPI_HWACCEL 0 ++#define CONFIG_VP9_VDPAU_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA_HWACCEL 0 ++#define CONFIG_WMV3_D3D11VA2_HWACCEL 0 ++#define CONFIG_WMV3_DXVA2_HWACCEL 0 ++#define CONFIG_WMV3_NVDEC_HWACCEL 0 ++#define CONFIG_WMV3_VAAPI_HWACCEL 0 ++#define CONFIG_WMV3_VDPAU_HWACCEL 0 ++#define CONFIG_AAC_PARSER 0 ++#define CONFIG_AAC_LATM_PARSER 0 ++#define CONFIG_AC3_PARSER 0 ++#define CONFIG_ADX_PARSER 0 ++#define CONFIG_AV1_PARSER 0 ++#define CONFIG_AVS2_PARSER 0 ++#define CONFIG_BMP_PARSER 0 ++#define CONFIG_CAVSVIDEO_PARSER 0 ++#define CONFIG_COOK_PARSER 0 ++#define CONFIG_DCA_PARSER 0 ++#define CONFIG_DIRAC_PARSER 0 ++#define CONFIG_DNXHD_PARSER 0 ++#define CONFIG_DPX_PARSER 0 ++#define CONFIG_DVAUDIO_PARSER 0 ++#define CONFIG_DVBSUB_PARSER 0 ++#define CONFIG_DVDSUB_PARSER 0 ++#define CONFIG_DVD_NAV_PARSER 0 ++#define CONFIG_FLAC_PARSER 1 ++#define CONFIG_G723_1_PARSER 0 ++#define CONFIG_G729_PARSER 0 ++#define CONFIG_GIF_PARSER 0 ++#define CONFIG_GSM_PARSER 0 ++#define CONFIG_H261_PARSER 0 ++#define CONFIG_H263_PARSER 0 ++#define CONFIG_H264_PARSER 0 ++#define CONFIG_HEVC_PARSER 0 ++#define CONFIG_JPEG2000_PARSER 0 ++#define CONFIG_MJPEG_PARSER 0 ++#define CONFIG_MLP_PARSER 0 ++#define CONFIG_MPEG4VIDEO_PARSER 0 ++#define CONFIG_MPEGAUDIO_PARSER 1 ++#define CONFIG_MPEGVIDEO_PARSER 0 ++#define CONFIG_OPUS_PARSER 1 ++#define CONFIG_PNG_PARSER 0 ++#define CONFIG_PNM_PARSER 0 ++#define CONFIG_RV30_PARSER 0 ++#define CONFIG_RV40_PARSER 0 ++#define CONFIG_SBC_PARSER 0 ++#define CONFIG_SIPR_PARSER 0 ++#define CONFIG_TAK_PARSER 0 ++#define CONFIG_VC1_PARSER 0 ++#define CONFIG_VORBIS_PARSER 1 ++#define CONFIG_VP3_PARSER 1 ++#define CONFIG_VP8_PARSER 1 ++#define CONFIG_VP9_PARSER 1 ++#define CONFIG_WEBP_PARSER 0 ++#define CONFIG_XMA_PARSER 0 ++#define CONFIG_ALSA_INDEV 0 ++#define CONFIG_ANDROID_CAMERA_INDEV 0 ++#define CONFIG_AVFOUNDATION_INDEV 0 ++#define CONFIG_BKTR_INDEV 0 ++#define CONFIG_DECKLINK_INDEV 0 ++#define CONFIG_DSHOW_INDEV 0 ++#define CONFIG_FBDEV_INDEV 0 ++#define CONFIG_GDIGRAB_INDEV 0 ++#define CONFIG_IEC61883_INDEV 0 ++#define CONFIG_JACK_INDEV 0 ++#define CONFIG_KMSGRAB_INDEV 0 ++#define CONFIG_LAVFI_INDEV 0 ++#define CONFIG_OPENAL_INDEV 0 ++#define CONFIG_OSS_INDEV 0 ++#define CONFIG_PULSE_INDEV 0 ++#define CONFIG_SNDIO_INDEV 0 ++#define CONFIG_V4L2_INDEV 0 ++#define CONFIG_VFWCAP_INDEV 0 ++#define CONFIG_XCBGRAB_INDEV 0 ++#define CONFIG_LIBCDIO_INDEV 0 ++#define CONFIG_LIBDC1394_INDEV 0 ++#define CONFIG_ALSA_OUTDEV 0 ++#define CONFIG_AUDIOTOOLBOX_OUTDEV 0 ++#define CONFIG_CACA_OUTDEV 0 ++#define CONFIG_DECKLINK_OUTDEV 0 ++#define CONFIG_FBDEV_OUTDEV 0 ++#define CONFIG_OPENGL_OUTDEV 0 ++#define CONFIG_OSS_OUTDEV 0 ++#define CONFIG_PULSE_OUTDEV 0 ++#define CONFIG_SDL2_OUTDEV 0 ++#define CONFIG_SNDIO_OUTDEV 0 ++#define CONFIG_V4L2_OUTDEV 0 ++#define CONFIG_XV_OUTDEV 0 ++#define CONFIG_ABENCH_FILTER 0 ++#define CONFIG_ACOMPRESSOR_FILTER 0 ++#define CONFIG_ACONTRAST_FILTER 0 ++#define CONFIG_ACOPY_FILTER 0 ++#define CONFIG_ACUE_FILTER 0 ++#define CONFIG_ACROSSFADE_FILTER 0 ++#define CONFIG_ACROSSOVER_FILTER 0 ++#define CONFIG_ACRUSHER_FILTER 0 ++#define CONFIG_ADECLICK_FILTER 0 ++#define CONFIG_ADECLIP_FILTER 0 ++#define CONFIG_ADELAY_FILTER 0 ++#define CONFIG_ADERIVATIVE_FILTER 0 ++#define CONFIG_AECHO_FILTER 0 ++#define CONFIG_AEMPHASIS_FILTER 0 ++#define CONFIG_AEVAL_FILTER 0 ++#define CONFIG_AFADE_FILTER 0 ++#define CONFIG_AFFTDN_FILTER 0 ++#define CONFIG_AFFTFILT_FILTER 0 ++#define CONFIG_AFIR_FILTER 0 ++#define CONFIG_AFORMAT_FILTER 0 ++#define CONFIG_AGATE_FILTER 0 ++#define CONFIG_AIIR_FILTER 0 ++#define CONFIG_AINTEGRAL_FILTER 0 ++#define CONFIG_AINTERLEAVE_FILTER 0 ++#define CONFIG_ALIMITER_FILTER 0 ++#define CONFIG_ALLPASS_FILTER 0 ++#define CONFIG_ALOOP_FILTER 0 ++#define CONFIG_AMERGE_FILTER 0 ++#define CONFIG_AMETADATA_FILTER 0 ++#define CONFIG_AMIX_FILTER 0 ++#define CONFIG_AMULTIPLY_FILTER 0 ++#define CONFIG_ANEQUALIZER_FILTER 0 ++#define CONFIG_ANLMDN_FILTER 0 ++#define CONFIG_ANLMS_FILTER 0 ++#define CONFIG_ANULL_FILTER 0 ++#define CONFIG_APAD_FILTER 0 ++#define CONFIG_APERMS_FILTER 0 ++#define CONFIG_APHASER_FILTER 0 ++#define CONFIG_APULSATOR_FILTER 0 ++#define CONFIG_AREALTIME_FILTER 0 ++#define CONFIG_ARESAMPLE_FILTER 0 ++#define CONFIG_AREVERSE_FILTER 0 ++#define CONFIG_ARNNDN_FILTER 0 ++#define CONFIG_ASELECT_FILTER 0 ++#define CONFIG_ASENDCMD_FILTER 0 ++#define CONFIG_ASETNSAMPLES_FILTER 0 ++#define CONFIG_ASETPTS_FILTER 0 ++#define CONFIG_ASETRATE_FILTER 0 ++#define CONFIG_ASETTB_FILTER 0 ++#define CONFIG_ASHOWINFO_FILTER 0 ++#define CONFIG_ASIDEDATA_FILTER 0 ++#define CONFIG_ASOFTCLIP_FILTER 0 ++#define CONFIG_ASPLIT_FILTER 0 ++#define CONFIG_ASR_FILTER 0 ++#define CONFIG_ASTATS_FILTER 0 ++#define CONFIG_ASTREAMSELECT_FILTER 0 ++#define CONFIG_ASUBBOOST_FILTER 0 ++#define CONFIG_ATEMPO_FILTER 0 ++#define CONFIG_ATRIM_FILTER 0 ++#define CONFIG_AXCORRELATE_FILTER 0 ++#define CONFIG_AZMQ_FILTER 0 ++#define CONFIG_BANDPASS_FILTER 0 ++#define CONFIG_BANDREJECT_FILTER 0 ++#define CONFIG_BASS_FILTER 0 ++#define CONFIG_BIQUAD_FILTER 0 ++#define CONFIG_BS2B_FILTER 0 ++#define CONFIG_CHROMABER_VULKAN_FILTER 0 ++#define CONFIG_CHANNELMAP_FILTER 0 ++#define CONFIG_CHANNELSPLIT_FILTER 0 ++#define CONFIG_CHORUS_FILTER 0 ++#define CONFIG_COMPAND_FILTER 0 ++#define CONFIG_COMPENSATIONDELAY_FILTER 0 ++#define CONFIG_CROSSFEED_FILTER 0 ++#define CONFIG_CRYSTALIZER_FILTER 0 ++#define CONFIG_DCSHIFT_FILTER 0 ++#define CONFIG_DEESSER_FILTER 0 ++#define CONFIG_DRMETER_FILTER 0 ++#define CONFIG_DYNAUDNORM_FILTER 0 ++#define CONFIG_EARWAX_FILTER 0 ++#define CONFIG_EBUR128_FILTER 0 ++#define CONFIG_EQUALIZER_FILTER 0 ++#define CONFIG_EXTRASTEREO_FILTER 0 ++#define CONFIG_FIREQUALIZER_FILTER 0 ++#define CONFIG_FLANGER_FILTER 0 ++#define CONFIG_HAAS_FILTER 0 ++#define CONFIG_HDCD_FILTER 0 ++#define CONFIG_HEADPHONE_FILTER 0 ++#define CONFIG_HIGHPASS_FILTER 0 ++#define CONFIG_HIGHSHELF_FILTER 0 ++#define CONFIG_JOIN_FILTER 0 ++#define CONFIG_LADSPA_FILTER 0 ++#define CONFIG_LOUDNORM_FILTER 0 ++#define CONFIG_LOWPASS_FILTER 0 ++#define CONFIG_LOWSHELF_FILTER 0 ++#define CONFIG_LV2_FILTER 0 ++#define CONFIG_MCOMPAND_FILTER 0 ++#define CONFIG_PAN_FILTER 0 ++#define CONFIG_REPLAYGAIN_FILTER 0 ++#define CONFIG_RESAMPLE_FILTER 0 ++#define CONFIG_RUBBERBAND_FILTER 0 ++#define CONFIG_SIDECHAINCOMPRESS_FILTER 0 ++#define CONFIG_SIDECHAINGATE_FILTER 0 ++#define CONFIG_SILENCEDETECT_FILTER 0 ++#define CONFIG_SILENCEREMOVE_FILTER 0 ++#define CONFIG_SOFALIZER_FILTER 0 ++#define CONFIG_STEREOTOOLS_FILTER 0 ++#define CONFIG_STEREOWIDEN_FILTER 0 ++#define CONFIG_SUPEREQUALIZER_FILTER 0 ++#define CONFIG_SURROUND_FILTER 0 ++#define CONFIG_TREBLE_FILTER 0 ++#define CONFIG_TREMOLO_FILTER 0 ++#define CONFIG_VIBRATO_FILTER 0 ++#define CONFIG_VOLUME_FILTER 0 ++#define CONFIG_VOLUMEDETECT_FILTER 0 ++#define CONFIG_AEVALSRC_FILTER 0 ++#define CONFIG_AFIRSRC_FILTER 0 ++#define CONFIG_ANOISESRC_FILTER 0 ++#define CONFIG_ANULLSRC_FILTER 0 ++#define CONFIG_FLITE_FILTER 0 ++#define CONFIG_HILBERT_FILTER 0 ++#define CONFIG_SINC_FILTER 0 ++#define CONFIG_SINE_FILTER 0 ++#define CONFIG_ANULLSINK_FILTER 0 ++#define CONFIG_ADDROI_FILTER 0 ++#define CONFIG_ALPHAEXTRACT_FILTER 0 ++#define CONFIG_ALPHAMERGE_FILTER 0 ++#define CONFIG_AMPLIFY_FILTER 0 ++#define CONFIG_ASS_FILTER 0 ++#define CONFIG_ATADENOISE_FILTER 0 ++#define CONFIG_AVGBLUR_FILTER 0 ++#define CONFIG_AVGBLUR_OPENCL_FILTER 0 ++#define CONFIG_AVGBLUR_VULKAN_FILTER 0 ++#define CONFIG_BBOX_FILTER 0 ++#define CONFIG_BENCH_FILTER 0 ++#define CONFIG_BILATERAL_FILTER 0 ++#define CONFIG_BITPLANENOISE_FILTER 0 ++#define CONFIG_BLACKDETECT_FILTER 0 ++#define CONFIG_BLACKFRAME_FILTER 0 ++#define CONFIG_BLEND_FILTER 0 ++#define CONFIG_BM3D_FILTER 0 ++#define CONFIG_BOXBLUR_FILTER 0 ++#define CONFIG_BOXBLUR_OPENCL_FILTER 0 ++#define CONFIG_BWDIF_FILTER 0 ++#define CONFIG_CAS_FILTER 0 ++#define CONFIG_CHROMAHOLD_FILTER 0 ++#define CONFIG_CHROMAKEY_FILTER 0 ++#define CONFIG_CHROMANR_FILTER 0 ++#define CONFIG_CHROMASHIFT_FILTER 0 ++#define CONFIG_CIESCOPE_FILTER 0 ++#define CONFIG_CODECVIEW_FILTER 0 ++#define CONFIG_COLORBALANCE_FILTER 0 ++#define CONFIG_COLORCHANNELMIXER_FILTER 0 ++#define CONFIG_COLORKEY_FILTER 0 ++#define CONFIG_COLORKEY_OPENCL_FILTER 0 ++#define CONFIG_COLORHOLD_FILTER 0 ++#define CONFIG_COLORLEVELS_FILTER 0 ++#define CONFIG_COLORMATRIX_FILTER 0 ++#define CONFIG_COLORSPACE_FILTER 0 ++#define CONFIG_CONVOLUTION_FILTER 0 ++#define CONFIG_CONVOLUTION_OPENCL_FILTER 0 ++#define CONFIG_CONVOLVE_FILTER 0 ++#define CONFIG_COPY_FILTER 0 ++#define CONFIG_COREIMAGE_FILTER 0 ++#define CONFIG_COVER_RECT_FILTER 0 ++#define CONFIG_CROP_FILTER 0 ++#define CONFIG_CROPDETECT_FILTER 0 ++#define CONFIG_CUE_FILTER 0 ++#define CONFIG_CURVES_FILTER 0 ++#define CONFIG_DATASCOPE_FILTER 0 ++#define CONFIG_DBLUR_FILTER 0 ++#define CONFIG_DCTDNOIZ_FILTER 0 ++#define CONFIG_DEBAND_FILTER 0 ++#define CONFIG_DEBLOCK_FILTER 0 ++#define CONFIG_DECIMATE_FILTER 0 ++#define CONFIG_DECONVOLVE_FILTER 0 ++#define CONFIG_DEDOT_FILTER 0 ++#define CONFIG_DEFLATE_FILTER 0 ++#define CONFIG_DEFLICKER_FILTER 0 ++#define CONFIG_DEINTERLACE_QSV_FILTER 0 ++#define CONFIG_DEINTERLACE_VAAPI_FILTER 0 ++#define CONFIG_DEJUDDER_FILTER 0 ++#define CONFIG_DELOGO_FILTER 0 ++#define CONFIG_DENOISE_VAAPI_FILTER 0 ++#define CONFIG_DERAIN_FILTER 0 ++#define CONFIG_DESHAKE_FILTER 0 ++#define CONFIG_DESHAKE_OPENCL_FILTER 0 ++#define CONFIG_DESPILL_FILTER 0 ++#define CONFIG_DETELECINE_FILTER 0 ++#define CONFIG_DILATION_FILTER 0 ++#define CONFIG_DILATION_OPENCL_FILTER 0 ++#define CONFIG_DISPLACE_FILTER 0 ++#define CONFIG_DNN_PROCESSING_FILTER 0 ++#define CONFIG_DOUBLEWEAVE_FILTER 0 ++#define CONFIG_DRAWBOX_FILTER 0 ++#define CONFIG_DRAWGRAPH_FILTER 0 ++#define CONFIG_DRAWGRID_FILTER 0 ++#define CONFIG_DRAWTEXT_FILTER 0 ++#define CONFIG_EDGEDETECT_FILTER 0 ++#define CONFIG_ELBG_FILTER 0 ++#define CONFIG_ENTROPY_FILTER 0 ++#define CONFIG_EQ_FILTER 0 ++#define CONFIG_EROSION_FILTER 0 ++#define CONFIG_EROSION_OPENCL_FILTER 0 ++#define CONFIG_EXTRACTPLANES_FILTER 0 ++#define CONFIG_FADE_FILTER 0 ++#define CONFIG_FFTDNOIZ_FILTER 0 ++#define CONFIG_FFTFILT_FILTER 0 ++#define CONFIG_FIELD_FILTER 0 ++#define CONFIG_FIELDHINT_FILTER 0 ++#define CONFIG_FIELDMATCH_FILTER 0 ++#define CONFIG_FIELDORDER_FILTER 0 ++#define CONFIG_FILLBORDERS_FILTER 0 ++#define CONFIG_FIND_RECT_FILTER 0 ++#define CONFIG_FLOODFILL_FILTER 0 ++#define CONFIG_FORMAT_FILTER 0 ++#define CONFIG_FPS_FILTER 0 ++#define CONFIG_FRAMEPACK_FILTER 0 ++#define CONFIG_FRAMERATE_FILTER 0 ++#define CONFIG_FRAMESTEP_FILTER 0 ++#define CONFIG_FREEZEDETECT_FILTER 0 ++#define CONFIG_FREEZEFRAMES_FILTER 0 ++#define CONFIG_FREI0R_FILTER 0 ++#define CONFIG_FSPP_FILTER 0 ++#define CONFIG_GBLUR_FILTER 0 ++#define CONFIG_GEQ_FILTER 0 ++#define CONFIG_GRADFUN_FILTER 0 ++#define CONFIG_GRAPHMONITOR_FILTER 0 ++#define CONFIG_GREYEDGE_FILTER 0 ++#define CONFIG_HALDCLUT_FILTER 0 ++#define CONFIG_HFLIP_FILTER 0 ++#define CONFIG_HISTEQ_FILTER 0 ++#define CONFIG_HISTOGRAM_FILTER 0 ++#define CONFIG_HQDN3D_FILTER 0 ++#define CONFIG_HQX_FILTER 0 ++#define CONFIG_HSTACK_FILTER 0 ++#define CONFIG_HUE_FILTER 0 ++#define CONFIG_HWDOWNLOAD_FILTER 0 ++#define CONFIG_HWMAP_FILTER 0 ++#define CONFIG_HWUPLOAD_FILTER 0 ++#define CONFIG_HWUPLOAD_CUDA_FILTER 0 ++#define CONFIG_HYSTERESIS_FILTER 0 ++#define CONFIG_IDET_FILTER 0 ++#define CONFIG_IL_FILTER 0 ++#define CONFIG_INFLATE_FILTER 0 ++#define CONFIG_INTERLACE_FILTER 0 ++#define CONFIG_INTERLEAVE_FILTER 0 ++#define CONFIG_KERNDEINT_FILTER 0 ++#define CONFIG_LAGFUN_FILTER 0 ++#define CONFIG_LENSCORRECTION_FILTER 0 ++#define CONFIG_LENSFUN_FILTER 0 ++#define CONFIG_LIBVMAF_FILTER 0 ++#define CONFIG_LIMITER_FILTER 0 ++#define CONFIG_LOOP_FILTER 0 ++#define CONFIG_LUMAKEY_FILTER 0 ++#define CONFIG_LUT_FILTER 0 ++#define CONFIG_LUT1D_FILTER 0 ++#define CONFIG_LUT2_FILTER 0 ++#define CONFIG_LUT3D_FILTER 0 ++#define CONFIG_LUTRGB_FILTER 0 ++#define CONFIG_LUTYUV_FILTER 0 ++#define CONFIG_MASKEDCLAMP_FILTER 0 ++#define CONFIG_MASKEDMAX_FILTER 0 ++#define CONFIG_MASKEDMERGE_FILTER 0 ++#define CONFIG_MASKEDMIN_FILTER 0 ++#define CONFIG_MASKEDTHRESHOLD_FILTER 0 ++#define CONFIG_MASKFUN_FILTER 0 ++#define CONFIG_MCDEINT_FILTER 0 ++#define CONFIG_MEDIAN_FILTER 0 ++#define CONFIG_MERGEPLANES_FILTER 0 ++#define CONFIG_MESTIMATE_FILTER 0 ++#define CONFIG_METADATA_FILTER 0 ++#define CONFIG_MIDEQUALIZER_FILTER 0 ++#define CONFIG_MINTERPOLATE_FILTER 0 ++#define CONFIG_MIX_FILTER 0 ++#define CONFIG_MPDECIMATE_FILTER 0 ++#define CONFIG_NEGATE_FILTER 0 ++#define CONFIG_NLMEANS_FILTER 0 ++#define CONFIG_NLMEANS_OPENCL_FILTER 0 ++#define CONFIG_NNEDI_FILTER 0 ++#define CONFIG_NOFORMAT_FILTER 0 ++#define CONFIG_NOISE_FILTER 0 ++#define CONFIG_NORMALIZE_FILTER 0 ++#define CONFIG_NULL_FILTER 0 ++#define CONFIG_OCR_FILTER 0 ++#define CONFIG_OCV_FILTER 0 ++#define CONFIG_OSCILLOSCOPE_FILTER 0 ++#define CONFIG_OVERLAY_FILTER 0 ++#define CONFIG_OVERLAY_OPENCL_FILTER 0 ++#define CONFIG_OVERLAY_QSV_FILTER 0 ++#define CONFIG_OVERLAY_VULKAN_FILTER 0 ++#define CONFIG_OVERLAY_CUDA_FILTER 0 ++#define CONFIG_OWDENOISE_FILTER 0 ++#define CONFIG_PAD_FILTER 0 ++#define CONFIG_PAD_OPENCL_FILTER 0 ++#define CONFIG_PALETTEGEN_FILTER 0 ++#define CONFIG_PALETTEUSE_FILTER 0 ++#define CONFIG_PERMS_FILTER 0 ++#define CONFIG_PERSPECTIVE_FILTER 0 ++#define CONFIG_PHASE_FILTER 0 ++#define CONFIG_PHOTOSENSITIVITY_FILTER 0 ++#define CONFIG_PIXDESCTEST_FILTER 0 ++#define CONFIG_PIXSCOPE_FILTER 0 ++#define CONFIG_PP_FILTER 0 ++#define CONFIG_PP7_FILTER 0 ++#define CONFIG_PREMULTIPLY_FILTER 0 ++#define CONFIG_PREWITT_FILTER 0 ++#define CONFIG_PREWITT_OPENCL_FILTER 0 ++#define CONFIG_PROCAMP_VAAPI_FILTER 0 ++#define CONFIG_PROGRAM_OPENCL_FILTER 0 ++#define CONFIG_PSEUDOCOLOR_FILTER 0 ++#define CONFIG_PSNR_FILTER 0 ++#define CONFIG_PULLUP_FILTER 0 ++#define CONFIG_QP_FILTER 0 ++#define CONFIG_RANDOM_FILTER 0 ++#define CONFIG_READEIA608_FILTER 0 ++#define CONFIG_READVITC_FILTER 0 ++#define CONFIG_REALTIME_FILTER 0 ++#define CONFIG_REMAP_FILTER 0 ++#define CONFIG_REMOVEGRAIN_FILTER 0 ++#define CONFIG_REMOVELOGO_FILTER 0 ++#define CONFIG_REPEATFIELDS_FILTER 0 ++#define CONFIG_REVERSE_FILTER 0 ++#define CONFIG_RGBASHIFT_FILTER 0 ++#define CONFIG_ROBERTS_FILTER 0 ++#define CONFIG_ROBERTS_OPENCL_FILTER 0 ++#define CONFIG_ROTATE_FILTER 0 ++#define CONFIG_SAB_FILTER 0 ++#define CONFIG_SCALE_FILTER 0 ++#define CONFIG_SCALE_CUDA_FILTER 0 ++#define CONFIG_SCALE_NPP_FILTER 0 ++#define CONFIG_SCALE_QSV_FILTER 0 ++#define CONFIG_SCALE_VAAPI_FILTER 0 ++#define CONFIG_SCALE_VULKAN_FILTER 0 ++#define CONFIG_SCALE2REF_FILTER 0 ++#define CONFIG_SCDET_FILTER 0 ++#define CONFIG_SCROLL_FILTER 0 ++#define CONFIG_SELECT_FILTER 0 ++#define CONFIG_SELECTIVECOLOR_FILTER 0 ++#define CONFIG_SENDCMD_FILTER 0 ++#define CONFIG_SEPARATEFIELDS_FILTER 0 ++#define CONFIG_SETDAR_FILTER 0 ++#define CONFIG_SETFIELD_FILTER 0 ++#define CONFIG_SETPARAMS_FILTER 0 ++#define CONFIG_SETPTS_FILTER 0 ++#define CONFIG_SETRANGE_FILTER 0 ++#define CONFIG_SETSAR_FILTER 0 ++#define CONFIG_SETTB_FILTER 0 ++#define CONFIG_SHARPNESS_VAAPI_FILTER 0 ++#define CONFIG_SHOWINFO_FILTER 0 ++#define CONFIG_SHOWPALETTE_FILTER 0 ++#define CONFIG_SHUFFLEFRAMES_FILTER 0 ++#define CONFIG_SHUFFLEPLANES_FILTER 0 ++#define CONFIG_SIDEDATA_FILTER 0 ++#define CONFIG_SIGNALSTATS_FILTER 0 ++#define CONFIG_SIGNATURE_FILTER 0 ++#define CONFIG_SMARTBLUR_FILTER 0 ++#define CONFIG_SOBEL_FILTER 0 ++#define CONFIG_SOBEL_OPENCL_FILTER 0 ++#define CONFIG_SPLIT_FILTER 0 ++#define CONFIG_SPP_FILTER 0 ++#define CONFIG_SR_FILTER 0 ++#define CONFIG_SSIM_FILTER 0 ++#define CONFIG_STEREO3D_FILTER 0 ++#define CONFIG_STREAMSELECT_FILTER 0 ++#define CONFIG_SUBTITLES_FILTER 0 ++#define CONFIG_SUPER2XSAI_FILTER 0 ++#define CONFIG_SWAPRECT_FILTER 0 ++#define CONFIG_SWAPUV_FILTER 0 ++#define CONFIG_TBLEND_FILTER 0 ++#define CONFIG_TELECINE_FILTER 0 ++#define CONFIG_THISTOGRAM_FILTER 0 ++#define CONFIG_THRESHOLD_FILTER 0 ++#define CONFIG_THUMBNAIL_FILTER 0 ++#define CONFIG_THUMBNAIL_CUDA_FILTER 0 ++#define CONFIG_TILE_FILTER 0 ++#define CONFIG_TINTERLACE_FILTER 0 ++#define CONFIG_TLUT2_FILTER 0 ++#define CONFIG_TMEDIAN_FILTER 0 ++#define CONFIG_TMIX_FILTER 0 ++#define CONFIG_TONEMAP_FILTER 0 ++#define CONFIG_TONEMAP_OPENCL_FILTER 0 ++#define CONFIG_TONEMAP_VAAPI_FILTER 0 ++#define CONFIG_TPAD_FILTER 0 ++#define CONFIG_TRANSPOSE_FILTER 0 ++#define CONFIG_TRANSPOSE_NPP_FILTER 0 ++#define CONFIG_TRANSPOSE_OPENCL_FILTER 0 ++#define CONFIG_TRANSPOSE_VAAPI_FILTER 0 ++#define CONFIG_TRIM_FILTER 0 ++#define CONFIG_UNPREMULTIPLY_FILTER 0 ++#define CONFIG_UNSHARP_FILTER 0 ++#define CONFIG_UNSHARP_OPENCL_FILTER 0 ++#define CONFIG_UNTILE_FILTER 0 ++#define CONFIG_USPP_FILTER 0 ++#define CONFIG_V360_FILTER 0 ++#define CONFIG_VAGUEDENOISER_FILTER 0 ++#define CONFIG_VECTORSCOPE_FILTER 0 ++#define CONFIG_VFLIP_FILTER 0 ++#define CONFIG_VFRDET_FILTER 0 ++#define CONFIG_VIBRANCE_FILTER 0 ++#define CONFIG_VIDSTABDETECT_FILTER 0 ++#define CONFIG_VIDSTABTRANSFORM_FILTER 0 ++#define CONFIG_VIGNETTE_FILTER 0 ++#define CONFIG_VMAFMOTION_FILTER 0 ++#define CONFIG_VPP_QSV_FILTER 0 ++#define CONFIG_VSTACK_FILTER 0 ++#define CONFIG_W3FDIF_FILTER 0 ++#define CONFIG_WAVEFORM_FILTER 0 ++#define CONFIG_WEAVE_FILTER 0 ++#define CONFIG_XBR_FILTER 0 ++#define CONFIG_XFADE_FILTER 0 ++#define CONFIG_XFADE_OPENCL_FILTER 0 ++#define CONFIG_XMEDIAN_FILTER 0 ++#define CONFIG_XSTACK_FILTER 0 ++#define CONFIG_YADIF_FILTER 0 ++#define CONFIG_YADIF_CUDA_FILTER 0 ++#define CONFIG_YAEPBLUR_FILTER 0 ++#define CONFIG_ZMQ_FILTER 0 ++#define CONFIG_ZOOMPAN_FILTER 0 ++#define CONFIG_ZSCALE_FILTER 0 ++#define CONFIG_ALLRGB_FILTER 0 ++#define CONFIG_ALLYUV_FILTER 0 ++#define CONFIG_CELLAUTO_FILTER 0 ++#define CONFIG_COLOR_FILTER 0 ++#define CONFIG_COREIMAGESRC_FILTER 0 ++#define CONFIG_FREI0R_SRC_FILTER 0 ++#define CONFIG_GRADIENTS_FILTER 0 ++#define CONFIG_HALDCLUTSRC_FILTER 0 ++#define CONFIG_LIFE_FILTER 0 ++#define CONFIG_MANDELBROT_FILTER 0 ++#define CONFIG_MPTESTSRC_FILTER 0 ++#define CONFIG_NULLSRC_FILTER 0 ++#define CONFIG_OPENCLSRC_FILTER 0 ++#define CONFIG_PAL75BARS_FILTER 0 ++#define CONFIG_PAL100BARS_FILTER 0 ++#define CONFIG_RGBTESTSRC_FILTER 0 ++#define CONFIG_SIERPINSKI_FILTER 0 ++#define CONFIG_SMPTEBARS_FILTER 0 ++#define CONFIG_SMPTEHDBARS_FILTER 0 ++#define CONFIG_TESTSRC_FILTER 0 ++#define CONFIG_TESTSRC2_FILTER 0 ++#define CONFIG_YUVTESTSRC_FILTER 0 ++#define CONFIG_NULLSINK_FILTER 0 ++#define CONFIG_ABITSCOPE_FILTER 0 ++#define CONFIG_ADRAWGRAPH_FILTER 0 ++#define CONFIG_AGRAPHMONITOR_FILTER 0 ++#define CONFIG_AHISTOGRAM_FILTER 0 ++#define CONFIG_APHASEMETER_FILTER 0 ++#define CONFIG_AVECTORSCOPE_FILTER 0 ++#define CONFIG_CONCAT_FILTER 0 ++#define CONFIG_SHOWCQT_FILTER 0 ++#define CONFIG_SHOWFREQS_FILTER 0 ++#define CONFIG_SHOWSPATIAL_FILTER 0 ++#define CONFIG_SHOWSPECTRUM_FILTER 0 ++#define CONFIG_SHOWSPECTRUMPIC_FILTER 0 ++#define CONFIG_SHOWVOLUME_FILTER 0 ++#define CONFIG_SHOWWAVES_FILTER 0 ++#define CONFIG_SHOWWAVESPIC_FILTER 0 ++#define CONFIG_SPECTRUMSYNTH_FILTER 0 ++#define CONFIG_AMOVIE_FILTER 0 ++#define CONFIG_MOVIE_FILTER 0 ++#define CONFIG_AFIFO_FILTER 0 ++#define CONFIG_FIFO_FILTER 0 ++#define CONFIG_AA_DEMUXER 0 ++#define CONFIG_AAC_DEMUXER 0 ++#define CONFIG_AC3_DEMUXER 0 ++#define CONFIG_ACM_DEMUXER 0 ++#define CONFIG_ACT_DEMUXER 0 ++#define CONFIG_ADF_DEMUXER 0 ++#define CONFIG_ADP_DEMUXER 0 ++#define CONFIG_ADS_DEMUXER 0 ++#define CONFIG_ADX_DEMUXER 0 ++#define CONFIG_AEA_DEMUXER 0 ++#define CONFIG_AFC_DEMUXER 0 ++#define CONFIG_AIFF_DEMUXER 0 ++#define CONFIG_AIX_DEMUXER 0 ++#define CONFIG_ALP_DEMUXER 0 ++#define CONFIG_AMR_DEMUXER 0 ++#define CONFIG_AMRNB_DEMUXER 0 ++#define CONFIG_AMRWB_DEMUXER 0 ++#define CONFIG_ANM_DEMUXER 0 ++#define CONFIG_APC_DEMUXER 0 ++#define CONFIG_APE_DEMUXER 0 ++#define CONFIG_APM_DEMUXER 0 ++#define CONFIG_APNG_DEMUXER 0 ++#define CONFIG_APTX_DEMUXER 0 ++#define CONFIG_APTX_HD_DEMUXER 0 ++#define CONFIG_AQTITLE_DEMUXER 0 ++#define CONFIG_ARGO_ASF_DEMUXER 0 ++#define CONFIG_ASF_DEMUXER 0 ++#define CONFIG_ASF_O_DEMUXER 0 ++#define CONFIG_ASS_DEMUXER 0 ++#define CONFIG_AST_DEMUXER 0 ++#define CONFIG_AU_DEMUXER 0 ++#define CONFIG_AV1_DEMUXER 0 ++#define CONFIG_AVI_DEMUXER 0 ++#define CONFIG_AVISYNTH_DEMUXER 0 ++#define CONFIG_AVR_DEMUXER 0 ++#define CONFIG_AVS_DEMUXER 0 ++#define CONFIG_AVS2_DEMUXER 0 ++#define CONFIG_BETHSOFTVID_DEMUXER 0 ++#define CONFIG_BFI_DEMUXER 0 ++#define CONFIG_BINTEXT_DEMUXER 0 ++#define CONFIG_BINK_DEMUXER 0 ++#define CONFIG_BIT_DEMUXER 0 ++#define CONFIG_BMV_DEMUXER 0 ++#define CONFIG_BFSTM_DEMUXER 0 ++#define CONFIG_BRSTM_DEMUXER 0 ++#define CONFIG_BOA_DEMUXER 0 ++#define CONFIG_C93_DEMUXER 0 ++#define CONFIG_CAF_DEMUXER 0 ++#define CONFIG_CAVSVIDEO_DEMUXER 0 ++#define CONFIG_CDG_DEMUXER 0 ++#define CONFIG_CDXL_DEMUXER 0 ++#define CONFIG_CINE_DEMUXER 0 ++#define CONFIG_CODEC2_DEMUXER 0 ++#define CONFIG_CODEC2RAW_DEMUXER 0 ++#define CONFIG_CONCAT_DEMUXER 0 ++#define CONFIG_DASH_DEMUXER 0 ++#define CONFIG_DATA_DEMUXER 0 ++#define CONFIG_DAUD_DEMUXER 0 ++#define CONFIG_DCSTR_DEMUXER 0 ++#define CONFIG_DERF_DEMUXER 0 ++#define CONFIG_DFA_DEMUXER 0 ++#define CONFIG_DHAV_DEMUXER 0 ++#define CONFIG_DIRAC_DEMUXER 0 ++#define CONFIG_DNXHD_DEMUXER 0 ++#define CONFIG_DSF_DEMUXER 0 ++#define CONFIG_DSICIN_DEMUXER 0 ++#define CONFIG_DSS_DEMUXER 0 ++#define CONFIG_DTS_DEMUXER 0 ++#define CONFIG_DTSHD_DEMUXER 0 ++#define CONFIG_DV_DEMUXER 0 ++#define CONFIG_DVBSUB_DEMUXER 0 ++#define CONFIG_DVBTXT_DEMUXER 0 ++#define CONFIG_DXA_DEMUXER 0 ++#define CONFIG_EA_DEMUXER 0 ++#define CONFIG_EA_CDATA_DEMUXER 0 ++#define CONFIG_EAC3_DEMUXER 0 ++#define CONFIG_EPAF_DEMUXER 0 ++#define CONFIG_FFMETADATA_DEMUXER 0 ++#define CONFIG_FILMSTRIP_DEMUXER 0 ++#define CONFIG_FITS_DEMUXER 0 ++#define CONFIG_FLAC_DEMUXER 1 ++#define CONFIG_FLIC_DEMUXER 0 ++#define CONFIG_FLV_DEMUXER 0 ++#define CONFIG_LIVE_FLV_DEMUXER 0 ++#define CONFIG_FOURXM_DEMUXER 0 ++#define CONFIG_FRM_DEMUXER 0 ++#define CONFIG_FSB_DEMUXER 0 ++#define CONFIG_FWSE_DEMUXER 0 ++#define CONFIG_G722_DEMUXER 0 ++#define CONFIG_G723_1_DEMUXER 0 ++#define CONFIG_G726_DEMUXER 0 ++#define CONFIG_G726LE_DEMUXER 0 ++#define CONFIG_G729_DEMUXER 0 ++#define CONFIG_GDV_DEMUXER 0 ++#define CONFIG_GENH_DEMUXER 0 ++#define CONFIG_GIF_DEMUXER 0 ++#define CONFIG_GSM_DEMUXER 0 ++#define CONFIG_GXF_DEMUXER 0 ++#define CONFIG_H261_DEMUXER 0 ++#define CONFIG_H263_DEMUXER 0 ++#define CONFIG_H264_DEMUXER 0 ++#define CONFIG_HCA_DEMUXER 0 ++#define CONFIG_HCOM_DEMUXER 0 ++#define CONFIG_HEVC_DEMUXER 0 ++#define CONFIG_HLS_DEMUXER 0 ++#define CONFIG_HNM_DEMUXER 0 ++#define CONFIG_ICO_DEMUXER 0 ++#define CONFIG_IDCIN_DEMUXER 0 ++#define CONFIG_IDF_DEMUXER 0 ++#define CONFIG_IFF_DEMUXER 0 ++#define CONFIG_IFV_DEMUXER 0 ++#define CONFIG_ILBC_DEMUXER 0 ++#define CONFIG_IMAGE2_DEMUXER 0 ++#define CONFIG_IMAGE2PIPE_DEMUXER 0 ++#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 0 ++#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 0 ++#define CONFIG_INGENIENT_DEMUXER 0 ++#define CONFIG_IPMOVIE_DEMUXER 0 ++#define CONFIG_IRCAM_DEMUXER 0 ++#define CONFIG_ISS_DEMUXER 0 ++#define CONFIG_IV8_DEMUXER 0 ++#define CONFIG_IVF_DEMUXER 0 ++#define CONFIG_IVR_DEMUXER 0 ++#define CONFIG_JACOSUB_DEMUXER 0 ++#define CONFIG_JV_DEMUXER 0 ++#define CONFIG_KUX_DEMUXER 0 ++#define CONFIG_KVAG_DEMUXER 0 ++#define CONFIG_LMLM4_DEMUXER 0 ++#define CONFIG_LOAS_DEMUXER 0 ++#define CONFIG_LRC_DEMUXER 0 ++#define CONFIG_LVF_DEMUXER 0 ++#define CONFIG_LXF_DEMUXER 0 ++#define CONFIG_M4V_DEMUXER 0 ++#define CONFIG_MCC_DEMUXER 0 ++#define CONFIG_MATROSKA_DEMUXER 1 ++#define CONFIG_MGSTS_DEMUXER 0 ++#define CONFIG_MICRODVD_DEMUXER 0 ++#define CONFIG_MJPEG_DEMUXER 0 ++#define CONFIG_MJPEG_2000_DEMUXER 0 ++#define CONFIG_MLP_DEMUXER 0 ++#define CONFIG_MLV_DEMUXER 0 ++#define CONFIG_MM_DEMUXER 0 ++#define CONFIG_MMF_DEMUXER 0 ++#define CONFIG_MOV_DEMUXER 1 ++#define CONFIG_MP3_DEMUXER 1 ++#define CONFIG_MPC_DEMUXER 0 ++#define CONFIG_MPC8_DEMUXER 0 ++#define CONFIG_MPEGPS_DEMUXER 0 ++#define CONFIG_MPEGTS_DEMUXER 0 ++#define CONFIG_MPEGTSRAW_DEMUXER 0 ++#define CONFIG_MPEGVIDEO_DEMUXER 0 ++#define CONFIG_MPJPEG_DEMUXER 0 ++#define CONFIG_MPL2_DEMUXER 0 ++#define CONFIG_MPSUB_DEMUXER 0 ++#define CONFIG_MSF_DEMUXER 0 ++#define CONFIG_MSNWC_TCP_DEMUXER 0 ++#define CONFIG_MTAF_DEMUXER 0 ++#define CONFIG_MTV_DEMUXER 0 ++#define CONFIG_MUSX_DEMUXER 0 ++#define CONFIG_MV_DEMUXER 0 ++#define CONFIG_MVI_DEMUXER 0 ++#define CONFIG_MXF_DEMUXER 0 ++#define CONFIG_MXG_DEMUXER 0 ++#define CONFIG_NC_DEMUXER 0 ++#define CONFIG_NISTSPHERE_DEMUXER 0 ++#define CONFIG_NSP_DEMUXER 0 ++#define CONFIG_NSV_DEMUXER 0 ++#define CONFIG_NUT_DEMUXER 0 ++#define CONFIG_NUV_DEMUXER 0 ++#define CONFIG_OBU_DEMUXER 0 ++#define CONFIG_OGG_DEMUXER 1 ++#define CONFIG_OMA_DEMUXER 0 ++#define CONFIG_PAF_DEMUXER 0 ++#define CONFIG_PCM_ALAW_DEMUXER 0 ++#define CONFIG_PCM_MULAW_DEMUXER 0 ++#define CONFIG_PCM_VIDC_DEMUXER 0 ++#define CONFIG_PCM_F64BE_DEMUXER 0 ++#define CONFIG_PCM_F64LE_DEMUXER 0 ++#define CONFIG_PCM_F32BE_DEMUXER 0 ++#define CONFIG_PCM_F32LE_DEMUXER 0 ++#define CONFIG_PCM_S32BE_DEMUXER 0 ++#define CONFIG_PCM_S32LE_DEMUXER 0 ++#define CONFIG_PCM_S24BE_DEMUXER 0 ++#define CONFIG_PCM_S24LE_DEMUXER 0 ++#define CONFIG_PCM_S16BE_DEMUXER 0 ++#define CONFIG_PCM_S16LE_DEMUXER 0 ++#define CONFIG_PCM_S8_DEMUXER 0 ++#define CONFIG_PCM_U32BE_DEMUXER 0 ++#define CONFIG_PCM_U32LE_DEMUXER 0 ++#define CONFIG_PCM_U24BE_DEMUXER 0 ++#define CONFIG_PCM_U24LE_DEMUXER 0 ++#define CONFIG_PCM_U16BE_DEMUXER 0 ++#define CONFIG_PCM_U16LE_DEMUXER 0 ++#define CONFIG_PCM_U8_DEMUXER 0 ++#define CONFIG_PJS_DEMUXER 0 ++#define CONFIG_PMP_DEMUXER 0 ++#define CONFIG_PP_BNK_DEMUXER 0 ++#define CONFIG_PVA_DEMUXER 0 ++#define CONFIG_PVF_DEMUXER 0 ++#define CONFIG_QCP_DEMUXER 0 ++#define CONFIG_R3D_DEMUXER 0 ++#define CONFIG_RAWVIDEO_DEMUXER 0 ++#define CONFIG_REALTEXT_DEMUXER 0 ++#define CONFIG_REDSPARK_DEMUXER 0 ++#define CONFIG_RL2_DEMUXER 0 ++#define CONFIG_RM_DEMUXER 0 ++#define CONFIG_ROQ_DEMUXER 0 ++#define CONFIG_RPL_DEMUXER 0 ++#define CONFIG_RSD_DEMUXER 0 ++#define CONFIG_RSO_DEMUXER 0 ++#define CONFIG_RTP_DEMUXER 0 ++#define CONFIG_RTSP_DEMUXER 0 ++#define CONFIG_S337M_DEMUXER 0 ++#define CONFIG_SAMI_DEMUXER 0 ++#define CONFIG_SAP_DEMUXER 0 ++#define CONFIG_SBC_DEMUXER 0 ++#define CONFIG_SBG_DEMUXER 0 ++#define CONFIG_SCC_DEMUXER 0 ++#define CONFIG_SDP_DEMUXER 0 ++#define CONFIG_SDR2_DEMUXER 0 ++#define CONFIG_SDS_DEMUXER 0 ++#define CONFIG_SDX_DEMUXER 0 ++#define CONFIG_SEGAFILM_DEMUXER 0 ++#define CONFIG_SER_DEMUXER 0 ++#define CONFIG_SHORTEN_DEMUXER 0 ++#define CONFIG_SIFF_DEMUXER 0 ++#define CONFIG_SLN_DEMUXER 0 ++#define CONFIG_SMACKER_DEMUXER 0 ++#define CONFIG_SMJPEG_DEMUXER 0 ++#define CONFIG_SMUSH_DEMUXER 0 ++#define CONFIG_SOL_DEMUXER 0 ++#define CONFIG_SOX_DEMUXER 0 ++#define CONFIG_SPDIF_DEMUXER 0 ++#define CONFIG_SRT_DEMUXER 0 ++#define CONFIG_STR_DEMUXER 0 ++#define CONFIG_STL_DEMUXER 0 ++#define CONFIG_SUBVIEWER1_DEMUXER 0 ++#define CONFIG_SUBVIEWER_DEMUXER 0 ++#define CONFIG_SUP_DEMUXER 0 ++#define CONFIG_SVAG_DEMUXER 0 ++#define CONFIG_SWF_DEMUXER 0 ++#define CONFIG_TAK_DEMUXER 0 ++#define CONFIG_TEDCAPTIONS_DEMUXER 0 ++#define CONFIG_THP_DEMUXER 0 ++#define CONFIG_THREEDOSTR_DEMUXER 0 ++#define CONFIG_TIERTEXSEQ_DEMUXER 0 ++#define CONFIG_TMV_DEMUXER 0 ++#define CONFIG_TRUEHD_DEMUXER 0 ++#define CONFIG_TTA_DEMUXER 0 ++#define CONFIG_TXD_DEMUXER 0 ++#define CONFIG_TTY_DEMUXER 0 ++#define CONFIG_TY_DEMUXER 0 ++#define CONFIG_V210_DEMUXER 0 ++#define CONFIG_V210X_DEMUXER 0 ++#define CONFIG_VAG_DEMUXER 0 ++#define CONFIG_VC1_DEMUXER 0 ++#define CONFIG_VC1T_DEMUXER 0 ++#define CONFIG_VIVIDAS_DEMUXER 0 ++#define CONFIG_VIVO_DEMUXER 0 ++#define CONFIG_VMD_DEMUXER 0 ++#define CONFIG_VOBSUB_DEMUXER 0 ++#define CONFIG_VOC_DEMUXER 0 ++#define CONFIG_VPK_DEMUXER 0 ++#define CONFIG_VPLAYER_DEMUXER 0 ++#define CONFIG_VQF_DEMUXER 0 ++#define CONFIG_W64_DEMUXER 0 ++#define CONFIG_WAV_DEMUXER 1 ++#define CONFIG_WC3_DEMUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 0 ++#define CONFIG_WEBVTT_DEMUXER 0 ++#define CONFIG_WSAUD_DEMUXER 0 ++#define CONFIG_WSD_DEMUXER 0 ++#define CONFIG_WSVQA_DEMUXER 0 ++#define CONFIG_WTV_DEMUXER 0 ++#define CONFIG_WVE_DEMUXER 0 ++#define CONFIG_WV_DEMUXER 0 ++#define CONFIG_XA_DEMUXER 0 ++#define CONFIG_XBIN_DEMUXER 0 ++#define CONFIG_XMV_DEMUXER 0 ++#define CONFIG_XVAG_DEMUXER 0 ++#define CONFIG_XWMA_DEMUXER 0 ++#define CONFIG_YOP_DEMUXER 0 ++#define CONFIG_YUV4MPEGPIPE_DEMUXER 0 ++#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_GIF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PGX_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_PSD_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SVG_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XPM_PIPE_DEMUXER 0 ++#define CONFIG_IMAGE_XWD_PIPE_DEMUXER 0 ++#define CONFIG_LIBGME_DEMUXER 0 ++#define CONFIG_LIBMODPLUG_DEMUXER 0 ++#define CONFIG_LIBOPENMPT_DEMUXER 0 ++#define CONFIG_VAPOURSYNTH_DEMUXER 0 ++#define CONFIG_A64_MUXER 0 ++#define CONFIG_AC3_MUXER 0 ++#define CONFIG_ADTS_MUXER 0 ++#define CONFIG_ADX_MUXER 0 ++#define CONFIG_AIFF_MUXER 0 ++#define CONFIG_AMR_MUXER 0 ++#define CONFIG_APM_MUXER 0 ++#define CONFIG_APNG_MUXER 0 ++#define CONFIG_APTX_MUXER 0 ++#define CONFIG_APTX_HD_MUXER 0 ++#define CONFIG_ARGO_ASF_MUXER 0 ++#define CONFIG_ASF_MUXER 0 ++#define CONFIG_ASS_MUXER 0 ++#define CONFIG_AST_MUXER 0 ++#define CONFIG_ASF_STREAM_MUXER 0 ++#define CONFIG_AU_MUXER 0 ++#define CONFIG_AVI_MUXER 0 ++#define CONFIG_AVM2_MUXER 0 ++#define CONFIG_AVS2_MUXER 0 ++#define CONFIG_BIT_MUXER 0 ++#define CONFIG_CAF_MUXER 0 ++#define CONFIG_CAVSVIDEO_MUXER 0 ++#define CONFIG_CODEC2_MUXER 0 ++#define CONFIG_CODEC2RAW_MUXER 0 ++#define CONFIG_CRC_MUXER 0 ++#define CONFIG_DASH_MUXER 0 ++#define CONFIG_DATA_MUXER 0 ++#define CONFIG_DAUD_MUXER 0 ++#define CONFIG_DIRAC_MUXER 0 ++#define CONFIG_DNXHD_MUXER 0 ++#define CONFIG_DTS_MUXER 0 ++#define CONFIG_DV_MUXER 0 ++#define CONFIG_EAC3_MUXER 0 ++#define CONFIG_F4V_MUXER 0 ++#define CONFIG_FFMETADATA_MUXER 0 ++#define CONFIG_FIFO_MUXER 0 ++#define CONFIG_FIFO_TEST_MUXER 0 ++#define CONFIG_FILMSTRIP_MUXER 0 ++#define CONFIG_FITS_MUXER 0 ++#define CONFIG_FLAC_MUXER 0 ++#define CONFIG_FLV_MUXER 0 ++#define CONFIG_FRAMECRC_MUXER 0 ++#define CONFIG_FRAMEHASH_MUXER 0 ++#define CONFIG_FRAMEMD5_MUXER 0 ++#define CONFIG_G722_MUXER 0 ++#define CONFIG_G723_1_MUXER 0 ++#define CONFIG_G726_MUXER 0 ++#define CONFIG_G726LE_MUXER 0 ++#define CONFIG_GIF_MUXER 0 ++#define CONFIG_GSM_MUXER 0 ++#define CONFIG_GXF_MUXER 0 ++#define CONFIG_H261_MUXER 0 ++#define CONFIG_H263_MUXER 0 ++#define CONFIG_H264_MUXER 0 ++#define CONFIG_HASH_MUXER 0 ++#define CONFIG_HDS_MUXER 0 ++#define CONFIG_HEVC_MUXER 0 ++#define CONFIG_HLS_MUXER 0 ++#define CONFIG_ICO_MUXER 0 ++#define CONFIG_ILBC_MUXER 0 ++#define CONFIG_IMAGE2_MUXER 0 ++#define CONFIG_IMAGE2PIPE_MUXER 0 ++#define CONFIG_IPOD_MUXER 0 ++#define CONFIG_IRCAM_MUXER 0 ++#define CONFIG_ISMV_MUXER 0 ++#define CONFIG_IVF_MUXER 0 ++#define CONFIG_JACOSUB_MUXER 0 ++#define CONFIG_KVAG_MUXER 0 ++#define CONFIG_LATM_MUXER 0 ++#define CONFIG_LRC_MUXER 0 ++#define CONFIG_M4V_MUXER 0 ++#define CONFIG_MD5_MUXER 0 ++#define CONFIG_MATROSKA_MUXER 0 ++#define CONFIG_MATROSKA_AUDIO_MUXER 0 ++#define CONFIG_MICRODVD_MUXER 0 ++#define CONFIG_MJPEG_MUXER 0 ++#define CONFIG_MLP_MUXER 0 ++#define CONFIG_MMF_MUXER 0 ++#define CONFIG_MOV_MUXER 0 ++#define CONFIG_MP2_MUXER 0 ++#define CONFIG_MP3_MUXER 0 ++#define CONFIG_MP4_MUXER 0 ++#define CONFIG_MPEG1SYSTEM_MUXER 0 ++#define CONFIG_MPEG1VCD_MUXER 0 ++#define CONFIG_MPEG1VIDEO_MUXER 0 ++#define CONFIG_MPEG2DVD_MUXER 0 ++#define CONFIG_MPEG2SVCD_MUXER 0 ++#define CONFIG_MPEG2VIDEO_MUXER 0 ++#define CONFIG_MPEG2VOB_MUXER 0 ++#define CONFIG_MPEGTS_MUXER 0 ++#define CONFIG_MPJPEG_MUXER 0 ++#define CONFIG_MXF_MUXER 0 ++#define CONFIG_MXF_D10_MUXER 0 ++#define CONFIG_MXF_OPATOM_MUXER 0 ++#define CONFIG_NULL_MUXER 0 ++#define CONFIG_NUT_MUXER 0 ++#define CONFIG_OGA_MUXER 0 ++#define CONFIG_OGG_MUXER 0 ++#define CONFIG_OGV_MUXER 0 ++#define CONFIG_OMA_MUXER 0 ++#define CONFIG_OPUS_MUXER 0 ++#define CONFIG_PCM_ALAW_MUXER 0 ++#define CONFIG_PCM_MULAW_MUXER 0 ++#define CONFIG_PCM_VIDC_MUXER 0 ++#define CONFIG_PCM_F64BE_MUXER 0 ++#define CONFIG_PCM_F64LE_MUXER 0 ++#define CONFIG_PCM_F32BE_MUXER 0 ++#define CONFIG_PCM_F32LE_MUXER 0 ++#define CONFIG_PCM_S32BE_MUXER 0 ++#define CONFIG_PCM_S32LE_MUXER 0 ++#define CONFIG_PCM_S24BE_MUXER 0 ++#define CONFIG_PCM_S24LE_MUXER 0 ++#define CONFIG_PCM_S16BE_MUXER 0 ++#define CONFIG_PCM_S16LE_MUXER 0 ++#define CONFIG_PCM_S8_MUXER 0 ++#define CONFIG_PCM_U32BE_MUXER 0 ++#define CONFIG_PCM_U32LE_MUXER 0 ++#define CONFIG_PCM_U24BE_MUXER 0 ++#define CONFIG_PCM_U24LE_MUXER 0 ++#define CONFIG_PCM_U16BE_MUXER 0 ++#define CONFIG_PCM_U16LE_MUXER 0 ++#define CONFIG_PCM_U8_MUXER 0 ++#define CONFIG_PSP_MUXER 0 ++#define CONFIG_RAWVIDEO_MUXER 0 ++#define CONFIG_RM_MUXER 0 ++#define CONFIG_ROQ_MUXER 0 ++#define CONFIG_RSO_MUXER 0 ++#define CONFIG_RTP_MUXER 0 ++#define CONFIG_RTP_MPEGTS_MUXER 0 ++#define CONFIG_RTSP_MUXER 0 ++#define CONFIG_SAP_MUXER 0 ++#define CONFIG_SBC_MUXER 0 ++#define CONFIG_SCC_MUXER 0 ++#define CONFIG_SEGAFILM_MUXER 0 ++#define CONFIG_SEGMENT_MUXER 0 ++#define CONFIG_STREAM_SEGMENT_MUXER 0 ++#define CONFIG_SINGLEJPEG_MUXER 0 ++#define CONFIG_SMJPEG_MUXER 0 ++#define CONFIG_SMOOTHSTREAMING_MUXER 0 ++#define CONFIG_SOX_MUXER 0 ++#define CONFIG_SPX_MUXER 0 ++#define CONFIG_SPDIF_MUXER 0 ++#define CONFIG_SRT_MUXER 0 ++#define CONFIG_STREAMHASH_MUXER 0 ++#define CONFIG_SUP_MUXER 0 ++#define CONFIG_SWF_MUXER 0 ++#define CONFIG_TEE_MUXER 0 ++#define CONFIG_TG2_MUXER 0 ++#define CONFIG_TGP_MUXER 0 ++#define CONFIG_MKVTIMESTAMP_V2_MUXER 0 ++#define CONFIG_TRUEHD_MUXER 0 ++#define CONFIG_TTA_MUXER 0 ++#define CONFIG_UNCODEDFRAMECRC_MUXER 0 ++#define CONFIG_VC1_MUXER 0 ++#define CONFIG_VC1T_MUXER 0 ++#define CONFIG_VOC_MUXER 0 ++#define CONFIG_W64_MUXER 0 ++#define CONFIG_WAV_MUXER 0 ++#define CONFIG_WEBM_MUXER 0 ++#define CONFIG_WEBM_DASH_MANIFEST_MUXER 0 ++#define CONFIG_WEBM_CHUNK_MUXER 0 ++#define CONFIG_WEBP_MUXER 0 ++#define CONFIG_WEBVTT_MUXER 0 ++#define CONFIG_WTV_MUXER 0 ++#define CONFIG_WV_MUXER 0 ++#define CONFIG_YUV4MPEGPIPE_MUXER 0 ++#define CONFIG_CHROMAPRINT_MUXER 0 ++#define CONFIG_ASYNC_PROTOCOL 0 ++#define CONFIG_BLURAY_PROTOCOL 0 ++#define CONFIG_CACHE_PROTOCOL 0 ++#define CONFIG_CONCAT_PROTOCOL 0 ++#define CONFIG_CRYPTO_PROTOCOL 0 ++#define CONFIG_DATA_PROTOCOL 0 ++#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 ++#define CONFIG_FFRTMPHTTP_PROTOCOL 0 ++#define CONFIG_FILE_PROTOCOL 0 ++#define CONFIG_FTP_PROTOCOL 0 ++#define CONFIG_GOPHER_PROTOCOL 0 ++#define CONFIG_HLS_PROTOCOL 0 ++#define CONFIG_HTTP_PROTOCOL 0 ++#define CONFIG_HTTPPROXY_PROTOCOL 0 ++#define CONFIG_HTTPS_PROTOCOL 0 ++#define CONFIG_ICECAST_PROTOCOL 0 ++#define CONFIG_MMSH_PROTOCOL 0 ++#define CONFIG_MMST_PROTOCOL 0 ++#define CONFIG_MD5_PROTOCOL 0 ++#define CONFIG_PIPE_PROTOCOL 0 ++#define CONFIG_PROMPEG_PROTOCOL 0 ++#define CONFIG_RTMP_PROTOCOL 0 ++#define CONFIG_RTMPE_PROTOCOL 0 ++#define CONFIG_RTMPS_PROTOCOL 0 ++#define CONFIG_RTMPT_PROTOCOL 0 ++#define CONFIG_RTMPTE_PROTOCOL 0 ++#define CONFIG_RTMPTS_PROTOCOL 0 ++#define CONFIG_RTP_PROTOCOL 0 ++#define CONFIG_SCTP_PROTOCOL 0 ++#define CONFIG_SRTP_PROTOCOL 0 ++#define CONFIG_SUBFILE_PROTOCOL 0 ++#define CONFIG_TEE_PROTOCOL 0 ++#define CONFIG_TCP_PROTOCOL 0 ++#define CONFIG_TLS_PROTOCOL 0 ++#define CONFIG_UDP_PROTOCOL 0 ++#define CONFIG_UDPLITE_PROTOCOL 0 ++#define CONFIG_UNIX_PROTOCOL 0 ++#define CONFIG_LIBAMQP_PROTOCOL 0 ++#define CONFIG_LIBRTMP_PROTOCOL 0 ++#define CONFIG_LIBRTMPE_PROTOCOL 0 ++#define CONFIG_LIBRTMPS_PROTOCOL 0 ++#define CONFIG_LIBRTMPT_PROTOCOL 0 ++#define CONFIG_LIBRTMPTE_PROTOCOL 0 ++#define CONFIG_LIBSRT_PROTOCOL 0 ++#define CONFIG_LIBSSH_PROTOCOL 0 ++#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 ++#define CONFIG_LIBZMQ_PROTOCOL 0 ++#endif /* FFMPEG_CONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/bsf_list.c +@@ -0,0 +1,3 @@ ++static const AVBitStreamFilter * const bitstream_filters[] = { ++ &ff_null_bsf, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/codec_list.c +@@ -0,0 +1,18 @@ ++static const AVCodec * const codec_list[] = { ++ &ff_theora_decoder, ++ &ff_vp3_decoder, ++ &ff_vp8_decoder, ++ &ff_flac_decoder, ++ &ff_mp3_decoder, ++ &ff_vorbis_decoder, ++ &ff_pcm_alaw_decoder, ++ &ff_pcm_f32le_decoder, ++ &ff_pcm_mulaw_decoder, ++ &ff_pcm_s16be_decoder, ++ &ff_pcm_s16le_decoder, ++ &ff_pcm_s24be_decoder, ++ &ff_pcm_s24le_decoder, ++ &ff_pcm_s32le_decoder, ++ &ff_pcm_u8_decoder, ++ &ff_libopus_decoder, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavcodec/parser_list.c +@@ -0,0 +1,9 @@ ++static const AVCodecParser * const parser_list[] = { ++ &ff_flac_parser, ++ &ff_mpegaudio_parser, ++ &ff_opus_parser, ++ &ff_vorbis_parser, ++ &ff_vp3_parser, ++ &ff_vp8_parser, ++ &ff_vp9_parser, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/demuxer_list.c +@@ -0,0 +1,8 @@ ++static const AVInputFormat * const demuxer_list[] = { ++ &ff_flac_demuxer, ++ &ff_matroska_demuxer, ++ &ff_mov_demuxer, ++ &ff_mp3_demuxer, ++ &ff_ogg_demuxer, ++ &ff_wav_demuxer, ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/muxer_list.c +@@ -0,0 +1,2 @@ ++static const AVOutputFormat * const muxer_list[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavformat/protocol_list.c +@@ -0,0 +1,2 @@ ++static const URLProtocol * const url_protocols[] = { ++ NULL }; +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chromium/linux/riscv64/libavutil/avconfig.h +@@ -0,0 +1,6 @@ ++/* Generated by ffmpeg configure */ ++#ifndef AVUTIL_AVCONFIG_H ++#define AVUTIL_AVCONFIG_H ++#define AV_HAVE_BIGENDIAN 0 ++#define AV_HAVE_FAST_UNALIGNED 0 ++#endif /* AVUTIL_AVCONFIG_H */ +--- /dev/null ++++ b/src/3rdparty/chromium/third_party/ffmpeg/chromium/config/Chrome/linux/riscv64/libavutil/ffversion.h +@@ -0,0 +1,5 @@ ++/* Automatically generated by version.sh, do not manually edit! */ ++#ifndef AVUTIL_FFVERSION_H ++#define AVUTIL_FFVERSION_H ++#define FFMPEG_VERSION "N-99931-gb6530ca24d" ++#endif /* AVUTIL_FFVERSION_H */ +--- a/src/3rdparty/chromium/base/BUILD.gn ++++ b/src/3rdparty/chromium/base/BUILD.gn +@@ -1308,7 +1308,7 @@ + # Needed for if using newer C++ library than sysroot, except if + # building inside the cros_sdk environment - use host_toolchain as a + # more robust check for this. +- if (!use_sysroot && ++ if (current_cpu == "riscv64" || !use_sysroot && + (is_android || ((is_linux || is_chromeos) && !is_chromecast && !use_qt)) && + host_toolchain != "//build/toolchain/cros:host") { + libs += [ "atomic" ] diff --git a/debian/patches/fix-regexp-loongarch64-stack-check.patch b/debian/patches/fix-regexp-loongarch64-stack-check.patch new file mode 100644 index 0000000000..ed50d28d3d --- /dev/null +++ b/debian/patches/fix-regexp-loongarch64-stack-check.patch @@ -0,0 +1,50 @@ +From: https://github.com/v8/v8/commit/1ec3c714bf75f01e +From: lichenggang +Date: Mon, 28 Aug 2024 08:44:28 +0800 +Subject: [PATCH] fix egexp loongarch64 stack check + + + +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.cc +@@ -669,6 +669,7 @@ Handle RegExpMacroAssemblerL + + ExternalReference stack_limit = + ExternalReference::address_of_jslimit(masm_->isolate()); ++ Operand extra_space_for_variables(num_registers_ * kSystemPointerSize); + __ li(a0, Operand(stack_limit)); + __ Ld_d(a0, MemOperand(a0, 0)); + __ Sub_d(a0, sp, a0); +@@ -1135,7 +1136,7 @@ int64_t RegExpMacroAssemblerLA64::CheckS + return_address, re_code, + frame_entry_address
(re_frame, kInputString), + frame_entry_address(re_frame, kInputStart), +- frame_entry_address(re_frame, kInputEndOffset), ++ frame_entry_address(re_frame, kInputEnd), + extra_space); + } + +@@ -1212,7 +1213,6 @@ void RegExpMacroAssemblerLA64::CheckPree + // Check for preemption. + ExternalReference stack_limit = + ExternalReference::address_of_jslimit(masm_->isolate()); +- Operand extra_space_for_variables(num_registers_ * kSystemPointerSize); + __ li(a0, Operand(stack_limit)); + __ Ld_d(a0, MemOperand(a0, 0)); + SafeCall(&check_preempt_label_, ls, sp, Operand(a0)); +@@ -1253,3 +1253,4 @@ void RegExpMacroAssemblerLA64::LoadCurre + } // namespace internal + } // namespace v8 + ++#endif //V8_TARGET_ARCH_LOONGARCH64 +--- qtwebengine-opensource-src-5.15.17+dfsg.orig/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h ++++ qtwebengine-opensource-src-5.15.17+dfsg/src/3rdparty/chromium/v8/src/regexp/loongarch64/regexp-macro-assembler-loongarch64.h +@@ -132,7 +132,7 @@ class V8_EXPORT_PRIVATE RegExpMacroAssem + + // Generate a call to CheckStackGuardState. + void CallCheckStackGuardState(Register scratch, +- Operand extra_space = Operand(0)); ++ Operand extra_space_for_variables = Operand(0)); + // The ebp-relative location of a regexp register. + MemOperand register_location(int register_index); + diff --git a/debian/rules b/debian/rules index 8c23562141..22f5bce01d 100755 --- a/debian/rules +++ b/debian/rules @@ -61,9 +61,24 @@ touch_files = src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/ src/3rdparty/chromium/third_party/devtools-frontend/src/front_end/third_party/acorn/package/dist/acorn.js \ src/3rdparty/chromium/third_party/web-animations-js/sources/web-animations-next-lite.min.js +ifeq (loong64, $(DEB_HOST_ARCH)) + TARGET_PATCH = patch_loong64 +else ifeq (riscv64, $(DEB_HOST_ARCH)) + TARGET_PATCH = patch_riscv64 +endif + +patch_loong64: + patch -p1 < debian/patches/Port-for-loongarch64.patch + patch -p1 < debian/patches/fix-regexp-loongarch64-stack-check.patch +patch_riscv64: + patch -p1 < debian/patches/add-riscv64-support.patch + %: dh $@ --with pkgkde_symbolshelper +override_dh_autoreconf: $(TARGET_PATCH) + dh_autoreconf + override_dh_auto_clean: dh_auto_clean